1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! ChordPro ↔ iReal Pro format-conversion bridge.
//!
//! Bidirectional converter tracked under
//! [#2050](https://github.com/koedame/chordsketch/issues/2050).
//! Both directions are now implemented:
//!
//! - **iReal → ChordPro** ([#2053](https://github.com/koedame/chordsketch/issues/2053))
//! — near-lossless; lives in [`crate::from_ireal`].
//! - **ChordPro → iReal** ([#2061](https://github.com/koedame/chordsketch/issues/2061))
//! — lossy (lyrics drop, fonts / colours / capo dropped); lives
//! in [`crate::to_ireal`]. Every drop surfaces as a
//! [`ConversionWarning`] so callers never silently lose data.
//!
//! # Layout
//!
//! - [`Converter`] is the generic trait every direction implements.
//! Free functions [`chordpro_to_ireal`] and [`ireal_to_chordpro`]
//! wrap the trait implementations for ergonomics. New formats
//! (MusicXML, Guitar Pro, etc.) plug in as additional `Converter`
//! implementations or as their own crates that depend on this one
//! for the warning / error vocabulary.
//! - [`ConversionOutput`] pairs the converted value with a
//! [`ConversionWarning`] list so callers can surface lossy
//! transformations without parsing the error type.
//! - [`ConversionError`] enumerates the reasons a conversion can
//! fail. The `NotImplemented` variant is the placeholder every
//! pre-implementation function currently returns.
//!
//! # Why a separate crate from `chordsketch-convert-musicxml`
//!
//! `chordsketch-convert-musicxml` predates this crate and binds the
//! ChordPro AST to MusicXML directly via free functions. The new
//! `chordsketch-convert` crate is the conversion home for formats
//! that share a small intermediate concept set (warnings, lossy
//! drops, approximations) — namely the ChordPro ↔ iReal bridge and
//! its expected MusicXML / Guitar Pro siblings. Consolidating the
//! musicxml converter into this crate is tracked in a future
//! cleanup; it would be a breaking change that does not block
//! v0.3.0.
//!
//! # Stability
//!
//! Pre-1.0 — the trait surface is intentionally narrow so the
//! follow-up issues can fill in implementations without breaking
//! the bindings or CLI. [`ConversionError`] and [`WarningKind`]
//! are both `#[non_exhaustive]`, so adding a new variant is
//! non-breaking for downstream `match` expressions; renaming an
//! existing variant remains breaking.
//!
//! # Example
//!
//! ```
//! use chordsketch_chordpro::ast::Song;
//! use chordsketch_convert::chordpro_to_ireal;
//!
//! let song = Song::new();
//! let result = chordpro_to_ireal(&song).expect("conversion succeeds");
//! // An empty source produces an empty `IrealSong` with no
//! // warnings — there is no metadata, no lyrics, and no
//! // sections to drop.
//! assert!(result.warnings.is_empty());
//! ```
pub use ;
pub use ;
/// Result of a successful conversion.
///
/// `output` is the converted value; `warnings` is the list of
/// information lost or approximated during the transformation. An
/// empty `warnings` vector indicates a clean (lossless) conversion;
/// callers that prefer fail-fast behaviour can promote any non-empty
/// warning list to an error themselves.
/// A converter that transforms `Source` into `Target`.
///
/// Implementations live alongside the source / target types — the
/// ChordPro ↔ iReal pair is in [`crate::ireal`]. Adding a new
/// direction means implementing `Converter<S, T>` for a new unit
/// struct (or extending an existing one) and re-exporting an
/// ergonomic free function from this crate's root.
///
/// # Why a trait in addition to free functions
///
/// The free functions in [`crate::ireal`] are the ergonomic entry
/// point for a known direction. The trait exists for two callers
/// the free functions cannot serve:
///
/// - **Generic dispatch.** A future pipeline that runs the same
/// ChordSketch `Song` through several converters
/// (`Vec<Box<dyn Converter<Song, MusicXml>>>` etc.) needs a
/// uniform type to hold them. The CLI auto-detect path (#2066)
/// is the first concrete consumer.
/// - **Configurable converters.** Once #2053 / #2061 land, an
/// implementation may need configuration (strictness level,
/// warning thresholds). A marker struct with fields holds that
/// state; the free function then becomes a thin wrapper around
/// the default-configured marker. Keeping the trait in place
/// from day one avoids a breaking re-shape later.
///
/// # Errors
///
/// Implementations return [`ConversionError`]; see that type for the
/// failure-mode taxonomy. Lossy but successful conversions return
/// `Ok(ConversionOutput { warnings: [...], .. })`, not `Err` — the
/// caller decides whether warnings should be promoted to errors.
/// Returns the library version (the workspace `Cargo.toml`
/// `version` field, baked in at compile time).