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

Method recvfrom_into

crates/stdlib/src/socket.rs:1713–1739  ·  view source on GitHub ↗
(
            &self,
            buf: ArgMemoryBuffer,
            nbytes: OptionalArg<isize>,
            flags: OptionalArg<i32>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1711
1712 #[pymethod]
1713 fn recvfrom_into(
1714 &self,
1715 buf: ArgMemoryBuffer,
1716 nbytes: OptionalArg<isize>,
1717 flags: OptionalArg<i32>,
1718 vm: &VirtualMachine,
1719 ) -> Result<(usize, PyObjectRef), IoOrPyException> {
1720 let mut buf = buf.borrow_buf_mut();
1721 let buf = &mut *buf;
1722 let buf = match nbytes {
1723 OptionalArg::Present(i) => {
1724 let i = i.to_usize().ok_or_else(|| {
1725 vm.new_value_error("negative buffersize in recvfrom_into")
1726 })?;
1727 buf.get_mut(..i).ok_or_else(|| {
1728 vm.new_value_error("nbytes is greater than the length of the buffer")
1729 })?
1730 }
1731 OptionalArg::Missing => buf,
1732 };
1733 let flags = flags.unwrap_or(0);
1734 let sock = self.sock()?;
1735 let (n, addr) = self.sock_op(vm, SelectKind::Read, || {
1736 sock.recv_from_with_flags(unsafe { slice_as_uninit(buf) }, flags)
1737 })?;
1738 Ok((n, get_addr_tuple(&addr, vm)))
1739 }
1740
1741 #[pymethod]
1742 fn send(

Callers

nothing calls this directly

Calls 8

slice_as_uninitFunction · 0.85
get_addr_tupleFunction · 0.85
ok_or_elseMethod · 0.80
get_mutMethod · 0.80
sockMethod · 0.80
sock_opMethod · 0.80
borrow_buf_mutMethod · 0.45
to_usizeMethod · 0.45

Tested by

no test coverage detected