Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privatize TransportParameters::default() #1627

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions quinn-proto/src/connection/streams/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ mod tests {
initial_max_streams_uni: 1u32.into(),
initial_max_data: 42u32.into(),
initial_max_stream_data_uni: 42u32.into(),
..Default::default()
..TransportParameters::default()
});

let (mut pending, state) = (Retransmits::default(), ConnState::Established);
Expand Down Expand Up @@ -1227,7 +1227,7 @@ mod tests {
initial_max_streams_bidi: 3u32.into(),
initial_max_data: 10u32.into(),
initial_max_stream_data_bidi_remote: 10u32.into(),
..Default::default()
..TransportParameters::default()
});

let (mut pending, state) = (Retransmits::default(), ConnState::Established);
Expand Down Expand Up @@ -1283,7 +1283,7 @@ mod tests {
initial_max_streams_bidi: 3u32.into(),
initial_max_data: 1000u32.into(),
initial_max_stream_data_bidi_remote: 1000u32.into(),
..Default::default()
..TransportParameters::default()
});

let (mut pending, state) = (Retransmits::default(), ConnState::Established);
Expand Down Expand Up @@ -1377,7 +1377,7 @@ mod tests {
initial_max_streams_uni: 1u32.into(),
initial_max_data: 42u32.into(),
initial_max_stream_data_uni: 42u32.into(),
..Default::default()
..TransportParameters::default()
});
let (mut pending, state) = (Retransmits::default(), ConnState::Established);
let mut streams = Streams {
Expand Down
11 changes: 7 additions & 4 deletions quinn-proto/src/transport_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ macro_rules! make_struct {
pub(crate) preferred_address: Option<PreferredAddress>,
}

impl Default for TransportParameters {
// We deliberately don't implement the `Default` trait, since that would be public, and
// downstream crates should never construct `TransportParameters` except by decoding those
// supplied by a peer.
impl TransportParameters {
/// Standard defaults, used if the peer does not supply a given parameter.
fn default() -> Self {
pub(crate) fn default() -> Self {
Self {
$($name: VarInt::from_u32($default),)*

Expand Down Expand Up @@ -528,11 +531,11 @@ mod test {
fn resumption_params_validation() {
let high_limit = TransportParameters {
initial_max_streams_uni: 32u32.into(),
..Default::default()
..TransportParameters::default()
};
let low_limit = TransportParameters {
initial_max_streams_uni: 16u32.into(),
..Default::default()
..TransportParameters::default()
};
high_limit.validate_resumption_from(&low_limit).unwrap();
low_limit.validate_resumption_from(&high_limit).unwrap_err();
Expand Down