Struct podman_api::api::Network
source · [−]pub struct Network<'podman> { /* private fields */ }
Expand description
Interface for accessing and manipulating Podman Network.
Implementations
sourceimpl<'podman> Network<'podman>
impl<'podman> Network<'podman>
sourcepub async fn delete(&self) -> Result<NetworkRmReport>
pub async fn delete(&self) -> Result<NetworkRmReport>
Delete this container. To delete this network forcefully use
Network::force_delete
.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.networks().get("some-network").delete().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn force_delete(&self) -> Result<NetworkRmReport>
pub async fn force_delete(&self) -> Result<NetworkRmReport>
Force remove this network removing associated containers. To delete network normally use
Network::delete
.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.networks().get("some-network").force_delete().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn exists(&self) -> Result<bool>
pub async fn exists(&self) -> Result<bool>
Quick way to determine if a network exists by name or id.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.networks().get("some-network").exists().await {
Ok(exists) => if exists {
println!("network exists!");
} else {
println!("network doesn't exists!");
},
Err(e) => eprintln!("check failed: {}", e),
}
};
sourcepub async fn inspect(&self) -> Result<NetworkConfigList>
pub async fn inspect(&self) -> Result<NetworkConfigList>
Display low level configuration for this CNI network.
Examples:
async {
use podman_api::Podman;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman.networks().get("some-network").inspect().await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn disconnect_container(
&self,
opts: &NetworkDisconnectOpts
) -> Result<()>
pub async fn disconnect_container(
&self,
opts: &NetworkDisconnectOpts
) -> Result<()>
Disconnect a container from this network.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::NetworkDisconnectOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.networks()
.get("some-network")
.disconnect_container(
&NetworkDisconnectOpts::builder()
.container("containerid")
.force(true)
.build()
)
.await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
sourcepub async fn connect_container(&self, opts: &NetworkConnectOpts) -> Result<()>
pub async fn connect_container(&self, opts: &NetworkConnectOpts) -> Result<()>
Connect a container to this network.
Examples:
async {
use podman_api::Podman;
use podman_api::opts::NetworkConnectOpts;
let podman = Podman::unix("/run/user/1000/podman/podman.sock");
match podman
.networks()
.get("some-network")
.connect_container(
&NetworkConnectOpts::builder()
.container("containerid")
.interface_name("eno128")
.build()
)
.await {
Ok(info) => println!("{:?}", info),
Err(e) => eprintln!("{}", e),
}
};
Trait Implementations
Auto Trait Implementations
impl<'podman> !RefUnwindSafe for Network<'podman>
impl<'podman> Send for Network<'podman>
impl<'podman> Sync for Network<'podman>
impl<'podman> Unpin for Network<'podman>
impl<'podman> !UnwindSafe for Network<'podman>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more