fidl_fuchsia_bluetooth_a2dp/
fidl_fuchsia_bluetooth_a2dp.rs1#![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_bluetooth_a2dp__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct AudioModeMarker;
16
17impl fidl::endpoints::ProtocolMarker for AudioModeMarker {
18 type Proxy = AudioModeProxy;
19 type RequestStream = AudioModeRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = AudioModeSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.a2dp.AudioMode";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for AudioModeMarker {}
26
27pub trait AudioModeProxyInterface: Send + Sync {
28 type SetRoleResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
29 fn r#set_role(&self, role: Role) -> Self::SetRoleResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct AudioModeSynchronousProxy {
34 client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for AudioModeSynchronousProxy {
39 type Proxy = AudioModeProxy;
40 type Protocol = AudioModeMarker;
41
42 fn from_channel(inner: fidl::Channel) -> Self {
43 Self::new(inner)
44 }
45
46 fn into_channel(self) -> fidl::Channel {
47 self.client.into_channel()
48 }
49
50 fn as_channel(&self) -> &fidl::Channel {
51 self.client.as_channel()
52 }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl AudioModeSynchronousProxy {
57 pub fn new(channel: fidl::Channel) -> Self {
58 let protocol_name = <AudioModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<AudioModeEvent, fidl::Error> {
72 AudioModeEvent::decode(self.client.wait_for_event(deadline)?)
73 }
74
75 pub fn r#set_role(
87 &self,
88 mut role: Role,
89 ___deadline: zx::MonotonicInstant,
90 ) -> Result<(), fidl::Error> {
91 let _response =
92 self.client.send_query::<AudioModeSetRoleRequest, fidl::encoding::EmptyPayload>(
93 (role,),
94 0x55bc139643a166a6,
95 fidl::encoding::DynamicFlags::empty(),
96 ___deadline,
97 )?;
98 Ok(_response)
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<AudioModeSynchronousProxy> for zx::Handle {
104 fn from(value: AudioModeSynchronousProxy) -> Self {
105 value.into_channel().into()
106 }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl From<fidl::Channel> for AudioModeSynchronousProxy {
111 fn from(value: fidl::Channel) -> Self {
112 Self::new(value)
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl fidl::endpoints::FromClient for AudioModeSynchronousProxy {
118 type Protocol = AudioModeMarker;
119
120 fn from_client(value: fidl::endpoints::ClientEnd<AudioModeMarker>) -> Self {
121 Self::new(value.into_channel())
122 }
123}
124
125#[derive(Debug, Clone)]
126pub struct AudioModeProxy {
127 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
128}
129
130impl fidl::endpoints::Proxy for AudioModeProxy {
131 type Protocol = AudioModeMarker;
132
133 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
134 Self::new(inner)
135 }
136
137 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
138 self.client.into_channel().map_err(|client| Self { client })
139 }
140
141 fn as_channel(&self) -> &::fidl::AsyncChannel {
142 self.client.as_channel()
143 }
144}
145
146impl AudioModeProxy {
147 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
149 let protocol_name = <AudioModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150 Self { client: fidl::client::Client::new(channel, protocol_name) }
151 }
152
153 pub fn take_event_stream(&self) -> AudioModeEventStream {
159 AudioModeEventStream { event_receiver: self.client.take_event_receiver() }
160 }
161
162 pub fn r#set_role(
174 &self,
175 mut role: Role,
176 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
177 AudioModeProxyInterface::r#set_role(self, role)
178 }
179}
180
181impl AudioModeProxyInterface for AudioModeProxy {
182 type SetRoleResponseFut =
183 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
184 fn r#set_role(&self, mut role: Role) -> Self::SetRoleResponseFut {
185 fn _decode(
186 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
187 ) -> Result<(), fidl::Error> {
188 let _response = fidl::client::decode_transaction_body::<
189 fidl::encoding::EmptyPayload,
190 fidl::encoding::DefaultFuchsiaResourceDialect,
191 0x55bc139643a166a6,
192 >(_buf?)?;
193 Ok(_response)
194 }
195 self.client.send_query_and_decode::<AudioModeSetRoleRequest, ()>(
196 (role,),
197 0x55bc139643a166a6,
198 fidl::encoding::DynamicFlags::empty(),
199 _decode,
200 )
201 }
202}
203
204pub struct AudioModeEventStream {
205 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
206}
207
208impl std::marker::Unpin for AudioModeEventStream {}
209
210impl futures::stream::FusedStream for AudioModeEventStream {
211 fn is_terminated(&self) -> bool {
212 self.event_receiver.is_terminated()
213 }
214}
215
216impl futures::Stream for AudioModeEventStream {
217 type Item = Result<AudioModeEvent, fidl::Error>;
218
219 fn poll_next(
220 mut self: std::pin::Pin<&mut Self>,
221 cx: &mut std::task::Context<'_>,
222 ) -> std::task::Poll<Option<Self::Item>> {
223 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
224 &mut self.event_receiver,
225 cx
226 )?) {
227 Some(buf) => std::task::Poll::Ready(Some(AudioModeEvent::decode(buf))),
228 None => std::task::Poll::Ready(None),
229 }
230 }
231}
232
233#[derive(Debug)]
234pub enum AudioModeEvent {}
235
236impl AudioModeEvent {
237 fn decode(
239 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
240 ) -> Result<AudioModeEvent, fidl::Error> {
241 let (bytes, _handles) = buf.split_mut();
242 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
243 debug_assert_eq!(tx_header.tx_id, 0);
244 match tx_header.ordinal {
245 _ => Err(fidl::Error::UnknownOrdinal {
246 ordinal: tx_header.ordinal,
247 protocol_name: <AudioModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
248 }),
249 }
250 }
251}
252
253pub struct AudioModeRequestStream {
255 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
256 is_terminated: bool,
257}
258
259impl std::marker::Unpin for AudioModeRequestStream {}
260
261impl futures::stream::FusedStream for AudioModeRequestStream {
262 fn is_terminated(&self) -> bool {
263 self.is_terminated
264 }
265}
266
267impl fidl::endpoints::RequestStream for AudioModeRequestStream {
268 type Protocol = AudioModeMarker;
269 type ControlHandle = AudioModeControlHandle;
270
271 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
272 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
273 }
274
275 fn control_handle(&self) -> Self::ControlHandle {
276 AudioModeControlHandle { inner: self.inner.clone() }
277 }
278
279 fn into_inner(
280 self,
281 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
282 {
283 (self.inner, self.is_terminated)
284 }
285
286 fn from_inner(
287 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
288 is_terminated: bool,
289 ) -> Self {
290 Self { inner, is_terminated }
291 }
292}
293
294impl futures::Stream for AudioModeRequestStream {
295 type Item = Result<AudioModeRequest, fidl::Error>;
296
297 fn poll_next(
298 mut self: std::pin::Pin<&mut Self>,
299 cx: &mut std::task::Context<'_>,
300 ) -> std::task::Poll<Option<Self::Item>> {
301 let this = &mut *self;
302 if this.inner.check_shutdown(cx) {
303 this.is_terminated = true;
304 return std::task::Poll::Ready(None);
305 }
306 if this.is_terminated {
307 panic!("polled AudioModeRequestStream after completion");
308 }
309 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
310 |bytes, handles| {
311 match this.inner.channel().read_etc(cx, bytes, handles) {
312 std::task::Poll::Ready(Ok(())) => {}
313 std::task::Poll::Pending => return std::task::Poll::Pending,
314 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
315 this.is_terminated = true;
316 return std::task::Poll::Ready(None);
317 }
318 std::task::Poll::Ready(Err(e)) => {
319 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
320 e.into(),
321 ))))
322 }
323 }
324
325 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
327
328 std::task::Poll::Ready(Some(match header.ordinal {
329 0x55bc139643a166a6 => {
330 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
331 let mut req = fidl::new_empty!(
332 AudioModeSetRoleRequest,
333 fidl::encoding::DefaultFuchsiaResourceDialect
334 );
335 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioModeSetRoleRequest>(&header, _body_bytes, handles, &mut req)?;
336 let control_handle = AudioModeControlHandle { inner: this.inner.clone() };
337 Ok(AudioModeRequest::SetRole {
338 role: req.role,
339
340 responder: AudioModeSetRoleResponder {
341 control_handle: std::mem::ManuallyDrop::new(control_handle),
342 tx_id: header.tx_id,
343 },
344 })
345 }
346 _ => Err(fidl::Error::UnknownOrdinal {
347 ordinal: header.ordinal,
348 protocol_name:
349 <AudioModeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
350 }),
351 }))
352 },
353 )
354 }
355}
356
357#[derive(Debug)]
359pub enum AudioModeRequest {
360 SetRole { role: Role, responder: AudioModeSetRoleResponder },
372}
373
374impl AudioModeRequest {
375 #[allow(irrefutable_let_patterns)]
376 pub fn into_set_role(self) -> Option<(Role, AudioModeSetRoleResponder)> {
377 if let AudioModeRequest::SetRole { role, responder } = self {
378 Some((role, responder))
379 } else {
380 None
381 }
382 }
383
384 pub fn method_name(&self) -> &'static str {
386 match *self {
387 AudioModeRequest::SetRole { .. } => "set_role",
388 }
389 }
390}
391
392#[derive(Debug, Clone)]
393pub struct AudioModeControlHandle {
394 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
395}
396
397impl fidl::endpoints::ControlHandle for AudioModeControlHandle {
398 fn shutdown(&self) {
399 self.inner.shutdown()
400 }
401 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
402 self.inner.shutdown_with_epitaph(status)
403 }
404
405 fn is_closed(&self) -> bool {
406 self.inner.channel().is_closed()
407 }
408 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
409 self.inner.channel().on_closed()
410 }
411
412 #[cfg(target_os = "fuchsia")]
413 fn signal_peer(
414 &self,
415 clear_mask: zx::Signals,
416 set_mask: zx::Signals,
417 ) -> Result<(), zx_status::Status> {
418 use fidl::Peered;
419 self.inner.channel().signal_peer(clear_mask, set_mask)
420 }
421}
422
423impl AudioModeControlHandle {}
424
425#[must_use = "FIDL methods require a response to be sent"]
426#[derive(Debug)]
427pub struct AudioModeSetRoleResponder {
428 control_handle: std::mem::ManuallyDrop<AudioModeControlHandle>,
429 tx_id: u32,
430}
431
432impl std::ops::Drop for AudioModeSetRoleResponder {
436 fn drop(&mut self) {
437 self.control_handle.shutdown();
438 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
440 }
441}
442
443impl fidl::endpoints::Responder for AudioModeSetRoleResponder {
444 type ControlHandle = AudioModeControlHandle;
445
446 fn control_handle(&self) -> &AudioModeControlHandle {
447 &self.control_handle
448 }
449
450 fn drop_without_shutdown(mut self) {
451 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
453 std::mem::forget(self);
455 }
456}
457
458impl AudioModeSetRoleResponder {
459 pub fn send(self) -> Result<(), fidl::Error> {
463 let _result = self.send_raw();
464 if _result.is_err() {
465 self.control_handle.shutdown();
466 }
467 self.drop_without_shutdown();
468 _result
469 }
470
471 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
473 let _result = self.send_raw();
474 self.drop_without_shutdown();
475 _result
476 }
477
478 fn send_raw(&self) -> Result<(), fidl::Error> {
479 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
480 (),
481 self.tx_id,
482 0x55bc139643a166a6,
483 fidl::encoding::DynamicFlags::empty(),
484 )
485 }
486}
487
488mod internal {
489 use super::*;
490}