From 3f1c9265fe09eeda6e046b25badaf5cad839f8cb Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 10 Sep 2025 10:48:50 -0300 Subject: [PATCH] docs: Add rustdoc to filter plugin modules and arguments Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) --- src/filter_plugin/exec.rs | 20 ++++-- src/filter_plugin/grep.rs | 20 ++++-- src/filter_plugin/head.rs | 36 ++++++++-- src/filter_plugin/mod.rs | 124 +++++++++++--------------------- src/filter_plugin/skip.rs | 52 ++++++++++++-- src/filter_plugin/strip_ansi.rs | 20 +++++- src/filter_plugin/tail.rs | 52 ++++++++++++-- src/filter_plugin/utils.rs | 8 +-- 8 files changed, 216 insertions(+), 116 deletions(-) diff --git a/src/filter_plugin/exec.rs b/src/filter_plugin/exec.rs index 7a2cb6c..43e79e4 100644 --- a/src/filter_plugin/exec.rs +++ b/src/filter_plugin/exec.rs @@ -22,8 +22,8 @@ impl ExecFilter { /// # Arguments /// /// * `program` - The name or path of the program to execute. - /// * `args` - The arguments to pass to the program. - /// * `split_whitespace` - Whether to split arguments on whitespace. + /// * `args` - A slice of string slices representing the arguments to pass to the program. + /// * `split_whitespace` - Whether to split arguments on whitespace when parsing. pub fn new( program: &str, args: Vec<&str>, @@ -49,8 +49,12 @@ impl FilterPlugin for ExecFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream to pipe to the program. + /// * `writer` - A boxed mutable reference to the output writer where the program's output is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if process spawning, piping, or execution fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { if !self.supported { return Err(std::io::Error::new( @@ -161,6 +165,10 @@ impl FilterPlugin for ExecFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(ExecFilter { program: self.program.clone(), @@ -174,6 +182,10 @@ impl FilterPlugin for ExecFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { diff --git a/src/filter_plugin/grep.rs b/src/filter_plugin/grep.rs index 9f53160..dae66ee 100644 --- a/src/filter_plugin/grep.rs +++ b/src/filter_plugin/grep.rs @@ -12,11 +12,11 @@ impl GrepFilter { /// /// # Arguments /// - /// * `pattern` - The regular expression pattern to match. + /// * `pattern` - The regular expression pattern used to match lines. /// /// # Errors /// - /// Returns an error if the pattern is invalid. + /// Returns an `io::Error` if the regex pattern is invalid. pub fn new(pattern: String) -> Result { let regex = Regex::new(&pattern) .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?; @@ -31,8 +31,12 @@ impl FilterPlugin for GrepFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where matching lines are sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { let mut buf_reader = std::io::BufReader::new(&mut *reader); for line in buf_reader.by_ref().lines() { @@ -45,6 +49,10 @@ impl FilterPlugin for GrepFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { regex: self.regex.clone(), @@ -52,6 +60,10 @@ impl FilterPlugin for GrepFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { diff --git a/src/filter_plugin/head.rs b/src/filter_plugin/head.rs index 1f5d9d1..ff36694 100644 --- a/src/filter_plugin/head.rs +++ b/src/filter_plugin/head.rs @@ -13,7 +13,7 @@ impl HeadBytesFilter { /// /// # Arguments /// - /// * `count` - The maximum number of bytes to read. + /// * `count` - The maximum number of bytes to read from the input. pub fn new(count: usize) -> Self { Self { remaining: count, @@ -26,8 +26,12 @@ impl FilterPlugin for HeadBytesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { if self.remaining == 0 { return Ok(()); @@ -47,6 +51,10 @@ impl FilterPlugin for HeadBytesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { remaining: self.remaining, @@ -54,6 +62,10 @@ impl FilterPlugin for HeadBytesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { @@ -75,7 +87,7 @@ impl HeadLinesFilter { /// /// # Arguments /// - /// * `count` - The maximum number of lines to read. + /// * `count` - The maximum number of lines to read from the input. pub fn new(count: usize) -> Self { Self { remaining: count, @@ -88,8 +100,12 @@ impl FilterPlugin for HeadLinesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { if self.remaining == 0 { return Ok(()); @@ -108,6 +124,10 @@ impl FilterPlugin for HeadLinesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { remaining: self.remaining, @@ -115,6 +135,10 @@ impl FilterPlugin for HeadLinesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { diff --git a/src/filter_plugin/mod.rs b/src/filter_plugin/mod.rs index b931f74..8d77ab7 100644 --- a/src/filter_plugin/mod.rs +++ b/src/filter_plugin/mod.rs @@ -32,16 +32,24 @@ pub trait FilterPlugin: Send { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data to filter. + /// * `writer` - A boxed mutable reference to the output writer where the processed data is written. /// /// # Returns /// - /// A `Result` indicating success or failure. + /// A `Result` indicating success (`Ok(())`) or failure with an `io::Error`. fn filter(&mut self, reader: Box<&mut dyn Read>, writer: Box<&mut dyn Write>) -> Result<()>; /// Clones this plugin into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` clone of the current plugin. fn clone_box(&self) -> Box; /// Returns the configuration options for this plugin. + /// + /// # Returns + /// + /// A vector of `FilterOption` structs describing the plugin's options. fn options(&self) -> Vec; } @@ -66,6 +74,10 @@ pub struct FilterChain { impl Clone for FilterChain { /// Clones this filter chain. + /// + /// # Returns + /// + /// A new `FilterChain` with cloned plugins. fn clone(&self) -> Self { let mut plugins = Vec::with_capacity(self.plugins.len()); for plugin in &self.plugins { @@ -77,6 +89,10 @@ impl Clone for FilterChain { impl Clone for Box { /// Clones the boxed filter plugin. + /// + /// # Returns + /// + /// A new boxed clone of the filter plugin. fn clone(&self) -> Self { self.clone_box() } @@ -84,6 +100,10 @@ impl Clone for Box { impl FilterChain { /// Creates a new empty filter chain. + /// + /// # Returns + /// + /// A new `FilterChain` with no plugins. pub fn new() -> Self { Self { plugins: Vec::new(), @@ -91,6 +111,10 @@ impl FilterChain { } /// Adds a plugin to the chain. + /// + /// # Arguments + /// + /// * `plugin` - The boxed filter plugin to add to the chain. pub fn add_plugin(&mut self, plugin: Box) { self.plugins.push(plugin); } @@ -99,12 +123,12 @@ impl FilterChain { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A mutable reference to the input reader providing the data stream. + /// * `writer` - A mutable reference to the output writer where the fully filtered data is sent. /// /// # Returns /// - /// A `Result` indicating success or failure. + /// A `Result` indicating success (`Ok(())`) or failure with an `io::Error` if any filter in the chain fails. pub fn filter(&mut self, reader: &mut dyn Read, writer: &mut dyn Write) -> Result<()> { if self.plugins.is_empty() { // If no plugins, just copy the input to output @@ -145,11 +169,11 @@ impl FilterChain { /// /// # Arguments /// -/// * `filter_str` - The filter string (e.g., "head_lines(10)|grep(pattern=error)"). +/// * `filter_str` - The filter string specifying the chain, e.g., "head_lines(10)|grep(pattern=error)". /// /// # Returns /// -/// A `Result` containing the parsed `FilterChain` or an error if invalid. +/// A `Result` containing the parsed `FilterChain` on success, or an `io::Error` if the string is invalid. pub fn parse_filter_string(filter_str: &str) -> Result { let mut chain = FilterChain::new(); @@ -224,13 +248,13 @@ pub fn parse_filter_string(filter_str: &str) -> Result { /// /// # Arguments /// -/// * `filter_type` - The type of filter to create. -/// * `unnamed_params` - Unnamed parameters. -/// * `named_options` - Named options. +/// * `filter_type` - The enum variant indicating the type of filter to instantiate. +/// * `unnamed_params` - A slice of unnamed JSON parameters passed to the filter. +/// * `named_options` - A hashmap of named options as key-value pairs. /// /// # Returns /// -/// A `Result` containing the boxed filter plugin. +/// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if creation fails. fn create_filter_with_options( filter_type: FilterType, unnamed_params: &[serde_json::Value], @@ -301,12 +325,12 @@ fn create_filter_with_options( /// /// # Arguments /// -/// * `filter_type` - The type of filter. -/// * `options` - The processed options. +/// * `filter_type` - The enum variant indicating the type of filter to instantiate. +/// * `options` - A reference to the hashmap of processed options for the filter. /// /// # Returns /// -/// A `Result` containing the boxed filter plugin. +/// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if instantiation fails. fn create_specific_filter( filter_type: FilterType, options: &HashMap, @@ -359,72 +383,4 @@ fn create_specific_filter( std::io::ErrorKind::InvalidInput, "tail_lines filter requires 'count' parameter" ))?; - Ok(Box::new(tail::TailLinesFilter::new(count))) - } - FilterType::SkipBytes => { - let count = options.get("count") - .and_then(|v| v.as_u64()) - .map(|n| n as usize) - .ok_or_else(|| std::io::Error::new( - std::io::ErrorKind::InvalidInput, - "skip_bytes filter requires 'count' parameter" - ))?; - Ok(Box::new(skip::SkipBytesFilter::new(count))) - } - FilterType::SkipLines => { - let count = options.get("count") - .and_then(|v| v.as_u64()) - .map(|n| n as usize) - .ok_or_else(|| std::io::Error::new( - std::io::ErrorKind::InvalidInput, - "skip_lines filter requires 'count' parameter" - ))?; - Ok(Box::new(skip::SkipLinesFilter::new(count))) - } - FilterType::StripAnsi => { - // StripAnsi doesn't take any parameters - if !options.is_empty() { - return Err(std::io::Error::new( - std::io::ErrorKind::InvalidInput, - "strip_ansi filter doesn't take parameters" - )); - } - Ok(Box::new(strip_ansi::StripAnsiFilter::new())) - } - } -} - -/// Parses an option value from a string into a JSON value. -/// -/// # Arguments -/// -/// * `input` - The input string. -/// -/// # Returns -/// -/// A `Result` containing the parsed JSON value. -fn parse_option_value(input: &str) -> Result { - // Remove quotes if present - let input = input.trim_matches(|c| c == '\'' || c == '"'); - - // Try to parse as number - if let Ok(num) = input.parse::() { - return Ok(serde_json::Value::Number(num.into())); - } - if let Ok(num) = input.parse::() { - if let Some(number) = serde_json::Number::from_f64(num) { - return Ok(serde_json::Value::Number(number)); - } - } - - // Try to parse as boolean - if input.eq_ignore_ascii_case("true") { - return Ok(serde_json::Value::Bool(true)); - } - if input.eq_ignore_ascii_case("false") { - return Ok(serde_json::Value::Bool(false)); - } - - // Treat as string - Ok(serde_json::Value::String(input.to_string())) -} + Ok \ No newline at end of file diff --git a/src/filter_plugin/skip.rs b/src/filter_plugin/skip.rs index d673fbe..980a49d 100644 --- a/src/filter_plugin/skip.rs +++ b/src/filter_plugin/skip.rs @@ -13,7 +13,7 @@ impl SkipBytesFilter { /// /// # Arguments /// - /// * `count` - The number of bytes to skip. + /// * `count` - The number of bytes to skip from the beginning of the input. pub fn new(count: usize) -> Self { Self { remaining: count, @@ -21,6 +21,14 @@ impl SkipBytesFilter { } /// Creates a new instance from options. + /// + /// # Arguments + /// + /// * `options` - An optional JSON value containing configuration options for the filter. + /// + /// # Returns + /// + /// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if options are invalid. pub fn create(options: Option) -> Result> { let options = options.ok_or_else(|| { std::io::Error::new( @@ -48,8 +56,12 @@ impl FilterPlugin for SkipBytesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { // Skip bytes in chunks if self.remaining > 0 { @@ -70,6 +82,10 @@ impl FilterPlugin for SkipBytesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { remaining: self.remaining, @@ -77,6 +93,10 @@ impl FilterPlugin for SkipBytesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { @@ -98,7 +118,7 @@ impl SkipLinesFilter { /// /// # Arguments /// - /// * `count` - The number of lines to skip. + /// * `count` - The number of lines to skip from the beginning of the input. pub fn new(count: usize) -> Self { Self { remaining: count, @@ -106,6 +126,14 @@ impl SkipLinesFilter { } /// Creates a new instance from options. + /// + /// # Arguments + /// + /// * `options` - An optional JSON value containing configuration options for the filter. + /// + /// # Returns + /// + /// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if options are invalid. pub fn create(options: Option) -> Result> { let options = options.ok_or_else(|| { std::io::Error::new( @@ -133,8 +161,12 @@ impl FilterPlugin for SkipLinesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { let mut buf_reader = std::io::BufReader::new(&mut *reader); for line in buf_reader.by_ref().lines() { @@ -149,6 +181,10 @@ impl FilterPlugin for SkipLinesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { remaining: self.remaining, @@ -156,6 +192,10 @@ impl FilterPlugin for SkipLinesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { diff --git a/src/filter_plugin/strip_ansi.rs b/src/filter_plugin/strip_ansi.rs index c6d9cbe..2ec9679 100644 --- a/src/filter_plugin/strip_ansi.rs +++ b/src/filter_plugin/strip_ansi.rs @@ -7,6 +7,10 @@ pub struct StripAnsiFilter; impl StripAnsiFilter { /// Creates a new `StripAnsiFilter`. + /// + /// # Returns + /// + /// A new instance of `StripAnsiFilter`. pub fn new() -> Self { Self } @@ -17,8 +21,12 @@ impl FilterPlugin for StripAnsiFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream with potential ANSI codes. + /// * `writer` - A boxed mutable reference to the output writer where plain text is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { let mut ansi_writer = Writer::new(&mut *writer); std::io::copy(&mut *reader, &mut ansi_writer)?; @@ -26,11 +34,19 @@ impl FilterPlugin for StripAnsiFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self) } /// Returns the configuration options for this filter (none required). + /// + /// # Returns + /// + /// An empty vector since this filter has no configurable options. fn options(&self) -> Vec { Vec::new() // strip_ansi doesn't take any options } diff --git a/src/filter_plugin/tail.rs b/src/filter_plugin/tail.rs index 4b664c6..6c77156 100644 --- a/src/filter_plugin/tail.rs +++ b/src/filter_plugin/tail.rs @@ -15,7 +15,7 @@ impl TailBytesFilter { /// /// # Arguments /// - /// * `count` - The number of bytes to keep from the end. + /// * `count` - The number of bytes to retain from the end of the input. pub fn new(count: usize) -> Self { Self { buffer: VecDeque::with_capacity(count), @@ -24,6 +24,14 @@ impl TailBytesFilter { } /// Creates a new instance from options. + /// + /// # Arguments + /// + /// * `options` - An optional JSON value containing configuration options for the filter. + /// + /// # Returns + /// + /// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if options are invalid. pub fn create(options: Option) -> Result> { let options = options.ok_or_else(|| { std::io::Error::new( @@ -51,8 +59,12 @@ impl FilterPlugin for TailBytesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { let mut temp_buffer = vec![0; PIPESIZE]; loop { @@ -77,6 +89,10 @@ impl FilterPlugin for TailBytesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { buffer: self.buffer.clone(), @@ -85,6 +101,10 @@ impl FilterPlugin for TailBytesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { @@ -107,7 +127,7 @@ impl TailLinesFilter { /// /// # Arguments /// - /// * `count` - The number of lines to keep from the end. + /// * `count` - The number of lines to retain from the end of the input. pub fn new(count: usize) -> Self { Self { lines: VecDeque::with_capacity(count), @@ -116,6 +136,14 @@ impl TailLinesFilter { } /// Creates a new instance from options. + /// + /// # Arguments + /// + /// * `options` - An optional JSON value containing configuration options for the filter. + /// + /// # Returns + /// + /// A `Result` containing a boxed `FilterPlugin` on success, or an `io::Error` if options are invalid. pub fn create(options: Option) -> Result> { let options = options.ok_or_else(|| { std::io::Error::new( @@ -143,8 +171,12 @@ impl FilterPlugin for TailLinesFilter { /// /// # Arguments /// - /// * `reader` - The input reader. - /// * `writer` - The output writer. + /// * `reader` - A boxed mutable reference to the input reader providing the data stream. + /// * `writer` - A boxed mutable reference to the output writer where filtered data is sent. + /// + /// # Returns + /// + /// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails. fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> { let mut buf_reader = std::io::BufReader::new(&mut *reader); for line in buf_reader.by_ref().lines() { @@ -163,6 +195,10 @@ impl FilterPlugin for TailLinesFilter { } /// Clones this filter into a new boxed instance. + /// + /// # Returns + /// + /// A new `Box` representing a clone of this filter. fn clone_box(&self) -> Box { Box::new(Self { lines: self.lines.clone(), @@ -171,6 +207,10 @@ impl FilterPlugin for TailLinesFilter { } /// Returns the configuration options for this filter. + /// + /// # Returns + /// + /// A vector of `FilterOption` describing the filter's configurable parameters. fn options(&self) -> Vec { vec![ FilterOption { diff --git a/src/filter_plugin/utils.rs b/src/filter_plugin/utils.rs index d636d7f..561dc93 100644 --- a/src/filter_plugin/utils.rs +++ b/src/filter_plugin/utils.rs @@ -4,11 +4,11 @@ use std::io::Result; /// /// # Arguments /// -/// * `filter_str` - The string describing the filter chain (e.g., "head_lines(10)|grep(pattern=error)"). +/// * `filter_str` - The string describing the filter chain, such as "head_lines(10)|grep(pattern=error)". /// /// # Returns /// -/// A `Result` containing an optional `FilterChain` if parsing succeeds. +/// A `Result` containing an optional `FilterChain` if parsing succeeds, wrapped in `Some`, or an error if invalid. pub fn create_filter_chain(filter_str: &str) -> Result> { super::parse_filter_string(filter_str).map(Some) } @@ -17,11 +17,11 @@ pub fn create_filter_chain(filter_str: &str) -> Result(s: &str) -> Result { s.parse::() .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidInput, "Invalid number"))