2021-09-19 19:32:04 +00:00
|
|
|
#[derive(Clone, Copy, Debug, serde::Deserialize)]
|
2020-12-08 21:59:55 +00:00
|
|
|
pub(crate) enum Extension {
|
|
|
|
#[serde(rename = "jpg")]
|
|
|
|
Jpg,
|
|
|
|
|
|
|
|
#[serde(rename = "webp")]
|
|
|
|
Webp,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Extension {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
Self::Jpg => write!(f, "jpg"),
|
|
|
|
Self::Webp => write!(f, "webp"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize)]
|
|
|
|
pub(crate) struct Image {
|
|
|
|
file: String,
|
|
|
|
delete_token: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Image {
|
|
|
|
pub(crate) fn file(&self) -> &str {
|
|
|
|
&self.file
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn delete_token(&self) -> &str {
|
|
|
|
&self.delete_token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize)]
|
|
|
|
pub(crate) struct Images {
|
|
|
|
msg: String,
|
|
|
|
files: Option<Vec<Image>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Images {
|
2022-05-27 23:27:44 +00:00
|
|
|
pub(crate) fn msg(&self) -> &str {
|
|
|
|
&self.msg
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn files(&self) -> impl Iterator<Item = &Image> {
|
|
|
|
self.files.iter().flat_map(|v| v.iter())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, serde::Deserialize)]
|
|
|
|
pub(crate) struct Upload {
|
|
|
|
upload_id: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Upload {
|
|
|
|
pub(crate) fn id(&self) -> &str {
|
|
|
|
&self.upload_id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize)]
|
|
|
|
pub(crate) struct Uploads {
|
|
|
|
msg: String,
|
|
|
|
uploads: Option<Vec<Upload>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Uploads {
|
2020-12-08 21:59:55 +00:00
|
|
|
pub(crate) fn is_err(&self) -> bool {
|
2022-05-27 23:27:44 +00:00
|
|
|
self.uploads.is_none()
|
2020-12-08 21:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn message(&self) -> &str {
|
|
|
|
&self.msg
|
|
|
|
}
|
|
|
|
|
2022-05-27 23:27:44 +00:00
|
|
|
pub(crate) fn files(&self) -> impl Iterator<Item = &Upload> {
|
|
|
|
self.uploads.iter().flat_map(|v| v.iter())
|
2020-12-08 21:59:55 +00:00
|
|
|
}
|
|
|
|
}
|