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
//! System information types for building type-safe system-level applications.
//!
//! This module provides strongly-typed abstractions for common system information concepts,
//! ensuring type safety and preventing common errors in system programming.
//!
//! ## Design Rules
//!
//! All types in this module follow the core design rules, which adhere to
//! [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/):
//!
//! ### 1. Type Safety (C-NEWTYPE, C-CUSTOM-TYPE)
//!
//! - Strong types prevent mixing incompatible values
//! - Arguments convey meaning through types, not `bool` or `Option`
//! - All validation performed at construction time
//! - No runtime errors from invalid states
//! - Invalid states are unrepresentable
//!
//! ### 2. Zero-Cost Abstractions
//!
//! - No runtime overhead compared to using primitive types
//! - All validation happens at compile time or construction
//! - Subsequent operations have zero cost
//! - Use `#[repr(transparent)]` for newtypes over primitive types
//!
//! ### 3. Compile-Time Constants
//!
//! - `Arch::current()` and `OsType::current()` return compile-time constants
//! - These reflect the target platform, not runtime detection
//! - Cross-compilation safe
//!
//! ### 4. Composability (C-COMMON-TRAITS, C-CONV-TRAITS)
//!
//! All types implement standard traits:
//! - **Common traits** (C-COMMON-TRAITS):
//!   - `Debug` for debugging
//!   - `Clone` for copying
//!   - `Display` for formatting
//!   - `Hash` for use in hash maps
//!   - `Eq` and `PartialEq` for equality
//!   - `Ord` and `PartialOrd` for ordering (where applicable)
//! - **Conversion traits** (C-CONV-TRAITS):
//!   - `FromStr` for parsing from strings
//!   - `From` for infallible conversions
//!   - `TryFrom` for fallible conversions
//!
//! ### 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
//!
//! ### 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 constructors
//! - Clear, readable code over clever abstractions
//!
//! ## Types
//!
//! This module includes types for:
//!
//! - **Architecture**: CPU architecture enumeration (`Arch`)
//! - **Operating System**: OS type enumeration (`OsType`)
//! - **OS Version**: Version numbers for OS releases (`OsVersion`)
//! - **Kernel Version**: Linux/Unix kernel versions with release strings (`KernelVersion`)
//! - **System Hostname**: System hostname with RFC 1123 validation (`Hostname`)
//! - **System Username**: POSIX-compliant system username (`Username`)
//! - **OS Distribution**: OS distribution name with family detection (`Distro`)
//! - **Process ID**: Type-safe process identifier (`Pid`)
//! - **File Descriptor**: Type-safe file descriptor (`Fd`)
//!
//! Note: `Hostname` is re-exported from the `net` module as it uses the same
//! RFC 1123 validation rules for both network and system contexts.
//!
//! ## Features
//!
//! This module requires `sys` feature to be enabled.
//!
//! ```toml
//! [dependencies]
//! bare-types = { version = "0.1", features = ["sys"] }
//! ```
//!
//! ## `no_std` Support
//!
//! This module is fully `no_std` compatible. All types are built on `core`
//! and do not require the standard library.
//!
//! To use in a `no_std` environment:
//!
//! ```toml
//! [dependencies]
//! bare-types = { version = "0.1", default-features = false, features = ["sys"] }
//! ```
//!
//! The `std` feature can be optionally enabled for `std::error::Error` implementations.

pub mod arch;
pub mod distro;
pub mod fd;
pub mod kernel_version;
pub mod os_type;
pub mod os_version;
pub mod pid;
pub mod username;

pub use arch::{Arch, ArchError};
pub use distro::{Distro, DistroError};
pub use fd::{Fd, FdError};
pub use kernel_version::{KernelVersion, KernelVersionError};
pub use os_type::{OsType, OsTypeError};
pub use os_version::{OsVersion, OsVersionError};
pub use pid::{Pid, PidError};
pub use username::{Username, UsernameError};

// Re-export Hostname from net module for sys context
pub use crate::net::{Hostname, HostnameError};