use std::fmt::Display;
use crate::constants::CURRENT_CONGRESS;
use crate::error::Error;
use crate::utils::Result;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Congress(pub usize);
impl Congress {
pub(crate) fn parse(input: usize) -> Result<Self> {
if input <= *CURRENT_CONGRESS {
Ok(Congress(input))
} else {
Err(Error::InvalidCongress)
}
}
}
impl Display for Congress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Chamber {
House,
Senate,
}
impl Display for Chamber {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::House => 'h',
Self::Senate => 's',
}
)
}
}
impl Chamber {
pub(crate) fn parse(input: &str) -> Self {
if input.starts_with('h') {
Self::House
} else {
Self::Senate
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum MeasureType {
Bill,
Resolution,
ConcurrentResolution,
JointResolution,
}
impl Display for MeasureType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Bill => "",
Self::Resolution => "res",
Self::ConcurrentResolution => "conres",
Self::JointResolution => "jres",
}
)
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum CommitteeDocumentType {
Print,
Report,
}
impl Display for CommitteeDocumentType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Self::Print => "prt",
Self::Report => "rpt",
}
)
}
}