pub struct StateRegistry { /* private fields */ }Expand description
Registry of all distributed state types on this node.
Stores type-erased AnyStateShard entries keyed by state name.
Provides lookup (with typed downcasting) and cluster-event broadcasting.
Implementations§
Source§impl StateRegistry
impl StateRegistry
Sourcepub fn register<S: AnyStateShard>(
&mut self,
shard: S,
) -> Result<(), RegistryError>
pub fn register<S: AnyStateShard>( &mut self, shard: S, ) -> Result<(), RegistryError>
Register a state shard.
The type parameter S must match the concrete type of the shard.
The TypeId is derived from S for later typed lookups via
lookup_typed.
Returns Err(RegistryError::DuplicateName) if a shard with the
same name is already registered.
Sourcepub fn lookup(&self, name: &str) -> Result<&dyn AnyStateShard, RegistryError>
pub fn lookup(&self, name: &str) -> Result<&dyn AnyStateShard, RegistryError>
Look up a shard by name (type-erased).
Sourcepub fn lookup_typed<T: AnyStateShard + 'static>(
&self,
name: &str,
) -> Result<&T, RegistryError>
pub fn lookup_typed<T: AnyStateShard + 'static>( &self, name: &str, ) -> Result<&T, RegistryError>
Look up a shard by name and downcast to a concrete type T.
Returns Err(TypeMismatch) if the registered TypeId doesn’t
match TypeId::of::<T>().
Sourcepub fn broadcast_node_joined(&self, node_id: NodeId)
pub fn broadcast_node_joined(&self, node_id: NodeId)
Broadcast NodeJoined to all registered shards.
Sourcepub fn broadcast_node_left(&self, node_id: NodeId)
pub fn broadcast_node_left(&self, node_id: NodeId)
Broadcast NodeLeft to all registered shards.
Sourcepub fn state_names(&self) -> impl Iterator<Item = &str>
pub fn state_names(&self) -> impl Iterator<Item = &str>
Iterate over all registered state names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StateRegistry
impl !RefUnwindSafe for StateRegistry
impl Send for StateRegistry
impl Sync for StateRegistry
impl Unpin for StateRegistry
impl UnsafeUnpin for StateRegistry
impl !UnwindSafe for StateRegistry
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