#[repr(u8)]pub enum CoroState {
Created = 0,
Running = 1,
Yielded = 2,
Awaiting = 3,
Returned = 4,
Failed = 5,
}Expand description
The state of a coroutine, as Inst::CoroStatus
reports it (a u8 code).
Created --resume--> Running --yield--> Yielded --resume--> Running ...
| --await--> Awaiting --resume--> Running ...
| --ret----> Returned
+--- error escapes the body --> Failed§Examples
use bytecode_lang::CoroState;
assert_eq!(CoroState::Awaiting.code(), 3);
assert_eq!(CoroState::from_code(4), Some(CoroState::Returned));
assert!(CoroState::Yielded.is_resumable());
assert!(!CoroState::Failed.is_resumable());Variants§
Created = 0
Made by coro_new, never resumed: its body has not started.
Running = 1
Executing: it is the running coroutine or one of its resumers.
Yielded = 2
Suspended by yield.
Awaiting = 3
Suspended by await.
Returned = 4
Its body returned; it can never run again.
Failed = 5
An error escaped its body; it can never run again.
Implementations§
Source§impl CoroState
impl CoroState
Source§impl CoroState
impl CoroState
Sourcepub const fn is_resumable(self) -> bool
pub const fn is_resumable(self) -> bool
Whether resume, resume_throw, and coro_close would run code in
a coroutine in this state (Created, Yielded, or Awaiting).
§Examples
use bytecode_lang::CoroState;
assert!(CoroState::Created.is_resumable());
assert!(!CoroState::Running.is_resumable());Trait Implementations§
impl Copy for CoroState
impl Eq for CoroState
Source§impl Ord for CoroState
impl Ord for CoroState
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for CoroState
impl PartialOrd for CoroState
impl StructuralPartialEq for CoroState
Auto Trait Implementations§
impl Freeze for CoroState
impl RefUnwindSafe for CoroState
impl Send for CoroState
impl Sync for CoroState
impl Unpin for CoroState
impl UnsafeUnpin for CoroState
impl UnwindSafe for CoroState
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