pub struct MockResponse {
pub status: StatusCode,
pub headers: HeaderMap,
pub chunks: Vec<Vec<u8>>,
pub trailers: Option<HeaderMap>,
pub length: Option<u64>,
pub error: Option<HttpError>,
}Expand description
One response a MockHttpClient answers.
Fields§
§status: StatusCode§headers: HeaderMap§chunks: Vec<Vec<u8>>The body in the pieces it arrives in, one per read.
trailers: Option<HeaderMap>Fields that come after the body.
length: Option<u64>The length the sender claims; the sum of the chunks when not given.
error: Option<HttpError>Why the body stopped short instead of ending.
Implementations§
Source§impl MockResponse
impl MockResponse
Sourcepub fn new() -> MockResponse
pub fn new() -> MockResponse
An OK response with no body.
pub fn status(self, status: StatusCode) -> MockResponse
pub fn header(self, name: &str, value: &str) -> MockResponse
Sourcepub fn chunks(self, chunks: Vec<Vec<u8>>) -> MockResponse
pub fn chunks(self, chunks: Vec<Vec<u8>>) -> MockResponse
A body that arrives in chunks, one per read.
pub fn trailers(self, trailers: HeaderMap) -> MockResponse
Sourcepub fn length(self, length: u64) -> MockResponse
pub fn length(self, length: u64) -> MockResponse
A length other than the bytes actually sent, as a compressed body reports.
Sourcepub fn error(self, error: HttpError) -> MockResponse
pub fn error(self, error: HttpError) -> MockResponse
The body fails after the chunks it was given, with error.
Trait Implementations§
Source§impl Clone for MockResponse
impl Clone for MockResponse
Source§impl Debug for MockResponse
impl Debug for MockResponse
Source§impl Default for MockResponse
impl Default for MockResponse
Source§impl PartialEq for MockResponse
impl PartialEq for MockResponse
impl StructuralPartialEq for MockResponse
Auto Trait Implementations§
impl Forget for MockResponse
impl Freeze for MockResponsewhere
NonZero<u16>: Freeze,
*const [Pos] is !null: Freeze,
PhantomData<[Pos]>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Bucket<HeaderValue>>: Freeze,
PhantomData<ExtraValue<HeaderValue>>: Freeze,
PhantomData<Vec<u8>>: Freeze,
PhantomData<u8>: Freeze,
impl Move for MockResponse
impl RefUnwindSafe for MockResponse
impl Send for MockResponse
impl Sync for MockResponse
impl Unpin for MockResponse
impl UnsafeUnpin for MockResponsewhere
NonZeroU16Inner: UnsafeUnpin,
*const [Pos] is !null: UnsafeUnpin,
PhantomData<[Pos]>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Bucket<HeaderValue>>: UnsafeUnpin,
PhantomData<ExtraValue<HeaderValue>>: UnsafeUnpin,
PhantomData<Vec<u8>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for MockResponsewhere
NonZero<u16>: UnwindSafe,
BoxRaw<[Pos]>: UnwindSafe,
RawVecInner: UnwindSafe,
*const u8: UnwindSafe,
Align8<*mut ()>: UnwindSafe,
&'static Vtable: 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