Attempts to read null
value from an Input
.
Attempts to read null
value from an Input
. Returning true
means that input instance contained a
null
value. Its state should then be changed so that input can be considered "consumed"
(no other reads are possible on this instance). Returning false
means that the input contains something else
than a null
value. Its state must not change in this situation and it must be possible to call some other
read method on it.
Ignores this input and skips its contents internally, if necessary
This ugly workaround has been introduced when standard Option
encoding changed from zero-or-one element list
encoding to unwrapped-or-null encoding which effectively disallowed serializing null
and Some(null)
.
This ugly workaround has been introduced when standard Option
encoding changed from zero-or-one element list
encoding to unwrapped-or-null encoding which effectively disallowed serializing null
and Some(null)
.
If some Input
implementation still wants to use the list encoding, it may do it by overriding this method
and returning true
.
Attempts to read some arbitrary custom "native" value that this input may or may not support.
Attempts to read some arbitrary custom "native" value that this input may or may not support.
The custom type is identified by an instance of TypeMarker
which is usually an object (e.g. companion
object of the custom T
type itself). This way Input
and Output
implementations may support other
native types than the ones supported by default by Input
and Output
interfaces.
Codecs may use this method to optimize encoded format in case it it possible with particular Input
implementation. GenCodec
may generally assume that if the data was written by a corresponding Output
which also support this custom native type then readCustom
should return non-empty value.
Opt.Empty
returned by this method indicates that this input does not support this particular type.
If it supports it but there was some error reading it then a ReadFailure
should be thrown instead of
returning Opt.Empty
.
Attempts to read some arbitrary "metadata" about this input instance.
Attempts to read some arbitrary "metadata" about this input instance. Metadata is identified by
InputMetadata which is usually an object
(e.g. companion object of metadata value type T
).
An example of InputMetadata is
JsonType supported by
JsonStringInput.
Codecs may use this method to optimize encoded format in case it it possible with particular Input
implementation. GenCodec
may generally assume that if the data was written by a corresponding Output
that preserves particular metadata type (which may be determined by Output.keepsMetadata()
) then
readMetadata
will return a non-empty value.
Opt.Empty
may be returned form this method ONLY if this Input
implementation does not support
this metadata type AT ALL. Any errors should be signaled by throwing ReadFailure
.
Represents an abstract source from which a value may be deserialized (read). Each of the
read
methods tries to read a value of specified type and may throw an exception (usually ReadFailure) when reading is not successful.An
Input
value should be assumed to be stateful. If any of thereadX
methods have already been called, theInput
instance can no longer be used and MUST be discarded.In order to ignore the value kept in this
Input
,skip()
MUST be called.In summary: every
Input
MUST be fully exhausted by either calling one of theread
methods which returns successful value or by callingskip()
. Also, ListInput and ObjectInput instances returned from thisInput
must also be fully exhausted on their own.