Struct bonsaidb::server::CustomServer [−][src]
Expand description
A BonsaiDb server.
Implementations
pub async fn listen_for_tcp_on<S, T>(
&'_ self,
addr: T,
service: S
) -> Result<(), Error> where
S: TcpService,
T: ToSocketAddrs + Send + Sync,
pub async fn listen_for_tcp_on<S, T>(
&'_ self,
addr: T,
service: S
) -> Result<(), Error> where
S: TcpService,
T: ToSocketAddrs + Send + Sync,
Listens for HTTP traffic on port
. This port will also receive
WebSocket
connections if feature websockets
is enabled.
pub async fn listen_for_secure_tcp_on<S, T>(
&'_ self,
addr: T,
service: S
) -> Result<(), Error> where
S: TcpService,
T: ToSocketAddrs + Send + Sync,
pub async fn listen_for_secure_tcp_on<S, T>(
&'_ self,
addr: T,
service: S
) -> Result<(), Error> where
S: TcpService,
T: ToSocketAddrs + Send + Sync,
Listens for HTTPS traffic on port
. This port will also receive
WebSocket
connections if feature websockets
is enabled. If feature
acme
is enabled, this connection will automatically manage the
server’s private key and certificate, which is also used for the
QUIC-based protocol.
Listens for websocket connections on addr
.
pub async fn upgrade_websocket(
&'_ self,
peer_address: SocketAddr,
request: Request<Body>
) -> Response<Body>
pub async fn upgrade_websocket(
&'_ self,
peer_address: SocketAddr,
request: Request<Body>
) -> Response<Body>
Handles upgrading an HTTP connection to the WebSocket
protocol based
on the upgrade request
. Requires feature hyper
to be enabled.
pub async fn handle_websocket<S, E>(
&'_ self,
connection: S,
peer_address: SocketAddr
) where
S: 'static + Stream<Item = Result<Message, E>> + Sink<Message> + Send,
E: Debug + Send,
pub async fn handle_websocket<S, E>(
&'_ self,
connection: S,
peer_address: SocketAddr
) where
S: 'static + Stream<Item = Result<Message, E>> + Sink<Message> + Send,
E: Debug + Send,
Handles an established tokio-tungstenite
WebSocket
stream.
pub async fn open(
configuration: ServerConfiguration<B>
) -> Result<CustomServer<B>, BackendError<<B as Backend>::Error>>
pub async fn open(
configuration: ServerConfiguration<B>
) -> Result<CustomServer<B>, BackendError<<B as Backend>::Error>>
Opens a server using directory
for storage.
Returns the path to the public pinned certificate, if this server has one. Note: this function will always succeed, but the file may not exist.
Returns the primary domain configured for this server.
Returns the administration database.
Installs an X.509 certificate used for general purpose connections.
Installs a certificate chain and private key used for TLS connections.
pub async fn install_certificate(
&'_ self,
certificate_chain: &'_ CertificateChain,
private_key: &'_ PrivateKey
) -> Result<(), Error>
pub async fn install_certificate(
&'_ self,
certificate_chain: &'_ CertificateChain,
private_key: &'_ PrivateKey
) -> Result<(), Error>
Installs a certificate chain and private key used for TLS connections.
Returns the current certificate chain.
Listens for incoming client connections. Does not return until the server shuts down.
Returns all of the currently connected clients.
Sends a custom API response to all connected clients.
Shuts the server down. If a timeout
is provided, the server will stop
accepting new connections and attempt to respond to any outstanding
requests already being processed. After the timeout
has elapsed or if
no timeout
was provided, the server is forcefully shut down.
Listens for signals from the operating system that the server should shut down and attempts to gracefully shut down.
Methods from Deref<Target = AsyncStorage>
Restores all data from a previously stored backup location
.
Stores a copy of all data in this instance to location
.
pub fn with_effective_permissions(
&self,
effective_permissions: Permissions
) -> Option<AsyncStorage>
pub fn with_effective_permissions(
&self,
effective_permissions: Permissions
) -> Option<AsyncStorage>
Restricts an unauthenticated instance to having effective_permissions
.
Returns None
if a session has already been established.
Converts this instance into its blocking version, which is able to be used without async.
Returns a reference to this instance’s blocking version, which is able to be used without async.
Trait Implementations
pub fn read_account<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8, Global>>, <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn read_account<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8, Global>>, <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
CustomServer<B>: 'async_trait,
Returns the previously written data for contacts
, if any. This
function should return None
instead of erroring if data was not
previously written for contacts
. Read more
pub fn write_account<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str],
contents: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn write_account<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str],
contents: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
CustomServer<B>: 'async_trait,
Writes data
for contacts
. The data being written is unique for the
combined list of contacts
. Read more
pub fn write_certificate<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_domains: &'life1 [String],
_directory_url: &'life2 str,
key_pem: &'life3 str,
certificate_pem: &'life4 str
) -> Pin<Box<dyn Future<Output = Result<(), <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn write_certificate<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_domains: &'life1 [String],
_directory_url: &'life2 str,
key_pem: &'life3 str,
certificate_pem: &'life4 str
) -> Pin<Box<dyn Future<Output = Result<(), <CustomServer<B> as AcmeCache>::Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
CustomServer<B>: 'async_trait,
Writes a certificate retrieved from Acme
. The parameters are: Read more
type Database = ServerDatabase<B>
type Database = ServerDatabase<B>
The type that represents a database for this implementation.
type Authenticated = CustomServer<B>
type Authenticated = CustomServer<B>
The StorageConnection
type returned from authentication calls.
pub fn admin<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = <CustomServer<B> as AsyncStorageConnection>::Database> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn admin<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = <CustomServer<B> as AsyncStorageConnection>::Database> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
CustomServer<B>: 'async_trait,
Returns the currently authenticated session, if any.
pub fn create_database_with_schema<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
schema: SchemaName,
only_if_needed: bool
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn create_database_with_schema<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
schema: SchemaName,
only_if_needed: bool
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
CustomServer<B>: 'async_trait,
Creates a database named name
using the SchemaName
schema
. Read more
pub fn database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Database, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: 'async_trait + Schema,
CustomServer<B>: 'async_trait,
pub fn database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Database, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: 'async_trait + Schema,
CustomServer<B>: 'async_trait,
Returns a reference to database name
with schema DB
.
Deletes a database named name
. Read more
Lists the databases in this storage.
pub fn list_available_schemas<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SchemaName, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn list_available_schemas<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SchemaName, Global>, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
CustomServer<B>: 'async_trait,
Lists the SchemaName
s registered with this storage.
Creates a user.
Deletes a user.
pub fn set_user_password<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn set_user_password<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Sets a user’s password.
pub fn authenticate<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Authenticated, Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn authenticate<'user, 'life0, 'async_trait, U>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Authenticated, Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Authenticates as a user with a authentication method.
pub fn assume_identity<'life0, 'life1, 'async_trait>(
&'life0 self,
identity: IdentityReference<'life1>
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Authenticated, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
CustomServer<B>: 'async_trait,
pub fn assume_identity<'life0, 'life1, 'async_trait>(
&'life0 self,
identity: IdentityReference<'life1>
) -> Pin<Box<dyn Future<Output = Result<<CustomServer<B> as AsyncStorageConnection>::Authenticated, Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
CustomServer<B>: 'async_trait,
Assumes the identity
. If successful, the returned instance will have
the merged permissions of the current authentication session and the
permissions from identity
. Read more
pub fn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Adds a user to a permission group.
pub fn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Removes a user from a permission group.
pub fn add_role_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn add_role_to_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Adds a user to a permission group.
pub fn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
pub fn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U, G>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'user: 'async_trait,
'group: 'async_trait,
'life0: 'async_trait,
U: 'async_trait + Nameable<'user, u64> + Send + Sync,
G: 'async_trait + Nameable<'group, u64> + Send + Sync,
CustomServer<B>: 'async_trait,
Removes a user from a permission group.
Creates a database named name
with the Schema
provided. Read more
type Target = AsyncStorage
type Target = AsyncStorage
The resulting type after dereferencing.
Dereferences the value.
Performs the conversion.
Performs the conversion.
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool where
R: AsRef<[Identifier<'a>]>,
P: Action,
fn allowed_to<'a, R, P>(&self, resource_name: R, action: &P) -> bool where
R: AsRef<[Identifier<'a>]>,
P: Action,
Checks if action
is permitted against resource_name
.
Checks if action
is permitted against resource_name
. If permission
is denied, returns a PermissionDenied
error. Read more
Auto Trait Implementations
impl<B = NoBackend> !RefUnwindSafe for CustomServer<B>
impl<B> Send for CustomServer<B>
impl<B> Sync for CustomServer<B>
impl<B> Unpin for CustomServer<B>
impl<B = NoBackend> !UnwindSafe for CustomServer<B>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more