@@ -5,6 +5,30 @@ use crate::{
5
5
unsafe_guid, CStr16 , Char16 ,
6
6
} ;
7
7
8
+ /// This struct is a wrapper of `display_only` parameter
9
+ /// used by Device Path to Text protocol.
10
+ ///
11
+ /// The `display_only` parameter controls whether the longer
12
+ /// (parseable) or shorter (display-only) form of the conversion
13
+ /// is used. If `display_only` is TRUE, then the shorter text
14
+ /// representation of the display node is used, where applicable.
15
+ /// If `display_only` is FALSE, then the longer text representation
16
+ /// of the display node is used.
17
+ #[ derive( Clone , Copy ) ]
18
+ pub struct DisplayOnly ( pub bool ) ;
19
+
20
+ /// This struct is a wrapper of `allow_shortcuts` parameter
21
+ /// used by Device Path to Text protocol.
22
+ ///
23
+ /// The `allow_shortcuts` is FALSE, then the shortcut forms of
24
+ /// text representation for a device node cannot be used. A
25
+ /// shortcut form is one which uses information other than the
26
+ /// type or subtype. If `allow_shortcuts is TRUE, then the
27
+ /// shortcut forms of text representation for a device node
28
+ /// can be used, where applicable.
29
+ #[ derive( Clone , Copy ) ]
30
+ pub struct AllowShortcuts ( pub bool ) ;
31
+
8
32
/// Device Path to Text protocol.
9
33
///
10
34
/// This protocol provides common utility functions for converting device
@@ -28,54 +52,32 @@ pub struct DevicePathToText {
28
52
impl DevicePathToText {
29
53
/// Convert a device node to its text representation.
30
54
///
31
- /// The `display_only` parameter controls whether the longer (parseable) or
32
- /// shorter (display-only) form of the conversion is used. If `display_only`
33
- /// is TRUE, then the shorter text representation of the display node is
34
- /// used, where applicable. If `display_only` is FALSE, then the longer text
35
- /// representation of the display node is used.
36
- ///
37
- /// The `allow_shortcuts` is FALSE, then the shortcut forms of text
38
- /// representation for a device node cannot be used. A shortcut form
39
- /// is one which uses information other than the type or subtype. If
40
- /// `allow_shortcuts is TRUE, then the shortcut forms of text
41
- /// representation for a device node can be used, where applicable.
42
- ///
43
- /// Returns `None` if `device_node` was NULL or there was insufficient memory.
55
+ /// Returns `None` if `device_node` was NULL or there was
56
+ /// insufficient memory.
44
57
pub fn convert_device_node_to_text (
45
58
& self ,
46
59
device_node : & DevicePath ,
47
- display_only : bool ,
48
- allow_shortcuts : bool ,
60
+ display_only : DisplayOnly ,
61
+ allow_shortcuts : AllowShortcuts ,
49
62
) -> Option < & CStr16 > {
50
63
let text_device_node = unsafe {
51
- ( self . convert_device_node_to_text ) ( device_node, display_only, allow_shortcuts)
64
+ ( self . convert_device_node_to_text ) ( device_node, display_only. 0 , allow_shortcuts. 0 )
52
65
} ;
53
66
unsafe { Some ( CStr16 :: from_ptr ( text_device_node. as_ref ( ) ?) ) }
54
67
}
55
68
56
69
/// Convert a device path to its text representation.
57
70
///
58
- /// The `display_only` parameter controls whether the longer (parseable) or
59
- /// shorter (display-only) form of the conversion is used. If `display_only`
60
- /// is TRUE, then the shorter text representation of the display node is
61
- /// used, where applicable. If `display_only` is FALSE, then the longer text
62
- /// representation of the display node is used.
63
- ///
64
- /// The `allow_shortcuts` is FALSE, then the shortcut forms of text
65
- /// representation for a device node cannot be used. A shortcut form
66
- /// is one which uses information other than the type or subtype. If
67
- /// `allow_shortcuts is TRUE, then the shortcut forms of text
68
- /// representation for a device node can be used, where applicable.
69
- ///
70
- /// Returns `None` if `device_path` was NULL or there was insufficient memory.
71
+ /// Returns `None` if `device_path` was NULL or there was
72
+ /// insufficient memory.
71
73
pub fn convert_device_path_to_text (
72
74
& self ,
73
75
device_path : & DevicePath ,
74
- display_only : bool ,
75
- allow_shortcuts : bool ,
76
+ display_only : DisplayOnly ,
77
+ allow_shortcuts : AllowShortcuts ,
76
78
) -> Option < & CStr16 > {
77
79
let text_device_path = unsafe {
78
- ( self . convert_device_path_to_text ) ( device_path, display_only, allow_shortcuts)
80
+ ( self . convert_device_path_to_text ) ( device_path, display_only. 0 , allow_shortcuts. 0 )
79
81
} ;
80
82
unsafe { Some ( CStr16 :: from_ptr ( text_device_path. as_ref ( ) ?) ) }
81
83
}
0 commit comments