Prepare loading state
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user