pub struct Publish { /* private fields */ }Expand description
Port publishing configuration for container networking.
Specifies how container ports are exposed to the host system.
The format follows Docker’s --publish flag: [[ip:][hostPort]:]containerPort[/protocol]
Implementations§
Source§impl Publish
impl Publish
Sourcepub fn tcp(container_port: u16) -> Self
pub fn tcp(container_port: u16) -> Self
Creates a TCP port publish configuration.
§Example
let publish = ociman::Publish::tcp(8080);
assert_eq!(publish.to_string(), "8080/tcp");Sourcepub fn udp(container_port: u16) -> Self
pub fn udp(container_port: u16) -> Self
Creates a UDP port publish configuration.
§Example
let publish = ociman::Publish::udp(53);
assert_eq!(publish.to_string(), "53/udp");Sourcepub fn host_ip(self, ip: IpAddr) -> Self
pub fn host_ip(self, ip: IpAddr) -> Self
Sets the host IP address to bind to.
§Examples
let publish = ociman::Publish::tcp(8080)
.host_ip(std::net::Ipv4Addr::LOCALHOST.into());
assert_eq!(publish.to_string(), "127.0.0.1::8080/tcp");With unspecified address:
let publish = ociman::Publish::tcp(5432)
.host_ip(std::net::Ipv4Addr::UNSPECIFIED.into());
assert_eq!(publish.to_string(), "0.0.0.0::5432/tcp");With IPv6:
let publish = ociman::Publish::tcp(8080)
.host_ip(std::net::Ipv6Addr::LOCALHOST.into());
assert_eq!(publish.to_string(), "::1::8080/tcp");Preserves previously set host port:
let publish = ociman::Publish::tcp(80)
.host_port(8080)
.host_ip(std::net::Ipv4Addr::LOCALHOST.into());
assert_eq!(publish.to_string(), "127.0.0.1:8080:80/tcp");Sourcepub fn host_port(self, port: u16) -> Self
pub fn host_port(self, port: u16) -> Self
Sets the host port to map to the container port.
If no host IP has been set, defaults to 0.0.0.0.
§Examples
let publish = ociman::Publish::tcp(80).host_port(8080);
assert_eq!(publish.to_string(), "0.0.0.0:8080:80/tcp");Preserves previously set host IP:
let publish = ociman::Publish::tcp(80)
.host_ip(std::net::Ipv4Addr::LOCALHOST.into())
.host_port(8080);
assert_eq!(publish.to_string(), "127.0.0.1:8080:80/tcp");Sourcepub fn host_ip_port(self, ip: IpAddr, port: u16) -> Self
pub fn host_ip_port(self, ip: IpAddr, port: u16) -> Self
Sets both host IP and port in a single call.
§Example
let publish = ociman::Publish::tcp(80)
.host_ip_port(std::net::Ipv4Addr::LOCALHOST.into(), 8080);
assert_eq!(publish.to_string(), "127.0.0.1:8080:80/tcp");Trait Implementations§
impl Eq for Publish
impl StructuralPartialEq for Publish
Auto Trait Implementations§
impl Freeze for Publish
impl RefUnwindSafe for Publish
impl Send for Publish
impl Sync for Publish
impl Unpin for Publish
impl UnwindSafe for Publish
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§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.