Skip to content

Fix misleading NamedPipeServer example#6590

Merged
Darksonn merged 1 commit intotokio-rs:masterfrom
Tacklebox:named_pipe_server_example_fix
May 26, 2024
Merged

Fix misleading NamedPipeServer example#6590
Darksonn merged 1 commit intotokio-rs:masterfrom
Tacklebox:named_pipe_server_example_fix

Conversation

@Tacklebox
Copy link
Copy Markdown
Contributor

Motivation

The previous NamedPipeServer doc example seemed to imply that the return type of NamedPipeServer::connect() was a Future<Result<some_kind_of_client>>>, however, connect() returns a Future<Result<()>>>. The following line of code reopening the pipe would shadow the newly connected pipe immediately, making the following spawned task pointless.

Solution

Instead, now it binds the original named pipe to a new variable after a client connects, allowing for the subsequent task to be able use the connection.

The previous NamedPipeServer doc example seemed to imply that the return
type of `NamedPipeServer::connect()` was a
`Future<Result<some_kind_of_client>>>`, however, `connect()` returns a
`Future<Result<()>>>`. The following line of code reopening the pipe
would shadow the newly connected pipe immediately, making the following
spawned task pointless. Hopefully these changes make it more clear what
should be happening in the example.
@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-net Module: tokio/net labels May 26, 2024
Copy link
Copy Markdown
Member

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@Darksonn Darksonn merged commit 6c42d28 into tokio-rs:master May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate M-net Module: tokio/net T-docs Topic: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants