Skip to main content

Crate maybe_valid

Crate maybe_valid 

Source
Expand description

maybe-valid provides traits and dedicated outcome enums for structural validation/refinement conversions.

Core pieces:

  • Validated: declares a canonical diagnostic reason type for a validated target.
  • AsValidated: borrow-based validation (&Self -> &V).
  • IntoValidated: owning validation (Self -> V, with precursor recovery on failure).
  • MaybeValidRef and MaybeValidOwned: explicit valid/invalid outcomes (intentionally distinct from Result) that carry precursor data on the invalid branch.

Feature flags:

  • std (default): enables alloc and all provided std/alloc-backed impls.
  • alloc: enables owned string/C string conversions.
  • no default features: keeps core/no-alloc functionality.

Structs§

ZeroReason
Returned on the invalid path when validating an integer as a corresponding NonZero* type.

Enums§

CStrInvalidReason
Returned on the invalid path when validating bytes as CStr or CString.
MaybeValidOwned
The outcome of consuming a value into a validated form of type V.
MaybeValidRef
The outcome of borrowing a value as a validated view of type V.

Traits§

AsValidated
Borrows Self as a validated view of type V, if self satisfies V’s predicate.
IntoValidated
Consumes Self into a validated value of type V, if self satisfies V’s predicate.
Validated
A type whose values are guaranteed to satisfy a validation predicate.