Skip to main content

BranchToken

Struct BranchToken 

Source
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>

Source

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>

Source

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>

§

impl<T, S> Send for BranchToken<T, S>
where T: Send, S: Send,

§

impl<T, S> Sync for BranchToken<T, S>
where T: Sync, S: Sync,

§

impl<T, S> Unpin for BranchToken<T, S>
where T: Unpin, S: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.