Struct aws_smithy_mocks_experimental::RuleBuilder

source ·
pub struct RuleBuilder<I, O, E> { /* private fields */ }

Implementations§

source§

impl<I, O, E> RuleBuilder<I, O, E>
where I: Send + Sync + Debug + 'static, O: Send + Sync + Debug + 'static, E: Send + Sync + Debug + Error + 'static,

source

pub fn new<F, R>( _input_hint: impl Fn() -> I, _output_hint: impl Fn() -> F, ) -> Self
where F: Future<Output = Result<O, SdkError<E, R>>>,

Creates a new RuleBuilder. This is normally constructed with the mock! macro

source

pub fn match_requests( self, filter: impl Fn(&I) -> bool + Send + Sync + 'static, ) -> Self

Add an additional filter to constrain which inputs match this rule.

For examples, see the examples directory of this repository.

source

pub fn then_http_response( self, response: impl Fn() -> HttpResponse + Send + Sync + 'static, ) -> Rule

If the rule matches, then return a specific HTTP response.

This is the recommended way of testing error behavior.

source

pub fn then_output(self, output: impl Fn() -> O + Send + Sync + 'static) -> Rule

If a rule matches, then return a specific output

source

pub fn then_error(self, output: impl Fn() -> E + Send + Sync + 'static) -> Rule

If a rule matches, then return a specific error

Although this basically works, using then_http_response is strongly recommended to create a higher fidelity mock. Error handling is quite complex in practice and returning errors directly often will not perfectly capture the way the error is actually returned to the SDK.

Auto Trait Implementations§

§

impl<I, O, E> Freeze for RuleBuilder<I, O, E>

§

impl<I, O, E> !RefUnwindSafe for RuleBuilder<I, O, E>

§

impl<I, O, E> Send for RuleBuilder<I, O, E>
where I: Send, O: Send, E: Send,

§

impl<I, O, E> Sync for RuleBuilder<I, O, E>
where I: Sync, O: Sync, E: Sync,

§

impl<I, O, E> Unpin for RuleBuilder<I, O, E>
where I: Unpin, O: Unpin, E: Unpin,

§

impl<I, O, E> !UnwindSafe for RuleBuilder<I, O, E>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more