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 rejectedHandoff<HandoffAccepted>: Can be completedHandoff<Rejected>: Terminal, no further transitionsHandoff<HandoffCompleted>: Terminal, no further transitions
Fields§
§data: HandoffRecord§_state: PhantomData<S>Implementations§
Source§impl<S: HandoffState> Handoff<S>
impl<S: HandoffState> Handoff<S>
Sourcepub fn data(&self) -> &HandoffRecord
pub fn data(&self) -> &HandoffRecord
Access the underlying handoff data (read-only).
Sourcepub fn handoff_id(&self) -> HandoffId
pub fn handoff_id(&self) -> HandoffId
Get the handoff ID.
Sourcepub fn from_agent_id(&self) -> AgentId
pub fn from_agent_id(&self) -> AgentId
Get the source agent ID.
Sourcepub fn to_agent_id(&self) -> AgentId
pub fn to_agent_id(&self) -> AgentId
Get the target agent ID.
Sourcepub fn trajectory_id(&self) -> TrajectoryId
pub fn trajectory_id(&self) -> TrajectoryId
Get the trajectory ID.
Sourcepub fn context_snapshot(&self) -> &[u8] ⓘ
pub fn context_snapshot(&self) -> &[u8] ⓘ
Get the context snapshot.
Sourcepub fn created_at(&self) -> Timestamp
pub fn created_at(&self) -> Timestamp
Get when the handoff was created.
Sourcepub fn into_data(self) -> HandoffRecord
pub fn into_data(self) -> HandoffRecord
Consume and return the underlying data (for serialization).
Source§impl Handoff<Initiated>
impl Handoff<Initiated>
Sourcepub fn new(data: HandoffRecord) -> Self
pub fn new(data: HandoffRecord) -> Self
Create a new initiated handoff.
Sourcepub fn accept(self, accepted_at: Timestamp) -> Handoff<HandoffAccepted>
pub fn accept(self, accepted_at: Timestamp) -> Handoff<HandoffAccepted>
Accept the handoff.
Transitions to Handoff<HandoffAccepted>.
Consumes the current handoff.
Source§impl Handoff<HandoffAccepted>
impl Handoff<HandoffAccepted>
Sourcepub fn accepted_at(&self) -> Timestamp
pub fn accepted_at(&self) -> Timestamp
Get when the handoff was accepted.
Sourcepub fn complete(self, completed_at: Timestamp) -> Handoff<HandoffCompleted>
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<HandoffCompleted>
impl Handoff<HandoffCompleted>
Sourcepub fn accepted_at(&self) -> Timestamp
pub fn accepted_at(&self) -> Timestamp
Get when the handoff was accepted.
Sourcepub fn completed_at(&self) -> Timestamp
pub fn completed_at(&self) -> Timestamp
Get when the handoff was completed.
Trait Implementations§
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> 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