(
&self,
bytes: ArgBytesLike,
arg2: PyObjectRef,
arg3: OptionalArg<PyObjectRef>,
vm: &VirtualMachine,
)
| 1784 | |
| 1785 | #[pymethod] |
| 1786 | fn sendto( |
| 1787 | &self, |
| 1788 | bytes: ArgBytesLike, |
| 1789 | arg2: PyObjectRef, |
| 1790 | arg3: OptionalArg<PyObjectRef>, |
| 1791 | vm: &VirtualMachine, |
| 1792 | ) -> Result<usize, IoOrPyException> { |
| 1793 | // signature is bytes[, flags], address |
| 1794 | let (flags, address) = match arg3 { |
| 1795 | OptionalArg::Present(arg3) => { |
| 1796 | // should just be i32::try_from_obj but tests check for error message |
| 1797 | let int = arg2 |
| 1798 | .try_index_opt(vm) |
| 1799 | .unwrap_or_else(|| Err(vm.new_type_error("an integer is required")))?; |
| 1800 | let flags = int.try_to_primitive::<i32>(vm)?; |
| 1801 | (flags, arg3) |
| 1802 | } |
| 1803 | OptionalArg::Missing => (0, arg2), |
| 1804 | }; |
| 1805 | let addr = self.extract_address(address, "sendto", vm)?; |
| 1806 | let buf = bytes.borrow_buf(); |
| 1807 | let buf = &*buf; |
| 1808 | self.sock_op(vm, SelectKind::Write, || { |
| 1809 | self.sock()?.send_to_with_flags(buf, &addr, flags) |
| 1810 | }) |
| 1811 | } |
| 1812 | |
| 1813 | #[cfg(all(unix, not(target_os = "redox")))] |
| 1814 | #[pymethod] |
nothing calls this directly
no test coverage detected