pub struct ActorContext<A: Actor> { /* private fields */ }Expand description
actor 的后台端。
由 Actor::channel 创建,通常由后台任务持有。
用于接收命令、更新状态/进度、广播事件。
Implementations§
Source§impl<A: Actor> ActorContext<A>
impl<A: Actor> ActorContext<A>
Sourcepub fn get_events_clone(&self) -> Sender<A::Event>
pub fn get_events_clone(&self) -> Sender<A::Event>
获取额外的事件发送端。
Sourcepub fn send_event(&self, event: A::Event)
pub fn send_event(&self, event: A::Event)
发送事件。
Sourcepub fn update_state(&self, state: A::State)
pub fn update_state(&self, state: A::State)
更新状态。
Sourcepub fn update_progress(&self, progress: A::Progress)
pub fn update_progress(&self, progress: A::Progress)
更新进度。
Sourcepub fn wait_for_cmd(&mut self) -> impl Future<Output = Option<A::Cmd>>
pub fn wait_for_cmd(&mut self) -> impl Future<Output = Option<A::Cmd>>
阻塞等待命令。
pub fn cancel_clone(&self) -> CancelToken
Auto Trait Implementations§
impl<A> Freeze for ActorContext<A>
impl<A> RefUnwindSafe for ActorContext<A>where
Receiver<<A as Actor>::Cmd>: RefUnwindSafe,
Sender<<A as Actor>::State>: RefUnwindSafe,
Sender<<A as Actor>::Event>: RefUnwindSafe,
Sender<<A as Actor>::Progress>: RefUnwindSafe,
impl<A> Send for ActorContext<A>
impl<A> Sync for ActorContext<A>
impl<A> Unpin for ActorContext<A>
impl<A> UnsafeUnpin for ActorContext<A>where
Receiver<<A as Actor>::Cmd>: UnsafeUnpin,
Sender<<A as Actor>::State>: UnsafeUnpin,
Sender<<A as Actor>::Event>: UnsafeUnpin,
Sender<<A as Actor>::Progress>: UnsafeUnpin,
impl<A> UnwindSafe for ActorContext<A>where
Receiver<<A as Actor>::Cmd>: UnwindSafe,
Sender<<A as Actor>::State>: UnwindSafe,
Sender<<A as Actor>::Event>: UnwindSafe,
Sender<<A as Actor>::Progress>: UnwindSafe,
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