pub enum ValidityMask {
AllPresent(u32),
Mixed {
present: BitVec,
unknown: BitVec,
},
}Expand description
Which positions of a column carry a value, and why the others do not.
The overwhelmingly common case is that every position carries one, and that case costs a length rather than two bit sets.
§Examples
use molframe_core::column::{Presence, ValidityMask};
let mut mask = ValidityMask::all_present(3);
assert_eq!(mask.get(0), Presence::Present);
mask.set(1, Presence::Unknown);
assert_eq!(mask.get(1), Presence::Unknown);
assert_eq!(mask.present_count(), 2);Variants§
AllPresent(u32)
Every position carries a value.
Mixed
Positions differ, so both distinctions are tracked.
Implementations§
Source§impl ValidityMask
impl ValidityMask
Sourcepub const fn all_present(len: u32) -> Self
pub const fn all_present(len: u32) -> Self
Creates a mask over len positions that all carry a value.
Sourcepub fn is_all_present(&self) -> bool
pub fn is_all_present(&self) -> bool
Returns true when every covered position carries a value.
Sourcepub fn get(&self, position: u32) -> Presence
pub fn get(&self, position: u32) -> Presence
What the column says about position.
A position past the end reads as inapplicable, because a column that does not reach that far makes no statement about it.
Sourcepub fn set(&mut self, position: u32, presence: Presence)
pub fn set(&mut self, position: u32, presence: Presence)
Records what the column says about position.
Setting anything other than present on an all-present mask materialises the bit sets, which is the only point at which they are allocated.
Sourcepub fn present_count(&self) -> u32
pub fn present_count(&self) -> u32
The number of positions carrying a value.
Source§impl ValidityMask
impl ValidityMask
Sourcepub fn try_from_iter<T: IntoIterator<Item = Presence>>(iter: T) -> Option<Self>
pub fn try_from_iter<T: IntoIterator<Item = Presence>>(iter: T) -> Option<Self>
Builds a validity mask, returning None if u32 row capacity is exceeded.
Trait Implementations§
Source§impl Clone for ValidityMask
impl Clone for ValidityMask
Source§impl Debug for ValidityMask
impl Debug for ValidityMask
impl Eq for ValidityMask
Source§impl PartialEq for ValidityMask
impl PartialEq for ValidityMask
impl StructuralPartialEq for ValidityMask
Auto Trait Implementations§
impl Freeze for ValidityMask
impl RefUnwindSafe for ValidityMask
impl Send for ValidityMask
impl Sync for ValidityMask
impl Unpin for ValidityMask
impl UnsafeUnpin for ValidityMask
impl UnwindSafe for ValidityMask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more