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

Method share

crates/stdlib/src/socket.rs:2463–2484  ·  view source on GitHub ↗
(&self, process_id: u32, _vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2461 #[cfg(windows)]
2462 #[pymethod]
2463 fn share(&self, process_id: u32, _vm: &VirtualMachine) -> Result<Vec<u8>, IoOrPyException> {
2464 let sock = self.sock()?;
2465 let fd = sock_fileno(&sock);
2466
2467 let mut info: MaybeUninit<c::WSAPROTOCOL_INFOW> = MaybeUninit::uninit();
2468
2469 let ret = unsafe { c::WSADuplicateSocketW(fd as _, process_id, info.as_mut_ptr()) };
2470
2471 if ret == c::SOCKET_ERROR {
2472 return Err(Self::wsa_error().into());
2473 }
2474
2475 let info = unsafe { info.assume_init() };
2476 let bytes = unsafe {
2477 core::slice::from_raw_parts(
2478 &info as *const c::WSAPROTOCOL_INFOW as *const u8,
2479 core::mem::size_of::<c::WSAPROTOCOL_INFOW>(),
2480 )
2481 };
2482
2483 Ok(bytes.to_vec())
2484 }
2485
2486 #[pygetset(name = "type")]
2487 fn kind(&self) -> i32 {

Callers 5

testShareMethod · 0.80
testShareLengthMethod · 0.80
testShareLocalMethod · 0.80
testTypesMethod · 0.80
sendMethod · 0.80

Calls 5

sock_filenoFunction · 0.85
sockMethod · 0.80
as_mut_ptrMethod · 0.80
to_vecMethod · 0.80
ErrClass · 0.50

Tested by 4

testShareMethod · 0.64
testShareLengthMethod · 0.64
testShareLocalMethod · 0.64
testTypesMethod · 0.64