Struct iroh_blobs::protocol::RangeSpecSeq
source · pub struct RangeSpecSeq(/* private fields */);
Expand description
A chunk range specification for a sequence of blobs.
To select chunks in a sequence of blobs this is encoded as a sequence of (blob_offset, range_spec)
tuples. Offsets are interpreted in an accumulating fashion.
§Example:
Suppose two RangeSpec
s range_a
and range_b
.
[(0, range_a), (2, empty), (3, range_b), (1, empty)]
encodes:- Select
range_a
for children in the range[0, 2)
- do no selection (empty) for children in the range
[2, 2+3) = [2, 5)
(3 children) - Select
range_b
for children in the range[5, 5+1) = [5, 6)
(1 children) - do no selection (empty) for children in the open range
[6, inf)
- Select
Another way to understand this is that offsets represent the number of times the previous range appears.
Other examples:
-
Select
range_a
from all blobs after the 5th one in the sequence:[(5, range_a)]
. -
Select
range_a
from all blobs in the sequence:[(0, range_a)]
. -
Select
range_a
from blob 1234:[(1234, range_a), (1, empty)]
. -
Select nothing:
[]
.
This is a smallvec so that we can avoid allocations in the common case of a single child range.
Implementations§
source§impl RangeSpecSeq
impl RangeSpecSeq
sourcepub const fn empty() -> Self
pub const fn empty() -> Self
A RangeSpecSeq
containing no chunks from any blobs in the sequence.
RangeSpecSeq::iter
, will return an empty range forever.
sourcepub fn as_single(&self) -> Option<(u64, &RangeSpec)>
pub fn as_single(&self) -> Option<(u64, &RangeSpec)>
If this range seq describes a range for a single item, returns the offset and range spec for that item
sourcepub fn all() -> Self
pub fn all() -> Self
A RangeSpecSeq
containing all chunks from all blobs.
RangeSpecSeq::iter
, will return a full range forever.
sourcepub fn from_ranges(
ranges: impl IntoIterator<Item = impl AsRef<ChunkRangesRef>>
) -> Self
pub fn from_ranges( ranges: impl IntoIterator<Item = impl AsRef<ChunkRangesRef>> ) -> Self
Convenience function to create a RangeSpecSeq
from a finite sequence of range sets.
sourcepub fn from_ranges_infinite(
ranges: impl IntoIterator<Item = impl AsRef<ChunkRangesRef>>
) -> Self
pub fn from_ranges_infinite( ranges: impl IntoIterator<Item = impl AsRef<ChunkRangesRef>> ) -> Self
Convenience function to create a RangeSpecSeq
from a sequence of range sets.
Compared to RangeSpecSeq::from_ranges
, this will not add an empty range spec at the end, so the final
range spec will repeat forever.
sourcepub fn new(children: impl IntoIterator<Item = RangeSpec>) -> Self
pub fn new(children: impl IntoIterator<Item = RangeSpec>) -> Self
Creates a new range spec sequence from a sequence of range specs.
This will merge adjacent range specs with the same value and thus make sure that the resulting sequence is as compact as possible.
sourcepub fn iter(&self) -> RequestRangeSpecIter<'_>
pub fn iter(&self) -> RequestRangeSpecIter<'_>
An infinite iterator of range specs for blobs in the sequence.
Each item yielded by the iterator is the RangeSpec
for a blob in the sequence.
Thus the first call to .next()
returns the range spec for the first blob, the next
call returns the range spec of the second blob, etc.
sourcepub fn iter_non_empty(&self) -> NonEmptyRequestRangeSpecIter<'_> ⓘ
pub fn iter_non_empty(&self) -> NonEmptyRequestRangeSpecIter<'_> ⓘ
An iterator over blobs in the sequence with a non-empty range spec.
This iterator will only yield items for blobs which have at least one chunk selected.
This iterator is infinite if the RangeSpecSeq
ends on a non-empty RangeSpec
,
that is all further blobs have selected chunks spans.
Trait Implementations§
source§impl Clone for RangeSpecSeq
impl Clone for RangeSpecSeq
source§fn clone(&self) -> RangeSpecSeq
fn clone(&self) -> RangeSpecSeq
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RangeSpecSeq
impl Debug for RangeSpecSeq
source§impl<'de> Deserialize<'de> for RangeSpecSeq
impl<'de> Deserialize<'de> for RangeSpecSeq
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Hash for RangeSpecSeq
impl Hash for RangeSpecSeq
source§impl PartialEq for RangeSpecSeq
impl PartialEq for RangeSpecSeq
source§fn eq(&self, other: &RangeSpecSeq) -> bool
fn eq(&self, other: &RangeSpecSeq) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for RangeSpecSeq
impl Serialize for RangeSpecSeq
impl Eq for RangeSpecSeq
impl StructuralPartialEq for RangeSpecSeq
Auto Trait Implementations§
impl Freeze for RangeSpecSeq
impl RefUnwindSafe for RangeSpecSeq
impl Send for RangeSpecSeq
impl Sync for RangeSpecSeq
impl Unpin for RangeSpecSeq
impl UnwindSafe for RangeSpecSeq
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.