pub trait Mocks: Debug + 'static {
// Required method
fn process_command(
&self,
command: MockCommand,
) -> Result<RedisValue, RedisError>;
// Provided method
fn process_transaction(
&self,
commands: Vec<MockCommand>,
) -> Result<RedisValue, RedisError> { ... }
}mocks only.Expand description
An interface for intercepting and processing Redis commands in a mocking layer.
Required Methods§
sourcefn process_command(
&self,
command: MockCommand,
) -> Result<RedisValue, RedisError>
fn process_command( &self, command: MockCommand, ) -> Result<RedisValue, RedisError>
Intercept and process a Redis command, returning any RedisValue.
§Important
The caller must ensure the response value makes sense in the context of the specific command(s) being mocked. The parsing logic following each command on the public interface will still be applied. Most commands perform minimal parsing on the response, but some may require specific response formats to function correctly.
RedisValue::Queued can be used to return a value that will work almost anywhere.
Provided Methods§
sourcefn process_transaction(
&self,
commands: Vec<MockCommand>,
) -> Result<RedisValue, RedisError>
fn process_transaction( &self, commands: Vec<MockCommand>, ) -> Result<RedisValue, RedisError>
Intercept and process an entire transaction. The provided commands will not include MULTI or EXEC.
Note: The default implementation redirects each command to the process_command function. The results of each call are buffered and returned as an array.