pub struct Port(/* private fields */);Expand description
TCP/UDP port number from 1 to 65535 inclusive.
Implementations§
Source§impl Port
impl Port
pub const MIN: u16 = 1
pub const MAX: u16 = 65535
Sourcepub fn new(value: u16) -> PrimitiveResult<Self>
pub fn new(value: u16) -> PrimitiveResult<Self>
Creates a new port.
Examples found in repository?
examples/primitives_basic.rs (line 9)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 type ServiceName = BoundedStr<3, 32>;
5
6 let display_name = NonEmptyStr::new("Reliakit API")?;
7 let service_name = ServiceName::new("api-service")?;
8 let threshold = Percent::new(95)?;
9 let port = Port::new(8080)?;
10 let body_limit = ByteSize::from_mb(10);
11
12 println!("display name: {display_name}");
13 println!("service name: {service_name}");
14 println!("threshold: {threshold}");
15 println!("port: {port}");
16 println!("body limit: {body_limit}");
17
18 Ok(())
19}Trait Implementations§
Source§impl Ord for Port
impl Ord for Port
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Port
impl PartialOrd for Port
impl Copy for Port
impl Eq for Port
impl StructuralPartialEq for Port
Auto Trait Implementations§
impl Freeze for Port
impl RefUnwindSafe for Port
impl Send for Port
impl Sync for Port
impl Unpin for Port
impl UnsafeUnpin for Port
impl UnwindSafe for Port
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more