ResponseRangeExt

Trait ResponseRangeExt 

Source
pub trait ResponseRangeExt
where Self: Sized,
{ // Required methods fn new_206_partial_content() -> Self; fn set_accept_ranges_bytes(&mut self); fn set_accept_ranges_none(&mut self); fn set_content_range<T>( &mut self, range: T, total: u64, ) -> Result<(), Error> where T: RangeBounds<u64>; fn set_body_data_range<T, R>( &mut self, data: T, range: R, ) -> Result<(), Error> where T: Into<Data>, R: RangeBounds<usize>; fn set_body_file_range<T, R>( &mut self, file: T, range: R, ) -> Result<(), Error> where T: Into<File>, R: RangeBounds<u64>; }
Expand description

An extension trait for HTTP responses to work with range requests

Required Methods§

Source

fn new_206_partial_content() -> Self

Creates a new 206 Partial Content HTTP response

Source

fn set_accept_ranges_bytes(&mut self)

Sets the Accept-Ranges to bytes

Source

fn set_accept_ranges_none(&mut self)

Sets the Accept-Ranges to none

Source

fn set_content_range<T>(&mut self, range: T, total: u64) -> Result<(), Error>
where T: RangeBounds<u64>,

Sets the Content-Range header

Source

fn set_body_data_range<T, R>(&mut self, data: T, range: R) -> Result<(), Error>
where T: Into<Data>, R: RangeBounds<usize>,

Sets the body for a Partial Range response

§Note

This function also sets the Content-Length and the Content-Range headers. Furthermore, it raises an error if self.status is not 206

Source

fn set_body_file_range<T, R>(&mut self, file: T, range: R) -> Result<(), Error>
where T: Into<File>, R: RangeBounds<u64>,

Sets the body for a Partial Range response

§Note

This function also sets the Content-Length and the Content-Range headers. Furthermore, it raises an error if self.status is not 206

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.

Implementations on Foreign Types§

Source§

impl<const HEADER_SIZE_MAX: usize> ResponseRangeExt for Response<HEADER_SIZE_MAX>

Source§

fn new_206_partial_content() -> Self

Source§

fn set_accept_ranges_bytes(&mut self)

Source§

fn set_accept_ranges_none(&mut self)

Source§

fn set_content_range<T>(&mut self, range: T, total: u64) -> Result<(), Error>
where T: RangeBounds<u64>,

Source§

fn set_body_data_range<T, R>(&mut self, data: T, range: R) -> Result<(), Error>
where T: Into<Data>, R: RangeBounds<usize>,

Source§

fn set_body_file_range<T, R>(&mut self, file: T, range: R) -> Result<(), Error>
where T: Into<File>, R: RangeBounds<u64>,

Implementors§