pub enum PortPair {
Distinct {
host: u16,
guest: u16,
},
Same(u16),
}Expand description
Represents a port mapping between host and guest systems, following Docker’s port mapping convention.
§Format
The port pair can be specified in two formats:
host:guest- Maps the host port to a different guest port (e.g., “8080:80”)portorport:port- Maps the same port number on both host and guest (e.g., “8080” or “8080:8080”)
§Examples
Creating port pairs:
use microsandbox_core::config::PortPair;
// Same port on host and guest (8080:8080)
let same_port = PortPair::with_same(8080);
// Different ports (host 8080 maps to guest 80)
let distinct_ports = PortPair::with_distinct(8080, 80);
// Parse from string
let from_str = "8080:80".parse::<PortPair>().unwrap();
assert_eq!(from_str, distinct_ports);Variants§
Distinct
The guest port and the host port are distinct.
Same(u16)
The guest port and the host port are the same.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PortPair
impl<'de> Deserialize<'de> for PortPair
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PortPair
impl StructuralPartialEq for PortPair
Auto Trait Implementations§
impl Freeze for PortPair
impl RefUnwindSafe for PortPair
impl Send for PortPair
impl Sync for PortPair
impl Unpin for PortPair
impl UnsafeUnpin for PortPair
impl UnwindSafe for PortPair
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more