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 crate::Ecc;

/// An intermediate chunk description.
#[derive(Debug)]
pub struct ChunkDesc<'a> {
    /// The primary identifier.
    primary: Ecc,
    /// The secondary identifier.
    secondary: Ecc,
    /// The source of the chunk data.
    data: DataSource<'a>,
}

impl<'a> ChunkDesc<'a> {
    /// Create a new chunk desc.
    pub fn new(primary: Ecc, secondary: Ecc, data: DataSource<'a>) -> 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) -> DataSource<'a> {
        self.data
    }
}