zcr_alpha_compositing_v1_client_protocol/
zcr_alpha_compositing_v1_client_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_alpha_compositing_v1 {
33use super::*;
34
35#[derive(Debug)]
42pub struct ZcrAlphaCompositingV1;
43
44impl Interface for ZcrAlphaCompositingV1 {
45 const NAME: &'static str = "zcr_alpha_compositing_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 = Event;
60 type Outgoing = Request;
61}
62
63#[derive(Debug)]
64pub enum Request {
65
66 Destroy,
72
73 GetBlending {
80 id: NewId,
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_alpha_compositing_v1@{:?}::destroy()", this)
93 }
94 Request::GetBlending {
95 ref id,
96 ref surface,
97 } => {
98 format!("zcr_alpha_compositing_v1@{:?}::get_blending(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_alpha_compositing_v1::destroy",
105 Request::GetBlending { .. } => c"zcr_alpha_compositing_v1::get_blending",
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 Request {
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 Request::Destroy {
135 } => {
136 header.opcode = 0;
137 },
138 Request::GetBlending {
139 id,
140 surface,
141 } => {
142 msg.write_arg(Arg::NewId(id))?;
143 msg.write_arg(Arg::Object(surface))?;
144 header.opcode = 1;
145 },
146 }
147 header.length = msg.bytes().len() as u16;
148 msg.rewind();
149 msg.write_header(&header)?;
150 Ok(msg)
151 }
152}
153impl FromArgs for Event {
154 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
155 match op {
156 _ => {
157 Err(DecodeError::InvalidOpcode(op).into())
158 },
159 }
160 }
161}
162#[derive(Copy, Clone, Debug, Eq, PartialEq)]
163#[repr(u32)]
164pub enum Error {
165 BlendingExists = 0,
167}
168
169impl Error {
170 pub fn from_bits(v: u32) -> Option<Self> {
171 match v {
172 0 => Some(Error::BlendingExists),
173 _ => None,
174 }
175 }
176
177 pub fn bits(&self) -> u32 {
178 *self as u32
179 }
180}
181impl Into<Arg> for Error {
182 fn into(self) -> Arg {
183 Arg::Uint(self.bits())
184 }
185}
186} pub use crate::zcr_alpha_compositing_v1::ZcrAlphaCompositingV1;
189pub use crate::zcr_alpha_compositing_v1::Request as ZcrAlphaCompositingV1Request;
190pub use crate::zcr_alpha_compositing_v1::Event as ZcrAlphaCompositingV1Event;
191pub mod zcr_blending_v1 {
192use super::*;
193
194#[derive(Debug)]
207pub struct ZcrBlendingV1;
208
209impl Interface for ZcrBlendingV1 {
210 const NAME: &'static str = "zcr_blending_v1";
211 const VERSION: u32 = 1;
212 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
213 MessageSpec(&[
215 ]),
216 MessageSpec(&[
218 ArgKind::Uint,
219 ]),
220 MessageSpec(&[
222 ArgKind::Fixed,
223 ]),
224 ]);
225 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
226 ]);
227 type Incoming = Event;
228 type Outgoing = Request;
229}
230
231#[derive(Debug)]
232pub enum Request {
233
234 Destroy,
239
240 SetBlending {
248 equation: u32,
250 },
251
252 SetAlpha {
260 value: Fixed,
262 },
263}
264
265impl MessageType for Request {
266 fn log(&self, this: ObjectId) -> String {
267 match *self {
268 Request::Destroy {
269 } => {
270 format!("zcr_blending_v1@{:?}::destroy()", this)
271 }
272 Request::SetBlending {
273 ref equation,
274 } => {
275 format!("zcr_blending_v1@{:?}::set_blending(equation: {:?})", this, equation)
276 }
277 Request::SetAlpha {
278 ref value,
279 } => {
280 format!("zcr_blending_v1@{:?}::set_alpha(value: {:?})", this, value)
281 }
282 }
283 }
284 fn message_name(&self) -> &'static std::ffi::CStr{
285 match *self {
286 Request::Destroy { .. } => c"zcr_blending_v1::destroy",
287 Request::SetBlending { .. } => c"zcr_blending_v1::set_blending",
288 Request::SetAlpha { .. } => c"zcr_blending_v1::set_alpha",
289 }
290 }
291}
292#[derive(Debug)]
293pub enum Event {
294}
295
296impl MessageType for Event {
297 fn log(&self, this: ObjectId) -> String {
298 match *self {
299 }
300 }
301 fn message_name(&self) -> &'static std::ffi::CStr{
302 match *self {
303 }
304 }
305}
306impl IntoMessage for Request {
307 type Error = EncodeError;
308 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
309 let mut header = MessageHeader {
310 sender: id,
311 opcode: 0,
312 length: 0,
313 };
314 let mut msg = Message::new();
315 msg.write_header(&header)?;
316 match self {
317 Request::Destroy {
318 } => {
319 header.opcode = 0;
320 },
321 Request::SetBlending {
322 equation,
323 } => {
324 msg.write_arg(Arg::Uint(equation))?;
325 header.opcode = 1;
326 },
327 Request::SetAlpha {
328 value,
329 } => {
330 msg.write_arg(Arg::Fixed(value))?;
331 header.opcode = 2;
332 },
333 }
334 header.length = msg.bytes().len() as u16;
335 msg.rewind();
336 msg.write_header(&header)?;
337 Ok(msg)
338 }
339}
340impl FromArgs for Event {
341 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
342 match op {
343 _ => {
344 Err(DecodeError::InvalidOpcode(op).into())
345 },
346 }
347 }
348}
349
350#[derive(Copy, Clone, Debug, Eq, PartialEq)]
354#[repr(u32)]
355pub enum BlendingEquation {
356 None = 0,
358 Premult = 1,
360 Coverage = 2,
362}
363
364impl BlendingEquation {
365 pub fn from_bits(v: u32) -> Option<Self> {
366 match v {
367 0 => Some(BlendingEquation::None),
368 1 => Some(BlendingEquation::Premult),
369 2 => Some(BlendingEquation::Coverage),
370 _ => None,
371 }
372 }
373
374 pub fn bits(&self) -> u32 {
375 *self as u32
376 }
377}
378impl Into<Arg> for BlendingEquation {
379 fn into(self) -> Arg {
380 Arg::Uint(self.bits())
381 }
382}
383} pub use crate::zcr_blending_v1::ZcrBlendingV1;
386pub use crate::zcr_blending_v1::Request as ZcrBlendingV1Request;
387pub use crate::zcr_blending_v1::Event as ZcrBlendingV1Event;