Trait bonsaidb::core::connection::StorageConnection [−][src]
pub trait StorageConnection: HasSession + Send + Sync {
type Database: Connection;
type Authenticated: StorageConnection;
Show 16 methods
fn admin(&self) -> Self::Database;
fn database<DB>(&self, name: &str) -> Result<Self::Database, Error>
where
DB: Schema;
fn create_database_with_schema(
&self,
name: &str,
schema: SchemaName,
only_if_needed: bool
) -> Result<(), Error>;
fn delete_database(&self, name: &str) -> Result<(), Error>;
fn list_databases(&self) -> Result<Vec<Database, Global>, Error>;
fn list_available_schemas(&self) -> Result<Vec<SchemaName, Global>, Error>;
fn create_user(&self, username: &str) -> Result<u64, Error>;
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 authenticate<'user, U>(
&self,
user: U,
authentication: Authentication
) -> Result<Self::Authenticated, Error>
where
U: Nameable<'user, u64> + Send + Sync;
fn assume_identity(
&self,
identity: IdentityReference<'_>
) -> Result<Self::Authenticated, Error>;
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 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 create_database<DB>(
&self,
name: &str,
only_if_needed: bool
) -> Result<Self::Database, Error>
where
DB: Schema,
{ ... }
}
Expand description
Functions for interacting with a multi-database BonsaiDb instance.
Associated Types
type Database: Connection
type Database: Connection
The type that represents a database for this implementation.
The StorageConnection
type returned from authentication calls.
Required methods
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>
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
.
Errors
Error::InvalidDatabaseName
:name
must begin with an alphanumeric character ([a-zA-Z0-9]
), and all remaining characters must be alphanumeric, a period (.
), or a hyphen (-
).Error::DatabaseNameAlreadyTaken
:name
was already used for a previous database name. Database names are case insensitive. Returned ifonly_if_needed
is false.
Deletes a database named name
.
Errors
Error::DatabaseNotFound
: databasename
does not exist.Error::Io
: an error occurred while deleting files.
Lists the databases in this storage.
fn list_available_schemas(&self) -> Result<Vec<SchemaName, Global>, Error>
fn list_available_schemas(&self) -> Result<Vec<SchemaName, Global>, Error>
Lists the SchemaName
s registered with this storage.
Deletes a user.
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,
Sets a user’s password.
fn authenticate<'user, U>(
&self,
user: U,
authentication: Authentication
) -> Result<Self::Authenticated, Error> where
U: Nameable<'user, u64> + Send + Sync,
fn authenticate<'user, U>(
&self,
user: U,
authentication: Authentication
) -> Result<Self::Authenticated, Error> where
U: Nameable<'user, u64> + Send + Sync,
Authenticates as a user with a authentication method.
fn assume_identity(
&self,
identity: IdentityReference<'_>
) -> Result<Self::Authenticated, Error>
fn assume_identity(
&self,
identity: IdentityReference<'_>
) -> Result<Self::Authenticated, Error>
Assumes the identity
. If successful, the returned instance will have
the merged permissions of the current authentication session and the
permissions from identity
.
Adds a user to a permission group.
Removes a user from a permission group.
Adds a user to a permission group.
Provided methods
Creates a database named name
with the Schema
provided.
Errors
Error::InvalidDatabaseName
:name
must begin with an alphanumeric character ([a-zA-Z0-9]
), and all remaining characters must be alphanumeric, a period (.
), or a hyphen (-
).Error::DatabaseNameAlreadyTaken
:name
was already used for a previous database name. Database names are case insensitive. Returned ifonly_if_needed
is false.