Use idiomatic feature names & namespace support from Rust 1.60

This commit is contained in:
Joakim Frostegård 2022-04-10 01:25:03 +02:00
parent fc9211835e
commit c229872134
12 changed files with 22 additions and 29 deletions

View file

@ -12,9 +12,7 @@ readme = "../README.md"
name = "aquatic_common" name = "aquatic_common"
[features] [features]
with-glommio = ["glommio"] rustls = ["dep:rustls", "rustls-pemfile"]
with-hwloc = ["hwloc"]
rustls-config = ["rustls", "rustls-pemfile"]
[dependencies] [dependencies]
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }
@ -38,7 +36,5 @@ toml = "0.5"
# Optional # Optional
glommio = { version = "0.7", optional = true } glommio = { version = "0.7", optional = true }
hwloc = { version = "0.5", optional = true } hwloc = { version = "0.5", optional = true }
# rustls-config
rustls = { version = "0.20", optional = true } rustls = { version = "0.20", optional = true }
rustls-pemfile = { version = "0.3", optional = true } rustls-pemfile = { version = "0.3", optional = true }

View file

@ -16,7 +16,7 @@ impl Default for CpuPinningDirection {
} }
} }
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
#[derive(Clone, Copy, Debug, PartialEq, TomlConfig, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, TomlConfig, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum HyperThreadMapping { pub enum HyperThreadMapping {
@ -25,7 +25,7 @@ pub enum HyperThreadMapping {
Split, Split,
} }
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
impl Default for HyperThreadMapping { impl Default for HyperThreadMapping {
fn default() -> Self { fn default() -> Self {
Self::System Self::System
@ -35,7 +35,7 @@ impl Default for HyperThreadMapping {
pub trait CpuPinningConfig { pub trait CpuPinningConfig {
fn active(&self) -> bool; fn active(&self) -> bool;
fn direction(&self) -> CpuPinningDirection; fn direction(&self) -> CpuPinningDirection;
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
fn hyperthread(&self) -> HyperThreadMapping; fn hyperthread(&self) -> HyperThreadMapping;
fn core_offset(&self) -> usize; fn core_offset(&self) -> usize;
} }
@ -54,7 +54,7 @@ pub mod mod_name {
pub struct struct_name { pub struct struct_name {
pub active: bool, pub active: bool,
pub direction: CpuPinningDirection, pub direction: CpuPinningDirection,
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
pub hyperthread: HyperThreadMapping, pub hyperthread: HyperThreadMapping,
pub core_offset: usize, pub core_offset: usize,
} }
@ -64,7 +64,7 @@ pub mod mod_name {
Self { Self {
active: false, active: false,
direction: cpu_pinning_direction, direction: cpu_pinning_direction,
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
hyperthread: Default::default(), hyperthread: Default::default(),
core_offset: 0, core_offset: 0,
} }
@ -77,7 +77,7 @@ pub mod mod_name {
fn direction(&self) -> CpuPinningDirection { fn direction(&self) -> CpuPinningDirection {
self.direction self.direction
} }
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
fn hyperthread(&self) -> HyperThreadMapping { fn hyperthread(&self) -> HyperThreadMapping {
self.hyperthread self.hyperthread
} }
@ -119,7 +119,7 @@ impl WorkerIndex {
} }
} }
#[cfg(feature = "with-glommio")] #[cfg(feature = "glommio")]
pub mod glommio { pub mod glommio {
use ::glommio::{CpuSet, Placement}; use ::glommio::{CpuSet, Placement};
@ -271,7 +271,7 @@ pub mod glommio {
/// Pin current thread to a suitable core /// Pin current thread to a suitable core
/// ///
/// Requires hwloc (`apt-get install libhwloc-dev`) /// Requires hwloc (`apt-get install libhwloc-dev`)
#[cfg(feature = "with-hwloc")] #[cfg(feature = "hwloc")]
pub fn pin_current_if_configured_to<C: CpuPinningConfig>( pub fn pin_current_if_configured_to<C: CpuPinningConfig>(
config: &C, config: &C,
socket_workers: usize, socket_workers: usize,

View file

@ -10,7 +10,7 @@ pub mod access_list;
pub mod cli; pub mod cli;
pub mod cpu_pinning; pub mod cpu_pinning;
pub mod privileges; pub mod privileges;
#[cfg(feature = "rustls-config")] #[cfg(feature = "rustls")]
pub mod rustls_config; pub mod rustls_config;
/// Amortized IndexMap using AHash hasher /// Amortized IndexMap using AHash hasher

View file

@ -16,7 +16,7 @@ name = "aquatic_http"
name = "aquatic_http" name = "aquatic_http"
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls-config", "with-glommio"] } aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls", "glommio"] }
aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol" } aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol" }
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }

View file

@ -13,7 +13,7 @@ readme = "../README.md"
name = "aquatic_http_load_test" name = "aquatic_http_load_test"
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["with-glommio"] } aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["glommio"] }
aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol" } aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol" }
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }

View file

@ -14,8 +14,8 @@ name = "aquatic_http_private"
name = "aquatic_http_private" name = "aquatic_http_private"
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls-config"] } aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls"] }
aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol", features = ["with-axum"] } aquatic_http_protocol = { version = "0.2.0", path = "../aquatic_http_protocol", features = ["axum"] }
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }
anyhow = "1" anyhow = "1"

View file

@ -22,9 +22,6 @@ name = "bench_announce_response_to_bytes"
path = "benches/bench_announce_response_to_bytes.rs" path = "benches/bench_announce_response_to_bytes.rs"
harness = false harness = false
[features]
with-axum = ["axum"]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
axum = { version = "0.5", optional = true, default-features = false } axum = { version = "0.5", optional = true, default-features = false }

View file

@ -117,7 +117,7 @@ impl AnnounceResponse {
} }
} }
#[cfg(feature = "with-axum")] #[cfg(feature = "axum")]
impl axum::response::IntoResponse for AnnounceResponse { impl axum::response::IntoResponse for AnnounceResponse {
fn into_response(self) -> axum::response::Response { fn into_response(self) -> axum::response::Response {
let mut response_bytes = Vec::with_capacity(128); let mut response_bytes = Vec::with_capacity(128);
@ -158,7 +158,7 @@ impl ScrapeResponse {
} }
} }
#[cfg(feature = "with-axum")] #[cfg(feature = "axum")]
impl axum::response::IntoResponse for ScrapeResponse { impl axum::response::IntoResponse for ScrapeResponse {
fn into_response(self) -> axum::response::Response { fn into_response(self) -> axum::response::Response {
let mut response_bytes = Vec::with_capacity(128); let mut response_bytes = Vec::with_capacity(128);
@ -197,7 +197,7 @@ impl FailureResponse {
} }
} }
#[cfg(feature = "with-axum")] #[cfg(feature = "axum")]
impl axum::response::IntoResponse for FailureResponse { impl axum::response::IntoResponse for FailureResponse {
fn into_response(self) -> axum::response::Response { fn into_response(self) -> axum::response::Response {
let mut response_bytes = Vec::with_capacity(64); let mut response_bytes = Vec::with_capacity(64);
@ -229,7 +229,7 @@ impl Response {
} }
} }
#[cfg(feature = "with-axum")] #[cfg(feature = "axum")]
impl axum::response::IntoResponse for Response { impl axum::response::IntoResponse for Response {
fn into_response(self) -> axum::response::Response { fn into_response(self) -> axum::response::Response {
match self { match self {

View file

@ -16,7 +16,7 @@ name = "aquatic_udp"
name = "aquatic_udp" name = "aquatic_udp"
[features] [features]
cpu-pinning = ["aquatic_common/with-hwloc"] cpu-pinning = ["aquatic_common/hwloc"]
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common" } aquatic_common = { version = "0.2.0", path = "../aquatic_common" }

View file

@ -10,7 +10,7 @@ keywords = ["udp", "benchmark", "peer-to-peer", "torrent", "bittorrent"]
readme = "../README.md" readme = "../README.md"
[features] [features]
cpu-pinning = ["aquatic_common/with-hwloc"] cpu-pinning = ["aquatic_common/hwloc"]
[[bin]] [[bin]]
name = "aquatic_udp_load_test" name = "aquatic_udp_load_test"

View file

@ -16,7 +16,7 @@ name = "aquatic_ws"
name = "aquatic_ws" name = "aquatic_ws"
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls-config", "with-glommio"] } aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["rustls", "glommio"] }
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }
aquatic_ws_protocol = { version = "0.2.0", path = "../aquatic_ws_protocol" } aquatic_ws_protocol = { version = "0.2.0", path = "../aquatic_ws_protocol" }

View file

@ -13,7 +13,7 @@ readme = "../README.md"
name = "aquatic_ws_load_test" name = "aquatic_ws_load_test"
[dependencies] [dependencies]
aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["with-glommio"] } aquatic_common = { version = "0.2.0", path = "../aquatic_common", features = ["glommio"] }
aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" } aquatic_toml_config = { version = "0.2.0", path = "../aquatic_toml_config" }
aquatic_ws_protocol = { version = "0.2.0", path = "../aquatic_ws_protocol" } aquatic_ws_protocol = { version = "0.2.0", path = "../aquatic_ws_protocol" }