pub trait ArrayPlugin:
'static
+ Send
+ Sync {
// Required methods
fn id(&self) -> ArrayId;
fn serialize(
&self,
array: &ArrayRef,
session: &VortexSession,
) -> VortexResult<Option<Vec<u8>>>;
fn deserialize(
&self,
dtype: &DType,
len: usize,
metadata: &[u8],
buffers: &[BufferHandle],
children: &dyn ArrayChildren,
session: &VortexSession,
) -> VortexResult<ArrayRef>;
// Provided method
fn is_supported_encoding(&self, id: &ArrayId) -> bool { ... }
}Expand description
Registry trait for ID-based deserialization of arrays.
Plugins are registered in the session by their ArrayId. When a serialized array is
encountered, the session resolves the ID to the plugin and calls deserialize to reconstruct
the value as an ArrayRef.
Required Methods§
Sourcefn id(&self) -> ArrayId
fn id(&self) -> ArrayId
Returns the ID for this array encoding.
During serde, this is the key the registry uses to find this plugin instance and call the appropriate method on it.
Sourcefn serialize(
&self,
array: &ArrayRef,
session: &VortexSession,
) -> VortexResult<Option<Vec<u8>>>
fn serialize( &self, array: &ArrayRef, session: &VortexSession, ) -> VortexResult<Option<Vec<u8>>>
Serialize the array metadata.
This function will only be called for arrays where the encoding ID matches that of this plugin.
Sourcefn deserialize(
&self,
dtype: &DType,
len: usize,
metadata: &[u8],
buffers: &[BufferHandle],
children: &dyn ArrayChildren,
session: &VortexSession,
) -> VortexResult<ArrayRef>
fn deserialize( &self, dtype: &DType, len: usize, metadata: &[u8], buffers: &[BufferHandle], children: &dyn ArrayChildren, session: &VortexSession, ) -> VortexResult<ArrayRef>
Deserialize an array from serialized components.
The returned array doesn’t necessary have to match this plugin’s encoding ID. This is useful for implementing back-compat logic and deserializing arrays into the new version.
Provided Methods§
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.