reactive_signals/signals/types/
client.rs

1use super::{OptReadable, SignalType};
2
3/// A client-side function that produces a value that doesn't implement [PartialEq]
4pub struct ClientFunc<T>(pub(crate) T);
5
6impl<T> OptReadable for ClientFunc<T> {
7    const RUN_ON_SERVER: bool = false;
8}
9
10impl<T: 'static> SignalType for ClientFunc<T> {
11    type Inner = T;
12
13    fn inner(&self) -> &Self::Inner {
14        &self.0
15    }
16    fn inner_mut(&mut self) -> &mut Self::Inner {
17        &mut self.0
18    }
19    fn new(value: Self::Inner) -> Self {
20        Self(value)
21    }
22}
23
24/// A client-side function that produces a value that implements [PartialEq]
25pub struct ClientEqFunc<T>(pub(crate) T);
26
27impl<T> OptReadable for ClientEqFunc<T> {}
28
29impl<T: 'static + PartialEq> SignalType for ClientEqFunc<T> {
30    type Inner = T;
31
32    fn is_eq(&self, other: &Self::Inner) -> bool {
33        self.0 == *other
34    }
35
36    fn inner(&self) -> &Self::Inner {
37        &self.0
38    }
39    fn inner_mut(&mut self) -> &mut Self::Inner {
40        &mut self.0
41    }
42    fn new(value: Self::Inner) -> Self {
43        Self(value)
44    }
45}