Handoff

Struct Handoff 

Source
pub struct Handoff<S: HandoffState> {
    data: HandoffRecord,
    _state: PhantomData<S>,
}
Expand description

A handoff with compile-time state tracking.

The type parameter S indicates the current state of the handoff. Methods are only available in appropriate states:

  • Handoff<Initiated>: Can be accepted or rejected
  • Handoff<HandoffAccepted>: Can be completed
  • Handoff<Rejected>: Terminal, no further transitions
  • Handoff<HandoffCompleted>: Terminal, no further transitions

Fields§

§data: HandoffRecord§_state: PhantomData<S>

Implementations§

Source§

impl<S: HandoffState> Handoff<S>

Source

pub fn data(&self) -> &HandoffRecord

Access the underlying handoff data (read-only).

Source

pub fn handoff_id(&self) -> HandoffId

Get the handoff ID.

Source

pub fn tenant_id(&self) -> TenantId

Get the tenant ID.

Source

pub fn from_agent_id(&self) -> AgentId

Get the source agent ID.

Source

pub fn to_agent_id(&self) -> AgentId

Get the target agent ID.

Source

pub fn trajectory_id(&self) -> TrajectoryId

Get the trajectory ID.

Source

pub fn scope_id(&self) -> ScopeId

Get the scope ID.

Source

pub fn reason(&self) -> &str

Get the handoff reason.

Source

pub fn context_snapshot(&self) -> &[u8]

Get the context snapshot.

Source

pub fn created_at(&self) -> Timestamp

Get when the handoff was created.

Source

pub fn into_data(self) -> HandoffRecord

Consume and return the underlying data (for serialization).

Source§

impl Handoff<Initiated>

Source

pub fn new(data: HandoffRecord) -> Self

Create a new initiated handoff.

Source

pub fn accept(self, accepted_at: Timestamp) -> Handoff<HandoffAccepted>

Accept the handoff.

Transitions to Handoff<HandoffAccepted>. Consumes the current handoff.

Source

pub fn reject(self, reason: String) -> Handoff<Rejected>

Reject the handoff.

Transitions to Handoff<Rejected> (terminal state). Consumes the current handoff.

Source§

impl Handoff<HandoffAccepted>

Source

pub fn accepted_at(&self) -> Timestamp

Get when the handoff was accepted.

Source

pub fn complete(self, completed_at: Timestamp) -> Handoff<HandoffCompleted>

Complete the handoff.

Transitions to Handoff<HandoffCompleted> (terminal state). Consumes the current handoff.

Source§

impl Handoff<Rejected>

Source

pub fn rejection_reason(&self) -> &str

Get the rejection reason.

Source§

impl Handoff<HandoffCompleted>

Source

pub fn accepted_at(&self) -> Timestamp

Get when the handoff was accepted.

Source

pub fn completed_at(&self) -> Timestamp

Get when the handoff was completed.

Trait Implementations§

Source§

impl<S: Clone + HandoffState> Clone for Handoff<S>

Source§

fn clone(&self) -> Handoff<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + HandoffState> Debug for Handoff<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Handoff<S>

§

impl<S> RefUnwindSafe for Handoff<S>
where S: RefUnwindSafe,

§

impl<S> Send for Handoff<S>

§

impl<S> Sync for Handoff<S>

§

impl<S> Unpin for Handoff<S>
where S: Unpin,

§

impl<S> UnwindSafe for Handoff<S>
where 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.