three_word_networking/
lib.rs

1//! Three-Word Networking
2//!
3//! Convert network IP addresses into memorable word combinations
4//! for human-friendly networking.
5//!
6//! ## Features
7//!
8//! - **Perfect IPv4**: Converts IPv4 addresses like `192.168.1.1:443`
9//!   into exactly 3 memorable words like `lehr.delfs.enrages` with 100% perfect reconstruction
10//! - **Adaptive IPv6**: Converts IPv6 addresses into 6 or 9 words (groups of 3) using intelligent compression
11//! - **Voice-Friendly**: Easy to share over phone calls or voice chat
12//! - **Error-Resistant**: Much less prone to typos than long technical addresses
13//! - **Deterministic**: Same IP address always produces the same word combination
14//! - **Visual Distinction**: IPv4 uses dots, IPv6 uses dashes for clear differentiation
15//! - **Universal**: Works with any valid IP address format
16//!
17//! ## Example
18//!
19//! ```rust
20//! use three_word_networking::ThreeWordAdaptiveEncoder;
21//!
22//! let encoder = ThreeWordAdaptiveEncoder::new()?;
23//! let address = "192.168.1.1:443";
24//!
25//! // Convert to three words (perfect reconstruction for IPv4)
26//! let words = encoder.encode(address)?;
27//! println!("Address: {} -> {}", address, words);
28//! // Output: Address: 192.168.1.1:443 -> lehr.delfs.enrages
29//!
30//! // Decode back to exact address
31//! let decoded = encoder.decode(&words)?;
32//! assert_eq!(address, decoded);
33//! # Ok::<(), Box<dyn std::error::Error>>(())
34//! ```
35
36pub mod compression;
37pub mod dictionary65k;
38pub mod error;
39pub mod three_word_encoder;
40pub mod three_word_ipv6_encoder;
41pub mod unified_three_word_encoder;
42// Experimental modules removed
43pub mod ipv6_compression;
44pub mod ipv6_pattern_feistel;
45pub mod ipv6_perfect_patterns;
46pub mod pure_ip_compression;
47pub mod three_word_adaptive_encoder;
48// Ultra modules removed - used outdated 3-word system
49pub mod universal_ip_compression;
50
51#[cfg(test)]
52mod property_tests;
53
54pub use error::{FourWordError, Result};
55// Experimental modules removed - use FourWordAdaptiveEncoder instead
56pub use ipv6_compression::{CompressedIpv6, Ipv6Category, Ipv6Compressor};
57pub use ipv6_pattern_feistel::{IPv6PatternFeistel, IPv6PatternId};
58pub use ipv6_perfect_patterns::{IPv6Pattern, IPv6PatternDetector};
59pub use pure_ip_compression::{MathematicalCompressor, PureIpCompressor};
60pub use three_word_adaptive_encoder::ThreeWordAdaptiveEncoder;
61// UltraCompactEncoder removed - used outdated 3-word system
62pub use three_word_encoder::{ThreeWordEncoder, ThreeWordEncoding};
63pub use three_word_ipv6_encoder::{
64    Ipv6ThreeWordGroupEncoding, ThreeWordGroup, ThreeWordIpv6Encoder,
65};
66pub use unified_three_word_encoder::{UnifiedThreeWordEncoder, UnifiedThreeWordEncoding};
67pub use universal_ip_compression::UniversalIpCompressor;
68
69/// Version of the three-word networking library
70pub const VERSION: &str = env!("CARGO_PKG_VERSION");
71
72#[cfg(test)]
73mod tests {
74    use super::*;
75
76    #[test]
77    fn test_basic_functionality() {
78        let encoder = ThreeWordAdaptiveEncoder::new().unwrap();
79        let address = "192.168.1.1:443";
80
81        let words = encoder.encode(address).unwrap();
82        let decoded = encoder.decode(&words).unwrap();
83        assert_eq!(address, decoded);
84    }
85}