Skip to main content

load_filter_file

Function load_filter_file 

Source
pub fn load_filter_file(
    path: impl AsRef<Path>,
    config: &ParserConfig,
) -> Result<CompiledFilter, LoadError>
Expand description

Load and compile a filter from a file.

The file can contain:

  • Comments (lines starting with #)
  • Delimiter directive: @delimiter = ";;;"
  • Field mappings: @field FIELD_NAME = index
  • The filter expression

If the file contains @delimiter or @field directives, they override the provided config.

§Arguments

  • path - Path to the filter file
  • config - Base parser configuration (can be overridden by file directives)

§Returns

A compiled filter ready for evaluation.

§Example

use bytecode_filter::{load_filter_file, ParserConfig};

let config = ParserConfig::default();
let filter = load_filter_file("filters/my.filter", &config).unwrap();

§Errors

Returns LoadError if the file cannot be read or the filter fails to compile.