2022-05-08 23:30:49 +02:00
|
|
|
/*\
|
2021-01-06 21:35:46 +01:00
|
|
|
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
|
|
|
View
|
|
|
|
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
|
|
|
\*/
|
2021-11-19 12:19:52 +01:00
|
|
|
pub trait View: Send + Sync {
|
2021-01-06 21:35:46 +01:00
|
|
|
/// Notification message for the observers
|
2021-11-19 12:19:52 +01:00
|
|
|
type Msg: Send + Sync;
|
2021-01-06 21:35:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
|
|
|
|
2021-03-30 22:47:05 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::RwLock;
|
2021-01-06 21:35:46 +01:00
|
|
|
|
2021-01-19 22:54:50 +01:00
|
|
|
impl<V: View + ?Sized> View for RwLock<V> {
|
2021-01-06 21:35:46 +01:00
|
|
|
type Msg = V::Msg;
|
|
|
|
}
|
|
|
|
|
2021-01-19 22:54:50 +01:00
|
|
|
impl<V: View + ?Sized> View for Arc<V> {
|
2021-01-06 21:35:46 +01:00
|
|
|
type Msg = V::Msg;
|
|
|
|
}
|
|
|
|
|
2021-01-19 22:54:50 +01:00
|
|
|
impl<V: View> View for Option<V> {
|
|
|
|
type Msg = V::Msg;
|
|
|
|
}
|