@@ -349,7 +349,7 @@ impl Body {
349
349
Ok ( serde_urlencoded:: from_str ( & s) . status ( StatusCode :: UnprocessableEntity ) ?)
350
350
}
351
351
352
- /// Create a `Body` from a file.
352
+ /// Create a `Body` from a file named by a path .
353
353
///
354
354
/// The Mime type is sniffed from the file contents if possible, otherwise
355
355
/// it is inferred from the path's extension if possible, otherwise is set
@@ -362,17 +362,17 @@ impl Body {
362
362
/// use http_types::{Body, Response, StatusCode};
363
363
///
364
364
/// let mut res = Response::new(StatusCode::Ok);
365
- /// res.set_body(Body::from_file ("/path/to/file").await?);
365
+ /// res.set_body(Body::from_path ("/path/to/file").await?);
366
366
/// # Ok(()) }) }
367
367
/// ```
368
368
#[ cfg( all( feature = "fs" , not( target_os = "unknown" ) ) ) ]
369
- pub async fn from_file < P > ( path : P ) -> io:: Result < Self >
369
+ pub async fn from_path < P > ( path : P ) -> io:: Result < Self >
370
370
where
371
371
P : AsRef < std:: path:: Path > ,
372
372
{
373
373
let path = path. as_ref ( ) ;
374
374
let file = async_std:: fs:: File :: open ( path) . await ?;
375
- Self :: from_open_file ( file, path) . await
375
+ Self :: from_file ( file, path) . await
376
376
}
377
377
378
378
/// Create a `Body` from an already-open file.
@@ -393,11 +393,11 @@ impl Body {
393
393
/// let mut res = Response::new(StatusCode::Ok);
394
394
/// let path = std::path::Path::new("/path/to/file");
395
395
/// let file = async_std::fs::File::open(path).await?;
396
- /// res.set_body(Body::from_open_file (file, path).await?);
396
+ /// res.set_body(Body::from_file (file, path).await?);
397
397
/// # Ok(()) }) }
398
398
/// ```
399
399
#[ cfg( all( feature = "fs" , not( target_os = "unknown" ) ) ) ]
400
- pub async fn from_open_file (
400
+ pub async fn from_file (
401
401
mut file : async_std:: fs:: File ,
402
402
path : & std:: path:: Path ,
403
403
) -> io:: Result < Self > {
0 commit comments