account_id.rs 466 B

123456789101112131415161718192021222324
  1. use std::fmt::Display;
  2. use serde::Serialize;
  3. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)]
  4. pub struct AccountId(pub [u8; 32]);
  5. impl AccountId {
  6. pub fn new() -> Self {
  7. Self([0; 32])
  8. }
  9. }
  10. impl Display for AccountId {
  11. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  12. write!(f, "{}", hex::encode(self.0))
  13. }
  14. }
  15. impl AsRef<[u8]> for AccountId {
  16. fn as_ref(&self) -> &[u8] {
  17. &self.0
  18. }
  19. }