kanata-evsieve 1.3.1

evsieve functionality for use by kanata
Documentation
// SPDX-License-Identifier: GPL-2.0-or-later

// Allowed because useless default implementations are dead lines of code.
#![allow(clippy::new_without_default)]
// Allowed because the key "" is a canonically valid key, and comparing a key to "" is more
// idiomatic than asking whether a key is empty.
#![allow(clippy::comparison_to_empty)]
// Allowed because nested ifs allow for more-readable code.
#![allow(clippy::collapsible_if)]
// Allowed because the matches! macro is not supported in Rust 1.41.1, under which evsieve must compile.
#![allow(clippy::match_like_matches_macro)]
// Disallowed for code uniformity.
#![warn(clippy::explicit_iter_loop)]
#![warn(clippy::explicit_into_iter_loop)]

pub mod capability;
pub mod control_fifo;
pub mod daemon;
pub mod domain;
pub mod ecodes;
pub mod error;
pub mod event;
pub mod key;
pub mod loopback;
pub mod predevice;
pub mod range;
pub mod signal;
pub mod state;
pub mod stream;
pub mod subprocess;
pub mod utils;

#[cfg(feature = "auto-scan")]
pub mod scancodes;

pub mod io {
    pub mod epoll;
    pub mod fd;
    pub mod fifo;
    pub mod input;
    pub mod internal_pipe;
    pub mod output;
}

pub mod persist {
    pub mod blueprint;
    pub mod inotify;
    pub mod interface;
    pub mod subsystem;
}

pub mod arguments {
    pub mod control_fifo;
    pub mod delay;
    pub mod hook;
    pub mod input;
    pub mod lib;
    pub mod map;
    pub mod merge;
    pub mod output;
    pub mod parser;
    pub mod print;
    pub mod test;
    pub mod toggle;
    pub mod withhold;
}

pub mod bindings {
    #[allow(warnings)]
    pub mod libevdev;
}

#[macro_use]
extern crate lazy_static;

use control_fifo::ControlFifo;
use io::fd::HasFixedFd;
use io::input::InputDevice;
use signal::SignalFd;
use std::os::unix::prelude::{AsRawFd, RawFd};

pub enum Pollable {
    InputDevice(InputDevice),
    SignalFd(SignalFd),
    ControlFifo(ControlFifo),
    PersistSubsystem(persist::interface::HostInterface),
}
unsafe impl HasFixedFd for Pollable {}

impl AsRawFd for Pollable {
    fn as_raw_fd(&self) -> RawFd {
        match self {
            Pollable::InputDevice(device) => device.as_raw_fd(),
            Pollable::SignalFd(fd) => fd.as_raw_fd(),
            Pollable::ControlFifo(fifo) => fifo.as_raw_fd(),
            Pollable::PersistSubsystem(interface) => interface.as_raw_fd(),
        }
    }
}