mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 10:43:25 +00:00
Use matches!() macro where appropriate
This commit is contained in:
committed by
Benjamin Saunders
parent
9d3942d272
commit
5bb0a32cd4
@@ -21,12 +21,12 @@ impl SettingId {
|
||||
const NONE: SettingId = SettingId(0);
|
||||
|
||||
fn is_supported(self) -> bool {
|
||||
match self {
|
||||
matches!(
|
||||
self,
|
||||
SettingId::MAX_HEADER_LIST_SIZE
|
||||
| SettingId::QPACK_MAX_TABLE_CAPACITY
|
||||
| SettingId::QPACK_MAX_BLOCKED_STREAMS => true,
|
||||
_ => false,
|
||||
}
|
||||
| SettingId::QPACK_MAX_TABLE_CAPACITY
|
||||
| SettingId::QPACK_MAX_BLOCKED_STREAMS
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -475,10 +475,7 @@ impl DynamicTable {
|
||||
}
|
||||
|
||||
fn is_tracked(&self, reference: usize) -> bool {
|
||||
match self.track_map.get(&reference) {
|
||||
Some(count) if *count > 0 => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.track_map.get(&reference), Some(count) if *count > 0)
|
||||
}
|
||||
|
||||
fn track_block(&mut self, stream_id: u64, refs: HashMap<usize, usize>) {
|
||||
|
||||
@@ -3079,34 +3079,19 @@ impl State {
|
||||
}
|
||||
|
||||
fn is_handshake(&self) -> bool {
|
||||
match *self {
|
||||
State::Handshake(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, State::Handshake(_))
|
||||
}
|
||||
|
||||
fn is_established(&self) -> bool {
|
||||
match *self {
|
||||
State::Established => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, State::Established)
|
||||
}
|
||||
|
||||
fn is_closed(&self) -> bool {
|
||||
match *self {
|
||||
State::Closed(_) => true,
|
||||
State::Draining => true,
|
||||
State::Drained => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, State::Closed(_) | State::Draining | State::Drained)
|
||||
}
|
||||
|
||||
fn is_drained(&self) -> bool {
|
||||
if let State::Drained = *self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(*self, State::Drained)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,18 +1035,12 @@ impl Recv {
|
||||
}
|
||||
|
||||
fn receiving_unknown_size(&self) -> bool {
|
||||
match self.state {
|
||||
RecvState::Recv { size: None } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.state, RecvState::Recv { size: None })
|
||||
}
|
||||
|
||||
/// No more data expected from peer
|
||||
fn is_finished(&self) -> bool {
|
||||
match self.state {
|
||||
RecvState::Recv { .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self.state, RecvState::Recv { .. })
|
||||
}
|
||||
|
||||
/// All data read by application
|
||||
|
||||
@@ -54,11 +54,7 @@ impl PartialDecode {
|
||||
}
|
||||
|
||||
pub(crate) fn has_long_header(&self) -> bool {
|
||||
use self::PlainHeader::*;
|
||||
match self.plain_header {
|
||||
Short { .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self.plain_header, PlainHeader::Short { .. })
|
||||
}
|
||||
|
||||
pub(crate) fn is_initial(&self) -> bool {
|
||||
@@ -343,10 +339,7 @@ impl Header {
|
||||
|
||||
/// Whether the packet is encrypted on the wire
|
||||
pub(crate) fn is_protected(&self) -> bool {
|
||||
match *self {
|
||||
Header::Retry { .. } | Header::VersionNegotiate { .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(*self, Header::Retry { .. } | Header::VersionNegotiate { .. })
|
||||
}
|
||||
|
||||
pub(crate) fn number(&self) -> Option<PacketNumber> {
|
||||
@@ -385,10 +378,7 @@ impl Header {
|
||||
}
|
||||
|
||||
pub(crate) fn is_short(&self) -> bool {
|
||||
match *self {
|
||||
Header::Short { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, Header::Short { .. })
|
||||
}
|
||||
|
||||
pub(crate) fn is_1rtt(&self) -> bool {
|
||||
@@ -396,13 +386,7 @@ impl Header {
|
||||
}
|
||||
|
||||
pub(crate) fn is_0rtt(&self) -> bool {
|
||||
match *self {
|
||||
Header::Long {
|
||||
ty: LongType::ZeroRtt,
|
||||
..
|
||||
} => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*self, Header::Long { ty: LongType::ZeroRtt, .. })
|
||||
}
|
||||
|
||||
pub(crate) fn dst_cid(&self) -> &ConnectionId {
|
||||
|
||||
Reference in New Issue
Block a user