Skip to content

Commit 012f556

Browse files
committed
style: cargo fmt & clippy
1 parent d82cd4d commit 012f556

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

crates/wind-tuic/src/proto/v5/addr.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ impl Decoder for AddressCodec {
3535
type Item = Address;
3636

3737
fn decode(&mut self, src: &mut bytes::BytesMut) -> Result<Option<Self::Item>, Self::Error> {
38-
if src.len() < 1 {
38+
if src.is_empty() {
3939
return Ok(None);
4040
}
4141
let addr_type = AddressType::from(src.get_u8());
4242

4343
ensure!(!matches!(addr_type, AddressType::Other(..)), UnknownAddressTypeSnafu { value: u8::from(addr_type) });
4444
match addr_type {
45-
AddressType::None => {
46-
Ok(Some(Address::None))
47-
}
45+
AddressType::None => Ok(Some(Address::None)),
4846
AddressType::IPv4 => {
4947
if src.len() < 4 + 2 {
5048
return Ok(None);
@@ -66,7 +64,7 @@ impl Decoder for AddressCodec {
6664
Ok(Some(Address::IPv6(ip, port)))
6765
}
6866
AddressType::FQDN => {
69-
if src.len() < 1 {
67+
if src.is_empty() {
7068
return Ok(None);
7169
}
7270
let domain_len = src.get_u8() as usize;
@@ -80,6 +78,7 @@ impl Decoder for AddressCodec {
8078
raw: hex::encode(domain),
8179
})?
8280
.to_string();
81+
src.advance(domain_len);
8382
let port = src.get_u16();
8483
Ok(Some(Address::FQDN(domain, port)))
8584
}

crates/wind-tuic/src/proto/v5/cmd.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,27 @@ impl Encoder<Command> for CommandCodec {
8888
dst.reserve(16 + 32);
8989
dst.put_slice(uuid.as_bytes());
9090
dst.put_slice(&token);
91-
},
92-
Command::Connect => {},
93-
Command::Packet { assos_id, pkt_id, frag_total, frag_id, size } => {
91+
}
92+
Command::Connect => {}
93+
Command::Packet {
94+
assos_id,
95+
pkt_id,
96+
frag_total,
97+
frag_id,
98+
size,
99+
} => {
94100
dst.reserve(8);
95101
dst.put_u16(assos_id);
96102
dst.put_u16(pkt_id);
97103
dst.put_u8(frag_total);
98104
dst.put_u8(frag_id);
99105
dst.put_u16(size);
100-
},
106+
}
101107
Command::Dissociate { assos_id } => {
102108
dst.reserve(2);
103109
dst.put_u16(assos_id);
104-
},
105-
Command::Heartbeat => {},
110+
}
111+
Command::Heartbeat => {}
106112
}
107113
Ok(())
108114
}

0 commit comments

Comments
 (0)