use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct CryptoAsset(String);
impl CryptoAsset {
pub fn new(symbol: impl Into<String>) -> Self {
Self(symbol.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl From<String> for CryptoAsset {
fn from(s: String) -> Self {
CryptoAsset(s)
}
}
impl From<&str> for CryptoAsset {
fn from(s: &str) -> Self {
CryptoAsset(s.to_string())
}
}
impl Display for CryptoAsset {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}