proto: use new constructor where possible

This commit is contained in:
Dirkjan Ochtman
2025-12-02 12:29:20 +01:00
committed by Benjamin Saunders
parent a1bdfd6113
commit 98e2c26325
2 changed files with 13 additions and 24 deletions
+12 -18
View File
@@ -2598,15 +2598,12 @@ impl Connection {
if self.side.is_client() {
// Client-only because server params were set from the client's Initial
let params =
self.crypto
.transport_parameters()?
.ok_or_else(|| TransportError {
code: TransportErrorCode::crypto(0x6d),
frame: None,
reason: "transport parameters missing".into(),
crypto: None,
})?;
let params = self.crypto.transport_parameters()?.ok_or_else(|| {
TransportError::new(
TransportErrorCode::crypto(0x6d),
"transport parameters missing".to_owned(),
)
})?;
if self.has_0rtt() {
if !self.crypto.early_data_accepted().unwrap() {
@@ -2674,15 +2671,12 @@ impl Connection {
&& starting_space == SpaceId::Initial
&& self.highest_space != SpaceId::Initial
{
let params =
self.crypto
.transport_parameters()?
.ok_or_else(|| TransportError {
code: TransportErrorCode::crypto(0x6d),
frame: None,
reason: "transport parameters missing".into(),
crypto: None,
})?;
let params = self.crypto.transport_parameters()?.ok_or_else(|| {
TransportError::new(
TransportErrorCode::crypto(0x6d),
"transport parameters missing".to_owned(),
)
})?;
self.handle_peer_params(params)?;
self.issue_first_cids(now);
self.init_0rtt();
+1 -6
View File
@@ -103,12 +103,7 @@ macro_rules! errors {
impl Error {
$(
pub(crate) fn $name<T>(reason: T) -> Self where T: Into<String> {
Self {
code: Code::$name,
frame: None,
reason: reason.into(),
crypto: None,
}
Self::new(Code::$name, reason.into())
}
)*
}