pub enum MockHttpResponse {
Success(Bytes),
SuccessWithHeaders(Bytes, HeaderMap),
ErrorResponse(StatusCode, Bytes),
ErrorWithHeaders(StatusCode, String, HeaderMap),
ErrorResponseWithHeaders(StatusCode, Bytes, HeaderMap),
}test-utils only.Expand description
Response scripted for RecordingHttpClient.
Variants§
Success(Bytes)
Return this body with a successful HTTP status and no headers.
SuccessWithHeaders(Bytes, HeaderMap)
Return this body with a successful HTTP status and these headers —
the reply whose Content-Type decides how it may be framed.
ErrorResponse(StatusCode, Bytes)
Return an HTTP response with the given (typically non-success) status and body, instead of a transport-level error.
ErrorWithHeaders(StatusCode, String, HeaderMap)
Return a status-code error that preserved the failed response’s headers, exactly as the bundled reqwest transport does (rig#2210).
ErrorResponseWithHeaders(StatusCode, Bytes, HeaderMap)
Return an HTTP response with the given (typically non-success) status, body, and response headers, instead of a transport-level error.
Implementations§
Source§impl MockHttpResponse
impl MockHttpResponse
Sourcepub fn success(body: impl Into<Bytes>) -> MockHttpResponse
pub fn success(body: impl Into<Bytes>) -> MockHttpResponse
Create a successful response from bytes.
Sourcepub fn success_typed(
body: impl Into<Bytes>,
content_type: &'static str,
) -> MockHttpResponse
pub fn success_typed( body: impl Into<Bytes>, content_type: &'static str, ) -> MockHttpResponse
Create a successful response carrying content_type.
Sourcepub fn error(status: StatusCode, message: impl Into<String>) -> MockHttpResponse
pub fn error(status: StatusCode, message: impl Into<String>) -> MockHttpResponse
Create a transport-level status error whose reply carried no headers
of interest: the same shape as Self::error_with_headers with an
empty map, since a rejection always comes with its headers.
Sourcepub fn error_with_headers(
status: StatusCode,
message: impl Into<String>,
headers: HeaderMap,
) -> MockHttpResponse
pub fn error_with_headers( status: StatusCode, message: impl Into<String>, headers: HeaderMap, ) -> MockHttpResponse
Create a transport-level status error that preserved the failed response’s headers, as the bundled reqwest transport does.
Trait Implementations§
Source§impl Clone for MockHttpResponse
impl Clone for MockHttpResponse
Source§fn clone(&self) -> MockHttpResponse
fn clone(&self) -> MockHttpResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MockHttpResponse
impl Debug for MockHttpResponse
Source§impl Default for MockHttpResponse
impl Default for MockHttpResponse
Source§fn default() -> MockHttpResponse
fn default() -> MockHttpResponse
Auto Trait Implementations§
impl !Freeze for MockHttpResponse
impl RefUnwindSafe for MockHttpResponse
impl Send for MockHttpResponse
impl Sync for MockHttpResponse
impl Unpin for MockHttpResponse
impl UnsafeUnpin for MockHttpResponse
impl UnwindSafe for MockHttpResponse
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more