Skip to main content

cadmpeg_codec_step/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2//! Failures returned while streaming STEP output.
3
4use cadmpeg_core::CodecError;
5
6/// Failure returned while streaming STEP output.
7///
8/// Unsupported or reduced IR content appears in [`cadmpeg_ir::report::ExportReport::losses`] after a
9/// successful write.
10#[derive(Debug, thiserror::Error)]
11pub enum StepError {
12    /// Strict writing found semantics that would be reduced or omitted.
13    #[error("STEP target cannot represent the document without loss: {0}")]
14    Unsupported(String),
15    /// The output sink rejected a write.
16    #[error("failed to write STEP output: {0}")]
17    Io(#[from] std::io::Error),
18}
19
20impl From<StepError> for CodecError {
21    fn from(error: StepError) -> Self {
22        match error {
23            StepError::Unsupported(message) => Self::NotImplemented(message),
24            StepError::Io(error) => Self::Io(error),
25        }
26    }
27}