pub struct MockSender { /* private fields */ }
Implementations§
Source§impl MockSender
impl MockSender
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.