Skip to main content

uls_parser/
lib.rs

1//! Parser for FCC ULS pipe-delimited DAT files.
2//!
3//! This crate provides functionality to parse the DAT files extracted from
4//! FCC ULS ZIP archives. Each DAT file contains pipe-delimited records
5//! with the record type as the first field.
6
7pub mod archive;
8pub mod dat;
9
10pub use archive::ZipExtractor;
11pub use dat::{DatReader, ParsedLine};
12
13use thiserror::Error;
14
15/// Parser error types.
16#[derive(Error, Debug)]
17pub enum ParseError {
18    /// I/O error during file operations.
19    #[error("I/O error: {0}")]
20    Io(#[from] std::io::Error),
21
22    /// Invalid record format.
23    #[error("invalid record format on line {line}: {message}")]
24    InvalidFormat { line: usize, message: String },
25
26    /// Unknown record type.
27    #[error("unknown record type: {0}")]
28    UnknownRecordType(String),
29
30    /// Field parsing error.
31    #[error("failed to parse field {field} on line {line}: {message}")]
32    FieldParse {
33        line: usize,
34        field: String,
35        message: String,
36    },
37
38    /// ZIP extraction error.
39    #[error("ZIP error: {0}")]
40    Zip(#[from] ::zip::result::ZipError),
41}
42
43/// Result type for parser operations.
44pub type Result<T> = std::result::Result<T, ParseError>;