StructDescriptor
- class wpiutil.wpistruct.StructDescriptor(typeString: str, schema: str, size: int, pack: Callable[[Any], bytes], packInto: Callable[[Any, bytearray], None], unpack: Callable[[bytearray], Any], forEachNested: Callable[[Callable[[str, str], None]], None] | None)[source]
Bases:
NamedTuple
To define a type in python that can use the wpilib serialization, the type must have an attribute WPIStruct that contains this class (but C++ classes do not have this).
It is not intended that you should create this class directly, something else should generate it for you.
See
wpiutil.wpistruct.make_wpistruct()
for a easy to use mechanism for defining custom structs using a dataclass.Create new instance of StructDescriptor(typeString, schema, size, pack, packInto, unpack, forEachNested)
- forEachNested: Callable[[Callable[[str, str], None]], None] | None
If this contains nested structs, calls wpiutil.wpistruct.forEachNested for each
- pack: Callable[[Any], bytes]
A function that converts the type to bytes
- packInto: Callable[[Any, bytearray], None]
A function that converts the type to bytes
- schema: str
The struct schema
- size: int
Size in bytes of binary representation of this struct
- typeString: str
The type string
- unpack: Callable[[bytearray], Any]
A function that converts bytes to an instance