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}
535
536#[cfg(target_os = "fuchsia")]
537impl fidl::endpoints::ServiceRequest for ServiceRequest {
538    type Service = ServiceMarker;
539
540    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
541        match name {
542            "volume" => Self::Volume(
543                <fidl_fuchsia_storage_block::BlockRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
544            ),
545            "inline_encryption" => Self::InlineEncryption(
546                <fidl_fuchsia_hardware_inlineencryption::DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
547            ),
548            "node" => Self::Node(
549                <NodeRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
550            ),
551            _ => panic!("no such member protocol name for service Service"),
552        }
553    }
554
555    fn member_names() -> &'static [&'static str] {
556        &["volume", "inline_encryption", "node"]
557    }
558}
559#[cfg(target_os = "fuchsia")]
560pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
561
562#[cfg(target_os = "fuchsia")]
563impl fidl::endpoints::ServiceProxy for ServiceProxy {
564    type Service = ServiceMarker;
565
566    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
567        Self(opener)
568    }
569}
570
571#[cfg(target_os = "fuchsia")]
572impl ServiceProxy {
573    pub fn connect_to_volume(&self) -> Result<fidl_fuchsia_storage_block::BlockProxy, fidl::Error> {
574        let (proxy, server_end) =
575            fidl::endpoints::create_proxy::<fidl_fuchsia_storage_block::BlockMarker>();
576        self.connect_channel_to_volume(server_end)?;
577        Ok(proxy)
578    }
579
580    /// Like `connect_to_volume`, but returns a sync proxy.
581    /// See [`Self::connect_to_volume`] for more details.
582    pub fn connect_to_volume_sync(
583        &self,
584    ) -> Result<fidl_fuchsia_storage_block::BlockSynchronousProxy, fidl::Error> {
585        let (proxy, server_end) =
586            fidl::endpoints::create_sync_proxy::<fidl_fuchsia_storage_block::BlockMarker>();
587        self.connect_channel_to_volume(server_end)?;
588        Ok(proxy)
589    }
590
591    /// Like `connect_to_volume`, but accepts a server end.
592    /// See [`Self::connect_to_volume`] for more details.
593    pub fn connect_channel_to_volume(
594        &self,
595        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
596    ) -> Result<(), fidl::Error> {
597        self.0.open_member("volume", server_end.into_channel())
598    }
599    pub fn connect_to_inline_encryption(
600        &self,
601    ) -> Result<fidl_fuchsia_hardware_inlineencryption::DeviceProxy, fidl::Error> {
602        let (proxy, server_end) =
603            fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_inlineencryption::DeviceMarker>();
604        self.connect_channel_to_inline_encryption(server_end)?;
605        Ok(proxy)
606    }
607
608    /// Like `connect_to_inline_encryption`, but returns a sync proxy.
609    /// See [`Self::connect_to_inline_encryption`] for more details.
610    pub fn connect_to_inline_encryption_sync(
611        &self,
612    ) -> Result<fidl_fuchsia_hardware_inlineencryption::DeviceSynchronousProxy, fidl::Error> {
613        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<
614            fidl_fuchsia_hardware_inlineencryption::DeviceMarker,
615        >();
616        self.connect_channel_to_inline_encryption(server_end)?;
617        Ok(proxy)
618    }
619
620    /// Like `connect_to_inline_encryption`, but accepts a server end.
621    /// See [`Self::connect_to_inline_encryption`] for more details.
622    pub fn connect_channel_to_inline_encryption(
623        &self,
624        server_end: fidl::endpoints::ServerEnd<
625            fidl_fuchsia_hardware_inlineencryption::DeviceMarker,
626        >,
627    ) -> Result<(), fidl::Error> {
628        self.0.open_member("inline_encryption", server_end.into_channel())
629    }
630    pub fn connect_to_node(&self) -> Result<NodeProxy, fidl::Error> {
631        let (proxy, server_end) = fidl::endpoints::create_proxy::<NodeMarker>();
632        self.connect_channel_to_node(server_end)?;
633        Ok(proxy)
634    }
635
636    /// Like `connect_to_node`, but returns a sync proxy.
637    /// See [`Self::connect_to_node`] for more details.
638    pub fn connect_to_node_sync(&self) -> Result<NodeSynchronousProxy, fidl::Error> {
639        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<NodeMarker>();
640        self.connect_channel_to_node(server_end)?;
641        Ok(proxy)
642    }
643
644    /// Like `connect_to_node`, but accepts a server end.
645    /// See [`Self::connect_to_node`] for more details.
646    pub fn connect_channel_to_node(
647        &self,
648        server_end: fidl::endpoints::ServerEnd<NodeMarker>,
649    ) -> Result<(), fidl::Error> {
650        self.0.open_member("node", server_end.into_channel())
651    }
652
653    pub fn instance_name(&self) -> &str {
654        self.0.instance_name()
655    }
656}
657
658mod internal {
659    use super::*;
660
661    impl fidl::encoding::ResourceTypeMarker for NodeAddChildRequest {
662        type Borrowed<'a> = &'a mut Self;
663        fn take_or_borrow<'a>(
664            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
665        ) -> Self::Borrowed<'a> {
666            value
667        }
668    }
669
670    unsafe impl fidl::encoding::TypeMarker for NodeAddChildRequest {
671        type Owned = Self;
672
673        #[inline(always)]
674        fn inline_align(_context: fidl::encoding::Context) -> usize {
675            8
676        }
677
678        #[inline(always)]
679        fn inline_size(_context: fidl::encoding::Context) -> usize {
680            24
681        }
682    }
683
684    unsafe impl
685        fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
686        for &mut NodeAddChildRequest
687    {
688        #[inline]
689        unsafe fn encode(
690            self,
691            encoder: &mut fidl::encoding::Encoder<
692                '_,
693                fidl::encoding::DefaultFuchsiaResourceDialect,
694            >,
695            offset: usize,
696            _depth: fidl::encoding::Depth,
697        ) -> fidl::Result<()> {
698            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
699            // Delegate to tuple encoding.
700            fidl::encoding::Encode::<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
701                (
702                    <fidl_fuchsia_driver_framework::NodeAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
703                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
704                ),
705                encoder, offset, _depth
706            )
707        }
708    }
709    unsafe impl<
710        T0: fidl::encoding::Encode<
711                fidl_fuchsia_driver_framework::NodeAddArgs,
712                fidl::encoding::DefaultFuchsiaResourceDialect,
713            >,
714        T1: fidl::encoding::Encode<
715                fidl::encoding::Endpoint<
716                    fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
717                >,
718                fidl::encoding::DefaultFuchsiaResourceDialect,
719            >,
720    > fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
721        for (T0, T1)
722    {
723        #[inline]
724        unsafe fn encode(
725            self,
726            encoder: &mut fidl::encoding::Encoder<
727                '_,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729            >,
730            offset: usize,
731            depth: fidl::encoding::Depth,
732        ) -> fidl::Result<()> {
733            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
734            // Zero out padding regions. There's no need to apply masks
735            // because the unmasked parts will be overwritten by fields.
736            unsafe {
737                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
738                (ptr as *mut u64).write_unaligned(0);
739            }
740            // Write the fields.
741            self.0.encode(encoder, offset + 0, depth)?;
742            self.1.encode(encoder, offset + 16, depth)?;
743            Ok(())
744        }
745    }
746
747    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
748        for NodeAddChildRequest
749    {
750        #[inline(always)]
751        fn new_empty() -> Self {
752            Self {
753                args: fidl::new_empty!(
754                    fidl_fuchsia_driver_framework::NodeAddArgs,
755                    fidl::encoding::DefaultFuchsiaResourceDialect
756                ),
757                controller: fidl::new_empty!(
758                    fidl::encoding::Endpoint<
759                        fidl::endpoints::ServerEnd<
760                            fidl_fuchsia_driver_framework::NodeControllerMarker,
761                        >,
762                    >,
763                    fidl::encoding::DefaultFuchsiaResourceDialect
764                ),
765            }
766        }
767
768        #[inline]
769        unsafe fn decode(
770            &mut self,
771            decoder: &mut fidl::encoding::Decoder<
772                '_,
773                fidl::encoding::DefaultFuchsiaResourceDialect,
774            >,
775            offset: usize,
776            _depth: fidl::encoding::Depth,
777        ) -> fidl::Result<()> {
778            decoder.debug_check_bounds::<Self>(offset);
779            // Verify that padding bytes are zero.
780            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
781            let padval = unsafe { (ptr as *const u64).read_unaligned() };
782            let mask = 0xffffffff00000000u64;
783            let maskedval = padval & mask;
784            if maskedval != 0 {
785                return Err(fidl::Error::NonZeroPadding {
786                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
787                });
788            }
789            fidl::decode!(
790                fidl_fuchsia_driver_framework::NodeAddArgs,
791                fidl::encoding::DefaultFuchsiaResourceDialect,
792                &mut self.args,
793                decoder,
794                offset + 0,
795                _depth
796            )?;
797            fidl::decode!(
798                fidl::encoding::Endpoint<
799                    fidl::endpoints::ServerEnd<fidl_fuchsia_driver_framework::NodeControllerMarker>,
800                >,
801                fidl::encoding::DefaultFuchsiaResourceDialect,
802                &mut self.controller,
803                decoder,
804                offset + 16,
805                _depth
806            )?;
807            Ok(())
808        }
809    }
810}