pub struct CapTokenRecord {
pub token: CapToken,
pub uses_left: Option<u32>,
pub revoked: bool,
pub task_id: Option<TaskId>,
}Expand description
Server-side counter/state holder paired 1:1 with a minted CapToken
(keyed by nonce in EngineState.tokens). Tracks remaining uses,
revocation, and — for Worker tokens — the task the token is bound to.
Fields§
§token: CapTokenThe token this record backs.
uses_left: Option<u32>Remaining number of verb-consuming calls. None means unlimited
(session-style tokens); Some(0) makes consume fail.
revoked: boolWhen true, consume always fails regardless of uses_left.
task_id: Option<TaskId>The task this Worker token is bound to (set when minted via
dispatch_attempt). Used on two axes:
-
Depth tracking. When a Worker calls
start_taskto spawn a child, the child receives this task’sspawn_depth + 1. -
Ownership gate. When a Worker calls a state-touch verb (
fetch_prompt/post_result/read_task_state/cancel_task/poll_task), the argument’stask_idmust match this value.start_taskanddispatch_attemptare exempt — recursive swarming must stay open, and depth is capped bymax_spawn_depth.Operator tokens (minted at attach time) leave this
None, so they can touch any task.
Implementations§
Source§impl CapTokenRecord
impl CapTokenRecord
Sourcepub fn from_token(token: CapToken) -> Self
pub fn from_token(token: CapToken) -> Self
Wrap a freshly minted CapToken with no bound task (task_id = None) — the shape used for Operator/session tokens.
Sourcepub fn from_worker_token(token: CapToken, task_id: TaskId) -> Self
pub fn from_worker_token(token: CapToken, task_id: TaskId) -> Self
Convenience constructor used when minting a Worker token — binds the record to the target task.
Sourcepub fn consume(&mut self) -> Result<(), CapTokenConsumeError>
pub fn consume(&mut self) -> Result<(), CapTokenConsumeError>
Consume one use. None (session token) always returns Ok;
Some(0) returns Err.
Trait Implementations§
Source§impl Clone for CapTokenRecord
impl Clone for CapTokenRecord
Source§fn clone(&self) -> CapTokenRecord
fn clone(&self) -> CapTokenRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CapTokenRecord
impl Debug for CapTokenRecord
Source§impl<'de> Deserialize<'de> for CapTokenRecord
impl<'de> Deserialize<'de> for CapTokenRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CapTokenRecord
impl RefUnwindSafe for CapTokenRecord
impl Send for CapTokenRecord
impl Sync for CapTokenRecord
impl Unpin for CapTokenRecord
impl UnsafeUnpin for CapTokenRecord
impl UnwindSafe for CapTokenRecord
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more