6
6
//!
7
7
//! See [`Http`].
8
8
9
- extern crate alloc;
10
9
use alloc:: string:: String ;
11
10
use alloc:: vec;
12
11
use alloc:: vec:: Vec ;
@@ -138,7 +137,7 @@ pub struct HttpHelper {
138
137
139
138
impl HttpHelper {
140
139
/// Create new HTTP helper instance for the given NIC handle.
141
- pub fn new ( nic_handle : Handle ) -> uefi:: Result < HttpHelper > {
140
+ pub fn new ( nic_handle : Handle ) -> uefi:: Result < Self > {
142
141
let mut binding = unsafe {
143
142
boot:: open_protocol :: < HttpBinding > (
144
143
boot:: OpenProtocolParams {
@@ -170,7 +169,7 @@ impl HttpHelper {
170
169
}
171
170
debug ! ( "http: protocol ok" ) ;
172
171
173
- Ok ( HttpHelper {
172
+ Ok ( Self {
174
173
child_handle,
175
174
binding,
176
175
protocol : Some ( protocol_res. unwrap ( ) ) ,
@@ -215,12 +214,12 @@ impl HttpHelper {
215
214
216
215
let mut tx_req = HttpRequestData {
217
216
method,
218
- url : url16. as_ptr ( ) as * const u16 ,
217
+ url : url16. as_ptr ( ) . cast :: < u16 > ( ) ,
219
218
} ;
220
219
221
220
let mut tx_hdr = Vec :: new ( ) ;
222
221
tx_hdr. push ( HttpHeader {
223
- field_name : c"Host" . as_ptr ( ) as * const u8 ,
222
+ field_name : c"Host" . as_ptr ( ) . cast :: < u8 > ( ) ,
224
223
field_value : c_hostname. as_ptr ( ) ,
225
224
} ) ;
226
225
@@ -231,7 +230,7 @@ impl HttpHelper {
231
230
if body. is_some ( ) {
232
231
let b = body. unwrap ( ) ;
233
232
tx_msg. body_length = b. len ( ) ;
234
- tx_msg. body = b. as_mut_ptr ( ) as * mut c_void ;
233
+ tx_msg. body = b. as_mut_ptr ( ) . cast :: < c_void > ( ) ;
235
234
}
236
235
237
236
let mut tx_token = HttpToken {
@@ -319,8 +318,8 @@ impl HttpHelper {
319
318
let n;
320
319
let v;
321
320
unsafe {
322
- n = CStr :: from_ptr ( ( * rx_msg. header . add ( i) ) . field_name as * const c_char ) ;
323
- v = CStr :: from_ptr ( ( * rx_msg. header . add ( i) ) . field_value as * const c_char ) ;
321
+ n = CStr :: from_ptr ( ( * rx_msg. header . add ( i) ) . field_name . cast :: < c_char > ( ) ) ;
322
+ v = CStr :: from_ptr ( ( * rx_msg. header . add ( i) ) . field_value . cast :: < c_char > ( ) ) ;
324
323
}
325
324
headers. push ( (
326
325
n. to_str ( ) . unwrap ( ) . to_lowercase ( ) ,
@@ -343,7 +342,7 @@ impl HttpHelper {
343
342
let mut body = vec ! [ 0 ; 16 * 1024 ] ;
344
343
let mut rx_msg = HttpMessage {
345
344
body_length : body. len ( ) ,
346
- body : body. as_mut_ptr ( ) as * mut c_void ,
345
+ body : body. as_mut_ptr ( ) . cast :: < c_void > ( ) ,
347
346
..Default :: default ( )
348
347
} ;
349
348
0 commit comments