Struct httptest::ExpectationBuilder
source · pub struct ExpectationBuilder { /* private fields */ }
Expand description
Define expectations using a builder pattern.
Implementations§
source§impl ExpectationBuilder
impl ExpectationBuilder
sourcepub fn times<R>(self, times: R) -> ExpectationBuilderwhere
R: IntoTimes,
pub fn times<R>(self, times: R) -> ExpectationBuilderwhere
R: IntoTimes,
Expect this many requests.
// exactly 2 requests
Expectation::matching(any()).times(2).respond_with(status_code(200));
// at least 2 requests
Expectation::matching(any()).times(2..).respond_with(status_code(200));
// at most 2 requests
Expectation::matching(any()).times(..=2).respond_with(status_code(200));
// between 2 and 5 inclusive
Expectation::matching(any()).times(2..6).respond_with(status_code(200));
// equivalently
Expectation::matching(any()).times(2..=5).respond_with(status_code(200));
sourcepub fn respond_with(self, responder: impl Responder + 'static) -> Expectation
pub fn respond_with(self, responder: impl Responder + 'static) -> Expectation
What should this expectation respond with.
Auto Trait Implementations§
impl Freeze for ExpectationBuilder
impl !RefUnwindSafe for ExpectationBuilder
impl Send for ExpectationBuilder
impl !Sync for ExpectationBuilder
impl Unpin for ExpectationBuilder
impl !UnwindSafe for ExpectationBuilder
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