pub struct AuthClient<T, L = Root> { /* 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.
A one-item method is an async fn returning Result<item, ClientError>; a many-item method returns a MethodStream. The parameter and item types are the activation’s own, so a change to either 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: impl Into<RoutePath>) -> Self
pub fn at(transport: T, path: impl Into<RoutePath>) -> Self
Wrap a transport, for this activation mounted at path —
the dotted route from the service, e.g. "tickets.inputs"
for a #[child]. new is at(transport, NAMESPACE). Its
events are this activation’s own aggregate; a parent’s child
accessor builds one whose events are the parent’s.
Source§impl<T, L> AuthClient<T, L>
impl<T, L> AuthClient<T, L>
Sourcepub fn lifted(transport: T, route: Route, lift: L) -> Self
pub fn lifted(transport: T, route: Route, lift: L) -> Self
RETURNS-46: a client on route whose calls’ .events() are
lifted by lift — what a parent’s child accessor builds
(TreeClient::branch() lifts into TreeEvent).
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &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.
Source§impl<T: Transport, L: Lift<AuthAggregate>> AuthClient<T, L>
impl<T: Transport, L: Lift<AuthAggregate>> AuthClient<T, L>
Sourcepub fn providers(&self) -> AuthProvidersStream<'_, L>
pub fn providers(&self) -> AuthProvidersStream<'_, L>
The ways in this server offers
Calls auth.providers.
Many items, as a stream of Result<item, ClientError> — a AuthProvidersStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Providers — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn login(&self, flow: LoginFlow) -> AuthLoginStream<'_, L>
pub fn login(&self, flow: LoginFlow) -> AuthLoginStream<'_, L>
Sign in — a person through the browser, an agent with its key
Calls auth.login.
Many items, as a stream of Result<item, ClientError> — a AuthLoginStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Login — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn signup(&self, via: Option<ProviderName>) -> AuthSignupStream<'_, L>
pub fn signup(&self, via: Option<ProviderName>) -> AuthSignupStream<'_, L>
Create an account, or ask for access
Calls auth.signup.
Many items, as a stream of Result<item, ClientError> — a AuthSignupStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Signup — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn whoami(&self) -> AuthWhoamiStream<'_, L>
pub fn whoami(&self) -> AuthWhoamiStream<'_, L>
Who you are: principal, roles held where, ceiling
Calls auth.whoami.
Many items, as a stream of Result<item, ClientError> — a AuthWhoamiStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Whoami — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn logout(&self) -> AuthLogoutStream<'_, L>
pub fn logout(&self) -> AuthLogoutStream<'_, L>
Sign out: end this session
Calls auth.logout.
Many items, as a stream of Result<item, ClientError> — a AuthLogoutStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Logout — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn requires(&self, method: MethodPath) -> AuthRequiresStream<'_, L>
pub fn requires(&self, method: MethodPath) -> AuthRequiresStream<'_, L>
What a method needs: its grant, target, and the roles that list it
Calls auth.requires.
Many items, as a stream of Result<item, ClientError> — a AuthRequiresStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Requires — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn roles(&self) -> AuthRolesStream<'_, L>
pub fn roles(&self) -> AuthRolesStream<'_, L>
Every role and the grants it lists
Calls auth.roles.
Many items, as a stream of Result<item, ClientError> — a AuthRolesStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Roles — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn role_set(
&self,
role: RoleName,
grants: Vec<GrantName>,
) -> AuthRoleSetStream<'_, L>
pub fn role_set( &self, role: RoleName, grants: Vec<GrantName>, ) -> AuthRoleSetStream<'_, L>
Set a role’s grants (admin on *)
Calls auth.role_set.
Many items, as a stream of Result<item, ClientError> — a AuthRoleSetStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::RoleSet — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn grant(
&self,
principal: Principal,
role: RoleName,
scope: ScopeName,
) -> AuthGrantStream<'_, L>
pub fn grant( &self, principal: Principal, role: RoleName, scope: ScopeName, ) -> AuthGrantStream<'_, L>
Give a principal a role on a scope
Calls auth.grant.
Many items, as a stream of Result<item, ClientError> — a AuthGrantStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Grant — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn revoke(
&self,
principal: Principal,
role: Option<RoleName>,
scope: ScopeName,
) -> AuthRevokeStream<'_, L>
pub fn revoke( &self, principal: Principal, role: Option<RoleName>, scope: ScopeName, ) -> AuthRevokeStream<'_, L>
Take a principal’s role on a scope away
Calls auth.revoke.
Many items, as a stream of Result<item, ClientError> — a AuthRevokeStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Revoke — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Sourcepub fn waiting(&self) -> AuthWaitingStream<'_, L>
pub fn waiting(&self) -> AuthWaitingStream<'_, L>
Who asked for access and holds nothing yet (admin on *)
Calls auth.waiting.
Many items, as a stream of Result<item, ClientError> — a AuthWaitingStream; progress is dropped unless opted in with .with_progress(), and .events() yields AuthAggregate::Waiting — lifted by L into the aggregate of the client this one was reached from (RETURNS-46).
Trait Implementations§
Source§impl<T, L> Aggregated for AuthClient<T, L>
impl<T, L> Aggregated for AuthClient<T, L>
Source§type Event = AuthAggregate
type Event = AuthAggregate
Source§impl<T: Debug, L> Debug for AuthClient<T, L>
impl<T: Debug, L> Debug for AuthClient<T, L>
Source§impl<T: Default> Default for AuthClient<T>
impl<T: Default> Default for AuthClient<T>
Source§impl<T> FromRoute<T> for AuthClient<T>
impl<T> FromRoute<T> for AuthClient<T>
Source§fn from_route(transport: T, route: Route) -> Self
fn from_route(transport: T, route: Route) -> Self
route, over transport.Source§impl<__T, __L> ParentHash for AuthClient<__T, __L>
impl<__T, __L> ParentHash for AuthClient<__T, __L>
Source§impl<__T, __L> ParentShape for AuthClient<__T, __L>
impl<__T, __L> ParentShape for AuthClient<__T, __L>
Source§fn resolve(segments: &[&str]) -> Option<(String, Option<String>)>
fn resolve(segments: &[&str]) -> Option<(String, Option<String>)>
segments are a call chain’s names as the Rust code wrote them
(["ui", "slots", "list", "collect"]). The wire path of the method the
chain calls, below this client’s node ("ui.slots.list"), and its
shape hash where known; None when the chain names no method of this
client (a dynamic child’s or a peer slot’s accessor, which take a name
only known when the code runs).Source§impl<__T, __L> ShapeCheck for AuthClient<__T, __L>
impl<__T, __L> ShapeCheck for AuthClient<__T, __L>
Source§fn shape_check(path: &str, schema: &Value) -> Result<(), ClientError>
fn shape_check(path: &str, schema: &Value) -> Result<(), ClientError>
Ok when schema — the node at path’s answer to schema — serves
every method this client calls under the same shape; else
ClientError::ShapeMismatch naming those it does not.