If None, will be filled with the size of the payload
| 2272 | |
| 2273 | |
| 2274 | class LenField(Field[int, int]): |
| 2275 | """ |
| 2276 | If None, will be filled with the size of the payload |
| 2277 | """ |
| 2278 | __slots__ = ["adjust"] |
| 2279 | |
| 2280 | def __init__(self, name, default, fmt="H", adjust=lambda x: x): |
| 2281 | # type: (str, Optional[Any], str, Callable[[int], int]) -> None |
| 2282 | Field.__init__(self, name, default, fmt) |
| 2283 | self.adjust = adjust |
| 2284 | |
| 2285 | def i2m(self, |
| 2286 | pkt, # type: Optional[Packet] |
| 2287 | x, # type: Optional[int] |
| 2288 | ): |
| 2289 | # type: (...) -> int |
| 2290 | if x is None: |
| 2291 | x = 0 |
| 2292 | if pkt is not None: |
| 2293 | x = self.adjust(len(pkt.payload)) |
| 2294 | return x |
| 2295 | |
| 2296 | |
| 2297 | class BCDFloatField(Field[float, int]): |
no outgoing calls
no test coverage detected
searching dependent graphs…