pub struct MockSender { /* private fields */ }
Implementations§
Source§impl MockSender
impl MockSender
An RpcSender
used for unit testing RpcClient
.
This is primarily for internal use.
Unless directed otherwise, it will generally return a reasonable default
response, at least for RpcRequest
values for which responses have been
implemented.
The behavior can be customized in two ways:
-
The
url
constructor argument is not actually a URL, but a simple string directive that changesMockSender
s behavior in specific scenarios.If
url
is “fails” then any call tosend
will returnOk(Value::Null)
.It is customary to set the
url
to “succeeds” for mocks that should return successfully, though this value is not actually interpreted.Other possible values of
url
are specific to differentRpcRequest
values. Read the implementation for specifics. -
Custom responses can be configured by providing
Mocks
to theMockSender::new_with_mocks
constructor. This type is aHashMap
fromRpcRequest
to a JSONValue
response, Any entries in this map override the default behavior for the given request.
Trait Implementations§
Source§impl RpcSender for MockSender
impl RpcSender for MockSender
Auto Trait Implementations§
impl !Freeze for MockSender
impl RefUnwindSafe for MockSender
impl Send for MockSender
impl Sync for MockSender
impl Unpin for MockSender
impl UnwindSafe for MockSender
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
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