Skip to content

Commit 1c95dd5

Browse files
committed
Replace parameters to wrapper.
1 parent fa91d55 commit 1c95dd5

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

src/proto/device_path/text.rs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ use crate::{
55
unsafe_guid, CStr16, Char16,
66
};
77

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+
832
/// Device Path to Text protocol.
933
///
1034
/// This protocol provides common utility functions for converting device
@@ -28,54 +52,32 @@ pub struct DevicePathToText {
2852
impl DevicePathToText {
2953
/// Convert a device node to its text representation.
3054
///
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.
4457
pub fn convert_device_node_to_text(
4558
&self,
4659
device_node: &DevicePath,
47-
display_only: bool,
48-
allow_shortcuts: bool,
60+
display_only: DisplayOnly,
61+
allow_shortcuts: AllowShortcuts,
4962
) -> Option<&CStr16> {
5063
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)
5265
};
5366
unsafe { Some(CStr16::from_ptr(text_device_node.as_ref()?)) }
5467
}
5568

5669
/// Convert a device path to its text representation.
5770
///
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.
7173
pub fn convert_device_path_to_text(
7274
&self,
7375
device_path: &DevicePath,
74-
display_only: bool,
75-
allow_shortcuts: bool,
76+
display_only: DisplayOnly,
77+
allow_shortcuts: AllowShortcuts,
7678
) -> Option<&CStr16> {
7779
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)
7981
};
8082
unsafe { Some(CStr16::from_ptr(text_device_path.as_ref()?)) }
8183
}

0 commit comments

Comments
 (0)