Skip to main content

csan_core/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Cutter call number generation for library cataloging.
4//!
5//! `csan-core` derives shelf-ready cutter numbers from author names (or, for
6//! anonymous works, titles) using two methods:
7//!
8//! * **Cutter-Sanborn three-figure** — a lookup against the bundled
9//!   Cutter-Sanborn table, with optional call number prefix and lowercase
10//!   work mark ([`CutterSanbornMethod`]).
11//! * **Library of Congress** — the `LoC` character-branching rules,
12//!   producing an initial plus a digit sequence ([`CutterLocMethod`]).
13//!
14//! Input names are normalized first: whitespace and punctuation are
15//! stripped, diacritics are folded to ASCII, `Mc`/`M'` prefixes expand to
16//! `Mac`, and `St`/`Ste` expand to `Saint`/`Sainte`, matching the
17//! conventions of the underlying tables.
18//!
19//! # Example
20//! ```
21//! use csan_core::{
22//!     Attribution, Author, CutterConfig, CutterGenerator, CutterLocMethod,
23//!     CutterSanbornMethod, Opus,
24//! };
25//!
26//! let entry = Attribution::Both {
27//!     author: Author::new("Charles", "Dickens"),
28//!     opus: Opus::new("Oliver Twist"),
29//! };
30//!
31//! let sanborn = CutterSanbornMethod::generate(&entry, CutterConfig::default())?;
32//! assert_eq!(sanborn.to_string(), "D548o");
33//!
34//! let loc = CutterLocMethod::generate(&entry, CutterConfig::default())?;
35//! assert_eq!(loc.to_string(), "D535");
36//! # Ok::<(), csan_core::NormalizationError>(())
37//! ```
38pub mod catalog;
39
40pub use catalog::{
41    cutter::{
42        CutterConfig, CutterGenerator, CutterLocMethod, CutterSanbornMethod, Detailed,
43        DetailedError, detailed_json,
44    },
45    models::{Attribution, Author, CutterLoc, CutterSanborn, CutterType, Opus},
46    normalization::NormalizationError,
47};