1#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub mod natural {
6
7 pub use fidl_next_common_fuchsia_hardware_mailbox::natural::*;
8
9 #[derive(Debug, PartialEq)]
10 #[repr(C)]
11 pub struct ChannelRegisterListenerRequest {
12 pub listener: ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::fuchsia::zx::Channel>,
13 }
14
15 unsafe impl<___E> ::fidl_next::Encode<crate::wire::ChannelRegisterListenerRequest, ___E>
16 for ChannelRegisterListenerRequest
17 where
18 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
19 ___E: ::fidl_next::fuchsia::HandleEncoder,
20 {
21 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
22 Self,
23 crate::wire::ChannelRegisterListenerRequest,
24 > = unsafe {
25 ::fidl_next::CopyOptimization::enable_if(
26 true
27
28 && <
29 ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::fuchsia::zx::Channel> as ::fidl_next::Encode<::fidl_next::ClientEnd<crate::Listener, ::fidl_next::wire::fuchsia::Channel>, ___E>
30 >::COPY_OPTIMIZATION.is_enabled()
31
32 )
33 };
34
35 #[inline]
36 fn encode(
37 self,
38 encoder_: &mut ___E,
39 out_: &mut ::core::mem::MaybeUninit<crate::wire::ChannelRegisterListenerRequest>,
40 _: (),
41 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
42 ::fidl_next::munge! {
43 let crate::wire::ChannelRegisterListenerRequest {
44 listener,
45
46 } = out_;
47 }
48
49 ::fidl_next::Encode::encode(self.listener, encoder_, listener, ())?;
50
51 let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(listener.as_mut_ptr()) };
52
53 Ok(())
54 }
55 }
56
57 unsafe impl<___E>
58 ::fidl_next::EncodeOption<
59 ::fidl_next::wire::Box<'static, crate::wire::ChannelRegisterListenerRequest>,
60 ___E,
61 > for ChannelRegisterListenerRequest
62 where
63 ___E: ::fidl_next::Encoder + ?Sized,
64 ChannelRegisterListenerRequest:
65 ::fidl_next::Encode<crate::wire::ChannelRegisterListenerRequest, ___E>,
66 {
67 #[inline]
68 fn encode_option(
69 this: ::core::option::Option<Self>,
70 encoder: &mut ___E,
71 out: &mut ::core::mem::MaybeUninit<
72 ::fidl_next::wire::Box<'static, crate::wire::ChannelRegisterListenerRequest>,
73 >,
74 _: (),
75 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
76 if let Some(inner) = this {
77 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
78 ::fidl_next::wire::Box::encode_present(out);
79 } else {
80 ::fidl_next::wire::Box::encode_absent(out);
81 }
82
83 Ok(())
84 }
85 }
86
87 impl ::fidl_next::FromWire<crate::wire::ChannelRegisterListenerRequest>
88 for ChannelRegisterListenerRequest
89 {
90 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
91 crate::wire::ChannelRegisterListenerRequest,
92 Self,
93 > = unsafe {
94 ::fidl_next::CopyOptimization::enable_if(
95 true
96
97 && <
98 ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::fuchsia::zx::Channel> as ::fidl_next::FromWire<::fidl_next::ClientEnd<crate::Listener, ::fidl_next::wire::fuchsia::Channel>>
99 >::COPY_OPTIMIZATION.is_enabled()
100
101 )
102 };
103
104 #[inline]
105 fn from_wire(wire: crate::wire::ChannelRegisterListenerRequest) -> Self {
106 Self { listener: ::fidl_next::FromWire::from_wire(wire.listener) }
107 }
108 }
109}
110
111pub mod wire {
112
113 pub use fidl_next_common_fuchsia_hardware_mailbox::wire::*;
114
115 #[derive(Debug)]
117 #[repr(C)]
118 pub struct ChannelRegisterListenerRequest {
119 pub listener: ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::wire::fuchsia::Channel>,
120 }
121
122 static_assertions::const_assert_eq!(std::mem::size_of::<ChannelRegisterListenerRequest>(), 4);
123 static_assertions::const_assert_eq!(std::mem::align_of::<ChannelRegisterListenerRequest>(), 4);
124
125 static_assertions::const_assert_eq!(
126 std::mem::offset_of!(ChannelRegisterListenerRequest, listener),
127 0
128 );
129
130 impl ::fidl_next::Constrained for ChannelRegisterListenerRequest {
131 type Constraint = ();
132
133 fn validate(
134 _: ::fidl_next::Slot<'_, Self>,
135 _: Self::Constraint,
136 ) -> Result<(), ::fidl_next::ValidationError> {
137 Ok(())
138 }
139 }
140
141 unsafe impl ::fidl_next::Wire for ChannelRegisterListenerRequest {
142 type Narrowed<'de> = ChannelRegisterListenerRequest;
143
144 #[inline]
145 fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
146 ::fidl_next::munge! {
147 let Self {
148 listener,
149
150 } = &mut *out_;
151 }
152
153 ::fidl_next::Wire::zero_padding(listener);
154 }
155 }
156
157 unsafe impl<___D> ::fidl_next::Decode<___D> for ChannelRegisterListenerRequest
158 where
159 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
160 ___D: ::fidl_next::fuchsia::HandleDecoder,
161 {
162 fn decode(
163 slot_: ::fidl_next::Slot<'_, Self>,
164 decoder_: &mut ___D,
165 _: (),
166 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
167 ::fidl_next::munge! {
168 let Self {
169 mut listener,
170
171 } = slot_;
172 }
173
174 let _field = listener.as_mut();
175
176 ::fidl_next::Decode::decode(listener.as_mut(), decoder_, ())?;
177
178 Ok(())
179 }
180 }
181
182 impl ::fidl_next::IntoNatural for ChannelRegisterListenerRequest {
183 type Natural = crate::natural::ChannelRegisterListenerRequest;
184 }
185}
186
187pub mod wire_optional {
188
189 pub use fidl_next_common_fuchsia_hardware_mailbox::wire_optional::*;
190}
191
192pub mod generic {
193
194 pub use fidl_next_common_fuchsia_hardware_mailbox::generic::*;
195
196 pub struct ChannelRegisterListenerRequest<T0> {
198 pub listener: T0,
199 }
200
201 unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::ChannelRegisterListenerRequest, ___E>
202 for ChannelRegisterListenerRequest<T0>
203 where
204 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
205 ___E: ::fidl_next::fuchsia::HandleEncoder,
206 T0: ::fidl_next::Encode<
207 ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::wire::fuchsia::Channel>,
208 ___E,
209 >,
210 {
211 #[inline]
212 fn encode(
213 self,
214 encoder_: &mut ___E,
215 out_: &mut ::core::mem::MaybeUninit<crate::wire::ChannelRegisterListenerRequest>,
216 _: (),
217 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
218 ::fidl_next::munge! {
219 let crate::wire::ChannelRegisterListenerRequest {
220 listener,
221
222 } = out_;
223 }
224
225 ::fidl_next::Encode::encode(self.listener, encoder_, listener, ())?;
226
227 Ok(())
228 }
229 }
230}
231
232pub use self::natural::*;
233
234#[doc = " `Channel` represents a single mailbox channel that can be used to send messages to a\n destination core.\n"]
236#[derive(PartialEq, Debug)]
237pub struct Channel;
238
239impl ::fidl_next::Discoverable for Channel {
240 const PROTOCOL_NAME: &'static str = "fuchsia.hardware.mailbox.Channel";
241}
242
243#[cfg(target_os = "fuchsia")]
244impl ::fidl_next::HasTransport for Channel {
245 type Transport = ::fidl_next::fuchsia::zx::Channel;
246}
247
248pub mod channel {
249 pub mod prelude {
250 pub use crate::{
251 Channel, ChannelClientHandler, ChannelLocalClientHandler, ChannelLocalServerHandler,
252 ChannelServerHandler, channel,
253 };
254
255 pub use crate::natural::ChannelRegisterListenerRequest;
256
257 pub use crate::natural::ChannelSendMessageRequest;
258
259 pub use crate::natural::ChannelSendRequestRequest;
260
261 pub use crate::natural::ChannelRegisterListenerResponse;
262
263 pub use crate::natural::ChannelSendMessageResponse;
264
265 pub use crate::natural::ChannelSendRequestResponse;
266 }
267
268 pub struct SendMessage;
269
270 impl ::fidl_next::Method for SendMessage {
271 const ORDINAL: u64 = 6704182562539000811;
272 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
273 ::fidl_next::protocol::Flexibility::Strict;
274
275 type Protocol = crate::Channel;
276
277 type Request = crate::wire::ChannelSendMessageRequest<'static>;
278 }
279
280 impl ::fidl_next::TwoWayMethod for SendMessage {
281 type Response = ::fidl_next::wire::Result<
282 'static,
283 crate::wire::ChannelSendMessageResponse,
284 ::fidl_next::wire::fuchsia::Status,
285 >;
286 }
287
288 impl<___R> ::fidl_next::Respond<___R> for SendMessage {
289 type Output = ::core::result::Result<___R, ::fidl_next::never::Never>;
290
291 fn respond(response: ___R) -> Self::Output {
292 ::core::result::Result::Ok(response)
293 }
294 }
295
296 impl<___R> ::fidl_next::RespondErr<___R> for SendMessage {
297 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
298
299 fn respond_err(response: ___R) -> Self::Output {
300 ::core::result::Result::Err(response)
301 }
302 }
303
304 pub struct SendRequest;
305
306 impl ::fidl_next::Method for SendRequest {
307 const ORDINAL: u64 = 8628593229059937179;
308 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
309 ::fidl_next::protocol::Flexibility::Flexible;
310
311 type Protocol = crate::Channel;
312
313 type Request = crate::wire::ChannelSendRequestRequest<'static>;
314 }
315
316 impl ::fidl_next::TwoWayMethod for SendRequest {
317 type Response = ::fidl_next::wire::Result<
318 'static,
319 crate::wire::ChannelSendRequestResponse<'static>,
320 ::fidl_next::wire::fuchsia::Status,
321 >;
322 }
323
324 impl<___R> ::fidl_next::Respond<___R> for SendRequest {
325 type Output = ::core::result::Result<
326 crate::generic::ChannelSendRequestResponse<___R>,
327 ::fidl_next::never::Never,
328 >;
329
330 fn respond(response: ___R) -> Self::Output {
331 ::core::result::Result::Ok(crate::generic::ChannelSendRequestResponse {
332 response: response,
333 })
334 }
335 }
336
337 impl<___R> ::fidl_next::RespondErr<___R> for SendRequest {
338 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
339
340 fn respond_err(response: ___R) -> Self::Output {
341 ::core::result::Result::Err(response)
342 }
343 }
344
345 pub struct RegisterListener;
346
347 impl ::fidl_next::Method for RegisterListener {
348 const ORDINAL: u64 = 7770453825026299131;
349 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
350 ::fidl_next::protocol::Flexibility::Flexible;
351
352 type Protocol = crate::Channel;
353
354 type Request = crate::wire::ChannelRegisterListenerRequest;
355 }
356
357 impl ::fidl_next::TwoWayMethod for RegisterListener {
358 type Response = ::fidl_next::wire::Result<
359 'static,
360 crate::wire::ChannelRegisterListenerResponse,
361 ::fidl_next::wire::fuchsia::Status,
362 >;
363 }
364
365 impl<___R> ::fidl_next::Respond<___R> for RegisterListener {
366 type Output = ::core::result::Result<___R, ::fidl_next::never::Never>;
367
368 fn respond(response: ___R) -> Self::Output {
369 ::core::result::Result::Ok(response)
370 }
371 }
372
373 impl<___R> ::fidl_next::RespondErr<___R> for RegisterListener {
374 type Output = ::core::result::Result<::fidl_next::never::Never, ___R>;
375
376 fn respond_err(response: ___R) -> Self::Output {
377 ::core::result::Result::Err(response)
378 }
379 }
380
381 mod ___detail {
382 unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Channel
383 where
384 ___T: ::fidl_next::Transport,
385 {
386 type Client = ChannelClient<___T>;
387 type Server = ChannelServer<___T>;
388 }
389
390 #[repr(transparent)]
392 pub struct ChannelClient<___T: ::fidl_next::Transport> {
393 #[allow(dead_code)]
394 client: ::fidl_next::protocol::Client<___T>,
395 }
396
397 impl<___T> ChannelClient<___T>
398 where
399 ___T: ::fidl_next::Transport,
400 {
401 #[doc = " Writes the message to the mailbox, interrupts the destination core, and (if applicable)\n waits for the destination core to ack the message.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `message` is larger than what the hardware can support.\n"]
402 pub fn send_message(
403 &self,
404
405 message: impl ::fidl_next::Encode<
406 ::fidl_next::wire::Vector<'static, u8>,
407 <___T as ::fidl_next::Transport>::SendBuffer,
408 >,
409 ) -> ::fidl_next::TwoWayFuture<'_, super::SendMessage, ___T>
410 where
411 <___T as ::fidl_next::Transport>::SendBuffer:
412 ::fidl_next::encoder::InternalHandleEncoder,
413 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
414 {
415 self.send_message_with(crate::generic::ChannelSendMessageRequest { message })
416 }
417
418 #[doc = " Writes the message to the mailbox, interrupts the destination core, and (if applicable)\n waits for the destination core to ack the message.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `message` is larger than what the hardware can support.\n"]
419 pub fn send_message_with<___R>(
420 &self,
421 request: ___R,
422 ) -> ::fidl_next::TwoWayFuture<'_, super::SendMessage, ___T>
423 where
424 ___R: ::fidl_next::Encode<
425 crate::wire::ChannelSendMessageRequest<'static>,
426 <___T as ::fidl_next::Transport>::SendBuffer,
427 >,
428 {
429 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
430 6704182562539000811,
431 <super::SendMessage as ::fidl_next::Method>::FLEXIBILITY,
432 request,
433 ))
434 }
435
436 #[doc = " Writes the request to the mailbox, interrupts the destination core, and\n waits for the destination core to send a response.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `request` is larger than what the hardware can support.\n Returns `ZX_ERR_NOT_SUPPORTED` if the destination core does not support correlating\n requests to responses.\n"]
437 pub fn send_request(
438 &self,
439
440 request: impl ::fidl_next::Encode<
441 ::fidl_next::wire::Vector<'static, u8>,
442 <___T as ::fidl_next::Transport>::SendBuffer,
443 >,
444 ) -> ::fidl_next::TwoWayFuture<'_, super::SendRequest, ___T>
445 where
446 <___T as ::fidl_next::Transport>::SendBuffer:
447 ::fidl_next::encoder::InternalHandleEncoder,
448 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
449 {
450 self.send_request_with(crate::generic::ChannelSendRequestRequest { request })
451 }
452
453 #[doc = " Writes the request to the mailbox, interrupts the destination core, and\n waits for the destination core to send a response.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `request` is larger than what the hardware can support.\n Returns `ZX_ERR_NOT_SUPPORTED` if the destination core does not support correlating\n requests to responses.\n"]
454 pub fn send_request_with<___R>(
455 &self,
456 request: ___R,
457 ) -> ::fidl_next::TwoWayFuture<'_, super::SendRequest, ___T>
458 where
459 ___R: ::fidl_next::Encode<
460 crate::wire::ChannelSendRequestRequest<'static>,
461 <___T as ::fidl_next::Transport>::SendBuffer,
462 >,
463 {
464 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
465 8628593229059937179,
466 <super::SendRequest as ::fidl_next::Method>::FLEXIBILITY,
467 request,
468 ))
469 }
470
471 #[doc = " Registers a listener for incoming messages on this channel. Multiple listeners may NOT be\n registered at a time. If a listener is already registered, this call will fail with\n `ZX_ERR_ALREADY_BOUND`.\n\n To unregister a listener, the server will close its end of the channel. Another listener\n may be registered after the previous listener has been unregistered.\n"]
472 pub fn register_listener(
473 &self,
474
475 listener: impl ::fidl_next::Encode<
476 ::fidl_next::ClientEnd<crate::Listener, ::fidl_next::wire::fuchsia::Channel>,
477 <___T as ::fidl_next::Transport>::SendBuffer,
478 >,
479 ) -> ::fidl_next::TwoWayFuture<'_, super::RegisterListener, ___T>
480 where
481 <___T as ::fidl_next::Transport>::SendBuffer:
482 ::fidl_next::encoder::InternalHandleEncoder,
483 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::fuchsia::HandleEncoder,
484 {
485 self.register_listener_with(crate::generic::ChannelRegisterListenerRequest {
486 listener,
487 })
488 }
489
490 #[doc = " Registers a listener for incoming messages on this channel. Multiple listeners may NOT be\n registered at a time. If a listener is already registered, this call will fail with\n `ZX_ERR_ALREADY_BOUND`.\n\n To unregister a listener, the server will close its end of the channel. Another listener\n may be registered after the previous listener has been unregistered.\n"]
491 pub fn register_listener_with<___R>(
492 &self,
493 request: ___R,
494 ) -> ::fidl_next::TwoWayFuture<'_, super::RegisterListener, ___T>
495 where
496 ___R: ::fidl_next::Encode<
497 crate::wire::ChannelRegisterListenerRequest,
498 <___T as ::fidl_next::Transport>::SendBuffer,
499 >,
500 {
501 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
502 7770453825026299131,
503 <super::RegisterListener as ::fidl_next::Method>::FLEXIBILITY,
504 request,
505 ))
506 }
507 }
508
509 #[repr(transparent)]
511 pub struct ChannelServer<___T: ::fidl_next::Transport> {
512 server: ::fidl_next::protocol::Server<___T>,
513 }
514
515 impl<___T> ChannelServer<___T> where ___T: ::fidl_next::Transport {}
516 }
517}
518
519#[diagnostic::on_unimplemented(
520 note = "If {Self} implements the non-local ChannelClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
521)]
522
523pub trait ChannelLocalClientHandler<
527 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
528 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
529>
530{
531 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
532 ::core::future::ready(())
533 }
534}
535
536impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Channel
537where
538 ___H: ChannelLocalClientHandler<___T>,
539 ___T: ::fidl_next::Transport,
540{
541 async fn on_event(
542 handler: &mut ___H,
543 mut message: ::fidl_next::Message<___T>,
544 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
545 match *message.header().ordinal {
546 ordinal => {
547 handler.on_unknown_interaction(ordinal).await;
548 if ::core::matches!(
549 message.header().flexibility(),
550 ::fidl_next::protocol::Flexibility::Strict
551 ) {
552 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
553 } else {
554 Ok(())
555 }
556 }
557 }
558 }
559}
560
561#[diagnostic::on_unimplemented(
562 note = "If {Self} implements the non-local ChannelServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
563)]
564
565pub trait ChannelLocalServerHandler<
569 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
570 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
571>
572{
573 #[doc = " Writes the message to the mailbox, interrupts the destination core, and (if applicable)\n waits for the destination core to ack the message.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `message` is larger than what the hardware can support.\n"]
574 fn send_message(
575 &mut self,
576
577 request: ::fidl_next::Request<channel::SendMessage, ___T>,
578
579 responder: ::fidl_next::Responder<channel::SendMessage, ___T>,
580 ) -> impl ::core::future::Future<Output = ()>;
581
582 #[doc = " Writes the request to the mailbox, interrupts the destination core, and\n waits for the destination core to send a response.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `request` is larger than what the hardware can support.\n Returns `ZX_ERR_NOT_SUPPORTED` if the destination core does not support correlating\n requests to responses.\n"]
583 fn send_request(
584 &mut self,
585
586 request: ::fidl_next::Request<channel::SendRequest, ___T>,
587
588 responder: ::fidl_next::Responder<channel::SendRequest, ___T>,
589 ) -> impl ::core::future::Future<Output = ()>;
590
591 #[doc = " Registers a listener for incoming messages on this channel. Multiple listeners may NOT be\n registered at a time. If a listener is already registered, this call will fail with\n `ZX_ERR_ALREADY_BOUND`.\n\n To unregister a listener, the server will close its end of the channel. Another listener\n may be registered after the previous listener has been unregistered.\n"]
592 fn register_listener(
593 &mut self,
594
595 request: ::fidl_next::Request<channel::RegisterListener, ___T>,
596
597 responder: ::fidl_next::Responder<channel::RegisterListener, ___T>,
598 ) -> impl ::core::future::Future<Output = ()>;
599
600 fn on_unknown_interaction(&mut self, ordinal: u64) -> impl ::core::future::Future<Output = ()> {
601 ::core::future::ready(())
602 }
603}
604
605impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Channel
606where
607 ___H: ChannelLocalServerHandler<___T>,
608 ___T: ::fidl_next::Transport,
609 for<'de> crate::wire::ChannelSendMessageRequest<'de>: ::fidl_next::Decode<
610 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
611 Constraint = (),
612 >,
613 for<'de> crate::wire::ChannelSendRequestRequest<'de>: ::fidl_next::Decode<
614 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
615 Constraint = (),
616 >,
617 for<'de> crate::wire::ChannelRegisterListenerRequest: ::fidl_next::Decode<
618 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
619 Constraint = (),
620 >,
621{
622 async fn on_one_way(
623 handler: &mut ___H,
624 mut message: ::fidl_next::Message<___T>,
625 ) -> ::core::result::Result<
626 (),
627 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
628 > {
629 match *message.header().ordinal {
630 ordinal => {
631 handler.on_unknown_interaction(ordinal).await;
632 if ::core::matches!(
633 message.header().flexibility(),
634 ::fidl_next::protocol::Flexibility::Strict
635 ) {
636 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
637 } else {
638 Ok(())
639 }
640 }
641 }
642 }
643
644 async fn on_two_way(
645 handler: &mut ___H,
646 mut message: ::fidl_next::Message<___T>,
647 responder: ::fidl_next::protocol::Responder<___T>,
648 ) -> ::core::result::Result<
649 (),
650 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
651 > {
652 match *message.header().ordinal {
653 6704182562539000811 => {
654 let responder = ::fidl_next::Responder::from_untyped(responder);
655
656 match ::fidl_next::AsDecoderExt::into_decoded(message) {
657 Ok(decoded) => {
658 handler
659 .send_message(::fidl_next::Request::from_decoded(decoded), responder)
660 .await;
661 Ok(())
662 }
663 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
664 ordinal: 6704182562539000811,
665 error,
666 }),
667 }
668 }
669
670 8628593229059937179 => {
671 let responder = ::fidl_next::Responder::from_untyped(responder);
672
673 match ::fidl_next::AsDecoderExt::into_decoded(message) {
674 Ok(decoded) => {
675 handler
676 .send_request(::fidl_next::Request::from_decoded(decoded), responder)
677 .await;
678 Ok(())
679 }
680 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
681 ordinal: 8628593229059937179,
682 error,
683 }),
684 }
685 }
686
687 7770453825026299131 => {
688 let responder = ::fidl_next::Responder::from_untyped(responder);
689
690 match ::fidl_next::AsDecoderExt::into_decoded(message) {
691 Ok(decoded) => {
692 handler
693 .register_listener(
694 ::fidl_next::Request::from_decoded(decoded),
695 responder,
696 )
697 .await;
698 Ok(())
699 }
700 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
701 ordinal: 7770453825026299131,
702 error,
703 }),
704 }
705 }
706
707 ordinal => {
708 handler.on_unknown_interaction(ordinal).await;
709 if ::core::matches!(
710 message.header().flexibility(),
711 ::fidl_next::protocol::Flexibility::Strict
712 ) {
713 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
714 } else {
715 responder
716 .respond_framework_error(
717 ordinal,
718 ::fidl_next::FrameworkError::UnknownMethod,
719 )
720 .expect("encoding a framework error should never fail")
721 .await?;
722 Ok(())
723 }
724 }
725 }
726 }
727}
728
729pub trait ChannelClientHandler<
733 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
734 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
735>
736{
737 fn on_unknown_interaction(
738 &mut self,
739 ordinal: u64,
740 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
741 ::core::future::ready(())
742 }
743}
744
745impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Channel
746where
747 ___H: ChannelClientHandler<___T> + ::core::marker::Send,
748 ___T: ::fidl_next::Transport,
749{
750 async fn on_event(
751 handler: &mut ___H,
752 mut message: ::fidl_next::Message<___T>,
753 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
754 match *message.header().ordinal {
755 ordinal => {
756 handler.on_unknown_interaction(ordinal).await;
757 if ::core::matches!(
758 message.header().flexibility(),
759 ::fidl_next::protocol::Flexibility::Strict
760 ) {
761 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
762 } else {
763 Ok(())
764 }
765 }
766 }
767 }
768}
769
770pub trait ChannelServerHandler<
774 #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
775 #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
776>
777{
778 #[doc = " Writes the message to the mailbox, interrupts the destination core, and (if applicable)\n waits for the destination core to ack the message.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `message` is larger than what the hardware can support.\n"]
779 fn send_message(
780 &mut self,
781
782 request: ::fidl_next::Request<channel::SendMessage, ___T>,
783
784 responder: ::fidl_next::Responder<channel::SendMessage, ___T>,
785 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
786
787 #[doc = " Writes the request to the mailbox, interrupts the destination core, and\n waits for the destination core to send a response.\n\n Returns `ZX_ERR_OUT_OF_RANGE` if `request` is larger than what the hardware can support.\n Returns `ZX_ERR_NOT_SUPPORTED` if the destination core does not support correlating\n requests to responses.\n"]
788 fn send_request(
789 &mut self,
790
791 request: ::fidl_next::Request<channel::SendRequest, ___T>,
792
793 responder: ::fidl_next::Responder<channel::SendRequest, ___T>,
794 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
795
796 #[doc = " Registers a listener for incoming messages on this channel. Multiple listeners may NOT be\n registered at a time. If a listener is already registered, this call will fail with\n `ZX_ERR_ALREADY_BOUND`.\n\n To unregister a listener, the server will close its end of the channel. Another listener\n may be registered after the previous listener has been unregistered.\n"]
797 fn register_listener(
798 &mut self,
799
800 request: ::fidl_next::Request<channel::RegisterListener, ___T>,
801
802 responder: ::fidl_next::Responder<channel::RegisterListener, ___T>,
803 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
804
805 fn on_unknown_interaction(
806 &mut self,
807 ordinal: u64,
808 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
809 ::core::future::ready(())
810 }
811}
812
813impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Channel
814where
815 ___H: ChannelServerHandler<___T> + ::core::marker::Send,
816 ___T: ::fidl_next::Transport,
817 for<'de> crate::wire::ChannelSendMessageRequest<'de>: ::fidl_next::Decode<
818 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
819 Constraint = (),
820 >,
821 for<'de> crate::wire::ChannelSendRequestRequest<'de>: ::fidl_next::Decode<
822 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
823 Constraint = (),
824 >,
825 for<'de> crate::wire::ChannelRegisterListenerRequest: ::fidl_next::Decode<
826 <<___T as ::fidl_next::Transport>::RecvBuffer as ::fidl_next::AsDecoder<'de>>::Decoder,
827 Constraint = (),
828 >,
829{
830 async fn on_one_way(
831 handler: &mut ___H,
832 mut message: ::fidl_next::Message<___T>,
833 ) -> ::core::result::Result<
834 (),
835 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
836 > {
837 match *message.header().ordinal {
838 ordinal => {
839 handler.on_unknown_interaction(ordinal).await;
840 if ::core::matches!(
841 message.header().flexibility(),
842 ::fidl_next::protocol::Flexibility::Strict
843 ) {
844 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
845 } else {
846 Ok(())
847 }
848 }
849 }
850 }
851
852 async fn on_two_way(
853 handler: &mut ___H,
854 mut message: ::fidl_next::Message<___T>,
855 responder: ::fidl_next::protocol::Responder<___T>,
856 ) -> ::core::result::Result<
857 (),
858 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
859 > {
860 match *message.header().ordinal {
861 6704182562539000811 => {
862 let responder = ::fidl_next::Responder::from_untyped(responder);
863
864 match ::fidl_next::AsDecoderExt::into_decoded(message) {
865 Ok(decoded) => {
866 handler
867 .send_message(::fidl_next::Request::from_decoded(decoded), responder)
868 .await;
869 Ok(())
870 }
871 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
872 ordinal: 6704182562539000811,
873 error,
874 }),
875 }
876 }
877
878 8628593229059937179 => {
879 let responder = ::fidl_next::Responder::from_untyped(responder);
880
881 match ::fidl_next::AsDecoderExt::into_decoded(message) {
882 Ok(decoded) => {
883 handler
884 .send_request(::fidl_next::Request::from_decoded(decoded), responder)
885 .await;
886 Ok(())
887 }
888 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
889 ordinal: 8628593229059937179,
890 error,
891 }),
892 }
893 }
894
895 7770453825026299131 => {
896 let responder = ::fidl_next::Responder::from_untyped(responder);
897
898 match ::fidl_next::AsDecoderExt::into_decoded(message) {
899 Ok(decoded) => {
900 handler
901 .register_listener(
902 ::fidl_next::Request::from_decoded(decoded),
903 responder,
904 )
905 .await;
906 Ok(())
907 }
908 Err(error) => Err(::fidl_next::ProtocolError::InvalidMessage {
909 ordinal: 7770453825026299131,
910 error,
911 }),
912 }
913 }
914
915 ordinal => {
916 handler.on_unknown_interaction(ordinal).await;
917 if ::core::matches!(
918 message.header().flexibility(),
919 ::fidl_next::protocol::Flexibility::Strict
920 ) {
921 Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal))
922 } else {
923 responder
924 .respond_framework_error(
925 ordinal,
926 ::fidl_next::FrameworkError::UnknownMethod,
927 )
928 .expect("encoding a framework error should never fail")
929 .await?;
930 Ok(())
931 }
932 }
933 }
934 }
935}
936
937impl<___T> ChannelClientHandler<___T> for ::fidl_next::IgnoreEvents
938where
939 ___T: ::fidl_next::Transport,
940{
941 async fn on_unknown_interaction(&mut self, _: u64) {}
942}
943
944impl<___H, ___T> ChannelLocalClientHandler<___T> for ::fidl_next::Local<___H>
945where
946 ___H: ChannelClientHandler<___T>,
947 ___T: ::fidl_next::Transport,
948{
949 async fn on_unknown_interaction(&mut self, ordinal: u64) {
950 ___H::on_unknown_interaction(&mut self.0, ordinal).await
951 }
952}
953
954impl<___H, ___T> ChannelLocalServerHandler<___T> for ::fidl_next::Local<___H>
955where
956 ___H: ChannelServerHandler<___T>,
957 ___T: ::fidl_next::Transport,
958{
959 async fn send_message(
960 &mut self,
961
962 request: ::fidl_next::Request<channel::SendMessage, ___T>,
963
964 responder: ::fidl_next::Responder<channel::SendMessage, ___T>,
965 ) {
966 ___H::send_message(&mut self.0, request, responder).await
967 }
968
969 async fn send_request(
970 &mut self,
971
972 request: ::fidl_next::Request<channel::SendRequest, ___T>,
973
974 responder: ::fidl_next::Responder<channel::SendRequest, ___T>,
975 ) {
976 ___H::send_request(&mut self.0, request, responder).await
977 }
978
979 async fn register_listener(
980 &mut self,
981
982 request: ::fidl_next::Request<channel::RegisterListener, ___T>,
983
984 responder: ::fidl_next::Responder<channel::RegisterListener, ___T>,
985 ) {
986 ___H::register_listener(&mut self.0, request, responder).await
987 }
988
989 async fn on_unknown_interaction(&mut self, ordinal: u64) {
990 ___H::on_unknown_interaction(&mut self.0, ordinal).await
991 }
992}
993
994#[derive(Debug)]
996pub struct Service;
997
998impl ::fidl_next::DiscoverableService for Service {
999 const SERVICE_NAME: &'static str = "fuchsia.hardware.mailbox.Service";
1000 const MEMBER_NAMES: &'static [&'static str] = &["channel"];
1001}
1002
1003impl ::fidl_next::HasServiceRequest<::fidl_next::fuchsia::zx::Channel> for Service {}
1004
1005impl<___C> ::fidl_next::Service<___C> for Service
1006where
1007 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1008{
1009 type Connector = ServiceConnector<___C>;
1010}
1011
1012#[repr(transparent)]
1014pub struct ServiceConnector<___C> {
1015 #[allow(dead_code)]
1016 connector: ___C,
1017}
1018
1019impl<___C> ServiceConnector<___C>
1020where
1021 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1022{
1023 pub fn channel(
1025 &self,
1026 server_end: ::fidl_next::ServerEnd<crate::Channel, ::fidl_next::fuchsia::zx::Channel>,
1027 ) -> ::core::result::Result<
1028 (),
1029 <___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
1030 > {
1031 ::fidl_next::protocol::ServiceConnector::<
1032 ::fidl_next::fuchsia::zx::Channel
1033 >::connect_to_member(
1034 &self.connector,
1035 "channel",
1036 server_end.into_untyped(),
1037 )
1038 }
1039}
1040
1041pub trait ServiceHandler {
1043 fn channel(
1045 &self,
1046 server_end: ::fidl_next::ServerEnd<crate::Channel, ::fidl_next::fuchsia::zx::Channel>,
1047 );
1048}
1049
1050impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
1051where
1052 ___H: ServiceHandler,
1053 ::fidl_next::fuchsia::zx::Channel: ::fidl_next::InstanceFromServiceTransport<___T>,
1054{
1055 fn on_connection(handler: &___H, member: &str, server_end: ___T) {
1056 use ::fidl_next::InstanceFromServiceTransport;
1057 match member {
1058 "channel" => handler.channel(::fidl_next::ServerEnd::from_untyped(
1059 ::fidl_next::fuchsia::zx::Channel::from_service_transport(server_end),
1060 )),
1061
1062 _ => unreachable!(),
1063 }
1064 }
1065}
1066
1067pub use fidl_next_common_fuchsia_hardware_mailbox::*;