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

Function inet_ntoa

crates/stdlib/src/socket.rs:2661–2666  ·  view source on GitHub ↗
(packed_ip: ArgBytesLike, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2659
2660 #[pyfunction]
2661 fn inet_ntoa(packed_ip: ArgBytesLike, vm: &VirtualMachine) -> PyResult<PyStrRef> {
2662 let packed_ip = packed_ip.borrow_buf();
2663 let packed_ip = <&[u8; 4]>::try_from(&*packed_ip)
2664 .map_err(|_| vm.new_os_error("packed IP wrong length for inet_ntoa".to_owned()))?;
2665 Ok(vm.ctx.new_str(Ipv4Addr::from(*packed_ip).to_string()))
2666 }
2667
2668 fn cstr_opt_as_ptr(x: &OptionalArg<ffi::CString>) -> *const libc::c_char {
2669 x.as_ref().map_or_else(core::ptr::null, |s| s.as_ptr())

Callers

nothing calls this directly

Calls 5

new_os_errorMethod · 0.80
to_stringMethod · 0.80
borrow_bufMethod · 0.45
to_ownedMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected