-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add codec objects #364
base: main
Are you sure you want to change the base?
Add codec objects #364
Commits on Nov 25, 2024
-
Codecs are any objects that can be en- and decoded into PDUs. The approach so far was to derive all "composite" codecs from `BasicStructure` and to use a subset of that API for "simple" codable objects like DOPs or parameters. In particular, the previous approach to composite objects was sub-optimal because `BASIC-STRUCTURE` features subtags that other codable objects like `Request` and `Response` do not exhibit (i.e., `.byte_size`). Since codecs do not play very nicely with inheritance, the new approach is based on typing protocols (Java would call these "interfaces"): `codec.py` defines a few runtime checkable `typing.Protocol` classes which codecs must implement: `Codec` for the basic functionality, `CompositeCodec` defines the API for codecs that are composed of a list of parameters like structures, requests, responses or environment datas, and `ToplevelCodec` defines the "external" API for requests and responses that is supposed to be called by user scripts. Any codable class implementing these APIs can check if it is compliant using `isinstance()` in the `__post_init__()` method of the respective class. Signed-off-by: Andreas Lauser <[email protected]> Signed-off-by: Alexander Walz <[email protected]> Signed-off-by: Gunnar Andersson <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fbfbfe7 - Browse repository at this point
Copy the full SHA fbfbfe7View commit details -
refrain from checking adherence of DOPs and basic structures to the C…
…odec APIs at runtime as [at]kayoub5 correctly notes, this is already done by `mypy` ahead of time. Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 428b2ee - Browse repository at this point
Copy the full SHA 428b2eeView commit details -
Message: remove deprecated
.structure
propertythis property has been deprecated for more than a year and after this pull request, request and response objects are no longer structures. Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5f97146 - Browse repository at this point
Copy the full SHA 5f97146View commit details -
Request
/Response
: remove unnecessary exception handlingthe intention of this was to make the code more robust in non-strict mode, but come think about it, exceptions raised by `._resolve_snref()` will not be caught even in non-strict mode, so we can as well simply skip the exception handling entirely. (besides this, `context.response` is now properly set in `Response._resolve_snrefs()`.) thanks to [at]kayoub5 for noticing this... Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e1688c8 - Browse repository at this point
Copy the full SHA e1688c8View commit details -
remove the
ToplevelCodec
type protocolAs [at]kayoub5 rightfully notes, this was not used anywere for real. (Also, the `Response` class did not even strictly implement it, because the `.decode()` and `.encode()` methods accept the additional `coded_request` argument.) Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 96b8e26 - Browse repository at this point
Copy the full SHA 96b8e26View commit details -
DataObjectProperty: remove unnecessary
.byte_size
propertythis was an artifact stemming from the development history of this PR: originally, the `Codec` type protocol mandated this property, but it turned out that the better approach was to move handling of statically-sized structures from the generic function (`composite_codec_get_static_bit_length()`) to the `get_static_bit_length()` method of structures. Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 068f479 - Browse repository at this point
Copy the full SHA 068f479View commit details -
Thanks for the catch, [at]kayoub5. Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1da10e7 - Browse repository at this point
Copy the full SHA 1da10e7View commit details -
replace structure by composite codec in some comments
thanks to [at]kayoub5 Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 4483a3b - Browse repository at this point
Copy the full SHA 4483a3bView commit details -
DiagCodedType: remove spurious
byte_size
propertythanks to [at]kayoub5 Signed-off-by: Andreas Lauser <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bf33ea2 - Browse repository at this point
Copy the full SHA bf33ea2View commit details