domus

One damus client to rule them all
git clone git://jb55.com/domus
Log | Files | Refs | README

pubkey.rs (502B)


      1 use serde_derive::{Deserialize, Serialize};
      2 
      3 #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone, Hash)]
      4 pub struct Pubkey(String);
      5 
      6 impl AsRef<str> for Pubkey {
      7     fn as_ref(&self) -> &str {
      8         &self.0
      9     }
     10 }
     11 
     12 impl From<String> for Pubkey {
     13     fn from(s: String) -> Self {
     14         Pubkey(s)
     15     }
     16 }
     17 
     18 impl From<&str> for Pubkey {
     19     fn from(s: &str) -> Self {
     20         Pubkey(s.to_owned())
     21     }
     22 }
     23 
     24 impl From<Pubkey> for String {
     25     fn from(pk: Pubkey) -> Self {
     26         pk.0
     27     }
     28 }