ezcal 0.3.4

Ergonomic iCalendar + vCard library for Rust
Documentation
/// Errors that can occur when parsing iCalendar or vCard content.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("parse error at line {line}: {message}")]
    Parse { line: usize, message: String },

    #[error("missing required property: {0}")]
    MissingProperty(String),

    #[error("invalid value for {property}: {message}")]
    InvalidValue { property: String, message: String },

    #[error("unexpected component: expected {expected}, found {found}")]
    UnexpectedComponent { expected: String, found: String },

    #[error("unclosed component: {0}")]
    UnclosedComponent(String),

    #[error("{0}")]
    Other(String),
}

impl Error {
    pub(crate) fn parse(line: usize, message: impl Into<String>) -> Self {
        Error::Parse {
            line,
            message: message.into(),
        }
    }

    pub(crate) fn invalid_value(property: impl Into<String>, message: impl Into<String>) -> Self {
        Error::InvalidValue {
            property: property.into(),
            message: message.into(),
        }
    }
}

pub type Result<T> = std::result::Result<T, Error>;