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 read_ids(&self) -> Vec<ArrayId> { ... }
fn write_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 writes one in-memory encoding, identified by id. It declares the wire
IDs that it reads and writes separately, so it can write another encoding’s wire form without
replacing that encoding’s reader. The serialization context validates that the chosen wire ID
is permitted before it is written.
A plugin can retain historical read IDs after it stops writing them. A reader that predates a newer ID has no registration for it and reports it as unknown.
Required Methods§
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.
The session calls this only for arrays whose in-memory encoding matches id.
Implementations in this crate check that as well, so a direct caller gets an error rather
than a panic from the downcast.
The returned ID must be declared by write_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 session only
routes IDs from read_ids here; implementations in this crate check it as
well, so a direct caller gets an error rather than a misread array. 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 read_ids(&self) -> Vec<ArrayId>
fn read_ids(&self) -> Vec<ArrayId>
Returns the wire IDs that deserialize accepts, oldest to newest.
ArraySession::register makes this plugin the
reader of each ID. An ID can stay in this list after the plugin stops writing it, so that
old files stay readable.
By default, a plugin reads only its in-memory id.
Sourcefn write_ids(&self) -> Vec<ArrayId>
fn write_ids(&self) -> Vec<ArrayId>
Returns the wire IDs that serialize may return.
An ID in this list does not have to be in read_ids. A plugin can write
its arrays in the wire form of another encoding. The plugin that owns that form reads it.
The node must hold the logical values of the array under the dtype of the array.
By default, a plugin writes only its in-memory id.
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".