pub struct TokenStore(/* private fields */);Expand description
The issued confirmations of one server process.
Implementations§
Source§impl TokenStore
impl TokenStore
Sourcepub fn issue(&self, plan: &EditPlan, repository: &Path) -> ConfirmToken
pub fn issue(&self, plan: &EditPlan, repository: &Path) -> ConfirmToken
Issues a confirmation for a previewed plan.
Sourcepub fn consume_for_plan(
&self,
presented: Option<&str>,
repository: &Path,
) -> Result<EditPlan, Value>
pub fn consume_for_plan( &self, presented: Option<&str>, repository: &Path, ) -> Result<EditPlan, Value>
Consumes a confirmation presented alone and returns the plan it previewed.
The checks are the ones consume makes, minus the fingerprint comparison — there is no
second copy of the plan to compare, which is the point: the stored plan is the one the
fingerprint was computed from.
§Errors
Returns the contract refusal — TOKEN_UNKNOWN, TOKEN_EXPIRED or
TOKEN_REPOSITORY_MISMATCH — when the confirmation cannot be honoured. The token is
spent either way, so a caller cannot probe with the same value twice.
Sourcepub fn consume(
&self,
presented: Option<&str>,
plan: &EditPlan,
repository: &Path,
) -> Option<Value>
pub fn consume( &self, presented: Option<&str>, plan: &EditPlan, repository: &Path, ) -> Option<Value>
Consumes a confirmation, or returns the refusal that says why it could not be.
Consuming happens whether or not the checks pass: a token that was presented is spent, so a caller cannot probe with the same value twice.