pub struct UnionVector<'buf, T: ?Sized> { /* private fields */ }Expand description
A slice-like view of a union vector into a serialized flatbuffer that deserializes on demand.
Implementations§
Source§impl<'buf, T: ?Sized> UnionVector<'buf, T>
impl<'buf, T: ?Sized> UnionVector<'buf, T>
Sourcepub const fn new_empty() -> UnionVector<'buf, T>
pub const fn new_empty() -> UnionVector<'buf, T>
Returns an empty UnionVector
This is typically not very useful, since the vector is read-only, but has uses for instance as a default value.
Source§impl<'buf, T: VectorReadUnion<'buf>> UnionVector<'buf, T>
impl<'buf, T: VectorReadUnion<'buf>> UnionVector<'buf, T>
Sourcepub fn first(self) -> Option<Result<T>>
pub fn first(self) -> Option<Result<T>>
Returns the first element of the UnionVector, or None if it is empty.
Sourcepub fn last(self) -> Option<Result<T>>
pub fn last(self) -> Option<Result<T>>
Returns the last element of the UnionVector, or None if it is empty.
Sourcepub fn get<I>(self, index: I) -> Option<I::Output>where
I: UnionVectorIndex<'buf, T>,
pub fn get<I>(self, index: I) -> Option<I::Output>where
I: UnionVectorIndex<'buf, T>,
Returns an element or sub-vector depending on the type of index.
- If given a position, returns the element at that
position or
Noneif out of bounds. - If given a range, returns the sub-vector corresponding to that range,
or
Noneif out of bounds.
Sourcepub unsafe fn get_unchecked<I>(self, index: I) -> I::Outputwhere
I: UnionVectorIndex<'buf, T>,
pub unsafe fn get_unchecked<I>(self, index: I) -> I::Outputwhere
I: UnionVectorIndex<'buf, T>,
Returns an element or sub-vector, without doing bounds checking.
For a safe alternative see get.
§Safety
Calling this method with an out-of-bounds index is undefined behavior even if the resulting output is not used.
Sourcepub fn chunks(self, chunk_size: usize) -> Chunks<'buf, T> ⓘ
pub fn chunks(self, chunk_size: usize) -> Chunks<'buf, T> ⓘ
Returns an iterator over chunk_size elements of the UnionVector at a time, starting at the
beginning of the vector.
The chunks are UnionVectors themselves and do not overlap. If chunk_size does not
divide the length of the UnionVector, then the last chunk will not have length chunk_size.
See chunks_exact for a variant of this iterator that returns chunks of always exactly
chunk_size elements, and rchunks for the same iterator but starting at the end of the
vector.
§Panics
Panics if chunk_size is 0.
Sourcepub fn rchunks(self, chunk_size: usize) -> RChunks<'buf, T> ⓘ
pub fn rchunks(self, chunk_size: usize) -> RChunks<'buf, T> ⓘ
Returns an iterator over chunk_size elements of the UnionVector at a time, starting at the end
of the vector.
The chunks are UnionVectors themselves and do not overlap. If chunk_size does not
divide the length of the UnionVector, then the last chunk will not have length chunk_size.
See rchunks_exact for a variant of this iterator that returns chunks of always exactly
chunk_size elements, and chunks for the same iterator but starting at the beginning
of the vector.
§Panics
Panics if chunk_size is 0.
Sourcepub fn chunks_exact(self, chunk_size: usize) -> ChunksExact<'buf, T> ⓘ
pub fn chunks_exact(self, chunk_size: usize) -> ChunksExact<'buf, T> ⓘ
Returns an iterator over chunk_size elements of the UnionVector at a time, starting at the
beginning of the vector.
The chunks are UnionVectors themselves and do not overlap. If chunk_size does not
divide the length of the vector, then the last up to chunk_size-1 elements will
be omitted and can be retrieved from the remainder function of the iterator.
Due to each chunk having exactly chunk_size elements, the compiler can often optimize the
resulting code better than in the case of chunks.
See chunks for a variant of this iterator that also returns the remainder as a smaller
chunk, and rchunks_exact for the same iterator but starting at the end of the vector.
§Panics
Panics if chunk_size is 0.
Sourcepub fn rchunks_exact(self, chunk_size: usize) -> RChunksExact<'buf, T> ⓘ
pub fn rchunks_exact(self, chunk_size: usize) -> RChunksExact<'buf, T> ⓘ
Returns an iterator over chunk_size elements of the UnionVector at a time, starting at the
end of the vector.
The chunks are UnionVectors themselves and do not overlap. If chunk_size does not
divide the length of the vector, then the last up to chunk_size-1 elements will
be omitted and can be retrieved from the remainder function of the iterator.
Due to each chunk having exactly chunk_size elements, the compiler can often optimize the
resulting code better than in the case of rchunks.
See rchunks for a variant of this iterator that also returns the remainder as a smaller
chunk, and chunks_exact for the same iterator but starting at the beginning of the
vector.
§Panics
Panics if chunk_size is 0.
Sourcepub fn windows(self, size: usize) -> Windows<'buf, T> ⓘ
pub fn windows(self, size: usize) -> Windows<'buf, T> ⓘ
Returns an iterator over all contiguous windows of length
size. The windows overlap. If the vector is shorter than
size, the iterator returns no values.
§Panics
Panics if size is 0.
Sourcepub fn split_first(self) -> Option<(Result<T>, UnionVector<'buf, T>)>
pub fn split_first(self) -> Option<(Result<T>, UnionVector<'buf, T>)>
Returns the first and all the rest of the elements of the Vector, or None if it is empty
Sourcepub fn split_last(self) -> Option<(Result<T>, UnionVector<'buf, T>)>
pub fn split_last(self) -> Option<(Result<T>, UnionVector<'buf, T>)>
Returns the last and all the rest of the elements of the Vector, or None if it is empty
Sourcepub fn split_at(
self,
mid: usize,
) -> Option<(UnionVector<'buf, T>, UnionVector<'buf, T>)>
pub fn split_at( self, mid: usize, ) -> Option<(UnionVector<'buf, T>, UnionVector<'buf, T>)>
Divides one Vector into two at an index.
The first will contain all indices from [0, mid) (excluding
the index mid itself) and the second will contain all
indices from [mid, len) (excluding the index len itself).
Sourcepub unsafe fn split_at_unchecked(
self,
mid: usize,
) -> (UnionVector<'buf, T>, UnionVector<'buf, T>)
pub unsafe fn split_at_unchecked( self, mid: usize, ) -> (UnionVector<'buf, T>, UnionVector<'buf, T>)
Divides one UnionVector into two at an index, without doing bounds checking.
The first will contain all indices from [0, mid) (excluding
the index mid itself) and the second will contain all
indices from [mid, len) (excluding the index len itself).
For a safe alternative see split_at.
§Safety
Calling this method with an out-of-bounds index is undefined behavior
even if the resulting output is not used. The caller has to ensure that
0 <= mid <= self.len().
Trait Implementations§
Source§impl<T: ?Sized> Clone for UnionVector<'_, T>
impl<T: ?Sized> Clone for UnionVector<'_, T>
Source§impl<'buf, T> Debug for UnionVector<'buf, T>where
T: Debug + VectorReadUnion<'buf>,
impl<'buf, T> Debug for UnionVector<'buf, T>where
T: Debug + VectorReadUnion<'buf>,
Source§impl<'buf, T: VectorReadUnion<'buf>> IntoIterator for UnionVector<'buf, T>
impl<'buf, T: VectorReadUnion<'buf>> IntoIterator for UnionVector<'buf, T>
Source§impl<'buf, T: VectorReadUnion<'buf>, O> TryFrom<UnionVector<'buf, T>> for Vec<O>
impl<'buf, T: VectorReadUnion<'buf>, O> TryFrom<UnionVector<'buf, T>> for Vec<O>
impl<T: ?Sized> Copy for UnionVector<'_, T>
Auto Trait Implementations§
impl<'buf, T> Freeze for UnionVector<'buf, T>where
T: ?Sized,
impl<'buf, T> RefUnwindSafe for UnionVector<'buf, T>where
T: RefUnwindSafe + ?Sized,
impl<'buf, T> Send for UnionVector<'buf, T>
impl<'buf, T> Sync for UnionVector<'buf, T>
impl<'buf, T> Unpin for UnionVector<'buf, T>where
T: ?Sized,
impl<'buf, T> UnwindSafe for UnionVector<'buf, T>where
T: RefUnwindSafe + ?Sized,
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<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