cadmpeg-asm 0.6.2

Parse and write Autodesk Shape Manager record streams.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-License-Identifier: Apache-2.0
//! Fixture helpers for ASM and its codec consumers.

pub mod sab;

#[cfg(test)]
use cadmpeg_core::decode::{DecodeArena, DecodeContext, DecodePolicy};

/// Run a fixture with the service decode policy.
#[cfg(test)]
pub(crate) fn with_service_context<T>(
    bytes: &[u8],
    use_context: impl FnOnce(&DecodeContext<'_>) -> T,
) -> Result<T, cadmpeg_core::CodecError> {
    let arena = DecodeArena::new();
    let (ctx, _) = DecodeContext::from_root_bytes(bytes, &arena, &DecodePolicy::service())?;
    Ok(use_context(&ctx))
}