cosmic_space/
config.rs

1use std::ops::Deref;
2
3use serde::{Deserialize, Serialize};
4
5use crate::config::mechtron::MechtronConfig;
6use crate::point::Point;
7use crate::particle::{Details, Stub};
8use crate::BindConfig;
9
10pub mod bind;
11pub mod mechtron;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub enum PortalKind {
15    Mechtron,
16    Portal,
17}
18
19impl ToString for PortalKind {
20    fn to_string(&self) -> String {
21        match self {
22            PortalKind::Mechtron => "Mechtron".to_string(),
23            PortalKind::Portal => "Portal".to_string(),
24        }
25    }
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct Info {
30    pub stub: Stub,
31    pub kind: PortalKind,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct PortalConfig {
36    pub max_payload_size: u32,
37    pub init_timeout: u64,
38    pub frame_timeout: u64,
39    pub response_timeout: u64,
40}
41
42impl Default for PortalConfig {
43    fn default() -> Self {
44        Self {
45            max_payload_size: 128 * 1024,
46            init_timeout: 30,
47            frame_timeout: 5,
48            response_timeout: 15,
49        }
50    }
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
54pub struct PointConfig<Body> {
55    pub point: Point,
56    pub body: Body,
57}
58
59impl<Body> Deref for PointConfig<Body> {
60    type Target = Body;
61
62    fn deref(&self) -> &Self::Target {
63        &self.body
64    }
65}
66
67#[derive(Clone)]
68pub enum Document {
69    BindConfig(BindConfig),
70    MechtronConfig(MechtronConfig),
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
74pub struct ParticleConfigBody {
75    pub details: Details,
76}