substreams_solana_program_instructions/
pubkey.rs1pub const PUBKEY_BYTES: usize = 32;
3#[derive(Clone, Copy, Debug, PartialEq)]
13pub struct Pubkey(pub(crate) [u8; 32]);
14
15impl Pubkey{
16 pub fn to_bytes(self) -> [u8; 32] {
17 self.0
18 }
19}
20
21impl AsRef<[u8]> for Pubkey {
22 fn as_ref(&self) -> &[u8] {
23 &self.0[..]
24 }
25}
26
27impl From<[u8; 32]> for Pubkey {
28 #[inline]
29 fn from(from: [u8; 32]) -> Self {
30 Self(from)
31 }
32}
33
34impl TryFrom<&[u8]> for Pubkey {
35 type Error = std::array::TryFromSliceError;
36
37 #[inline]
38 fn try_from(pubkey: &[u8]) -> Result<Self, Self::Error> {
39 <[u8; 32]>::try_from(pubkey).map(Self::from)
40 }
41}
42
43impl TryFrom<Vec<u8>> for Pubkey {
44 type Error = Vec<u8>;
45
46 #[inline]
47 fn try_from(pubkey: Vec<u8>) -> Result<Self, Self::Error> {
48 <[u8; 32]>::try_from(pubkey).map(Self::from)
49 }
50}
51