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_bluetooth_rfcomm_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct RfcommTestMarker;
16
17impl fidl::endpoints::ProtocolMarker for RfcommTestMarker {
18 type Proxy = RfcommTestProxy;
19 type RequestStream = RfcommTestRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = RfcommTestSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.rfcomm.test.RfcommTest";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for RfcommTestMarker {}
26
27pub trait RfcommTestProxyInterface: Send + Sync {
28 fn r#disconnect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error>;
29 fn r#remote_line_status(
30 &self,
31 id: &fidl_fuchsia_bluetooth::PeerId,
32 channel_number: u8,
33 status: Status,
34 ) -> Result<(), fidl::Error>;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct RfcommTestSynchronousProxy {
39 client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for RfcommTestSynchronousProxy {
44 type Proxy = RfcommTestProxy;
45 type Protocol = RfcommTestMarker;
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 RfcommTestSynchronousProxy {
62 pub fn new(channel: fidl::Channel) -> Self {
63 let protocol_name = <RfcommTestMarker 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<RfcommTestEvent, fidl::Error> {
77 RfcommTestEvent::decode(self.client.wait_for_event(deadline)?)
78 }
79
80 pub fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
86 self.client.send::<RfcommTestDisconnectRequest>(
87 (id,),
88 0x6173bb03e37ddddf,
89 fidl::encoding::DynamicFlags::empty(),
90 )
91 }
92
93 pub fn r#remote_line_status(
101 &self,
102 mut id: &fidl_fuchsia_bluetooth::PeerId,
103 mut channel_number: u8,
104 mut status: Status,
105 ) -> Result<(), fidl::Error> {
106 self.client.send::<RfcommTestRemoteLineStatusRequest>(
107 (id, channel_number, status),
108 0x3689603441392637,
109 fidl::encoding::DynamicFlags::empty(),
110 )
111 }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl From<RfcommTestSynchronousProxy> for zx::Handle {
116 fn from(value: RfcommTestSynchronousProxy) -> Self {
117 value.into_channel().into()
118 }
119}
120
121#[cfg(target_os = "fuchsia")]
122impl From<fidl::Channel> for RfcommTestSynchronousProxy {
123 fn from(value: fidl::Channel) -> Self {
124 Self::new(value)
125 }
126}
127
128#[derive(Debug, Clone)]
129pub struct RfcommTestProxy {
130 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
131}
132
133impl fidl::endpoints::Proxy for RfcommTestProxy {
134 type Protocol = RfcommTestMarker;
135
136 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
137 Self::new(inner)
138 }
139
140 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
141 self.client.into_channel().map_err(|client| Self { client })
142 }
143
144 fn as_channel(&self) -> &::fidl::AsyncChannel {
145 self.client.as_channel()
146 }
147}
148
149impl RfcommTestProxy {
150 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
152 let protocol_name = <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
153 Self { client: fidl::client::Client::new(channel, protocol_name) }
154 }
155
156 pub fn take_event_stream(&self) -> RfcommTestEventStream {
162 RfcommTestEventStream { event_receiver: self.client.take_event_receiver() }
163 }
164
165 pub fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
171 RfcommTestProxyInterface::r#disconnect(self, id)
172 }
173
174 pub fn r#remote_line_status(
182 &self,
183 mut id: &fidl_fuchsia_bluetooth::PeerId,
184 mut channel_number: u8,
185 mut status: Status,
186 ) -> Result<(), fidl::Error> {
187 RfcommTestProxyInterface::r#remote_line_status(self, id, channel_number, status)
188 }
189}
190
191impl RfcommTestProxyInterface for RfcommTestProxy {
192 fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
193 self.client.send::<RfcommTestDisconnectRequest>(
194 (id,),
195 0x6173bb03e37ddddf,
196 fidl::encoding::DynamicFlags::empty(),
197 )
198 }
199
200 fn r#remote_line_status(
201 &self,
202 mut id: &fidl_fuchsia_bluetooth::PeerId,
203 mut channel_number: u8,
204 mut status: Status,
205 ) -> Result<(), fidl::Error> {
206 self.client.send::<RfcommTestRemoteLineStatusRequest>(
207 (id, channel_number, status),
208 0x3689603441392637,
209 fidl::encoding::DynamicFlags::empty(),
210 )
211 }
212}
213
214pub struct RfcommTestEventStream {
215 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
216}
217
218impl std::marker::Unpin for RfcommTestEventStream {}
219
220impl futures::stream::FusedStream for RfcommTestEventStream {
221 fn is_terminated(&self) -> bool {
222 self.event_receiver.is_terminated()
223 }
224}
225
226impl futures::Stream for RfcommTestEventStream {
227 type Item = Result<RfcommTestEvent, fidl::Error>;
228
229 fn poll_next(
230 mut self: std::pin::Pin<&mut Self>,
231 cx: &mut std::task::Context<'_>,
232 ) -> std::task::Poll<Option<Self::Item>> {
233 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
234 &mut self.event_receiver,
235 cx
236 )?) {
237 Some(buf) => std::task::Poll::Ready(Some(RfcommTestEvent::decode(buf))),
238 None => std::task::Poll::Ready(None),
239 }
240 }
241}
242
243#[derive(Debug)]
244pub enum RfcommTestEvent {}
245
246impl RfcommTestEvent {
247 fn decode(
249 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
250 ) -> Result<RfcommTestEvent, fidl::Error> {
251 let (bytes, _handles) = buf.split_mut();
252 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
253 debug_assert_eq!(tx_header.tx_id, 0);
254 match tx_header.ordinal {
255 _ => Err(fidl::Error::UnknownOrdinal {
256 ordinal: tx_header.ordinal,
257 protocol_name: <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
258 }),
259 }
260 }
261}
262
263pub struct RfcommTestRequestStream {
265 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
266 is_terminated: bool,
267}
268
269impl std::marker::Unpin for RfcommTestRequestStream {}
270
271impl futures::stream::FusedStream for RfcommTestRequestStream {
272 fn is_terminated(&self) -> bool {
273 self.is_terminated
274 }
275}
276
277impl fidl::endpoints::RequestStream for RfcommTestRequestStream {
278 type Protocol = RfcommTestMarker;
279 type ControlHandle = RfcommTestControlHandle;
280
281 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
282 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
283 }
284
285 fn control_handle(&self) -> Self::ControlHandle {
286 RfcommTestControlHandle { inner: self.inner.clone() }
287 }
288
289 fn into_inner(
290 self,
291 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
292 {
293 (self.inner, self.is_terminated)
294 }
295
296 fn from_inner(
297 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
298 is_terminated: bool,
299 ) -> Self {
300 Self { inner, is_terminated }
301 }
302}
303
304impl futures::Stream for RfcommTestRequestStream {
305 type Item = Result<RfcommTestRequest, fidl::Error>;
306
307 fn poll_next(
308 mut self: std::pin::Pin<&mut Self>,
309 cx: &mut std::task::Context<'_>,
310 ) -> std::task::Poll<Option<Self::Item>> {
311 let this = &mut *self;
312 if this.inner.check_shutdown(cx) {
313 this.is_terminated = true;
314 return std::task::Poll::Ready(None);
315 }
316 if this.is_terminated {
317 panic!("polled RfcommTestRequestStream after completion");
318 }
319 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
320 |bytes, handles| {
321 match this.inner.channel().read_etc(cx, bytes, handles) {
322 std::task::Poll::Ready(Ok(())) => {}
323 std::task::Poll::Pending => return std::task::Poll::Pending,
324 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
325 this.is_terminated = true;
326 return std::task::Poll::Ready(None);
327 }
328 std::task::Poll::Ready(Err(e)) => {
329 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
330 e.into(),
331 ))))
332 }
333 }
334
335 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
337
338 std::task::Poll::Ready(Some(match header.ordinal {
339 0x6173bb03e37ddddf => {
340 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
341 let mut req = fidl::new_empty!(
342 RfcommTestDisconnectRequest,
343 fidl::encoding::DefaultFuchsiaResourceDialect
344 );
345 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RfcommTestDisconnectRequest>(&header, _body_bytes, handles, &mut req)?;
346 let control_handle = RfcommTestControlHandle { inner: this.inner.clone() };
347 Ok(RfcommTestRequest::Disconnect { id: req.id, control_handle })
348 }
349 0x3689603441392637 => {
350 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
351 let mut req = fidl::new_empty!(
352 RfcommTestRemoteLineStatusRequest,
353 fidl::encoding::DefaultFuchsiaResourceDialect
354 );
355 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RfcommTestRemoteLineStatusRequest>(&header, _body_bytes, handles, &mut req)?;
356 let control_handle = RfcommTestControlHandle { inner: this.inner.clone() };
357 Ok(RfcommTestRequest::RemoteLineStatus {
358 id: req.id,
359 channel_number: req.channel_number,
360 status: req.status,
361
362 control_handle,
363 })
364 }
365 _ => Err(fidl::Error::UnknownOrdinal {
366 ordinal: header.ordinal,
367 protocol_name:
368 <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
369 }),
370 }))
371 },
372 )
373 }
374}
375
376#[derive(Debug)]
379pub enum RfcommTestRequest {
380 Disconnect { id: fidl_fuchsia_bluetooth::PeerId, control_handle: RfcommTestControlHandle },
386 RemoteLineStatus {
394 id: fidl_fuchsia_bluetooth::PeerId,
395 channel_number: u8,
396 status: Status,
397 control_handle: RfcommTestControlHandle,
398 },
399}
400
401impl RfcommTestRequest {
402 #[allow(irrefutable_let_patterns)]
403 pub fn into_disconnect(
404 self,
405 ) -> Option<(fidl_fuchsia_bluetooth::PeerId, RfcommTestControlHandle)> {
406 if let RfcommTestRequest::Disconnect { id, control_handle } = self {
407 Some((id, control_handle))
408 } else {
409 None
410 }
411 }
412
413 #[allow(irrefutable_let_patterns)]
414 pub fn into_remote_line_status(
415 self,
416 ) -> Option<(fidl_fuchsia_bluetooth::PeerId, u8, Status, RfcommTestControlHandle)> {
417 if let RfcommTestRequest::RemoteLineStatus { id, channel_number, status, control_handle } =
418 self
419 {
420 Some((id, channel_number, status, control_handle))
421 } else {
422 None
423 }
424 }
425
426 pub fn method_name(&self) -> &'static str {
428 match *self {
429 RfcommTestRequest::Disconnect { .. } => "disconnect",
430 RfcommTestRequest::RemoteLineStatus { .. } => "remote_line_status",
431 }
432 }
433}
434
435#[derive(Debug, Clone)]
436pub struct RfcommTestControlHandle {
437 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
438}
439
440impl fidl::endpoints::ControlHandle for RfcommTestControlHandle {
441 fn shutdown(&self) {
442 self.inner.shutdown()
443 }
444 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
445 self.inner.shutdown_with_epitaph(status)
446 }
447
448 fn is_closed(&self) -> bool {
449 self.inner.channel().is_closed()
450 }
451 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
452 self.inner.channel().on_closed()
453 }
454
455 #[cfg(target_os = "fuchsia")]
456 fn signal_peer(
457 &self,
458 clear_mask: zx::Signals,
459 set_mask: zx::Signals,
460 ) -> Result<(), zx_status::Status> {
461 use fidl::Peered;
462 self.inner.channel().signal_peer(clear_mask, set_mask)
463 }
464}
465
466impl RfcommTestControlHandle {}
467
468mod internal {
469 use super::*;
470}