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

Function getprotobyname

crates/stdlib/src/socket.rs:3002–3010  ·  view source on GitHub ↗
(name: PyStrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3000
3001 #[pyfunction]
3002 fn getprotobyname(name: PyStrRef, vm: &VirtualMachine) -> PyResult {
3003 let cstr = name.to_cstring(vm)?;
3004 let proto = unsafe { c::getprotobyname(cstr.as_ptr() as _) };
3005 if proto.is_null() {
3006 return Err(vm.new_os_error("protocol not found".to_owned()));
3007 }
3008 let num = unsafe { (*proto).p_proto };
3009 Ok(vm.ctx.new_int(num).into())
3010 }
3011
3012 #[pyfunction]
3013 fn getnameinfo(

Callers

nothing calls this directly

Calls 6

new_os_errorMethod · 0.80
ErrClass · 0.50
to_cstringMethod · 0.45
as_ptrMethod · 0.45
to_ownedMethod · 0.45
new_intMethod · 0.45

Tested by

no test coverage detected