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 error;
22
23pub mod core {
24 pub mod codec;
25 pub mod packet;
26}
27
28pub mod transport; // will add files shortly
29pub mod protocol; // message + handshake routing
30pub mod service; // client/daemon abstraction
31pub mod utils; // crypto/compression/time/etc
32
33pub use config::*;
34pub use error::*;
35pub use core::packet::Packet;
36pub use core::codec::PacketCodec;
37
38/// Initialize the library with default logging configuration.
39/// This should be called early in your application setup.
40pub fn init() {
41 utils::logging::setup_default_logging();
42}
43
44/// Initialize the library with custom logging configuration.
45///
46/// # Example
47/// ```
48/// use network_protocol::{init_with_config, utils::logging::LogConfig};
49/// use tracing::Level;
50///
51/// let config = LogConfig {
52/// app_name: "my-application".to_string(),
53/// log_level: Level::DEBUG,
54/// ..Default::default()
55/// };
56///
57/// init_with_config(&config);
58/// ```
59pub fn init_with_config(log_config: &utils::logging::LogConfig) {
60 utils::logging::init_logging(log_config);
61}