pub trait StreamingResponseExt {
// Required methods
fn stream_file<P: AsRef<Path>>(
path: P,
cx: Cx,
content_type: &[u8],
) -> Result<Response>;
fn stream_file_with_config<P: AsRef<Path>>(
path: P,
cx: Cx,
content_type: &[u8],
config: StreamConfig,
) -> Result<Response>;
fn stream_file_range<P: AsRef<Path>>(
path: P,
range: ByteRange,
total_size: u64,
cx: Cx,
content_type: &[u8],
) -> Result<Response>;
fn stream_file_range_with_config<P: AsRef<Path>>(
path: P,
range: ByteRange,
total_size: u64,
cx: Cx,
content_type: &[u8],
config: StreamConfig,
) -> Result<Response>;
}Expand description
Extension trait for creating streaming response bodies.
Required Methods§
Sourcefn stream_file_with_config<P: AsRef<Path>>(
path: P,
cx: Cx,
content_type: &[u8],
config: StreamConfig,
) -> Result<Response>
fn stream_file_with_config<P: AsRef<Path>>( path: P, cx: Cx, content_type: &[u8], config: StreamConfig, ) -> Result<Response>
Create a streaming response from a file with custom config.
§Errors
Returns an error if the file cannot be opened.
Sourcefn stream_file_range<P: AsRef<Path>>(
path: P,
range: ByteRange,
total_size: u64,
cx: Cx,
content_type: &[u8],
) -> Result<Response>
fn stream_file_range<P: AsRef<Path>>( path: P, range: ByteRange, total_size: u64, cx: Cx, content_type: &[u8], ) -> Result<Response>
Create a 206 Partial Content response for a byte range of a file.
This is used to handle HTTP Range requests for partial content delivery.
§Arguments
path- Path to the filerange- The validated byte range to servetotal_size- Total size of the file (for Content-Range header)cx- Capability contextcontent_type- MIME type for the Content-Type header
§Errors
Returns an error if the file cannot be opened or seeked.
Sourcefn stream_file_range_with_config<P: AsRef<Path>>(
path: P,
range: ByteRange,
total_size: u64,
cx: Cx,
content_type: &[u8],
config: StreamConfig,
) -> Result<Response>
fn stream_file_range_with_config<P: AsRef<Path>>( path: P, range: ByteRange, total_size: u64, cx: Cx, content_type: &[u8], config: StreamConfig, ) -> Result<Response>
Create a 206 Partial Content response with custom streaming config.
§Errors
Returns an error if the file cannot be opened or seeked.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.