fidl_fuchsia_hardware_block_volume/
fidl_fuchsia_hardware_block_volume.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_hardware_block_volume__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct NodeAddChildRequest {
16    pub args: fidl_fuchsia_driver_framework::NodeAddArgs,
17    pub controller: fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddChildRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct NodeMarker;
24
25impl fidl::endpoints::ProtocolMarker for NodeMarker {
26    type Proxy = NodeProxy;
27    type RequestStream = NodeRequestStream;
28    #[cfg(target_os = "fuchsia")]
29    type SynchronousProxy = NodeSynchronousProxy;
30
31    const DEBUG_NAME: &'static str = "(anonymous) Node";
32}
33pub type NodeAddChildResult = Result<(), fidl_fuchsia_driver_framework::NodeError>;
34
35pub trait NodeProxyInterface: Send + Sync {
36    type AddChildResponseFut: std::future::Future<Output = Result<NodeAddChildResult, fidl::Error>>
37        + Send;
38    fn r#add_child(
39        &self,
40        args: fidl_fuchsia_driver_framework::NodeAddArgs,
41        controller: fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
42    ) -> Self::AddChildResponseFut;
43}
44#[derive(Debug)]
45#[cfg(target_os = "fuchsia")]
46pub struct NodeSynchronousProxy {
47    client: fidl::client::sync::Client,
48}
49
50#[cfg(target_os = "fuchsia")]
51impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
52    type Proxy = NodeProxy;
53    type Protocol = NodeMarker;
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 NodeSynchronousProxy {
70    pub fn new(channel: fidl::Channel) -> Self {
71        let protocol_name = <NodeMarker 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(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
82        NodeEvent::decode(self.client.wait_for_event(deadline)?)
83    }
84
85    /// Adds a child node to this node.
86    ///
87    /// The driver framework will locate an appropriate driver to bind the child to.
88    pub fn r#add_child(
89        &self,
90        mut args: fidl_fuchsia_driver_framework::NodeAddArgs,
91        mut controller: fidl::endpoints::ServerEnd<
92            fidl_fuchsia_driver_framework::NodeControllerMarker,
93        >,
94        ___deadline: zx::MonotonicInstant,
95    ) -> Result<NodeAddChildResult, fidl::Error> {
96        let _response = self.client.send_query::<NodeAddChildRequest, fidl::encoding::ResultType<
97            fidl::encoding::EmptyStruct,
98            fidl_fuchsia_driver_framework::NodeError,
99        >>(
100            (&mut args, controller),
101            0x359fc7742655b162,
102            fidl::encoding::DynamicFlags::empty(),
103            ___deadline,
104        )?;
105        Ok(_response.map(|x| x))
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl From<NodeSynchronousProxy> for zx::NullableHandle {
111    fn from(value: NodeSynchronousProxy) -> Self {
112        value.into_channel().into()
113    }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl From<fidl::Channel> for NodeSynchronousProxy {
118    fn from(value: fidl::Channel) -> Self {
119        Self::new(value)
120    }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl fidl::endpoints::FromClient for NodeSynchronousProxy {
125    type Protocol = NodeMarker;
126
127    fn from_client(value: fidl::endpoints::ClientEnd<NodeMarker>) -> Self {
128        Self::new(value.into_channel())
129    }
130}
131
132#[derive(Debug, Clone)]
133pub struct NodeProxy {
134    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
135}
136
137impl fidl::endpoints::Proxy for NodeProxy {
138    type Protocol = NodeMarker;
139
140    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
141        Self::new(inner)
142    }
143
144    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
145        self.client.into_channel().map_err(|client| Self { client })
146    }
147
148    fn as_channel(&self) -> &::fidl::AsyncChannel {
149        self.client.as_channel()
150    }
151}
152
153impl NodeProxy {
154    /// Create a new Proxy for fuchsia.hardware.block.volume/Node.
155    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
156        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
157        Self { client: fidl::client::Client::new(channel, protocol_name) }
158    }
159
160    /// Get a Stream of events from the remote end of the protocol.
161    ///
162    /// # Panics
163    ///
164    /// Panics if the event stream was already taken.
165    pub fn take_event_stream(&self) -> NodeEventStream {
166        NodeEventStream { event_receiver: self.client.take_event_receiver() }
167    }
168
169    /// Adds a child node to this node.
170    ///
171    /// The driver framework will locate an appropriate driver to bind the child to.
172    pub fn r#add_child(
173        &self,
174        mut args: fidl_fuchsia_driver_framework::NodeAddArgs,
175        mut controller: fidl::endpoints::ServerEnd<
176            fidl_fuchsia_driver_framework::NodeControllerMarker,
177        >,
178    ) -> fidl::client::QueryResponseFut<
179        NodeAddChildResult,
180        fidl::encoding::DefaultFuchsiaResourceDialect,
181    > {
182        NodeProxyInterface::r#add_child(self, args, controller)
183    }
184}
185
186impl NodeProxyInterface for NodeProxy {
187    type AddChildResponseFut = fidl::client::QueryResponseFut<
188        NodeAddChildResult,
189        fidl::encoding::DefaultFuchsiaResourceDialect,
190    >;
191    fn r#add_child(
192        &self,
193        mut args: fidl_fuchsia_driver_framework::NodeAddArgs,
194        mut controller: fidl::endpoints::ServerEnd<
195            fidl_fuchsia_driver_framework::NodeControllerMarker,
196        >,
197    ) -> Self::AddChildResponseFut {
198        fn _decode(
199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
200        ) -> Result<NodeAddChildResult, fidl::Error> {
201            let _response = fidl::client::decode_transaction_body::<
202                fidl::encoding::ResultType<
203                    fidl::encoding::EmptyStruct,
204                    fidl_fuchsia_driver_framework::NodeError,
205                >,
206                fidl::encoding::DefaultFuchsiaResourceDialect,
207                0x359fc7742655b162,
208            >(_buf?)?;
209            Ok(_response.map(|x| x))
210        }
211        self.client.send_query_and_decode::<NodeAddChildRequest, NodeAddChildResult>(
212            (&mut args, controller),
213            0x359fc7742655b162,
214            fidl::encoding::DynamicFlags::empty(),
215            _decode,
216        )
217    }
218}
219
220pub struct NodeEventStream {
221    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
222}
223
224impl std::marker::Unpin for NodeEventStream {}
225
226impl futures::stream::FusedStream for NodeEventStream {
227    fn is_terminated(&self) -> bool {
228        self.event_receiver.is_terminated()
229    }
230}
231
232impl futures::Stream for NodeEventStream {
233    type Item = Result<NodeEvent, fidl::Error>;
234
235    fn poll_next(
236        mut self: std::pin::Pin<&mut Self>,
237        cx: &mut std::task::Context<'_>,
238    ) -> std::task::Poll<Option<Self::Item>> {
239        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
240            &mut self.event_receiver,
241            cx
242        )?) {
243            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
244            None => std::task::Poll::Ready(None),
245        }
246    }
247}
248
249#[derive(Debug)]
250pub enum NodeEvent {}
251
252impl NodeEvent {
253    /// Decodes a message buffer as a [`NodeEvent`].
254    fn decode(
255        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
256    ) -> Result<NodeEvent, fidl::Error> {
257        let (bytes, _handles) = buf.split_mut();
258        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
259        debug_assert_eq!(tx_header.tx_id, 0);
260        match tx_header.ordinal {
261            _ => Err(fidl::Error::UnknownOrdinal {
262                ordinal: tx_header.ordinal,
263                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
264            }),
265        }
266    }
267}
268
269/// A Stream of incoming requests for fuchsia.hardware.block.volume/Node.
270pub struct NodeRequestStream {
271    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
272    is_terminated: bool,
273}
274
275impl std::marker::Unpin for NodeRequestStream {}
276
277impl futures::stream::FusedStream for NodeRequestStream {
278    fn is_terminated(&self) -> bool {
279        self.is_terminated
280    }
281}
282
283impl fidl::endpoints::RequestStream for NodeRequestStream {
284    type Protocol = NodeMarker;
285    type ControlHandle = NodeControlHandle;
286
287    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
288        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
289    }
290
291    fn control_handle(&self) -> Self::ControlHandle {
292        NodeControlHandle { inner: self.inner.clone() }
293    }
294
295    fn into_inner(
296        self,
297    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
298    {
299        (self.inner, self.is_terminated)
300    }
301
302    fn from_inner(
303        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
304        is_terminated: bool,
305    ) -> Self {
306        Self { inner, is_terminated }
307    }
308}
309
310impl futures::Stream for NodeRequestStream {
311    type Item = Result<NodeRequest, fidl::Error>;
312
313    fn poll_next(
314        mut self: std::pin::Pin<&mut Self>,
315        cx: &mut std::task::Context<'_>,
316    ) -> std::task::Poll<Option<Self::Item>> {
317        let this = &mut *self;
318        if this.inner.check_shutdown(cx) {
319            this.is_terminated = true;
320            return std::task::Poll::Ready(None);
321        }
322        if this.is_terminated {
323            panic!("polled NodeRequestStream after completion");
324        }
325        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
326            |bytes, handles| {
327                match this.inner.channel().read_etc(cx, bytes, handles) {
328                    std::task::Poll::Ready(Ok(())) => {}
329                    std::task::Poll::Pending => return std::task::Poll::Pending,
330                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
331                        this.is_terminated = true;
332                        return std::task::Poll::Ready(None);
333                    }
334                    std::task::Poll::Ready(Err(e)) => {
335                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
336                            e.into(),
337                        ))));
338                    }
339                }
340
341                // A message has been received from the channel
342                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
343
344                std::task::Poll::Ready(Some(match header.ordinal {
345                    0x359fc7742655b162 => {
346                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
347                        let mut req = fidl::new_empty!(
348                            NodeAddChildRequest,
349                            fidl::encoding::DefaultFuchsiaResourceDialect
350                        );
351                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
352                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
353                        Ok(NodeRequest::AddChild {
354                            args: req.args,
355                            controller: req.controller,
356
357                            responder: NodeAddChildResponder {
358                                control_handle: std::mem::ManuallyDrop::new(control_handle),
359                                tx_id: header.tx_id,
360                            },
361                        })
362                    }
363                    _ => Err(fidl::Error::UnknownOrdinal {
364                        ordinal: header.ordinal,
365                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
366                    }),
367                }))
368            },
369        )
370    }
371}
372
373#[derive(Debug)]
374pub enum NodeRequest {
375    /// Adds a child node to this node.
376    ///
377    /// The driver framework will locate an appropriate driver to bind the child to.
378    AddChild {
379        args: fidl_fuchsia_driver_framework::NodeAddArgs,
380        controller: fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
381        responder: NodeAddChildResponder,
382    },
383}
384
385impl NodeRequest {
386    #[allow(irrefutable_let_patterns)]
387    pub fn into_add_child(
388        self,
389    ) -> Option<(
390        fidl_fuchsia_driver_framework::NodeAddArgs,
391        fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
392        NodeAddChildResponder,
393    )> {
394        if let NodeRequest::AddChild { args, controller, responder } = self {
395            Some((args, controller, responder))
396        } else {
397            None
398        }
399    }
400
401    /// Name of the method defined in FIDL
402    pub fn method_name(&self) -> &'static str {
403        match *self {
404            NodeRequest::AddChild { .. } => "add_child",
405        }
406    }
407}
408
409#[derive(Debug, Clone)]
410pub struct NodeControlHandle {
411    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
412}
413
414impl fidl::endpoints::ControlHandle for NodeControlHandle {
415    fn shutdown(&self) {
416        self.inner.shutdown()
417    }
418
419    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
420        self.inner.shutdown_with_epitaph(status)
421    }
422
423    fn is_closed(&self) -> bool {
424        self.inner.channel().is_closed()
425    }
426    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
427        self.inner.channel().on_closed()
428    }
429
430    #[cfg(target_os = "fuchsia")]
431    fn signal_peer(
432        &self,
433        clear_mask: zx::Signals,
434        set_mask: zx::Signals,
435    ) -> Result<(), zx_status::Status> {
436        use fidl::Peered;
437        self.inner.channel().signal_peer(clear_mask, set_mask)
438    }
439}
440
441impl NodeControlHandle {}
442
443#[must_use = "FIDL methods require a response to be sent"]
444#[derive(Debug)]
445pub struct NodeAddChildResponder {
446    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
447    tx_id: u32,
448}
449
450/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
451/// if the responder is dropped without sending a response, so that the client
452/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
453impl std::ops::Drop for NodeAddChildResponder {
454    fn drop(&mut self) {
455        self.control_handle.shutdown();
456        // Safety: drops once, never accessed again
457        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
458    }
459}
460
461impl fidl::endpoints::Responder for NodeAddChildResponder {
462    type ControlHandle = NodeControlHandle;
463
464    fn control_handle(&self) -> &NodeControlHandle {
465        &self.control_handle
466    }
467
468    fn drop_without_shutdown(mut self) {
469        // Safety: drops once, never accessed again due to mem::forget
470        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
471        // Prevent Drop from running (which would shut down the channel)
472        std::mem::forget(self);
473    }
474}
475
476impl NodeAddChildResponder {
477    /// Sends a response to the FIDL transaction.
478    ///
479    /// Sets the channel to shutdown if an error occurs.
480    pub fn send(
481        self,
482        mut result: Result<(), fidl_fuchsia_driver_framework::NodeError>,
483    ) -> Result<(), fidl::Error> {
484        let _result = self.send_raw(result);
485        if _result.is_err() {
486            self.control_handle.shutdown();
487        }
488        self.drop_without_shutdown();
489        _result
490    }
491
492    /// Similar to "send" but does not shutdown the channel if an error occurs.
493    pub fn send_no_shutdown_on_err(
494        self,
495        mut result: Result<(), fidl_fuchsia_driver_framework::NodeError>,
496    ) -> Result<(), fidl::Error> {
497        let _result = self.send_raw(result);
498        self.drop_without_shutdown();
499        _result
500    }
501
502    fn send_raw(
503        &self,
504        mut result: Result<(), fidl_fuchsia_driver_framework::NodeError>,
505    ) -> Result<(), fidl::Error> {
506        self.control_handle.inner.send::<fidl::encoding::ResultType<
507            fidl::encoding::EmptyStruct,
508            fidl_fuchsia_driver_framework::NodeError,
509        >>(
510            result,
511            self.tx_id,
512            0x359fc7742655b162,
513            fidl::encoding::DynamicFlags::empty(),
514        )
515    }
516}
517
518#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
519pub struct ServiceMarker;
520
521#[cfg(target_os = "fuchsia")]
522impl fidl::endpoints::ServiceMarker for ServiceMarker {
523    type Proxy = ServiceProxy;
524    type Request = ServiceRequest;
525    const SERVICE_NAME: &'static str = "fuchsia.hardware.block.volume.Service";
526}
527
528/// A request for one of the member protocols of Service.
529///
530#[cfg(target_os = "fuchsia")]
531pub enum ServiceRequest {
532    Volume(fidl_fuchsia_storage_block::BlockRequestStream),
533    InlineEncryption(fidl_fuchsia_hardware_inlineencryption::DeviceRequestStream),
534    Node(NodeRequestStream),
535}
536
537#[cfg(target_os = "fuchsia")]
538impl fidl::endpoints::ServiceRequest for ServiceRequest {
539    type Service = ServiceMarker;
540
541    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
542        match name {
543            "volume" => Self::Volume(
544                <fidl_fuchsia_storage_block::BlockRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
545            ),
546            "inline_encryption" => Self::InlineEncryption(
547                <fidl_fuchsia_hardware_inlineencryption::DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
548            ),
549            "node" => Self::Node(
550                <NodeRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
551            ),
552            _ => panic!("no such member protocol name for service Service"),
553        }
554    }
555
556    fn member_names() -> &'static [&'static str] {
557        &["volume", "inline_encryption", "node"]
558    }
559}
560#[cfg(target_os = "fuchsia")]
561pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
562
563#[cfg(target_os = "fuchsia")]
564impl fidl::endpoints::ServiceProxy for ServiceProxy {
565    type Service = ServiceMarker;
566
567    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
568        Self(opener)
569    }
570}
571
572#[cfg(target_os = "fuchsia")]
573impl ServiceProxy {
574    pub fn connect_to_volume(&self) -> Result<fidl_fuchsia_storage_block::BlockProxy, fidl::Error> {
575        let (proxy, server_end) =
576            fidl::endpoints::create_proxy::<fidl_fuchsia_storage_block::BlockMarker>();
577        self.connect_channel_to_volume(server_end)?;
578        Ok(proxy)
579    }
580
581    /// Like `connect_to_volume`, but returns a sync proxy.
582    /// See [`Self::connect_to_volume`] for more details.
583    pub fn connect_to_volume_sync(
584        &self,
585    ) -> Result<fidl_fuchsia_storage_block::BlockSynchronousProxy, fidl::Error> {
586        let (proxy, server_end) =
587            fidl::endpoints::create_sync_proxy::<fidl_fuchsia_storage_block::BlockMarker>();
588        self.connect_channel_to_volume(server_end)?;
589        Ok(proxy)
590    }
591
592    /// Like `connect_to_volume`, but accepts a server end.
593    /// See [`Self::connect_to_volume`] for more details.
594    pub fn connect_channel_to_volume(
595        &self,
596        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
597    ) -> Result<(), fidl::Error> {
598        self.0.open_member("volume", server_end.into_channel())
599    }
600    pub fn connect_to_inline_encryption(
601        &self,
602    ) -> Result<fidl_fuchsia_hardware_inlineencryption::DeviceProxy, fidl::Error> {
603        let (proxy, server_end) =
604            fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_inlineencryption::DeviceMarker>();
605        self.connect_channel_to_inline_encryption(server_end)?;
606        Ok(proxy)
607    }
608
609    /// Like `connect_to_inline_encryption`, but returns a sync proxy.
610    /// See [`Self::connect_to_inline_encryption`] for more details.
611    pub fn connect_to_inline_encryption_sync(
612        &self,
613    ) -> Result<fidl_fuchsia_hardware_inlineencryption::DeviceSynchronousProxy, fidl::Error> {
614        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<
615            fidl_fuchsia_hardware_inlineencryption::DeviceMarker,
616        >();
617        self.connect_channel_to_inline_encryption(server_end)?;
618        Ok(proxy)
619    }
620
621    /// Like `connect_to_inline_encryption`, but accepts a server end.
622    /// See [`Self::connect_to_inline_encryption`] for more details.
623    pub fn connect_channel_to_inline_encryption(
624        &self,
625        server_end: fidl::endpoints::ServerEnd<
626            fidl_fuchsia_hardware_inlineencryption::DeviceMarker,
627        >,
628    ) -> Result<(), fidl::Error> {
629        self.0.open_member("inline_encryption", server_end.into_channel())
630    }
631    pub fn connect_to_node(&self) -> Result<NodeProxy, fidl::Error> {
632        let (proxy, server_end) = fidl::endpoints::create_proxy::<NodeMarker>();
633        self.connect_channel_to_node(server_end)?;
634        Ok(proxy)
635    }
636
637    /// Like `connect_to_node`, but returns a sync proxy.
638    /// See [`Self::connect_to_node`] for more details.
639    pub fn connect_to_node_sync(&self) -> Result<NodeSynchronousProxy, fidl::Error> {
640        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<NodeMarker>();
641        self.connect_channel_to_node(server_end)?;
642        Ok(proxy)
643    }
644
645    /// Like `connect_to_node`, but accepts a server end.
646    /// See [`Self::connect_to_node`] for more details.
647    pub fn connect_channel_to_node(
648        &self,
649        server_end: fidl::endpoints::ServerEnd<NodeMarker>,
650    ) -> Result<(), fidl::Error> {
651        self.0.open_member("node", server_end.into_channel())
652    }
653
654    pub fn instance_name(&self) -> &str {
655        self.0.instance_name()
656    }
657}
658
659mod internal {
660    use super::*;
661
662    impl fidl::encoding::ResourceTypeMarker for NodeAddChildRequest {
663        type Borrowed<'a> = &'a mut Self;
664        fn take_or_borrow<'a>(
665            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
666        ) -> Self::Borrowed<'a> {
667            value
668        }
669    }
670
671    unsafe impl fidl::encoding::TypeMarker for NodeAddChildRequest {
672        type Owned = Self;
673
674        #[inline(always)]
675        fn inline_align(_context: fidl::encoding::Context) -> usize {
676            8
677        }
678
679        #[inline(always)]
680        fn inline_size(_context: fidl::encoding::Context) -> usize {
681            24
682        }
683    }
684
685    unsafe impl
686        fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
687        for &mut NodeAddChildRequest
688    {
689        #[inline]
690        unsafe fn encode(
691            self,
692            encoder: &mut fidl::encoding::Encoder<
693                '_,
694                fidl::encoding::DefaultFuchsiaResourceDialect,
695            >,
696            offset: usize,
697            _depth: fidl::encoding::Depth,
698        ) -> fidl::Result<()> {
699            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
700            // Delegate to tuple encoding.
701            fidl::encoding::Encode::<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
702                (
703                    <fidl_fuchsia_driver_framework::NodeAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
704                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
705                ),
706                encoder, offset, _depth
707            )
708        }
709    }
710    unsafe impl<
711        T0: fidl::encoding::Encode<
712                fidl_fuchsia_driver_framework::NodeAddArgs,
713                fidl::encoding::DefaultFuchsiaResourceDialect,
714            >,
715        T1: fidl::encoding::Encode<
716                fidl::encoding::Endpoint<
717                    fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
718                >,
719                fidl::encoding::DefaultFuchsiaResourceDialect,
720            >,
721    > fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
722        for (T0, T1)
723    {
724        #[inline]
725        unsafe fn encode(
726            self,
727            encoder: &mut fidl::encoding::Encoder<
728                '_,
729                fidl::encoding::DefaultFuchsiaResourceDialect,
730            >,
731            offset: usize,
732            depth: fidl::encoding::Depth,
733        ) -> fidl::Result<()> {
734            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
735            // Zero out padding regions. There's no need to apply masks
736            // because the unmasked parts will be overwritten by fields.
737            unsafe {
738                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
739                (ptr as *mut u64).write_unaligned(0);
740            }
741            // Write the fields.
742            self.0.encode(encoder, offset + 0, depth)?;
743            self.1.encode(encoder, offset + 16, depth)?;
744            Ok(())
745        }
746    }
747
748    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
749        for NodeAddChildRequest
750    {
751        #[inline(always)]
752        fn new_empty() -> Self {
753            Self {
754                args: fidl::new_empty!(
755                    fidl_fuchsia_driver_framework::NodeAddArgs,
756                    fidl::encoding::DefaultFuchsiaResourceDialect
757                ),
758                controller: fidl::new_empty!(
759                    fidl::encoding::Endpoint<
760                        fidl::endpoints::ServerEnd<
761                            fidl_fuchsia_driver_framework::NodeControllerMarker,
762                        >,
763                    >,
764                    fidl::encoding::DefaultFuchsiaResourceDialect
765                ),
766            }
767        }
768
769        #[inline]
770        unsafe fn decode(
771            &mut self,
772            decoder: &mut fidl::encoding::Decoder<
773                '_,
774                fidl::encoding::DefaultFuchsiaResourceDialect,
775            >,
776            offset: usize,
777            _depth: fidl::encoding::Depth,
778        ) -> fidl::Result<()> {
779            decoder.debug_check_bounds::<Self>(offset);
780            // Verify that padding bytes are zero.
781            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
782            let padval = unsafe { (ptr as *const u64).read_unaligned() };
783            let mask = 0xffffffff00000000u64;
784            let maskedval = padval & mask;
785            if maskedval != 0 {
786                return Err(fidl::Error::NonZeroPadding {
787                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
788                });
789            }
790            fidl::decode!(
791                fidl_fuchsia_driver_framework::NodeAddArgs,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793                &mut self.args,
794                decoder,
795                offset + 0,
796                _depth
797            )?;
798            fidl::decode!(
799                fidl::encoding::Endpoint<
800                    fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
801                >,
802                fidl::encoding::DefaultFuchsiaResourceDialect,
803                &mut self.controller,
804                decoder,
805                offset + 16,
806                _depth
807            )?;
808            Ok(())
809        }
810    }
811}