MCPcopy Index your code
hub / github.com/RustPython/RustPython / if_indextoname

Function if_indextoname

crates/stdlib/src/socket.rs:3098–3109  ·  view source on GitHub ↗
(index: IfIndex, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3096 #[cfg(not(target_os = "redox"))]
3097 #[pyfunction]
3098 fn if_indextoname(index: IfIndex, vm: &VirtualMachine) -> PyResult<String> {
3099 let mut buf = [0; c::IF_NAMESIZE + 1];
3100 // in case 'if_indextoname' does not set errno
3101 crate::common::os::set_errno(libc::ENXIO);
3102 let ret = unsafe { c::if_indextoname(index, buf.as_mut_ptr()) };
3103 if ret.is_null() {
3104 Err(vm.new_last_errno_error())
3105 } else {
3106 let buf = unsafe { ffi::CStr::from_ptr(buf.as_ptr() as _) };
3107 Ok(buf.to_string_lossy().into_owned())
3108 }
3109 }
3110
3111 #[cfg(any(
3112 windows,

Callers 1

get_addr_tupleFunction · 0.85

Calls 7

as_mut_ptrMethod · 0.80
new_last_errno_errorMethod · 0.80
into_ownedMethod · 0.80
set_errnoFunction · 0.50
ErrClass · 0.50
as_ptrMethod · 0.45
to_string_lossyMethod · 0.45

Tested by

no test coverage detected