From 253ff25d88c6582fc55956f55eb4ad603465ffcb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 14:47:17 +0100 Subject: [PATCH] timedfd: Provide TimedFdWriter too Signed-off-by: Ian Jackson --- src/timedfd.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/timedfd.rs b/src/timedfd.rs index c16aa136..91eed394 100644 --- a/src/timedfd.rs +++ b/src/timedfd.rs @@ -25,11 +25,16 @@ pub trait TimedFdReadWrite { } pub type TimedFdReader = TimedFd; +pub type TimedFdWriter = TimedFd; #[derive(Debug,Copy,Clone)] pub struct TimedFdRead; impl TimedFdReadWrite for TimedFdRead { const INTEREST : mio::Interest = mio::Interest::READABLE; } +#[derive(Debug,Copy,Clone)] pub struct TimedFdWrite; +impl TimedFdReadWrite for TimedFdWrite { + const INTEREST : mio::Interest = mio::Interest::WRITABLE; +} pub struct Fd(RawFd); impl Fd { @@ -128,6 +133,16 @@ impl Read for TimedFd { } } +impl Write for TimedFd { + #[throws(io::Error)] + fn write(&mut self, buf: &[u8]) -> usize { + self.rw(|fd| unistd::write(fd, buf))? + } + #[throws(io::Error)] + fn flush(&mut self) { + } +} + impl Drop for Fd { fn drop(&mut self) { let fd = self.extract_raw_fd(); -- 2.30.2