Skip to content

Custom types with HasCompact #613

Open
@lemunozm

Description

@lemunozm

Hi, I have a custom wrapper type that, in terms of encoding/decoding, should behave exactly as its underlying type:

type MyWrapper<T>;

I'm able to implement Encode/Decode successfully, nevertheless, if this type is used as follows:

struct Foo {
    #[codec(compact)]
    a: MyWrapper<u64>,
}

The compile throws an error. Basically, it requires that CompactRef<'a, MyWrapper<u64>> implements Encode/Decode. But I can not do that because both CompactRef and Encode/Decode are foreign to my crate. I can neither implement HasCompact directly because it's already implemented for T in the library, and to fulfill the conditions, I need the CompactRef implementation.

Is any way to create compactables custom types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions