Skip to content

Commit 983e99a

Browse files
committed
Use const creation of byte_unit::Byte
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
1 parent 14c2d5e commit 983e99a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lading/src/bin/payloadtool.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use rand::{SeedableRng, rngs::StdRng};
1010
use tracing::{debug, error, info, warn};
1111
use tracing_subscriber::{fmt::format::FmtSpan, util::SubscriberInitExt};
1212

13-
const UDP_PACKET_LIMIT_BYTES: u64 = 65_507;
13+
const UDP_PACKET_LIMIT_BYTES: byte_unit::Byte =
14+
byte_unit::Byte::from_u64_with_unit(65_507, Unit::B).expect("valid bytes");
1415

1516
#[derive(Parser, Debug)]
1617
#[clap(author, version, about, long_about = None)]
@@ -79,9 +80,7 @@ fn check_generator(config: &lading::generator::Config) -> Result<(), Error> {
7980
match &config.inner {
8081
lading::generator::Inner::FileGen(_) => unimplemented!("FileGen not supported"),
8182
lading::generator::Inner::UnixDatagram(g) => {
82-
let max_block_size =
83-
byte_unit::Byte::from_u64_with_unit(UDP_PACKET_LIMIT_BYTES, Unit::B)
84-
.expect("valid bytes");
83+
let max_block_size = UDP_PACKET_LIMIT_BYTES;
8584
let total_bytes = NonZeroU32::new(g.maximum_prebuild_cache_size_bytes.as_u128() as u32)
8685
.expect("Non-zero max prebuild cache size");
8786
generate_and_check(&g.variant, g.seed, total_bytes, max_block_size)?;
@@ -94,9 +93,7 @@ fn check_generator(config: &lading::generator::Config) -> Result<(), Error> {
9493
lading::generator::Inner::Udp(g) => {
9594
let total_bytes = NonZeroU32::new(g.maximum_prebuild_cache_size_bytes.as_u128() as u32)
9695
.expect("Non-zero max prebuild cache size");
97-
let max_block_size =
98-
byte_unit::Byte::from_u64_with_unit(UDP_PACKET_LIMIT_BYTES, Unit::B)
99-
.expect("valid bytes");
96+
let max_block_size = UDP_PACKET_LIMIT_BYTES;
10097
generate_and_check(&g.variant, g.seed, total_bytes, max_block_size)?;
10198
}
10299
lading::generator::Inner::Http(g) => {

0 commit comments

Comments
 (0)