1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use crate::core::{Block, Cid, PbLink};

pub trait Package {
    type BlockIterator: Iterator<Item=Block>;

    fn cid(&self) -> &Cid;
    fn total_size(&self) -> u64;
    fn into_blocks(self) -> Self::BlockIterator;

    fn link(&self, name: String) -> PbLink {
        PbLink {
            cid: self.cid().clone(),
            size: self.total_size(),
            name
        }
    }
}