Skip to main content

chordsketch_ireal/
lib.rs

1//! iReal Pro AST types and a zero-dependency JSON debug serializer / parser.
2//!
3//! This crate carries the iReal Pro data model plus the
4//! `irealb://` URL parser (#2054) and serializer (#2052).
5//! Conversion to/from ChordPro (#2053 / #2061) and the
6//! iReal-style graphical renderer (#2058 et seq) build on this
7//! foundation in their own crates.
8//!
9//! See `ARCHITECTURE.md` (in this crate's directory) for the design
10//! decisions behind the AST shape, the field/variant choices made up
11//! front to keep the follow-up crates non-breaking, and the open
12//! questions deferred to the parser crate (#2054).
13//!
14//! # Dependency policy
15//!
16//! Like `chordsketch-chordpro`, this crate has **zero external
17//! dependencies**. Mirrors the policy that anchors the core AST in the
18//! standard library so downstream crates inherit a minimal compile
19//! surface and a stable transitive-dep tree.
20
21#![forbid(unsafe_code)]
22
23pub mod ast;
24pub mod json;
25pub mod parser;
26pub mod serialize;
27
28// Re-export the AST types so call sites can write
29// `chordsketch_ireal::IrealSong` instead of
30// `chordsketch_ireal::ast::IrealSong`. Mirrors the re-export style
31// `chordsketch-chordpro` uses for its frequently-typed names.
32pub use ast::{
33    Accidental, Bar, BarChord, BarChordKind, BarLine, BeatGrouping, BeatPosition, Chord,
34    ChordQuality, ChordRoot, ChordSize, Ending, IrealSong, JumpTarget, KeyMode, KeySignature,
35    MusicalSymbol, Section, SectionLabel, StaffText, TimeSignature,
36};
37pub use json::{FromJson, JsonError, JsonValue, ToJson, parse_json};
38pub use parser::{ParseError, parse, parse_collection};
39pub use serialize::{
40    irealb_serialize, irealbook_serialize, serialize_open_protocol,
41    serialize_open_protocol_collection,
42};
43
44/// Returns the library version (the workspace `Cargo.toml` `version`
45/// field, baked in at compile time).
46#[must_use]
47pub fn version() -> &'static str {
48    env!("CARGO_PKG_VERSION")
49}