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

Method ConnectNamedPipe

crates/stdlib/src/overlapped.rs:1195–1229  ·  view source on GitHub ↗
(zelf: &Py<Self>, pipe: isize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1193 // ConnectNamedPipe
1194 #[pymethod]
1195 fn ConnectNamedPipe(zelf: &Py<Self>, pipe: isize, vm: &VirtualMachine) -> PyResult<bool> {
1196 use windows_sys::Win32::Foundation::{
1197 ERROR_IO_PENDING, ERROR_PIPE_CONNECTED, ERROR_SUCCESS,
1198 };
1199 use windows_sys::Win32::System::Pipes::ConnectNamedPipe;
1200
1201 let mut inner = zelf.inner.lock();
1202 if !matches!(inner.data, OverlappedData::None) {
1203 return Err(vm.new_value_error("operation already attempted"));
1204 }
1205
1206 inner.handle = pipe as HANDLE;
1207 inner.data = OverlappedData::ConnectNamedPipe;
1208
1209 let ret = unsafe { ConnectNamedPipe(pipe as HANDLE, &mut inner.overlapped) };
1210
1211 let err = if ret != 0 {
1212 ERROR_SUCCESS
1213 } else {
1214 unsafe { GetLastError() }
1215 };
1216 inner.error = err;
1217
1218 match err {
1219 ERROR_PIPE_CONNECTED => {
1220 mark_as_completed(&mut inner.overlapped);
1221 Ok(true)
1222 }
1223 ERROR_SUCCESS | ERROR_IO_PENDING => Ok(false),
1224 _ => {
1225 inner.data = OverlappedData::NotStarted;
1226 Err(set_from_windows_err(err, vm))
1227 }
1228 }
1229 }
1230
1231 // WSASendTo
1232 #[pymethod]

Callers 4

accept_pipeMethod · 0.95
pipeFunction · 0.80
PipeFunction · 0.80
acceptMethod · 0.80

Calls 6

ConnectNamedPipeFunction · 0.85
mark_as_completedFunction · 0.85
set_from_windows_errFunction · 0.85
ErrClass · 0.50
GetLastErrorFunction · 0.50
lockMethod · 0.45

Tested by

no test coverage detected