A dynamic pickler for type T
.
A dynamic pickler for type T
. Its pickle
method takes an object-to-be-pickled of
static type T
, and pickles it to an instance of PBuilder
. In the process the object
is turned into some external representation like a byte array. The particular external
representation (the "pickle format") is defined by the builder
.
In contrast to static picklers (instances of type Pickler[T]
), a dynamic pickler of
type DPickler[T]
pickles any object of type T
.
Hintable defines the interface used between picklers and formats to "aide' in creating clean/efficient formats.
Hintable defines the interface used between picklers and formats to "aide' in creating clean/efficient formats.
The FULL features picklers allow: - eliding statically known types - structural sharing of data - possible binary size optimizations (using jvm sizes)
Obviously not all picklers will use these mechanisms.
If a pickler/unpickler calls hintKnownSize
, it's talking about a binary size of the following entry.
----
If a pickler/unpickler call hintElidedType
, it's allowing the underlying format to 'drop' the forced storage of a
type tag.
----
If a pickler/unpickler calls hintOid
, it's telling the underlying format that this particular pickler entry
shares it structure with the same entry of that number.
Currently, rather than using known tags, picklers assume a per-pickle ordinal associated with each entry. This ordinal should be automatically tracked and restored.
A layer of protocol stack that can "lift" picklable types to have the core pickle operations.
A layer of protocol stack that can "lift" picklable types to have the core pickle operations.
For example usage, see scala.pickling.Defaults
A builder of pickled content.
A builder of pickled content. This is a mutable API, intended to be called in certain specific ways.
Here are a few static rules that all picklers must follow when using this interface.
1. There will be one endEntry() for every beginEntry() call. 2. There will be one endCollection() for every beginCollection() call. 3. Every beginCollection()/endCollection() pair will be inside a beginEntry()/endEntry() pair. 4. Every putElement() call must happen within a beginCollection()/endCollection() block. 5. Every putField() call must happen within a beginEntry()/endEntry() block. 6. There is no guarantee that putElement() will be called within a beginCollectoin()/endCollection() pair. i.e. we can write empty collections. 7. There is no guarantee that putField will be called within a beginEntry()/endEntry() pair. i.e. if we don't put any fields, this means the entry was for a "primitive" type, at least what The pickling library considers primitives. 8. The order of putField calls in any pickler will be the exact same ordering when unpickling, if the format is compatible.
Here is a list of all types the auto-generated Picklers considers "primitives" and must be directly supported by any PBuilder:
A reader of pickled content.
A reader of pickled content. This is a mutable API, intended to be called in certain specific ways.
Here are a few static rules that all picklers must follow when using this interface.
1. There will be one endEntry() for every beginEntry() call. 2. There will be one endCollection() for every beginCollection() call. 3. Every beginCollection()/endCollection() pair will be inside a beginEntry()/endEntry() pair. 4. Every readLength() call will be immediately after a beginCollection() call. 5. Every readElement() call must happen within a beginCollection()/endCollection() block, and after a readLength(). 6. Every readField() call must happen within a beginEntry()/endEntry() block. 7. If readLength() returns 0, there will be no called to readElement(). 8. readField() will only be called where atObject would return true 9. readPrimitive will only be called when atPrimitive would return true 10. The order of readField calls in any pickler will be the exact same ordering when pickling,
Here is a list of all types the auto-generated Picklers considers "primitives" and must be directly supported by any PReader "readPrimitive" operation:
Holds the serialized representation of a value, such as an Array[Byte]
.
Holds the serialized representation of a value, such as an Array[Byte]
.
A Pickle
is only returned by PickleOps.pickle
. A directly-streamed PBuilder
must be used together with
PickleOps.pickleTo
or PickleOps.pickleInto
which return Unit
instead of a pickle.
When unpickling from a stream, a subclass such as BinaryInputPickle
is used, which initializes the value
to a dummy value. TODO - we may want to rethink this interface.
A format for how to pickle the structure of an object.
Appends the pickle/pickleTo/pickleInto operations onto any type, assuming implicits picklers are available.
A static pickler for type T
.
A static pickler for type T
. Its pickle
method takes an object-to-be-pickled of
static type T
, and pickles it to an instance of PBuilder
. In the process the object
is turned into some external representation like a byte array. The particular external
representation (the "pickle format") is defined by the builder
.
This pickler requires that the dynamic type of the object-to-be-pickled is equal to
the erasure of its static type T
.
This is something which knowns how to reconstitute/materialize a type out of a pickle reader.
This is something which knowns how to reconstitute/materialize a type out of a pickle reader.
Import scala.pickling.Defaults._
to introduce all picklers and ops.