pub struct Response {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Expand description
A response: status, headers (names lowercase, in order) and body.
Fields§
§status: u16§headers: Vec<(String, String)>§body: Vec<u8>Implementations§
Source§impl Response
impl Response
Sourcepub fn new(status: u16) -> Self
pub fn new(status: u16) -> Self
A response with status and nothing else: what a test queues
(MockHost::http), with Response::header and Response::body
set by the builders below.
Sourcepub fn with_header(self, name: &str, value: &str) -> Self
pub fn with_header(self, name: &str, value: &str) -> Self
Adds a header (the name lowercased, as a host reports it).
pub fn with_body(self, body: impl Into<Vec<u8>>) -> Self
Sourcepub fn with_json<T: Serialize + ?Sized>(self, value: &T) -> Result<Self>
pub fn with_json<T: Serialize + ?Sized>(self, value: &T) -> Result<Self>
A JSON body and its content-type.
pub fn text(&self) -> Result<&str>
pub fn json<T: DeserializeOwned>(&self) -> Result<T>
Trait Implementations§
impl Eq for Response
impl StructuralPartialEq for Response
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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