pub struct AppStateBuilder { /* private fields */ }Expand description
A builder for constructing AppState.
This is the intended way to create an AppState both in main.rs and in tests.
Using a builder makes it easy to inject different databases and vault paths
in test environments without modifying the production code path.
§Example
use webdav_server::app::AppStateBuilder;
let state = AppStateBuilder::new()
.vault_path("./vault")
.db(pool)
.build();Implementations§
Source§impl AppStateBuilder
impl AppStateBuilder
Sourcepub fn vault_path<P>(self, path: P) -> Self
pub fn vault_path<P>(self, path: P) -> Self
Sets the path to the vault directory where blobs are stored.
This field is required. Calling build() without setting it will panic.
Sourcepub fn db(self, pool: SqlitePool) -> Self
pub fn db(self, pool: SqlitePool) -> Self
Sets the SqlitePool for all database operations.
This field is required. Calling build() without setting it will panic.
Sourcepub fn session_cache(self, session_cache: Cache<TokenHash, UserId>) -> Self
pub fn session_cache(self, session_cache: Cache<TokenHash, UserId>) -> Self
Optionally provides a pre-configured moka session cache.
If not set, build() will create a default cache with a 10-minute
Time-To-Idle (TTI) policy and a maximum capacity of 10,000 entries.
This default is suitable for most deployments.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AppStateBuilder
impl !UnwindSafe for AppStateBuilder
impl Freeze for AppStateBuilder
impl Send for AppStateBuilder
impl Sync for AppStateBuilder
impl Unpin for AppStateBuilder
impl UnsafeUnpin for AppStateBuilder
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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