1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! # Async Reverse Buffer Reader
//!
//! A high-performance async buffered reader for reading lines in reverse order.
//! Optimized for processing log files, chat histories, or any text data where
//! you need to read from the end backwards.
//!
//! ## Features
//!
//! - **High Performance**: 8+ million lines/sec throughput
//! - **Streaming Interface**: Clean `lines().next_line().await` pattern
//! - **Memory Efficient**: Fixed buffer size, minimal allocations
//! - **Unicode Support**: Proper UTF-8 handling
//! - **Async/Await**: Full tokio compatibility
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use async_rev_buf::RevBufReader;
//! use tokio::fs::File;
//!
//! #[tokio::main]
//! async fn main() -> std::io::Result<()> {
//! let file = File::open("large.log").await?;
//! let reader = RevBufReader::new(file);
//! let mut lines = reader.lines();
//!
//! // Read last 10 lines efficiently
//! for _ in 0..10 {
//! if let Some(line) = lines.next_line().await? {
//! println!("{}", line);
//! } else {
//! break;
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## API Patterns
//!
//! ### Streaming Interface (Recommended)
//!
//! ```rust
//! # use async_rev_buf::RevBufReader;
//! # use std::io::Cursor;
//! # async fn example() -> std::io::Result<()> {
//! let reader = RevBufReader::new(Cursor::new("line1\nline2\nline3"));
//! let mut lines = reader.lines();
//!
//! while let Some(line) = lines.next_line().await? {
//! println!("{}", line);
//! }
//! # Ok(()) }
//! ```
//!
//! ### Direct Method Access
//!
//! ```rust
//! # use async_rev_buf::RevBufReader;
//! # use std::io::Cursor;
//! # async fn example() -> std::io::Result<()> {
//! let mut reader = RevBufReader::new(Cursor::new("line1\nline2\nline3"));
//!
//! while let Some(line) = reader.next_line().await? {
//! println!("{}", line);
//! }
//! # Ok(()) }
//! ```
pub use RevBufReader;
pub use Lines;
/// Default buffer size: 8 KB
pub const DEFAULT_BUF_SIZE: usize = 8 * 1024;