-
Notifications
You must be signed in to change notification settings - Fork 183
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 SignedPlainOldULE, add serialize impls for ULE types (also missing Eq impl for VZV) #1356
Conversation
I'm not totally convinced. |
@sffc Yes, I think those questions should be raised: the answer (in this model) is to use POU only if you either:
otherwise you should wrap POU with your own wrapper that forwards the ULE impl. An alternate solution is to provide |
Actually, not |
I can try implementing that instead, I think it would be pretty clean. |
#1357. I definitely like this better |
in ZeroVec the "non ULE" version is always available so we can always convert to/from it for ser/de. However, VZV deals with unsized types and as such does not know anything about the "non ULE" version (EncodeAsVarULE helps but only in specific contexts). We could use FromVarULE (#1180) here but
FromVarULE
will likely allow for multiple impls and there wouldn't be a way to select a particular one.The current ser/de impls for VarZeroVec will serialize the byte buffer on machine formats, but for human readable formats will instead convert each element to
Box<T>
and serialize that instead.For human readable serialization to do the "right thing", the serialization of the VarULE type should "look like the serialization of a normal type". This works out fine for regular
VarULE
types, however we have a complication when it comes to types like[T: ULE]
because there can be more than one AsULE type that it matches. We would likeVarZeroVec<[i32::ULE]>
andVarZeroVec<[u32::ULE]>
to have human readable serializations that show the actual integer (as opposed to a byte buffer).This means that
u32
andi32
cannot map to the same ULE type since the ULE type must have different ser/de impls. This PR adds aSignedPlainOldULE
type whose only difference is in how it ser/des.Needed by @echeran for #1353, though in his PR he probably should have a wrapper type that serializes as a Script.