pub struct ManagerState<State> { /* private fields */ }Expand description
管理器聚合的所有子 actor 状态。
以 id 为键,存储每个子 actor 的最新状态。
通过 ActorHandle::get_state 获取。
§示例
let state: ManagerState<u32> = handle.get_state();
// 按 id 读取
if let Some(&42) = state.get(1) {
println!("actor 1 的状态是 42");
}
// 遍历所有子 actor 状态
for (id, s) in state.iter() {
println!("actor {id}: {s}");
}
println!("共 {} 个子 actor", state.len());Implementations§
Source§impl<State> ManagerState<State>
impl<State> ManagerState<State>
Trait Implementations§
Source§impl<State: Clone> Clone for ManagerState<State>
impl<State: Clone> Clone for ManagerState<State>
Auto Trait Implementations§
impl<State> Freeze for ManagerState<State>
impl<State> RefUnwindSafe for ManagerState<State>
impl<State> Send for ManagerState<State>
impl<State> Sync for ManagerState<State>
impl<State> Unpin for ManagerState<State>
impl<State> UnsafeUnpin for ManagerState<State>
impl<State> UnwindSafe for ManagerState<State>
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