Debian Codegraph @

.cargo/vendor/onenote_parser/src/onestore/revision_role.rs

raw
1 use crate::errors::{ErrorKind, Result};
2 use crate::fsshttpb::data::exguid::ExGuid;
3
4 /// A revision's role.
5 ///
6 /// See [\[MS-ONESTORE\] 2.7.4]
7 ///
8 /// [\[MS-ONESTORE\] 2.7.4]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-onestore/344c9aa5-2826-4b61-b1bb-1ef841b1b79e
9 #[derive(Debug, PartialEq, Hash, Eq, Copy, Clone)]
10 pub(crate) enum RevisionRole {
11 DefaultContent,
12 Metadata,
13 EncryptionKey,
14 VersionMetadata,
15 }
16
17 impl RevisionRole {
18 pub(crate) fn parse(id: ExGuid) -> Result<RevisionRole> {
19 let guid = guid!({4A3717F8-1C14-49E7-9526-81D942DE1741});
20
21 if id.guid != guid {
22 return Err(
23 ErrorKind::MalformedOneStoreData("invalid root declare root id".into()).into(),
24 );
25 }
26
27 match id {
28 ExGuid { value: 1, .. } => Ok(RevisionRole::DefaultContent),
29 ExGuid { value: 2, .. } => Ok(RevisionRole::Metadata),
30 ExGuid { value: 3, .. } => Ok(RevisionRole::EncryptionKey),
31 ExGuid { value: 4, .. } => Ok(RevisionRole::VersionMetadata),
32 ExGuid { value, .. } => Err(ErrorKind::MalformedOneStoreData(
33 format!("invalid root declare id exguid value {}", value).into(),
34 )
35 .into()),
36 }
37 }
38 }