pub struct NetNs<E: Env = DefaultEnv> { /* private fields */ }
Expand description
A network namespace type.
It could be used to enter network namespace.
Implementations§
Source§impl<E: Env> NetNs<E>
impl<E: Env> NetNs<E>
Sourcepub fn new_with_env<S: AsRef<str>>(ns_name: S, env: E) -> Result<Self>
pub fn new_with_env<S: AsRef<str>>(ns_name: S, env: E) -> Result<Self>
Creates a new NetNs
with the specified name and Env.
The persist dir of network namespace will be created if it doesn’t already exist.
Sourcepub fn enter(&self) -> Result<()>
pub fn enter(&self) -> Result<()>
Makes the current thread enter this network namespace.
Requires elevated privileges.
Sourcepub fn get_from_env<S: AsRef<str>>(ns_name: S, env: E) -> Result<Self>
pub fn get_from_env<S: AsRef<str>>(ns_name: S, env: E) -> Result<Self>
Returns the NetNs with the specified name and Env.
Source§impl NetNs
impl NetNs
Sourcepub fn new<S: AsRef<str>>(ns_name: S) -> Result<Self>
pub fn new<S: AsRef<str>>(ns_name: S) -> Result<Self>
Creates a new persistent (bind-mounted) network namespace and returns an object representing that namespace, without switching to it.
The persist directory of network namespace will be created if it doesn’t already exist.
This function will use DefaultEnv
to create persist directory.
Requires elevated privileges.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for NetNs<E>where
E: Freeze,
impl<E> RefUnwindSafe for NetNs<E>where
E: RefUnwindSafe,
impl<E> Send for NetNs<E>where
E: Send,
impl<E> Sync for NetNs<E>where
E: Sync,
impl<E> Unpin for NetNs<E>where
E: Unpin,
impl<E> UnwindSafe for NetNs<E>where
E: UnwindSafe,
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