VectorOps

Trait VectorOps 

Source
pub trait VectorOps:
    Sealed
    + Into<Vector>
    + Sized {
    type Mutable: VectorMutOps<Immutable = Self>;

    // Required methods
    fn len(&self) -> usize;
    fn validity(&self) -> &Mask;
    fn scalar_at(&self, index: usize) -> Scalar;
    fn slice(&self, range: impl RangeBounds<usize> + Clone + Debug) -> Self;
    fn try_into_mut(self) -> Result<Self::Mutable, Self>;
    fn into_mut(self) -> Self::Mutable;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn null_count(&self) -> usize { ... }
}
Expand description

Common operations for immutable vectors (all the variants of Vector).

Required Associated Types§

Source

type Mutable: VectorMutOps<Immutable = Self>

The mutable equivalent of this immutable vector.

Required Methods§

Source

fn len(&self) -> usize

Returns the number of elements in the vector, also referred to as its “length”.

Source

fn validity(&self) -> &Mask

Returns the validity mask of the vector, where true represents a valid element and false represents a null element.

Note that vectors are always considered nullable. “Non-nullable” data will simply have a Mask of AllTrue(len). It is on the caller to ensure that they do not add nullable data to a vector they want to keep as non-nullable.

Source

fn scalar_at(&self, index: usize) -> Scalar

Return the scalar at the given index.

§Panics

Panics if the index is out of bounds.

Source

fn slice(&self, range: impl RangeBounds<usize> + Clone + Debug) -> Self

Slice the vector from start to end (exclusive).

Source

fn try_into_mut(self) -> Result<Self::Mutable, Self>

Tries to convert self into a mutable vector (implementing VectorMutOps).

This method will only succeed if self is the only unique strong reference (it effectively “owns” the buffer). If this is true, this method will return a mutable vector with the contents of self without any copying of data.

§Errors

If self is not unique, this will fail and return self back to the caller.

Source

fn into_mut(self) -> Self::Mutable

Converts self into a mutable vector (implementing VectorMutOps).

This method uses “clone-on-write” semantics, meaning it will clone any underlying data that has multiple references (preventing mutable access). into_mut can be more efficient than try_into_mut() when mutations are infrequent.

The semantics of into_mut are somewhat similar to that of Arc::make_mut(), but instead of working with references, this works with owned immutable / mutable types.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the vector contains no elements.

Source

fn null_count(&self) -> usize

Returns the null count of the vector.

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§