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
64
65
66
67
68
69
70
71
72
73
74
use serde::{Deserialize, Serialize};

/// Information associated with an imported file, containing the file's name and size in bytes.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct ImportFileInfo {
    /// The file's name.
    pub name: Box<str>,
    /// The file's size in bytes.
    pub size: u64,
}

/// A description of a device or interface block.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeviceDescriptor {
    /// The device's UUID.
    pub device_id: uuid::Uuid,
    /// A list of strings that determine which kind of device the UUID refers to.
    pub type_names: Box<[Box<str>]>,
}

/// An RPC method signature and description.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MethodDescriptor {
    /// The method's name.
    pub name: Box<str>,
    /// The method's return type.
    pub return_type: Box<str>,
    /// Documentation about what the method does.
    pub description: Box<str>,
    /// A list of method parameters.
    pub parameters: Box<[ParameterDescriptor]>,
}

/// A description of one of a method's parameters, including the method name, description, and type.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct ParameterDescriptor {
    /// The parameter's name.
    pub name: Box<str>,
    /// Documentation about what the parameter is used for.
    pub description: Box<str>,
    #[serde(rename = "type")]
    /// The parameter's type.
    pub ty: Box<str>,
}

/// A block's relative direction.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Direction {
    Up,
    Down,
    Front,
    Back,
    Left,
    Right,
}

/// A rotation direction.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum RotationDirection {
    Left,
    Right,
}

/// The state of a robot's current action.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub enum RobotActionResult {
    Incomplete,
    Success,
    Failure,
}