use super::{ChannelMode, SonicChannel, SonicStream};
use crate::commands::*;
use crate::result::Result;
use std::net::ToSocketAddrs;
#[derive(Debug)]
pub struct SearchChannel(SonicStream);
impl SonicChannel for SearchChannel {
type Channel = SearchChannel;
fn stream(&self) -> &SonicStream {
&self.0
}
fn start<A, S>(addr: A, password: S) -> Result<Self::Channel>
where
A: ToSocketAddrs,
S: ToString,
{
SonicStream::connect_with_start(ChannelMode::Search, addr, password).map(Self)
}
}
impl SearchChannel {
init_command!(
use QuitCommand for fn quit();
);
init_command!(
use PingCommand for fn ping();
);
}
impl SearchChannel {
init_command!(
use QueryCommand for fn query(
req: QueryRequest,
);
);
init_command!(
use SuggestCommand for fn suggest(
req: SuggestRequest,
);
);
init_command!(
use ListCommand for fn list(
req: ListRequest,
);
);
}