Interface StreamingDeserializer<T>
-
- Type Parameters:
T
- Type of object to be deserialized.
- All Superinterfaces:
java.lang.AutoCloseable
,GracefulAutoCloseable
public interface StreamingDeserializer<T> extends GracefulAutoCloseable
A contract capable of deserializing a stream ofBuffer
s into a stream ofStreamingDeserializer
s. This interface is designed to be used as a function that can convert aBuffer
into aStreamingDeserializer
.deserialize(Buffer)
maybe called multiple times.Implementations are assumed to be stateful since a single
Buffer
may not hold enough data to deserialize an entire object. It is expected thatdeserialize(Buffer)
ordeserialize(Iterable)
may be called multiple times to deserialize a single instance ofStreamingDeserializer
as more data is available.Implementations are assumed to be synchronous.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Disposes thisStreamingDeserializer
.java.lang.Iterable<T>
deserialize(Buffer toDeserialize)
default BlockingIterable<T>
deserialize(BlockingIterable<Buffer> toDeserialize)
Deserialize the passedBlockingIterable
ofBuffer
s into aBlockingIterable
ofStreamingDeserializer
s.default java.lang.Iterable<T>
deserialize(java.lang.Iterable<Buffer> toDeserialize)
boolean
hasData()
Returnstrue
if thisStreamingDeserializer
contains any data from a previous invocation ofdeserialize(Buffer)
that has not yet been deserialized.-
Methods inherited from interface io.servicetalk.concurrent.GracefulAutoCloseable
closeGracefully
-
-
-
-
Method Detail
-
deserialize
java.lang.Iterable<T> deserialize(Buffer toDeserialize)
Deserialize the passedBuffer
into anIterable
ofStreamingDeserializer
s. If thisBuffer
and any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializer
then the returnedIterable
will be empty, i.e. the returnedIterator
fromIterable.iterator()
will always returnfalse
fromIterator.hasNext()
.It is assumed that a single instance of
StreamingDeserializer
may receive calls to both this method anddeserialize(Iterable)
. Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize
-Buffer
to deserialize.- Returns:
Iterable
containing zero or more deserialized instances ofStreamingDeserializer
, if any can be deserialized from the data received till now.
-
deserialize
default java.lang.Iterable<T> deserialize(java.lang.Iterable<Buffer> toDeserialize)
Deserialize the passedIterable
ofBuffer
s into anIterable
ofStreamingDeserializer
s. If theseBuffer
s and any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializer
then the returnedIterable
will be empty, i.e. the returnedIterator
fromIterable.iterator()
will always returnfalse
fromIterator.hasNext()
.It is assumed that a single instance of
StreamingDeserializer
may receive calls to both this method anddeserialize(Buffer)
. Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize
-Iterable
ofBuffer
s to deserialize.- Returns:
Iterable
containing zero or more deserialized instances ofStreamingDeserializer
, if any can be deserialized from the data received till now.
-
deserialize
default BlockingIterable<T> deserialize(BlockingIterable<Buffer> toDeserialize)
Deserialize the passedBlockingIterable
ofBuffer
s into aBlockingIterable
ofStreamingDeserializer
s. If theseBuffer
s and any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializer
then the returnedBlockingIterable
will be empty, i.e. the returnedBlockingIterable
fromBlockingIterable.iterator()
will always returnfalse
fromIterator.hasNext()
.It is assumed that a single instance of
StreamingDeserializer
may receive calls to both this method anddeserialize(Buffer)
. Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize
-BlockingIterable
ofBuffer
s to deserialize.- Returns:
BlockingIterable
containing zero or more deserialized instances ofStreamingDeserializer
, if any can be deserialized from the data received till now.
-
hasData
boolean hasData()
Returnstrue
if thisStreamingDeserializer
contains any data from a previous invocation ofdeserialize(Buffer)
that has not yet been deserialized.- Returns:
true
if thisStreamingDeserializer
contains any data from a previous invocation ofdeserialize(Buffer)
that has not yet been deserialized.
-
close
void close()
Disposes thisStreamingDeserializer
. If there is any left-over data left in thisStreamingDeserializer
from a previous call todeserialize(Buffer)
which has not been consumed, this method should throw anSerializationException
to indicate that there is more data that is going to be disposed.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
SerializationException
- If there is some over data left but not consumed as returned byhasData()
.
-
-