pub struct Delegation<S: DelegationState> {
data: DelegationRecord,
_state: PhantomData<S>,
}Expand description
A delegation with compile-time state tracking.
The type parameter S indicates the current state of the delegation.
Methods are only available in appropriate states:
Delegation<Pending>: Can be accepted, rejected, or timeoutDelegation<DelegationAccepted>: Can be started or failDelegation<InProgress>: Can be completed or failDelegation<DelegationCompleted>: Terminal, has resultDelegation<DelegationRejected>: TerminalDelegation<DelegationFailed>: Terminal, has failure reason
Fields§
§data: DelegationRecord§_state: PhantomData<S>Implementations§
Source§impl<S: DelegationState> Delegation<S>
impl<S: DelegationState> Delegation<S>
Sourcepub fn data(&self) -> &DelegationRecord
pub fn data(&self) -> &DelegationRecord
Access the underlying delegation data (read-only).
Sourcepub fn delegation_id(&self) -> DelegationId
pub fn delegation_id(&self) -> DelegationId
Get the delegation ID.
Sourcepub fn from_agent_id(&self) -> AgentId
pub fn from_agent_id(&self) -> AgentId
Get the delegating agent ID.
Sourcepub fn to_agent_id(&self) -> AgentId
pub fn to_agent_id(&self) -> AgentId
Get the delegate agent ID.
Sourcepub fn trajectory_id(&self) -> TrajectoryId
pub fn trajectory_id(&self) -> TrajectoryId
Get the trajectory ID.
Sourcepub fn task_description(&self) -> &str
pub fn task_description(&self) -> &str
Get the task description.
Sourcepub fn created_at(&self) -> Timestamp
pub fn created_at(&self) -> Timestamp
Get when the delegation was created.
Sourcepub fn expected_completion(&self) -> Option<Timestamp>
pub fn expected_completion(&self) -> Option<Timestamp>
Get the expected completion time.
Sourcepub fn into_data(self) -> DelegationRecord
pub fn into_data(self) -> DelegationRecord
Consume and return the underlying data (for serialization).
Source§impl Delegation<Pending>
impl Delegation<Pending>
Sourcepub fn new(data: DelegationRecord) -> Self
pub fn new(data: DelegationRecord) -> Self
Create a new pending delegation.
Sourcepub fn accept(self, accepted_at: Timestamp) -> Delegation<DelegationAccepted>
pub fn accept(self, accepted_at: Timestamp) -> Delegation<DelegationAccepted>
Accept the delegation.
Transitions to Delegation<DelegationAccepted>.
Consumes the current delegation.
Sourcepub fn reject(self, reason: String) -> Delegation<DelegationRejected>
pub fn reject(self, reason: String) -> Delegation<DelegationRejected>
Reject the delegation.
Transitions to Delegation<DelegationRejected> (terminal state).
Consumes the current delegation.
Sourcepub fn fail(self, reason: String) -> Delegation<DelegationFailed>
pub fn fail(self, reason: String) -> Delegation<DelegationFailed>
Mark the delegation as failed (e.g., timeout).
Transitions to Delegation<DelegationFailed> (terminal state).
Consumes the current delegation.
Source§impl Delegation<DelegationAccepted>
impl Delegation<DelegationAccepted>
Sourcepub fn accepted_at(&self) -> Timestamp
pub fn accepted_at(&self) -> Timestamp
Get when the delegation was accepted.
Sourcepub fn start(self, started_at: Timestamp) -> Delegation<InProgress>
pub fn start(self, started_at: Timestamp) -> Delegation<InProgress>
Start working on the delegation.
Transitions to Delegation<InProgress>.
Consumes the current delegation.
Sourcepub fn fail(self, reason: String) -> Delegation<DelegationFailed>
pub fn fail(self, reason: String) -> Delegation<DelegationFailed>
Mark the delegation as failed before starting.
Transitions to Delegation<DelegationFailed> (terminal state).
Consumes the current delegation.
Source§impl Delegation<InProgress>
impl Delegation<InProgress>
Sourcepub fn accepted_at(&self) -> Timestamp
pub fn accepted_at(&self) -> Timestamp
Get when the delegation was accepted.
Sourcepub fn started_at(&self) -> Timestamp
pub fn started_at(&self) -> Timestamp
Get when work started.
Sourcepub fn complete(
self,
completed_at: Timestamp,
result: DelegationResult,
) -> Delegation<DelegationCompleted>
pub fn complete( self, completed_at: Timestamp, result: DelegationResult, ) -> Delegation<DelegationCompleted>
Complete the delegation with a result.
Transitions to Delegation<DelegationCompleted> (terminal state).
Consumes the current delegation.
Sourcepub fn fail(self, reason: String) -> Delegation<DelegationFailed>
pub fn fail(self, reason: String) -> Delegation<DelegationFailed>
Mark the delegation as failed during execution.
Transitions to Delegation<DelegationFailed> (terminal state).
Consumes the current delegation.
Source§impl Delegation<DelegationCompleted>
impl Delegation<DelegationCompleted>
Sourcepub fn accepted_at(&self) -> Timestamp
pub fn accepted_at(&self) -> Timestamp
Get when the delegation was accepted.
Sourcepub fn started_at(&self) -> Timestamp
pub fn started_at(&self) -> Timestamp
Get when work started.
Sourcepub fn completed_at(&self) -> Timestamp
pub fn completed_at(&self) -> Timestamp
Get when the delegation was completed.
Sourcepub fn result(&self) -> &DelegationResult
pub fn result(&self) -> &DelegationResult
Get the delegation result.
Source§impl Delegation<DelegationRejected>
impl Delegation<DelegationRejected>
Sourcepub fn rejection_reason(&self) -> &str
pub fn rejection_reason(&self) -> &str
Get the rejection reason.
Source§impl Delegation<DelegationFailed>
impl Delegation<DelegationFailed>
Sourcepub fn failure_reason(&self) -> &str
pub fn failure_reason(&self) -> &str
Get the failure reason.
Trait Implementations§
Source§impl<S: Clone + DelegationState> Clone for Delegation<S>
impl<S: Clone + DelegationState> Clone for Delegation<S>
Source§fn clone(&self) -> Delegation<S>
fn clone(&self) -> Delegation<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more