mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
udp: consistently use NonZeroU16 for announce request port
This commit is contained in:
parent
b4e27903dc
commit
3513b714b4
8 changed files with 18 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::fmt::Debug;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::num::NonZeroU16;
|
||||
|
||||
pub use aquatic_peer_id::{PeerClient, PeerId};
|
||||
use zerocopy::network_endian::{I32, I64, U16, U32};
|
||||
|
|
@ -76,8 +77,8 @@ impl NumberOfDownloads {
|
|||
pub struct Port(pub U16);
|
||||
|
||||
impl Port {
|
||||
pub fn new(v: u16) -> Self {
|
||||
Self(U16::new(v))
|
||||
pub fn new(v: NonZeroU16) -> Self {
|
||||
Self(U16::new(v.into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ impl RequestParseError {
|
|||
mod tests {
|
||||
use quickcheck::TestResult;
|
||||
use quickcheck_macros::quickcheck;
|
||||
use zerocopy::network_endian::{I32, I64, U16};
|
||||
use zerocopy::network_endian::{I32, I64};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ mod tests {
|
|||
ip_address: Ipv4AddrBytes::arbitrary(g),
|
||||
key: PeerKey::new(i32::arbitrary(g)),
|
||||
peers_wanted: NumberOfPeers(I32::new(i32::arbitrary(g))),
|
||||
port: Port(U16::new(u16::arbitrary(g))),
|
||||
port: Port::new(quickcheck::Arbitrary::arbitrary(g)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue