zbus/connection/socket/
split.rsuse super::{ReadHalf, Socket, WriteHalf};
#[derive(Debug)]
pub struct Split<R: ReadHalf, W: WriteHalf> {
pub(super) read: R,
pub(super) write: W,
}
impl<R: ReadHalf, W: WriteHalf> Split<R, W> {
pub fn read(&self) -> &R {
&self.read
}
pub fn read_mut(&mut self) -> &mut R {
&mut self.read
}
pub fn write(&self) -> &W {
&self.write
}
pub fn write_mut(&mut self) -> &mut W {
&mut self.write
}
pub fn take(self) -> (R, W) {
(self.read, self.write)
}
}
pub type BoxedSplit = Split<Box<dyn ReadHalf>, Box<dyn WriteHalf>>;
impl<S: Socket> From<S> for BoxedSplit {
fn from(socket: S) -> Self {
let split = socket.split();
Split {
read: Box::new(split.read),
write: Box::new(split.write),
}
}
}