[M5] mxaccess-codec: F24 ASB Variant + AsbStatus + RuntimeValue codec
Ports `Variant` (cs:1170-1241), `AsbStatus` (cs:1109-1167), `RuntimeValue`
(cs:741-791), `AsbVariantFactory.From*` (cs:1310-1429), and
`MxAsbDataClient.DecodeVariant` (cs:713-825) into `mxaccess-codec::asb_variant`.
Three layers per `docs/ASB-Variant-Wire-Format.md`:
1. `AsbVariant` — raw 2/4/4/payload header + bytes; round-trips byte-identical.
2. `DecodedVariant` — typed view with one variant per proven ASB scalar / array
(`Bool`, `Int32`, `Float`, `Double`, `String`, `DateTime`, `Duration` plus
array forms). Type ids outside the proven matrix surface as
`Unsupported { type_id, payload }` — same fallback as .NET's `_ => payload`.
3. `from_*` factories — mirror `AsbVariantFactory.FromX` exactly, setting
`length` to `payload.len()` per `cs:1431-1438`.
`AsbStatus` and `RuntimeValue` round-trip the wire layout verbatim.
Status-element walking (marker bit 7 = implicit zero, etc., per
`docs/ASB-Variant-Wire-Format.md:180-205`) is deferred to a follow-up; the
codec exposes the raw status payload bytes for now, matching .NET's
`AsbStatus.Payload = byte[]` shape.
The lib.rs `AsbVariant` / `AsbStatus` / `RuntimeValue` stubs are replaced by
the real types via `pub use`. 25 new unit tests cover the proven matrix:
scalar + array round-trip, byte layout (2/4/4/payload), `Unsupported`
fallback for declared-but-unproven types, short-frame rejection,
malformed `string[]` partial-decode preservation matching .NET behavior.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,14 +15,15 @@
|
||||
//! `NmxTransferEnvelopeTemplate` (round-trip preserver).
|
||||
//!
|
||||
//! Remaining (wave 2): `NmxSecuredWrite2Message` (`0x38`),
|
||||
//! `ObservedWriteBodyTemplate`. ASB Variant + AsbStatus + RuntimeValue land
|
||||
//! in M5.
|
||||
//! `ObservedWriteBodyTemplate`. ASB Variant + AsbStatus + RuntimeValue
|
||||
//! landed in the F24 sub-stream of M5 — see [`asb_variant`].
|
||||
//!
|
||||
//! Every wire shape here is grounded in `src/MxNativeCodec/*.cs` (the .NET
|
||||
//! reference) and `captures/0NN-frida-*` (Frida ground truth).
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
pub mod asb_variant;
|
||||
pub mod envelope;
|
||||
pub mod envelope_template;
|
||||
pub mod error;
|
||||
@@ -68,16 +69,11 @@ pub struct NmxWriteMessage;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NmxSecuredWrite2Message;
|
||||
|
||||
// ---- ASB types (M5 follow-up) --------------------------------------------
|
||||
// ---- ASB types (M5, F24) -------------------------------------------------
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AsbVariant;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct AsbStatus;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RuntimeValue;
|
||||
pub use asb_variant::{
|
||||
AsbDataType, AsbStatus, AsbVariant, DecodedVariant, RuntimeValue, decode_variant,
|
||||
};
|
||||
|
||||
// ---- Convenience prelude -------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user