zcr_secure_output_v1_server_protocol/
zcr_secure_output_v1_server_protocol.rs
1#![allow(warnings)]
25#![allow(clippy::all)]
26use anyhow;
27#[allow(unused_imports)]
28use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
29use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
30 MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
31 ObjectId, EncodeError, DecodeError, Interface};
32pub mod zcr_secure_output_v1 {
33use super::*;
34
35#[derive(Debug)]
42pub struct ZcrSecureOutputV1;
43
44impl Interface for ZcrSecureOutputV1 {
45 const NAME: &'static str = "zcr_secure_output_v1";
46 const VERSION: u32 = 1;
47 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
48 MessageSpec(&[
50 ]),
51 MessageSpec(&[
53 ArgKind::NewId,
54 ArgKind::Object,
55 ]),
56 ]);
57 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
58 ]);
59 type Incoming = Request;
60 type Outgoing = Event;
61}
62
63#[derive(Debug)]
64pub enum Request {
65
66 Destroy,
72
73 GetSecurity {
80 id: NewObject<ZcrSecurityV1>,
82 surface: ObjectId,
84 },
85}
86
87impl MessageType for Request {
88 fn log(&self, this: ObjectId) -> String {
89 match *self {
90 Request::Destroy {
91 } => {
92 format!("zcr_secure_output_v1@{:?}::destroy()", this)
93 }
94 Request::GetSecurity {
95 ref id,
96 ref surface,
97 } => {
98 format!("zcr_secure_output_v1@{:?}::get_security(id: {:?}, surface: {:?})", this, id, surface)
99 }
100 }
101 }
102 fn message_name(&self) -> &'static std::ffi::CStr{
103 match *self {
104 Request::Destroy { .. } => c"zcr_secure_output_v1::destroy",
105 Request::GetSecurity { .. } => c"zcr_secure_output_v1::get_security",
106 }
107 }
108}
109#[derive(Debug)]
110pub enum Event {
111}
112
113impl MessageType for Event {
114 fn log(&self, this: ObjectId) -> String {
115 match *self {
116 }
117 }
118 fn message_name(&self) -> &'static std::ffi::CStr{
119 match *self {
120 }
121 }
122}
123impl IntoMessage for Event {
124 type Error = EncodeError;
125 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
126 let mut header = MessageHeader {
127 sender: id,
128 opcode: 0,
129 length: 0,
130 };
131 let mut msg = Message::new();
132 msg.write_header(&header)?;
133 match self {
134 }
135 header.length = msg.bytes().len() as u16;
136 msg.rewind();
137 msg.write_header(&header)?;
138 Ok(msg)
139 }
140}
141impl FromArgs for Request {
142 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
143 match op {
144 0 => {
145 let mut iter = args.into_iter();
146 Ok(Request::Destroy {
147
148 })
149 },
150 1 => {
151 let mut iter = args.into_iter();
152 Ok(Request::GetSecurity {
153 id: iter.next()
154 .ok_or(DecodeError::InsufficientArgs)?
155 .as_new_id()?.into(),
156 surface: iter.next()
157 .ok_or(DecodeError::InsufficientArgs)?
158 .as_object()?,
159
160 })
161 },
162 _ => {
163 Err(DecodeError::InvalidOpcode(op).into())
164 },
165 }
166 }
167}
168#[derive(Copy, Clone, Debug, Eq, PartialEq)]
169#[repr(u32)]
170pub enum Error {
171 SecurityExists = 0,
173}
174
175impl Error {
176 pub fn from_bits(v: u32) -> Option<Self> {
177 match v {
178 0 => Some(Error::SecurityExists),
179 _ => None,
180 }
181 }
182
183 pub fn bits(&self) -> u32 {
184 *self as u32
185 }
186}
187impl Into<Arg> for Error {
188 fn into(self) -> Arg {
189 Arg::Uint(self.bits())
190 }
191}
192} pub use crate::zcr_secure_output_v1::ZcrSecureOutputV1;
195pub use crate::zcr_secure_output_v1::Request as ZcrSecureOutputV1Request;
196pub use crate::zcr_secure_output_v1::Event as ZcrSecureOutputV1Event;
197pub mod zcr_security_v1 {
198use super::*;
199
200#[derive(Debug)]
213pub struct ZcrSecurityV1;
214
215impl Interface for ZcrSecurityV1 {
216 const NAME: &'static str = "zcr_security_v1";
217 const VERSION: u32 = 1;
218 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
219 MessageSpec(&[
221 ]),
222 MessageSpec(&[
224 ]),
225 ]);
226 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
227 ]);
228 type Incoming = Request;
229 type Outgoing = Event;
230}
231
232#[derive(Debug)]
233pub enum Request {
234
235 Destroy,
240
241 OnlyVisibleOnSecureOutput,
249}
250
251impl MessageType for Request {
252 fn log(&self, this: ObjectId) -> String {
253 match *self {
254 Request::Destroy {
255 } => {
256 format!("zcr_security_v1@{:?}::destroy()", this)
257 }
258 Request::OnlyVisibleOnSecureOutput {
259 } => {
260 format!("zcr_security_v1@{:?}::only_visible_on_secure_output()", this)
261 }
262 }
263 }
264 fn message_name(&self) -> &'static std::ffi::CStr{
265 match *self {
266 Request::Destroy { .. } => c"zcr_security_v1::destroy",
267 Request::OnlyVisibleOnSecureOutput { .. } => c"zcr_security_v1::only_visible_on_secure_output",
268 }
269 }
270}
271#[derive(Debug)]
272pub enum Event {
273}
274
275impl MessageType for Event {
276 fn log(&self, this: ObjectId) -> String {
277 match *self {
278 }
279 }
280 fn message_name(&self) -> &'static std::ffi::CStr{
281 match *self {
282 }
283 }
284}
285impl IntoMessage for Event {
286 type Error = EncodeError;
287 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
288 let mut header = MessageHeader {
289 sender: id,
290 opcode: 0,
291 length: 0,
292 };
293 let mut msg = Message::new();
294 msg.write_header(&header)?;
295 match self {
296 }
297 header.length = msg.bytes().len() as u16;
298 msg.rewind();
299 msg.write_header(&header)?;
300 Ok(msg)
301 }
302}
303impl FromArgs for Request {
304 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
305 match op {
306 0 => {
307 let mut iter = args.into_iter();
308 Ok(Request::Destroy {
309
310 })
311 },
312 1 => {
313 let mut iter = args.into_iter();
314 Ok(Request::OnlyVisibleOnSecureOutput {
315
316 })
317 },
318 _ => {
319 Err(DecodeError::InvalidOpcode(op).into())
320 },
321 }
322 }
323}
324} pub use crate::zcr_security_v1::ZcrSecurityV1;
327pub use crate::zcr_security_v1::Request as ZcrSecurityV1Request;
328pub use crate::zcr_security_v1::Event as ZcrSecurityV1Event;