Add casting method to our struct variant

kraken_userref_hackzin
Tyler Goodlet 2022-07-30 14:27:50 -04:00
parent e6a3e8b65a
commit db564d7977
1 changed files with 7 additions and 0 deletions

View File

@ -66,3 +66,10 @@ class Struct(
).decode(
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)))