Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

the trait BitStore is not implemented for u64 #570

Closed
polariseye opened this issue Jun 17, 2022 · 7 comments
Closed

the trait BitStore is not implemented for u64 #570

polariseye opened this issue Jun 17, 2022 · 7 comments

Comments

@polariseye
Copy link

hi,
when i build with arm64-v8a.the error shown.

rror[E0277]: the trait bound `u64: BitStore` is not satisfied
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/subxt-0.21.0/src/events/decoding.rs:201:36
    |
201 |                     consume_type::<BitVec<u64, Lsb0>>(input)
    |                                    ^^^^^^^^^^^^^^^^^ the trait `BitStore` is not implemented for `u64`
    |
    = help: the following implementations were found:
              <u16 as BitStore>
              <u32 as BitStore>
              <u8 as BitStore>
              <usize as BitStore>
note: required by a bound in `BitVec`
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/bitvec-1.0.0/src/vec.rs:56:5
    |
56  |     T: BitStore,
    |        ^^^^^^^^ required by this bound in `BitVec`

error[E0277]: the trait bound `BitVec<u64>: Decode` is not satisfied
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/subxt-0.21.0/src/events/decoding.rs:201:36
    |
201 |                     consume_type::<BitVec<u64, Lsb0>>(input)
    |                                    ^^^^^^^^^^^^^^^^^ the trait `Decode` is not implemented for `BitVec<u64>`
    |
    = help: the following implementations were found:
              <BitVec<T, O> as Decode>
    = note: required because of the requirements on the impl of `Codec` for `BitVec<u64>`
note: required by a bound in `consume_type`
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/subxt-0.21.0/src/events/decoding.rs:49:24
    |
49  |     fn consume_type<T: Codec>(input: &mut &[u8]) -> Result<(), BasicError> {
    |                        ^^^^^ required by this bound in `consume_type`

error[E0277]: the trait bound `BitVec<u64>: Encode` is not satisfied
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/subxt-0.21.0/src/events/decoding.rs:201:36
    |
201 |                     consume_type::<BitVec<u64, Lsb0>>(input)
    |                                    ^^^^^^^^^^^^^^^^^ the trait `Encode` is not implemented for `BitVec<u64>`
    |
    = help: the following implementations were found:
              <BitVec<T, O> as Encode>
    = note: required because of the requirements on the impl of `Codec` for `BitVec<u64>`
note: required by a bound in `consume_type`
   --> /home/polaris/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/subxt-0.21.0/src/events/decoding.rs:49:24
    |
49  |     fn consume_type<T: Codec>(input: &mut &[u8]) -> Result<(), BasicError> {
    |                        ^^^^^ required by this bound in `consume_type`

For more information about this error, try `rustc --explain E0277`.

the build command is cargo ndk -t arm64-v8a

what i want is build the package to android and ios.so could you add the support for u64

@jsdw
Copy link
Collaborator

jsdw commented Jun 17, 2022

Ah, I think the issue is that BitVec doesn't implement u64 bitstores on some platforms by the sounds of that error message. We'd have to look into why not, consider adding a feature flag or cfg to remove support ourselves, and perhaps more importantly see what other support is missing to get it compiling for that target and whether we can commit to supporting it as a target.

In the meantime, you could experiment by forking subxt and removing the match arm here:

TypeDef::Primitive(TypeDefPrimitive::U64) => {

and see whether things compile OK after that?

@jsdw
Copy link
Collaborator

jsdw commented Jun 17, 2022

Other note: I'm planning to replace this decode logic entirely with scale-value, so any actual support/fix should end up there once we make use of decoding from it.

@polariseye
Copy link
Author

Ah, I think the issue is that BitVec doesn't implement u64 bitstores on some platforms by the sounds of that error message. We'd have to look into why not, consider adding a feature flag or cfg to remove support ourselves, and perhaps more importantly see what other support is missing to get it compiling for that target and whether we can commit to supporting it as a target.

In the meantime, you could experiment by forking subxt and removing the match arm here:

TypeDef::Primitive(TypeDefPrimitive::U64) => {

and see whether things compile OK after that?

i compile success with code:

TypeDef::Primitive(TypeDefPrimitive::U64) => {
                    //consume_type::<BitVec<u64, Lsb0>>(input)
                    let mut u64_val=[0u8;8];
                    Input::read(input, u64_val.as_mut_slice())?;
                    Ok(())
                }

@polariseye
Copy link
Author

thank you

Ah, I think the issue is that BitVec doesn't implement u64 bitstores on some platforms by the sounds of that error message. We'd have to look into why not, consider adding a feature flag or cfg to remove support ourselves, and perhaps more importantly see what other support is missing to get it compiling for that target and whether we can commit to supporting it as a target.

that sounds perfect. thank you for youer answers. best wishes to you.

@jsdw
Copy link
Collaborator

jsdw commented Jun 20, 2022

i compile success with code:

TypeDef::Primitive(TypeDefPrimitive::U64) => {
                    //consume_type::<BitVec<u64, Lsb0>>(input)
                    let mut u64_val=[0u8;8];
                    Input::read(input, u64_val.as_mut_slice())?;
                    Ok(())
                }

This code looks like it will compile, but it wouldn't do the right thing at runtime.

It's probably better just to remove the match arm and let the error arm at the end let you know if something has tried to return this type and errored, because your code will act OK but not do the right thing :)

I'm going to re-open this issue, because I had a look at what BitVec does, and I'll use the config thing bitvec does to remove this match arm in scale-value, and then migrate subxt to use scale-value to decode events so it'll benefit from this.

@jsdw
Copy link
Collaborator

jsdw commented Jun 21, 2022

This will be closed by #576 when a small change to scale_value is published as a patch version bump :)

@jsdw jsdw closed this as completed Jun 21, 2022
@jsdw jsdw reopened this Jun 21, 2022
@jsdw
Copy link
Collaborator

jsdw commented Jun 27, 2022

With the release of scale_value 0.2.1, this should be resolved now as of the latest master, if you make sure to install the latest dependencies asked for.

@jsdw jsdw closed this as completed Jun 27, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants