pub struct MarcReader { /* private fields */ }Expand description
Unified MARC reader with auto-detection of file format (binary ISO2709 or MARC-XML).
Internally, all data is stored as ISO2709 bytes. XML input is eagerly
converted by XmlReader::parse(), so iteration always goes through
BinaryReader.
Implementations§
Source§impl MarcReader
impl MarcReader
Sourcepub fn from_bytes(data: Vec<u8>) -> Result<Self, MarcError>
pub fn from_bytes(data: Vec<u8>) -> Result<Self, MarcError>
Auto-detect format from raw bytes and build the reader. XML data is eagerly converted to ISO2709.
Sourcepub fn from_file(path: &Path) -> Result<Self, MarcError>
pub fn from_file(path: &Path) -> Result<Self, MarcError>
Read a file, auto-detect its format, and build the reader.
Sourcepub fn from_binary(data: Vec<u8>) -> Self
pub fn from_binary(data: Vec<u8>) -> Self
Force binary ISO2709 format (no detection).
Sourcepub fn from_xml(data: &[u8]) -> Result<Self, MarcError>
pub fn from_xml(data: &[u8]) -> Result<Self, MarcError>
Force MARC-XML format (no detection). Parses XML eagerly into ISO2709.
Sourcepub fn with_encoding(self, encoding: Encoding) -> Self
pub fn with_encoding(self, encoding: Encoding) -> Self
Force the encoding used when decoding raw record data. Use when the record’s declared encoding (e.g. leader byte 9 for MARC21, 100$a for UNIMARC) is wrong.
Sourcepub fn clear_encoding_override(&mut self)
pub fn clear_encoding_override(&mut self)
Clear any encoding override.
Sourcepub fn source_format(&self) -> FileFormat
pub fn source_format(&self) -> FileFormat
Returns the original file format before conversion.
Sourcepub fn encoding_override(&self) -> Option<Encoding>
pub fn encoding_override(&self) -> Option<Encoding>
Returns the encoding override when set.
Sourcepub fn iter(&self) -> BinaryReader<'_> ⓘ
pub fn iter(&self) -> BinaryReader<'_> ⓘ
Iterate over raw ISO2709 records (with optional encoding override applied when decoding).