marc_rs/
lib.rs

1//! # marc-rs
2//!
3//! A Rust library for parsing and writing MARC21, UNIMARC, and MARC XML bibliographic records.
4//!
5//! ## Features
6//!
7//! - Support for MARC21, UNIMARC, and MARC XML formats
8//! - Multiple character encodings (UTF-8, MARC-8, ISO-8859-*)
9//! - Parse multiple records from a single buffer
10//! - Write single or multiple records
11//! - Optional Serde support for serialization/deserialization
12//!
13//! ## Examples
14//!
15//! ### Parsing MARC21 records
16//!
17//! ```no_run
18//! use marc_rs::{parse, FormatEncoding, MarcFormat, Encoding};
19//!
20//! let data = b"..."; // MARC binary data
21//! let format_encoding = FormatEncoding::new(MarcFormat::Marc21, Encoding::Marc8);
22//! let records = parse(data, format_encoding).unwrap();
23//! ```
24//!
25//! ### Writing MARC XML
26//!
27//! ```no_run
28//! use marc_rs::{write, FormatEncoding, MarcFormat, Encoding, Record};
29//! use std::io::stdout;
30//!
31//! let records = vec![/* ... */];
32//! let format_encoding = FormatEncoding::marc_xml();
33//! write(&records, format_encoding, &mut stdout()).unwrap();
34//! ```
35//!
36//! ### Serde Serialization/Deserialization
37//!
38//! With the `serde` feature enabled, you can serialize/deserialize directly to/from MARC formats:
39//!
40//! ```ignore
41//! use marc_rs::{Record, FormatEncoding, MarcFormat, Encoding, serde_marc};
42//! use std::fs::File;
43//!
44//! fn example() -> Result<(), Box<dyn std::error::Error>> {
45//!     // Deserialize from bytes
46//!     let data = b"..."; // MARC binary data
47//!     let format = FormatEncoding::new(MarcFormat::Marc21, Encoding::Marc8);
48//!     let record = serde_marc::from_slice(data, format)?;
49//!
50//!     // Deserialize from reader
51//!     let file = File::open("record.mrc")?;
52//!     let record = serde_marc::from_reader(file, format)?;
53//!
54//!     // Serialize to bytes
55//!     let bytes = serde_marc::to_vec(&record, format)?;
56//!
57//!     // Serialize to writer
58//!     let mut output = Vec::new();
59//!     serde_marc::to_writer(&record, format, &mut output)?;
60//!
61//!     // For XML format, you can also use string functions
62//!     let xml_format = FormatEncoding::marc_xml();
63//!     let xml_string = serde_marc::to_string(&record, xml_format)?;
64//!     let record_from_xml = serde_marc::from_str(&xml_string, xml_format)?;
65//!
66//!     Ok(())
67//! }
68//! ```
69//!
70//! ## References
71//!
72//! - [MARC 21 Format for Bibliographic Data](https://www.loc.gov/marc/bibliographic/)
73//! - [MARC XML Schema](https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd)
74//! - [UNIMARC Manual](https://www.transition-bibliographique.fr/unimarc/manuel-unimarc-format-bibliographique/)
75
76pub mod encoding;
77pub mod fields;
78pub mod format;
79pub mod parser;
80pub mod record;
81pub mod writer;
82pub mod helpers;
83pub use encoding::*;
84pub use fields::*;
85pub use format::*;
86pub use parser::*;
87pub use record::*;
88pub use writer::*;