Derive Pod/Zeroable for Pubkey

This commit is contained in:
Michael Vines 2021-10-06 17:38:34 -07:00
parent df39b37cb8
commit f966859829
4 changed files with 23 additions and 16 deletions

1
Cargo.lock generated
View File

@ -5271,6 +5271,7 @@ dependencies = [
"borsh-derive",
"bs58 0.4.0",
"bv",
"bytemuck",
"curve25519-dalek 3.2.0",
"hex",
"itertools 0.10.1",

View File

@ -3135,6 +3135,7 @@ dependencies = [
"borsh-derive",
"bs58 0.4.0",
"bv",
"bytemuck",
"curve25519-dalek 3.2.0",
"hex",
"itertools 0.10.1",

View File

@ -16,6 +16,7 @@ blake3 = { version = "1.0.0", features = ["traits-preview"] }
borsh = "0.9.1"
borsh-derive = "0.9.1"
bs58 = "0.4.0"
bytemuck = { version = "1.7.2", features = ["derive"] }
bv = { version = "0.11.1", features = ["serde"] }
hex = "0.4.2"
itertools = "0.10.1"

View File

@ -1,14 +1,16 @@
#![allow(clippy::integer_arithmetic)]
use crate::{decode_error::DecodeError, hash::hashv};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use num_derive::{FromPrimitive, ToPrimitive};
use std::{
convert::{Infallible, TryFrom},
fmt, mem,
str::FromStr,
use {
crate::{decode_error::DecodeError, hash::hashv},
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
bytemuck::{Pod, Zeroable},
num_derive::{FromPrimitive, ToPrimitive},
std::{
convert::{Infallible, TryFrom},
fmt, mem,
str::FromStr,
},
thiserror::Error,
};
use thiserror::Error;
/// Number of bytes in a pubkey
pub const PUBKEY_BYTES: usize = 32;
@ -48,20 +50,22 @@ impl From<u64> for PubkeyError {
#[repr(transparent)]
#[derive(
Serialize,
Deserialize,
BorshSerialize,
AbiExample,
BorshDeserialize,
BorshSchema,
BorshSerialize,
Clone,
Copy,
Default,
Deserialize,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
AbiExample,
Ord,
PartialEq,
PartialOrd,
Pod,
Serialize,
Zeroable,
)]
pub struct Pubkey([u8; 32]);