1use std::fmt;
4
5#[derive(Clone)]
7pub enum Block {
8 Raw(Box<[u8; Block::SIZE as usize]>),
10 Fill([u8; 4]),
12 Skip,
14 Crc32(u32),
16}
17
18impl Block {
19 pub const SIZE: u32 = 4096;
21}
22
23impl fmt::Debug for Block {
24 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25 use self::Block::*;
26
27 match self {
28 Raw(r) => write!(f, "Raw({:?})", &r[..]),
29 Fill(_) | Skip | Crc32(_) => self.fmt(f),
30 }
31 }
32}
33
34impl PartialEq for Block {
35 fn eq(&self, other: &Self) -> bool {
36 use self::Block::*;
37
38 match (self, other) {
39 (Raw(r1), Raw(r2)) => r1[..] == r2[..],
40 (Fill(v1), Fill(v2)) => v1 == v2,
41 (Skip, Skip) => true,
42 (Crc32(c1), Crc32(c2)) => c1 == c2,
43 _ => false,
44 }
45 }
46}