Skip to content

Commit

Permalink
windows_sys has those, thankfully
Browse files Browse the repository at this point in the history
  • Loading branch information
kotauskas committed Mar 24, 2024
1 parent a5b0dcd commit 31d7fda
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/os/windows/named_pipe/stream/wrapper_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use windows_sys::Win32::{
},
System::Pipes::{
GetNamedPipeHandleStateW, GetNamedPipeInfo, PeekNamedPipe, SetNamedPipeHandleState,
WaitNamedPipeW, PIPE_NOWAIT,
WaitNamedPipeW, PIPE_NOWAIT, PIPE_SERVER_END, PIPE_TYPE_MESSAGE,
},
};

Expand All @@ -42,18 +42,10 @@ pub(crate) fn get_flags(handle: BorrowedHandle<'_>) -> io::Result<u32> {
.true_val_or_errno(flags)
}
pub(crate) fn is_server_from_sys(handle: BorrowedHandle<'_>) -> io::Result<bool> {
// Source: https://docs.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-getnamedpipeinfo
const PIPE_IS_SERVER_BIT: u32 = 0x00000001;

let flags = get_flags(handle)?;
Ok(flags & PIPE_IS_SERVER_BIT != 0)
Ok(get_flags(handle)? & PIPE_SERVER_END != 0)
}
pub(crate) fn has_msg_boundaries_from_sys(handle: BorrowedHandle<'_>) -> io::Result<bool> {
// Same source.
const PIPE_IS_MESSAGE_BIT: u32 = 0x00000004;

let flags = get_flags(handle)?;
Ok((flags & PIPE_IS_MESSAGE_BIT) != 0)
Ok((get_flags(handle)? & PIPE_TYPE_MESSAGE) != 0)
}
#[allow(dead_code)] // TODO give this thing a public API
pub(crate) fn peek_msg_len(handle: BorrowedHandle<'_>) -> io::Result<usize> {
Expand Down

0 comments on commit 31d7fda

Please sign in to comment.