pub struct FileInviteStore { /* private fields */ }Expand description
Invite store persisted at <root>/.server/invites.json.
Implementations§
Source§impl FileInviteStore
impl FileInviteStore
Sourcepub async fn list(&self) -> Result<Vec<InviteRow>, InviteStoreError>
pub async fn list(&self) -> Result<Vec<InviteRow>, InviteStoreError>
Every stored invite, oldest first.
Sourcepub async fn revoke(&self, token: &str) -> Result<bool, InviteStoreError>
pub async fn revoke(&self, token: &str) -> Result<bool, InviteStoreError>
Delete an invite by its token, or by the unique id prefix shown in
invite list (8 or more hex characters). Ok(true) if it existed
(JSS revokeInvite).
Sourcepub async fn consume(&self, token: &str) -> Result<Consume, InviteStoreError>
pub async fn consume(&self, token: &str) -> Result<Consume, InviteStoreError>
Redeem one use of token: checks expiry and the max_uses cap and
records the use, all under the store lock, so two concurrent
redemptions of a single-use invite cannot both succeed. A redemption
path must call this and proceed only on Consume::Granted.
use solid_pod_rs_idp::{Invite, InviteStore};
use solid_pod_rs_server::cli::{Consume, FileInviteStore};
let store = FileInviteStore::new("/var/lib/pod");
store
.insert(Invite { token: "t".into(), max_uses: Some(1), expires_at: None })
.await?;
assert_eq!(store.consume("t").await?, Consume::Granted);
assert_eq!(store.consume("t").await?, Consume::Exhausted);Trait Implementations§
Source§impl InviteStore for FileInviteStore
impl InviteStore for FileInviteStore
Source§fn insert<'life0, 'async_trait>(
&'life0 self,
invite: Invite,
) -> Pin<Box<dyn Future<Output = Result<(), InviteStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
invite: Invite,
) -> Pin<Box<dyn Future<Output = Result<(), InviteStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert an invite. Idempotent on the token: if the token already
exists the call is a no-op that returns
Ok(()). The token is
caller-supplied so the CLI can echo it back to the operator
without a second round-trip.Auto Trait Implementations§
impl !Freeze for FileInviteStore
impl !RefUnwindSafe for FileInviteStore
impl !UnwindSafe for FileInviteStore
impl Send for FileInviteStore
impl Sync for FileInviteStore
impl Unpin for FileInviteStore
impl UnsafeUnpin for FileInviteStore
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
Mutably borrows from an owned value. Read more