Skip to content

Commit b01ffa8

Browse files
jeckersbcgwalters
authored andcommitted
kernel_cmdline: Add some more derives for Cmdline
Prep so we can parse these directly via clap Signed-off-by: John Eckersberg <[email protected]>
1 parent 051a881 commit b01ffa8

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/kernel_cmdline/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repository = "https://github.com/bootc-dev/bootc"
99
[dependencies]
1010
# Workspace dependencies
1111
anyhow = { workspace = true }
12+
serde = { workspace = true, features = ["derive"] }
1213

1314
[dev-dependencies]
1415
similar-asserts = { workspace = true }

crates/kernel_cmdline/src/bytes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ use std::ops::Deref;
99
use crate::{utf8, Action};
1010

1111
use anyhow::Result;
12+
use serde::{Deserialize, Serialize};
1213

1314
/// A parsed kernel command line.
1415
///
1516
/// Wraps the raw command line bytes and provides methods for parsing and iterating
1617
/// over individual parameters. Uses copy-on-write semantics to avoid unnecessary
1718
/// allocations when working with borrowed data.
18-
#[derive(Clone, Debug, Default)]
19+
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
1920
pub struct Cmdline<'a>(Cow<'a, [u8]>);
2021

2122
/// An owned Cmdline. Alias for `Cmdline<'static>`.

crates/kernel_cmdline/src/utf8.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ use std::ops::Deref;
88
use crate::{bytes, Action};
99

1010
use anyhow::Result;
11+
use serde::{Deserialize, Serialize};
1112

1213
/// A parsed UTF-8 kernel command line.
1314
///
1415
/// Wraps the raw command line bytes and provides methods for parsing and iterating
1516
/// over individual parameters. Uses copy-on-write semantics to avoid unnecessary
1617
/// allocations when working with borrowed data.
17-
#[derive(Clone, Debug, Default)]
18+
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
1819
pub struct Cmdline<'a>(bytes::Cmdline<'a>);
1920

2021
/// An owned `Cmdline`. Alias for `Cmdline<'static>`.

0 commit comments

Comments
 (0)