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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Composition seam between transports and parsers.
//!
//! [`WireStream`] is the trait `WsStream`/`HttpConnection` consume —
//! abstracts over plain TCP, TLS-wrapped TCP, and any user-provided
//! transport (via the `AsyncReadAdapter` types in `nexus-async-net`,
//! one per supported runtime).
//! [`ParserSink`] is the parser-side buffer; implemented by
//! [`FrameReader`](crate::ws::FrameReader) and the HTTP response
//! parser, plus any third-party parser that follows the
//! `spare`/`filled` discipline.
//!
//! The split lets implementations skip the `&mut [u8]` intermediate
//! that `AsyncRead`'s contract requires when a faster path is
//! available — notably, the nexus-async-rt TLS adapter copies bytes
//! from rustls's plaintext queue straight into the parser's spare
//! region (one memcpy instead of two per recv).
use io;
use Pin;
use ;
/// A bidirectional byte-level stream that fills a parser's buffer.
///
/// Abstracts over plain TCP, TLS-wrapped TCP, and any user-provided
/// transport (wrap in `nexus_async_net::AsyncReadAdapter` /
/// `NexusAsyncReadAdapter` for the latter, depending on backend).
///
/// Implementations may take advantage of zero-copy paths when
/// available — e.g. `MaybeTls`'s TLS variant feeds plaintext directly
/// from rustls's queue into the parser's buffer, skipping the
/// intermediate `&mut [u8]` copy that `AsyncRead`'s contract requires.
/// Parser-side buffer that a [`WireStream`] fills.
///
/// Implementations expose a writable spare region via [`spare()`](Self::spare)
/// and commit the bytes via [`filled(n)`](Self::filled). This is the
/// same shape as `nexus_net::buf::ReadBuf` — any parser already using
/// that pattern can implement `ParserSink` in two methods.