Skip to main content

cadmpeg_codec_sat/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2#![cfg_attr(test, allow(clippy::unwrap_used))]
3//! Decode bare Autodesk `ShapeManager` (ASM) B-rep streams.
4//!
5//! A bare stream is an ASM serialization outside any container: a binary
6//! `.sab`/`.smb` SAB stream or a text `.sat`/`.smt` stream. Content
7//! selects the path, never the file extension: the `ASM BinaryFile` magic
8//! selects the binary framer and the ASCII header lines select the text
9//! parser. Both paths decode through the shared kernel decoders in
10//! [`cadmpeg_asm::brep`] into the neutral model arenas, with the kernel-side
11//! native records under the `sat` namespace.
12//!
13//! Spatial ACIS 217 and 218 binary streams use the verified 32-bit SAB grammar.
14//! Other ACIS binary header bands keep an admitted `sat:` host layer and recover
15//! through an unverified `acis:` kernel layer that names the nearest
16//! verified grammar and charges the recovery loss. Inspection and decode emit
17//! both layers. A text stream frames on either branch terminator, and its decode
18//! outcome decides whether the report carries geometry.
19//!
20//! <!-- generated: capability sat -->
21//! Support: L3 ([ladder](https://github.com/cadmpeg/cadmpeg/blob/main/docs/format-support.md#asmacis-bare-satsmtsmbsab-streams)).
22//! <!-- /generated: capability sat -->
23
24mod coverage;
25mod decode;
26mod detect;
27mod dialect;
28mod loss;
29
30include!("dialect/registry_ids.rs");
31
32use cadmpeg_core::decode::{DecodeContext, View};
33use cadmpeg_core::dialect::DialectId;
34use cadmpeg_core::CodecError;
35use cadmpeg_ir::codec::{CodecBackend, Confidence, Decoded, FormatId};
36use cadmpeg_ir::ContainerSummary;
37
38/// Bare ASM stream codec.
39pub struct SatCodec;
40
41impl CodecBackend for SatCodec {
42    const FORMAT: FormatId = FormatId::new(FORMAT);
43
44    fn detect_impl(
45        &self,
46        _ctx: &cadmpeg_core::decode::DecodeContext<'_>,
47        prefix: cadmpeg_core::decode::View<'_>,
48    ) -> Result<Confidence, cadmpeg_core::CodecError> {
49        Ok(detect::confidence(prefix.window()))
50    }
51
52    fn inspect_impl(
53        &self,
54        ctx: &DecodeContext<'_>,
55        root: View<'_>,
56    ) -> Result<ContainerSummary, CodecError> {
57        detect::inspect(ctx, root)
58    }
59
60    fn decode_impl(&self, ctx: &DecodeContext<'_>, root: View<'_>) -> Result<Decoded, CodecError> {
61        decode::decode(ctx, root.window())
62    }
63}
64
65#[cfg(test)]
66mod golden_tests;
67#[cfg(test)]
68pub(crate) mod test_support;
69
70#[cfg(test)]
71mod integration_tests;