arxiv/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![deny(missing_copy_implementations, missing_debug_implementations)]
3
4//! A Rust library for parsing `arXiv` categories, identifiers and references.
5//!
6//! ## Identifiers
7//! ```rust
8//! use arxiv::{ArticleId, ArticleVersion};
9//!
10//! let id = ArticleId::try_from("arXiv:9912.12345v2").unwrap();
11//! assert_eq!(id.month(), 12);
12//! assert_eq!(id.year(), 2099);
13//! assert_eq!(id.number(), "12345");
14//! assert_eq!(id.version(), ArticleVersion::Num(2));
15//! ```
16//!
17//! ## Categories
18//! ```rust
19//! use arxiv::{Archive, CategoryId, Group};
20//!
21//! let category = CategoryId::try_from("astro-ph.HE").unwrap();
22//! assert_eq!(category.group(), Group::Physics);
23//! assert_eq!(category.archive(), Archive::AstroPh);
24//! assert_eq!(category.subject(), "HE");
25//! ```
26//!
27//! ## Stamps
28//! ```rust
29//! use arxiv::{Archive, CategoryId, Stamp};
30//!
31//! let stamp = Stamp::try_from("arXiv:0706.0001v1 [q-bio.CB] 1 Jun 2007").unwrap();
32//! assert_eq!(stamp.category, CategoryId::try_new(Archive::QBio, "CB").unwrap());
33//! assert_eq!(stamp.submitted.year(), 2007);
34//! ```
35//!
36//! ## Feature flags
37//! The crate has the following feature flags:
38//! - `url` (default): Enables converting types into URLs where possible,
39//! such as converting an article identifier into a URL that leads to its abstract page.
40
41mod category;
42mod identifier;
43mod stamp;
44mod subject_tables;
45pub use crate::category::*;
46pub use crate::identifier::*;
47pub use crate::stamp::*;
48
49/// Represents the versioned grammar that defines an arXiv identifier
50#[derive(Debug, Clone, Copy, PartialEq, Eq)]
51pub enum ArticleIdScheme {
52 /// Identifier scheme up to [March 2007][arxiv-march-2007]
53 ///
54 /// [arxiv-march-2007]: https://info.arxiv.org/help/arxiv_identifier.html#identifiers-up-to-march-2007-9107-0703
55 Old,
56
57 /// Identifier scheme since [1 April 2007][arxiv-april-2007]
58 ///
59 /// [arxiv-april-2007]: https://info.arxiv.org/help/arxiv_identifier.html#identifier-scheme-since-1-april-2007-0704-
60 New,
61}