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

Deserialize arrays in Borsh? #123

Closed
vedantroy opened this issue Nov 29, 2021 · 1 comment
Closed

Deserialize arrays in Borsh? #123

vedantroy opened this issue Nov 29, 2021 · 1 comment

Comments

@vedantroy
Copy link

I'm trying to use Borsh to deserialize a large array.

pixels: [(Pubkey, u8); 1_000 * 1_000],

I've added the following crate attribute:

#![feature(trivial_bounds)]

And I'm getting the error:

   |
76 | #[account]
   | ^^^^^^^^^^ the trait `BorshSerialize` is not implemented for `[(anchor_lang::prelude::Pubkey, u8); 1000000]`
   | 
  ::: /home/vedantroy/.cargo/registry/src/github.com-1ecc6299db9ec823/borsh-0.9.1/src/ser/mod.rs:44:18
   |
44 |     fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>;
   |                  - required by this bound in `anchor_lang::AnchorSerialize::serialize`
   |
   = help: the following implementations were found:
             <[T; 0] as BorshSerialize>
             <[T; 1024] as BorshSerialize>
             <[T; 10] as BorshSerialize>
             <[T; 11] as BorshSerialize>
           and 37 others
   = note: required because of the requirements on the impl of `BorshSerialize` for `GameState`
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `[(anchor_lang::prelude::Pubkey, u8); 1000000]: BorshDeserialize` is not satisfied
  --> programs/auction/src/lib.rs:76:1
   |
76 | #[account]
   | ^^^^^^^^^^ the trait `BorshDeserialize` is not implemented for `[(anchor_lang::prelude::Pubkey, u8); 1000000]`
   |
   = help: the following implementations were found:
             <[T; 0] as BorshDeserialize>
             <[T; 1024] as BorshDeserialize>
             <[T; 10] as BorshDeserialize>
             <[T; 11] as BorshDeserialize>
           and 36 others
   = note: required because of the requirements on the impl of `BorshDeserialize` for `GameState`
   = note: required by `anchor_lang::AnchorDeserialize::deserialize`
   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `auction`

Is there any way to get around this?

@vedantroy
Copy link
Author

Closing in favor of: near/borsh-rs#44

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

1 participant