pub struct OrgStore { /* private fields */ }Implementations§
Source§impl OrgStore
impl OrgStore
pub fn new() -> Self
pub fn with_backend(backend: Box<dyn OrgBackend>) -> Self
Sourcepub fn create(&self, name: &str, creator_id: &str) -> Org
pub fn create(&self, name: &str, creator_id: &str) -> Org
Create an org. Creator becomes Owner.
pub fn get(&self, org_id: &str) -> Option<Org>
pub fn list_for_user(&self, user_id: &str) -> Vec<(Org, OrgRole)>
pub fn list_members(&self, org_id: &str) -> Vec<Membership>
pub fn role_of(&self, org_id: &str, user_id: &str) -> Option<OrgRole>
pub fn set_role(&self, org_id: &str, user_id: &str, role: OrgRole) -> bool
pub fn remove_member(&self, org_id: &str, user_id: &str) -> bool
Sourcepub fn delete(&self, org_id: &str) -> bool
pub fn delete(&self, org_id: &str) -> bool
Delete an org + all its memberships + all pending invites.
Sourcepub fn create_invite(
&self,
org_id: &str,
email: &str,
role: OrgRole,
invited_by: &str,
) -> InviteWithToken
pub fn create_invite( &self, org_id: &str, email: &str, role: OrgRole, invited_by: &str, ) -> InviteWithToken
Mint an invite. Returns the plaintext token alongside the
stored record — caller is responsible for emailing the
plaintext to the invitee. The token is single-use, expires
in 7 days, and is rejected for any account whose email
doesn’t match the invite’s email field.
pub fn list_invites(&self, org_id: &str) -> Vec<Invite>
pub fn revoke_invite(&self, invite_id: &str) -> bool
Sourcepub fn accept_invite(
&self,
token: &str,
accepting_user_id: &str,
accepting_email: &str,
) -> Result<Membership, AcceptError>
pub fn accept_invite( &self, token: &str, accepting_user_id: &str, accepting_email: &str, ) -> Result<Membership, AcceptError>
Accept an invite. Verifies the token (Argon2 hash compare),
checks expiry + accepted-at, ensures the accepting user’s
email matches the invite, and either creates the membership
or returns the right error variant. The invite row is
updated with accepted_at (not deleted) so the audit trail
stays intact.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OrgStore
impl !RefUnwindSafe for OrgStore
impl Send for OrgStore
impl Sync for OrgStore
impl Unpin for OrgStore
impl UnsafeUnpin for OrgStore
impl !UnwindSafe for OrgStore
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