bare-types 0.3.0

A zero-cost foundation for type-safe domain modeling in Rust. Implements the 'Parse, don't validate' philosophy to eliminate primitive obsession and ensure data integrity at the system boundary.
Documentation
//! # bare-types
//!
//! A zero-cost foundation for type-safe domain modeling in Rust.
//!
//! ## Overview
//!
//! `bare-types` provides strongly-typed, zero-cost abstractions for domain modeling in Rust.
//! It implements the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/) and follows strict design principles to ensure
//! type safety, performance, and correctness.
//!
//! ## Design Philosophy
//!
//! ### Parse, Don't Validate
//!
//! This project follows the "Parse, don't validate" philosophy. Instead of validating data throughout your codebase,
//! parse it once at the system boundary and use strong types to ensure invariants are maintained.
//!
//! This approach provides:
//! - **Type safety**: Invalid states are unrepresentable
//! - **Zero-cost abstractions**: Validation happens once at construction
//! - **Clear error handling**: Errors are caught early and explicitly
//! - **Self-documenting code**: Types convey meaning
//!
//! ## Design Rules
//!
//! This project adheres to the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/) and implements the following design rules:
//!
//! ### 1. Type Safety (C-NEWTYPE, C-CUSTOM-TYPE)
//!
//! - Use newtype pattern to provide static distinctions between types (C-NEWTYPE)
//! - Arguments convey meaning through types, not `bool` or `Option` (C-CUSTOM-TYPE)
//! - All validation is performed at construction time
//! - Invalid states are unrepresentable
//!
//! ### 2. Zero-Cost Abstractions
//!
//! - All validation is performed at compile time or construction time
//! - No runtime cost for accessing validated data
//! - Use `#[repr(transparent)]` for newtypes over primitive types
//! - Memory layout matches underlying types
//!
//! ### 3. RFC Compliance
//!
//! Strictly follow relevant standards:
//! - Domain names: RFC 1035
//! - Hostnames: RFC 1123
//! - IP addresses: Standard IPv4/IPv6
//!
//! ### 4. Composability (C-COMMON-TRAITS, C-CONV-TRAITS)
//!
//! All types implement standard traits for easy composition:
//! - **Common traits** (C-COMMON-TRAITS): `Debug`, `Clone`, `Display`, `Hash`, `Eq`, `PartialEq`, `Ord`, `PartialOrd`, `Default`
//! - **Conversion traits** (C-CONV-TRAITS): `From`, `TryFrom`, `AsRef`, `AsMut` (NOT `Into` or `TryInto`)
//! - **Collection traits** (C-COLLECT): `FromIterator`, `Extend` (for collection types)
//!
//! ### 5. Security (C-SEND-SYNC, C-GOOD-ERR)
//!
//! - Types are `Send` and `Sync` where possible (C-SEND-SYNC)
//! - Error types implement `std::error::Error`, `Send`, `Sync` (C-GOOD-ERR)
//! - No unsafe code allowed (`unsafe_code = "forbid"`)
//! - Sensitive data uses `Zeroize` for automatic memory clearing
//!
//! ### 6. Explicit Over Implicit (C-DEREF, C-CTOR)
//!
//! - Only smart pointers implement `Deref` and `DerefMut` (C-DEREF)
//! - Constructors are static, inherent methods (C-CTOR)
//! - Prefer explicit code over implicit behavior
//! - No declarative macros except for serde derives
//!
//! ### 7. Strict Linting
//!
//! The project enforces strict linting rules:
//! - `unsafe_code = "forbid"`
//! - `missing_docs = "warn"`
//! - Deny-level clippy rules for safety and correctness
//!
//! ## Design Goals
//!
//! ### Performance
//!
//! - Zero-cost abstractions for type safety
//! - Efficient memory usage with optimized data structures
//! - No runtime overhead for validated types
//!
//! ### Portability
//!
//! - Cross-platform: Linux, macOS, Windows
//! - `no_std` support for embedded and WASM
//! - Minimal dependencies for reduced attack surface
//!
//! ### Ergonomics
//!
//! - Type-safe APIs prevent common errors
//! - Clear error messages with detailed context
//! - Comprehensive documentation with examples
//! - Follow Rust naming conventions (RFC 430)
//!
//! ### Security
//!
//! - Memory safety guaranteed by Rust
//! - Type safety prevents many classes of bugs
//! - No unsafe code in codebase
//! - Minimal external dependencies
//!
//! ## Features
//!
//! - **`std`** - Enable standard library support (default)
//! - **`net`** - Network-related types (IP addresses, ports, hostnames, etc.)
//! - **`sys`** - System information types (architecture, OS, versions, etc.)
//! - **`serde`** - Enable serde serialization/deserialization support
//! - **`arbitrary`** - Enable arbitrary value generation for fuzzing
//! - **`zeroize`** - Enable automatic memory clearing for sensitive data
//!
//! ## Modules
//!
//!//! ### net (requires `net` feature)
//!
//! Network-related types for building type-safe network applications:
//! - IP addresses (IPv4 and IPv6) with validation
//! - Port numbers with IANA range validation
//! - Hostnames with RFC 1123 validation
//! - Domain names with RFC 1035 validation
//! - Host type unifying IP, domain name, and hostname
//! - Socket addresses combining host and port
//! - CIDR notation for IP network prefixes
//!
//! ### sys (requires `sys` feature)
//!
//! System information types for building type-safe system-level applications:
//! - CPU architecture (`Arch`) with compile-time detection
//! - Operating system type (`OsType`) with compile-time detection
//! - OS version (`OsVersion`) with semantic versioning
//! - Kernel version (`KernelVersion`) with release strings
//! - System hostname (`Hostname`) with RFC 1123 validation (re-exported from `net` module)
//! - System username (`Username`) with POSIX validation
//! - OS distribution name (`Distro`) with family detection
//!
//! ## License
//!
//! MIT OR Apache-2.0

#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]
#![allow(unused_crate_dependencies)]

#[cfg(feature = "net")]
pub mod net;

#[cfg(feature = "sys")]
pub mod sys;

#[cfg(feature = "std")]
pub mod prelude;