Skip to content

Commit 98e2c26

Browse files
djcRalith
authored andcommitted
proto: use new constructor where possible
1 parent a1bdfd6 commit 98e2c26

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,15 +2598,12 @@ impl Connection {
25982598

25992599
if self.side.is_client() {
26002600
// Client-only because server params were set from the client's Initial
2601-
let params =
2602-
self.crypto
2603-
.transport_parameters()?
2604-
.ok_or_else(|| TransportError {
2605-
code: TransportErrorCode::crypto(0x6d),
2606-
frame: None,
2607-
reason: "transport parameters missing".into(),
2608-
crypto: None,
2609-
})?;
2601+
let params = self.crypto.transport_parameters()?.ok_or_else(|| {
2602+
TransportError::new(
2603+
TransportErrorCode::crypto(0x6d),
2604+
"transport parameters missing".to_owned(),
2605+
)
2606+
})?;
26102607

26112608
if self.has_0rtt() {
26122609
if !self.crypto.early_data_accepted().unwrap() {
@@ -2674,15 +2671,12 @@ impl Connection {
26742671
&& starting_space == SpaceId::Initial
26752672
&& self.highest_space != SpaceId::Initial
26762673
{
2677-
let params =
2678-
self.crypto
2679-
.transport_parameters()?
2680-
.ok_or_else(|| TransportError {
2681-
code: TransportErrorCode::crypto(0x6d),
2682-
frame: None,
2683-
reason: "transport parameters missing".into(),
2684-
crypto: None,
2685-
})?;
2674+
let params = self.crypto.transport_parameters()?.ok_or_else(|| {
2675+
TransportError::new(
2676+
TransportErrorCode::crypto(0x6d),
2677+
"transport parameters missing".to_owned(),
2678+
)
2679+
})?;
26862680
self.handle_peer_params(params)?;
26872681
self.issue_first_cids(now);
26882682
self.init_0rtt();

quinn-proto/src/transport_error.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,7 @@ macro_rules! errors {
103103
impl Error {
104104
$(
105105
pub(crate) fn $name<T>(reason: T) -> Self where T: Into<String> {
106-
Self {
107-
code: Code::$name,
108-
frame: None,
109-
reason: reason.into(),
110-
crypto: None,
111-
}
106+
Self::new(Code::$name, reason.into())
112107
}
113108
)*
114109
}

0 commit comments

Comments
 (0)