pub struct FileStream<S> {
pub stream: S,
pub file_name: Option<String>,
pub content_size: Option<u64>,
}Available on crate feature
file-stream only.Expand description
HTTP file stream with metadata support for efficient file delivery.
FileStream wraps any stream that produces bytes and associates it with optional
metadata like filename and content size. This enables proper HTTP headers to be
set for file downloads, including Content-Disposition for filename suggestions
and Content-Length for known file sizes. The implementation supports both
regular responses and HTTP range requests for partial content delivery.
Fields§
§stream: SThe underlying byte stream
file_name: Option<String>Optional filename for Content-Disposition header
content_size: Option<u64>Optional content size for Content-Length header
Implementations§
Source§impl<S> FileStream<S>
impl<S> FileStream<S>
Sourcepub fn new(
stream: S,
file_name: Option<String>,
content_size: Option<u64>,
) -> Self
pub fn new( stream: S, file_name: Option<String>, content_size: Option<u64>, ) -> Self
Creates a new file stream with the provided metadata.
Sourcepub async fn from_path<P>(
path: P,
) -> Result<FileStream<Once<Ready<Result<Bytes, Error>>>>>
Available on crate feature compio only.
pub async fn from_path<P>( path: P, ) -> Result<FileStream<Once<Ready<Result<Bytes, Error>>>>>
compio only.Creates a file stream from a file system path with automatic metadata detection (compio variant).
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for FileStream<S>where
S: Freeze,
impl<S> RefUnwindSafe for FileStream<S>where
S: RefUnwindSafe,
impl<S> Send for FileStream<S>where
S: Send,
impl<S> Sync for FileStream<S>where
S: Sync,
impl<S> Unpin for FileStream<S>where
S: Unpin,
impl<S> UnsafeUnpin for FileStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for FileStream<S>where
S: UnwindSafe,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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