Skip to main content

AnyVec

Trait AnyVec 

Source
pub trait AnyVec:
    Any
    + Send
    + Sync {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn swap_remove_any(&mut self, index: usize);
    fn to_bytes(&self) -> Vec<u8> ;
    unsafe fn set_from_bytes(
        &mut self,
        bytes: &[u8],
    ) -> Result<(), SetFromBytesError>;
}
Expand description

An internal helper trait to perform vector operations on a type-erased Box<dyn Any>.

This allows us to call methods like swap_remove on component columns without needing to know their concrete Vec<T> type at compile time.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Casts the trait object to &dyn Any.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Casts the trait object to &mut dyn Any.

Source

fn swap_remove_any(&mut self, index: usize)

Performs a swap_remove on the underlying column, removing the element at index.

Source

fn to_bytes(&self) -> Vec<u8>

Serialises the column to an owned byte buffer.

Returns an owned Vec<u8> (not a borrowed slice) so that columns whose data is not a single contiguous buffer — e.g. a field-split SoA column — can materialise their bytes. The format is the column’s own concern; the only contract is that set_from_bytes on the same column type reverses it.

Source

unsafe fn set_from_bytes( &mut self, bytes: &[u8], ) -> Result<(), SetFromBytesError>

Replaces the column contents from bytes previously produced by to_bytes on the same column type.

The length is validated against the column’s element size and against MAX_COLUMN_PAYLOAD_BYTES before any allocation, so untrusted input cannot force an out-of-memory abort; a malformed length returns SetFromBytesError and leaves the column unchanged.

§Safety

The caller must guarantee the bytes match this column’s element type, element size, and alignment. Length validation alone cannot detect a type mismatch, so feeding bytes produced by a different column type is still undefined behaviour.

Implementations on Foreign Types§

Source§

impl<T: 'static + Send + Sync> AnyVec for Vec<T>

Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

fn swap_remove_any(&mut self, index: usize)

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

unsafe fn set_from_bytes( &mut self, bytes: &[u8], ) -> Result<(), SetFromBytesError>

Implementors§