rename feature and add changelog

This commit is contained in:
Rob Ede 2021-11-21 21:12:25 +00:00
parent 3dfa8b0faf
commit e9554bf851
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
6 changed files with 26 additions and 24 deletions

View File

@ -65,8 +65,8 @@ rustls = ["actix-http/rustls", "actix-tls/accept", "actix-tls/rustls"]
# Don't rely on these whatsoever. They may disappear at anytime.
__compress = []
# io-uring feature only avaiable for linux OS.
io-uring = ["actix-server/io-uring"]
# io-uring feature only avaiable for Linux OSes.
experimental-io-uring = ["actix-server/io-uring"]
[dependencies]
actix-codec = "0.4.1"

View File

@ -1,8 +1,10 @@
# Changes
## Unreleased - 2021-xx-xx
* Add crate feature `experimental-io-uring`, enabling async file I/O to be utilized. This feature is only available on Linux OSes with recent kernel versions. This feature is semver-exempt. [#2408]
* Fix 304 Not Modified responses to omit the Content-Length header, as per the spec. [#2453]
[#2408]: https://github.com/actix/actix-web/pull/2408
[#2453]: https://github.com/actix/actix-web/pull/2453

View File

@ -15,7 +15,7 @@ name = "actix_files"
path = "src/lib.rs"
[features]
io-uring = ["actix-web/io-uring", "tokio-uring"]
experimental-io-uring = ["actix-web/experimental-io-uring", "tokio-uring"]
[dependencies]
actix-web = { version = "4.0.0-beta.11", default-features = false }

View File

@ -27,7 +27,7 @@ pin_project! {
}
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
pin_project! {
#[project = ChunkedReadFileStateProj]
#[project_replace = ChunkedReadFileStateProjReplace]
@ -42,7 +42,7 @@ pin_project! {
}
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
pin_project! {
#[project = ChunkedReadFileStateProj]
#[project_replace = ChunkedReadFileStateProjReplace]
@ -71,9 +71,9 @@ pub(crate) fn new_chunked_read(
ChunkedReadFile {
size,
offset,
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
state: ChunkedReadFileState::File { file: Some(file) },
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
state: ChunkedReadFileState::File {
file: Some((file, BytesMut::new())),
},
@ -82,7 +82,7 @@ pub(crate) fn new_chunked_read(
}
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
async fn chunked_read_file_callback(
mut file: File,
offset: u64,
@ -109,7 +109,7 @@ async fn chunked_read_file_callback(
Ok(res)
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
async fn chunked_read_file_callback(
file: File,
offset: u64,
@ -129,7 +129,7 @@ async fn chunked_read_file_callback(
Ok((file, bytes, bytes_mut))
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
impl<F, Fut> Stream for ChunkedReadFile<F, Fut>
where
F: Fn(File, u64, usize, BytesMut) -> Fut,
@ -178,7 +178,7 @@ where
}
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
impl<F, Fut> Stream for ChunkedReadFile<F, Fut>
where
F: Fn(File, u64, usize) -> Fut,
@ -226,12 +226,12 @@ where
}
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
use bytes_mut::BytesMut;
// TODO: remove new type and use bytes::BytesMut directly
#[doc(hidden)]
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
mod bytes_mut {
use std::ops::{Deref, DerefMut};

View File

@ -215,12 +215,12 @@ mod tests {
#[actix_rt::test]
async fn test_named_file_non_ascii_file_name() {
let file = {
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
{
crate::named::File::open("Cargo.toml").await.unwrap()
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
{
crate::named::File::open("Cargo.toml").unwrap()
}

View File

@ -88,11 +88,11 @@ impl fmt::Debug for NamedFile {
.field("path", &self.path)
.field(
"file",
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
{
&"File"
},
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
{
&self.file
},
@ -108,9 +108,9 @@ impl fmt::Debug for NamedFile {
}
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
pub(crate) use std::fs::File;
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
pub(crate) use tokio_uring::fs::File;
impl NamedFile {
@ -183,12 +183,12 @@ impl NamedFile {
};
let md = {
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
{
file.metadata()?
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
{
use std::os::unix::prelude::{AsRawFd, FromRawFd};
@ -220,7 +220,7 @@ impl NamedFile {
})
}
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
/// Attempts to open a file in read-only mode.
///
/// # Examples
@ -248,12 +248,12 @@ impl NamedFile {
/// ```
pub async fn open_async<P: AsRef<Path>>(path: P) -> io::Result<NamedFile> {
let file = {
#[cfg(not(feature = "io-uring"))]
#[cfg(not(feature = "experimental-io-uring"))]
{
File::open(&path)?
}
#[cfg(feature = "io-uring")]
#[cfg(feature = "experimental-io-uring")]
{
File::open(&path).await?
}