Debian Codegraph @

.cargo/vendor/onenote_parser/src/fsshttpb/data_element/object_data_blob.rs

raw
1 use crate::errors::Result;
2 use crate::fsshttpb::data::binary_item::BinaryItem;
3 use crate::fsshttpb::data::object_types::ObjectType;
4 use crate::fsshttpb::data::stream_object::ObjectHeader;
5 use crate::fsshttpb::data_element::DataElement;
6 use crate::Reader;
7 use std::fmt;
8
9 /// An object data blob.
10 ///
11 /// See [\[MS-FSSHTTPB\] 2.2.1.12.8]
12 ///
13 /// [\[MS-FSSHTTPB\] 2.2.1.12.8]: https://docs.microsoft.com/en-us/openspecs/sharepoint_protocols/ms-fsshttpb/d36dd2b4-bad1-441b-93c7-adbe3069152c
14 pub(crate) struct ObjectDataBlob(Vec<u8>);
15
16 impl ObjectDataBlob {
17 pub(crate) fn value(&self) -> &[u8] {
18 &self.0
19 }
20 }
21
22 impl fmt::Debug for ObjectDataBlob {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 write!(f, "ObjectDataBlob({} bytes)", self.0.len())
25 }
26 }
27
28 impl DataElement {
29 pub(crate) fn parse_object_data_blob(reader: Reader) -> Result<ObjectDataBlob> {
30 ObjectHeader::try_parse(reader, ObjectType::ObjectDataBlob)?;
31
32 let data = BinaryItem::parse(reader)?;
33
34 ObjectHeader::try_parse_end_8(reader, ObjectType::DataElement)?;
35
36 Ok(ObjectDataBlob(data.value()))
37 }
38 }