Expand description
Client for connecting to a BonsaiDb
server.
Implementations
Initialize a client connecting to url
. This client can be shared by
cloning it. All requests are done asynchronously over the same
connection.
If the client has an error connecting, the first request made will
present that error. If the client disconnects while processing requests,
all requests being processed will exit and return
Error::Disconnected
. The client will automatically try reconnecting.
The goal of this design of this reconnection strategy is to make it easier to build resilliant apps. By allowing existing Client instances to recover and reconnect, each component of the apps built can adopt a “retry-to-recover” design, or “abort-and-fail” depending on how critical the database is to operation.
Sends an api request
.
Returns the current effective permissions for the client. Returns None if unauthenticated.
Trait Implementations
type Database = RemoteDatabase<A>
type Database = RemoteDatabase<A>
The type that represents a database for this implementation.
Creates a database named name
using the SchemaName
schema
. Read more
pub fn database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<<Client<A> as StorageConnection>::Database, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: Schema + 'async_trait,
Client<A>: 'async_trait,
pub fn database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<<Client<A> as StorageConnection>::Database, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: Schema + 'async_trait,
Client<A>: 'async_trait,
Returns a reference to database name
with schema DB
.
Deletes a database named name
. Read more
Lists the databases in this storage.
Lists the SchemaName
s registered with this storage.
Creates a user.
pub fn set_user_password<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn set_user_password<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Sets a user’s password.
pub fn authenticate<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<Authenticated, Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn authenticate<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<Authenticated, Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Authenticates as a user with a authentication method.
pub fn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Adds a user to a permission group.
pub fn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Removes a user from a permission group.
pub fn add_role_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn add_role_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Adds a user to a permission group.
pub fn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
pub fn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: Into<NamedReference<'user>> + Send + Sync + 'async_trait,
G: Into<NamedReference<'group>> + Send + Sync + 'async_trait,
Client<A>: 'async_trait,
Removes a user from a permission group.
Creates a database named name
with the Schema
provided. Read more
Auto Trait Implementations
impl<A = ()> !RefUnwindSafe for Client<A>
impl<A = ()> !UnwindSafe for Client<A>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more