netwatch_rs/platform/
mod.rs1use crate::{device::NetworkReader, error::Result};
2
3#[cfg(target_os = "linux")]
4mod linux;
5#[cfg(target_os = "linux")]
6pub use linux::LinuxReader;
7
8#[cfg(target_os = "macos")]
9mod macos;
10#[cfg(target_os = "macos")]
11pub use macos::MacOSReader;
12
13pub fn create_reader() -> Result<Box<dyn NetworkReader>> {
14 #[cfg(target_os = "linux")]
15 return Ok(Box::new(LinuxReader::new()));
16
17 #[cfg(target_os = "macos")]
18 return Ok(Box::new(MacOSReader::new()));
19
20 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
21 return Err(crate::error::NetwatchError::Platform(
22 "Unsupported platform".to_string(),
23 ));
24}