Struct bonsaidb::client::BlockingClient
pub struct BlockingClient(_);
Expand description
A BonsaiDb client that blocks the current thread when performing requests.
Implementations§
§impl BlockingClient
impl BlockingClient
pub fn new(url: Url) -> Result<BlockingClient, Error>
pub fn new(url: Url) -> Result<BlockingClient, Error>
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.
pub fn send_api_request<Api>(
&self,
request: &Api
) -> Result<<Api as Api>::Response, ApiError<<Api as Api>::Error>>where
Api: Api,
pub fn send_api_request<Api>( &self, request: &Api ) -> Result<<Api as Api>::Response, ApiError<<Api as Api>::Error>>where Api: Api,
Sends an api request
.
pub fn invoke_api_request<Api>(&self, request: &Api) -> Result<(), Error>where
Api: Api,
pub fn invoke_api_request<Api>(&self, request: &Api) -> Result<(), Error>where Api: Api,
Sends an api request
without waiting for a result. The response from
the server will be ignored.
pub fn as_async(&self) -> &AsyncClient
pub fn as_async(&self) -> &AsyncClient
Returns a reference to an async-compatible version of this client.
pub fn set_request_timeout(&mut self, timeout: impl Into<Duration>)
pub fn set_request_timeout(&mut self, timeout: impl Into<Duration>)
Sets this instance’s request timeout.
Each client has its own timeout. When cloning a client, this timeout setting will be copied to the clone.
Trait Implementations§
§impl Clone for BlockingClient
impl Clone for BlockingClient
§fn clone(&self) -> BlockingClient
fn clone(&self) -> BlockingClient
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for BlockingClient
impl Debug for BlockingClient
§impl From<AsyncClient> for BlockingClient
impl From<AsyncClient> for BlockingClient
§fn from(client: AsyncClient) -> BlockingClient
fn from(client: AsyncClient) -> BlockingClient
§impl From<BlockingClient> for AsyncClient
impl From<BlockingClient> for AsyncClient
§fn from(client: BlockingClient) -> AsyncClient
fn from(client: BlockingClient) -> AsyncClient
§impl HasSession for BlockingClient
impl HasSession for BlockingClient
§fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> boolwhere
R: AsRef<[Identifier<'a>]>,
P: Action,
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> boolwhere R: AsRef<[Identifier<'a>]>, P: Action,
action
is permitted against resource_name
.§fn check_permission<'a, R, P>(
&self,
resource_name: R,
action: &P
) -> Result<(), Error>where
R: AsRef<[Identifier<'a>]>,
P: Action,
fn check_permission<'a, R, P>( &self, resource_name: R, action: &P ) -> Result<(), Error>where R: AsRef<[Identifier<'a>]>, P: Action,
action
is permitted against resource_name
. If permission
is denied, returns a PermissionDenied
error.§impl StorageConnection for BlockingClient
impl StorageConnection for BlockingClient
§type Authenticated = BlockingClient
type Authenticated = BlockingClient
StorageConnection
type returned from authentication calls.§type Database = BlockingRemoteDatabase
type Database = BlockingRemoteDatabase
§fn admin(&self) -> <BlockingClient as StorageConnection>::Database
fn admin(&self) -> <BlockingClient as StorageConnection>::Database
§fn database<DB>(
&self,
name: &str
) -> Result<<BlockingClient as StorageConnection>::Database, Error>where
DB: Schema,
fn database<DB>( &self, name: &str ) -> Result<<BlockingClient as StorageConnection>::Database, Error>where DB: Schema,
name
with schema DB
.§fn create_database_with_schema(
&self,
name: &str,
schema: SchemaName,
only_if_needed: bool
) -> Result<(), Error>
fn create_database_with_schema( &self, name: &str, schema: SchemaName, only_if_needed: bool ) -> Result<(), Error>
§fn list_databases(&self) -> Result<Vec<Database, Global>, Error>
fn list_databases(&self) -> Result<Vec<Database, Global>, Error>
§fn list_available_schemas(&self) -> Result<Vec<SchemaSummary, Global>, Error>
fn list_available_schemas(&self) -> Result<Vec<SchemaSummary, Global>, Error>
SchemaName
s registered with this storage.§fn delete_user<'user, U>(&self, user: U) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
fn delete_user<'user, U>(&self, user: U) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync,
§fn set_user_password<'user, U>(
&self,
user: U,
password: SensitiveString
) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
fn set_user_password<'user, U>( &self, user: U, password: SensitiveString ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync,
§fn authenticate(
&self,
authentication: Authentication
) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
fn authenticate( &self, authentication: Authentication ) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
§fn assume_identity(
&self,
identity: IdentityReference<'_>
) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
fn assume_identity( &self, identity: IdentityReference<'_> ) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
identity
. If successful, the returned instance will have
the permissions from identity
.§fn add_permission_group_to_user<'user, 'group, U, G>(
&self,
user: U,
permission_group: G
) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
G: Nameable<'group, u64> + Send + Sync,
fn add_permission_group_to_user<'user, 'group, U, G>( &self, user: U, permission_group: G ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync,
§fn remove_permission_group_from_user<'user, 'group, U, G>(
&self,
user: U,
permission_group: G
) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
G: Nameable<'group, u64> + Send + Sync,
fn remove_permission_group_from_user<'user, 'group, U, G>( &self, user: U, permission_group: G ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync,
§fn add_role_to_user<'user, 'role, U, R>(
&self,
user: U,
role: R
) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
R: Nameable<'role, u64> + Send + Sync,
fn add_role_to_user<'user, 'role, U, R>( &self, user: U, role: R ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync,
§fn remove_role_from_user<'user, 'role, U, R>(
&self,
user: U,
role: R
) -> Result<(), Error>where
U: Nameable<'user, u64> + Send + Sync,
R: Nameable<'role, u64> + Send + Sync,
fn remove_role_from_user<'user, 'role, U, R>( &self, user: U, role: R ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync,
§fn create_database<DB>(
&self,
name: &str,
only_if_needed: bool
) -> Result<Self::Database, Error>where
DB: Schema,
fn create_database<DB>( &self, name: &str, only_if_needed: bool ) -> Result<Self::Database, Error>where DB: Schema,
§fn authenticate_with_token(
&self,
id: u64,
token: &SensitiveString
) -> Result<<Self::Authenticated as StorageConnection>::Authenticated, Error>
fn authenticate_with_token( &self, id: u64, token: &SensitiveString ) -> Result<<Self::Authenticated as StorageConnection>::Authenticated, Error>
AuthenticationToken
. If
successful, the returned instance will have the permissions from
identity
.§fn authenticate_with_password<'name, User>(
&self,
user: User,
password: SensitiveString
) -> Result<Self::Authenticated, Error>where
User: Nameable<'name, u64>,
fn authenticate_with_password<'name, User>( &self, user: User, password: SensitiveString ) -> Result<Self::Authenticated, Error>where User: Nameable<'name, u64>,
User
using a password. If
successful, the returned instance will have the permissions from
identity
.