pub trait ConsistencyTokenStore:
Send
+ Sync
+ Debug {
// Required methods
fn get(&self) -> String;
fn set(&self, token: String);
// Provided methods
fn replace(&self, presented: &str, answered: String) { ... }
fn remove(&self, refused: &str) { ... }
}Expand description
Holds the consistency token a client presents. The client reads it
before each attempt of an authenticated call, replaces it with the token
an answer carries, and removes one the API refused.
It must be Send + Sync on every target, as Client
is, so that a client can live in a browser app’s reactive state. In a
browser a store therefore holds the token in something Send + Sync,
such as a Mutex or a reactive signal, and copies it to
web_sys::Storage from there if it is to outlive the page, rather than
wrapping the Storage itself, which isn’t Send. Its methods are
synchronous, and are called with no lock of the client’s held.
Required Methods§
Provided Methods§
Sourcefn replace(&self, presented: &str, answered: String)
fn replace(&self, presented: &str, answered: String)
Replaces the token held with answered, the token the answer to a
call that presented presented (empty for none) carried. A store
that holds a token other than presented by then was written by a
concurrent call in between, and may keep one or the other as it
sees fit; the default sets answered, so the token
answered last is kept.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".