use super::{ChannelMode, SonicChannel, SonicStream};
use crate::commands::*;
use crate::result::Result;
use std::net::ToSocketAddrs;
#[derive(Debug)]
pub struct IngestChannel(SonicStream);
impl SonicChannel for IngestChannel {
type Channel = IngestChannel;
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::Ingest, addr, password).map(Self)
}
}
impl IngestChannel {
init_command!(
use QuitCommand for fn quit();
);
init_command!(
use PingCommand for fn ping();
);
}
impl IngestChannel {
init_command!(
use PushCommand for fn push<'a>(
req: PushRequest,
);
);
init_command!(
use PopCommand for fn pop(
req: PopRequest,
);
);
init_command!(
use FlushCommand for fn flush(
req: FlushRequest,
);
);
init_command!(
use CountCommand for fn count(
req: CountRequest,
);
);
}