clean code

This commit is contained in:
2025-09-06 19:16:30 +09:00
parent 8e4b6be991
commit 602411dbdb
9 changed files with 18 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
use crate::http::counter::{AtomicHttpCounter, HttpCounter};
use crate::http::counter::AtomicHttpCounter;
use crate::http::header_config::HeadersConfig;
use crate::http::simple::HttpSwardArray;
use crate::http::{RandomUrlGenerator, SimpleHttpRequest, SimpleHttpSward};
@@ -166,7 +166,7 @@ impl IntegratedHttpSwardBuilder {
// get the cookie
let maybe_cookie = self
.headers_config
.get_cookie_jar(&url_example)
.get_cookie_jar(url_example)
.map(Arc::new);
// build the clients

View File

@@ -1,9 +1,9 @@
pub mod counter;
pub mod header_config;
pub mod integrated;
pub mod random;
pub mod simple;
pub mod integrated;
pub mod header_config;
pub mod counter;
pub use integrated::IntegratedHttpSward;
pub use random::RandomUrlGenerator;
pub use simple::{SimpleHttpRequest, SimpleHttpSward};
pub use integrated::IntegratedHttpSward;

View File

@@ -3,6 +3,6 @@
#![deny(clippy::expect_used)]
pub mod http;
pub mod utils;
pub mod tcp;
pub mod udp;
pub mod utils;

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1 @@

View File

@@ -1,5 +1,5 @@
use rand::RngCore;
use crate::udp::{BoxedUdpRequest, SizedUdpRequest};
use rand::RngCore;
pub struct RandomUdpWorkloadGenerator<Rng: RngCore> {
rng: Rng,
@@ -12,9 +12,7 @@ impl<Rng: RngCore> RandomUdpWorkloadGenerator<Rng> {
pub fn generate_sized<const SIZE: usize>(&mut self) -> SizedUdpRequest<SIZE> {
let mut buf = [0u8; SIZE];
self.rng.fill_bytes(&mut buf);
SizedUdpRequest {
bytes: buf
}
SizedUdpRequest { bytes: buf }
}
pub fn generate_boxed(&mut self, size: usize) -> BoxedUdpRequest {
let mut buf = vec![0u8; size].into_boxed_slice();

View File

@@ -1,7 +1,7 @@
mod counter;
pub mod generator;
pub mod integrated;
pub mod random_flood;
mod counter;
pub use generator::RandomUdpWorkloadGenerator;
pub use integrated::IntegratedUdpSward;

View File

@@ -36,9 +36,7 @@ impl<const N: usize> Service<SizedUdpRequest<N>> for UdpSward {
fn call(&mut self, req: SizedUdpRequest<N>) -> Self::Future {
self.sent_count += 1;
let socket = self.socket.clone();
Box::pin(async move {
socket.send(&req.bytes).await
})
Box::pin(async move { socket.send(&req.bytes).await })
}
}
@@ -55,9 +53,7 @@ impl Service<BoxedUdpRequest> for UdpSward {
fn call(&mut self, req: BoxedUdpRequest) -> Self::Future {
self.sent_count += 1;
let socket = self.socket.clone();
Box::pin(async move {
socket.send(&req.0).await
})
Box::pin(async move { socket.send(&req.0).await })
}
}