pub struct SegmentSliceVec { /* private fields */ }Expand description
One validator’s slices of a work package’s segments: one slice per segment, all of the same length.
Erasure-coding n segments for v validators yields a v x n matrix of slices; this
type is one row. Segment j is reconstructed from the j-th slice of any D(v) rows:
seg 0 seg 1 ... seg n-1
validator 0 slice slice slice <- one SegmentSliceVec
...
validator v-1 slice slice sliceThe row is stored as data, the concatenation of the validator’s slices in segment
order; slice_len (SEGMENT_LEN / D(v), a property of the erasure coding rather than a
protocol constant) gives the slice boundaries within it. The slice count is bound by the
maximum number of segments a work package may export.
Every constructor takes the slice length, so slice_len is always in
[1, MAX_SEGMENT_SLICE_LEN].
Implementations§
Source§impl SegmentSliceVec
impl SegmentSliceVec
Sourcepub fn raw(&self) -> &[u8] ⓘ
pub fn raw(&self) -> &[u8] ⓘ
Get the raw byte buffer: all slices concatenated in segment order.
Sourcepub fn into_inner(self) -> Vec<u8> ⓘ
pub fn into_inner(self) -> Vec<u8> ⓘ
Get the underlying Vec.
Sourcepub fn from_bytes(data: Vec<u8>, slice_len: usize) -> Option<Self>
pub fn from_bytes(data: Vec<u8>, slice_len: usize) -> Option<Self>
Creates a vec of slice_len-sized slices from serialized bytes.
Returns None if the size is incorrect.
Sourcepub fn with_capacity(capacity: usize, slice_len: usize) -> Self
pub fn with_capacity(capacity: usize, slice_len: usize) -> Self
Preallocates a vec for the given number of slice_len-sized slices.
Sourcepub fn push(&mut self, slice: &[u8]) -> Result<(), &'static str>
pub fn push(&mut self, slice: &[u8]) -> Result<(), &'static str>
Appends a slice to this vec. Returns an error if the slice size is incorrect or the vec overflows.
Sourcepub fn push_default(&mut self) -> Result<&mut [u8], &'static str>
pub fn push_default(&mut self) -> Result<&mut [u8], &'static str>
Adds a new empty slice to the vec and returns a reference to it. Produces an error if the vec overflows.
Trait Implementations§
Source§impl Clone for SegmentSliceVec
impl Clone for SegmentSliceVec
Source§impl Debug for SegmentSliceVec
impl Debug for SegmentSliceVec
impl Eq for SegmentSliceVec
Source§impl Index<usize> for SegmentSliceVec
impl Index<usize> for SegmentSliceVec
Source§impl PartialEq for SegmentSliceVec
impl PartialEq for SegmentSliceVec
impl StructuralPartialEq for SegmentSliceVec
Auto Trait Implementations§
impl Freeze for SegmentSliceVec
impl RefUnwindSafe for SegmentSliceVec
impl Send for SegmentSliceVec
impl Sync for SegmentSliceVec
impl Unpin for SegmentSliceVec
impl UnsafeUnpin for SegmentSliceVec
impl UnwindSafe for SegmentSliceVec
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§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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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