Skip to main content

sel/source/
mod.rs

1//! Input sources — iterators that yield `Line`s one at a time.
2
3pub mod file;
4pub mod stdin;
5
6pub use file::FileSource;
7pub use stdin::StdinSource;
8
9use crate::Line;
10use crate::Result;
11
12/// A stream of input lines with 1-indexed line numbers.
13///
14/// Implementations own the underlying reader and handle newline stripping.
15pub trait Source {
16    /// Read the next line. Returns `Ok(None)` at EOF.
17    fn next_line(&mut self) -> Result<Option<Line>>;
18
19    /// A short label for this source, used for the filename prefix (`-` for stdin).
20    fn label(&self) -> &str;
21
22    /// Can this source be paired with positional selectors?
23    /// `false` for stdin.
24    fn is_seekable(&self) -> bool;
25}