Struct tokio::net::windows::named_pipe::NamedPipeClient [−][src]
pub struct NamedPipeClient { /* fields omitted */ }
net
only.Expand description
A Windows named pipe client.
Constructed using ClientOptions::open
.
Connecting a client correctly involves a few steps. When connecting through
ClientOptions::open
, it might error indicating one of two things:
std::io::ErrorKind::NotFound
- There is no server available.ERROR_PIPE_BUSY
- There is a server available, but it is busy. Sleep for a while and try again.
So a correctly implemented client looks like this:
use std::time::Duration; use tokio::net::windows::named_pipe::ClientOptions; use tokio::time; use winapi::shared::winerror; const PIPE_NAME: &str = r"\\.\pipe\named-pipe-idiomatic-client"; let client = loop { match ClientOptions::new().open(PIPE_NAME) { Ok(client) => break client, Err(e) if e.raw_os_error() == Some(winerror::ERROR_PIPE_BUSY as i32) => (), Err(e) => return Err(e), } time::sleep(Duration::from_millis(50)).await; }; /* use the connected client */
Implementations
Construct a new named pipe client from the specified raw handle.
This function will consume ownership of the handle given, passing responsibility for closing the handle to the returned object.
This function is also unsafe as the primitives currently returned have the contract that they are the sole owner of the file descriptor they are wrapping. Usage of this function could accidentally allow violating this contract which can cause memory unsafety in code that relies on it being true.
Errors
This errors if called outside of a Tokio Runtime, or in a runtime that has not enabled I/O, or if any OS-specific I/O errors occur.
Retrieves information about the named pipe the client is associated with.
use tokio::net::windows::named_pipe::{ClientOptions, PipeEnd, PipeMode}; const PIPE_NAME: &str = r"\\.\pipe\tokio-named-pipe-client-info"; let client = ClientOptions::new() .open(PIPE_NAME)?; let client_info = client.info()?; assert_eq!(client_info.end, PipeEnd::Client); assert_eq!(client_info.mode, PipeMode::Message); assert_eq!(client_info.max_instances, 5);
Trait Implementations
Attempt to write bytes from buf
into the object. Read more
Like poll_write
, except that it writes from a slice of buffers. Read more
Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Determines if this writer has an efficient poll_write_vectored
implementation. Read more
Auto Trait Implementations
impl !RefUnwindSafe for NamedPipeClient
impl Send for NamedPipeClient
impl Sync for NamedPipeClient
impl Unpin for NamedPipeClient
impl !UnwindSafe for NamedPipeClient