Skip to main content

wsi_dicom_annotations/
lib.rs

1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4use std::error::Error as StdError;
5use std::path::PathBuf;
6
7mod annotations;
8pub mod metadata;
9
10#[cfg(test)]
11mod annotation_tests;
12#[cfg(test)]
13mod linear_measurement_tests;
14#[cfg(all(test, feature = "parametric-map"))]
15mod parametric_map_tests;
16#[cfg(test)]
17mod pathology_geojson_tests;
18#[cfg(test)]
19mod scheme_tests;
20#[cfg(test)]
21mod test_support;
22
23pub use annotations::*;
24
25/// Error returned by annotation import, conversion, and DICOM persistence.
26#[derive(Debug, thiserror::Error)]
27pub enum Error {
28    /// Input is structurally invalid or violates a checked invariant.
29    #[error("invalid input: {0}")]
30    InvalidInput(String),
31    /// Input is valid but uses a representation this crate does not support.
32    #[error("unsupported input: {0}")]
33    Unsupported(String),
34    /// Filesystem operation failed.
35    #[error("I/O error at {path}: {source}")]
36    Io {
37        /// Path involved in the failed operation.
38        path: PathBuf,
39        /// Underlying filesystem error.
40        #[source]
41        source: std::io::Error,
42    },
43    /// DICOM decoding failed.
44    #[error("DICOM read error at {path}: {source}")]
45    DicomRead {
46        /// Path of the DICOM object being read.
47        path: PathBuf,
48        /// Underlying DICOM parser error.
49        #[source]
50        source: Box<dyn StdError + Send + Sync>,
51    },
52    /// DICOM encoding failed.
53    #[error("DICOM write error at {path}: {source}")]
54    DicomWrite {
55        /// Destination path of the DICOM object being written.
56        path: PathBuf,
57        /// Underlying DICOM writer error.
58        #[source]
59        source: Box<dyn StdError + Send + Sync>,
60    },
61}
62
63/// Result type used by annotation operations.
64pub type Result<T> = std::result::Result<T, Error>;