Struct aws_smithy_client::test_connection::TestConnection
source · [−]pub struct TestConnection<B> { /* private fields */ }
Expand description
TestConnection for use with a Client
.
A basic test connection. It will:
- Respond to requests with a preloaded series of responses
- Record requests for future examination
The generic parameter B
is the type of the response body.
For more complex use cases, see Tower Test
Usage example:
use aws_smithy_client::test_connection::TestConnection;
use aws_smithy_http::body::SdkBody;
let events = vec![(
http::Request::new(SdkBody::from("request body")),
http::Response::builder()
.status(200)
.body("response body")
.unwrap(),
)];
let conn = TestConnection::new(events);
let client = aws_smithy_client::Client::from(conn);
Implementations
sourceimpl<B> TestConnection<B>
impl<B> TestConnection<B>
pub fn new(data: Vec<(Request<SdkBody>, Response<B>)>) -> Self
pub fn requests(&self) -> impl Deref<Target = Vec<ValidateRequest>> + '_
pub fn assert_requests_match(&self, ignore_headers: &[HeaderName])
Trait Implementations
sourceimpl<B> Clone for TestConnection<B>
impl<B> Clone for TestConnection<B>
sourceimpl<B: Debug> Debug for TestConnection<B>
impl<B: Debug> Debug for TestConnection<B>
sourceimpl<B> From<TestConnection<B>> for Client<TestConnection<B>, Identity> where
B: Send + 'static,
SdkBody: From<B>,
impl<B> From<TestConnection<B>> for Client<TestConnection<B>, Identity> where
B: Send + 'static,
SdkBody: From<B>,
sourcefn from(tc: TestConnection<B>) -> Self
fn from(tc: TestConnection<B>) -> Self
Converts to this type from the input type.
sourceimpl<B> Service<Request<SdkBody>> for TestConnection<B> where
SdkBody: From<B>,
impl<B> Service<Request<SdkBody>> for TestConnection<B> where
SdkBody: From<B>,
type Error = ConnectorError
type Error = ConnectorError
Errors produced by the service.
type Future = Ready<Result<<TestConnection<B> as Service<Request<SdkBody>>>::Response, <TestConnection<B> as Service<Request<SdkBody>>>::Error>>
type Future = Ready<Result<<TestConnection<B> as Service<Request<SdkBody>>>::Response, <TestConnection<B> as Service<Request<SdkBody>>>::Error>>
The future response value.
Auto Trait Implementations
impl<B> RefUnwindSafe for TestConnection<B>
impl<B> Send for TestConnection<B> where
B: Send,
impl<B> Sync for TestConnection<B> where
B: Send,
impl<B> Unpin for TestConnection<B>
impl<B> UnwindSafe for TestConnection<B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Request> ServiceExt<Request> for T where
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for T where
T: Service<Request> + ?Sized,
sourcefn ready(&mut self) -> Ready<'_, Self, Request>
fn ready(&mut self) -> Ready<'_, Self, Request>
Yields a mutable reference to the service when it is ready to accept a request.
sourcefn ready_and(&mut self) -> Ready<'_, Self, Request>
fn ready_and(&mut self) -> Ready<'_, Self, Request>
please use the ServiceExt::ready
method instead
Yields a mutable reference to the service when it is ready to accept a request.
sourcefn ready_oneshot(self) -> ReadyOneshot<Self, Request>
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
Yields the service when it is ready to accept a request.
sourcefn oneshot(self, req: Request) -> Oneshot<Self, Request>
fn oneshot(self, req: Request) -> Oneshot<Self, Request>
Consume this Service
, calling with the providing request once it is ready.
sourcefn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
S: Stream<Item = Request>,
Self::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
fn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
S: Stream<Item = Request>,
Self::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
sourcefn and_then<F>(self, f: F) -> AndThen<Self, F> where
F: Clone,
fn and_then<F>(self, f: F) -> AndThen<Self, F> where
F: Clone,
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the poll_ready
method. Read more
sourcefn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F> where
F: FnOnce(Self::Response) -> Response + Clone,
Maps this service’s response value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
sourcefn map_err<F, Error>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> Error + Clone,
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(Self::Error) -> Error + Clone,
Maps this service’s error value to a different value. This does not
alter the behaviour of the poll_ready
method. Read more
sourcefn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,
Maps this service’s result type (Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more
sourcefn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F> where
F: FnMut(NewRequest) -> Request,
Composes a function in front of the service. Read more
sourcefn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>,
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F> where
Error: From<Self::Error>,
F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone,
Fut: Future<Output = Result<Response, Error>>,
Composes an asynchronous function after this service. Read more
sourcefn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F> where
F: FnMut(Self::Future) -> Fut,
Error: From<Self::Error>,
Fut: Future<Output = Result<Response, Error>>,
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F> where
F: FnMut(Self::Future) -> Fut,
Error: From<Self::Error>,
Fut: Future<Output = Result<Response, Error>>,
Composes a function that transforms futures produced by the service. Read more
sourcefn boxed(self) -> BoxService<Request, Self::Response, Self::Error> where
Self: 'static + Send,
Self::Future: 'static,
Self::Future: Send,
fn boxed(self) -> BoxService<Request, Self::Response, Self::Error> where
Self: 'static + Send,
Self::Future: 'static,
Self::Future: Send,
sourcefn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error> where
Self: 'static + Clone + Send,
Self::Future: 'static,
Self::Future: Send,
fn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error> where
Self: 'static + Clone + Send,
Self::Future: 'static,
Self::Future: Send,
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more