zcr_secure_output_v1_client_protocol/zcr_secure_output_v1_client_protocol.rs
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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
// GENERATED FILE -- DO NOT EDIT
//
// Copyright 2016 The Chromium Authors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice (including the next
// paragraph) shall be included in all copies or substantial portions of the
// Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#![allow(warnings)]
#![allow(clippy::all)]
use anyhow;
#[allow(unused_imports)]
use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
ObjectId, EncodeError, DecodeError, Interface};
pub mod zcr_secure_output_v1 {
use super::*;
/// secure output
///
/// The global interface exposing secure output capabilities is used
/// to instantiate an interface extension for a wl_surface object.
/// This extended interface will then allow surfaces to be marked as
/// as only visible on secure outputs.
#[derive(Debug)]
pub struct ZcrSecureOutputV1;
impl Interface for ZcrSecureOutputV1 {
const NAME: &'static str = "zcr_secure_output_v1";
const VERSION: u32 = 1;
const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
// destroy
MessageSpec(&[
]),
// get_security
MessageSpec(&[
ArgKind::NewId,
ArgKind::Object,
]),
]);
const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
]);
type Incoming = Event;
type Outgoing = Request;
}
#[derive(Debug)]
pub enum Request {
/// unbind from the secure output interface
///
/// Informs the server that the client will not be using this
/// protocol object anymore. This does not affect any other objects,
/// security objects included.
Destroy,
/// extend surface interface for security
///
/// Instantiate an interface extension for the given wl_surface to
/// provide surface security. If the given wl_surface already has
/// a security object associated, the security_exists protocol error
/// is raised.
GetSecurity {
/// the new security interface id
id: NewId,
/// the surface
surface: ObjectId,
},
}
impl MessageType for Request {
fn log(&self, this: ObjectId) -> String {
match *self {
Request::Destroy {
} => {
format!("zcr_secure_output_v1@{:?}::destroy()", this)
}
Request::GetSecurity {
ref id,
ref surface,
} => {
format!("zcr_secure_output_v1@{:?}::get_security(id: {:?}, surface: {:?})", this, id, surface)
}
}
}
fn message_name(&self) -> &'static std::ffi::CStr{
match *self {
Request::Destroy { .. } => c"zcr_secure_output_v1::destroy",
Request::GetSecurity { .. } => c"zcr_secure_output_v1::get_security",
}
}
}
#[derive(Debug)]
pub enum Event {
}
impl MessageType for Event {
fn log(&self, this: ObjectId) -> String {
match *self {
}
}
fn message_name(&self) -> &'static std::ffi::CStr{
match *self {
}
}
}
impl IntoMessage for Request {
type Error = EncodeError;
fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
let mut header = MessageHeader {
sender: id,
opcode: 0,
length: 0,
};
let mut msg = Message::new();
msg.write_header(&header)?;
match self {
Request::Destroy {
} => {
header.opcode = 0;
},
Request::GetSecurity {
id,
surface,
} => {
msg.write_arg(Arg::NewId(id))?;
msg.write_arg(Arg::Object(surface))?;
header.opcode = 1;
},
}
header.length = msg.bytes().len() as u16;
msg.rewind();
msg.write_header(&header)?;
Ok(msg)
}
}
impl FromArgs for Event {
fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
match op {
_ => {
Err(DecodeError::InvalidOpcode(op).into())
},
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u32)]
pub enum Error {
/// the surface already has a security object associated,
SecurityExists = 0,
}
impl Error {
pub fn from_bits(v: u32) -> Option<Self> {
match v {
0 => Some(Error::SecurityExists),
_ => None,
}
}
pub fn bits(&self) -> u32 {
*self as u32
}
}
impl Into<Arg> for Error {
fn into(self) -> Arg {
Arg::Uint(self.bits())
}
}
} // mod zcr_secure_output_v1
pub use crate::zcr_secure_output_v1::ZcrSecureOutputV1;
pub use crate::zcr_secure_output_v1::Request as ZcrSecureOutputV1Request;
pub use crate::zcr_secure_output_v1::Event as ZcrSecureOutputV1Event;
pub mod zcr_security_v1 {
use super::*;
/// security interface to a wl_surface
///
/// An additional interface to a wl_surface object, which allows the
/// client to specify that a surface should not appear in screenshots
/// or be visible on non-secure outputs.
///
/// If the wl_surface associated with the security object is destroyed,
/// the security object becomes inert.
///
/// If the security object is destroyed, the security state is removed
/// from the wl_surface. The change will be applied on the next
/// wl_surface.commit.
#[derive(Debug)]
pub struct ZcrSecurityV1;
impl Interface for ZcrSecurityV1 {
const NAME: &'static str = "zcr_security_v1";
const VERSION: u32 = 1;
const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
// destroy
MessageSpec(&[
]),
// only_visible_on_secure_output
MessageSpec(&[
]),
]);
const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
]);
type Incoming = Event;
type Outgoing = Request;
}
#[derive(Debug)]
pub enum Request {
/// remove security from the surface
///
/// The associated wl_surface's security state is removed.
/// The change is applied on the next wl_surface.commit.
Destroy,
/// set the only visible on secure output state
///
/// Constrain visibility of wl_surface contents to secure outputs.
/// See wp_secure_output for the description.
///
/// The only visible on secure output state is double-buffered state,
/// and will be applied on the next wl_surface.commit.
OnlyVisibleOnSecureOutput,
}
impl MessageType for Request {
fn log(&self, this: ObjectId) -> String {
match *self {
Request::Destroy {
} => {
format!("zcr_security_v1@{:?}::destroy()", this)
}
Request::OnlyVisibleOnSecureOutput {
} => {
format!("zcr_security_v1@{:?}::only_visible_on_secure_output()", this)
}
}
}
fn message_name(&self) -> &'static std::ffi::CStr{
match *self {
Request::Destroy { .. } => c"zcr_security_v1::destroy",
Request::OnlyVisibleOnSecureOutput { .. } => c"zcr_security_v1::only_visible_on_secure_output",
}
}
}
#[derive(Debug)]
pub enum Event {
}
impl MessageType for Event {
fn log(&self, this: ObjectId) -> String {
match *self {
}
}
fn message_name(&self) -> &'static std::ffi::CStr{
match *self {
}
}
}
impl IntoMessage for Request {
type Error = EncodeError;
fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
let mut header = MessageHeader {
sender: id,
opcode: 0,
length: 0,
};
let mut msg = Message::new();
msg.write_header(&header)?;
match self {
Request::Destroy {
} => {
header.opcode = 0;
},
Request::OnlyVisibleOnSecureOutput {
} => {
header.opcode = 1;
},
}
header.length = msg.bytes().len() as u16;
msg.rewind();
msg.write_header(&header)?;
Ok(msg)
}
}
impl FromArgs for Event {
fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
match op {
_ => {
Err(DecodeError::InvalidOpcode(op).into())
},
}
}
}
} // mod zcr_security_v1
pub use crate::zcr_security_v1::ZcrSecurityV1;
pub use crate::zcr_security_v1::Request as ZcrSecurityV1Request;
pub use crate::zcr_security_v1::Event as ZcrSecurityV1Event;