todotxt-tui 0.2.0

Todo.txt TUI is a highly customizable terminal-based application for managing your todo tasks. It follows the todo.txt format and offers a wide range of configuration options to suit your needs.
Documentation
use std::{
    env::VarError,
    path::{Path, PathBuf},
    result::Result as stdResult,
};

/// Define a custom result type for ToDo related operations.
pub type Result<T> = stdResult<T, ToDoError>;

/// Enum representing ToDo-related errors.
#[derive(Debug, thiserror::Error)]
pub enum ToDoError {
    #[error("Selected widgent is not in layout")]
    WidgetDoesNotExist,
    #[error("Value cannot be parsed: {0}")]
    ParseValue(#[from] std::num::ParseIntError),
    #[error("Value can constraint only unsigned integer and % not {0}")]
    ParseUnknownValue(String),
    #[error("Unknown widget type: {0}")]
    ParseWidgetType(String),
    #[error("There must be almost one container.")]
    ParseNotStart,
    #[error("All containers must be closed.")]
    ParseNotEnd,
    #[error("Unknown text before start of the container '{0}'")]
    ParseUnknowBeforeContainer(String),
    #[error("Direction '{0}' is invalid.")]
    ParseInvalidDirection(String),
    #[error("Style '{0}' is invalid")]
    ParseTextStyle(String),
    #[error("Style list '{0}' does not contain at least one item")]
    ParseTextStyleList(String),
    #[error("Modifier '{0}' is invalid.")]
    ParseTextModifier(String),
    #[error("Block '{0}' have escape on the end.")]
    ParseBlockEscapeOnEnd(String),
    #[error("Block '{0}' is not closed.")]
    ParseBlockNotClosed(String),
    #[error("Variable '{0}' is not closed.")]
    ParseVariableNotClosed(String),
    #[error("Block '{0}' constraint empty variable name.")]
    EmptyVariableName(String),
    #[error("Invalid state, active container is not widget.")]
    ActiveIsNotWidget,
    #[error("IO error file: {0}, error: {1}")]
    IOoperationFailed(PathBuf, #[source] std::io::Error),
    #[error("IOError: {0}")]
    IOFailed(#[from] std::io::Error),
    #[error("TOML serialization error: {0}")]
    TomlSerError(#[from] toml::ser::Error),
    #[error("TOML deserialization error: {}", .0.to_string())]
    TomlDesError(#[from] toml::de::Error),
    #[error("String '{0}' is not valid color.")]
    ColorSerializationFailed(String),
    #[error("Var error: {0}")]
    VarError(#[from] VarError),
    #[error("Cannot load configuration: {0}")]
    ConfigLoadError(#[from] twelf::Error),
    #[error("Cannot parse event entry: {0}")]
    CannotParseEventEntry(String),
    #[error("Cannot parse UI event: {0}")]
    CannotParseUIEvent(String),
    #[error("Cannot parse custom category style: {0}")]
    CustomCategoryStyleParseFailed(&'static str),
    #[error("Notify {0}")]
    NotifyError(#[from] notify::Error),
}

impl ToDoError {
    pub fn io_operation_failed(path: impl AsRef<Path>, err: std::io::Error) -> Self {
        Self::IOoperationFailed(path.as_ref().to_path_buf(), err)
    }
}