pub struct MockPage { /* private fields */ }Available on crate feature
testing only.Expand description
A response a MockSite serves.
Implementations§
Source§impl MockPage
impl MockPage
Sourcepub fn status(status: StatusCode) -> Self
pub fn status(status: StatusCode) -> Self
Creates an empty page with status.
Sourcepub fn redirect(location: &str) -> Self
pub fn redirect(location: &str) -> Self
Creates a redirect to location, which the site follows as an HTTP
client would: the response is the page at location, served from
that URI.
§Panics
Panics if location is not a valid absolute URI.
Sourcepub const fn with_status(self, status: StatusCode) -> Self
pub const fn with_status(self, status: StatusCode) -> Self
Replaces the status.
Sourcepub fn with_header(self, name: impl IntoHeaderName, value: HeaderValue) -> Self
pub fn with_header(self, name: impl IntoHeaderName, value: HeaderValue) -> Self
Inserts a header, replacing any previous value.
Sourcepub const fn with_latency(self, latency: Duration) -> Self
pub const fn with_latency(self, latency: Duration) -> Self
Takes latency to answer, e.g. to test timeouts or adaptive host
delays. Tests with paused time, #[tokio::test(start_paused = true)],
skip the wait.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MockPage
impl RefUnwindSafe for MockPage
impl Send for MockPage
impl Sync for MockPage
impl Unpin for MockPage
impl UnsafeUnpin for MockPage
impl UnwindSafe for MockPage
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