Replace rand with fastrand, remove tracing

This commit is contained in:
asonix 2023-07-20 20:48:06 -05:00
parent b655ef8511
commit e35aa639ad
3 changed files with 4 additions and 9 deletions

View file

@ -7,12 +7,11 @@ edition = "2021"
[dependencies]
bytes = "1"
fastrand = "2.0.0"
futures-core = "0.3"
mime = "0.3"
rand = { version = "0.8", features = ["small_rng"] }
tokio = { version = "1", default-features = false, features = [ "io-util" ] }
tokio-util = { version = "0.7", default-features = false, features = ["io"] }
tracing = "0.1.37"
[dev-dependencies]
common-multipart-rfc7578 = "0.6.0"

View file

@ -192,7 +192,6 @@ where
}
if self.closed {
tracing::debug!("Polled for close");
return Poll::Ready(Ok(()));
}

View file

@ -3,10 +3,10 @@ mod internal;
use std::{collections::VecDeque, io::Cursor, pin::Pin};
use bytes::Bytes;
use fastrand::Rng;
use futures_core::Stream;
use internal::{SendRead, UnsendRead};
use mime::Mime;
use rand::{distributions::Alphanumeric, rngs::SmallRng, Rng, SeedableRng};
use tokio::io::AsyncRead;
use tokio_util::io::ReaderStream;
@ -32,11 +32,8 @@ pub struct Empty;
impl<'a> Body<SendRead<'a>> {
pub fn builder() -> BodyBuilder<SendRead<'a>> {
let boundary = SmallRng::from_entropy()
.sample_iter(&Alphanumeric)
.map(char::from)
.take(6)
.collect::<String>();
let mut rng = Rng::new();
let boundary = (0..6).map(|_| rng.alphanumeric()).collect::<String>();
BodyBuilder {
boundary,