iocore 3.1.0

IOCore is a safe library for unix CLI tools and Systems programming. IOCore provides the [`iocore::Path`] abstraction of file-system paths designed to replace most [`std::path`] and [`std::fs`] operations with practical methods, other abstractions include: - handling file-system permissions via [`iocore::PathPermissions`] powered by the crate [`trilobyte`]. - handling file-system timestamps via [`iocore::PathTimestamps`] granularly via [`iocore::PathDateTime`]. IOCore provides the [`iocore::walk_dir`] function and its companion trait [`iocore::WalkProgressHandler`] which traverses file-systems quickly via threads. IOcore provides [`iocore::User`] which provides unix user information such as uid, path to home etc. The module [`iocore::env`] provides [`iocore::env:args`] returns a [`Vec<String>`] from [`std::env:args`], and [`iocore::env:var`] that returns environment variables as string.
Documentation
use std::fmt::Display;
use std::string::ToString;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
pub enum PathStatus {
    None,
    ReadOnlyDirectory,
    ReadOnlyFile,
    ReadOnlySetuid,
    ReadOnlySymlink,
    WritableDirectory,
    WritableFile,
    WritableSetuid,
    WritableSymlink,
}

impl PathStatus {
    pub fn to_str(self) -> &'static str {
        match self {
            Self::ReadOnlyDirectory => "read-only directory",
            Self::ReadOnlyFile => "read-only file",
            Self::ReadOnlySetuid => "read-only setuid",
            Self::ReadOnlySymlink => "read-only symlink",
            Self::WritableFile => "writable file",
            Self::None => "none",
            Self::WritableDirectory => "writable directory",
            Self::WritableSetuid => "writable setuid",
            Self::WritableSymlink => "writable symlink",
        }
    }
}

impl Into<&'static str> for PathStatus {
    fn into(self) -> &'static str {
        self.to_str()
    }
}

impl Into<String> for PathStatus {
    fn into(self) -> String {
        self.to_str().to_string()
    }
}

impl Display for PathStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.to_str())
    }
}