eject/
lib.rs

1//! A crate to control the tray of your CD drive.
2//!
3//! [`Device`][device::Device] contains methods to open drives and send commands to them.
4//!
5//! [`cd_drives`][discovery::cd_drives] allows you to find all CD drives on a system.
6//!
7//! # Example
8//!
9//! ```no_run
10//! use eject::{device::Device, discovery::cd_drives};
11//!
12//! // Open the drive at this path
13//! let cdrom = Device::open("/dev/cdrom")?;
14//! // Or get the first one available
15//! let cdrom_path = cd_drives().next().unwrap();
16//! let cdrom = Device::open(&cdrom_path)?;
17//! // Open the tray
18//! cdrom.eject()?;
19//! # eject::error::Result::Ok(())
20//! ```
21
22#![deny(unsafe_op_in_unsafe_fn)]
23#![warn(missing_docs)]
24
25pub mod device;
26pub mod discovery;
27pub mod error;
28#[cfg_attr(windows, path = "platforms/windows/mod.rs")]
29#[cfg_attr(target_os = "linux", path = "platforms/linux/mod.rs")]
30#[cfg_attr(target_os = "macos", path = "platforms/macos/mod.rs")]
31mod platform;
32#[cfg(test)]
33mod tests;