parse_records_from_file

Function parse_records_from_file 

Source
pub fn parse_records_from_file<P>(
    path: P,
) -> Result<(Vec<Record>, Vec<Error>), ParseError>
where P: AsRef<Path>,
Expand description

从文件读取并收集所有 Records 和错误(内存模式)

⚠️ 警告:此函数会将所有结果加载到内存中,不适合处理大文件。 对于大文件,请使用 iter_records_from_file() 返回的迭代器。

§参数

  • path - 日志文件路径

§返回

  • Ok((Vec<Record>, Vec<std::io::Error>)) - 成功解析的 records 和遇到的错误
  • Err(ParseError) - 文件打开错误

§示例

use dm_database_parser_sqllog::parse_records_from_file;

// 仅适用于小文件
let (records, errors) = parse_records_from_file("small_log.txt")?;

println!("成功解析 {} 条记录", records.len());
println!("遇到 {} 个错误", errors.len());