cscart_rs/service/
state.rs

1use crate::ServiceAuth;
2
3/* Type states used for building services */
4pub struct Unconfigured;
5pub struct Unauthenticated;
6pub struct OnlyHost;
7pub struct OnlyAuth;
8pub struct Authenticated;
9
10/* Marker trait each struct can be used with trait bounds e.g S: ServiceState */
11pub trait ServiceState {}
12
13impl ServiceState for Unconfigured {}
14impl ServiceState for Unauthenticated {}
15impl ServiceState for Authenticated {}
16impl ServiceState for OnlyHost {}
17impl ServiceState for OnlyAuth {}
18
19/* Util trait that can be impl on all `Authenticated`` services to ensure getters exist */
20pub trait ConfiguredService {
21    fn auth(&self) -> ServiceAuth;
22    fn host(&self) -> String;
23}