Skip to main content

ChunkedUploadManager

Struct ChunkedUploadManager 

Source
pub struct ChunkedUploadManager { /* private fields */ }
Expand description

Manager for chunked uploads

Implementations§

Source§

impl ChunkedUploadManager

Source

pub fn new(temp_base_dir: PathBuf) -> Self

Create a new chunked upload manager

§Examples
use reinhardt_http::chunked_upload::ChunkedUploadManager;
use std::path::PathBuf;

let manager = ChunkedUploadManager::new(PathBuf::from("/tmp/chunked_uploads"));
Source

pub fn start_session( &self, session_id: String, filename: String, total_size: usize, chunk_size: usize, ) -> Result<ChunkedUploadSession, ChunkedUploadError>

Start a new upload session

§Examples
use reinhardt_http::chunked_upload::ChunkedUploadManager;
use std::path::PathBuf;

let manager = ChunkedUploadManager::new(PathBuf::from("/tmp/chunked_uploads"));
let session = manager.start_session(
    "session123".to_string(),
    "large_file.bin".to_string(),
    10_000_000, // 10MB
    1_000_000,  // 1MB chunks
).unwrap();
assert_eq!(session.total_chunks, 10);
Source

pub fn upload_chunk( &self, session_id: &str, chunk_number: usize, data: &[u8], ) -> Result<ChunkedUploadSession, ChunkedUploadError>

Upload a chunk

§Examples
use reinhardt_http::chunked_upload::ChunkedUploadManager;
use std::path::PathBuf;

let manager = ChunkedUploadManager::new(PathBuf::from("/tmp/chunked_uploads"));
manager.start_session("session123".to_string(), "file.bin".to_string(), 1000, 100).unwrap();

let chunk_data = vec![0u8; 100];
manager.upload_chunk("session123", 0, &chunk_data).unwrap();
Source

pub fn assemble_chunks( &self, session_id: &str, output_path: PathBuf, ) -> Result<PathBuf, ChunkedUploadError>

Assemble all chunks into final file

§Examples
use reinhardt_http::chunked_upload::ChunkedUploadManager;
use std::path::PathBuf;

let manager = ChunkedUploadManager::new(PathBuf::from("/tmp/chunked_uploads"));
let output_path = manager.assemble_chunks("session123", PathBuf::from("/tmp/final_file.bin")).unwrap();
Source

pub fn cleanup_session( &self, session_id: &str, ) -> Result<(), ChunkedUploadError>

Clean up a session (delete temporary files)

§Examples
use reinhardt_http::chunked_upload::ChunkedUploadManager;
use std::path::PathBuf;

let manager = ChunkedUploadManager::new(PathBuf::from("/tmp/chunked_uploads"));
manager.cleanup_session("session123").unwrap();
Source

pub fn get_session(&self, session_id: &str) -> Option<ChunkedUploadSession>

Get session information

Source

pub fn list_sessions(&self) -> Vec<ChunkedUploadSession>

List all active sessions

Source

pub fn cleanup_expired_sessions(&self)

Remove sessions that have exceeded the timeout.

Expired sessions have their temporary files cleaned up automatically. This is called lazily on start_session and upload_chunk to prevent unbounded memory growth from abandoned uploads.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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