1010// if there is insufficient memory. So we treat any NULL output as an
1111// `OUT_OF_RESOURCES` error.
1212
13+ use crate :: data_types:: PoolString ;
1314use crate :: mem:: PoolAllocation ;
1415use crate :: proto:: device_path:: { DevicePath , DevicePathNode } ;
1516use crate :: proto:: unsafe_protocol;
16- use crate :: { CStr16 , Char16 , Result , Status } ;
17- use core:: ops:: Deref ;
17+ use crate :: { CStr16 , Result , Status } ;
1818use core:: ptr:: NonNull ;
1919use uefi_raw:: protocol:: device_path:: { DevicePathFromTextProtocol , DevicePathToTextProtocol } ;
2020
@@ -47,31 +47,6 @@ pub struct DisplayOnly(pub bool);
4747#[ derive( Clone , Copy , Debug ) ]
4848pub struct AllowShortcuts ( pub bool ) ;
4949
50- /// UCS-2 string allocated from UEFI pool memory.
51- ///
52- /// This is similar to a [`CString16`], but used for memory that was allocated
53- /// internally by UEFI rather than the Rust allocator.
54- ///
55- /// [`CString16`]: crate::CString16
56- #[ derive( Debug ) ]
57- pub struct PoolString ( PoolAllocation ) ;
58-
59- impl PoolString {
60- fn new ( text : * const Char16 ) -> Result < Self > {
61- NonNull :: new ( text. cast_mut ( ) )
62- . map ( |p| Self ( PoolAllocation :: new ( p. cast ( ) ) ) )
63- . ok_or ( Status :: OUT_OF_RESOURCES . into ( ) )
64- }
65- }
66-
67- impl Deref for PoolString {
68- type Target = CStr16 ;
69-
70- fn deref ( & self ) -> & Self :: Target {
71- unsafe { CStr16 :: from_ptr ( self . 0 . as_ptr ( ) . as_ptr ( ) . cast ( ) ) }
72- }
73- }
74-
7550/// Protocol for converting a [`DevicePath`] or `DevicePathNode`] to a string.
7651#[ derive( Debug ) ]
7752#[ repr( transparent) ]
@@ -98,7 +73,7 @@ impl DevicePathToText {
9873 allow_shortcuts. 0 . into ( ) ,
9974 )
10075 } ;
101- PoolString :: new ( text. cast ( ) )
76+ unsafe { PoolString :: new ( text. cast ( ) ) }
10277 }
10378
10479 /// Convert a [`DevicePath`] to a [`PoolString`].
@@ -120,7 +95,7 @@ impl DevicePathToText {
12095 allow_shortcuts. 0 . into ( ) ,
12196 )
12297 } ;
123- PoolString :: new ( text. cast ( ) )
98+ unsafe { PoolString :: new ( text. cast ( ) ) }
12499 }
125100}
126101
0 commit comments