pub struct AccountService { /* private fields */ }Expand description
Connecting, listing and disconnecting accounts.
Keeps the two halves of an account consistent: the record in storage and the credentials in the credential store.
Implementations§
Source§impl AccountService
impl AccountService
pub fn new( accounts: AccountStore, tokens: TokenStore, events: EventBus, storage: Arc<dyn Storage>, clock: Arc<dyn Clock>, ) -> Self
Sourcepub async fn connect(
&self,
connector: &ConnectorId,
display_name: impl Into<String>,
tokens: &TokenSet,
) -> Result<Account>
pub async fn connect( &self, connector: &ConnectorId, display_name: impl Into<String>, tokens: &TokenSet, ) -> Result<Account>
Register a freshly authorized account.
Credentials are written first so no visible account can exist without them. If persisting the account fails, the credential write is rolled back.
Sourcepub async fn connect_with_token(
&self,
connector: &ConnectorId,
display_name: impl Into<String>,
token: impl Into<String>,
scopes: Vec<String>,
) -> Result<Account>
pub async fn connect_with_token( &self, connector: &ConnectorId, display_name: impl Into<String>, token: impl Into<String>, scopes: Vec<String>, ) -> Result<Account>
Register an account from a pasted token instead of an OAuth flow (B7/C1).
The caller is expected to have verified the token against the service first —
this method only records it. Same credential-first ordering and rollback as
AccountService::connect.
pub async fn list(&self) -> Result<Vec<Account>>
pub async fn list_for(&self, connector: &ConnectorId) -> Result<Vec<Account>>
pub async fn get(&self, account: &AccountId) -> Result<Account>
Sourcepub async fn disconnect(&self, account: &AccountId) -> Result<()>
pub async fn disconnect(&self, account: &AccountId) -> Result<()>
Remove an account, its credentials and everything stored under it.
The namespace convention (ADR-0019) is what makes the last part mechanical: all
account data lives under acct.<connector>.<account>., so no module has to
register which namespaces it wrote.
Sourcepub async fn mark_expired(&self, account: &AccountId) -> Result<()>
pub async fn mark_expired(&self, account: &AccountId) -> Result<()>
Mark an account as needing re-authentication.
Called when a connector reports that credentials are no longer valid. The credentials are kept: a provider outage can look like an expired token, and deleting them would force an unnecessary reconnect.
Sourcepub async fn mark_active(&self, account: &AccountId) -> Result<()>
pub async fn mark_active(&self, account: &AccountId) -> Result<()>
Mark an account usable again after a successful verification.
Trait Implementations§
Source§impl Clone for AccountService
impl Clone for AccountService
Source§fn clone(&self) -> AccountService
fn clone(&self) -> AccountService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more