use std::ops::{Deref, DerefMut, Index, IndexMut};
use crate::details::Details;
#[derive(serde::Deserialize, Debug, Clone, Hash)]
struct NekosBestResponseV2 {
results: Vec<NekosBestResponseSingle>,
}
#[derive(serde::Deserialize, Debug, Clone, Hash)]
#[serde(from = "NekosBestResponseV2")]
pub struct NekosBestResponse(pub Vec<NekosBestResponseSingle>);
impl From<NekosBestResponseV2> for NekosBestResponse {
fn from(r: NekosBestResponseV2) -> Self {
NekosBestResponse(r.results)
}
}
impl Index<usize> for NekosBestResponse {
type Output = NekosBestResponseSingle;
fn index(&self, index: usize) -> &Self::Output {
self.0.index(index)
}
}
impl IndexMut<usize> for NekosBestResponse {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
self.0.index_mut(index)
}
}
impl Deref for NekosBestResponse {
type Target = Vec<NekosBestResponseSingle>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for NekosBestResponse {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
#[derive(Debug, Clone, Hash, serde::Deserialize)]
pub struct NekosBestResponseSingle {
pub url: String,
#[serde(flatten)]
pub details: Details,
pub dimensions: NekosBestDimensions,
}
impl Deref for NekosBestResponseSingle {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.url
}
}
impl DerefMut for NekosBestResponseSingle {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.url
}
}
#[derive(Debug, Clone, Hash, serde::Deserialize)]
pub struct NekosBestDimensions {
pub width: u32,
pub height: u32,
}