network_protocol/lib.rs
1//! # Network Protocol
2//! This file is part of the Network Protocol project.
3//!
4//! It provides the main entry point for the protocol layer,
5//! including the core components, transport mechanisms,
6//! and utility functions.
7//!
8//! The protocol is designed to be modular, high-performance,
9//! and suitable for local, remote, and cluster communication.
10//!
11//! The main components include:
12//! - Core: packet handling, codec, error management
13//! - Transport: network communication, remote operations
14//! - Protocol: message routing, handshake logic
15//! - Service: client and daemon abstractions
16//! - Utils: cryptography, compression, time management
17//!
18//! The protocol layer is built with a focus on performance,
19//! scalability, and ease of integration with other systems.
20pub mod config;
21pub mod core;
22pub mod error;
23
24pub mod protocol; // message + handshake routing
25pub mod service; // client/daemon abstraction
26pub mod transport; // will add files shortly
27pub mod utils; // crypto/compression/time/etc
28
29pub use config::*;
30pub use core::codec::PacketCodec;
31pub use core::packet::Packet;
32pub use core::serialization::{MultiFormat, SerializationFormat};
33pub use error::*;
34pub use transport::session_cache::SessionCache;
35pub use utils::ReplayCache;
36
37/// Initialize the library with default logging configuration.
38/// This should be called early in your application setup.
39pub fn init() {
40 utils::logging::setup_default_logging();
41}
42
43/// Initialize the library with custom logging configuration.
44///
45/// # Example
46/// ```
47/// use network_protocol::{init_with_config, utils::logging::LogConfig};
48/// use tracing::Level;
49///
50/// let config = LogConfig {
51/// app_name: "my-application".to_string(),
52/// log_level: Level::DEBUG,
53/// ..Default::default()
54/// };
55///
56/// init_with_config(&config);
57/// ```
58pub fn init_with_config(log_config: &utils::logging::LogConfig) {
59 utils::logging::init_logging(log_config);
60}