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
79
80
81
82
//! Tokio-native typed TCP/UDP pipeline framework inspired by Netty.
//!
//! `rs-netty` keeps the familiar channel, pipeline, and handler shape while
//! using Rust's type system to validate pipeline order and message transitions
//! at compile time.
//!
//! # Quick start
//!
//! ```no_run
//! use rs_netty::{codec::LineCodec, pipeline, Context, Handler, Result, TcpServer};
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! TcpServer::bind("127.0.0.1:9000")
//! .pipeline(|| pipeline().codec(LineCodec::new()).handler(Echo))
//! .run()
//! .await
//! }
//!
//! struct Echo;
//!
//! impl Handler<String> for Echo {
//! type Write = String;
//!
//! async fn read(&mut self, ctx: &mut Context<Self::Write>, msg: String) -> Result<()> {
//! ctx.write(msg).await
//! }
//! }
//! ```
//!
//! # Pipeline shape
//!
//! TCP pipelines are built with [`pipeline()`] and UDP pipelines are built with
//! [`datagram_pipeline()`]. The builder only exposes methods that are valid in
//! the current state, so invalid orderings such as adding a handler before a
//! codec fail to compile.
//!
//! A TCP pipeline has this shape:
//!
//! ```text
//! codec -> inbound* -> business* -> handler -> outbound*
//! ```
//!
//! A UDP pipeline has the same typed stage model, but processes whole datagrams
//! rather than a byte stream.
//!
//! # Write and flush semantics
//!
//! Writes issued through [`Context`] or [`DatagramContext`] are staged in the
//! current handler's outbox and are flushed when the handler returns, or earlier
//! when `flush`/`write_and_flush` is awaited.
//!
//! Writes issued through [`Channel`], [`TcpClientHandle`], [`DatagramChannel`],
//! or [`UdpClientHandle`] are sent through the connection/socket command queue.
//! The queue is bounded by the configured outbound queue size.
pub use ;
pub use ;
pub use ;
pub use ;
pub use pipeline;
pub use datagram_pipeline;
pub use ;
pub use ;
pub use TcpServer;
pub use ;
pub use UdpServer;