sonic-channel 1.1.0

Rust client for sonic search backend
Documentation
use super::StreamCommand;
use crate::protocol;
use crate::result::*;

#[derive(Debug)]
pub struct QuitCommand;

impl StreamCommand for QuitCommand {
    type Response = ();

    fn request(&self) -> protocol::Request {
        protocol::Request::Quit
    }

    fn receive(&self, res: protocol::Response) -> Result<Self::Response> {
        if matches!(res, protocol::Response::Ended) {
            Ok(())
        } else {
            Err(Error::WrongResponse)
        }
    }
}