pub struct IfName { /* private fields */ }Implementations§
Source§impl IfName
impl IfName
Sourcepub fn new<From: Into<Vec<u8>>>(name: From) -> Result<Self>
pub fn new<From: Into<Vec<u8>>>(name: From) -> Result<Self>
Examples found in repository?
examples/if_nametoindex.rs (line 10)
3fn main() {
4 let args = std::env::args().collect::<Vec<_>>();
5 if args.len() < 2 {
6 println!("Usage: {} <if_index>", &args[0]);
7 std::process::exit(1);
8 }
9
10 let name = match IfName::new(args[1].clone()) {
11 Ok(n) => n,
12 _ => {
13 eprintln!("{}: Invalid interface name", &args[0]);
14 std::process::exit(1);
15 }
16 };
17
18 match name_to_index(name) {
19 Ok(id) => {
20 println!("{}", id);
21 },
22 _ => {
23 eprintln!("{}: No such interface", args[0]);
24 std::process::exit(2);
25 }
26 }
27}pub fn from_c_str(name: &CStr) -> Result<Self>
pub fn as_c_str<'a>(&'a self) -> &'a CStr
Trait Implementations§
impl Copy for IfName
impl Eq for IfName
impl StructuralPartialEq for IfName
Auto Trait Implementations§
impl Freeze for IfName
impl RefUnwindSafe for IfName
impl Send for IfName
impl Sync for IfName
impl Unpin for IfName
impl UnsafeUnpin for IfName
impl UnwindSafe for IfName
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