Skip to main content

Storage

Struct Storage 

Source
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().await

Implementations§

Source§

impl Storage

Source

pub fn new() -> Self

The module with settings from [modules.storage] (defaults if absent).

Source

pub fn with_config(self, config: StorageConfig) -> Self

Use these settings instead of [modules.storage] (which must then be absent).

Source

pub fn service(&self) -> Option<&StorageService>

The service, once the server is built.

Trait Implementations§

Source§

impl Debug for Storage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Storage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Module for Storage

Source§

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]

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>

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>

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>

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 openapi(&self) -> Option<OpenApi>

Extra OpenAPI parts (schemas, tags) not tied to a route.
Source§

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)

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>>

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>>

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).
Source§

fn shutdown<'a>(&'a self, state: &'a AppState) -> BoxFuture<'a, ()>

Clean up after the in-flight requests drained (reverse registration order). Bounded by server.module_shutdown_timeout_secs; a panic is caught and logged.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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 T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

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

Source§

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