pub struct FlatOpScopeDesc {
pub limit_name: &'static str,
pub push_opcode: u32,
pub pop_opcode: u32,
pub max_depth: u32,
}Expand description
Derives NvEncode and NvDecode for Tier-2 little-endian structs and enums.
§Compile-Time Guards
Generics are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadGeneric<T: nativeview_codec::NvEncode + nativeview_codec::NvDecode>(T);where clauses are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadWhere(u8) where u8: Copy;Field-level #[nativeview_codec(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadFieldAttr {
#[nativeview_codec(skip)]
a: u8,
}Conflicting #[nativeview_codec(tag = ...)] and = discriminant are rejected:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum ConflictingTag {
#[nativeview_codec(tag = 1)]
A(u8) = 2,
}Duplicate enum tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum DupTag {
#[nativeview_codec(tag = 1)]
A(u8),
#[nativeview_codec(tag = 1)]
B(u16),
}Out-of-range tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum OutOfRange {
#[nativeview_codec(tag = 256)]
TooBig(u8),
}Non-u8 data-carrying enums are rejected:
use nativeview_codec::NvCodec;
#[repr(u16)]
#[derive(NvCodec)]
enum BadDataRepr {
A(u32),
}Unknown #[nativeview_codec(...)] keys are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
#[nativeview_codec(unknown_key = "x")]
struct BadKey(u8);Unit-only enums must use Rust discriminants instead of #[nativeview_codec(tag = ...)]:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum BadUnitTag {
#[nativeview_codec(tag = 7)]
A,
}Unsupported integer #[repr(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[repr(i8)]
#[derive(NvCodec)]
enum BadRepr {
A = 1,
}Derives NvEncode and NvDecode for Tier-2 little-endian structs and enums.
§Compile-Time Guards
Generics are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadGeneric<T: nativeview_codec::NvEncode + nativeview_codec::NvDecode>(T);where clauses are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadWhere(u8) where u8: Copy;Field-level #[nativeview_codec(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadFieldAttr {
#[nativeview_codec(skip)]
a: u8,
}Conflicting #[nativeview_codec(tag = ...)] and = discriminant are rejected:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum ConflictingTag {
#[nativeview_codec(tag = 1)]
A(u8) = 2,
}Duplicate enum tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum DupTag {
#[nativeview_codec(tag = 1)]
A(u8),
#[nativeview_codec(tag = 1)]
B(u16),
}Out-of-range tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum OutOfRange {
#[nativeview_codec(tag = 256)]
TooBig(u8),
}Non-u8 data-carrying enums are rejected:
use nativeview_codec::NvCodec;
#[repr(u16)]
#[derive(NvCodec)]
enum BadDataRepr {
A(u32),
}Unknown #[nativeview_codec(...)] keys are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
#[nativeview_codec(unknown_key = "x")]
struct BadKey(u8);Unit-only enums must use Rust discriminants instead of #[nativeview_codec(tag = ...)]:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum BadUnitTag {
#[nativeview_codec(tag = 7)]
A,
}Unsupported integer #[repr(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[repr(i8)]
#[derive(NvCodec)]
enum BadRepr {
A = 1,
}Derives NvEncode and NvDecode for Tier-2 little-endian structs and enums.
§Compile-Time Guards
Generics are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadGeneric<T: nativeview_codec::NvEncode + nativeview_codec::NvDecode>(T);where clauses are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadWhere(u8) where u8: Copy;Field-level #[nativeview_codec(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
struct BadFieldAttr {
#[nativeview_codec(skip)]
a: u8,
}Conflicting #[nativeview_codec(tag = ...)] and = discriminant are rejected:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum ConflictingTag {
#[nativeview_codec(tag = 1)]
A(u8) = 2,
}Duplicate enum tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum DupTag {
#[nativeview_codec(tag = 1)]
A(u8),
#[nativeview_codec(tag = 1)]
B(u16),
}Out-of-range tags are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
enum OutOfRange {
#[nativeview_codec(tag = 256)]
TooBig(u8),
}Non-u8 data-carrying enums are rejected:
use nativeview_codec::NvCodec;
#[repr(u16)]
#[derive(NvCodec)]
enum BadDataRepr {
A(u32),
}Unknown #[nativeview_codec(...)] keys are rejected:
use nativeview_codec::NvCodec;
#[derive(NvCodec)]
#[nativeview_codec(unknown_key = "x")]
struct BadKey(u8);Unit-only enums must use Rust discriminants instead of #[nativeview_codec(tag = ...)]:
use nativeview_codec::NvCodec;
#[repr(u8)]
#[derive(NvCodec)]
enum BadUnitTag {
#[nativeview_codec(tag = 7)]
A,
}Unsupported integer #[repr(...)] attributes are rejected:
use nativeview_codec::NvCodec;
#[repr(i8)]
#[derive(NvCodec)]
enum BadRepr {
A = 1,
}Optional balanced push/pop scope discipline enforced by generated stream decoders
(e.g. ClipRect / RestoreClip capped at MAX_CLIP_DEPTH = 64).
Every generated decoder enforces identical semantics:
- Pushing while
depth < max_depthincrementsdepthBEFORE invoking the push callback (so throwing callbacks still unwind cleanly). - Pushing while
depth >= max_depthskips the push callback and incrementsoverflow. - Popping while
overflow > 0decrementsoverflowwithout invoking the pop callback. - Popping while
overflow == 0 && depth > 0decrementsdepthand invokes the pop callback. - Popping while
overflow == 0 && depth == 0is a no-op. - On normal stream end or callback error/exception unwind, all remaining
depthscopes are closed by invoking the pop callbackdepthtimes.
Fields§
§limit_name: &'static strConstant identifier for the depth cap (e.g. "MAX_CLIP_DEPTH").
push_opcode: u32Opcode that pushes a scope (e.g. 7 for ClipRect).
pop_opcode: u32Opcode that pops a scope (e.g. 8 for RestoreClip; must have zero fields).
max_depth: u32Maximum live scope depth passed to the sink (e.g. 64).