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

Method GetOverlappedResult

crates/vm/src/stdlib/_winapi.rs:926–972  ·  view source on GitHub ↗
(&self, wait: bool, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

924
925 #[pymethod]
926 fn GetOverlappedResult(&self, wait: bool, vm: &VirtualMachine) -> PyResult<(u32, u32)> {
927 use windows_sys::Win32::Foundation::{
928 ERROR_IO_INCOMPLETE, ERROR_MORE_DATA, ERROR_OPERATION_ABORTED, ERROR_SUCCESS,
929 GetLastError,
930 };
931 use windows_sys::Win32::System::IO::GetOverlappedResult;
932
933 let mut inner = self.inner.lock();
934
935 let mut transferred: u32 = 0;
936
937 let ret = unsafe {
938 GetOverlappedResult(
939 inner.handle,
940 &*inner.overlapped,
941 &mut transferred,
942 if wait { 1 } else { 0 },
943 )
944 };
945
946 let err = if ret == 0 {
947 unsafe { GetLastError() }
948 } else {
949 ERROR_SUCCESS
950 };
951
952 match err {
953 ERROR_SUCCESS | ERROR_MORE_DATA | ERROR_OPERATION_ABORTED => {
954 inner.completed = true;
955 inner.pending = false;
956 }
957 ERROR_IO_INCOMPLETE => {}
958 _ => {
959 inner.pending = false;
960 return Err(std::io::Error::from_raw_os_error(err as i32).to_pyexception(vm));
961 }
962 }
963
964 if inner.completed
965 && let Some(read_buffer) = &mut inner.read_buffer
966 && transferred != read_buffer.len() as u32
967 {
968 read_buffer.truncate(transferred as usize);
969 }
970
971 Ok((transferred, err))
972 }
973
974 #[pymethod]
975 fn getbuffer(&self, vm: &VirtualMachine) -> PyResult<Option<PyObjectRef>> {

Callers 7

pipeFunction · 0.80
_send_bytesMethod · 0.80
_recv_bytesMethod · 0.80
_get_more_dataMethod · 0.80
PipeFunction · 0.80
acceptMethod · 0.80
waitFunction · 0.80

Calls 6

GetLastErrorFunction · 0.70
ErrClass · 0.50
lockMethod · 0.45
to_pyexceptionMethod · 0.45
lenMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected