pub struct WorkerLifecycle {
state: WorkerState,
restart_notice_pending: bool,
ever_ready: bool,
}Expand description
Tracks worker state plus the one-shot “restarted after crash” notice that must surface EXACTLY once (spec §4: the next call after a crash returns WORKER_RESTARTED once, so the agent knows unsaved edits were lost).
Fields§
§state: WorkerState§restart_notice_pending: bool§ever_ready: boolTrue once the worker has completed at least one successful init (reached Ready). A crash during the very first boot loses nothing, so it must NOT arm the WORKER_RESTARTED notice.
Implementations§
Source§impl WorkerLifecycle
impl WorkerLifecycle
pub fn new() -> Self
pub fn state(&self) -> WorkerState
Sourcepub fn on_ready(&mut self) -> Result<(), InvalidTransition>
pub fn on_ready(&mut self) -> Result<(), InvalidTransition>
Successful init handshake: Starting -> Ready.
Sourcepub fn on_dispatch(&mut self) -> Result<(), InvalidTransition>
pub fn on_dispatch(&mut self) -> Result<(), InvalidTransition>
Dispatch a call onto the executor: Ready -> Busy.
Sourcepub fn on_complete(&mut self) -> Result<(), InvalidTransition>
pub fn on_complete(&mut self) -> Result<(), InvalidTransition>
Call finished: Busy -> Ready.
Sourcepub fn on_respawn(&mut self) -> Result<(), InvalidTransition>
pub fn on_respawn(&mut self) -> Result<(), InvalidTransition>
Begin a respawn: Crashed -> Starting, arming the one-shot restart notice.
Sourcepub fn take_restart_notice(&mut self) -> bool
pub fn take_restart_notice(&mut self) -> bool
Consume the one-shot WORKER_RESTARTED notice; true at most once per crash.
Trait Implementations§
Source§impl Clone for WorkerLifecycle
impl Clone for WorkerLifecycle
Source§fn clone(&self) -> WorkerLifecycle
fn clone(&self) -> WorkerLifecycle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorkerLifecycle
impl Debug for WorkerLifecycle
Source§impl Default for WorkerLifecycle
impl Default for WorkerLifecycle
impl Eq for WorkerLifecycle
Source§impl PartialEq for WorkerLifecycle
impl PartialEq for WorkerLifecycle
impl StructuralPartialEq for WorkerLifecycle
Auto Trait Implementations§
impl Freeze for WorkerLifecycle
impl RefUnwindSafe for WorkerLifecycle
impl Send for WorkerLifecycle
impl Sync for WorkerLifecycle
impl Unpin for WorkerLifecycle
impl UnsafeUnpin for WorkerLifecycle
impl UnwindSafe for WorkerLifecycle
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