Repository navigation
@custom_serialize / @custom_deserialize DSL - #234
Merged
Merged
Conversation
e.g. `; @custom_serialize write_hex_bytes` For specifying externally-provided functions for arbitrary encodings/cbor details for (de)serialization. Allowed at both the type-level (affecting everywhere it's used) or at the field-level (overrides type-level if present). Example use-case: CML's PlutusData's Bytes (and BigInt) variant doesn't use arbitrary CBOR bytes strings but instead follows a specific chunking format. We used to hand code this but now we can just put this in the DSL. This is particularily useful for people generating plutus-datum-based CDDLs. It could also be used to allow for utf8 text (rust API) to be (de)serialized to bytes to be encodable as a datum. TODO: [ ] tests for preserve-encodings [ ] tests for tagged/otherwise extra encoding details over top of this
rooooooooob
marked this pull request as draft
April 26, 2024 19:16
|
|
||
| Avoids generating and/or deriving json-related traits under the assumption that the user will supply their own implementation to be used in the generated library. | ||
|
|
||
| ## @custom_serialize / @custom_deserialize |
Collaborator
There was a problem hiding this comment.
I think it's not necessarily obvious from the docs that what comes after these is a user-specified arbitrary string (i.e. write_hex_string is not some magical thing built into cddl-codegen, but rather an arbitrary string we just used as an example)
Contributor
Author
There was a problem hiding this comment.
I added a short paragraph explaining that the string is just directly called and thus must be qualified or imported.
SebastienGllmt
approved these changes
May 17, 2024
SebastienGllmt
left a comment
Collaborator
There was a problem hiding this comment.
LGTM other than the comment about the docs
SebastienGllmt
pushed a commit
that referenced
this pull request
Aug 18, 2026
* @custom_serialize / @custom_deserialize DSL e.g. `; @custom_serialize write_hex_bytes` For specifying externally-provided functions for arbitrary encodings/cbor details for (de)serialization. Allowed at both the type-level (affecting everywhere it's used) or at the field-level (overrides type-level if present). Example use-case: CML's PlutusData's Bytes (and BigInt) variant doesn't use arbitrary CBOR bytes strings but instead follows a specific chunking format. We used to hand code this but now we can just put this in the DSL. This is particularily useful for people generating plutus-datum-based CDDLs. It could also be used to allow for utf8 text (rust API) to be (de)serialized to bytes to be encodable as a datum. TODO: [ ] tests for preserve-encodings [ ] tests for tagged/otherwise extra encoding details over top of this * preserve-encodings=true tests * docs + more test cases + misc fixes * clarify where the custom_serialize string comes from
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
e.g.
; @custom_serialize write_hex_bytesFor specifying externally-provided functions for arbitrary encodings/cbor details for (de)serialization.
Allowed at both the type-level (affecting everywhere it's used) or at the field-level (overrides type-level if present).
Example use-case: CML's PlutusData's Bytes (and BigInt) variant doesn't use arbitrary CBOR bytes strings but instead follows a specific chunking format. We used to hand code this but now we can just put this in the DSL.
This is particularily useful for people generating plutus-datum-based CDDLs. It could also be used to allow for utf8 text (rust API) to be (de)serialized to bytes to be encodable as a datum.