nexcore_network/lib.rs
1// Copyright (c) 2026 Matthew Campion, PharmD; NexVigilant
2// All Rights Reserved. See LICENSE file for details.
3
4//! # nexcore-network — NexCore OS Networking Subsystem
5//!
6//! Tier: T3 (Σ + μ + ∂ + ς + σ + π + ∝ + N + ν + κ + → + λ + ∃)
7//!
8//! Complete networking stack for NexCore OS sitting above `nexcore-pal::Network`.
9//! Manages interfaces, connections, DNS, routing, firewall rules, traffic
10//! monitoring, and TLS certificate trust stores across all three form factors
11//! (watch, phone, desktop).
12//!
13//! ## Module Architecture
14//!
15//! | Module | Tier | Dominant | Purpose |
16//! |--------|------|----------|---------|
17//! | `interface` | T2-C | Σ + μ + ∃ | Network interface abstraction |
18//! | `connection` | T2-C | ς + σ + ∂ | Connection state machine |
19//! | `dns` | T2-C | μ + π + ν | DNS resolver with caching |
20//! | `firewall` | T2-C | ∂ + κ + → | Packet filtering rules |
21//! | `route` | T2-C | → + κ + λ | Routing table with prefix matching |
22//! | `monitor` | T2-C | N + ν + σ | Bandwidth, latency, and quality tracking |
23//! | `certificate` | T2-C | ∂ + π + ∝ | TLS certificate trust store |
24//!
25//! ## Example
26//!
27//! ```rust
28//! use nexcore_network::{Interface, InterfaceType, IpAddr, Connection, ConnectionState};
29//!
30//! // Create a WiFi interface
31//! let iface = Interface::new("wlan0", "wlan0", InterfaceType::WiFi)
32//! .up()
33//! .with_address(IpAddr::v4(192, 168, 1, 100));
34//!
35//! assert!(iface.is_up);
36//! assert_eq!(iface.interface_type, InterfaceType::WiFi);
37//!
38//! // Create a connection tracking its lifecycle
39//! let conn = Connection::new(iface.id.clone(), iface.interface_type, "HomeWiFi");
40//! assert_eq!(conn.state(), ConnectionState::Disconnected);
41//! ```
42
43#![forbid(unsafe_code)]
44#![warn(missing_docs)]
45#![cfg_attr(
46 not(test),
47 deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)
48)]
49
50// ── Modules ──────────────────────────────────────────────────────────
51
52pub mod certificate;
53pub mod composites;
54pub mod connection;
55pub mod dns;
56pub mod firewall;
57pub mod interface;
58pub mod monitor;
59pub mod prelude;
60pub mod route;
61
62// ── Re-exports: interface ────────────────────────────────────────────
63
64pub use interface::{Interface, InterfaceId, InterfaceType, IpAddr};
65
66// ── Re-exports: connection ───────────────────────────────────────────
67
68pub use connection::{Connection, ConnectionError, ConnectionState, FailureReason};
69
70// ── Re-exports: dns ──────────────────────────────────────────────────
71
72pub use dns::{DnsCacheStats, DnsRecord, DnsResolver};
73
74// ── Re-exports: firewall ─────────────────────────────────────────────
75
76pub use firewall::{
77 Firewall, FirewallRule, PacketDisposition, PortRange, Protocol, TrafficDirection,
78};
79
80/// Backward-compatible re-export.
81#[deprecated(note = "use PacketDisposition — F2 equivocation fix")]
82#[allow(
83 deprecated,
84 reason = "re-exporting our own deprecated type alias for backward compatibility"
85)]
86pub use firewall::Action;
87
88// ── Re-exports: route ────────────────────────────────────────────────
89
90pub use route::{Route, RoutingTable};
91
92// ── Re-exports: monitor ──────────────────────────────────────────────
93
94pub use monitor::{
95 ConnectionQuality, InterfaceMonitor, LatencySample, NetworkMonitor, TrafficCounters,
96};
97
98// ── Re-exports: certificate ──────────────────────────────────────────
99
100pub use certificate::{CertFingerprint, CertStatus, CertStore, Certificate, TrustLevel};