onenote_parser 2.0.0

A parser for Microsoft OneNoteĀ® files
Documentation
use crate::Reader;
use crate::errors::Result;
use std::fmt;

/// An object type.
///
/// See [\[MS-ONESTORE\] 2.6.14].
///
/// [\[MS-ONESTORE\] 6.14.2]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-onestore/388c266c-08e4-4ea4-af0e-5e2c5d1b995c
#[derive(Copy, Clone, PartialEq)]
pub(crate) struct JcId(pub(crate) u32);

impl JcId {
    pub(crate) fn parse(reader: Reader) -> Result<JcId> {
        reader.get_u32().map(JcId)
    }
}

impl fmt::Debug for JcId {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "JcId(0x{:08X})", self.0)
    }
}

#[cfg(test)]
mod tests {
    use super::JcId;
    use crate::reader::Reader;

    #[test]
    fn test_parse() {
        let data = [0x78, 0x56, 0x34, 0x12];
        let jc_id = JcId::parse(&mut Reader::new(&data)).unwrap();

        assert_eq!(jc_id.0, 0x1234_5678);
    }
}