Skip to content

Commit f92461d

Browse files
committed
drop redundant internal Fixed notion, keep in external API
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
1 parent 096a4c1 commit f92461d

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

lading_payload/src/block.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,8 @@ impl Handle {
268268
/// et al.
269269
///
270270
/// We expect to expand the different modes of `Cache` operation in the future.
271-
pub enum Cache {
272-
/// A fixed size cache of blocks. Blocks are looped over in a round-robin
273-
/// fashion.
274-
Fixed {
275-
/// Shared cache data
276-
data: Arc<CacheData>,
277-
},
271+
pub struct Cache {
272+
data: Arc<CacheData>,
278273
}
279274

280275
impl Cache {
@@ -458,7 +453,7 @@ impl Cache {
458453
.map(|block| u64::from(block.total_bytes.get()))
459454
.sum();
460455

461-
Ok(Self::Fixed {
456+
Ok(Self {
462457
data: Arc::new(CacheData {
463458
blocks,
464459
total_cycle_size,
@@ -472,11 +467,9 @@ impl Cache {
472467
/// allowing multiple handles to read from the same cache independently.
473468
#[must_use]
474469
pub fn handle(&self) -> Handle {
475-
match self {
476-
Self::Fixed { data } => Handle {
477-
cache: Arc::clone(data),
478-
idx: 0,
479-
},
470+
Handle {
471+
cache: Arc::clone(&self.data),
472+
idx: 0,
480473
}
481474
}
482475

@@ -485,9 +478,7 @@ impl Cache {
485478
/// This is primarily useful for inspection and debugging purposes.
486479
#[must_use]
487480
pub fn blocks(&self) -> &[Block] {
488-
match self {
489-
Self::Fixed { data } => &data.blocks,
490-
}
481+
&self.data.blocks
491482
}
492483

493484
/// Run `Cache` forward on the user-provided mpsc sender.
@@ -502,15 +493,11 @@ impl Cache {
502493
/// is closed.
503494
#[allow(clippy::needless_pass_by_value)]
504495
pub fn spin(self, snd: Sender<Block>) -> Result<(), SpinError> {
505-
match self {
506-
Self::Fixed { data } => {
507-
let mut idx = 0;
508-
let blocks = &data.blocks;
509-
loop {
510-
snd.blocking_send(blocks[idx].clone())?;
511-
idx = (idx + 1) % blocks.len();
512-
}
513-
}
496+
let mut idx = 0;
497+
let blocks = &self.data.blocks;
498+
loop {
499+
snd.blocking_send(blocks[idx].clone())?;
500+
idx = (idx + 1) % blocks.len();
514501
}
515502
}
516503
}

0 commit comments

Comments
 (0)