moddef.codec package¶
Codec (spec §8–§15): pure functions over schema Points, kept in behavioral lockstep with go/codec, moddef-ts, and moddef-rs (shared vector suite in tests/test_codec.py).
- moddef.codec.decode_all(points: Iterable[Point], regs_by_id: Mapping[str, Sequence[int]]) dict[str, float | int | bool | str | bytes | list[str] | dict[str, int] | datetime | Unavailable][source]¶
Decode several points, resolving refs among them first.
- moddef.codec.decode_point(p: Point, regs: Sequence[int], ctx: Mapping[str, int] | None = None) float | int | bool | str | bytes | list[str] | dict[str, int] | datetime | Unavailable[source]¶
Decode the registers for a point into a typed value.
- moddef.codec.decode_point_raw(p: Point, regs: Sequence[int]) tuple[int, int][source]¶
Pre-scale integer view for callers that need exactness: (raw, bits).
- moddef.codec.encode_point(p: Point, value: float | int | bool | str | bytes | Sequence[str] | datetime, ctx: Mapping[str, int] | None = None) list[int][source]¶
Serialize a typed value into register words per the point’s mapping.
- moddef.codec.point_words(p: Point) int[source]¶
Register count to read/write for p (mapping length or storage width).
- moddef.codec.resolve_context(points: Iterable[Point], regs_by_id: Mapping[str, Sequence[int]]) dict[str, int][source]¶
Decode every point that is a scale_ref/selector_ref target into ints.