laravel-casts 0.2.0

Eloquent-style attribute casts for laravel-rust models: DateCast and DateTimeCast read, write and serialize a date column in a PHP format
Documentation
//! The error of a cast, typed or dynamic.

/// A value that cannot be cast, or a cast that cannot be understood.
///
/// `laravel::Error` takes it with `?` as a `500`. When the value came from a request, match on it and answer a `422`
/// for [`CastError::Rejected`] and [`CastError::Invalid`].
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum CastError {
    /// The cast name is not one this port knows.
    #[error("unsupported cast `{0}`")]
    Unsupported(String),
    /// The cast is known but its arguments or the value are not usable.
    #[error("cast `{cast}`: {reason}")]
    Invalid {
        /// The cast, as written.
        cast: String,
        /// What is wrong.
        reason: String,
    },
    /// A date pattern the cast was given cannot be used.
    #[error(transparent)]
    Pattern(#[from] php_dates::Error),
    /// The cast hashes, and hashing is asynchronous: use the `_async` form.
    #[error(
        "cast `{0}` hashes on the blocking pool: use `set_async`, `apply_async` or `cast_array_async`"
    )]
    NeedsAsync(String),
    /// The framework could not hash or encrypt the value, or decrypt it.
    #[error("cast `{cast}`: {message}")]
    Failed {
        /// The cast, as written.
        cast: String,
        /// What the framework said.
        message: String,
    },
    /// A value that came from outside (a request, JSON) and that the cast refuses, in the cast's own words.
    /// What a [`crate::ColumnCast`] of your own answers, and what [`crate::canonical`] shows.
    #[error("{0}")]
    Rejected(String),
}