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
//! Eloquent-style attribute casts for laravel-rust models.
//!
//! laravel-rust models have typed fields and no cast hook, so a cast is the field's type, the way
//! `Encrypted<T>` is. `get` is `Decode` + `Serialize`, `set` is `From<&T> for Value` + `Deserialize`.
//!
//! ```ignore
//! #[model]
//! struct Invoice {
//!     id: i64,
//!     issued_at: DateCast,                  // DateCast::class
//!     paid_at: Option<DateTimeCast<Parsed>>, // DateTimeCast::SETPARSED
//!     period: Option<DateCast<MonthYear>>,  // DateCast::SETONLYMONTHYEAR
//! }
//! ```
//!
//! A cast of your own implements [`ColumnCast`]. Casts chosen at run time, by name, are in `laravel_casts::dynamic`,
//! behind the `dynamic` feature (off by default).

#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod canonical;
mod cast;
mod config;
mod contract;
#[cfg(feature = "dynamic")]
pub mod dynamic;
mod error;
mod kind;
mod pattern;

pub use cast::{Cast, DateCast, DateTimeCast};
pub use config::configure;
pub use contract::ColumnCast;
pub use error::CastError;
pub use kind::{Configured, DateAndTime, DateOnly, Format, Kind, MonthYear, Parsed, Storage};
pub use php_dates::{DateConfig, DatePatterns, Error, PhpDatePattern, Result};

/// What [`impl_column_cast!`] names, so that the type that uses it does not need these crates by name.
#[doc(hidden)]
pub mod __private {
    pub use laravel::Result;
    pub use laravel::db::{AnyRow, Decode, Nullable, Value};
}