feat(serde): Add Serde support (#83)

Co-authored-by: Miles Wirht <114884788+philocalyst@users.noreply.github.com>
Co-authored-by: Horu <73709188+HigherOrderLogic@users.noreply.github.com>
This commit is contained in:
Kat Marchán 2026-05-28 21:49:30 -07:00 committed by GitHub
parent 01183642a7
commit 92998aac93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 3328 additions and 7 deletions

View File

@ -28,7 +28,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [1.82, stable]
rust: [1.95, stable]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:

1
Cargo.lock generated
View File

@ -399,6 +399,7 @@ dependencies = [
"miette 7.6.0",
"num",
"pretty_assertions",
"serde",
"thiserror 2.0.17",
"winnow",
]

View File

@ -8,11 +8,11 @@ readme = "README.md"
homepage = "https://kdl.dev"
repository = "https://github.com/kdl-org/kdl-rs"
keywords = ["kdl", "document", "serialization", "config"]
rust-version = "1.82"
rust-version = "1.95"
edition = "2021"
[features]
default = ["span"]
default = ["span", "serde"]
span = []
v1-fallback = ["v1"]
v1 = ["kdlv1"]
@ -23,6 +23,7 @@ members = ["tools/*"]
[dependencies]
miette.workspace = true
num = "0.4.2"
serde = { version = "1.0.210", optional = true }
winnow = { version = "0.7.13", features = ["alloc", "unstable-recover"] }
kdlv1 = { package = "kdl", version = "4.7.0", optional = true }
@ -33,6 +34,7 @@ miette = { version = "7.6.0", default-features = false }
miette = { workspace = true, features = ["derive", "fancy"] }
thiserror = "2.0.12"
pretty_assertions = "1.3.0"
serde = { version = "1.0.210", features = ["derive"] }
# The profile that 'dist' will build with
[profile.dist]

View File

@ -1 +1 @@
msrv = "1.82"
msrv = "1.95"

1669
src/de.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -140,7 +140,7 @@
//!
//! ## Minimum Supported Rust Version (MSRV)
//!
//! You must be at least `1.82` tall to get on this ride.
//! You must be at least `1.95` tall to get on this ride.
//!
//! ## License
//!
@ -209,3 +209,8 @@ mod node;
mod value;
mod v2_parser;
#[cfg(feature = "serde")]
pub mod de;
#[cfg(feature = "serde")]
pub mod se;

1644
src/se.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -380,12 +380,12 @@ fn base_node(input: &mut Input<'_>) -> PResult<KdlNode> {
// _both_ the error message for a string/ident parser error _and_ the error
// message for a node name being expected.
if !name_is_valid {
resume_after_cut(|input: &mut Input<'_>| -> PResult<()> {
resume_after_cut((|input: &mut Input<'_>| -> PResult<()> {
Err(ErrMode::Cut(KdlParseError {
span: Some(span_from_checkpoint(input, &_before_ident)),
..Default::default()
}))
}.context(cx().msg("Found invalid node name")
}).context(cx().msg("Found invalid node name")
.lbl("node name")
.hlp("This can be any string type, including a quoted, raw, or multiline string, as well as a plain identifier string.")),
empty).parse_next(input)?;