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

Method recv_into

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

Source from the content-addressed store, hash-verified

1662
1663 #[pymethod]
1664 fn recv_into(
1665 &self,
1666 buf: ArgMemoryBuffer,
1667 nbytes: OptionalArg<isize>,
1668 flags: OptionalArg<i32>,
1669 vm: &VirtualMachine,
1670 ) -> Result<usize, IoOrPyException> {
1671 let flags = flags.unwrap_or(0);
1672 let sock = self.sock()?;
1673 let mut buf = buf.borrow_buf_mut();
1674 let buf = &mut *buf;
1675
1676 // Handle nbytes parameter
1677 let read_len = if let OptionalArg::Present(nbytes) = nbytes {
1678 let nbytes = nbytes
1679 .to_usize()
1680 .ok_or_else(|| vm.new_value_error("negative buffersize in recv_into"))?;
1681 nbytes.min(buf.len())
1682 } else {
1683 buf.len()
1684 };
1685
1686 let buf = &mut buf[..read_len];
1687 self.sock_op(vm, SelectKind::Read, || {
1688 sock.recv_with_flags(unsafe { slice_as_uninit(buf) }, flags)
1689 })
1690 }
1691
1692 #[pymethod]
1693 fn recvfrom(

Callers

nothing calls this directly

Calls 8

slice_as_uninitFunction · 0.85
sockMethod · 0.80
ok_or_elseMethod · 0.80
sock_opMethod · 0.80
borrow_buf_mutMethod · 0.45
to_usizeMethod · 0.45
minMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected