Skip to content
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

Support Compact<Option<T>> #295

Open
athei opened this issue Oct 13, 2021 · 2 comments
Open

Support Compact<Option<T>> #295

athei opened this issue Oct 13, 2021 · 2 comments

Comments

@athei
Copy link
Member

athei commented Oct 13, 2021

There is currently no easy way to compact encode a value that is wrapped in an option. We should add:

impl<T> {Encode, Decode} for Compact<Option<T>> where Compact<T>: {Encode, Decode} {
    ...
}

The compact encoding of the Option itself is unchanged from the non compact one: Prepending one byte to indicate none or some.

@thiolliere
Copy link
Contributor

I'm not sure, this seems it wants to use the type Option<Compact<T>> instead.

Maybe it would be even better to have a real compact encoding for Option<interger> instead, like we could same as scale codec but with one bit used for the None/Some variant.

@athei
Copy link
Member Author

athei commented Oct 18, 2021

Yes I think it makes total sense to have a smarter compact encoding for Option<integer>. In my current use case that would suffice as I have a integer type at hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants