eck 0.0.3

A fast, simple file & folder encryption manager, written in Rust
use serde::{Deserialize, Serialize};
use std::fmt::Display;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ParallelismType {
    Auto,
    MultiThread(u8),
    Single,
}

impl ParallelismType {
    /// Description of the parallelism type. Single source of
    /// truth used by both `Display` and the `String` conversion.
    pub fn description(&self) -> String {
        match self {
            Self::Auto => "Automatic".to_string(),
            Self::MultiThread(n) => format!("MultiThreading with {} threads", n),
            Self::Single => "SingleThread".to_string(),
        }
    }
}

impl From<ParallelismType> for String {
    fn from(value: ParallelismType) -> Self {
        value.description()
    }
}

impl Display for ParallelismType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.description())
    }
}