pub trait ArrayPlugin:
'static
+ Send
+ Sync {
// Required methods
fn id(&self) -> ArrayId;
fn serialize(
&self,
array: &ArrayRef,
session: &VortexSession,
) -> VortexResult<Option<ArraySerialization>>;
fn deserialize(
&self,
parts: ArrayDeserialization<'_>,
session: &VortexSession,
) -> VortexResult<ArrayRef>;
// Provided methods
fn serialized_ids(&self) -> Vec<ArrayId> ⓘ { ... }
fn is_supported_encoding(&self, id: &ArrayId) -> bool { ... }
}Expand description
Registry trait for serializing and deserializing an in-memory array representation.
A plugin has one id for the in-memory representation and one or more
serialized_ids for wire representations. Its serializer chooses the
wire representation, and the serialization context validates that the chosen ID is permitted
before it is written.
Every serialized ID is also registered for deserialization. A current plugin may therefore deserialize several historical IDs into the same in-memory representation. A reader that predates a newer ID has no registration for it and reports it as unknown instead of silently interpreting an unsupported representation.
Required Methods§
Sourcefn id(&self) -> ArrayId
fn id(&self) -> ArrayId
Returns the ID of the in-memory array representation handled by this plugin.
Sourcefn serialize(
&self,
array: &ArrayRef,
session: &VortexSession,
) -> VortexResult<Option<ArraySerialization>>
fn serialize( &self, array: &ArrayRef, session: &VortexSession, ) -> VortexResult<Option<ArraySerialization>>
Serialize array to its wire representation.
This function is called only for arrays whose in-memory encoding matches id.
The returned ID must be declared by serialized_ids. Return
Ok(None) when the array cannot be serialized.
Sourcefn deserialize(
&self,
parts: ArrayDeserialization<'_>,
session: &VortexSession,
) -> VortexResult<ArrayRef>
fn deserialize( &self, parts: ArrayDeserialization<'_>, session: &VortexSession, ) -> VortexResult<ArrayRef>
Deserialize one recognized wire representation into the current in-memory array.
serialized_id identifies the exact representation encountered on disk. The returned
array does not necessarily have to use this plugin’s in-memory ID; this supports legacy
representations that are normalized into another current in-memory array. Implementations
must validate the contract of that exact ID rather than accepting every form understood by
the current in-memory representation under an older ID.
Provided Methods§
Sourcefn serialized_ids(&self) -> Vec<ArrayId> ⓘ
fn serialized_ids(&self) -> Vec<ArrayId> ⓘ
Returns the serialized array IDs understood by this plugin, ordered oldest to newest.
The default uses the in-memory ID as the sole wire ID. Override this for an in-memory array that has multiple serialized variants. IDs retained only for reading may also be included; the single serializer need not select them.
Sourcefn is_supported_encoding(&self, id: &ArrayId) -> bool
fn is_supported_encoding(&self, id: &ArrayId) -> bool
Can this plugin emit an array with the given encoding.
By default, this is just the ID of the plugin, but can be overridden if this plugin instance supports reading/writing multiple arrays.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".