Skip to main content

ValueStrategy

Trait ValueStrategy 

Source
pub trait ValueStrategy<T>:
    Send
    + Sync
    + Clone {
    const IS_NATIVE_LAYOUT: bool = false;

    // Required methods
    fn read(bytes: &[u8]) -> Result<T>;
    fn write_to_vec(value: &T, buf: &mut Vec<u8>);
    fn write_to_slice(value: &T, dst: &mut [u8]);
}
Expand description

Value serialization strategy shared by all vec types (raw and compressed).

Handles reading/writing individual values to/from bytes.

Provided Associated Constants§

Source

const IS_NATIVE_LAYOUT: bool = false

Whether T has native memory layout (can be memcpy’d to/from bytes).

Required Methods§

Source

fn read(bytes: &[u8]) -> Result<T>

Deserializes a value from its byte representation.

Source

fn write_to_vec(value: &T, buf: &mut Vec<u8>)

Serializes a value by appending its byte representation to the buffer.

Source

fn write_to_slice(value: &T, dst: &mut [u8])

Serializes a value directly into a fixed-size slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> ValueStrategy<T> for LZ4Strategy<T>
where T: LZ4VecValue,

Source§

const IS_NATIVE_LAYOUT: bool = T::IS_NATIVE_LAYOUT

Source§

impl<T> ValueStrategy<T> for PcodecStrategy<T>
where T: PcoVecValue,

Source§

const IS_NATIVE_LAYOUT: bool = T::IS_NATIVE_LAYOUT

Source§

impl<T> ValueStrategy<T> for ZstdStrategy<T>
where T: ZstdVecValue,

Source§

const IS_NATIVE_LAYOUT: bool = T::IS_NATIVE_LAYOUT

Source§

impl<T: BytesVecValue> ValueStrategy<T> for BytesStrategy<T>

Source§

const IS_NATIVE_LAYOUT: bool = T::IS_NATIVE_LAYOUT

Source§

impl<T: ZeroCopyVecValue> ValueStrategy<T> for ZeroCopyStrategy<T>