Skip to main content

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