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 super::traits::ParseBytes;
use crate::result::{SQLiteError, SQLiteResult};

use core::fmt::Debug;

/// Reserved for expansion. Must be zero. (20 Bytes)
#[derive(Default)]
pub struct ReservedForExpansion([u8; 20]);

impl Debug for ReservedForExpansion {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let output = stringify!("{:02x?}", self.0);
    f.debug_tuple("ReservedForExpansion")
      .field(&output)
      .finish()
  }
}

impl ParseBytes for ReservedForExpansion {
  const NAME: &'static str = "ReservedForExpansion";

  const LENGTH_BYTES: usize = 20;

  fn parsing_handler(bytes: &[u8]) -> SQLiteResult<Self> {
    for byte in bytes.iter() {
      if *byte != b'\0' {
        return Err(SQLiteError::Custom(stringify!(
          "Invalid payload for {}",
          Self::NAME
        )));
      }
    }
    Ok(Default::default())
  }
}