pub struct BucketService { /* private fields */ }Expand description
A bucket-aware storage service that enforces policies.
Wraps a StorageBackend with a BucketConfig to validate
upload size and MIME type restrictions before delegating operations.
Implementations§
Source§impl BucketService
impl BucketService
Sourcepub const fn new(backend: StorageBackend, config: BucketConfig) -> Self
pub const fn new(backend: StorageBackend, config: BucketConfig) -> Self
Creates a new bucket service.
Sourcepub const fn config(&self) -> &BucketConfig
pub const fn config(&self) -> &BucketConfig
Returns a reference to the bucket configuration.
Sourcepub async fn upload(
&self,
key: &str,
data: &[u8],
content_type: &str,
) -> Result<String>
pub async fn upload( &self, key: &str, data: &[u8], content_type: &str, ) -> Result<String>
Uploads data with policy validation.
Validates:
- Key is safe (no path traversal)
- Data size does not exceed configured limit
- Content type is in allowed MIME types list
§Errors
Returns FraiseQLError::File if validation fails or upload fails.
Sourcepub async fn download(&self, key: &str) -> Result<Vec<u8>>
pub async fn download(&self, key: &str) -> Result<Vec<u8>>
Downloads data without policy validation (policies only apply to upload).
§Errors
Returns FraiseQLError::File if download fails.
Auto Trait Implementations§
impl Freeze for BucketService
impl RefUnwindSafe for BucketService
impl Send for BucketService
impl Sync for BucketService
impl Unpin for BucketService
impl UnsafeUnpin for BucketService
impl UnwindSafe for BucketService
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
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