modality_trace_recorder_plugin/snapshot/
mod.rs1use derive_more::{Deref, Into};
2use std::fs::File;
3use std::path::{Path, PathBuf};
4use thiserror::Error;
5
6pub use attr::{EventAttrKey, TimelineAttrKey};
7
8pub mod attr;
9pub mod trace_recorder;
10
11#[derive(Debug, Error)]
12pub enum SnapshotFileOpenError {
13 #[error(
14 "Encountered and IO error while opening snapshot file '{0}' ({})",
15 .1.kind()
16 )]
17 Io(PathBuf, #[source] std::io::Error),
18}
19
20#[derive(Debug, Into, Deref)]
21pub struct SnapshotFile(File);
22
23impl SnapshotFile {
24 pub fn open<P: AsRef<Path>>(p: P) -> Result<Self, SnapshotFileOpenError> {
25 Ok(Self(File::open(p.as_ref()).map_err(|e| {
26 SnapshotFileOpenError::Io(p.as_ref().to_path_buf(), e)
27 })?))
28 }
29}