1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
    Appellation: specs <module>
    Contrib: FL03 <jo3mccain@icloud.com>
    Description: ... summary ...
*/
pub use self::applications::*;

pub(crate) mod applications;

use std::sync::Arc;

pub trait BaseApplication: BaseObject + Versionable {
    fn application(&self) -> &Self {
        self
    }
    fn namespace(&self) -> String;
}

pub trait Spawnable {
    fn spawn(&mut self) -> scsys::Result<&Self>;
}

#[async_trait::async_trait]
pub trait AsyncSpawable {
    async fn spawn(&mut self) -> scsys::AsyncResult<&Self>;
}

pub trait BaseObject {
    fn count(&self) -> usize;
    fn name(&self) -> String;
    fn slug(&self) -> String {
        self.name().to_ascii_lowercase()
    }
    fn symbol(&self) -> String;
}

pub trait Stateful: Clone {
    fn boxed(self: Box<Self>) -> Box<Self> {
        self
    }
    fn state(self) -> Self
    where
        Self: Sized,
    {
        self
    }
    fn threaded(self: Arc<Self>) -> Arc<Self> {
        self
    }
}

pub trait StatefulExt: Stateful + Default {
    fn constructor() -> Self
    where
        Self: Sized;
}

pub trait Versionable {
    type Error;

    fn update(&mut self) -> Result<(), Box<Self::Error>>;
    fn version(&self) -> String;
}