stak_device/device/
void.rs

1use crate::{BufferError, Device};
2use winter_maybe_async::maybe_async;
3
4/// A void device where all I/O operations succeed with no side effect.
5#[derive(Debug, Default)]
6pub struct VoidDevice {}
7
8impl VoidDevice {
9    /// Creates a device.
10    pub fn new() -> Self {
11        Self::default()
12    }
13}
14
15impl Device for VoidDevice {
16    type Error = BufferError;
17
18    #[maybe_async]
19    fn read(&mut self) -> Result<Option<u8>, Self::Error> {
20        Ok(None)
21    }
22
23    #[maybe_async]
24    fn write(&mut self, _byte: u8) -> Result<(), Self::Error> {
25        Ok(())
26    }
27
28    #[maybe_async]
29    fn write_error(&mut self, _byte: u8) -> Result<(), Self::Error> {
30        Ok(())
31    }
32}