pub struct Segments {
segments: Vec<(u64, Segment)>,
total_len: u64,
}Expand description
Contains a list of Segments. For each segment, stores its offset to allow binary search seeking.
Fields§
§segments: Vec<(u64, Segment)>§total_len: u64Implementations§
Source§impl Segments
impl Segments
Sourcepub fn from_root_node_and_directories(
root_node: &Node,
directories: &HashMap<B3Digest, Directory>,
) -> Self
pub fn from_root_node_and_directories( root_node: &Node, directories: &HashMap<B3Digest, Directory>, ) -> Self
Construct segments that can be used to assemble a NAR, using the given root_node and directories. Panics if the directory closure is not complete.
Sourcepub fn reader_for_offset<'bs, BS: BlobService + Clone + 'bs>(
&self,
offset: u64,
segment_concurrency: usize,
blob_service: BS,
) -> Box<dyn AsyncBufRead + Send + Unpin + 'bs>
pub fn reader_for_offset<'bs, BS: BlobService + Clone + 'bs>( &self, offset: u64, segment_concurrency: usize, blob_service: BS, ) -> Box<dyn AsyncBufRead + Send + Unpin + 'bs>
Provides a AsyncBufRead into a Segments from the given offset.
A BlobService to read blobs from needs to be specified, as well as the desired concurrency (for segments, not blobs).
This does not implement AsyncSeek, seeking can be done by calling this again with another offset.
pub fn total_len(&self) -> u64
fn push(&mut self, elem: Segment)
Auto Trait Implementations§
impl Freeze for Segments
impl RefUnwindSafe for Segments
impl Send for Segments
impl Sync for Segments
impl Unpin for Segments
impl UnsafeUnpin for Segments
impl UnwindSafe for Segments
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].