Skip to content

Commit

Permalink
Adjust unnamed pipe examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kotauskas committed Jun 13, 2024
1 parent 5bcd669 commit 050ae2e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/unnamed_pipe/sync/side_a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ pub(crate) fn emain(handle_sender: mpsc::SyncSender<Handle>) -> io::Result<()> {
assert_eq!(buf.trim(), "Hello from side B!");
//{
Ok(())
} //}
}
#[allow(dead_code)]
fn main() {}
fn main() {} //}
4 changes: 2 additions & 2 deletions examples/unnamed_pipe/sync/side_b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ pub(crate) fn emain(handle: Handle) -> io::Result<()> {
tx.write_all(b"Hello from side B!\n")?;
//{
Ok(())
} //}
}
#[allow(dead_code)]
fn main() {}
fn main() {} //}
4 changes: 2 additions & 2 deletions examples/unnamed_pipe/tokio/side_a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ pub(crate) async fn emain(handle_sender: oneshot::Sender<Handle>) -> io::Result<
assert_eq!(buf.trim(), "Hello from side B!");
//{
Ok(())
} //}
}
#[allow(dead_code)]
fn main() {}
fn main() {} //}
4 changes: 2 additions & 2 deletions examples/unnamed_pipe/tokio/side_b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ pub(crate) async fn emain(handle: Handle) -> io::Result<()> {
tx.write_all(b"Hello from side B!\n").await?;
//{
Ok(())
} //}
}
#[allow(dead_code)]
fn main() {}
fn main() {} //}
14 changes: 14 additions & 0 deletions src/unnamed_pipe/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Tokio-based asynchronous unnamed pipes.
//!
//! See the [parent-level documentation](super) for more.
//!
//! # Examples
//! See [`pipe()`].
impmod! {unnamed_pipe::tokio,
Recver as RecverImpl,
Expand All @@ -14,6 +17,17 @@ use std::io;
///
/// The platform-specific builders in the `os` module of the crate might be more helpful if extra
/// configuration for the pipe is needed.
///
/// # Examples
/// ## Basic communication
/// In a parent process, within a Tokio runtime:
/// ```no_run
#[doc = doctest_file::include_doctest!("examples/unnamed_pipe/sync/side_a.rs")]
/// ```
/// In a child process, within a Tokio runtime:
/// ```no_run
#[doc = doctest_file::include_doctest!("examples/unnamed_pipe/sync/side_b.rs")]
/// ```
#[inline]
pub fn pipe() -> io::Result<(Sender, Recver)> {
pipe_impl()
Expand Down

0 comments on commit 050ae2e

Please sign in to comment.