pub struct HaveReply {
pub bitmap: Vec<u8>,
}Expand description
The reply to a Have, with one bit for each entry.
Bit i is bit i % 8 of byte i / 8, counted from the least significant
bit. If a bit is set, the server does not hold the object, and the client
must send it.
Fields§
§bitmap: Vec<u8>The bitmap of the entries.
Implementations§
Source§impl HaveReply
impl HaveReply
Sourcepub fn from_missing(missing: impl IntoIterator<Item = bool>) -> HaveReply
pub fn from_missing(missing: impl IntoIterator<Item = bool>) -> HaveReply
Creates a reply from one bool for each entry of the Have.
Bit i is set if entry i of missing is true. For n entries,
the bitmap has n.div_ceil(8) bytes.
Sourcepub fn is_missing(&self, index: usize) -> bool
pub fn is_missing(&self, index: usize) -> bool
Returns true if the server does not hold entry index.
For an index after the end of the bitmap, it returns false.
Sourcepub fn check_len(&self, entries: usize) -> Result<()>
pub fn check_len(&self, entries: usize) -> Result<()>
Checks the reply against a Have of entries entries.
The bitmap must be entries.div_ceil(8) bytes long, and the bits
after the last entry must be zero.
§Errors
Error::Protocolif the bitmap has a different length.Error::Protocolif the bitmap sets a bit after the last entry.
Trait Implementations§
impl Eq for HaveReply
impl StructuralPartialEq for HaveReply
Auto Trait Implementations§
impl Forget for HaveReply
impl Freeze for HaveReply
impl Move for HaveReply
impl RefUnwindSafe for HaveReply
impl Send for HaveReplywhere
RawVecInner: Send,
impl Sync for HaveReplywhere
RawVecInner: Sync,
impl Unpin for HaveReply
impl UnsafeUnpin for HaveReply
impl UnwindSafe for HaveReplywhere
RawVecInner: UnwindSafe,
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,
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
Compare self to
key and return true if they are equal.