* protocol: extract response type * deps: drop lazy_static and regex * protocol: extract request commands * protocol: create a struct for... ...formatting and parsing sonic protocol * protocol: refac flush command * commands: introduce dest, refac push and count * commands: refac all commands * commands: add convinient methods * doc: add documentation for each new structs * doc: change examples in the readme * commands: implement from trait for count and flush * commands: change pag logic
22 lines
478 B
Rust
22 lines
478 B
Rust
use super::StreamCommand;
|
|
use crate::protocol;
|
|
use crate::result::*;
|
|
|
|
#[derive(Debug)]
|
|
pub struct PingCommand;
|
|
|
|
impl StreamCommand for PingCommand {
|
|
type Response = ();
|
|
|
|
fn request(&self) -> protocol::Request {
|
|
protocol::Request::Ping
|
|
}
|
|
|
|
fn receive(&self, res: protocol::Response) -> Result<Self::Response> {
|
|
if matches!(res, protocol::Response::Pong) {
|
|
Ok(())
|
|
} else {
|
|
Err(Error::WrongResponse)
|
|
}
|
|
}
|
|
}
|