fidl_fuchsia_bluetooth_rfcomm_test/
fidl_fuchsia_bluetooth_rfcomm_test.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// The status of the line.
14///
15/// These are defined in GSM 07.10 Section 5.4.6.3.10.
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17#[repr(u32)]
18pub enum Status {
19    Ok = 0,
20    OverrunError = 1,
21    ParityError = 2,
22    FramingError = 3,
23}
24
25impl Status {
26    #[inline]
27    pub fn from_primitive(prim: u32) -> Option<Self> {
28        match prim {
29            0 => Some(Self::Ok),
30            1 => Some(Self::OverrunError),
31            2 => Some(Self::ParityError),
32            3 => Some(Self::FramingError),
33            _ => None,
34        }
35    }
36
37    #[inline]
38    pub const fn into_primitive(self) -> u32 {
39        self as u32
40    }
41
42    #[deprecated = "Strict enums should not use `is_unknown`"]
43    #[inline]
44    pub fn is_unknown(&self) -> bool {
45        false
46    }
47}
48
49#[derive(Clone, Debug, PartialEq)]
50pub struct RfcommTestDisconnectRequest {
51    pub id: fidl_fuchsia_bluetooth::PeerId,
52}
53
54impl fidl::Persistable for RfcommTestDisconnectRequest {}
55
56#[derive(Clone, Debug, PartialEq)]
57pub struct RfcommTestRemoteLineStatusRequest {
58    pub id: fidl_fuchsia_bluetooth::PeerId,
59    pub channel_number: u8,
60    pub status: Status,
61}
62
63impl fidl::Persistable for RfcommTestRemoteLineStatusRequest {}
64
65#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
66pub struct RfcommTestMarker;
67
68impl fidl::endpoints::ProtocolMarker for RfcommTestMarker {
69    type Proxy = RfcommTestProxy;
70    type RequestStream = RfcommTestRequestStream;
71    #[cfg(target_os = "fuchsia")]
72    type SynchronousProxy = RfcommTestSynchronousProxy;
73
74    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.rfcomm.test.RfcommTest";
75}
76impl fidl::endpoints::DiscoverableProtocolMarker for RfcommTestMarker {}
77
78pub trait RfcommTestProxyInterface: Send + Sync {
79    fn r#disconnect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error>;
80    fn r#remote_line_status(
81        &self,
82        id: &fidl_fuchsia_bluetooth::PeerId,
83        channel_number: u8,
84        status: Status,
85    ) -> Result<(), fidl::Error>;
86}
87#[derive(Debug)]
88#[cfg(target_os = "fuchsia")]
89pub struct RfcommTestSynchronousProxy {
90    client: fidl::client::sync::Client,
91}
92
93#[cfg(target_os = "fuchsia")]
94impl fidl::endpoints::SynchronousProxy for RfcommTestSynchronousProxy {
95    type Proxy = RfcommTestProxy;
96    type Protocol = RfcommTestMarker;
97
98    fn from_channel(inner: fidl::Channel) -> Self {
99        Self::new(inner)
100    }
101
102    fn into_channel(self) -> fidl::Channel {
103        self.client.into_channel()
104    }
105
106    fn as_channel(&self) -> &fidl::Channel {
107        self.client.as_channel()
108    }
109}
110
111#[cfg(target_os = "fuchsia")]
112impl RfcommTestSynchronousProxy {
113    pub fn new(channel: fidl::Channel) -> Self {
114        let protocol_name = <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
115        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
116    }
117
118    pub fn into_channel(self) -> fidl::Channel {
119        self.client.into_channel()
120    }
121
122    /// Waits until an event arrives and returns it. It is safe for other
123    /// threads to make concurrent requests while waiting for an event.
124    pub fn wait_for_event(
125        &self,
126        deadline: zx::MonotonicInstant,
127    ) -> Result<RfcommTestEvent, fidl::Error> {
128        RfcommTestEvent::decode(self.client.wait_for_event(deadline)?)
129    }
130
131    /// Disconnect the RFCOMM session with the connected peer.
132    ///
133    /// This is a no-op if there is no connected peer with identifier `id`.
134    ///
135    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
136    pub fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
137        self.client.send::<RfcommTestDisconnectRequest>(
138            (id,),
139            0x6173bb03e37ddddf,
140            fidl::encoding::DynamicFlags::empty(),
141        )
142    }
143
144    /// Notify the connected peer of a change in the remote line status.
145    ///
146    /// This is a no-op if there is no connected peer with identifier `id`.
147    ///
148    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
149    /// + request `channel_number` is the identifier of the RFCOMM channel whose line status changed.
150    /// + request `status` is the status of the line.
151    pub fn r#remote_line_status(
152        &self,
153        mut id: &fidl_fuchsia_bluetooth::PeerId,
154        mut channel_number: u8,
155        mut status: Status,
156    ) -> Result<(), fidl::Error> {
157        self.client.send::<RfcommTestRemoteLineStatusRequest>(
158            (id, channel_number, status),
159            0x3689603441392637,
160            fidl::encoding::DynamicFlags::empty(),
161        )
162    }
163}
164
165#[derive(Debug, Clone)]
166pub struct RfcommTestProxy {
167    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
168}
169
170impl fidl::endpoints::Proxy for RfcommTestProxy {
171    type Protocol = RfcommTestMarker;
172
173    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
174        Self::new(inner)
175    }
176
177    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
178        self.client.into_channel().map_err(|client| Self { client })
179    }
180
181    fn as_channel(&self) -> &::fidl::AsyncChannel {
182        self.client.as_channel()
183    }
184}
185
186impl RfcommTestProxy {
187    /// Create a new Proxy for fuchsia.bluetooth.rfcomm.test/RfcommTest.
188    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
189        let protocol_name = <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
190        Self { client: fidl::client::Client::new(channel, protocol_name) }
191    }
192
193    /// Get a Stream of events from the remote end of the protocol.
194    ///
195    /// # Panics
196    ///
197    /// Panics if the event stream was already taken.
198    pub fn take_event_stream(&self) -> RfcommTestEventStream {
199        RfcommTestEventStream { event_receiver: self.client.take_event_receiver() }
200    }
201
202    /// Disconnect the RFCOMM session with the connected peer.
203    ///
204    /// This is a no-op if there is no connected peer with identifier `id`.
205    ///
206    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
207    pub fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
208        RfcommTestProxyInterface::r#disconnect(self, id)
209    }
210
211    /// Notify the connected peer of a change in the remote line status.
212    ///
213    /// This is a no-op if there is no connected peer with identifier `id`.
214    ///
215    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
216    /// + request `channel_number` is the identifier of the RFCOMM channel whose line status changed.
217    /// + request `status` is the status of the line.
218    pub fn r#remote_line_status(
219        &self,
220        mut id: &fidl_fuchsia_bluetooth::PeerId,
221        mut channel_number: u8,
222        mut status: Status,
223    ) -> Result<(), fidl::Error> {
224        RfcommTestProxyInterface::r#remote_line_status(self, id, channel_number, status)
225    }
226}
227
228impl RfcommTestProxyInterface for RfcommTestProxy {
229    fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Result<(), fidl::Error> {
230        self.client.send::<RfcommTestDisconnectRequest>(
231            (id,),
232            0x6173bb03e37ddddf,
233            fidl::encoding::DynamicFlags::empty(),
234        )
235    }
236
237    fn r#remote_line_status(
238        &self,
239        mut id: &fidl_fuchsia_bluetooth::PeerId,
240        mut channel_number: u8,
241        mut status: Status,
242    ) -> Result<(), fidl::Error> {
243        self.client.send::<RfcommTestRemoteLineStatusRequest>(
244            (id, channel_number, status),
245            0x3689603441392637,
246            fidl::encoding::DynamicFlags::empty(),
247        )
248    }
249}
250
251pub struct RfcommTestEventStream {
252    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
253}
254
255impl std::marker::Unpin for RfcommTestEventStream {}
256
257impl futures::stream::FusedStream for RfcommTestEventStream {
258    fn is_terminated(&self) -> bool {
259        self.event_receiver.is_terminated()
260    }
261}
262
263impl futures::Stream for RfcommTestEventStream {
264    type Item = Result<RfcommTestEvent, fidl::Error>;
265
266    fn poll_next(
267        mut self: std::pin::Pin<&mut Self>,
268        cx: &mut std::task::Context<'_>,
269    ) -> std::task::Poll<Option<Self::Item>> {
270        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
271            &mut self.event_receiver,
272            cx
273        )?) {
274            Some(buf) => std::task::Poll::Ready(Some(RfcommTestEvent::decode(buf))),
275            None => std::task::Poll::Ready(None),
276        }
277    }
278}
279
280#[derive(Debug)]
281pub enum RfcommTestEvent {}
282
283impl RfcommTestEvent {
284    /// Decodes a message buffer as a [`RfcommTestEvent`].
285    fn decode(
286        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
287    ) -> Result<RfcommTestEvent, fidl::Error> {
288        let (bytes, _handles) = buf.split_mut();
289        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
290        debug_assert_eq!(tx_header.tx_id, 0);
291        match tx_header.ordinal {
292            _ => Err(fidl::Error::UnknownOrdinal {
293                ordinal: tx_header.ordinal,
294                protocol_name: <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295            }),
296        }
297    }
298}
299
300/// A Stream of incoming requests for fuchsia.bluetooth.rfcomm.test/RfcommTest.
301pub struct RfcommTestRequestStream {
302    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303    is_terminated: bool,
304}
305
306impl std::marker::Unpin for RfcommTestRequestStream {}
307
308impl futures::stream::FusedStream for RfcommTestRequestStream {
309    fn is_terminated(&self) -> bool {
310        self.is_terminated
311    }
312}
313
314impl fidl::endpoints::RequestStream for RfcommTestRequestStream {
315    type Protocol = RfcommTestMarker;
316    type ControlHandle = RfcommTestControlHandle;
317
318    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
319        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
320    }
321
322    fn control_handle(&self) -> Self::ControlHandle {
323        RfcommTestControlHandle { inner: self.inner.clone() }
324    }
325
326    fn into_inner(
327        self,
328    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
329    {
330        (self.inner, self.is_terminated)
331    }
332
333    fn from_inner(
334        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335        is_terminated: bool,
336    ) -> Self {
337        Self { inner, is_terminated }
338    }
339}
340
341impl futures::Stream for RfcommTestRequestStream {
342    type Item = Result<RfcommTestRequest, fidl::Error>;
343
344    fn poll_next(
345        mut self: std::pin::Pin<&mut Self>,
346        cx: &mut std::task::Context<'_>,
347    ) -> std::task::Poll<Option<Self::Item>> {
348        let this = &mut *self;
349        if this.inner.check_shutdown(cx) {
350            this.is_terminated = true;
351            return std::task::Poll::Ready(None);
352        }
353        if this.is_terminated {
354            panic!("polled RfcommTestRequestStream after completion");
355        }
356        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
357            |bytes, handles| {
358                match this.inner.channel().read_etc(cx, bytes, handles) {
359                    std::task::Poll::Ready(Ok(())) => {}
360                    std::task::Poll::Pending => return std::task::Poll::Pending,
361                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
362                        this.is_terminated = true;
363                        return std::task::Poll::Ready(None);
364                    }
365                    std::task::Poll::Ready(Err(e)) => {
366                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
367                            e.into(),
368                        ))))
369                    }
370                }
371
372                // A message has been received from the channel
373                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375                std::task::Poll::Ready(Some(match header.ordinal {
376                    0x6173bb03e37ddddf => {
377                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
378                        let mut req = fidl::new_empty!(
379                            RfcommTestDisconnectRequest,
380                            fidl::encoding::DefaultFuchsiaResourceDialect
381                        );
382                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RfcommTestDisconnectRequest>(&header, _body_bytes, handles, &mut req)?;
383                        let control_handle = RfcommTestControlHandle { inner: this.inner.clone() };
384                        Ok(RfcommTestRequest::Disconnect { id: req.id, control_handle })
385                    }
386                    0x3689603441392637 => {
387                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
388                        let mut req = fidl::new_empty!(
389                            RfcommTestRemoteLineStatusRequest,
390                            fidl::encoding::DefaultFuchsiaResourceDialect
391                        );
392                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RfcommTestRemoteLineStatusRequest>(&header, _body_bytes, handles, &mut req)?;
393                        let control_handle = RfcommTestControlHandle { inner: this.inner.clone() };
394                        Ok(RfcommTestRequest::RemoteLineStatus {
395                            id: req.id,
396                            channel_number: req.channel_number,
397                            status: req.status,
398
399                            control_handle,
400                        })
401                    }
402                    _ => Err(fidl::Error::UnknownOrdinal {
403                        ordinal: header.ordinal,
404                        protocol_name:
405                            <RfcommTestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
406                    }),
407                }))
408            },
409        )
410    }
411}
412
413/// Provides additional methods to initiate RFCOMM protocol behavior. These methods
414/// are strictly for testing.
415#[derive(Debug)]
416pub enum RfcommTestRequest {
417    /// Disconnect the RFCOMM session with the connected peer.
418    ///
419    /// This is a no-op if there is no connected peer with identifier `id`.
420    ///
421    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
422    Disconnect { id: fidl_fuchsia_bluetooth::PeerId, control_handle: RfcommTestControlHandle },
423    /// Notify the connected peer of a change in the remote line status.
424    ///
425    /// This is a no-op if there is no connected peer with identifier `id`.
426    ///
427    /// + request `id` is the unique identifier associated with the connected RFCOMM peer.
428    /// + request `channel_number` is the identifier of the RFCOMM channel whose line status changed.
429    /// + request `status` is the status of the line.
430    RemoteLineStatus {
431        id: fidl_fuchsia_bluetooth::PeerId,
432        channel_number: u8,
433        status: Status,
434        control_handle: RfcommTestControlHandle,
435    },
436}
437
438impl RfcommTestRequest {
439    #[allow(irrefutable_let_patterns)]
440    pub fn into_disconnect(
441        self,
442    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, RfcommTestControlHandle)> {
443        if let RfcommTestRequest::Disconnect { id, control_handle } = self {
444            Some((id, control_handle))
445        } else {
446            None
447        }
448    }
449
450    #[allow(irrefutable_let_patterns)]
451    pub fn into_remote_line_status(
452        self,
453    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, u8, Status, RfcommTestControlHandle)> {
454        if let RfcommTestRequest::RemoteLineStatus { id, channel_number, status, control_handle } =
455            self
456        {
457            Some((id, channel_number, status, control_handle))
458        } else {
459            None
460        }
461    }
462
463    /// Name of the method defined in FIDL
464    pub fn method_name(&self) -> &'static str {
465        match *self {
466            RfcommTestRequest::Disconnect { .. } => "disconnect",
467            RfcommTestRequest::RemoteLineStatus { .. } => "remote_line_status",
468        }
469    }
470}
471
472#[derive(Debug, Clone)]
473pub struct RfcommTestControlHandle {
474    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
475}
476
477impl fidl::endpoints::ControlHandle for RfcommTestControlHandle {
478    fn shutdown(&self) {
479        self.inner.shutdown()
480    }
481    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
482        self.inner.shutdown_with_epitaph(status)
483    }
484
485    fn is_closed(&self) -> bool {
486        self.inner.channel().is_closed()
487    }
488    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
489        self.inner.channel().on_closed()
490    }
491
492    #[cfg(target_os = "fuchsia")]
493    fn signal_peer(
494        &self,
495        clear_mask: zx::Signals,
496        set_mask: zx::Signals,
497    ) -> Result<(), zx_status::Status> {
498        use fidl::Peered;
499        self.inner.channel().signal_peer(clear_mask, set_mask)
500    }
501}
502
503impl RfcommTestControlHandle {}
504
505mod internal {
506    use super::*;
507    unsafe impl fidl::encoding::TypeMarker for Status {
508        type Owned = Self;
509
510        #[inline(always)]
511        fn inline_align(_context: fidl::encoding::Context) -> usize {
512            std::mem::align_of::<u32>()
513        }
514
515        #[inline(always)]
516        fn inline_size(_context: fidl::encoding::Context) -> usize {
517            std::mem::size_of::<u32>()
518        }
519
520        #[inline(always)]
521        fn encode_is_copy() -> bool {
522            true
523        }
524
525        #[inline(always)]
526        fn decode_is_copy() -> bool {
527            false
528        }
529    }
530
531    impl fidl::encoding::ValueTypeMarker for Status {
532        type Borrowed<'a> = Self;
533        #[inline(always)]
534        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
535            *value
536        }
537    }
538
539    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Status {
540        #[inline]
541        unsafe fn encode(
542            self,
543            encoder: &mut fidl::encoding::Encoder<'_, D>,
544            offset: usize,
545            _depth: fidl::encoding::Depth,
546        ) -> fidl::Result<()> {
547            encoder.debug_check_bounds::<Self>(offset);
548            encoder.write_num(self.into_primitive(), offset);
549            Ok(())
550        }
551    }
552
553    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
554        #[inline(always)]
555        fn new_empty() -> Self {
556            Self::Ok
557        }
558
559        #[inline]
560        unsafe fn decode(
561            &mut self,
562            decoder: &mut fidl::encoding::Decoder<'_, D>,
563            offset: usize,
564            _depth: fidl::encoding::Depth,
565        ) -> fidl::Result<()> {
566            decoder.debug_check_bounds::<Self>(offset);
567            let prim = decoder.read_num::<u32>(offset);
568
569            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
570            Ok(())
571        }
572    }
573
574    impl fidl::encoding::ValueTypeMarker for RfcommTestDisconnectRequest {
575        type Borrowed<'a> = &'a Self;
576        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
577            value
578        }
579    }
580
581    unsafe impl fidl::encoding::TypeMarker for RfcommTestDisconnectRequest {
582        type Owned = Self;
583
584        #[inline(always)]
585        fn inline_align(_context: fidl::encoding::Context) -> usize {
586            8
587        }
588
589        #[inline(always)]
590        fn inline_size(_context: fidl::encoding::Context) -> usize {
591            8
592        }
593    }
594
595    unsafe impl<D: fidl::encoding::ResourceDialect>
596        fidl::encoding::Encode<RfcommTestDisconnectRequest, D> for &RfcommTestDisconnectRequest
597    {
598        #[inline]
599        unsafe fn encode(
600            self,
601            encoder: &mut fidl::encoding::Encoder<'_, D>,
602            offset: usize,
603            _depth: fidl::encoding::Depth,
604        ) -> fidl::Result<()> {
605            encoder.debug_check_bounds::<RfcommTestDisconnectRequest>(offset);
606            // Delegate to tuple encoding.
607            fidl::encoding::Encode::<RfcommTestDisconnectRequest, D>::encode(
608                (<fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(
609                    &self.id,
610                ),),
611                encoder,
612                offset,
613                _depth,
614            )
615        }
616    }
617    unsafe impl<
618            D: fidl::encoding::ResourceDialect,
619            T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth::PeerId, D>,
620        > fidl::encoding::Encode<RfcommTestDisconnectRequest, D> for (T0,)
621    {
622        #[inline]
623        unsafe fn encode(
624            self,
625            encoder: &mut fidl::encoding::Encoder<'_, D>,
626            offset: usize,
627            depth: fidl::encoding::Depth,
628        ) -> fidl::Result<()> {
629            encoder.debug_check_bounds::<RfcommTestDisconnectRequest>(offset);
630            // Zero out padding regions. There's no need to apply masks
631            // because the unmasked parts will be overwritten by fields.
632            // Write the fields.
633            self.0.encode(encoder, offset + 0, depth)?;
634            Ok(())
635        }
636    }
637
638    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
639        for RfcommTestDisconnectRequest
640    {
641        #[inline(always)]
642        fn new_empty() -> Self {
643            Self { id: fidl::new_empty!(fidl_fuchsia_bluetooth::PeerId, D) }
644        }
645
646        #[inline]
647        unsafe fn decode(
648            &mut self,
649            decoder: &mut fidl::encoding::Decoder<'_, D>,
650            offset: usize,
651            _depth: fidl::encoding::Depth,
652        ) -> fidl::Result<()> {
653            decoder.debug_check_bounds::<Self>(offset);
654            // Verify that padding bytes are zero.
655            fidl::decode!(
656                fidl_fuchsia_bluetooth::PeerId,
657                D,
658                &mut self.id,
659                decoder,
660                offset + 0,
661                _depth
662            )?;
663            Ok(())
664        }
665    }
666
667    impl fidl::encoding::ValueTypeMarker for RfcommTestRemoteLineStatusRequest {
668        type Borrowed<'a> = &'a Self;
669        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
670            value
671        }
672    }
673
674    unsafe impl fidl::encoding::TypeMarker for RfcommTestRemoteLineStatusRequest {
675        type Owned = Self;
676
677        #[inline(always)]
678        fn inline_align(_context: fidl::encoding::Context) -> usize {
679            8
680        }
681
682        #[inline(always)]
683        fn inline_size(_context: fidl::encoding::Context) -> usize {
684            16
685        }
686    }
687
688    unsafe impl<D: fidl::encoding::ResourceDialect>
689        fidl::encoding::Encode<RfcommTestRemoteLineStatusRequest, D>
690        for &RfcommTestRemoteLineStatusRequest
691    {
692        #[inline]
693        unsafe fn encode(
694            self,
695            encoder: &mut fidl::encoding::Encoder<'_, D>,
696            offset: usize,
697            _depth: fidl::encoding::Depth,
698        ) -> fidl::Result<()> {
699            encoder.debug_check_bounds::<RfcommTestRemoteLineStatusRequest>(offset);
700            // Delegate to tuple encoding.
701            fidl::encoding::Encode::<RfcommTestRemoteLineStatusRequest, D>::encode(
702                (
703                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(
704                        &self.id,
705                    ),
706                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.channel_number),
707                    <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
708                ),
709                encoder,
710                offset,
711                _depth,
712            )
713        }
714    }
715    unsafe impl<
716            D: fidl::encoding::ResourceDialect,
717            T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth::PeerId, D>,
718            T1: fidl::encoding::Encode<u8, D>,
719            T2: fidl::encoding::Encode<Status, D>,
720        > fidl::encoding::Encode<RfcommTestRemoteLineStatusRequest, D> for (T0, T1, T2)
721    {
722        #[inline]
723        unsafe fn encode(
724            self,
725            encoder: &mut fidl::encoding::Encoder<'_, D>,
726            offset: usize,
727            depth: fidl::encoding::Depth,
728        ) -> fidl::Result<()> {
729            encoder.debug_check_bounds::<RfcommTestRemoteLineStatusRequest>(offset);
730            // Zero out padding regions. There's no need to apply masks
731            // because the unmasked parts will be overwritten by fields.
732            unsafe {
733                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
734                (ptr as *mut u64).write_unaligned(0);
735            }
736            // Write the fields.
737            self.0.encode(encoder, offset + 0, depth)?;
738            self.1.encode(encoder, offset + 8, depth)?;
739            self.2.encode(encoder, offset + 12, depth)?;
740            Ok(())
741        }
742    }
743
744    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
745        for RfcommTestRemoteLineStatusRequest
746    {
747        #[inline(always)]
748        fn new_empty() -> Self {
749            Self {
750                id: fidl::new_empty!(fidl_fuchsia_bluetooth::PeerId, D),
751                channel_number: fidl::new_empty!(u8, D),
752                status: fidl::new_empty!(Status, D),
753            }
754        }
755
756        #[inline]
757        unsafe fn decode(
758            &mut self,
759            decoder: &mut fidl::encoding::Decoder<'_, D>,
760            offset: usize,
761            _depth: fidl::encoding::Depth,
762        ) -> fidl::Result<()> {
763            decoder.debug_check_bounds::<Self>(offset);
764            // Verify that padding bytes are zero.
765            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
766            let padval = unsafe { (ptr as *const u64).read_unaligned() };
767            let mask = 0xffffff00u64;
768            let maskedval = padval & mask;
769            if maskedval != 0 {
770                return Err(fidl::Error::NonZeroPadding {
771                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
772                });
773            }
774            fidl::decode!(
775                fidl_fuchsia_bluetooth::PeerId,
776                D,
777                &mut self.id,
778                decoder,
779                offset + 0,
780                _depth
781            )?;
782            fidl::decode!(u8, D, &mut self.channel_number, decoder, offset + 8, _depth)?;
783            fidl::decode!(Status, D, &mut self.status, decoder, offset + 12, _depth)?;
784            Ok(())
785        }
786    }
787}