tendermint/
moniker.rs

1//! Monikers: names associated with validators
2
3use core::{
4    fmt::{self, Display},
5    str::FromStr,
6};
7
8use serde::{Deserialize, Serialize};
9
10use crate::{error::Error, prelude::*};
11
12/// Validator display names
13#[derive(Serialize, Deserialize, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
14pub struct Moniker(String);
15
16impl FromStr for Moniker {
17    type Err = Error;
18
19    fn from_str(s: &str) -> Result<Self, Error> {
20        Ok(Moniker(s.to_owned()))
21    }
22}
23
24impl AsRef<str> for Moniker {
25    fn as_ref(&self) -> &str {
26        self.0.as_ref()
27    }
28}
29
30impl Display for Moniker {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        write!(f, "{}", self.0)
33    }
34}