pub struct StorageRouteState {
pub backend: Arc<dyn StorageBackend>,
pub max_upload_bytes: usize,
pub tenant_prefix: Option<String>,
pub max_presign_expiry_secs: u64,
}Expand description
Shared state for all storage route handlers.
Fields§
§backend: Arc<dyn StorageBackend>The configured storage backend (local, S3, GCS, Azure, …).
max_upload_bytes: usizeMaximum allowed upload body size in bytes.
Requests that exceed this limit are rejected with HTTP 413 before the body is forwarded to the backend, preventing memory exhaustion on the server when large files are sent.
tenant_prefix: Option<String>Optional key prefix prepended to every storage key.
Used for per-tenant isolation: set this to the tenant’s ID so that
tenant A’s keys ("tenantA/file.txt") are disjoint from tenant B’s
("tenantB/file.txt"). When None, keys are used as-is.
max_presign_expiry_secs: u64Ceiling on a presigned URL’s requested validity, in seconds.
A presigned URL grants credential-free access to an object for its lifetime, so an unbounded expiry is a standing exposure. Requests for a longer validity are clamped down to this ceiling (L-presigned-expiry).
Implementations§
Source§impl StorageRouteState
impl StorageRouteState
Sourcepub fn new(backend: Arc<dyn StorageBackend>) -> Self
pub fn new(backend: Arc<dyn StorageBackend>) -> Self
Create state with the given backend and the default 100 MiB upload limit.
Sourcepub const fn with_max_upload_bytes(self, bytes: usize) -> Self
pub const fn with_max_upload_bytes(self, bytes: usize) -> Self
Override the maximum upload size.
Sourcepub const fn with_max_presign_expiry_secs(self, secs: u64) -> Self
pub const fn with_max_presign_expiry_secs(self, secs: u64) -> Self
Override the ceiling on presigned-URL validity (in seconds).
Sourcepub fn with_tenant_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_tenant_prefix(self, prefix: impl Into<String>) -> Self
Set a tenant key prefix for per-tenant object isolation.
Every storage key is prefixed with {prefix}/ before being forwarded
to the backend, ensuring that tenants cannot access each other’s objects
even if they share the same bucket.
Trait Implementations§
Source§impl Clone for StorageRouteState
impl Clone for StorageRouteState
Source§fn clone(&self) -> StorageRouteState
fn clone(&self) -> StorageRouteState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for StorageRouteState
impl !UnwindSafe for StorageRouteState
impl Freeze for StorageRouteState
impl Send for StorageRouteState
impl Sync for StorageRouteState
impl Unpin for StorageRouteState
impl UnsafeUnpin for StorageRouteState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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