-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterface_message.rs
More file actions
173 lines (167 loc) · 8.38 KB
/
interface_message.rs
File metadata and controls
173 lines (167 loc) · 8.38 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use crate::{FromGil, PyDefault, flat};
use pyo3::prelude::*;
#[derive(pyo3::FromPyObject)]
pub enum InterfaceMessage {
DisconnectSignal(Py<super::DisconnectSignal>),
StartCommand(Py<super::StartCommand>),
MatchConfiguration(Py<super::MatchConfiguration>),
PlayerInput(Py<super::PlayerInput>),
DesiredGameState(Py<super::DesiredGameState>),
RenderGroup(Py<super::RenderGroup>),
RemoveRenderGroup(Py<super::RemoveRenderGroup>),
MatchComm(Py<super::MatchComm>),
ConnectionSettings(Py<super::ConnectionSettings>),
StopCommand(Py<super::StopCommand>),
SetLoadout(Py<super::SetLoadout>),
InitComplete(Py<super::InitComplete>),
RenderingStatus(Py<super::RenderingStatus>),
PingRequest(Py<super::PingRequest>),
PingResponse(Py<super::PingResponse>),
}
impl InterfaceMessage {
pub fn py_default(py: Python) -> Py<PyAny> {
super::DisconnectSignal::py_default(py).into_any()
}
}
impl FromGil<&flat::InterfaceMessage> for InterfaceMessage {
fn from_gil(py: Python, flat_t: &flat::InterfaceMessage) -> Self {
match flat_t {
flat::InterfaceMessage::DisconnectSignal(item) => Self::DisconnectSignal(
Py::new(py, super::DisconnectSignal::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::StartCommand(item) => {
Self::StartCommand(Py::new(py, super::StartCommand::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::MatchConfiguration(item) => Self::MatchConfiguration(
Py::new(py, super::MatchConfiguration::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::PlayerInput(item) => {
Self::PlayerInput(Py::new(py, super::PlayerInput::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::DesiredGameState(item) => Self::DesiredGameState(
Py::new(py, super::DesiredGameState::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::RenderGroup(item) => {
Self::RenderGroup(Py::new(py, super::RenderGroup::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::RemoveRenderGroup(item) => Self::RemoveRenderGroup(
Py::new(py, super::RemoveRenderGroup::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::MatchComm(item) => {
Self::MatchComm(Py::new(py, super::MatchComm::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::ConnectionSettings(item) => Self::ConnectionSettings(
Py::new(py, super::ConnectionSettings::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::StopCommand(item) => {
Self::StopCommand(Py::new(py, super::StopCommand::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::SetLoadout(item) => {
Self::SetLoadout(Py::new(py, super::SetLoadout::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::InitComplete(item) => {
Self::InitComplete(Py::new(py, super::InitComplete::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::RenderingStatus(item) => Self::RenderingStatus(
Py::new(py, super::RenderingStatus::from_gil(py, &**item)).unwrap(),
),
flat::InterfaceMessage::PingRequest(item) => {
Self::PingRequest(Py::new(py, super::PingRequest::from_gil(py, &**item)).unwrap())
}
flat::InterfaceMessage::PingResponse(item) => {
Self::PingResponse(Py::new(py, super::PingResponse::from_gil(py, &**item)).unwrap())
}
}
}
}
impl FromGil<&InterfaceMessage> for flat::InterfaceMessage {
fn from_gil(py: Python, py_type: &InterfaceMessage) -> Self {
match py_type {
InterfaceMessage::DisconnectSignal(item) => {
flat::InterfaceMessage::DisconnectSignal(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::StartCommand(item) => {
flat::InterfaceMessage::StartCommand(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::MatchConfiguration(item) => {
flat::InterfaceMessage::MatchConfiguration(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::PlayerInput(item) => {
flat::InterfaceMessage::PlayerInput(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::DesiredGameState(item) => {
flat::InterfaceMessage::DesiredGameState(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::RenderGroup(item) => {
flat::InterfaceMessage::RenderGroup(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::RemoveRenderGroup(item) => {
flat::InterfaceMessage::RemoveRenderGroup(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::MatchComm(item) => {
flat::InterfaceMessage::MatchComm(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::ConnectionSettings(item) => {
flat::InterfaceMessage::ConnectionSettings(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::StopCommand(item) => {
flat::InterfaceMessage::StopCommand(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::SetLoadout(item) => {
flat::InterfaceMessage::SetLoadout(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::InitComplete(item) => {
flat::InterfaceMessage::InitComplete(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::RenderingStatus(item) => {
flat::InterfaceMessage::RenderingStatus(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::PingRequest(item) => {
flat::InterfaceMessage::PingRequest(Box::new(crate::from_py_into(py, item)))
}
InterfaceMessage::PingResponse(item) => {
flat::InterfaceMessage::PingResponse(Box::new(crate::from_py_into(py, item)))
}
}
}
}
impl InterfaceMessage {
pub fn into_any(self) -> Py<PyAny> {
match self {
Self::DisconnectSignal(item) => item.into_any(),
Self::StartCommand(item) => item.into_any(),
Self::MatchConfiguration(item) => item.into_any(),
Self::PlayerInput(item) => item.into_any(),
Self::DesiredGameState(item) => item.into_any(),
Self::RenderGroup(item) => item.into_any(),
Self::RemoveRenderGroup(item) => item.into_any(),
Self::MatchComm(item) => item.into_any(),
Self::ConnectionSettings(item) => item.into_any(),
Self::StopCommand(item) => item.into_any(),
Self::SetLoadout(item) => item.into_any(),
Self::InitComplete(item) => item.into_any(),
Self::RenderingStatus(item) => item.into_any(),
Self::PingRequest(item) => item.into_any(),
Self::PingResponse(item) => item.into_any(),
}
}
pub fn __repr__(&self, py: Python) -> String {
match self {
Self::DisconnectSignal(item) => item.borrow(py).__repr__(py),
Self::StartCommand(item) => item.borrow(py).__repr__(py),
Self::MatchConfiguration(item) => item.borrow(py).__repr__(py),
Self::PlayerInput(item) => item.borrow(py).__repr__(py),
Self::DesiredGameState(item) => item.borrow(py).__repr__(py),
Self::RenderGroup(item) => item.borrow(py).__repr__(py),
Self::RemoveRenderGroup(item) => item.borrow(py).__repr__(py),
Self::MatchComm(item) => item.borrow(py).__repr__(py),
Self::ConnectionSettings(item) => item.borrow(py).__repr__(py),
Self::StopCommand(item) => item.borrow(py).__repr__(py),
Self::SetLoadout(item) => item.borrow(py).__repr__(py),
Self::InitComplete(item) => item.borrow(py).__repr__(py),
Self::RenderingStatus(item) => item.borrow(py).__repr__(py),
Self::PingRequest(item) => item.borrow(py).__repr__(py),
Self::PingResponse(item) => item.borrow(py).__repr__(py),
}
}
}