pub struct TargetTokenMap { /* private fields */ }Expand description
Account-scoped map from opaque tokens to authorized cases for one turn.
Implementations§
Source§impl TargetTokenMap
impl TargetTokenMap
Sourcepub fn new(account_id: AccountId, turn_id: TurnId) -> Self
pub fn new(account_id: AccountId, turn_id: TurnId) -> Self
Creates an empty map for one account and turn.
Sourcepub fn account_id(&self) -> &AccountId
pub fn account_id(&self) -> &AccountId
The account the map is scoped to.
Sourcepub fn issue(
&mut self,
case_ref: CaseRef,
label: impl Into<String>,
) -> TargetToken
pub fn issue( &mut self, case_ref: CaseRef, label: impl Into<String>, ) -> TargetToken
Issues (or returns the existing) token for a case.
Tokens are derived deterministically from the account, turn and case so a
replayed turn reproduces the same catalog; they are opaque and carry no
database identifier. Re-issuing for a case already in the map updates the
label and revision and restores Authorized.
Sourcepub fn resolve(
&self,
account: &AccountId,
token: &TargetToken,
) -> TargetResolution
pub fn resolve( &self, account: &AccountId, token: &TargetToken, ) -> TargetResolution
Resolves a token for account.
A different account, an unknown token and another tenant’s token all
yield Unauthorized. Missing and Stale are reported only for tokens
issued in this map and marked as such.
Sourcepub fn mark_missing(&mut self, token: &TargetToken) -> bool
pub fn mark_missing(&mut self, token: &TargetToken) -> bool
Marks a token’s case as gone. Returns false when the token is unknown.
Sourcepub fn mark_stale(
&mut self,
token: &TargetToken,
current_revision: CaseRevision,
) -> bool
pub fn mark_stale( &mut self, token: &TargetToken, current_revision: CaseRevision, ) -> bool
Marks a token’s case as moved to current_revision. Returns false when
the token is unknown.
Sourcepub fn token_for(&self, key: &CaseKey) -> Option<&TargetToken>
pub fn token_for(&self, key: &CaseKey) -> Option<&TargetToken>
The token issued for a case, if any.
Sourcepub fn get(&self, token: &TargetToken) -> Option<&TargetEntry>
pub fn get(&self, token: &TargetToken) -> Option<&TargetEntry>
Entry behind a token, without an account check. For the runtime that owns
the map; client-facing paths must use Self::resolve.
Sourcepub fn candidates(&self) -> Vec<TargetCandidate>
pub fn candidates(&self) -> Vec<TargetCandidate>
All authorized candidates, for the interpretation catalog.
Sourcepub fn candidates_for(&self, workflow: &WorkflowKey) -> Vec<TargetCandidate>
pub fn candidates_for(&self, workflow: &WorkflowKey) -> Vec<TargetCandidate>
Authorized candidates of one workflow, for resolving mentions.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&TargetToken, &TargetEntry)>
pub fn iter(&self) -> impl Iterator<Item = (&TargetToken, &TargetEntry)>
Iterates all entries.
Trait Implementations§
Source§impl Clone for TargetTokenMap
impl Clone for TargetTokenMap
Source§impl Debug for TargetTokenMap
impl Debug for TargetTokenMap
Source§impl<'de> Deserialize<'de> for TargetTokenMap
impl<'de> Deserialize<'de> for TargetTokenMap
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>,
impl Eq for TargetTokenMap
Source§impl PartialEq for TargetTokenMap
impl PartialEq for TargetTokenMap
Source§impl Serialize for TargetTokenMap
impl Serialize for TargetTokenMap
impl StructuralPartialEq for TargetTokenMap
Auto Trait Implementations§
impl Freeze for TargetTokenMap
impl RefUnwindSafe for TargetTokenMap
impl Send for TargetTokenMap
impl Sync for TargetTokenMap
impl Unpin for TargetTokenMap
impl UnsafeUnpin for TargetTokenMap
impl UnwindSafe for TargetTokenMap
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.