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
use crate::{DataSource, Error, Result};
use hff_core::{Chunk, Ecc, Table};

#[derive(Debug)]
pub struct ChunkDesc {
    primary: Ecc,
    secondary: Ecc,
    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
    }

    /// Take chunk and return the data source.
    pub fn data_source(self) -> Box<dyn DataSource> {
        self.data
    }
}