1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_starnix_gralloc_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct VulkanModeSetterMarker;
16
17impl fidl::endpoints::ProtocolMarker for VulkanModeSetterMarker {
18 type Proxy = VulkanModeSetterProxy;
19 type RequestStream = VulkanModeSetterRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = VulkanModeSetterSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.starnix.gralloc.VulkanModeSetter";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for VulkanModeSetterMarker {}
26pub type VulkanModeSetterSetVulkanModeResult = Result<(), VulkanModeSetterError>;
27
28pub trait VulkanModeSetterProxyInterface: Send + Sync {
29 type SetVulkanModeResponseFut: std::future::Future<Output = Result<VulkanModeSetterSetVulkanModeResult, fidl::Error>>
30 + Send;
31 fn r#set_vulkan_mode(
32 &self,
33 payload: &VulkanModeSetterSetVulkanModeRequest,
34 ) -> Self::SetVulkanModeResponseFut;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct VulkanModeSetterSynchronousProxy {
39 client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for VulkanModeSetterSynchronousProxy {
44 type Proxy = VulkanModeSetterProxy;
45 type Protocol = VulkanModeSetterMarker;
46
47 fn from_channel(inner: fidl::Channel) -> Self {
48 Self::new(inner)
49 }
50
51 fn into_channel(self) -> fidl::Channel {
52 self.client.into_channel()
53 }
54
55 fn as_channel(&self) -> &fidl::Channel {
56 self.client.as_channel()
57 }
58}
59
60#[cfg(target_os = "fuchsia")]
61impl VulkanModeSetterSynchronousProxy {
62 pub fn new(channel: fidl::Channel) -> Self {
63 let protocol_name = <VulkanModeSetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
64 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
65 }
66
67 pub fn into_channel(self) -> fidl::Channel {
68 self.client.into_channel()
69 }
70
71 pub fn wait_for_event(
74 &self,
75 deadline: zx::MonotonicInstant,
76 ) -> Result<VulkanModeSetterEvent, fidl::Error> {
77 VulkanModeSetterEvent::decode(self.client.wait_for_event(deadline)?)
78 }
79
80 pub fn r#set_vulkan_mode(
83 &self,
84 mut payload: &VulkanModeSetterSetVulkanModeRequest,
85 ___deadline: zx::MonotonicInstant,
86 ) -> Result<VulkanModeSetterSetVulkanModeResult, fidl::Error> {
87 let _response = self.client.send_query::<
88 VulkanModeSetterSetVulkanModeRequest,
89 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, VulkanModeSetterError>,
90 >(
91 payload,
92 0x71ffe16858e9e7eb,
93 fidl::encoding::DynamicFlags::empty(),
94 ___deadline,
95 )?;
96 Ok(_response.map(|x| x))
97 }
98}
99
100#[cfg(target_os = "fuchsia")]
101impl From<VulkanModeSetterSynchronousProxy> for zx::Handle {
102 fn from(value: VulkanModeSetterSynchronousProxy) -> Self {
103 value.into_channel().into()
104 }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl From<fidl::Channel> for VulkanModeSetterSynchronousProxy {
109 fn from(value: fidl::Channel) -> Self {
110 Self::new(value)
111 }
112}
113
114#[derive(Debug, Clone)]
115pub struct VulkanModeSetterProxy {
116 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
117}
118
119impl fidl::endpoints::Proxy for VulkanModeSetterProxy {
120 type Protocol = VulkanModeSetterMarker;
121
122 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
123 Self::new(inner)
124 }
125
126 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
127 self.client.into_channel().map_err(|client| Self { client })
128 }
129
130 fn as_channel(&self) -> &::fidl::AsyncChannel {
131 self.client.as_channel()
132 }
133}
134
135impl VulkanModeSetterProxy {
136 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
138 let protocol_name = <VulkanModeSetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
139 Self { client: fidl::client::Client::new(channel, protocol_name) }
140 }
141
142 pub fn take_event_stream(&self) -> VulkanModeSetterEventStream {
148 VulkanModeSetterEventStream { event_receiver: self.client.take_event_receiver() }
149 }
150
151 pub fn r#set_vulkan_mode(
154 &self,
155 mut payload: &VulkanModeSetterSetVulkanModeRequest,
156 ) -> fidl::client::QueryResponseFut<
157 VulkanModeSetterSetVulkanModeResult,
158 fidl::encoding::DefaultFuchsiaResourceDialect,
159 > {
160 VulkanModeSetterProxyInterface::r#set_vulkan_mode(self, payload)
161 }
162}
163
164impl VulkanModeSetterProxyInterface for VulkanModeSetterProxy {
165 type SetVulkanModeResponseFut = fidl::client::QueryResponseFut<
166 VulkanModeSetterSetVulkanModeResult,
167 fidl::encoding::DefaultFuchsiaResourceDialect,
168 >;
169 fn r#set_vulkan_mode(
170 &self,
171 mut payload: &VulkanModeSetterSetVulkanModeRequest,
172 ) -> Self::SetVulkanModeResponseFut {
173 fn _decode(
174 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
175 ) -> Result<VulkanModeSetterSetVulkanModeResult, fidl::Error> {
176 let _response = fidl::client::decode_transaction_body::<
177 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, VulkanModeSetterError>,
178 fidl::encoding::DefaultFuchsiaResourceDialect,
179 0x71ffe16858e9e7eb,
180 >(_buf?)?;
181 Ok(_response.map(|x| x))
182 }
183 self.client.send_query_and_decode::<
184 VulkanModeSetterSetVulkanModeRequest,
185 VulkanModeSetterSetVulkanModeResult,
186 >(
187 payload,
188 0x71ffe16858e9e7eb,
189 fidl::encoding::DynamicFlags::empty(),
190 _decode,
191 )
192 }
193}
194
195pub struct VulkanModeSetterEventStream {
196 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl std::marker::Unpin for VulkanModeSetterEventStream {}
200
201impl futures::stream::FusedStream for VulkanModeSetterEventStream {
202 fn is_terminated(&self) -> bool {
203 self.event_receiver.is_terminated()
204 }
205}
206
207impl futures::Stream for VulkanModeSetterEventStream {
208 type Item = Result<VulkanModeSetterEvent, fidl::Error>;
209
210 fn poll_next(
211 mut self: std::pin::Pin<&mut Self>,
212 cx: &mut std::task::Context<'_>,
213 ) -> std::task::Poll<Option<Self::Item>> {
214 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
215 &mut self.event_receiver,
216 cx
217 )?) {
218 Some(buf) => std::task::Poll::Ready(Some(VulkanModeSetterEvent::decode(buf))),
219 None => std::task::Poll::Ready(None),
220 }
221 }
222}
223
224#[derive(Debug)]
225pub enum VulkanModeSetterEvent {
226 #[non_exhaustive]
227 _UnknownEvent {
228 ordinal: u64,
230 },
231}
232
233impl VulkanModeSetterEvent {
234 fn decode(
236 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
237 ) -> Result<VulkanModeSetterEvent, fidl::Error> {
238 let (bytes, _handles) = buf.split_mut();
239 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
240 debug_assert_eq!(tx_header.tx_id, 0);
241 match tx_header.ordinal {
242 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
243 Ok(VulkanModeSetterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
244 }
245 _ => Err(fidl::Error::UnknownOrdinal {
246 ordinal: tx_header.ordinal,
247 protocol_name:
248 <VulkanModeSetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
249 }),
250 }
251 }
252}
253
254pub struct VulkanModeSetterRequestStream {
256 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
257 is_terminated: bool,
258}
259
260impl std::marker::Unpin for VulkanModeSetterRequestStream {}
261
262impl futures::stream::FusedStream for VulkanModeSetterRequestStream {
263 fn is_terminated(&self) -> bool {
264 self.is_terminated
265 }
266}
267
268impl fidl::endpoints::RequestStream for VulkanModeSetterRequestStream {
269 type Protocol = VulkanModeSetterMarker;
270 type ControlHandle = VulkanModeSetterControlHandle;
271
272 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
273 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
274 }
275
276 fn control_handle(&self) -> Self::ControlHandle {
277 VulkanModeSetterControlHandle { inner: self.inner.clone() }
278 }
279
280 fn into_inner(
281 self,
282 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
283 {
284 (self.inner, self.is_terminated)
285 }
286
287 fn from_inner(
288 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
289 is_terminated: bool,
290 ) -> Self {
291 Self { inner, is_terminated }
292 }
293}
294
295impl futures::Stream for VulkanModeSetterRequestStream {
296 type Item = Result<VulkanModeSetterRequest, fidl::Error>;
297
298 fn poll_next(
299 mut self: std::pin::Pin<&mut Self>,
300 cx: &mut std::task::Context<'_>,
301 ) -> std::task::Poll<Option<Self::Item>> {
302 let this = &mut *self;
303 if this.inner.check_shutdown(cx) {
304 this.is_terminated = true;
305 return std::task::Poll::Ready(None);
306 }
307 if this.is_terminated {
308 panic!("polled VulkanModeSetterRequestStream after completion");
309 }
310 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
311 |bytes, handles| {
312 match this.inner.channel().read_etc(cx, bytes, handles) {
313 std::task::Poll::Ready(Ok(())) => {}
314 std::task::Poll::Pending => return std::task::Poll::Pending,
315 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
316 this.is_terminated = true;
317 return std::task::Poll::Ready(None);
318 }
319 std::task::Poll::Ready(Err(e)) => {
320 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
321 e.into(),
322 ))))
323 }
324 }
325
326 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
328
329 std::task::Poll::Ready(Some(match header.ordinal {
330 0x71ffe16858e9e7eb => {
331 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
332 let mut req = fidl::new_empty!(
333 VulkanModeSetterSetVulkanModeRequest,
334 fidl::encoding::DefaultFuchsiaResourceDialect
335 );
336 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VulkanModeSetterSetVulkanModeRequest>(&header, _body_bytes, handles, &mut req)?;
337 let control_handle =
338 VulkanModeSetterControlHandle { inner: this.inner.clone() };
339 Ok(VulkanModeSetterRequest::SetVulkanMode {
340 payload: req,
341 responder: VulkanModeSetterSetVulkanModeResponder {
342 control_handle: std::mem::ManuallyDrop::new(control_handle),
343 tx_id: header.tx_id,
344 },
345 })
346 }
347 _ if header.tx_id == 0
348 && header
349 .dynamic_flags()
350 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
351 {
352 Ok(VulkanModeSetterRequest::_UnknownMethod {
353 ordinal: header.ordinal,
354 control_handle: VulkanModeSetterControlHandle {
355 inner: this.inner.clone(),
356 },
357 method_type: fidl::MethodType::OneWay,
358 })
359 }
360 _ if header
361 .dynamic_flags()
362 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
363 {
364 this.inner.send_framework_err(
365 fidl::encoding::FrameworkErr::UnknownMethod,
366 header.tx_id,
367 header.ordinal,
368 header.dynamic_flags(),
369 (bytes, handles),
370 )?;
371 Ok(VulkanModeSetterRequest::_UnknownMethod {
372 ordinal: header.ordinal,
373 control_handle: VulkanModeSetterControlHandle {
374 inner: this.inner.clone(),
375 },
376 method_type: fidl::MethodType::TwoWay,
377 })
378 }
379 _ => Err(fidl::Error::UnknownOrdinal {
380 ordinal: header.ordinal,
381 protocol_name:
382 <VulkanModeSetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
383 }),
384 }))
385 },
386 )
387 }
388}
389
390#[derive(Debug)]
391pub enum VulkanModeSetterRequest {
392 SetVulkanMode {
395 payload: VulkanModeSetterSetVulkanModeRequest,
396 responder: VulkanModeSetterSetVulkanModeResponder,
397 },
398 #[non_exhaustive]
400 _UnknownMethod {
401 ordinal: u64,
403 control_handle: VulkanModeSetterControlHandle,
404 method_type: fidl::MethodType,
405 },
406}
407
408impl VulkanModeSetterRequest {
409 #[allow(irrefutable_let_patterns)]
410 pub fn into_set_vulkan_mode(
411 self,
412 ) -> Option<(VulkanModeSetterSetVulkanModeRequest, VulkanModeSetterSetVulkanModeResponder)>
413 {
414 if let VulkanModeSetterRequest::SetVulkanMode { payload, responder } = self {
415 Some((payload, responder))
416 } else {
417 None
418 }
419 }
420
421 pub fn method_name(&self) -> &'static str {
423 match *self {
424 VulkanModeSetterRequest::SetVulkanMode { .. } => "set_vulkan_mode",
425 VulkanModeSetterRequest::_UnknownMethod {
426 method_type: fidl::MethodType::OneWay,
427 ..
428 } => "unknown one-way method",
429 VulkanModeSetterRequest::_UnknownMethod {
430 method_type: fidl::MethodType::TwoWay,
431 ..
432 } => "unknown two-way method",
433 }
434 }
435}
436
437#[derive(Debug, Clone)]
438pub struct VulkanModeSetterControlHandle {
439 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
440}
441
442impl fidl::endpoints::ControlHandle for VulkanModeSetterControlHandle {
443 fn shutdown(&self) {
444 self.inner.shutdown()
445 }
446 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
447 self.inner.shutdown_with_epitaph(status)
448 }
449
450 fn is_closed(&self) -> bool {
451 self.inner.channel().is_closed()
452 }
453 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
454 self.inner.channel().on_closed()
455 }
456
457 #[cfg(target_os = "fuchsia")]
458 fn signal_peer(
459 &self,
460 clear_mask: zx::Signals,
461 set_mask: zx::Signals,
462 ) -> Result<(), zx_status::Status> {
463 use fidl::Peered;
464 self.inner.channel().signal_peer(clear_mask, set_mask)
465 }
466}
467
468impl VulkanModeSetterControlHandle {}
469
470#[must_use = "FIDL methods require a response to be sent"]
471#[derive(Debug)]
472pub struct VulkanModeSetterSetVulkanModeResponder {
473 control_handle: std::mem::ManuallyDrop<VulkanModeSetterControlHandle>,
474 tx_id: u32,
475}
476
477impl std::ops::Drop for VulkanModeSetterSetVulkanModeResponder {
481 fn drop(&mut self) {
482 self.control_handle.shutdown();
483 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
485 }
486}
487
488impl fidl::endpoints::Responder for VulkanModeSetterSetVulkanModeResponder {
489 type ControlHandle = VulkanModeSetterControlHandle;
490
491 fn control_handle(&self) -> &VulkanModeSetterControlHandle {
492 &self.control_handle
493 }
494
495 fn drop_without_shutdown(mut self) {
496 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
498 std::mem::forget(self);
500 }
501}
502
503impl VulkanModeSetterSetVulkanModeResponder {
504 pub fn send(self, mut result: Result<(), VulkanModeSetterError>) -> Result<(), fidl::Error> {
508 let _result = self.send_raw(result);
509 if _result.is_err() {
510 self.control_handle.shutdown();
511 }
512 self.drop_without_shutdown();
513 _result
514 }
515
516 pub fn send_no_shutdown_on_err(
518 self,
519 mut result: Result<(), VulkanModeSetterError>,
520 ) -> Result<(), fidl::Error> {
521 let _result = self.send_raw(result);
522 self.drop_without_shutdown();
523 _result
524 }
525
526 fn send_raw(&self, mut result: Result<(), VulkanModeSetterError>) -> Result<(), fidl::Error> {
527 self.control_handle.inner.send::<fidl::encoding::ResultType<
528 fidl::encoding::EmptyStruct,
529 VulkanModeSetterError,
530 >>(
531 result,
532 self.tx_id,
533 0x71ffe16858e9e7eb,
534 fidl::encoding::DynamicFlags::empty(),
535 )
536 }
537}
538
539mod internal {
540 use super::*;
541}