pub struct Bitmap(/* private fields */);Expand description
A compressed bitmap using the Roaring bitmap compression scheme.
§BCS
The BCS serialized form for this type is defined by the following ABNF:
roaring-bitmap = bytes ; where the contents of the bytes are valid
; according to the serialized spec for
; roaring bitmapsImplementations§
Source§impl Bitmap
impl Bitmap
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
Returns the number of distinct integers added to the set.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
assert_eq!(bitmap.len(), 0);
bitmap.insert(3);
assert_eq!(bitmap.len(), 1);
bitmap.insert(3);
bitmap.insert(4);
assert_eq!(bitmap.len(), 2);Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all integers in this set.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
bitmap.insert(1);
assert_eq!(bitmap.contains(1), true);
bitmap.clear();
assert_eq!(bitmap.contains(1), false);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no integers in this set.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
assert_eq!(bitmap.is_empty(), true);
bitmap.insert(3);
assert_eq!(bitmap.is_empty(), false);Sourcepub fn insert(&mut self, value: u32) -> bool
pub fn insert(&mut self, value: u32) -> bool
Adds a value to the set.
Returns whether the value was absent from the set.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
assert_eq!(bitmap.insert(3), true);
assert_eq!(bitmap.insert(3), false);
assert_eq!(bitmap.contains(3), true);Sourcepub fn insert_range<R>(&mut self, range: R) -> u64where
R: RangeBounds<u32>,
pub fn insert_range<R>(&mut self, range: R) -> u64where
R: RangeBounds<u32>,
Inserts a range of values. Returns the number of inserted values.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
bitmap.insert_range(2..4);
assert!(bitmap.contains(2));
assert!(bitmap.contains(3));
assert!(!bitmap.contains(4));Sourcepub fn remove(&mut self, value: u32) -> bool
pub fn remove(&mut self, value: u32) -> bool
Removes a value from the set. Returns true if the value was present in the set.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
bitmap.insert(3);
assert_eq!(bitmap.remove(3), true);
assert_eq!(bitmap.remove(3), false);
assert_eq!(bitmap.contains(3), false);Sourcepub fn contains(&self, value: u32) -> bool
pub fn contains(&self, value: u32) -> bool
Returns true if this set contains the specified integer.
§Examples
use sui_sdk_types::Bitmap;
let mut bitmap = Bitmap::new();
bitmap.insert(1);
assert_eq!(bitmap.contains(0), false);
assert_eq!(bitmap.contains(1), true);
assert_eq!(bitmap.contains(100), false);Sourcepub fn iter(&self) -> impl Iterator<Item = u32> + use<'_>
pub fn iter(&self) -> impl Iterator<Item = u32> + use<'_>
Iterator over each value stored in the Bitmap, guarantees values are ordered by value.
§Examples
use core::iter::FromIterator;
use sui_sdk_types::Bitmap;
let bitmap = (1..3).collect::<Bitmap>();
let mut iter = bitmap.iter();
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);Sourcepub fn deserialize_from<R>(reader: R) -> Result<Bitmap, Error>where
R: Read,
pub fn deserialize_from<R>(reader: R) -> Result<Bitmap, Error>where
R: Read,
Deserialize a bitmap into memory from the standard Roaring on-disk format. This is compatible with the official C/C++, Java and Go implementations. This method checks that all of the internal values are valid.
§Examples
use sui_sdk_types::Bitmap;
let bitmap1: Bitmap = (1..4).collect();
let mut bytes = vec![];
bitmap1.serialize_into(&mut bytes).unwrap();
let bitmap2 = Bitmap::deserialize_from(&bytes[..]).unwrap();
assert_eq!(bitmap1, bitmap2);Sourcepub fn serialize_into<W>(&self, writer: W) -> Result<(), Error>where
W: Write,
pub fn serialize_into<W>(&self, writer: W) -> Result<(), Error>where
W: Write,
Serialize this bitmap into the standard Roaring on-disk format. This is compatible with the official C/C++, Java and Go implementations.
§Examples
use sui_sdk_types::Bitmap;
let bitmap1: Bitmap = (1..4).collect();
let mut bytes = vec![];
bitmap1.serialize_into(&mut bytes).unwrap();
let bitmap2 = Bitmap::deserialize_from(&bytes[..]).unwrap();
assert_eq!(bitmap1, bitmap2);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Bitmap
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Bitmap
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Bitmap, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Bitmap, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'a> Extend<&'a u32> for Bitmap
impl<'a> Extend<&'a u32> for Bitmap
Source§fn extend<I>(&mut self, values: I)where
I: IntoIterator<Item = &'a u32>,
fn extend<I>(&mut self, values: I)where
I: IntoIterator<Item = &'a u32>,
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<u32> for Bitmap
impl Extend<u32> for Bitmap
Source§fn extend<I>(&mut self, values: I)where
I: IntoIterator<Item = u32>,
fn extend<I>(&mut self, values: I)where
I: IntoIterator<Item = u32>,
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a> FromIterator<&'a u32> for Bitmap
impl<'a> FromIterator<&'a u32> for Bitmap
Source§impl FromIterator<u32> for Bitmap
impl FromIterator<u32> for Bitmap
Source§impl Serialize for Bitmap
Available on crate feature serde only.
impl Serialize for Bitmap
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for Bitmap
Auto Trait Implementations§
impl Freeze for Bitmap
impl RefUnwindSafe for Bitmap
impl Send for Bitmap
impl Sync for Bitmap
impl Unpin for Bitmap
impl UnsafeUnpin for Bitmap
impl UnwindSafe for Bitmap
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
fn from_bcs<'de>(bytes: &'de [u8]) -> Result<Self, Error>where
Self: Deserialize<'de>,
fn from_bcs_base64(base64: &str) -> Result<Self, Error>where
Self: DeserializeOwned,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = !
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.