Package io.servicetalk.serializer.utils
Class StringSerializer
java.lang.Object
io.servicetalk.serializer.utils.StringSerializer
- All Implemented Interfaces:
Deserializer<String>,Serializer<String>,SerializerDeserializer<String>
-
Method Summary
Modifier and TypeMethodDescriptionfinal Stringdeserialize(Buffer serializedData, BufferAllocator allocator) Deserialize the contents from theBufferparameter.final Bufferserialize(String toSerialize, BufferAllocator allocator) Serialize theSerializerparameter to aBuffer.voidserialize(String toSerialize, BufferAllocator allocator, Buffer buffer) Serialize theSerializerparameter to theBufferparameter.static SerializerDeserializer<String>stringSerializer(Charset charset) Create a new instance.
-
Method Details
-
stringSerializer
Create a new instance.- Parameters:
charset- The charset used for encoding.- Returns:
- A serializer that uses
charsetfor encoding.
-
deserialize
Description copied from interface:DeserializerDeserialize the contents from theBufferparameter.The caller is responsible for assuming the buffer contents contains enough
Buffer.readableBytes()to successfully deserialize.- Specified by:
deserializein interfaceDeserializer<String>- Parameters:
serializedData-BufferwhoseBuffer.readableBytes()contains a serialized object. TheBuffer.readerIndex()will be advanced to indicate the content which has been consumed.allocator- Used to allocate intermediateBuffers if required.- Returns:
- The result of the deserialization.
-
serialize
Description copied from interface:SerializerSerialize theSerializerparameter to aBuffer.- Specified by:
serializein interfaceSerializer<String>- Parameters:
toSerialize- TheSerializerto serialize.allocator- Used to allocate the buffer to serialize to.- Returns:
- The results of the serialization.
-
serialize
Description copied from interface:SerializerSerialize theSerializerparameter to theBufferparameter.- Specified by:
serializein interfaceSerializer<String>- Parameters:
toSerialize- TheSerializerto serialize.allocator- Used to allocate intermediateBuffers if required.buffer- Where the results of the serialization will be written to.
-