outlook_pst/messaging/
mod.rs1use std::io;
4use thiserror::Error;
5
6pub mod attachment;
7pub mod folder;
8pub mod message;
9pub mod named_prop;
10pub mod search;
11pub mod store;
12
13pub(crate) mod read_write;
14
15#[derive(Error, Debug)]
16pub enum MessagingError {
17 #[error("Node Database error: {0}")]
18 NodeDatabaseError(#[from] crate::ndb::NdbError),
19 #[error("Node Database error: {0}")]
20 ListsTablesPropertiesError(#[from] crate::ltp::LtpError),
21 #[error("Failed to lock PST file")]
22 FailedToLockFile,
23 #[error("Invalid EntryID rgbFlags: 0x{0:08X}")]
24 InvalidEntryIdFlags(u32),
25 #[error("Missing PidTagRecordKey on store")]
26 StoreRecordKeyNotFound,
27 #[error("Invalid PidTagRecordKey on store: {0:?}")]
28 InvalidStoreRecordKey(crate::ltp::prop_type::PropertyType),
29 #[error("Invalid PidTagRecordKey size on store: 0x{0:X}")]
30 InvalidStoreRecordKeySize(usize),
31 #[error("Failed to read root hierarchy table: {0}")]
32 StoreRootHierarchyTableFailed(String),
33 #[error("Failed to open a folder: {0}")]
34 StoreOpenFolder(String),
35 #[error("Failed to read named property map: {0}")]
36 StoreNamedPropertyMap(String),
37 #[error("Failed to read search update queue: {0}")]
38 StoreSearchUpdateQueue(String),
39 #[error("Missing PidTagDisplayName on store")]
40 StoreDisplayNameNotFound,
41 #[error("Invalid PidTagDisplayName on store: {0:?}")]
42 InvalidStoreDisplayName(crate::ltp::prop_type::PropertyType),
43 #[error("Missing PidTagIpmSubTreeEntryId on store")]
44 StoreIpmSubTreeEntryIdNotFound,
45 #[error("Invalid PidTagIpmSubTreeEntryId on store: {0:?}")]
46 InvalidStoreIpmSubTreeEntryId(crate::ltp::prop_type::PropertyType),
47 #[error("Missing PidTagIpmWastebasketEntryId on store")]
48 StoreIpmWastebasketEntryIdNotFound,
49 #[error("Invalid PidTagIpmWastebasketEntryId on store: {0:?}")]
50 InvalidStoreIpmWastebasketEntryId(crate::ltp::prop_type::PropertyType),
51 #[error("Missing PidTagFinderEntryId on store")]
52 StoreFinderEntryIdNotFound,
53 #[error("Invalid PidTagFinderEntryId on store: {0:?}")]
54 InvalidStoreFinderEntryId(crate::ltp::prop_type::PropertyType),
55 #[error("EntryID in wrong store")]
56 EntryIdWrongStore,
57 #[error("Missing PidTagDisplayName on folder")]
58 FolderDisplayNameNotFound,
59 #[error("Invalid PidTagDisplayName on folder: {0:?}")]
60 InvalidFolderDisplayName(crate::ltp::prop_type::PropertyType),
61 #[error("Missing PidTagContentCount on folder")]
62 FolderContentCountNotFound,
63 #[error("Invalid PidTagContentCount on folder: {0:?}")]
64 InvalidFolderContentCount(crate::ltp::prop_type::PropertyType),
65 #[error("Missing PidTagContentUnreadCount on folder")]
66 FolderUnreadCountNotFound,
67 #[error("Invalid PidTagContentUnreadCount on folder: {0:?}")]
68 InvalidFolderUnreadCount(crate::ltp::prop_type::PropertyType),
69 #[error("Missing PidTagSubfolders on folder")]
70 FolderHasSubfoldersNotFound,
71 #[error("Invalid PidTagSubfolders on folder: {0:?}")]
72 InvalidFolderHasSubfolders(crate::ltp::prop_type::PropertyType),
73 #[error("Invalid folder EntryID NID_TYPE: {0:?}")]
74 InvalidFolderEntryIdType(crate::ndb::node_id::NodeIdType),
75 #[error("Missing PidTagMessageClass on message")]
76 MessageClassNotFound,
77 #[error("Invalid PidTagMessageClass on message: {0:?}")]
78 InvalidMessageClass(crate::ltp::prop_type::PropertyType),
79 #[error("Missing PidTagMessageFlags on message")]
80 MessageFlagsNotFound,
81 #[error("Invalid PidTagMessageFlags on message: {0:?}")]
82 InvalidMessageFlags(crate::ltp::prop_type::PropertyType),
83 #[error("Missing PidTagMessageSize on message")]
84 MessageSizeNotFound,
85 #[error("Invalid PidTagMessageSize on message: {0:?}")]
86 InvalidMessageSize(crate::ltp::prop_type::PropertyType),
87 #[error("Missing PidTagMessageStatus on message")]
88 MessageStatusNotFound,
89 #[error("Invalid PidTagMessageStatus on message: {0:?}")]
90 InvalidMessageStatus(crate::ltp::prop_type::PropertyType),
91 #[error("Missing PidTagMessageCreationTime on message")]
92 MessageCreationTimeNotFound,
93 #[error("Invalid PidTagMessageCreationTime on message: {0:?}")]
94 InvalidMessageCreationTime(crate::ltp::prop_type::PropertyType),
95 #[error("Missing PidTagMessageLastModificationTime on message")]
96 MessageLastModificationTimeNotFound,
97 #[error("Invalid PidTagMessageLastModificationTime on message: {0:?}")]
98 InvalidMessageLastModificationTime(crate::ltp::prop_type::PropertyType),
99 #[error("Missing PidTagMessageSearchKey on message")]
100 MessageSearchKeyNotFound,
101 #[error("Invalid PidTagMessageSearchKey on message: {0:?}")]
102 InvalidMessageSearchKey(crate::ltp::prop_type::PropertyType),
103 #[error("Invalid message EntryID NID_TYPE: {0:?}")]
104 InvalidMessageEntryIdType(crate::ndb::node_id::NodeIdType),
105 #[error("Missing Sub-Node Tree on message")]
106 MessageSubNodeTreeNotFound,
107 #[error("Multiple NID_TYPE_RECIPIENT_TABLE sub-nodes on message")]
108 MultipleMessageRecipientTables,
109 #[error("Multiple NID_TYPE_ATTACHMENT_TABLE sub-nodes on message")]
110 MultipleMessageAttachmentTables,
111 #[error("Missing PidTagAttachSize on message")]
112 AttachmentSizeNotFound,
113 #[error("Invalid PidTagAttachSize on message: {0:?}")]
114 InvalidAttachmentSize(crate::ltp::prop_type::PropertyType),
115 #[error("Missing PidTagAttachMethod on message")]
116 AttachmentMethodNotFound,
117 #[error("Invalid PidTagAttachMethod on message: {0:?}")]
118 InvalidAttachmentMethod(crate::ltp::prop_type::PropertyType),
119 #[error("Missing PidTagRenderingPosition on message")]
120 AttachmentRenderingPositionNotFound,
121 #[error("Invalid PidTagRenderingPosition on message: {0:?}")]
122 InvalidAttachmentRenderingPosition(crate::ltp::prop_type::PropertyType),
123 #[error("Invalid attachment Sub-Node NID_TYPE: {0:?}")]
124 InvalidAttachmentNodeIdType(crate::ndb::node_id::NodeIdType),
125 #[error("Unrecognized PidTagAttachMethod on attachment: 0x{0:08X}")]
126 UnknownAttachmentMethod(i32),
127 #[error("Missing attachment Sub-Node on message: {0:?}")]
128 AttachmentSubNodeNotFound(crate::ndb::node_id::NodeId),
129 #[error("Missing PidTagAttachDataObject on afEmbeddedMessage attachment")]
130 AttachmentMessageObjectDataNotFound,
131 #[error("Invalid PidTagAttachDataObject on afEmbeddedMessage attachment: {0:?}")]
132 InvalidMessageObjectData(crate::ltp::prop_type::PropertyType),
133 #[error("Missing PidTagAttachDataBinary on afByValue attachment")]
134 AttachmentFileBinaryDataNotFound,
135 #[error("Invalid PidTagAttachDataBinary on afByValue attachment: {0:?}")]
136 InvalidAttachmentFileBinaryData(crate::ltp::prop_type::PropertyType),
137 #[error("Missing PidTagAttachDataObject on afStorage attachment")]
138 AttachmentStorageObjectDataNotFound,
139 #[error("Reading afStorage attachment failed: {0}")]
140 AttachmentStorageRead(String),
141 #[error("Invalid PidTagAttachDataObject on afStorage attachment: {0:?}")]
142 InvalidStorageObjectData(crate::ltp::prop_type::PropertyType),
143 #[error("NAMEID wGuid is out of bounds: 0x{0:04X}")]
144 NamedPropertyMapGuidIndexOutOfBounds(u16),
145 #[error("NAMEID wPropIdx is out of bounds: 0x{0:04X}")]
146 NamedPropertyMapPropertyIndexOutOfBounds(u16),
147 #[error("PidTagNameidBucketCount on Named Property Lookup Map is out of bounds: 0x{0:08X}")]
148 NamedPropertyMapBucketCountOutOfBounds(i32),
149 #[error("Hash bucket offset on Named Property Lookup Map is out of bounds: 0x{0:04X}")]
150 NamedPropertyMapBucketOffsetOutOfBounds(u32),
151 #[error("Invalid PidTagNameidStreamString string")]
152 NamedPropertyMapStringEntryOutOfBounds,
153 #[error("Missing PidTagNameidBucketCount on Named Property Lookup Map")]
154 NamedPropertyMapBucketCountNotFound,
155 #[error("Invalid PidTagNameidBucketCount on Named Property Lookup Map: {0:?}")]
156 InvalidNamedPropertyMapBucketCount(crate::ltp::prop_type::PropertyType),
157 #[error("Missing PidTagNameidStreamGuid on Named Property Lookup Map")]
158 NamedPropertyMapStreamGuidNotFound,
159 #[error("Invalid PidTagNameidStreamGuid on Named Property Lookup Map: {0:?}")]
160 InvalidNamedPropertyMapStreamGuid(crate::ltp::prop_type::PropertyType),
161 #[error("Missing PidTagNameidStreamEntry on Named Property Lookup Map")]
162 NamedPropertyMapStreamEntryNotFound,
163 #[error("Invalid PidTagNameidStreamEntry on Named Property Lookup Map: {0:?}")]
164 InvalidNamedPropertyMapStreamEntry(crate::ltp::prop_type::PropertyType),
165 #[error("Missing PidTagNameidStreamString on Named Property Lookup Map")]
166 NamedPropertyMapStreamStringNotFound,
167 #[error("Invalid PidTagNameidStreamString on Named Property Lookup Map: {0:?}")]
168 InvalidNamedPropertyMapStreamString(crate::ltp::prop_type::PropertyType),
169 #[error("Missing PidTagNameidBucketBase + hash on Named Property Lookup Map")]
170 NamedPropertyMapBucketNotFound(u16),
171 #[error("Invalid PidTagNameidBucketBase + hash on Named Property Lookup Map: {0:?}")]
172 InvalidNamedPropertyMapBucket(crate::ltp::prop_type::PropertyType),
173 #[error("Invalid SUD wSUDType: 0x{0:04X}")]
174 InvalidSearchUpdateType(u16),
175 #[error("Invalid SUD queue offset: 0x{0:08X}")]
176 InvalidSearchUpdateQueueOffset(u32),
177 #[error("Invalid SUD queue size: {0}")]
178 InvalidSearchUpdateQueueSize(usize),
179}
180
181impl From<MessagingError> for io::Error {
182 fn from(err: MessagingError) -> io::Error {
183 io::Error::new(io::ErrorKind::InvalidData, err)
184 }
185}
186
187pub type MessagingResult<T> = Result<T, MessagingError>;