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§
Sourceconst IS_NATIVE_LAYOUT: bool = false
const IS_NATIVE_LAYOUT: bool = false
Whether T has native memory layout (can be memcpy’d to/from bytes).
Required Methods§
Sourcefn write_to_vec(value: &T, buf: &mut Vec<u8>)
fn write_to_vec(value: &T, buf: &mut Vec<u8>)
Serializes a value by appending its byte representation to the buffer.
Sourcefn write_to_slice(value: &T, dst: &mut [u8])
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.