pub struct MultipartUploadService { /* private fields */ }Implementations§
Source§impl MultipartUploadService
impl MultipartUploadService
pub fn new( session_repo: Arc<UploadSessionRepository>, bucket_repo: Arc<BucketRepository>, quota_repo: Arc<UserQuotaRepository>, ) -> Self
pub async fn initiate( &self, bucket_id: Uuid, user_id: Uuid, path: &str, filename: &str, mime_type: Option<&str>, file_size: i64, chunk_size: Option<i32>, ) -> ServiceResult<UploadSession>
Check that a part may be written before its bytes are stored: the session is the caller’s, live, expecting this part number, the part not already recorded, and its size within the session’s chunk size.
pub async fn record_part( &self, session_id: Uuid, user_id: Uuid, part_number: i32, ) -> ServiceResult<UploadSession>
pub async fn complete( &self, session_id: Uuid, user_id: Uuid, ) -> ServiceResult<UploadSession>
Sourcepub async fn check_capacity(
&self,
user_id: Uuid,
bytes: i64,
) -> ServiceResult<()>
pub async fn check_capacity( &self, user_id: Uuid, bytes: i64, ) -> ServiceResult<()>
Check (without mutating) whether user_id has capacity for
bytes more. Returns Ok(()) when there is no quota row (no
limit configured) or when used_bytes + bytes <= limit_bytes.
Called by the single-shot upload handler before writing to
storage. The resumable flow calls into Self::complete which
performs the same check.
Sourcepub async fn record_completed_usage(
&self,
user_id: Uuid,
bytes: i64,
) -> ServiceResult<()>
pub async fn record_completed_usage( &self, user_id: Uuid, bytes: i64, ) -> ServiceResult<()>
Record post-upload usage on the user’s quota row. Best-effort:
when no quota row exists this is a no-op. Call AFTER the storage
put and DB row commit succeed.
pub async fn abort(&self, session_id: Uuid, user_id: Uuid) -> ServiceResult<()>
Sourcepub async fn mark_failed(&self, session_id: Uuid) -> ServiceResult<()>
pub async fn mark_failed(&self, session_id: Uuid) -> ServiceResult<()>
Fail a session whose completion was refused after it began (its parts did not assemble to
the declared size), so it does not stay completing forever.
pub async fn mark_completed(&self, session_id: Uuid) -> ServiceResult<()>
pub async fn cleanup_expired(&self) -> ServiceResult<u64>
pub async fn list_active( &self, _user_id: Uuid, _bucket_id: Uuid, ) -> ServiceResult<Vec<UploadSession>>
Auto Trait Implementations§
impl !RefUnwindSafe for MultipartUploadService
impl !UnwindSafe for MultipartUploadService
impl Freeze for MultipartUploadService
impl Send for MultipartUploadService
impl Sync for MultipartUploadService
impl Unpin for MultipartUploadService
impl UnsafeUnpin for MultipartUploadService
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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