Skip to main content

Crate chordsketch_convert

Crate chordsketch_convert 

Source
Expand description

ChordPro ↔ iReal Pro format-conversion bridge.

Bidirectional converter tracked under #2050. Both directions are now implemented:

§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());

Re-exports§

pub use error::ConversionError;
pub use error::ConversionWarning;
pub use error::WarningKind;
pub use ireal::ChordProToIreal;
pub use ireal::IrealToChordPro;
pub use ireal::chordpro_to_ireal;
pub use ireal::ireal_to_chordpro;

Modules§

error
Error and warning types shared by every conversion direction.
from_ireal
iReal Pro → ChordPro conversion (#2053).
ireal
ChordPro ↔ iReal Pro converter dispatch.
to_ireal
ChordPro → iReal Pro conversion (#2061).

Structs§

ConversionOutput
Result of a successful conversion.

Traits§

Converter
A converter that transforms Source into Target.

Functions§

version
Returns the library version (the workspace Cargo.toml version field, baked in at compile time).