pub struct SlotMap { /* private fields */ }Expand description
Maps each of the 16384 slots to a node ID.
When a slot is None, it means the slot is not assigned to any node,
which indicates an incomplete cluster configuration.
Implementations§
Source§impl SlotMap
impl SlotMap
Sourcepub fn single_node(node: NodeId) -> Self
pub fn single_node(node: NodeId) -> Self
Creates a slot map with all slots assigned to a single node.
Useful for single-node clusters.
Sourcepub fn owner(&self, slot: u16) -> Option<NodeId>
pub fn owner(&self, slot: u16) -> Option<NodeId>
Returns the node that owns the given slot, if assigned.
Sourcepub fn assign_range(&mut self, range: SlotRange, node: NodeId)
pub fn assign_range(&mut self, range: SlotRange, node: NodeId)
Assigns a range of slots to a node.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns true if all slots are assigned to some node.
Sourcepub fn unassigned_count(&self) -> usize
pub fn unassigned_count(&self) -> usize
Returns the number of unassigned slots.
Sourcepub fn slots_for_node(&self, node: NodeId) -> Vec<SlotRange>
pub fn slots_for_node(&self, node: NodeId) -> Vec<SlotRange>
Returns all slots owned by a specific node as a list of ranges.
Consecutive slots are merged into ranges for compact representation.
Sourcepub fn slot_counts(&self) -> HashMap<NodeId, usize>
pub fn slot_counts(&self) -> HashMap<NodeId, usize>
Returns a count of slots per node.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SlotMap
impl RefUnwindSafe for SlotMap
impl Send for SlotMap
impl Sync for SlotMap
impl Unpin for SlotMap
impl UnsafeUnpin for SlotMap
impl UnwindSafe for SlotMap
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