jaml/lib.rs
1//! A Rust library for parsing and formatting JAML (Just Another Markup Language).
2//!
3//! JAML is a human-readable data serialization format similar to YAML but with explicit integer and binary types.
4//! It shares the same data model as JASN, providing a YAML-like syntax as an alternative to the JSON5-like JASN format.
5//!
6//! # Features
7//! 1. **Explicit Integer Types**: Distinguish between integers and floats (2 vs 2.0).
8//! 2. **Binary Data**: Support for base64 and hex-encoded binary data
9//! 3. **Timestamps**: ISO8601/RFC3339 timestamps
10//! 4. **YAML-inspired syntax**: Indentation-based structure, cleaner appearance
11//!
12//! # Usage
13//!
14//! ## AST Manipulation (no serde required)
15//!
16//! ```rust
17//! use jaml::{parse, format};
18//!
19//! fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! let value = parse(r#"
21//! name: "Alice"
22//! age: 30
23//! balance: 1234.56
24//! data: b64"SGVsbG8="
25//! tags:
26//! - "rust"
27//! - "yaml"
28//! - "parser"
29//! "#)?;
30//!
31//! println!("{:#?}", value);
32//!
33//! // Format back to JAML
34//! let formatted = format(&value);
35//! println!("{}", formatted);
36//! Ok(())
37//! }
38//! ```
39//!
40//! ## Serde Integration (default feature)
41//!
42//! ```
43//! use serde::{Deserialize, Serialize};
44//!
45//! #[derive(Serialize, Deserialize)]
46//! struct Person {
47//! name: String,
48//! age: u32,
49//! }
50//!
51//! let person = Person { name: "Alice".into(), age: 30 };
52//! let jaml_text = jaml::to_string(&person).unwrap();
53//! let parsed: Person = jaml::from_str(&jaml_text).unwrap();
54//! ```
55//!
56//! # Features
57//!
58//! - `serde` (default): Enable serde serialization/deserialization support
59
60#![warn(missing_docs)]
61
62// Re-export core types
63pub use jasn_core::{Binary, Timestamp, Value};
64
65pub mod formatter;
66mod parser;
67
68pub use formatter::{format, format_with_opts};
69pub use parser::{Error as ParseError, Result as ParseResult, parse};
70
71#[cfg(feature = "serde")]
72pub mod de;
73#[cfg(feature = "serde")]
74pub mod ser;
75
76#[cfg(feature = "serde")]
77pub use de::{from_str, from_value};
78#[cfg(feature = "serde")]
79pub use ser::{to_string, to_string_pretty, to_value};