Prepare loading state

This commit is contained in:
2021-08-12 15:48:02 +02:00
parent 1aba33fb91
commit 26142084f6
2 changed files with 25 additions and 5 deletions
+19
View File
@@ -1,3 +1,5 @@
use std::ops::Deref;
use serde::{Deserialize, Serialize, Serializer};
/// A generic list returntype containing the User and a Vec containing e.g. Links or Users
#[derive(Clone, Deserialize, Serialize)]
@@ -86,3 +88,20 @@ impl std::fmt::Display for Secret {
f.write_str("*****SECRET*****")
}
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Loadable<T> {
Data(Option<T>),
Loading,
}
impl<T> Deref for Loadable<T>{
type Target = Option<T>;
fn deref(&self) -> &Self::Target {
match self {
Loadable::Data(t) => t,
Loadable::Loading => &None
}
}
}