Struct iroh_bytes::protocol::RangeSpecSeq
source · #[repr(transparent)]pub struct RangeSpecSeq(_);Expand description
A compressed sequence of range specs
Examples:
All child ranges: [(0, [0])] starting at offset 0, all offsets (see above)
First chunk of all children: [(0, [0, 1])] starting at offset 0, chunk range 0..1
All of child 1234: [(1234, [0]), [1, []]].
First 33 chunks of child 5678: [(5678, [0, 33]), (1, [])].
Chunks 10 to 30 of child 6789: [(6789, [10, 20]), (1, [])].
No child ranges: []
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
An empty range spec sequence
When iterated, will return an empty range forever
sourcepub fn single(&self) -> Option<(u64, &RangeSpec)>
pub fn 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 complete range spec sequence
When iterated, will return a full range forever
sourcepub fn new(children: impl IntoIterator<Item = RangeSet2<ChunkNum>>) -> Self
pub fn new(children: impl IntoIterator<Item = RangeSet2<ChunkNum>>) -> Self
Create a new range spec sequence from a sequence of range sets
sourcepub fn iter_non_empty(&self) -> NonEmptyRequestRangeSpecIter<'_> ⓘ
pub fn iter_non_empty(&self) -> NonEmptyRequestRangeSpecIter<'_> ⓘ
An iterator over non empty range specs
This iterator is infinite if the range spec is infinite
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 PartialEq<RangeSpecSeq> for RangeSpecSeq
impl PartialEq<RangeSpecSeq> 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 ==.