Skip to content

Commit 176deda

Browse files
committed
Rename from_file to from_path and from_open_file to from_file.
1 parent 1d06b9b commit 176deda

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/body.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl Body {
349349
Ok(serde_urlencoded::from_str(&s).status(StatusCode::UnprocessableEntity)?)
350350
}
351351

352-
/// Create a `Body` from a file.
352+
/// Create a `Body` from a file named by a path.
353353
///
354354
/// The Mime type is sniffed from the file contents if possible, otherwise
355355
/// it is inferred from the path's extension if possible, otherwise is set
@@ -362,17 +362,17 @@ impl Body {
362362
/// use http_types::{Body, Response, StatusCode};
363363
///
364364
/// 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?);
366366
/// # Ok(()) }) }
367367
/// ```
368368
#[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>
370370
where
371371
P: AsRef<std::path::Path>,
372372
{
373373
let path = path.as_ref();
374374
let file = async_std::fs::File::open(path).await?;
375-
Self::from_open_file(file, path).await
375+
Self::from_file(file, path).await
376376
}
377377

378378
/// Create a `Body` from an already-open file.
@@ -393,11 +393,11 @@ impl Body {
393393
/// let mut res = Response::new(StatusCode::Ok);
394394
/// let path = std::path::Path::new("/path/to/file");
395395
/// 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?);
397397
/// # Ok(()) }) }
398398
/// ```
399399
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
400-
pub async fn from_open_file(
400+
pub async fn from_file(
401401
mut file: async_std::fs::File,
402402
path: &std::path::Path,
403403
) -> io::Result<Self> {

0 commit comments

Comments
 (0)