zcr_secure_output_v1_server_protocol/
zcr_secure_output_v1_server_protocol.rs

1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright 2016 The Chromium Authors.
4// 
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11// 
12// The above copyright notice and this permission notice (including the next
13// paragraph) shall be included in all copies or substantial portions of the
14// Software.
15// 
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22// DEALINGS IN THE SOFTWARE.
23
24#![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/// secure output
36///
37/// The global interface exposing secure output capabilities is used
38/// to instantiate an interface extension for a wl_surface object.
39/// This extended interface will then allow surfaces to be marked as
40/// as only visible on secure outputs.
41#[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        // destroy
49        MessageSpec(&[
50        ]),
51        // get_security
52        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    /// unbind from the secure output interface
67    ///
68    /// Informs the server that the client will not be using this
69    /// protocol object anymore. This does not affect any other objects,
70    /// security objects included.
71    Destroy,
72
73    /// extend surface interface for security
74    ///
75    /// Instantiate an interface extension for the given wl_surface to
76    /// provide surface security. If the given wl_surface already has
77    /// a security object associated, the security_exists protocol error
78    /// is raised.
79    GetSecurity {
80        /// the new security interface id
81        id: NewObject<ZcrSecurityV1>,
82        /// the surface
83        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 /* destroy */ => {
145            let mut iter = args.into_iter();
146            Ok(Request::Destroy {
147
148            })
149        },
150        1 /* get_security */ => {
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    /// the surface already has a security object associated,
172    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} // mod zcr_secure_output_v1
193
194pub 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/// security interface to a wl_surface
201///
202/// An additional interface to a wl_surface object, which allows the
203/// client to specify that a surface should not appear in screenshots
204/// or be visible on non-secure outputs.
205/// 
206/// If the wl_surface associated with the security object is destroyed,
207/// the security object becomes inert.
208/// 
209/// If the security object is destroyed, the security state is removed
210/// from the wl_surface. The change will be applied on the next
211/// wl_surface.commit.
212#[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        // destroy
220        MessageSpec(&[
221        ]),
222        // only_visible_on_secure_output
223        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    /// remove security from the surface
236    ///
237    /// The associated wl_surface's security state is removed.
238    /// The change is applied on the next wl_surface.commit.
239    Destroy,
240
241    /// set the only visible on secure output state
242    ///
243    /// Constrain visibility of wl_surface contents to secure outputs.
244    /// See wp_secure_output for the description.
245    /// 
246    /// The only visible on secure output state is double-buffered state,
247    /// and will be applied on the next wl_surface.commit.
248    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 /* destroy */ => {
307            let mut iter = args.into_iter();
308            Ok(Request::Destroy {
309
310            })
311        },
312        1 /* only_visible_on_secure_output */ => {
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} // mod zcr_security_v1
325
326pub use crate::zcr_security_v1::ZcrSecurityV1;
327pub use crate::zcr_security_v1::Request as ZcrSecurityV1Request;
328pub use crate::zcr_security_v1::Event as ZcrSecurityV1Event;