use std::{io, os::fd};
pub struct Pair {
read: fd::OwnedFd,
write: fd::OwnedFd,
}
impl Pair {
pub fn blocking() -> io::Result<Self> {
use crate::backend::{Backend, WakeFactory};
let (read, write) = <Backend as WakeFactory>::open_blocking_wake_ends()?;
Ok(Self { read, write })
}
pub fn nonblocking() -> io::Result<Self> {
use crate::backend::{Backend, WakeFactory};
let (read, write) = <Backend as WakeFactory>::open_nonblocking_wake_ends()?;
Ok(Self { read, write })
}
pub fn split(self) -> (fd::OwnedFd, fd::OwnedFd) {
(self.read, self.write)
}
}