mv common/ sdk/

This commit is contained in:
Michael Vines
2018-10-25 12:53:50 -07:00
committed by Grimes
parent 471d8f6ff9
commit 1733beabf7
11 changed files with 7 additions and 7 deletions

32
sdk/src/pubkey.rs Normal file
View File

@@ -0,0 +1,32 @@
use bs58;
use generic_array::typenum::U32;
use generic_array::GenericArray;
use std::fmt;
#[repr(C)]
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Pubkey(GenericArray<u8, U32>);
impl Pubkey {
pub fn new(pubkey_vec: &[u8]) -> Self {
Pubkey(GenericArray::clone_from_slice(&pubkey_vec))
}
}
impl AsRef<[u8]> for Pubkey {
fn as_ref(&self) -> &[u8] {
&self.0[..]
}
}
impl fmt::Debug for Pubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
}
}
impl fmt::Display for Pubkey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", bs58::encode(self.0).into_string())
}
}