use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Coin {
pub name: String,
pub ticker: String,
pub slug: String,
pub has_png: bool,
pub has_svg: bool,
pub search_terms: Vec<String>,
pub market_cap_rank: Option<i32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogoFormat {
Svg,
Png,
WebP,
Jpeg,
Ico,
}
impl fmt::Display for LogoFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LogoFormat::Svg => write!(f, "svg"),
LogoFormat::Png => write!(f, "png"),
LogoFormat::WebP => write!(f, "webp"),
LogoFormat::Jpeg => write!(f, "jpeg"),
LogoFormat::Ico => write!(f, "ico"),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct LogoOptions {
pub width: Option<u32>,
pub height: Option<u32>,
pub bg: Option<String>,
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("Not found: {0}")]
NotFound(String),
#[error("HTTP {status}: {url}")]
Status { status: u16, url: String },
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}