Struct bonsaidb_server::CustomServer
source · [−]Expand description
A BonsaiDb server.
Implementations
sourceimpl<B: Backend> CustomServer<B>
impl<B: Backend> CustomServer<B>
sourcepub async fn listen_for_tcp_on<S: TcpService, T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
service: S
) -> Result<(), Error>
pub async fn listen_for_tcp_on<S: TcpService, T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
service: S
) -> Result<(), Error>
Listens for HTTP traffic on port. This port will also receive
WebSocket connections if feature websockets is enabled.
sourcepub async fn listen_for_secure_tcp_on<S: TcpService, T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
service: S
) -> Result<(), Error>
pub async fn listen_for_secure_tcp_on<S: TcpService, T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
service: S
) -> Result<(), Error>
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.
sourceimpl<B: Backend> CustomServer<B>
impl<B: Backend> CustomServer<B>
sourcepub async fn listen_for_websockets_on<T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
with_tls: bool
) -> Result<(), Error>
pub async fn listen_for_websockets_on<T: ToSocketAddrs + Send + Sync>(
&self,
addr: T,
with_tls: bool
) -> Result<(), Error>
Listens for websocket connections on addr.
sourcepub async fn handle_websocket<S: Stream<Item = Result<Message, E>> + Sink<Message> + Send + 'static, E: Debug + Send>(
&self,
connection: S,
peer_address: SocketAddr
)
pub async fn handle_websocket<S: Stream<Item = Result<Message, E>> + Sink<Message> + Send + 'static, E: Debug + Send>(
&self,
connection: S,
peer_address: SocketAddr
)
Handles an established tokio-tungstenite WebSocket stream.
sourceimpl<B: Backend> CustomServer<B>
impl<B: Backend> CustomServer<B>
sourcepub async fn open(configuration: ServerConfiguration) -> Result<Self, Error>
pub async fn open(configuration: ServerConfiguration) -> Result<Self, Error>
Opens a server using directory for storage.
sourcepub fn pinned_certificate_path(&self) -> PathBuf
pub fn pinned_certificate_path(&self) -> PathBuf
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.
sourcepub fn primary_domain(&self) -> &str
pub fn primary_domain(&self) -> &str
Returns the primary domain configured for this server.
sourcepub async fn admin(&self) -> ServerDatabase<B>
pub async fn admin(&self) -> ServerDatabase<B>
Returns the administration database.
sourcepub async fn install_self_signed_certificate(
&self,
overwrite: bool
) -> Result<(), Error>
pub async fn install_self_signed_certificate(
&self,
overwrite: bool
) -> Result<(), Error>
Installs an X.509 certificate used for general purpose connections.
sourcepub async fn install_pem_certificate(
&self,
certificate_chain: &[u8],
private_key: &[u8]
) -> Result<(), Error>
pub async fn install_pem_certificate(
&self,
certificate_chain: &[u8],
private_key: &[u8]
) -> Result<(), Error>
Installs a certificate chain and private key used for TLS connections.
sourcepub 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.
sourcepub async fn certificate_chain(&self) -> Result<CertificateChain, Error>
pub async fn certificate_chain(&self) -> Result<CertificateChain, Error>
Returns the current certificate chain.
sourcepub async fn listen_on(&self, port: u16) -> Result<(), Error>
pub async fn listen_on(&self, port: u16) -> Result<(), Error>
Listens for incoming client connections. Does not return until the server shuts down.
sourcepub async fn connected_clients(&self) -> Vec<ConnectedClient<B>>
pub async fn connected_clients(&self) -> Vec<ConnectedClient<B>>
Returns all of the currently connected clients.
sourcepub async fn broadcast(&self, response: CustomApiResult<B::CustomApi>)
pub async fn broadcast(&self, response: CustomApiResult<B::CustomApi>)
Sends a custom API response to all connected clients.
sourcepub async fn shutdown(&self, timeout: Option<Duration>) -> Result<(), Error>
pub async fn shutdown(&self, timeout: Option<Duration>) -> Result<(), Error>
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.
sourcepub async fn listen_for_shutdown(&self) -> Result<(), Error>
pub async fn listen_for_shutdown(&self) -> Result<(), Error>
Listens for signals from the operating system that the server should shut down and attempts to gracefully shut down.
sourcepub async fn authenticate_client_as<'name, N: Nameable<'name, u64> + Send + Sync>(
&self,
user: N,
client: &ConnectedClient<B>
) -> Result<Permissions, Error>
pub async fn authenticate_client_as<'name, N: Nameable<'name, u64> + Send + Sync>(
&self,
user: N,
client: &ConnectedClient<B>
) -> Result<Permissions, Error>
Methods from Deref<Target = Storage>
sourcepub fn unique_id(&self) -> StorageId
pub fn unique_id(&self) -> StorageId
Returns the unique id of the server.
This value is set from the StorageConfiguration or randomly
generated when creating a server. It shouldn’t be changed after a server
is in use, as doing can cause issues. For example, the vault that
manages encrypted storage uses the server ID to store the vault key. If
the server ID changes, the vault key storage will need to be updated
with the new server ID.
Trait Implementations
sourceimpl<B: Backend> AcmeCache for CustomServer<B>
impl<B: Backend> AcmeCache for CustomServer<B>
sourcefn read_account<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn read_account<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str]
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: '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
sourcefn write_account<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str],
contents: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn write_account<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
contacts: &'life1 [&'life2 str],
contents: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Writes data for contacts. The data being written is unique for the
combined list of contacts. Read more
sourcefn 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<(), Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
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<(), Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Writes a certificate retrieved from Acme. The parameters are: Read more
sourceimpl<B: Backend> Clone for CustomServer<B>
impl<B: Backend> Clone for CustomServer<B>
sourceimpl<B: Debug + Backend> Debug for CustomServer<B>
impl<B: Debug + Backend> Debug for CustomServer<B>
sourceimpl<B: Backend> Deref for CustomServer<B>
impl<B: Backend> Deref for CustomServer<B>
sourceimpl<B: Backend> ResolvesServerCert for CustomServer<B>
impl<B: Backend> ResolvesServerCert for CustomServer<B>
sourcefn resolve(&self, client_hello: ClientHello<'_>) -> Option<Arc<CertifiedKey>>
fn resolve(&self, client_hello: ClientHello<'_>) -> Option<Arc<CertifiedKey>>
Choose a certificate chain and matching key given simplified ClientHello information. Read more
sourceimpl<B: Backend> StorageConnection for CustomServer<B>
impl<B: Backend> StorageConnection for CustomServer<B>
type Database = ServerDatabase<B>
type Database = ServerDatabase<B>
The type that represents a database for this implementation.
sourcefn 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>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Creates a database named name using the SchemaName schema. Read more
sourcefn database<'life0, 'life1, 'async_trait, DB: Schema>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Self::Database, Error>> + Send + 'async_trait>> where
DB: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn database<'life0, 'life1, 'async_trait, DB: Schema>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<Self::Database, Error>> + Send + 'async_trait>> where
DB: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Returns a reference to database name with schema DB.
sourcefn delete_database<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete_database<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Deletes a database named name. Read more
sourcefn list_databases<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<Database>, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn list_databases<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<Database>, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Lists the databases in this storage.
sourcefn list_available_schemas<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SchemaName>, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn list_available_schemas<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<SchemaName>, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Lists the SchemaNames registered with this storage.
sourcefn create_user<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create_user<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Creates a user.
sourcefn set_user_password<'user, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
U: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn set_user_password<'user, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync>(
&'life0 self,
user: U,
password: SensitiveString
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
U: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Sets a user’s password.
sourcefn authenticate<'user, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<Authenticated, Error>> + Send + 'async_trait>> where
'user: 'async_trait,
U: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn authenticate<'user, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync>(
&'life0 self,
user: U,
authentication: Authentication
) -> Pin<Box<dyn Future<Output = Result<Authenticated, Error>> + Send + 'async_trait>> where
'user: 'async_trait,
U: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Authenticates as a user with a authentication method.
sourcefn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn add_permission_group_to_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Adds a user to a permission group.
sourcefn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn remove_permission_group_from_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
permission_group: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Removes a user from a permission group.
sourcefn add_role_to_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn add_role_to_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Adds a user to a permission group.
sourcefn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn remove_role_from_user<'user, 'group, 'life0, 'async_trait, U: Nameable<'user, u64> + Send + Sync, G: Nameable<'group, u64> + Send + Sync>(
&'life0 self,
user: U,
role: G
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
'user: 'async_trait,
'group: 'async_trait,
U: 'async_trait,
G: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Removes a user from a permission group.
sourcefn create_database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str,
only_if_needed: bool
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: Schema + 'async_trait,
Self: 'async_trait,
fn create_database<'life0, 'life1, 'async_trait, DB>(
&'life0 self,
name: &'life1 str,
only_if_needed: bool
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>> where
'life0: 'async_trait,
'life1: 'async_trait,
DB: Schema + 'async_trait,
Self: 'async_trait,
Creates a database named name with the Schema provided. 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more