@@ -48,8 +48,8 @@ fn cstring16_contains_char(string: &CString16, c: char) -> bool {
4848
4949/// Parses the input `path` as a [DevicePath].
5050/// Uses the [DevicePathFromText] protocol exclusively, and will fail if it cannot acquire the protocol.
51- pub fn text_to_device_path ( path : & str ) -> Result < PoolDevicePath > {
52- let path = CString16 :: try_from ( path) . context ( "unable to convert path to CString16" ) ?;
51+ pub fn text_to_device_path ( path : impl AsRef < str > ) -> Result < PoolDevicePath > {
52+ let path = CString16 :: try_from ( path. as_ref ( ) ) . context ( "unable to convert path to CString16" ) ?;
5353 let device_path_from_text = uefi:: boot:: open_protocol_exclusive :: < DevicePathFromText > (
5454 uefi:: boot:: get_handle_for_protocol :: < DevicePathFromText > ( )
5555 . context ( "no device path from text protocol" ) ?,
@@ -113,8 +113,13 @@ pub fn device_path_subpath(path: &DevicePath) -> Result<String> {
113113/// Resolve a path specified by `input` to its various components.
114114/// Uses `default_root_path` as the base root if one is not specified in the path.
115115/// Returns [ResolvedPath] which contains the resolved components.
116- pub fn resolve_path ( default_root_path : Option < & DevicePath > , input : & str ) -> Result < ResolvedPath > {
117- let mut path = text_to_device_path ( input) . context ( "unable to convert text to path" ) ?;
116+ pub fn resolve_path (
117+ default_root_path : Option < & DevicePath > ,
118+ input : impl ToString ,
119+ ) -> Result < ResolvedPath > {
120+ let mut input = input. to_string ( ) ;
121+
122+ let mut path = text_to_device_path ( & input) . context ( "unable to convert text to path" ) ?;
118123 let path_has_device = path
119124 . node_iter ( )
120125 . next ( )
@@ -125,7 +130,6 @@ pub fn resolve_path(default_root_path: Option<&DevicePath>, input: &str) -> Resu
125130 . map ( |it| it. to_string ( ) . contains ( '(' ) )
126131 . unwrap_or ( false ) ;
127132 if !path_has_device {
128- let mut input = input. to_string ( ) ;
129133 if !input. starts_with ( '\\' ) {
130134 input. insert ( 0 , '\\' ) ;
131135 }
0 commit comments