eject/device/
status.rs

1/// Position of the drive's tray and whether it has data loaded.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
3pub enum DriveStatus {
4    /// No media is inserted. If there's a tray, it's closed.
5    Empty,
6    /// The drive has a tray or other similar mechanism and it's open.
7    TrayOpen,
8    /// The drive is not available yet. With CD drives this happens for a few
9    /// seconds after the tray is closed.
10    ///
11    /// This status is not supported on Windows yet. There it'll be reported as [`Empty`][Self::Empty].
12    NotReady,
13    /// The drive has data loaded. If it reads from removable media
14    /// (e.g. CDs/floppy/SD cards) then one is inserted.
15    Loaded,
16}
17
18impl DriveStatus {
19    /// Returns whether this status implies that the tray is open.
20    pub const fn tray_open(&self) -> bool {
21        match self {
22            Self::Empty | Self::Loaded | Self::NotReady => false,
23            Self::TrayOpen => true,
24        }
25    }
26}