Add casting method to our struct variant
parent
e6a3e8b65a
commit
db564d7977
|
@ -66,3 +66,10 @@ class Struct(
|
||||||
).decode(
|
).decode(
|
||||||
msgspec.msgpack.Encoder().encode(self)
|
msgspec.msgpack.Encoder().encode(self)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def typecast(
|
||||||
|
self,
|
||||||
|
# fields: Optional[list[str]] = None,
|
||||||
|
) -> None:
|
||||||
|
for fname, ftype in self.__annotations__.items():
|
||||||
|
setattr(self, fname, ftype(getattr(self, fname)))
|
||||||
|
|
Loading…
Reference in New Issue