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<Self, Error>
pub fn new(url: Url) -> Result<Self, 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: Api>(
&self,
request: &Api,
) -> Result<Api::Response, ApiError<Api::Error>>
pub fn send_api_request<Api: Api>( &self, request: &Api, ) -> Result<Api::Response, ApiError<Api::Error>>
Sends an api request.
Sourcepub fn invoke_api_request<Api: Api>(&self, request: &Api) -> Result<(), Error>
pub fn invoke_api_request<Api: Api>(&self, request: &Api) -> Result<(), Error>
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) -> Self
fn from(client: AsyncClient) -> Self
Source§impl From<BlockingClient> for AsyncClient
impl From<BlockingClient> for AsyncClient
Source§fn from(client: BlockingClient) -> Self
fn from(client: BlockingClient) -> Self
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
Source§type Authenticated = BlockingClient
type Authenticated = BlockingClient
StorageConnection type returned from authentication calls.Source§type Database = BlockingRemoteDatabase
type Database = BlockingRemoteDatabase
Source§fn database<DB: Schema>(&self, name: &str) -> Result<Self::Database, Error>
fn database<DB: Schema>(&self, name: &str) -> Result<Self::Database, Error>
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>
SchemaNames registered with this storage.Source§fn delete_user<'user, U: Nameable<'user, u64> + Send + Sync>(
&self,
user: U,
) -> Result<(), Error>
fn delete_user<'user, U: Nameable<'user, u64> + Send + Sync>( &self, user: U, ) -> Result<(), Error>
Source§fn set_user_password<'user, U: Nameable<'user, u64> + Send + Sync>(
&self,
user: U,
password: SensitiveString,
) -> Result<(), Error>
fn set_user_password<'user, U: Nameable<'user, u64> + Send + Sync>( &self, user: U, password: SensitiveString, ) -> Result<(), Error>
Source§fn authenticate(
&self,
authentication: Authentication,
) -> Result<Self::Authenticated, Error>
fn authenticate( &self, authentication: Authentication, ) -> Result<Self::Authenticated, Error>
Source§fn assume_identity(
&self,
identity: IdentityReference<'_>,
) -> Result<Self::Authenticated, Error>
fn assume_identity( &self, identity: IdentityReference<'_>, ) -> Result<Self::Authenticated, Error>
identity. If successful, the returned instance will have
the permissions from identity.Source§fn add_permission_group_to_user<'user, 'group, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&self,
user: U,
permission_group: G,
) -> Result<(), Error>
fn add_permission_group_to_user<'user, 'group, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>( &self, user: U, permission_group: G, ) -> Result<(), Error>
Source§fn remove_permission_group_from_user<'user, 'group, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&self,
user: U,
permission_group: G,
) -> Result<(), Error>
fn remove_permission_group_from_user<'user, 'group, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>( &self, user: U, permission_group: G, ) -> Result<(), Error>
Source§fn add_role_to_user<'user, 'role, U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync>(
&self,
user: U,
role: R,
) -> Result<(), Error>
fn add_role_to_user<'user, 'role, U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync>( &self, user: U, role: R, ) -> Result<(), Error>
Source§fn remove_role_from_user<'user, 'role, U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync>(
&self,
user: U,
role: R,
) -> Result<(), Error>
fn remove_role_from_user<'user, 'role, U: Nameable<'user, u64> + Send + Sync, R: Nameable<'role, u64> + Send + Sync>( &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.Auto Trait Implementations§
impl Freeze for BlockingClient
impl !RefUnwindSafe for BlockingClient
impl Send for BlockingClient
impl Sync for BlockingClient
impl Unpin for BlockingClient
impl !UnwindSafe for BlockingClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more