pub struct Reply {
pub status: u16,
pub content_type: String,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Expand description
A handler’s answer: any status, content type, extra headers and binary body.
Fields§
§status: u16§content_type: String§headers: Vec<(String, String)>§body: Vec<u8>Implementations§
Source§impl Reply
impl Reply
Sourcepub fn bytes(content_type: &str, body: impl Into<Vec<u8>>) -> Self
pub fn bytes(content_type: &str, body: impl Into<Vec<u8>>) -> Self
200 with a binary body (generated media: image/png, audio/mpeg, video/mp4, …).
Sourcepub fn file(content_type: &str, path: &Path) -> Self
pub fn file(content_type: &str, path: &Path) -> Self
200 with a file’s bytes; an unreadable file is a 500 naming it.
pub fn with_status(self, status: u16) -> Self
pub fn with_header(self, name: &str, value: &str) -> Self
Sourcepub fn ignore_range(self) -> Self
pub fn ignore_range(self) -> Self
Answer every request with the full body, ignoring any Range (a server
that cannot resume). Recorded as the reserved IGNORE_RANGE_HEADER,
which the mock consumes and never sends.
Sourcepub fn cut_after(self, bytes: u64) -> Self
pub fn cut_after(self, bytes: u64) -> Self
Send the response head (with the full Content-Length), then only the first
bytes body bytes, then close the connection: a download dropped mid-transfer.
Applies after any Range slicing. Recorded as the reserved CUT_AFTER_HEADER,
which the mock consumes and never sends.
Trait Implementations§
impl Eq for Reply
impl StructuralPartialEq for Reply
Auto Trait Implementations§
impl Freeze for Reply
impl RefUnwindSafe for Reply
impl Send for Reply
impl Sync for Reply
impl Unpin for Reply
impl UnsafeUnpin for Reply
impl UnwindSafe for Reply
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.