pub struct BranchToken<T, S: BranchState> {
pub _task: PhantomData<T>,
pub _state: PhantomData<S>,
}Expand description
An ownership-bearing token representing a specific execution path.
Since _task and _state are PhantomData, this struct has a size of 0 bytes.
§Representation
A zero-sized type BranchToken holding a PhantomData<T> and PhantomData<S>.
Its size in memory is 0 bytes.
§Structure-only
Models compile-time ownership of an abstract execution path. It holds no runtime task references, performs no execution, and does not schedule workloads.
§Graduation
In wasm4pm, a token represents a dynamic work item tracked by the runtime database. In the compat library,
it enforces compile-time sequencing and typestate safety.
Fields§
§_task: PhantomData<T>§_state: PhantomData<S>Implementations§
Source§impl<T> BranchToken<T, Pending>
impl<T> BranchToken<T, Pending>
Sourcepub fn start(self) -> BranchToken<T, Running>
pub fn start(self) -> BranchToken<T, Running>
Progresses the branch from Pending to Running.
§Examples
use wasm4pm_compat::workflow::{BranchToken, Pending, Running};
use std::marker::PhantomData;
struct MyTask;
let token: BranchToken<MyTask, Pending> = BranchToken {
_task: PhantomData,
_state: PhantomData,
};
let running_token: BranchToken<MyTask, Running> = token.start();Source§impl<T> BranchToken<T, Running>
impl<T> BranchToken<T, Running>
Sourcepub fn complete(self) -> BranchToken<T, Completed>
pub fn complete(self) -> BranchToken<T, Completed>
Normal successful completion of the branch.
§Examples
use wasm4pm_compat::workflow::{BranchToken, Running, Completed};
use std::marker::PhantomData;
struct MyTask;
let token: BranchToken<MyTask, Running> = BranchToken {
_task: PhantomData,
_state: PhantomData,
};
let completed_token: BranchToken<MyTask, Completed> = token.complete();Auto Trait Implementations§
impl<T, S> Freeze for BranchToken<T, S>
impl<T, S> RefUnwindSafe for BranchToken<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for BranchToken<T, S>
impl<T, S> Sync for BranchToken<T, S>
impl<T, S> Unpin for BranchToken<T, S>
impl<T, S> UnsafeUnpin for BranchToken<T, S>
impl<T, S> UnwindSafe for BranchToken<T, S>where
T: UnwindSafe,
S: 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