pub struct AuthClient<T> { /* private fields */ }Expand description
Typed client for the auth activation, generated by #[plexus_macros::activation(client)].
Generic over the transport: construct it with any plexus_client::Transport — in-process for tests, WebSocket JSON-RPC or REST + SSE against a server.
The parameter and event types are the activation’s own, so a change to a method or an event is a compile error here, not a runtime surprise.
Implementations§
Source§impl<T> AuthClient<T>
impl<T> AuthClient<T>
Sourcepub fn at(transport: T, path: &'static str) -> Self
pub fn at(transport: T, path: &'static str) -> Self
Wrap a transport, for this activation mounted at path —
the dotted route from the hub, e.g. "tickets.inputs" for a
#[child]. A parent’s child accessor builds this; new is
at(transport, NAMESPACE).
Sourcepub fn path(&self) -> &'static str
pub fn path(&self) -> &'static str
The dotted path this client’s calls go to: the namespace, or the child path it was built at.
Sourcepub fn transport(&self) -> &T
pub fn transport(&self) -> &T
Borrow the underlying transport — for reading a
MemoryTransport‘s recorded calls, or sharing one transport
across several activations’ clients.
Sourcepub fn into_transport(self) -> T
pub fn into_transport(self) -> T
Unwrap the transport.
Source§impl<T: Transport> AuthClient<T>
impl<T: Transport> AuthClient<T>
Sourcepub const METHOD_PROVIDERS: MethodRef
pub const METHOD_PROVIDERS: MethodRef
The ways in this server offers
Calls auth.providers.
Sourcepub const METHOD_LOGIN: MethodRef
pub const METHOD_LOGIN: MethodRef
Sign in — a person through the browser, an agent with its key
Calls auth.login.
Sourcepub const METHOD_SIGNUP: MethodRef
pub const METHOD_SIGNUP: MethodRef
Create an account, or ask for access
Calls auth.signup.
Sourcepub const METHOD_WHOAMI: MethodRef
pub const METHOD_WHOAMI: MethodRef
Who you are: principal, roles held where, ceiling
Calls auth.whoami.
Sourcepub const METHOD_LOGOUT: MethodRef
pub const METHOD_LOGOUT: MethodRef
Sign out: end this session
Calls auth.logout.
Sourcepub const METHOD_REQUIRES: MethodRef
pub const METHOD_REQUIRES: MethodRef
What a method needs: its grant, target, and the roles that list it
Calls auth.requires.
Sourcepub const METHOD_ROLES: MethodRef
pub const METHOD_ROLES: MethodRef
Every role and the grants it lists
Calls auth.roles.
Sourcepub const METHOD_ROLE_SET: MethodRef
pub const METHOD_ROLE_SET: MethodRef
Set a role’s grants (admin on *)
Calls auth.role_set.
Sourcepub const METHOD_GRANT: MethodRef
pub const METHOD_GRANT: MethodRef
Give a principal a role on a scope
Calls auth.grant.
Sourcepub const METHOD_REVOKE: MethodRef
pub const METHOD_REVOKE: MethodRef
Take a principal’s role on a scope away
Calls auth.revoke.
Sourcepub const METHOD_WAITING: MethodRef
pub const METHOD_WAITING: MethodRef
Who asked for access and holds nothing yet (admin on *)
Calls auth.waiting.
Sourcepub fn providers(&self) -> EventStream<'_, AuthEvent>
pub fn providers(&self) -> EventStream<'_, AuthEvent>
The ways in this server offers
Calls auth.providers.
Sourcepub async fn providers_all(&self) -> Result<Vec<AuthEvent>, ClientError>
pub async fn providers_all(&self) -> Result<Vec<AuthEvent>, ClientError>
The ways in this server offers
Calls auth.providers.
Drives the stream to completion and collects every data event.
Sourcepub fn login(&self, flow: LoginFlow) -> EventStream<'_, AuthEvent>
pub fn login(&self, flow: LoginFlow) -> EventStream<'_, AuthEvent>
Sign in — a person through the browser, an agent with its key
Calls auth.login.
Sourcepub async fn login_all(
&self,
flow: LoginFlow,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn login_all( &self, flow: LoginFlow, ) -> Result<Vec<AuthEvent>, ClientError>
Sign in — a person through the browser, an agent with its key
Calls auth.login.
Drives the stream to completion and collects every data event.
Sourcepub fn signup(&self, via: Option<ProviderName>) -> EventStream<'_, AuthEvent>
pub fn signup(&self, via: Option<ProviderName>) -> EventStream<'_, AuthEvent>
Create an account, or ask for access
Calls auth.signup.
Sourcepub async fn signup_all(
&self,
via: Option<ProviderName>,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn signup_all( &self, via: Option<ProviderName>, ) -> Result<Vec<AuthEvent>, ClientError>
Create an account, or ask for access
Calls auth.signup.
Drives the stream to completion and collects every data event.
Sourcepub fn whoami(&self) -> EventStream<'_, AuthEvent>
pub fn whoami(&self) -> EventStream<'_, AuthEvent>
Who you are: principal, roles held where, ceiling
Calls auth.whoami.
Sourcepub async fn whoami_all(&self) -> Result<Vec<AuthEvent>, ClientError>
pub async fn whoami_all(&self) -> Result<Vec<AuthEvent>, ClientError>
Who you are: principal, roles held where, ceiling
Calls auth.whoami.
Drives the stream to completion and collects every data event.
Sourcepub fn logout(&self) -> EventStream<'_, AuthEvent>
pub fn logout(&self) -> EventStream<'_, AuthEvent>
Sign out: end this session
Calls auth.logout.
Sourcepub async fn logout_all(&self) -> Result<Vec<AuthEvent>, ClientError>
pub async fn logout_all(&self) -> Result<Vec<AuthEvent>, ClientError>
Sign out: end this session
Calls auth.logout.
Drives the stream to completion and collects every data event.
Sourcepub fn requires(&self, method: MethodPath) -> EventStream<'_, AuthEvent>
pub fn requires(&self, method: MethodPath) -> EventStream<'_, AuthEvent>
What a method needs: its grant, target, and the roles that list it
Calls auth.requires.
Sourcepub async fn requires_all(
&self,
method: MethodPath,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn requires_all( &self, method: MethodPath, ) -> Result<Vec<AuthEvent>, ClientError>
What a method needs: its grant, target, and the roles that list it
Calls auth.requires.
Drives the stream to completion and collects every data event.
Sourcepub fn roles(&self) -> EventStream<'_, AuthEvent>
pub fn roles(&self) -> EventStream<'_, AuthEvent>
Every role and the grants it lists
Calls auth.roles.
Sourcepub async fn roles_all(&self) -> Result<Vec<AuthEvent>, ClientError>
pub async fn roles_all(&self) -> Result<Vec<AuthEvent>, ClientError>
Every role and the grants it lists
Calls auth.roles.
Drives the stream to completion and collects every data event.
Sourcepub fn role_set(
&self,
role: RoleName,
grants: Vec<GrantName>,
) -> EventStream<'_, AuthEvent>
pub fn role_set( &self, role: RoleName, grants: Vec<GrantName>, ) -> EventStream<'_, AuthEvent>
Set a role’s grants (admin on *)
Calls auth.role_set.
Sourcepub async fn role_set_all(
&self,
role: RoleName,
grants: Vec<GrantName>,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn role_set_all( &self, role: RoleName, grants: Vec<GrantName>, ) -> Result<Vec<AuthEvent>, ClientError>
Set a role’s grants (admin on *)
Calls auth.role_set.
Drives the stream to completion and collects every data event.
Sourcepub fn grant(
&self,
principal: Principal,
role: RoleName,
scope: ScopeName,
) -> EventStream<'_, AuthEvent>
pub fn grant( &self, principal: Principal, role: RoleName, scope: ScopeName, ) -> EventStream<'_, AuthEvent>
Give a principal a role on a scope
Calls auth.grant.
Sourcepub async fn grant_all(
&self,
principal: Principal,
role: RoleName,
scope: ScopeName,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn grant_all( &self, principal: Principal, role: RoleName, scope: ScopeName, ) -> Result<Vec<AuthEvent>, ClientError>
Give a principal a role on a scope
Calls auth.grant.
Drives the stream to completion and collects every data event.
Sourcepub fn revoke(
&self,
principal: Principal,
role: Option<RoleName>,
scope: ScopeName,
) -> EventStream<'_, AuthEvent>
pub fn revoke( &self, principal: Principal, role: Option<RoleName>, scope: ScopeName, ) -> EventStream<'_, AuthEvent>
Take a principal’s role on a scope away
Calls auth.revoke.
Sourcepub async fn revoke_all(
&self,
principal: Principal,
role: Option<RoleName>,
scope: ScopeName,
) -> Result<Vec<AuthEvent>, ClientError>
pub async fn revoke_all( &self, principal: Principal, role: Option<RoleName>, scope: ScopeName, ) -> Result<Vec<AuthEvent>, ClientError>
Take a principal’s role on a scope away
Calls auth.revoke.
Drives the stream to completion and collects every data event.
Sourcepub fn waiting(&self) -> EventStream<'_, AuthEvent>
pub fn waiting(&self) -> EventStream<'_, AuthEvent>
Who asked for access and holds nothing yet (admin on *)
Calls auth.waiting.
Sourcepub async fn waiting_all(&self) -> Result<Vec<AuthEvent>, ClientError>
pub async fn waiting_all(&self) -> Result<Vec<AuthEvent>, ClientError>
Who asked for access and holds nothing yet (admin on *)
Calls auth.waiting.
Drives the stream to completion and collects every data event.