Struct bonsaidb::client::BlockingClient
source · pub struct BlockingClient(/* private fields */);
Expand description
A BonsaiDb client that blocks the current thread when performing requests.
Implementations§
source§impl BlockingClient
impl BlockingClient
sourcepub fn build(url: Url) -> Builder<Blocking>
pub fn build(url: Url) -> Builder<Blocking>
Returns a builder for a new client connecting to url
.
sourcepub 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.
sourcepub 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
.
sourcepub 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.
sourcepub fn as_async(&self) -> &AsyncClient
pub fn as_async(&self) -> &AsyncClient
Returns a reference to an async-compatible version of this client.
sourcepub 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§
source§impl Clone for BlockingClient
impl Clone for BlockingClient
source§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 moresource§impl Debug for BlockingClient
impl Debug for BlockingClient
source§impl From<AsyncClient> for BlockingClient
impl From<AsyncClient> for BlockingClient
source§fn from(client: AsyncClient) -> BlockingClient
fn from(client: AsyncClient) -> BlockingClient
source§impl From<BlockingClient> for AsyncClient
impl From<BlockingClient> for AsyncClient
source§fn from(client: BlockingClient) -> AsyncClient
fn from(client: BlockingClient) -> AsyncClient
source§impl HasSession for BlockingClient
impl HasSession for BlockingClient
source§fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool
action
is permitted against resource_name
.source§fn check_permission<'a, R, P>(
&self,
resource_name: R,
action: &P
) -> Result<(), Error>
fn check_permission<'a, R, P>( &self, resource_name: R, action: &P ) -> Result<(), Error>
action
is permitted against resource_name
. If permission
is denied, returns a PermissionDenied
error.source§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
source§fn admin(&self) -> <BlockingClient as StorageConnection>::Database
fn admin(&self) -> <BlockingClient as StorageConnection>::Database
source§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
.source§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>
source§fn delete_database(&self, name: &str) -> Result<(), Error>
fn delete_database(&self, name: &str) -> Result<(), Error>
name
. Read moresource§fn list_available_schemas(&self) -> Result<Vec<SchemaSummary>, Error>
fn list_available_schemas(&self) -> Result<Vec<SchemaSummary>, Error>
SchemaName
s registered with this storage.source§fn set_user_password<'user, U>(
&self,
user: U,
password: SensitiveString
) -> Result<(), Error>
fn set_user_password<'user, U>( &self, user: U, password: SensitiveString ) -> Result<(), Error>
source§fn authenticate(
&self,
authentication: Authentication
) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
fn authenticate( &self, authentication: Authentication ) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>
source§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
.source§fn add_permission_group_to_user<'user, 'group, U, G>(
&self,
user: U,
permission_group: G
) -> Result<(), Error>
fn add_permission_group_to_user<'user, 'group, U, G>( &self, user: U, permission_group: G ) -> Result<(), Error>
source§fn remove_permission_group_from_user<'user, 'group, U, G>(
&self,
user: U,
permission_group: G
) -> Result<(), Error>
fn remove_permission_group_from_user<'user, 'group, U, G>( &self, user: U, permission_group: G ) -> Result<(), Error>
source§fn add_role_to_user<'user, 'role, U, R>(
&self,
user: U,
role: R
) -> Result<(), Error>
fn add_role_to_user<'user, 'role, U, R>( &self, user: U, role: R ) -> Result<(), Error>
source§fn remove_role_from_user<'user, 'role, U, R>(
&self,
user: U,
role: R
) -> Result<(), Error>
fn remove_role_from_user<'user, 'role, U, R>( &self, user: U, role: R ) -> Result<(), Error>
source§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,
source§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
.source§fn authenticate_with_password<'name, User>(
&self,
user: User,
password: SensitiveString
) -> Result<Self::Authenticated, Error>
fn authenticate_with_password<'name, User>( &self, user: User, password: SensitiveString ) -> Result<Self::Authenticated, Error>
User
using a password. If
successful, the returned instance will have the permissions from
identity
.