@@ -38,13 +38,14 @@ fn dequote(value: &str) -> Option<String> {
38
38
Some ( result)
39
39
}
40
40
41
- pub ( crate ) struct OsReleaseInfo < ' a > {
41
+ #[ derive( Debug ) ]
42
+ pub struct OsReleaseInfo < ' a > {
42
43
map : HashMap < & ' a str , & ' a str > ,
43
44
}
44
45
45
46
impl < ' a > OsReleaseInfo < ' a > {
46
47
/// Parses an /etc/os-release file
47
- pub ( crate ) fn parse ( content : & ' a str ) -> Self {
48
+ pub fn parse ( content : & ' a str ) -> Self {
48
49
let map = HashMap :: from_iter (
49
50
content
50
51
. lines ( )
@@ -56,25 +57,25 @@ impl<'a> OsReleaseInfo<'a> {
56
57
57
58
/// Looks up a key (like "PRETTY_NAME") in the os-release file and returns the properly
58
59
/// dequoted and unescaped value, if one exists.
59
- pub ( crate ) fn get_value ( & self , keys : & [ & str ] ) -> Option < String > {
60
+ pub fn get_value ( & self , keys : & [ & str ] ) -> Option < String > {
60
61
keys. iter ( )
61
62
. find_map ( |key| self . map . get ( key) . and_then ( |v| dequote ( v) ) )
62
63
}
63
64
64
65
/// Returns the value of the PRETTY_NAME, NAME, or ID field, whichever is found first.
65
- pub ( crate ) fn get_pretty_name ( & self ) -> Option < String > {
66
+ pub fn get_pretty_name ( & self ) -> Option < String > {
66
67
self . get_value ( & [ "PRETTY_NAME" , "NAME" , "ID" ] )
67
68
}
68
69
69
70
/// Returns the value of the VERSION_ID or VERSION field, whichever is found first.
70
- pub ( crate ) fn get_version ( & self ) -> Option < String > {
71
+ pub fn get_version ( & self ) -> Option < String > {
71
72
self . get_value ( & [ "VERSION_ID" , "VERSION" ] )
72
73
}
73
74
74
75
/// Combines get_pretty_name() with get_version() as specified in the Boot Loader
75
76
/// Specification to produce a boot label. This will return None if we can't find a name, but
76
77
/// failing to find a version isn't fatal.
77
- pub ( crate ) fn get_boot_label ( & self ) -> Option < String > {
78
+ pub fn get_boot_label ( & self ) -> Option < String > {
78
79
let mut result = self . get_pretty_name ( ) ?;
79
80
if let Some ( version) = self . get_version ( ) {
80
81
result. push_str ( & format ! ( " {version}" ) ) ;
0 commit comments