manifold/src/models/dadjoke.rs

29 lines
596 B
Rust
Raw Normal View History

2023-08-30 17:44:39 +00:00
use std::fmt::{Display, Formatter};
use crate::models::fueltank::Pump;
#[derive(Serialize, Deserialize, Debug)]
pub struct DadJoke {
pub id: String,
pub joke: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct DadJokeWrapper {
pub results: Vec<DadJoke>
}
impl Display for DadJoke {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.joke)
}
}
impl Pump<DadJoke> for DadJokeWrapper {
fn pump(&mut self) -> Option<DadJoke> {
self.results.pop()
}
fn len(&self) -> usize {
self.results.len()
}
}