@@ -8,16 +8,17 @@ use std::borrow::Cow;
88use anyhow:: Result ;
99
1010/// This is used by dracut.
11- pub ( crate ) const INITRD_ARG_PREFIX : & str = "rd." ;
11+ pub const INITRD_ARG_PREFIX : & str = "rd." ;
1212/// The kernel argument for configuring the rootfs flags.
13- pub ( crate ) const ROOTFLAGS : & str = "rootflags" ;
13+ pub const ROOTFLAGS : & str = "rootflags" ;
1414
1515/// A parsed kernel command line.
1616///
1717/// Wraps the raw command line bytes and provides methods for parsing and iterating
1818/// over individual parameters. Uses copy-on-write semantics to avoid unnecessary
1919/// allocations when working with borrowed data.
20- pub ( crate ) struct Cmdline < ' a > ( Cow < ' a , [ u8 ] > ) ;
20+ #[ derive( Debug ) ]
21+ pub struct Cmdline < ' a > ( Cow < ' a , [ u8 ] > ) ;
2122
2223impl < ' a , T : AsRef < [ u8 ] > + ?Sized > From < & ' a T > for Cmdline < ' a > {
2324 /// Creates a new `Cmdline` from any type that can be referenced as bytes.
@@ -128,7 +129,7 @@ impl<'a> Cmdline<'a> {
128129///
129130/// Handles quoted values and treats dashes and underscores in keys as equivalent.
130131#[ derive( Debug , Eq ) ]
131- pub ( crate ) struct ParameterKey < ' a > ( & ' a [ u8 ] ) ;
132+ pub struct ParameterKey < ' a > ( & ' a [ u8 ] ) ;
132133
133134impl < ' a > std:: ops:: Deref for ParameterKey < ' a > {
134135 type Target = [ u8 ] ;
@@ -148,7 +149,7 @@ impl<'a> From<&'a [u8]> for ParameterKey<'a> {
148149///
149150/// Otherwise the same as [`ParameterKey`].
150151#[ derive( Debug , Eq ) ]
151- pub ( crate ) struct ParameterKeyStr < ' a > ( & ' a str ) ;
152+ pub struct ParameterKeyStr < ' a > ( & ' a str ) ;
152153
153154impl < ' a > From < & ' a str > for ParameterKeyStr < ' a > {
154155 fn from ( value : & ' a str ) -> Self {
@@ -158,7 +159,7 @@ impl<'a> From<&'a str> for ParameterKeyStr<'a> {
158159
159160/// A single kernel command line parameter.
160161#[ derive( Debug , Eq ) ]
161- pub ( crate ) struct Parameter < ' a > {
162+ pub struct Parameter < ' a > {
162163 /// The full original value
163164 pub parameter : & ' a [ u8 ] ,
164165 /// The parameter key as raw bytes
@@ -169,7 +170,7 @@ pub(crate) struct Parameter<'a> {
169170
170171/// A single kernel command line parameter.
171172#[ derive( Debug , PartialEq , Eq ) ]
172- pub ( crate ) struct ParameterStr < ' a > {
173+ pub struct ParameterStr < ' a > {
173174 /// The original value
174175 pub parameter : & ' a str ,
175176 /// The parameter key
@@ -179,6 +180,9 @@ pub(crate) struct ParameterStr<'a> {
179180}
180181
181182impl < ' a > Parameter < ' a > {
183+ /// Convert this parameter to a UTF-8 string parameter, if possible.
184+ ///
185+ /// Returns `None` if the parameter contains invalid UTF-8.
182186 pub fn to_str ( & self ) -> Option < ParameterStr < ' a > > {
183187 let Ok ( parameter) = std:: str:: from_utf8 ( self . parameter ) else {
184188 return None ;
0 commit comments