use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct ListingData<T> {
pub modhash: Option<String>,
pub dist: Option<i32>,
pub after: Option<String>,
pub before: Option<String>,
pub children: Vec<T>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename = "Listing")]
pub struct Listing<T> {
pub data: ListingData<T>,
}
impl<T> Listing<T> {
pub fn new(items: Vec<T>) -> Self {
Self {
data: ListingData {
modhash: None,
dist: None,
after: None,
before: None,
children: items,
},
}
}
pub fn push(&mut self, item: T) {
self.data.children.push(item);
}
}