Debian Codegraph @

third_party/rust/neqo-http3/src/qlog.rs

raw
1 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4 // option. This file may not be copied, modified, or distributed
5 // except according to those terms.
6
7 // Functions that handle capturing QLOG traces.
8
9 use neqo_common::qlog::NeqoQlog;
10 use neqo_transport::StreamId;
11 use qlog::events::{DataRecipient, EventData};
12
13 /// Uses [`NeqoQlog::add_event_data_now`] instead of
14 /// [`NeqoQlog::add_event_data_with_instant`], given that `now` is not available
15 /// on call-site. See docs on [`NeqoQlog::add_event_data_now`] for details.
16 pub fn h3_data_moved_up(qlog: &NeqoQlog, stream_id: StreamId, amount: usize) {
17 qlog.add_event_data_now(|| {
18 let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved {
19 stream_id: Some(stream_id.as_u64()),
20 offset: None,
21 length: Some(u64::try_from(amount).expect("usize fits in u64")),
22 from: Some(DataRecipient::Transport),
23 to: Some(DataRecipient::Application),
24 raw: None,
25 });
26
27 Some(ev_data)
28 });
29 }
30
31 /// Uses [`NeqoQlog::add_event_data_now`] instead of
32 /// [`NeqoQlog::add_event_data_with_instant`], given that `now` is not available
33 /// on call-site. See docs on [`NeqoQlog::add_event_data_now`] for details.
34 pub fn h3_data_moved_down(qlog: &NeqoQlog, stream_id: StreamId, amount: usize) {
35 qlog.add_event_data_now(|| {
36 let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved {
37 stream_id: Some(stream_id.as_u64()),
38 offset: None,
39 length: Some(u64::try_from(amount).expect("usize fits in u64")),
40 from: Some(DataRecipient::Application),
41 to: Some(DataRecipient::Transport),
42 raw: None,
43 });
44
45 Some(ev_data)
46 });
47 }