Packable

Packable()

Structural protocol for packable sample types.

This protocol allows classes decorated with @packable to be recognized as valid types for lens transformations and schema operations, even though the decorator doesn’t change the class’s nominal type at static analysis time.

Both PackableSample subclasses and @packable-decorated classes satisfy this protocol structurally.

The protocol captures the full interface needed for: - Lens type transformations (as_wds, from_data) - Schema publishing (class introspection via dataclass fields) - Serialization/deserialization (packed, from_bytes)

Examples

>>> @packable
... class MySample:
...     name: str
...     value: int
...
>>> def process(sample_type: Type[Packable]) -> None:
...     # Type checker knows sample_type has from_bytes, packed, etc.
...     instance = sample_type.from_bytes(data)
...     print(instance.packed)