Skip to main content

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        Self { client: fidl::client::sync::Client::new(channel) }
72    }
73
74    pub fn into_channel(self) -> fidl::Channel {
75        self.client.into_channel()
76    }
77
78    /// Waits until an event arrives and returns it. It is safe for other
79    /// threads to make concurrent requests while waiting for an event.
80    pub fn wait_for_event(
81        &self,
82        deadline: zx::MonotonicInstant,
83    ) -> Result<ThreadEvent, fidl::Error> {
84        ThreadEvent::decode(self.client.wait_for_event::<ThreadMarker>(deadline)?)
85    }
86
87    /// Import a json data file containing the Thread configuration as created by
88    /// [ThreadConfigManager]
89    /// (https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/src/connectivity/openthread/third_party/openthread/platform/thread_config_manager.cc).
90    /// The json format is:
91    /// {
92    ///   "key1" : [ base64_encoded_string1_1, base64_encoded_string1_2, ... ],
93    ///   "key2" : [ base64_encoded_string2_1, base64_encoded_string2_2, ... ],
94    ///   ...
95    /// }
96    /// where key1, key2 etc are decimal representation of uint16_t values.
97    /// base64_encoded_strings are created from a vector of uint16_t values.
98    /// This json format is equivalent to thread settings file in POSIX which
99    /// is binary file having the information encoded as:
100    /// 2 bytes of key1, 2 bytes of value_len1, 'value_len1' bytes of 'value1',
101    /// 2 bytes of key2, 2 bytes of value_len2, 'value_len2' bytes of 'value2',
102    /// 2 bytes of key1, 2 bytes of value_len3, 'value_len3' bytes of 'value3',
103    /// 2 bytes of key2, 2 bytes of value_len4, 'value_len4' bytes of 'value4'.
104    /// The POSIX binary file is simply a sequence of bytes and allows for
105    /// duplicate keys. This is converted to json format above with values
106    /// transformed as:
107    /// base64_encoded_string1_1 = base64_encode(value1[0:value_len1])
108    /// base64_encoded_string1_2 = base64_encode(value2[0:value_len2])
109    /// base64_encoded_string2_1 = base64_encode(value3[0:value_len3])
110    /// base64_encoded_string2_2 = base64_encode(value4[0:value_len4])
111    /// Keys are simply decimal representation of uint16_t keys in double quotes.
112    ///
113    /// Settings are guaranteed to have been persisted upon successful
114    /// completion of this call. The channel will be closed if importing
115    /// settings fail.
116    pub fn r#import_settings(
117        &self,
118        mut thread_settings_json: fidl_fuchsia_mem::Buffer,
119        ___deadline: zx::MonotonicInstant,
120    ) -> Result<(), fidl::Error> {
121        let _response = self
122            .client
123            .send_query::<ThreadImportSettingsRequest, fidl::encoding::EmptyPayload, ThreadMarker>(
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::NullableHandle {
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 ThreadControlHandle {
475    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
476        self.inner.shutdown_with_epitaph(status.into())
477    }
478}
479
480impl fidl::endpoints::ControlHandle for ThreadControlHandle {
481    fn shutdown(&self) {
482        self.inner.shutdown()
483    }
484
485    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
486        self.inner.shutdown_with_epitaph(status)
487    }
488
489    fn is_closed(&self) -> bool {
490        self.inner.channel().is_closed()
491    }
492    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
493        self.inner.channel().on_closed()
494    }
495
496    #[cfg(target_os = "fuchsia")]
497    fn signal_peer(
498        &self,
499        clear_mask: zx::Signals,
500        set_mask: zx::Signals,
501    ) -> Result<(), zx_status::Status> {
502        use fidl::Peered;
503        self.inner.channel().signal_peer(clear_mask, set_mask)
504    }
505}
506
507impl ThreadControlHandle {}
508
509#[must_use = "FIDL methods require a response to be sent"]
510#[derive(Debug)]
511pub struct ThreadImportSettingsResponder {
512    control_handle: std::mem::ManuallyDrop<ThreadControlHandle>,
513    tx_id: u32,
514}
515
516/// Set the the channel to be shutdown (see [`ThreadControlHandle::shutdown`])
517/// if the responder is dropped without sending a response, so that the client
518/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
519impl std::ops::Drop for ThreadImportSettingsResponder {
520    fn drop(&mut self) {
521        self.control_handle.shutdown();
522        // Safety: drops once, never accessed again
523        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
524    }
525}
526
527impl fidl::endpoints::Responder for ThreadImportSettingsResponder {
528    type ControlHandle = ThreadControlHandle;
529
530    fn control_handle(&self) -> &ThreadControlHandle {
531        &self.control_handle
532    }
533
534    fn drop_without_shutdown(mut self) {
535        // Safety: drops once, never accessed again due to mem::forget
536        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
537        // Prevent Drop from running (which would shut down the channel)
538        std::mem::forget(self);
539    }
540}
541
542impl ThreadImportSettingsResponder {
543    /// Sends a response to the FIDL transaction.
544    ///
545    /// Sets the channel to shutdown if an error occurs.
546    pub fn send(self) -> Result<(), fidl::Error> {
547        let _result = self.send_raw();
548        if _result.is_err() {
549            self.control_handle.shutdown();
550        }
551        self.drop_without_shutdown();
552        _result
553    }
554
555    /// Similar to "send" but does not shutdown the channel if an error occurs.
556    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
557        let _result = self.send_raw();
558        self.drop_without_shutdown();
559        _result
560    }
561
562    fn send_raw(&self) -> Result<(), fidl::Error> {
563        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
564            (),
565            self.tx_id,
566            0x5ac61a4908e85bbd,
567            fidl::encoding::DynamicFlags::empty(),
568        )
569    }
570}
571
572mod internal {
573    use super::*;
574
575    impl fidl::encoding::ResourceTypeMarker for ThreadImportSettingsRequest {
576        type Borrowed<'a> = &'a mut Self;
577        fn take_or_borrow<'a>(
578            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
579        ) -> Self::Borrowed<'a> {
580            value
581        }
582    }
583
584    unsafe impl fidl::encoding::TypeMarker for ThreadImportSettingsRequest {
585        type Owned = Self;
586
587        #[inline(always)]
588        fn inline_align(_context: fidl::encoding::Context) -> usize {
589            8
590        }
591
592        #[inline(always)]
593        fn inline_size(_context: fidl::encoding::Context) -> usize {
594            16
595        }
596    }
597
598    unsafe impl
599        fidl::encoding::Encode<
600            ThreadImportSettingsRequest,
601            fidl::encoding::DefaultFuchsiaResourceDialect,
602        > for &mut ThreadImportSettingsRequest
603    {
604        #[inline]
605        unsafe fn encode(
606            self,
607            encoder: &mut fidl::encoding::Encoder<
608                '_,
609                fidl::encoding::DefaultFuchsiaResourceDialect,
610            >,
611            offset: usize,
612            _depth: fidl::encoding::Depth,
613        ) -> fidl::Result<()> {
614            encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
615            // Delegate to tuple encoding.
616            fidl::encoding::Encode::<
617                ThreadImportSettingsRequest,
618                fidl::encoding::DefaultFuchsiaResourceDialect,
619            >::encode(
620                (<fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
621                    &mut self.thread_settings_json,
622                ),),
623                encoder,
624                offset,
625                _depth,
626            )
627        }
628    }
629    unsafe impl<
630        T0: fidl::encoding::Encode<
631                fidl_fuchsia_mem::Buffer,
632                fidl::encoding::DefaultFuchsiaResourceDialect,
633            >,
634    >
635        fidl::encoding::Encode<
636            ThreadImportSettingsRequest,
637            fidl::encoding::DefaultFuchsiaResourceDialect,
638        > for (T0,)
639    {
640        #[inline]
641        unsafe fn encode(
642            self,
643            encoder: &mut fidl::encoding::Encoder<
644                '_,
645                fidl::encoding::DefaultFuchsiaResourceDialect,
646            >,
647            offset: usize,
648            depth: fidl::encoding::Depth,
649        ) -> fidl::Result<()> {
650            encoder.debug_check_bounds::<ThreadImportSettingsRequest>(offset);
651            // Zero out padding regions. There's no need to apply masks
652            // because the unmasked parts will be overwritten by fields.
653            // Write the fields.
654            self.0.encode(encoder, offset + 0, depth)?;
655            Ok(())
656        }
657    }
658
659    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
660        for ThreadImportSettingsRequest
661    {
662        #[inline(always)]
663        fn new_empty() -> Self {
664            Self {
665                thread_settings_json: fidl::new_empty!(
666                    fidl_fuchsia_mem::Buffer,
667                    fidl::encoding::DefaultFuchsiaResourceDialect
668                ),
669            }
670        }
671
672        #[inline]
673        unsafe fn decode(
674            &mut self,
675            decoder: &mut fidl::encoding::Decoder<
676                '_,
677                fidl::encoding::DefaultFuchsiaResourceDialect,
678            >,
679            offset: usize,
680            _depth: fidl::encoding::Depth,
681        ) -> fidl::Result<()> {
682            decoder.debug_check_bounds::<Self>(offset);
683            // Verify that padding bytes are zero.
684            fidl::decode!(
685                fidl_fuchsia_mem::Buffer,
686                fidl::encoding::DefaultFuchsiaResourceDialect,
687                &mut self.thread_settings_json,
688                decoder,
689                offset + 0,
690                _depth
691            )?;
692            Ok(())
693        }
694    }
695}