pub struct Storage { /* private fields */ }Available on crate feature
storage only.Expand description
The storage module: per-user JSON objects with versions, conditional writes, batches, the
server write lock, quotas, hooks and audited admin access (see crate::storage). Name
storage; settings in [modules.storage] (StorageConfig); needs the auth module
registered first.
use net_backend_server::auth::Auth;
use net_backend_server::storage::Storage;
use net_backend_server::{Config, NetBackendServer};
NetBackendServer::new(Config::load()?).module(Auth::new()).module(Storage::new()).run().awaitImplementations§
Source§impl Storage
impl Storage
Sourcepub fn with_config(self, config: StorageConfig) -> Self
pub fn with_config(self, config: StorageConfig) -> Self
Use these settings instead of [modules.storage] (which must then be absent).
Sourcepub fn service(&self) -> Option<&StorageService>
pub fn service(&self) -> Option<&StorageService>
The service, once the server is built.
Trait Implementations§
Source§impl Module for Storage
impl Module for Storage
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
The module’s name:
[a-z][a-z0-9_]*, at most 32 bytes, not reserved
(RESERVED_MODULE_NAMES). It names its migrations namespace, its config section
([modules.<name>]) and its entry in /v1/info. Stable public API once released.Source§fn depends_on(&self) -> &'static [&'static str]
fn depends_on(&self) -> &'static [&'static str]
The modules this one needs, by name (e.g.
["auth"] for tables with a foreign key to the
accounts). Each must be registered BEFORE this module, so its migrations run first and its
state values exist in setup; the build fails otherwise.Source§fn migrations(&self, dialect: Dialect) -> Vec<Migration>
fn migrations(&self, dialect: Dialect) -> Vec<Migration>
The module’s migrations for a dialect, any order (they are sorted by version). Embedded
SQL (e.g.
include_str!); the app can publish and own them (migrations publish <name>).Source§fn setup(&self, setup: &mut Setup<'_>) -> Result<(), Error>
fn setup(&self, setup: &mut Setup<'_>) -> Result<(), Error>
Prepare the module when the server is built (after the database connected, before the
hooks and routes): read its
[modules.<name>] section, register its services as state
values, add an Authenticator or a RateLimiter. An error stops the build.Source§fn routes(&self) -> OpenApiRouter<AppState>
fn routes(&self) -> OpenApiRouter<AppState>
The module’s HTTP routes (full paths, e.g. the protocol’s
/v1/storage/... constants).
Handlers registered with utoipa_axum::routes! appear in the OpenAPI document.Source§fn register_hooks(&self, hooks: &mut Hooks)
fn register_hooks(&self, hooks: &mut Hooks)
Register hooks (the module’s own defaults, or hooks into other modules’ events).
Source§fn ws_handlers(&self, handlers: &mut WsHandlers)
fn ws_handlers(&self, handlers: &mut WsHandlers)
The module’s WebSocket request handlers and documented pushes (see
crate::ws), e.g.
handlers.call::<JoinRoom, _, _>(join). A kind may be registered once across the app and
all modules (a duplicate stops the build).Source§fn commands(&self) -> Vec<Arc<dyn AppCommand>>
fn commands(&self) -> Vec<Arc<dyn AppCommand>>
The module’s command-line commands (see
crate::command), e.g. user:create.Source§fn start<'a>(&'a self, state: &'a AppState) -> BoxFuture<'a, Result<(), Error>>
fn start<'a>(&'a self, state: &'a AppState) -> BoxFuture<'a, Result<(), Error>>
Start background work (called once before the server accepts requests, in registration
order). Wait on
state.shutdown() to stop. An error, a panic or running longer than
server.module_start_timeout_secs aborts the start (modules already started shut down).Auto Trait Implementations§
impl !Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
Converts
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> ⓘ
Converts
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