pub struct Bitfield {
pub ranges: ChunkRanges,
/* private fields */
}
Expand description
The state of a bitfield, or an update to a bitfield
Fields§
§ranges: ChunkRanges
The ranges that were added
Implementations§
Source§impl Bitfield
impl Bitfield
pub fn new(ranges: ChunkRanges, size: u64) -> Self
pub fn size(&self) -> u64
Sourcepub fn empty() -> Self
pub fn empty() -> Self
An empty bitfield. This is the neutral element for the combine operation.
Sourcepub fn is_validated(&self) -> bool
pub fn is_validated(&self) -> bool
True if the chunk corresponding to the size is included in the ranges
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
True if all chunks up to size are included in the ranges
Sourcepub fn validated_size(&self) -> Option<u64>
pub fn validated_size(&self) -> Option<u64>
Get the validated size if the bitfield is validated
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Total valid bytes in this bitfield.
pub fn state(&self) -> BitfieldState
Sourcepub fn update(&mut self, update: &Bitfield) -> UpdateResult
pub fn update(&mut self, update: &Bitfield) -> UpdateResult
Update the bitfield with a new value, and gives detailed information about the change.
returns a tuple of (changed, Some((old, new))). If the bitfield changed at all, the flag is true. If there was a significant change, the old and new states are returned.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bitfield
impl<'de> Deserialize<'de> for Bitfield
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&Bitfield> for ObserveItem
impl From<&Bitfield> for ObserveItem
Source§impl From<&ObserveItem> for Bitfield
impl From<&ObserveItem> for Bitfield
Source§fn from(value: &ObserveItem) -> Self
fn from(value: &ObserveItem) -> Self
Converts to this type from the input type.
impl Eq for Bitfield
impl StructuralPartialEq for Bitfield
Auto Trait Implementations§
impl Freeze for Bitfield
impl RefUnwindSafe for Bitfield
impl Send for Bitfield
impl Sync for Bitfield
impl Unpin for Bitfield
impl UnwindSafe for Bitfield
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt 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
Compare self to
key
and return true
if they are equal.