1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! # Maestro
//! `maestro` is a unified, high-performance framework for creating, supervising, and managing
//! asynchronous network services in Rust.
//!
//! This library’s purpose is to simplify the creation, supervision, and coordination of network-based services.
//! It provides a structured, asynchronous foundation for managing TCP and UDP protocols, handling service lifecycles, and ensuring robust, scalable operation.
//! By abstracting complex networking patterns, it allows developers to focus on service logic while the library handles concurrency, fault tolerance, and graceful shutdown.
//!
//! # Example
//!
//! ```rust,no_run
//! use maestro_rs::{NetworkInterface, Result, Supervisor, TcpHandler, UdpHandler, async_trait};
//! use std::{net::SocketAddr, str::FromStr, sync::Arc};
//! use tokio::{io::{AsyncReadExt, AsyncWriteExt}, net::{TcpStream, UdpSocket}};
//! use tracing::{error, info};
//!
//! struct MyTcpService;
//!
//! #[async_trait]
//! impl TcpHandler for MyTcpService {
//! fn name(&self) -> &'static str {
//! "MyTcpService"
//! }
//!
//! fn port(&self) -> u16 {
//! 8080
//! }
//!
//! async fn on_connection(&self, mut stream: TcpStream, peer: &SocketAddr) {
//! unimplemented!()
//! }
//! }
//!
//! struct MyUdpService;
//!
//! #[async_trait]
//! impl UdpHandler for MyUdpService {
//! fn name(&self) -> &'static str {
//! "MyUdpService"
//! }
//!
//! fn port(&self) -> u16 {
//! 5353
//! }
//!
//! async fn on_packet(&self, data: &[u8], socket: Arc<UdpSocket>, peer: &SocketAddr) {
//! unimplemented!()
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! tracing_subscriber::fmt()
//! .with_max_level(tracing::Level::INFO)
//! .init();
//!
//! let iface = NetworkInterface::from_str("lo")?;
//! let mut supervisor = Supervisor::new(iface);
//!
//! supervisor.add(MyUdpService);
//! supervisor.add(MyTcpService);
//!
//! supervisor.run().await?;
//!
//! Ok(())
//! }
//! ```
pub use async_trait;
pub use ;
pub use ;
pub use ;
pub use ;