pub struct CowMap { /* private fields */ }Expand description
Adaptive cluster map for cluster_id -> location resolution.
Each cluster is either local (written to this file), inherited from the parent (ParentRef), or unallocated.
Implementations§
Source§impl CowMap
impl CowMap
Sourcepub fn new_flat(cluster_count: u32) -> Self
pub fn new_flat(cluster_count: u32) -> Self
Create a new flat-array map with cluster_count entries, all Unallocated.
Sourcepub fn new_parent_ref(cluster_count: u32) -> Self
pub fn new_parent_ref(cluster_count: u32) -> Self
Create a new flat-array map with all entries set to ParentRef.
Sourcepub fn lookup(&self, cluster_id: u32) -> CowMapEntry
pub fn lookup(&self, cluster_id: u32) -> CowMapEntry
Look up a cluster by ID.
Sourcepub fn update(&mut self, cluster_id: u32, entry: CowMapEntry)
pub fn update(&mut self, cluster_id: u32, entry: CowMapEntry)
Update a cluster entry.
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize the map to bytes.
Wire format (flat_array): format(u8) | cluster_count(u32) | entries[cluster_count] Each entry: tag(u8) | offset(u64) tag 0x00 = Unallocated, tag 0x01 = ParentRef, tag 0x02 = LocalOffset
Sourcepub fn deserialize(data: &[u8], format: MapFormat) -> Result<Self, RvfError>
pub fn deserialize(data: &[u8], format: MapFormat) -> Result<Self, RvfError>
Deserialize a CowMap from bytes.
Sourcepub fn local_cluster_count(&self) -> u32
pub fn local_cluster_count(&self) -> u32
Count of clusters that have local data.
Sourcepub fn cluster_count(&self) -> u32
pub fn cluster_count(&self) -> u32
Total number of clusters in the map.
Auto Trait Implementations§
impl Freeze for CowMap
impl RefUnwindSafe for CowMap
impl Send for CowMap
impl Sync for CowMap
impl Unpin for CowMap
impl UnwindSafe for CowMap
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