maybe_valid/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2//! `maybe-valid` provides traits and dedicated outcome enums for
3//! structural validation/refinement conversions.
4//!
5//! Core pieces:
6//! - [`Validated`]: declares a canonical diagnostic reason type for a
7//! validated target.
8//! - [`AsValidated`]: borrow-based validation (`&Self` -> `&V`).
9//! - [`IntoValidated`]: owning validation (`Self` -> `V`, with precursor
10//! recovery on failure).
11//! - [`MaybeValidRef`] and [`MaybeValidOwned`]: explicit valid/invalid
12//! outcomes (intentionally distinct from `Result`) that carry
13//! precursor data on the invalid branch.
14//!
15//! Feature flags:
16//! - `std` (default): enables `alloc` and all provided std/alloc-backed impls.
17//! - `alloc`: enables owned string/C string conversions.
18//! - no default features: keeps core/no-alloc functionality.
19
20#[cfg(feature = "alloc")]
21extern crate alloc;
22
23mod api;
24mod impls;
25
26pub use api::*;
27pub use impls::core_impls::{CStrInvalidReason, ZeroReason};