(
&self,
level: i32,
name: i32,
value: Option<Either<ArgBytesLike, i32>>,
optlen: OptionalArg<u32>,
vm: &VirtualMachine,
| 2300 | |
| 2301 | #[pymethod] |
| 2302 | fn setsockopt( |
| 2303 | &self, |
| 2304 | level: i32, |
| 2305 | name: i32, |
| 2306 | value: Option<Either<ArgBytesLike, i32>>, |
| 2307 | optlen: OptionalArg<u32>, |
| 2308 | vm: &VirtualMachine, |
| 2309 | ) -> Result<(), IoOrPyException> { |
| 2310 | let sock = self.sock()?; |
| 2311 | let fd = sock_fileno(&sock); |
| 2312 | let ret = match (value, optlen) { |
| 2313 | (Some(Either::A(b)), OptionalArg::Missing) => b.with_ref(|b| unsafe { |
| 2314 | c::setsockopt(fd as _, level, name, b.as_ptr() as *const _, b.len() as _) |
| 2315 | }), |
| 2316 | (Some(Either::B(ref val)), OptionalArg::Missing) => unsafe { |
| 2317 | c::setsockopt( |
| 2318 | fd as _, |
| 2319 | level, |
| 2320 | name, |
| 2321 | val as *const i32 as *const _, |
| 2322 | core::mem::size_of::<i32>() as _, |
| 2323 | ) |
| 2324 | }, |
| 2325 | (None, OptionalArg::Present(optlen)) => unsafe { |
| 2326 | c::setsockopt(fd as _, level, name, core::ptr::null(), optlen as _) |
| 2327 | }, |
| 2328 | _ => { |
| 2329 | return Err(vm |
| 2330 | .new_type_error("expected the value arg xor the optlen arg") |
| 2331 | .into()); |
| 2332 | } |
| 2333 | }; |
| 2334 | if ret < 0 { |
| 2335 | Err(crate::common::os::errno_io_error().into()) |
| 2336 | } else { |
| 2337 | Ok(()) |
| 2338 | } |
| 2339 | } |
| 2340 | |
| 2341 | #[pymethod] |
| 2342 | fn shutdown(&self, how: i32, vm: &VirtualMachine) -> Result<(), IoOrPyException> { |
nothing calls this directly
no test coverage detected