pub enum MockHttpResponse {
Success(Bytes),
Error(StatusCode, String),
ErrorResponse(StatusCode, Bytes),
ErrorWithHeaders(StatusCode, String, Box<HeaderMap>),
ErrorResponseWithHeaders(StatusCode, Bytes, Box<HeaderMap>),
}test-utils only.Expand description
Response scripted for RecordingHttpClient.
Variants§
Success(Bytes)
Return this body with a successful HTTP status.
Error(StatusCode, String)
Return a status-code error with the given body text.
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, Box<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, Box<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 error(status: StatusCode, message: impl Into<String>) -> Self
pub fn error(status: StatusCode, message: impl Into<String>) -> Self
Create an error response with a status code and message.
Models a transport that reports a non-success status without
preserving the response headers (a custom HttpClientExt); use
Self::error_with_headers for the bundled reqwest behavior.
Sourcepub fn error_with_headers(
status: StatusCode,
message: impl Into<String>,
headers: HeaderMap,
) -> Self
pub fn error_with_headers( status: StatusCode, message: impl Into<String>, headers: HeaderMap, ) -> Self
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
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> 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