Skip to main content

Command

Trait Command 

Source
pub trait Command<F> {
    type Response;

    // Required methods
    fn encode(&self) -> F;
    fn eval_response(
        &self,
        frame: F,
    ) -> Result<Self::Response, ResponseTypeError>;
}
Expand description

Generic command structure. F is either Resp2Frame or Resp3Frame

Required Associated Types§

Source

type Response

Response type, either a custom evaluated “high-level” response or the original RESP frame

Required Methods§

Source

fn encode(&self) -> F

Encodes the command to RESP2/RESP3 frame

Source

fn eval_response(&self, frame: F) -> Result<Self::Response, ResponseTypeError>

The command has the ability to evaluate the response frame and craft its own high level response from that. Its also possible to just return 1:1 the RESP2 frame.

Error responses are captured upfront and converted to CommandErrors::ErrorResponse. So error responses never reach that method.

Returns Error only in case of protocol violation (e.g. received an array for an command that only returns strings)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Command<BytesFrame> for HelloCommand

Source§

impl Command<BytesFrame> for HelloCommand

Source§

impl<F: From<CommandBuilder> + ToInteger, const N: usize> Command<F> for HashSetCommand<N>

Source§

impl<F: From<CommandBuilder>> Command<F> for BackgroundSaveCommand

Source§

impl<F> Command<F> for AuthCommand

Source§

impl<F> Command<F> for CustomCommand
where F: From<CommandBuilder>,

Source§

impl<F> Command<F> for GetCommand

Source§

impl<F> Command<F> for HashGetAllCommand

Source§

impl<F> Command<F> for HashGetCommand

Source§

impl<F> Command<F> for KeysCommand

Source§

impl<F> Command<F> for PingCommand

Source§

impl<F> Command<F> for PublishCommand

Source§

impl<F> Command<F> for SetCommand<ConfirmationResponse>

Source§

impl<F> Command<F> for SetCommand<ExclusiveSetResponse>

Source§

impl<F> Command<F> for SetCommand<ReturnPreviousResponse>