zcr_alpha_compositing_v1_server_protocol/
zcr_alpha_compositing_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_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 = Request;
60 type Outgoing = Event;
61}
62
63#[derive(Debug)]
64pub enum Request {
65
66 Destroy,
72
73 GetBlending {
80 id: NewObject<ZcrBlendingV1>,
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 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::GetBlending {
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 BlendingExists = 0,
173}
174
175impl Error {
176 pub fn from_bits(v: u32) -> Option<Self> {
177 match v {
178 0 => Some(Error::BlendingExists),
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_alpha_compositing_v1::ZcrAlphaCompositingV1;
195pub use crate::zcr_alpha_compositing_v1::Request as ZcrAlphaCompositingV1Request;
196pub use crate::zcr_alpha_compositing_v1::Event as ZcrAlphaCompositingV1Event;
197pub mod zcr_blending_v1 {
198use super::*;
199
200#[derive(Debug)]
213pub struct ZcrBlendingV1;
214
215impl Interface for ZcrBlendingV1 {
216 const NAME: &'static str = "zcr_blending_v1";
217 const VERSION: u32 = 1;
218 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
219 MessageSpec(&[
221 ]),
222 MessageSpec(&[
224 ArgKind::Uint,
225 ]),
226 MessageSpec(&[
228 ArgKind::Fixed,
229 ]),
230 ]);
231 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
232 ]);
233 type Incoming = Request;
234 type Outgoing = Event;
235}
236
237#[derive(Debug)]
238pub enum Request {
239
240 Destroy,
245
246 SetBlending {
254 equation: u32,
256 },
257
258 SetAlpha {
266 value: Fixed,
268 },
269}
270
271impl MessageType for Request {
272 fn log(&self, this: ObjectId) -> String {
273 match *self {
274 Request::Destroy {
275 } => {
276 format!("zcr_blending_v1@{:?}::destroy()", this)
277 }
278 Request::SetBlending {
279 ref equation,
280 } => {
281 format!("zcr_blending_v1@{:?}::set_blending(equation: {:?})", this, equation)
282 }
283 Request::SetAlpha {
284 ref value,
285 } => {
286 format!("zcr_blending_v1@{:?}::set_alpha(value: {:?})", this, value)
287 }
288 }
289 }
290 fn message_name(&self) -> &'static std::ffi::CStr{
291 match *self {
292 Request::Destroy { .. } => c"zcr_blending_v1::destroy",
293 Request::SetBlending { .. } => c"zcr_blending_v1::set_blending",
294 Request::SetAlpha { .. } => c"zcr_blending_v1::set_alpha",
295 }
296 }
297}
298#[derive(Debug)]
299pub enum Event {
300}
301
302impl MessageType for Event {
303 fn log(&self, this: ObjectId) -> String {
304 match *self {
305 }
306 }
307 fn message_name(&self) -> &'static std::ffi::CStr{
308 match *self {
309 }
310 }
311}
312impl IntoMessage for Event {
313 type Error = EncodeError;
314 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
315 let mut header = MessageHeader {
316 sender: id,
317 opcode: 0,
318 length: 0,
319 };
320 let mut msg = Message::new();
321 msg.write_header(&header)?;
322 match self {
323 }
324 header.length = msg.bytes().len() as u16;
325 msg.rewind();
326 msg.write_header(&header)?;
327 Ok(msg)
328 }
329}
330impl FromArgs for Request {
331 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
332 match op {
333 0 => {
334 let mut iter = args.into_iter();
335 Ok(Request::Destroy {
336
337 })
338 },
339 1 => {
340 let mut iter = args.into_iter();
341 Ok(Request::SetBlending {
342 equation: iter.next()
343 .ok_or(DecodeError::InsufficientArgs)?
344 .as_uint()?,
345
346 })
347 },
348 2 => {
349 let mut iter = args.into_iter();
350 Ok(Request::SetAlpha {
351 value: iter.next()
352 .ok_or(DecodeError::InsufficientArgs)?
353 .as_fixed()?.into(),
354
355 })
356 },
357 _ => {
358 Err(DecodeError::InvalidOpcode(op).into())
359 },
360 }
361 }
362}
363
364#[derive(Copy, Clone, Debug, Eq, PartialEq)]
368#[repr(u32)]
369pub enum BlendingEquation {
370 None = 0,
372 Premult = 1,
374 Coverage = 2,
376}
377
378impl BlendingEquation {
379 pub fn from_bits(v: u32) -> Option<Self> {
380 match v {
381 0 => Some(BlendingEquation::None),
382 1 => Some(BlendingEquation::Premult),
383 2 => Some(BlendingEquation::Coverage),
384 _ => None,
385 }
386 }
387
388 pub fn bits(&self) -> u32 {
389 *self as u32
390 }
391}
392impl Into<Arg> for BlendingEquation {
393 fn into(self) -> Arg {
394 Arg::Uint(self.bits())
395 }
396}
397} pub use crate::zcr_blending_v1::ZcrBlendingV1;
400pub use crate::zcr_blending_v1::Request as ZcrBlendingV1Request;
401pub use crate::zcr_blending_v1::Event as ZcrBlendingV1Event;