Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Refactor ERD encode/decode methods #4

@ajmarks

Description

@ajmarks

Many of the ERD code values are represented by Enums, NamedTuples, or similar. Currently, translation between those occurs in a bunch of tiny functions in erd_utils.py. This is gross and cumbersome. Rather, we should have a protocol like

class ErdValueP(Generic[T]):
    def erd_encode(self, value: T) -> bytes: ...
    def erd_decode(self, raw_value: bytes) -> T: ...

and have each of those special types implement the protocol. Unencodable values can simply raise a NotImplementedError or similar. The Appliance.{encode/decode}_erd_value methods can then be updated to simply dispatch to the correct object's method.

We'll also probably need a register_erd_type(erd_code: ErdType) decorator to set up dispatch to the correct decoded.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions