fidl_fuchsia_lowpan_bootstrap/
fidl_fuchsia_lowpan_bootstrap.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 _};
10pub use fidl_fuchsia_lowpan_bootstrap__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ThreadImportSettingsRequest {
16    pub thread_settings_json: fidl_fuchsia_mem::Buffer,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ThreadImportSettingsRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct ThreadMarker;
26
27impl fidl::endpoints::ProtocolMarker for ThreadMarker {
28    type Proxy = ThreadProxy;
29    type RequestStream = ThreadRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = ThreadSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "fuchsia.lowpan.bootstrap.Thread";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for ThreadMarker {}
36
37pub trait ThreadProxyInterface: Send + Sync {
38    type ImportSettingsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
39    fn r#import_settings(
40        &self,
41        thread_settings_json: fidl_fuchsia_mem::Buffer,
42    ) -> Self::ImportSettingsResponseFut;
43}
44#[derive(Debug)]
45#[cfg(target_os = "fuchsia")]
46pub struct ThreadSynchronousProxy {
47    client: fidl::client::sync::Client,
48}
49
50#[cfg(target_os = "fuchsia")]
51impl fidl::endpoints::SynchronousProxy for ThreadSynchronousProxy {
52    type Proxy = ThreadProxy;
53    type Protocol = ThreadMarker;
54
55    fn from_channel(inner: fidl::Channel) -> Self {
56        Self::new(inner)
57    }
58
59    fn into_channel(self) -> fidl::Channel {
60        self.client.into_channel()
61    }
62
63    fn as_channel(&self) -> &fidl::Channel {
64        self.client.as_channel()
65    }
66}
67
68#[cfg(target_os = "fuchsia")]
69impl ThreadSynchronousProxy {
70    pub fn new(channel: fidl::Channel) -> Self {
71        let protocol_name = <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
72        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
73    }
74
75    pub fn into_channel(self) -> fidl::Channel {
76        self.client.into_channel()
77    }
78
79    /// Waits until an event arrives and returns it. It is safe for other
80    /// threads to make concurrent requests while waiting for an event.
81    pub fn wait_for_event(
82        &self,
83        deadline: zx::MonotonicInstant,
84    ) -> Result<ThreadEvent, fidl::Error> {
85        ThreadEvent::decode(self.client.wait_for_event(deadline)?)
86    }
87
88    /// Import a json data file containing the Thread configuration as created by
89    /// [ThreadConfigManager]
90    /// (https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/src/connectivity/openthread/third_party/openthread/platform/thread_config_manager.cc).
91    /// The json format is:
92    /// {
93    ///   "key1" : [ base64_encoded_string1_1, base64_encoded_string1_2, ... ],
94    ///   "key2" : [ base64_encoded_string2_1, base64_encoded_string2_2, ... ],
95    ///   ...
96    /// }
97    /// where key1, key2 etc are decimal representation of uint16_t values.
98    /// base64_encoded_strings are created from a vector of uint16_t values.
99    /// This json format is equivalent to thread settings file in POSIX which
100    /// is binary file having the information encoded as:
101    /// 2 bytes of key1, 2 bytes of value_len1, 'value_len1' bytes of 'value1',
102    /// 2 bytes of key2, 2 bytes of value_len2, 'value_len2' bytes of 'value2',
103    /// 2 bytes of key1, 2 bytes of value_len3, 'value_len3' bytes of 'value3',
104    /// 2 bytes of key2, 2 bytes of value_len4, 'value_len4' bytes of 'value4'.
105    /// The POSIX binary file is simply a sequence of bytes and allows for
106    /// duplicate keys. This is converted to json format above with values
107    /// transformed as:
108    /// base64_encoded_string1_1 = base64_encode(value1[0:value_len1])
109    /// base64_encoded_string1_2 = base64_encode(value2[0:value_len2])
110    /// base64_encoded_string2_1 = base64_encode(value3[0:value_len3])
111    /// base64_encoded_string2_2 = base64_encode(value4[0:value_len4])
112    /// Keys are simply decimal representation of uint16_t keys in double quotes.
113    ///
114    /// Settings are guaranteed to have been persisted upon successful
115    /// completion of this call. The channel will be closed if importing
116    /// settings fail.
117    pub fn r#import_settings(
118        &self,
119        mut thread_settings_json: fidl_fuchsia_mem::Buffer,
120        ___deadline: zx::MonotonicInstant,
121    ) -> Result<(), fidl::Error> {
122        let _response =
123            self.client.send_query::<ThreadImportSettingsRequest, fidl::encoding::EmptyPayload>(
124                (&mut thread_settings_json,),
125                0x5ac61a4908e85bbd,
126                fidl::encoding::DynamicFlags::empty(),
127                ___deadline,
128            )?;
129        Ok(_response)
130    }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl From<ThreadSynchronousProxy> for zx::Handle {
135    fn from(value: ThreadSynchronousProxy) -> Self {
136        value.into_channel().into()
137    }
138}
139
140#[cfg(target_os = "fuchsia")]
141impl From<fidl::Channel> for ThreadSynchronousProxy {
142    fn from(value: fidl::Channel) -> Self {
143        Self::new(value)
144    }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl fidl::endpoints::FromClient for ThreadSynchronousProxy {
149    type Protocol = ThreadMarker;
150
151    fn from_client(value: fidl::endpoints::ClientEnd<ThreadMarker>) -> Self {
152        Self::new(value.into_channel())
153    }
154}
155
156#[derive(Debug, Clone)]
157pub struct ThreadProxy {
158    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
159}
160
161impl fidl::endpoints::Proxy for ThreadProxy {
162    type Protocol = ThreadMarker;
163
164    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
165        Self::new(inner)
166    }
167
168    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
169        self.client.into_channel().map_err(|client| Self { client })
170    }
171
172    fn as_channel(&self) -> &::fidl::AsyncChannel {
173        self.client.as_channel()
174    }
175}
176
177impl ThreadProxy {
178    /// Create a new Proxy for fuchsia.lowpan.bootstrap/Thread.
179    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
180        let protocol_name = <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
181        Self { client: fidl::client::Client::new(channel, protocol_name) }
182    }
183
184    /// Get a Stream of events from the remote end of the protocol.
185    ///
186    /// # Panics
187    ///
188    /// Panics if the event stream was already taken.
189    pub fn take_event_stream(&self) -> ThreadEventStream {
190        ThreadEventStream { event_receiver: self.client.take_event_receiver() }
191    }
192
193    /// Import a json data file containing the Thread configuration as created by
194    /// [ThreadConfigManager]
195    /// (https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/src/connectivity/openthread/third_party/openthread/platform/thread_config_manager.cc).
196    /// The json format is:
197    /// {
198    ///   "key1" : [ base64_encoded_string1_1, base64_encoded_string1_2, ... ],
199    ///   "key2" : [ base64_encoded_string2_1, base64_encoded_string2_2, ... ],
200    ///   ...
201    /// }
202    /// where key1, key2 etc are decimal representation of uint16_t values.
203    /// base64_encoded_strings are created from a vector of uint16_t values.
204    /// This json format is equivalent to thread settings file in POSIX which
205    /// is binary file having the information encoded as:
206    /// 2 bytes of key1, 2 bytes of value_len1, 'value_len1' bytes of 'value1',
207    /// 2 bytes of key2, 2 bytes of value_len2, 'value_len2' bytes of 'value2',
208    /// 2 bytes of key1, 2 bytes of value_len3, 'value_len3' bytes of 'value3',
209    /// 2 bytes of key2, 2 bytes of value_len4, 'value_len4' bytes of 'value4'.
210    /// The POSIX binary file is simply a sequence of bytes and allows for
211    /// duplicate keys. This is converted to json format above with values
212    /// transformed as:
213    /// base64_encoded_string1_1 = base64_encode(value1[0:value_len1])
214    /// base64_encoded_string1_2 = base64_encode(value2[0:value_len2])
215    /// base64_encoded_string2_1 = base64_encode(value3[0:value_len3])
216    /// base64_encoded_string2_2 = base64_encode(value4[0:value_len4])
217    /// Keys are simply decimal representation of uint16_t keys in double quotes.
218    ///
219    /// Settings are guaranteed to have been persisted upon successful
220    /// completion of this call. The channel will be closed if importing
221    /// settings fail.
222    pub fn r#import_settings(
223        &self,
224        mut thread_settings_json: fidl_fuchsia_mem::Buffer,
225    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
226        ThreadProxyInterface::r#import_settings(self, thread_settings_json)
227    }
228}
229
230impl ThreadProxyInterface for ThreadProxy {
231    type ImportSettingsResponseFut =
232        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
233    fn r#import_settings(
234        &self,
235        mut thread_settings_json: fidl_fuchsia_mem::Buffer,
236    ) -> Self::ImportSettingsResponseFut {
237        fn _decode(
238            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
239        ) -> Result<(), fidl::Error> {
240            let _response = fidl::client::decode_transaction_body::<
241                fidl::encoding::EmptyPayload,
242                fidl::encoding::DefaultFuchsiaResourceDialect,
243                0x5ac61a4908e85bbd,
244            >(_buf?)?;
245            Ok(_response)
246        }
247        self.client.send_query_and_decode::<ThreadImportSettingsRequest, ()>(
248            (&mut thread_settings_json,),
249            0x5ac61a4908e85bbd,
250            fidl::encoding::DynamicFlags::empty(),
251            _decode,
252        )
253    }
254}
255
256pub struct ThreadEventStream {
257    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
258}
259
260impl std::marker::Unpin for ThreadEventStream {}
261
262impl futures::stream::FusedStream for ThreadEventStream {
263    fn is_terminated(&self) -> bool {
264        self.event_receiver.is_terminated()
265    }
266}
267
268impl futures::Stream for ThreadEventStream {
269    type Item = Result<ThreadEvent, fidl::Error>;
270
271    fn poll_next(
272        mut self: std::pin::Pin<&mut Self>,
273        cx: &mut std::task::Context<'_>,
274    ) -> std::task::Poll<Option<Self::Item>> {
275        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
276            &mut self.event_receiver,
277            cx
278        )?) {
279            Some(buf) => std::task::Poll::Ready(Some(ThreadEvent::decode(buf))),
280            None => std::task::Poll::Ready(None),
281        }
282    }
283}
284
285#[derive(Debug)]
286pub enum ThreadEvent {}
287
288impl ThreadEvent {
289    /// Decodes a message buffer as a [`ThreadEvent`].
290    fn decode(
291        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
292    ) -> Result<ThreadEvent, fidl::Error> {
293        let (bytes, _handles) = buf.split_mut();
294        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
295        debug_assert_eq!(tx_header.tx_id, 0);
296        match tx_header.ordinal {
297            _ => Err(fidl::Error::UnknownOrdinal {
298                ordinal: tx_header.ordinal,
299                protocol_name: <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
300            }),
301        }
302    }
303}
304
305/// A Stream of incoming requests for fuchsia.lowpan.bootstrap/Thread.
306pub struct ThreadRequestStream {
307    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
308    is_terminated: bool,
309}
310
311impl std::marker::Unpin for ThreadRequestStream {}
312
313impl futures::stream::FusedStream for ThreadRequestStream {
314    fn is_terminated(&self) -> bool {
315        self.is_terminated
316    }
317}
318
319impl fidl::endpoints::RequestStream for ThreadRequestStream {
320    type Protocol = ThreadMarker;
321    type ControlHandle = ThreadControlHandle;
322
323    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
324        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
325    }
326
327    fn control_handle(&self) -> Self::ControlHandle {
328        ThreadControlHandle { inner: self.inner.clone() }
329    }
330
331    fn into_inner(
332        self,
333    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
334    {
335        (self.inner, self.is_terminated)
336    }
337
338    fn from_inner(
339        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
340        is_terminated: bool,
341    ) -> Self {
342        Self { inner, is_terminated }
343    }
344}
345
346impl futures::Stream for ThreadRequestStream {
347    type Item = Result<ThreadRequest, fidl::Error>;
348
349    fn poll_next(
350        mut self: std::pin::Pin<&mut Self>,
351        cx: &mut std::task::Context<'_>,
352    ) -> std::task::Poll<Option<Self::Item>> {
353        let this = &mut *self;
354        if this.inner.check_shutdown(cx) {
355            this.is_terminated = true;
356            return std::task::Poll::Ready(None);
357        }
358        if this.is_terminated {
359            panic!("polled ThreadRequestStream after completion");
360        }
361        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
362            |bytes, handles| {
363                match this.inner.channel().read_etc(cx, bytes, handles) {
364                    std::task::Poll::Ready(Ok(())) => {}
365                    std::task::Poll::Pending => return std::task::Poll::Pending,
366                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
367                        this.is_terminated = true;
368                        return std::task::Poll::Ready(None);
369                    }
370                    std::task::Poll::Ready(Err(e)) => {
371                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
372                            e.into(),
373                        ))))
374                    }
375                }
376
377                // A message has been received from the channel
378                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
379
380                std::task::Poll::Ready(Some(match header.ordinal {
381                    0x5ac61a4908e85bbd => {
382                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
383                        let mut req = fidl::new_empty!(
384                            ThreadImportSettingsRequest,
385                            fidl::encoding::DefaultFuchsiaResourceDialect
386                        );
387                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ThreadImportSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
388                        let control_handle = ThreadControlHandle { inner: this.inner.clone() };
389                        Ok(ThreadRequest::ImportSettings {
390                            thread_settings_json: req.thread_settings_json,
391
392                            responder: ThreadImportSettingsResponder {
393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
394                                tx_id: header.tx_id,
395                            },
396                        })
397                    }
398                    _ => Err(fidl::Error::UnknownOrdinal {
399                        ordinal: header.ordinal,
400                        protocol_name:
401                            <ThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
402                    }),
403                }))
404            },
405        )
406    }
407}
408
409/// Protocol to allow components to provide initial configuration data derived from
410/// an existing Thread implementation to ensure continuity of the Thread network and
411/// other thread settings.
412#[derive(Debug)]
413pub enum ThreadRequest {
414    /// Import a json data file containing the Thread configuration as created by
415    /// [ThreadConfigManager]
416    /// (https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/src/connectivity/openthread/third_party/openthread/platform/thread_config_manager.cc).
417    /// The json format is:
418    /// {
419    ///   "key1" : [ base64_encoded_string1_1, base64_encoded_string1_2, ... ],
420    ///   "key2" : [ base64_encoded_string2_1, base64_encoded_string2_2, ... ],
421    ///   ...
422    /// }
423    /// where key1, key2 etc are decimal representation of uint16_t values.
424    /// base64_encoded_strings are created from a vector of uint16_t values.
425    /// This json format is equivalent to thread settings file in POSIX which
426    /// is binary file having the information encoded as:
427    /// 2 bytes of key1, 2 bytes of value_len1, 'value_len1' bytes of 'value1',
428    /// 2 bytes of key2, 2 bytes of value_len2, 'value_len2' bytes of 'value2',
429    /// 2 bytes of key1, 2 bytes of value_len3, 'value_len3' bytes of 'value3',
430    /// 2 bytes of key2, 2 bytes of value_len4, 'value_len4' bytes of 'value4'.
431    /// The POSIX binary file is simply a sequence of bytes and allows for
432    /// duplicate keys. This is converted to json format above with values
433    /// transformed as:
434    /// base64_encoded_string1_1 = base64_encode(value1[0:value_len1])
435    /// base64_encoded_string1_2 = base64_encode(value2[0:value_len2])
436    /// base64_encoded_string2_1 = base64_encode(value3[0:value_len3])
437    /// base64_encoded_string2_2 = base64_encode(value4[0:value_len4])
438    /// Keys are simply decimal representation of uint16_t keys in double quotes.
439    ///
440    /// Settings are guaranteed to have been persisted upon successful
441    /// completion of this call. The channel will be closed if importing
442    /// settings fail.
443    ImportSettings {
444        thread_settings_json: fidl_fuchsia_mem::Buffer,
445        responder: ThreadImportSettingsResponder,
446    },
447}
448
449impl ThreadRequest {
450    #[allow(irrefutable_let_patterns)]
451    pub fn into_import_settings(
452        self,
453    ) -> Option<(fidl_fuchsia_mem::Buffer, ThreadImportSettingsResponder)> {
454        if let ThreadRequest::ImportSettings { thread_settings_json, responder } = self {
455            Some((thread_settings_json, responder))
456        } else {
457            None
458        }
459    }
460
461    /// Name of the method defined in FIDL
462    pub fn method_name(&self) -> &'static str {
463        match *self {
464            ThreadRequest::ImportSettings { .. } => "import_settings",
465        }
466    }
467}
468
469#[derive(Debug, Clone)]
470pub struct ThreadControlHandle {
471    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
472}
473
474impl fidl::endpoints::ControlHandle for ThreadControlHandle {
475    fn shutdown(&self) {
476        self.inner.shutdown()
477    }
478    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
479        self.inner.shutdown_with_epitaph(status)
480    }
481
482    fn is_closed(&self) -> bool {
483        self.inner.channel().is_closed()
484    }
485    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
486        self.inner.channel().on_closed()
487    }
488
489    #[cfg(target_os = "fuchsia")]
490    fn signal_peer(
491        &self,
492        clear_mask: zx::Signals,
493        set_mask: zx::Signals,
494    ) -> Result<(), zx_status::Status> {
495        use fidl::Peered;
496        self.inner.channel().signal_peer(clear_mask, set_mask)
497    }
498}
499
500impl ThreadControlHandle {}
501
502#[must_use = "FIDL methods require a response to be sent"]
503#[derive(Debug)]
504pub struct ThreadImportSettingsResponder {
505    control_handle: std::mem::ManuallyDrop<ThreadControlHandle>,
506    tx_id: u32,
507}
508
509/// Set the the channel to be shutdown (see [`ThreadControlHandle::shutdown`])
510/// if the responder is dropped without sending a response, so that the client
511/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
512impl std::ops::Drop for ThreadImportSettingsResponder {
513    fn drop(&mut self) {
514        self.control_handle.shutdown();
515        // Safety: drops once, never accessed again
516        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
517    }
518}
519
520impl fidl::endpoints::Responder for ThreadImportSettingsResponder {
521    type ControlHandle = ThreadControlHandle;
522
523    fn control_handle(&self) -> &ThreadControlHandle {
524        &self.control_handle
525    }
526
527    fn drop_without_shutdown(mut self) {
528        // Safety: drops once, never accessed again due to mem::forget
529        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
530        // Prevent Drop from running (which would shut down the channel)
531        std::mem::forget(self);
532    }
533}
534
535impl ThreadImportSettingsResponder {
536    /// Sends a response to the FIDL transaction.
537    ///
538    /// Sets the channel to shutdown if an error occurs.
539    pub fn send(self) -> Result<(), fidl::Error> {
540        let _result = self.send_raw();
541        if _result.is_err() {
542            self.control_handle.shutdown();
543        }
544        self.drop_without_shutdown();
545        _result
546    }
547
548    /// Similar to "send" but does not shutdown the channel if an error occurs.
549    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
550        let _result = self.send_raw();
551        self.drop_without_shutdown();
552        _result
553    }
554
555    fn send_raw(&self) -> Result<(), fidl::Error> {
556        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
557            (),
558            self.tx_id,
559            0x5ac61a4908e85bbd,
560            fidl::encoding::DynamicFlags::empty(),
561        )
562    }
563}
564
565mod internal {
566    use super::*;
567
568    impl fidl::encoding::ResourceTypeMarker for ThreadImportSettingsRequest {
569        type Borrowed<'a> = &'a mut Self;
570        fn take_or_borrow<'a>(
571            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
572        ) -> Self::Borrowed<'a> {
573            value
574        }
575    }
576
577    unsafe impl fidl::encoding::TypeMarker for ThreadImportSettingsRequest {
578        type Owned = Self;
579
580        #[inline(always)]
581        fn inline_align(_context: fidl::encoding::Context) -> usize {
582            8
583        }
584
585        #[inline(always)]
586        fn inline_size(_context: fidl::encoding::Context) -> usize {
587            16
588        }
589    }
590
591    unsafe impl
592        fidl::encoding::Encode<
593            ThreadImportSettingsRequest,
594            fidl::encoding::DefaultFuchsiaResourceDialect,
595        > for &mut ThreadImportSettingsRequest
596    {
597        #[inline]
598        unsafe fn encode(
599            self,
600            encoder: &mut fidl::encoding::Encoder<
601                '_,
602                fidl::encoding::DefaultFuchsiaResourceDialect,
603            >,
604            offset: usize,
605            _depth: fidl::encoding::Depth,
606        ) -> fidl::Result<()> {
607            encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
608            // Delegate to tuple encoding.
609            fidl::encoding::Encode::<
610                ThreadImportSettingsRequest,
611                fidl::encoding::DefaultFuchsiaResourceDialect,
612            >::encode(
613                (<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
614                    &mut self.thread_settings_json,
615                ),),
616                encoder,
617                offset,
618                _depth,
619            )
620        }
621    }
622    unsafe impl<
623            T0: fidl::encoding::Encode<
624                fidl_fuchsia_mem::Buffer,
625                fidl::encoding::DefaultFuchsiaResourceDialect,
626            >,
627        >
628        fidl::encoding::Encode<
629            ThreadImportSettingsRequest,
630            fidl::encoding::DefaultFuchsiaResourceDialect,
631        > for (T0,)
632    {
633        #[inline]
634        unsafe fn encode(
635            self,
636            encoder: &mut fidl::encoding::Encoder<
637                '_,
638                fidl::encoding::DefaultFuchsiaResourceDialect,
639            >,
640            offset: usize,
641            depth: fidl::encoding::Depth,
642        ) -> fidl::Result<()> {
643            encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
644            // Zero out padding regions. There's no need to apply masks
645            // because the unmasked parts will be overwritten by fields.
646            // Write the fields.
647            self.0.encode(encoder, offset + 0, depth)?;
648            Ok(())
649        }
650    }
651
652    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
653        for ThreadImportSettingsRequest
654    {
655        #[inline(always)]
656        fn new_empty() -> Self {
657            Self {
658                thread_settings_json: fidl::new_empty!(
659                    fidl_fuchsia_mem::Buffer,
660                    fidl::encoding::DefaultFuchsiaResourceDialect
661                ),
662            }
663        }
664
665        #[inline]
666        unsafe fn decode(
667            &mut self,
668            decoder: &mut fidl::encoding::Decoder<
669                '_,
670                fidl::encoding::DefaultFuchsiaResourceDialect,
671            >,
672            offset: usize,
673            _depth: fidl::encoding::Depth,
674        ) -> fidl::Result<()> {
675            decoder.debug_check_bounds::<Self>(offset);
676            // Verify that padding bytes are zero.
677            fidl::decode!(
678                fidl_fuchsia_mem::Buffer,
679                fidl::encoding::DefaultFuchsiaResourceDialect,
680                &mut self.thread_settings_json,
681                decoder,
682                offset + 0,
683                _depth
684            )?;
685            Ok(())
686        }
687    }
688}