1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
use super::DataSource;
use hff_core::Ecc;
/// Internal description of a chunk and the data source for the contents.
#[derive(Debug)]
pub struct ChunkDesc {
/// The primary identifier for this chunk.
primary: Ecc,
/// The secondary identifier for this chunk.
secondary: Ecc,
/// The boxed chunk data source.
data: Box<dyn DataSource>,
}
impl ChunkDesc {
/// Create a new chunk desc.
pub fn new(primary: Ecc, secondary: Ecc, data: Box<dyn DataSource>) -> Self {
Self {
primary,
secondary,
data,
}
}
/// Get the primary identifier.
pub fn primary(&self) -> Ecc {
self.primary
}
/// Get the secondary identifier.
pub fn secondary(&self) -> Ecc {
self.secondary
}
/// Get the chunk data.
pub fn data(self) -> Box<dyn DataSource> {
self.data
}
}