Source code for lcmtypes.sym._lambda_update_type_t
# This file automatically generated by skymarshal# DO NOT MODIFY BY HAND## From Source File: /home/runner/work/symforce/symforce/lcmtypes/symforce.lcm# fmt: off# isort: off# mypy: disallow-untyped-defsimporttypingasTfromioimportBytesIOimportenumimportstructclasslambda_update_type_t(enum.Enum):INVALID=0STATIC=1DYNAMIC=2def__repr__(self):# type: () -> strreturn"{}.{}".format(self.__class__.__name__,self.name)@staticmethoddef_skytype_meta():# type: () -> T.Dict[str, str]returndict(type="enum",package="sym",name="lambda_update_type_t",)@classmethoddef_default(cls):# type: () -> lambda_update_type_t# Return the first enum casereturnlist(cls)[0]defencode(self):# type: () -> bytesbuf=BytesIO()buf.write(self._get_packed_fingerprint())self._encode_one(buf)returnbuf.getvalue()def_encode_one(self,buf):# type: (T.BinaryIO) -> Nonebuf.write(struct.pack('>i',self.value))@classmethoddefdecode(cls,data):# type: (T.Union[bytes, T.BinaryIO]) -> lambda_update_type_t# NOTE(eric): This function can technically accept either a BinaryIO or# anything that supports the C++ Buffer Protocol,# which is unspecifiable in type hints.ifhasattr(data,"read"):# NOTE(eric): mypy isn't able to figure out the hasattr checkbuf=T.cast(T.BinaryIO,data)else:buf=BytesIO(T.cast(bytes,data))ifbuf.read(8)!=cls._get_packed_fingerprint():raiseValueError("Decode error")returncls._decode_one(buf)@classmethoddef_decode_one(cls,buf):# type: (T.BinaryIO) -> lambda_update_type_tvalue=struct.unpack('>i',buf.read(4))[0]result=cls.from_int(value)ifresultisNone:returncls._default()returnresult@T.overload@classmethoddeffrom_int(cls,value,default):# type: (int, lambda_update_type_t) -> lambda_update_type_tpass@T.overload@classmethoddeffrom_int(cls,value,default=None):# pylint: disable=function-redefined# type: (int, None) -> T.Optional[lambda_update_type_t]pass@classmethoddeffrom_int(cls,value,default=None):# pylint: disable=function-redefined# type: (int, T.Optional[lambda_update_type_t]) -> T.Optional[lambda_update_type_t]""" An alternative to "lambda_update_type_t(value)" which will return the given default instead of raising a ValueError for unknown values. """try:returncls(value)exceptValueError:# Value unlisted / not associated with any casereturndefault@classmethoddef_get_hash_recursive(cls,parents):# type: (T.List[T.Type]) -> intifclsinparents:return0tmphash=(0xa6869f09f492d897)&0xfffffffffffffffftmphash=(((tmphash<<1)&0xffffffffffffffff)+(tmphash>>63))&0xffffffffffffffffreturntmphash@classmethoddef_get_packed_fingerprint(cls):# type: () -> bytesreturnstruct.pack(">Q",cls._get_hash_recursive([]))