projectr 0.4.1

A contextual, MRU sorted, project finder.
Documentation
#[derive(Debug)]
pub enum FormatError {
    Path(String),
    Timestamp(String),
}

#[derive(Debug)]
pub enum Error {
    IO(std::io::Error),
    Utf8(std::str::Utf8Error),
    PathFormat(String),
    TimestampFormat(String),
    ParseInt(std::num::ParseIntError),
    NotFound,
}

impl std::error::Error for Error {}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Error::IO(err) => write!(f, "IO error: {}", err),
            Error::Utf8(err) => write!(f, "Failed to parse UTF8: {}", err),

            Error::PathFormat(s) => write!(f, "Invalid path format: {}", s),
            Error::TimestampFormat(s) => write!(f, "Invalid timestamp format: {}", s),
            Error::ParseInt(err) => write!(f, "Failed to parse int: {}", err),
            Error::NotFound => write!(f, "Tmux session not found"),
        }
    }
}

impl From<std::io::Error> for Error {
    fn from(value: std::io::Error) -> Self {
        Self::IO(value)
    }
}

impl From<std::str::Utf8Error> for Error {
    fn from(value: std::str::Utf8Error) -> Self {
        Self::Utf8(value)
    }
}

impl From<std::num::ParseIntError> for Error {
    fn from(value: std::num::ParseIntError) -> Self {
        Self::ParseInt(value)
    }
}