Struct rtnetlink::NetworkNamespace
source · pub struct NetworkNamespace();
Implementations§
source§impl NetworkNamespace
impl NetworkNamespace
sourcepub async fn add(ns_name: String) -> Result<(), Error>
pub async fn add(ns_name: String) -> Result<(), Error>
Add a new network namespace.
This is equivalent to ip netns add NS_NAME
.
sourcepub async fn del(ns_name: String) -> Result<(), Error>
pub async fn del(ns_name: String) -> Result<(), Error>
Remove a network namespace
This is equivalent to ip netns del NS_NAME
.
pub fn prep_for_fork() -> Result<(), Error>
sourcepub fn parent_process(child: Pid) -> Result<(), Error>
pub fn parent_process(child: Pid) -> Result<(), Error>
This is the parent process form the fork, it waits for the child to exit properly
sourcepub fn child_process_create_ns(ns_name: String) -> Result<String, Error>
pub fn child_process_create_ns(ns_name: String) -> Result<String, Error>
This is the child process, it will actually create the namespace resources. It creates the folder and namespace file. Returns the namespace file path
This function unshare the calling process and move into the given network namespace
Auto Trait Implementations§
impl Freeze for NetworkNamespace
impl RefUnwindSafe for NetworkNamespace
impl Send for NetworkNamespace
impl Sync for NetworkNamespace
impl Unpin for NetworkNamespace
impl UnwindSafe for NetworkNamespace
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