4 #include <nexus/error_code.hpp>
5 #include <nexus/quic/stream_id.hpp>
9 namespace nexus::quic::detail {
11 struct connection_impl;
14 struct stream_header_read_operation;
15 struct stream_header_write_operation;
16 struct stream_data_operation;
17 struct stream_accept_operation;
18 struct stream_connect_operation;
19 struct stream_close_operation;
23 namespace sending_stream_state {
25 using header_operation = stream_header_write_operation;
26 using data_operation = stream_data_operation;
28 struct expecting_header {};
30 header_operation* op =
nullptr;
32 struct expecting_body {};
34 data_operation* op =
nullptr;
38 using variant = std::variant<expecting_header, header,
43 void write_header(variant& state, lsquic_stream* handle, header_operation& op);
44 void write_body(variant& state, lsquic_stream* handle, data_operation& op);
45 void on_write_header(variant& state, lsquic_stream* handle);
46 void on_write_body(variant& state, lsquic_stream* handle);
47 void on_write(variant& state, lsquic_stream* handle);
48 int cancel(variant& state, error_code ec);
49 void destroy(variant& state);
55 namespace receiving_stream_state {
57 using header_operation = stream_header_read_operation;
58 using data_operation = stream_data_operation;
60 struct expecting_header {};
62 header_operation* op =
nullptr;
64 struct expecting_body {};
66 data_operation* op =
nullptr;
70 using variant = std::variant<expecting_header, header,
75 void read_header(variant& state, lsquic_stream* handle, header_operation* op);
76 void read_body(variant& state, lsquic_stream* handle, data_operation* op);
77 void on_read_header(variant& state, error_code ec);
78 void on_read_body(variant& state, error_code ec);
79 void on_read(variant& state, lsquic_stream* handle);
80 int cancel(variant& state, error_code ec);
81 void destroy(variant& state);
86 namespace stream_state {
91 stream_accept_operation* op =
nullptr;
97 stream_connect_operation* op =
nullptr;
102 lsquic_stream& handle;
104 receiving_stream_state::variant in;
105 sending_stream_state::variant out;
108 open(lsquic_stream& handle, quic_tag) noexcept
110 in(receiving_stream_state::expecting_body{}),
111 out(sending_stream_state::expecting_body{})
115 open(lsquic_stream& handle, h3_tag) noexcept
117 in(receiving_stream_state::expecting_header{}),
118 out(sending_stream_state::expecting_header{})
125 stream_close_operation* op =
nullptr;
137 using variant = std::variant<accepting, connecting, open,
138 closing,
error, closed>;
141 enum class transition {
144 connecting_to_closed,
153 bool is_open(
const variant& state);
154 stream_id id(
const variant& state, error_code& ec);
157 void connect(variant& state, stream_connect_operation& op);
158 void on_connect(variant& state, lsquic_stream* handle,
bool is_http);
160 void accept(variant& state, stream_accept_operation& op);
161 void on_accept(variant& state, lsquic_stream* handle,
bool is_http);
163 bool read(variant& state, stream_data_operation& op);
164 bool read_headers(variant& state, stream_header_read_operation& op);
165 void on_read(variant& state);
167 bool write(variant& state, stream_data_operation& op);
168 bool write_headers(variant& state, stream_header_write_operation& op);
169 void on_write(variant& state);
171 void flush(variant& state, error_code& ec);
172 void shutdown(variant& state,
int how, error_code& ec);
173 int cancel(variant& state, error_code ec);
175 transition close(variant& state, stream_close_operation& op);
176 transition on_close(variant& state);
177 transition on_error(variant& state, error_code ec);
178 transition reset(variant& state);
180 void destroy(variant& state);
error
global error codes
Definition: error.hpp:11
uint64_t stream_id
stream identifier that is unique to a connection
Definition: stream_id.hpp:8