Skip to content

Commit

Permalink
Onwed Option
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Aug 6, 2024
1 parent 80108cb commit 4b55d0d
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ impl Connection {
let pt = PacketType::from(cspace);
let mut builder = if pt == PacketType::Short {
qdebug!("Building Short dcid {:?}", path.remote_cid());
PacketBuilder::short(encoder, tx.key_phase(), &path.remote_cid())
PacketBuilder::short(encoder, tx.key_phase(), path.remote_cid())
} else {
qdebug!(
"Building {:?} dcid {:?} scid {:?}",
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/connection/tests/idle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fn idle_caching() {
let mut client = default_client();
let mut server = default_server();
let start = now();
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);

// Perform the first round trip, but drop the Initial from the server.
// The client then caches the Handshake packet.
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/fc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ mod test {
fc[StreamType::BiDi].add_retired(1);
fc[StreamType::BiDi].send_flowc_update();
// consume the frame
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut tokens = Vec::new();
fc[StreamType::BiDi].write_frames(&mut builder, &mut tokens, &mut FrameStats::default());
assert_eq!(tokens.len(), 1);
Expand Down
10 changes: 5 additions & 5 deletions neqo-transport/src/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl PacketBuilder {
///
/// If, after calling this method, `remaining()` returns 0, then call `abort()` to get
/// the encoder back.
pub fn short(mut encoder: Encoder, key_phase: bool, dcid: &Option<impl AsRef<[u8]>>) -> Self {
pub fn short(mut encoder: Encoder, key_phase: bool, dcid: Option<impl AsRef<[u8]>>) -> Self {
let mut limit = Self::infer_limit(&encoder);
let header_start = encoder.len();
// Check that there is enough space for the header.
Expand Down Expand Up @@ -1065,7 +1065,7 @@ mod tests {
fn build_short() {
fixture_init();
let mut builder =
PacketBuilder::short(Encoder::new(), true, &Some(ConnectionId::from(SERVER_CID)));
PacketBuilder::short(Encoder::new(), true, Some(ConnectionId::from(SERVER_CID)));
builder.pn(0, 1);
builder.encode(SAMPLE_SHORT_PAYLOAD); // Enough payload for sampling.
let packet = builder
Expand All @@ -1080,7 +1080,7 @@ mod tests {
let mut firsts = Vec::new();
for _ in 0..64 {
let mut builder =
PacketBuilder::short(Encoder::new(), true, &Some(ConnectionId::from(SERVER_CID)));
PacketBuilder::short(Encoder::new(), true, Some(ConnectionId::from(SERVER_CID)));
builder.scramble(true);
builder.pn(0, 1);
firsts.push(builder.as_ref()[0]);
Expand Down Expand Up @@ -1153,7 +1153,7 @@ mod tests {
let first = encoder.clone();

let mut builder =
PacketBuilder::short(encoder, false, &Some(ConnectionId::from(SERVER_CID)));
PacketBuilder::short(encoder, false, Some(ConnectionId::from(SERVER_CID)));
builder.pn(1, 3);
builder.encode(&[0]); // Minimal size (packet number is big enough).
let encoder = builder.build(&mut prot).expect("build");
Expand Down Expand Up @@ -1237,7 +1237,7 @@ mod tests {
let mut builder = PacketBuilder::short(
Encoder::with_capacity(100),
true,
&Some(ConnectionId::from(SERVER_CID)),
Some(ConnectionId::from(SERVER_CID)),
);
builder.pn(0, 1);
// Pad, but not up to the full capacity. Leave enough space for the
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/pmtud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod tests {
let stats_before = stats.clone();

// Fake a packet number, so the builder logic works.
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let pn = prot.next_pn();
builder.pn(pn, 4);
builder.set_initial_limit(&SendProfile::new_limited(pmtud.plpmtu()), 16, pmtud);
Expand Down
8 changes: 4 additions & 4 deletions neqo-transport/src/recv_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ mod tests {
assert!(s.has_frames_to_write());

// consume it
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut token = Vec::new();
s.write_frame(&mut builder, &mut token, &mut FrameStats::default());

Expand Down Expand Up @@ -1597,7 +1597,7 @@ mod tests {
s.read(&mut buf).unwrap();
assert!(session_fc.borrow().frame_needed());
// consume it
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut token = Vec::new();
session_fc
.borrow_mut()
Expand All @@ -1618,7 +1618,7 @@ mod tests {
s.read(&mut buf).unwrap();
assert!(session_fc.borrow().frame_needed());
// consume it
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut token = Vec::new();
session_fc
.borrow_mut()
Expand Down Expand Up @@ -1866,7 +1866,7 @@ mod tests {
assert!(s.fc().unwrap().frame_needed());

// Write the fc update frame
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut token = Vec::new();
let mut stats = FrameStats::default();
fc.borrow_mut()
Expand Down
14 changes: 7 additions & 7 deletions neqo-transport/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,7 @@ mod tests {
ss.insert(StreamId::from(0), s);

let mut tokens = Vec::new();
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);

// Write a small frame: no fin.
let written = builder.len();
Expand Down Expand Up @@ -2684,7 +2684,7 @@ mod tests {
ss.insert(StreamId::from(0), s);

let mut tokens = Vec::new();
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
ss.write_frames(
TransmissionPriority::default(),
&mut builder,
Expand Down Expand Up @@ -2762,7 +2762,7 @@ mod tests {
assert_eq!(s.next_bytes(false), Some((0, &b"ab"[..])));

// This doesn't report blocking yet.
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut tokens = Vec::new();
let mut stats = FrameStats::default();
s.write_blocked_frame(
Expand Down Expand Up @@ -2815,7 +2815,7 @@ mod tests {
assert_eq!(s.send_atomic(b"abc").unwrap(), 0);

// Assert that STREAM_DATA_BLOCKED is sent.
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut tokens = Vec::new();
let mut stats = FrameStats::default();
s.write_blocked_frame(
Expand Down Expand Up @@ -2902,7 +2902,7 @@ mod tests {
s.mark_as_lost(len_u64, 0, true);

// No frame should be sent here.
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut tokens = Vec::new();
let mut stats = FrameStats::default();
s.write_stream_frame(
Expand Down Expand Up @@ -2962,7 +2962,7 @@ mod tests {
s.close();
}

let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let header_len = builder.len();
builder.set_limit(header_len + space);

Expand Down Expand Up @@ -3063,7 +3063,7 @@ mod tests {
s.send(data).unwrap();
s.close();

let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let header_len = builder.len();
// Add 2 for the frame type and stream ID, then add the extra.
builder.set_limit(header_len + data.len() + 2 + extra);
Expand Down
8 changes: 4 additions & 4 deletions neqo-transport/src/tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ mod tests {
}

fn write_frame_at(rp: &mut RecvdPackets, now: Instant) {
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
let mut stats = FrameStats::default();
let mut tokens = Vec::new();
rp.write_frame(now, RTT, &mut builder, &mut tokens, &mut stats);
Expand Down Expand Up @@ -952,7 +952,7 @@ mod tests {
#[test]
fn drop_spaces() {
let mut tracker = AckTracker::default();
let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
tracker
.get_mut(PacketNumberSpace::Initial)
.unwrap()
Expand Down Expand Up @@ -1017,7 +1017,7 @@ mod tests {
.ack_time(now().checked_sub(Duration::from_millis(1)).unwrap())
.is_some());

let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
builder.set_limit(10);

let mut stats = FrameStats::default();
Expand Down Expand Up @@ -1048,7 +1048,7 @@ mod tests {
.ack_time(now().checked_sub(Duration::from_millis(1)).unwrap())
.is_some());

let mut builder = PacketBuilder::short(Encoder::new(), false, &None::<&[u8]>);
let mut builder = PacketBuilder::short(Encoder::new(), false, None::<&[u8]>);
// The code pessimistically assumes that each range needs 16 bytes to express.
// So this won't be enough for a second range.
builder.set_limit(RecvdPackets::USEFUL_ACK_LEN + 8);
Expand Down

0 comments on commit 4b55d0d

Please sign in to comment.