pub struct BlockingClient(_);
Expand description

A BonsaiDb client that blocks the current thread when performing requests.

Implementations§

§

impl BlockingClient

pub fn build(url: Url) -> Builder<Blocking>

Returns a builder for a new client connecting to url.

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,

Sends an api request.

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

Returns a reference to an async-compatible version of this client.

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

§

fn clone(&self) -> BlockingClient

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for BlockingClient

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<AsyncClient> for BlockingClient

§

fn from(client: AsyncClient) -> BlockingClient

Converts to this type from the input type.
§

impl From<BlockingClient> for AsyncClient

§

fn from(client: BlockingClient) -> AsyncClient

Converts to this type from the input type.
§

impl HasSession for BlockingClient

§

fn session(&self) -> Option<&Session>

Returns the currently authenticated session, if any.
§

fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> boolwhere R: AsRef<[Identifier<'a>]>, P: Action,

Checks if 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,

Checks if action is permitted against resource_name. If permission is denied, returns a PermissionDenied error.
§

impl StorageConnection for BlockingClient

§

type Authenticated = BlockingClient

The StorageConnection type returned from authentication calls.
§

type Database = BlockingRemoteDatabase

The type that represents a database for this implementation.
§

fn admin(&self) -> <BlockingClient as StorageConnection>::Database

Returns the administration database.
§

fn database<DB>( &self, name: &str ) -> Result<<BlockingClient as StorageConnection>::Database, Error>where DB: Schema,

Returns a reference to database name with schema DB.
§

fn create_database_with_schema( &self, name: &str, schema: SchemaName, only_if_needed: bool ) -> Result<(), Error>

Creates a database named name using the SchemaName schema. Read more
§

fn delete_database(&self, name: &str) -> Result<(), Error>

Deletes a database named name. Read more
§

fn list_databases(&self) -> Result<Vec<Database, Global>, Error>

Lists the databases in this storage.
§

fn list_available_schemas(&self) -> Result<Vec<SchemaSummary, Global>, Error>

Lists the SchemaNames registered with this storage.
§

fn create_user(&self, username: &str) -> Result<u64, Error>

Creates a user.
§

fn delete_user<'user, U>(&self, user: U) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync,

Deletes a user.
§

fn set_user_password<'user, U>( &self, user: U, password: SensitiveString ) -> Result<(), Error>where U: Nameable<'user, u64> + Send + Sync,

Sets a user’s password.
§

fn authenticate( &self, authentication: Authentication ) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>

Authenticates using the active session, returning a connection with a new session upon success. The existing connection will remain usable with the existing authentication, if any.
§

fn assume_identity( &self, identity: IdentityReference<'_> ) -> Result<<BlockingClient as StorageConnection>::Authenticated, Error>

Assumes the 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,

Adds a user to a permission group.
§

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,

Removes a user from a permission group.
§

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,

Adds a user to a permission group.
§

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,

Removes a user from a permission group.
§

fn create_database<DB>( &self, name: &str, only_if_needed: bool ) -> Result<Self::Database, Error>where DB: Schema,

Creates a database named name with the Schema provided. Read more
§

fn authenticate_with_token( &self, id: u64, token: &SensitiveString ) -> Result<<Self::Authenticated as StorageConnection>::Authenticated, Error>

Authenticates using an 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>,

Authenticates a User using a password. If successful, the returned instance will have the permissions from identity.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more