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§
Sourcetype Mutable: VectorMutOps<Immutable = Self>
type Mutable: VectorMutOps<Immutable = Self>
The mutable equivalent of this immutable vector.
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of elements in the vector, also referred to as its “length”.
Sourcefn validity(&self) -> &Mask
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.
Sourcefn slice(&self, range: impl RangeBounds<usize> + Clone + Debug) -> Self
fn slice(&self, range: impl RangeBounds<usize> + Clone + Debug) -> Self
Slice the vector from start to end (exclusive).
Sourcefn try_into_mut(self) -> Result<Self::Mutable, Self>
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.
Sourcefn into_mut(self) -> Self::Mutable
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§
Sourcefn null_count(&self) -> usize
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.