rectangle_device_blocks/
core.rs

1use libipld::codec_impl::Multicodec;
2use libipld::multihash::Multihash;
3
4// This is an architectural limit in IPFS, chosen to limit the amount of memory
5// needed by bitswap to buffer not-yet-verified data from peers.
6pub const BLOCK_MAX_BYTES : usize = 1024 * 1024;
7
8pub use libipld::multihash::SHA2_256 as DefaultHashType;
9
10pub type Block = libipld::block::Block<Multicodec, Multihash>;
11pub use libipld::cid::Cid;
12pub use libipld::pb::PbLink;
13
14#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Clone)]
15pub enum BlockUsage {
16    // We try to send blocks in the same order listed here
17    PlayerDirectory(usize),
18    PlayerScript,
19    Player(usize),
20    VideoDirectory(usize),
21    Playlist(usize),
22    VideoSegment(usize),
23}
24
25pub struct BlockInfo {
26    pub block: Block,
27    pub usage: BlockUsage,
28}
29
30impl BlockUsage {
31    pub fn attach_to(&self, block: Block) -> BlockInfo {
32        BlockInfo {
33            block: block,
34            usage: self.clone(),
35        }
36    }
37}