Skip to content

Commit

Permalink
Add async doc in top doc
Browse files Browse the repository at this point in the history
add doc

Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
  • Loading branch information
jokemanfire committed Jan 6, 2025
1 parent 5e05dd7 commit c7c7333
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
//! files or directories.
//!
//! The [`Inotify`] struct is the main entry point into the API.
//! The [`EventStream`] struct is designed to be used with async streams.
//!
//! # Example
//! # Examples
//!
//! If you just want to synchronously retrieve events
//! ```
//! use inotify::{
//! Inotify,
Expand Down Expand Up @@ -47,7 +49,15 @@
//! // Handle event
//! }
//! ```
//!
//! When you want to read events asynchronously, you need to convert it to [`EventStream`].
//! The transform function is [`Inotify::into_event_stream`]
//! ```
//! let mut stream = inotify.into_event_stream(&mut buffer)?;
//! // Read events from async stream
//! while let Some(event_or_error) = stream.next().await {
//! println!("event: {:?}", event_or_error?);
//! }
//! ```
//! # Attention: inotify gotchas
//!
//! inotify (as in, the Linux API, not this wrapper) has many edge cases, making
Expand Down

0 comments on commit c7c7333

Please sign in to comment.