Crate proven

Crate proven 

Source
Expand description

§Proven - Safe, Formally Verified Library

Rust bindings for the proven library, providing formally verified implementations for safe math, cryptography, parsing, and validation. Calls Idris 2 verified code via Zig ABI.

§Features

  • Safe Math: Overflow detection, safe division, bounded integers
  • Safe Strings: UTF-8 validation, injection-safe escaping
  • Safe JSON: Exception-free parsing with type-safe access
  • Safe URLs: RFC 3986 compliant parsing
  • Safe Email: RFC 5321/5322 validation
  • Safe Paths: Traversal prevention, glob matching
  • Safe Crypto: Secure hashing, HMAC, random generation (stubs)
  • Safe Passwords: Policy validation, strength analysis
  • Safe DateTime: ISO 8601 parsing, timezone handling
  • Safe Network: IPv4/IPv6 parsing, CIDR, ports
  • Safe UUID: RFC 4122 UUID generation and validation
  • Safe Currency: Type-safe monetary values with ISO 4217 codes
  • Safe Phone: E.164 phone number parsing and formatting
  • Safe Hex: Hexadecimal encoding and decoding
  • Safe Header: HTTP header validation, CRLF injection prevention (v0.8.0)
  • Safe Cookie: HTTP cookie validation, injection prevention (v0.8.0)
  • Safe ContentType: MIME type validation, sniffing prevention (v0.8.0)
  • Safe Float: NaN/Infinity prevention, safe division for f32/f64 (v0.9.0)
  • Safe Tensor: Bounds-checked vector/matrix ops, shape validation (v0.9.0)
  • Safe ML: Numerically stable softmax, loss functions, activations (v0.9.0)

§Example

use proven::{SafeMath, SafeString, Result};

// Safe addition with overflow detection
let result = SafeMath::add(i64::MAX, 1);
assert!(result.is_err());

// Safe HTML escaping
let escaped = SafeString::escape_html("<script>alert('xss')</script>");
assert!(!escaped.contains('<'));

Re-exports§

pub use crate::core::Bounded;
pub use crate::core::Error;
pub use crate::core::NonEmpty;
pub use crate::core::Result;
pub use safe_content_type::ContentType;
pub use safe_content_type::MediaCategory;
pub use safe_content_type::SafeContentType;
pub use safe_cookie::Cookie;
pub use safe_cookie::CookieAttributes;
pub use safe_cookie::CookiePrefix;
pub use safe_cookie::SafeCookie;
pub use safe_cookie::SameSite;
pub use safe_crypto::SafeCrypto;
pub use safe_currency::CurrencyCode;
pub use safe_currency::Money;
pub use safe_currency::SafeCurrency;
pub use safe_datetime::SafeDateTime;
pub use safe_email::SafeEmail;
pub use safe_header::Header;
pub use safe_header::SafeHeader;
pub use safe_hex::SafeHex;
pub use safe_json::SafeJson;
pub use safe_math::SafeMath;
pub use safe_network::SafeNetwork;
pub use safe_password::SafePassword;
pub use safe_path::SafePath;
pub use safe_phone::PhoneNumber;
pub use safe_phone::SafePhone;
pub use safe_string::SafeString;
pub use safe_url::SafeUrl;
pub use safe_uuid::SafeUuid;
pub use safe_uuid::Uuid;
pub use safe_float::SafeFloat;
pub use safe_ml::SafeML;
pub use safe_tensor::SafeTensor;

Modules§

core
Core types for the proven library.
safe_content_type
Safe Content-Type operations that prevent MIME sniffing attacks.
safe_cookie
Safe HTTP Cookie operations that prevent injection attacks.
safe_crypto
Safe cryptographic operations with formally verified specifications.
safe_currency
Safe currency operations with type-safe monetary values.
safe_datetime
Safe datetime parsing and validation.
safe_email
Safe email validation.
safe_float
Safe floating-point operations with NaN/Infinity prevention.
safe_header
Safe HTTP Header operations that prevent CRLF injection attacks.
safe_hex
Safe hexadecimal encoding and decoding.
safe_json
Safe JSON parsing and access.
safe_math
Safe mathematical operations with overflow detection.
safe_ml
Safe machine learning operations with mathematical guarantees.
safe_network
Safe network address operations.
safe_password
Safe password handling and validation.
safe_path
Safe path operations with traversal prevention.
safe_phone
Safe phone number validation following E.164.
safe_string
Safe string operations with injection prevention.
safe_tensor
Safe tensor and matrix operations with bounds checking.
safe_url
Safe URL parsing and manipulation.
safe_uuid
Safe UUID generation and validation following RFC 4122.