use serde::{Deserialize, Serialize};
use super::primitives::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Era {
Byron,
Shelley,
Allegra,
Mary,
Alonzo,
Babbage,
Conway,
}
impl Era {
pub fn as_str(&self) -> &'static str {
match self {
Era::Byron => "byron",
Era::Shelley => "shelley",
Era::Allegra => "allegra",
Era::Mary => "mary",
Era::Alonzo => "alonzo",
Era::Babbage => "babbage",
Era::Conway => "conway",
}
}
}
impl std::fmt::Display for Era {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum EraWithGenesis {
Byron,
Shelley,
Alonzo,
Conway,
}
impl EraWithGenesis {
pub fn as_str(&self) -> &'static str {
match self {
EraWithGenesis::Byron => "byron",
EraWithGenesis::Shelley => "shelley",
EraWithGenesis::Alonzo => "alonzo",
EraWithGenesis::Conway => "conway",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EraSummary {
pub start: EraBound,
#[serde(default)]
pub end: Option<EraBound>,
pub parameters: EraParameters,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EraBound {
pub slot: Slot,
pub epoch: Epoch,
pub time: RelativeTime,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EraParameters {
pub epoch_length: u64,
pub slot_length: RelativeTime,
#[serde(default)]
pub safe_zone: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EraStart {
pub time: RelativeTime,
pub slot: Slot,
pub epoch: Epoch,
}