Skip to main content

fidl_fuchsia_storage_mapping/
fidl_fuchsia_storage_mapping.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_storage_mapping_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FileMapperOpenSessionRequest {
16    pub file_token: fidl::Event,
17    pub mapping_vmo: fidl::Vmo,
18    pub session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for FileMapperOpenSessionRequest
23{
24}
25
26#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct MappingProviderOpenSessionRequest {
28    pub session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for MappingProviderOpenSessionRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct MappingProviderOpenSessionResponse {
38    pub mapping_vmo: fidl::Vmo,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for MappingProviderOpenSessionResponse
43{
44}
45
46#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct MappingSessionWriteProfileRequest {
48    pub name: String,
49    pub profile_vmo: fidl::Vmo,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for MappingSessionWriteProfileRequest
54{
55}
56
57#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58pub struct MappingSessionGetProfileResponse {
59    pub profile_vmo: fidl::Vmo,
60}
61
62impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
63    for MappingSessionGetProfileResponse
64{
65}
66
67#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
68pub struct FileMapperMarker;
69
70impl fidl::endpoints::ProtocolMarker for FileMapperMarker {
71    type Proxy = FileMapperProxy;
72    type RequestStream = FileMapperRequestStream;
73    #[cfg(target_os = "fuchsia")]
74    type SynchronousProxy = FileMapperSynchronousProxy;
75
76    const DEBUG_NAME: &'static str = "fuchsia.storage.mapping.FileMapper";
77}
78impl fidl::endpoints::DiscoverableProtocolMarker for FileMapperMarker {}
79pub type FileMapperOpenSessionResult = Result<(), i32>;
80
81pub trait FileMapperProxyInterface: Send + Sync {
82    type OpenSessionResponseFut: std::future::Future<Output = Result<FileMapperOpenSessionResult, fidl::Error>>
83        + Send;
84    fn r#open_session(
85        &self,
86        file_token: fidl::Event,
87        mapping_vmo: fidl::Vmo,
88        session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
89    ) -> Self::OpenSessionResponseFut;
90}
91#[derive(Debug)]
92#[cfg(target_os = "fuchsia")]
93pub struct FileMapperSynchronousProxy {
94    client: fidl::client::sync::Client,
95}
96
97#[cfg(target_os = "fuchsia")]
98impl fidl::endpoints::SynchronousProxy for FileMapperSynchronousProxy {
99    type Proxy = FileMapperProxy;
100    type Protocol = FileMapperMarker;
101
102    fn from_channel(inner: fidl::Channel) -> Self {
103        Self::new(inner)
104    }
105
106    fn into_channel(self) -> fidl::Channel {
107        self.client.into_channel()
108    }
109
110    fn as_channel(&self) -> &fidl::Channel {
111        self.client.as_channel()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl FileMapperSynchronousProxy {
117    pub fn new(channel: fidl::Channel) -> Self {
118        Self { client: fidl::client::sync::Client::new(channel) }
119    }
120
121    pub fn into_channel(self) -> fidl::Channel {
122        self.client.into_channel()
123    }
124
125    /// Waits until an event arrives and returns it. It is safe for other
126    /// threads to make concurrent requests while waiting for an event.
127    pub fn wait_for_event(
128        &self,
129        deadline: zx::MonotonicInstant,
130    ) -> Result<FileMapperEvent, fidl::Error> {
131        FileMapperEvent::decode(self.client.wait_for_event::<FileMapperMarker>(deadline)?)
132    }
133
134    /// Opens a child `MapperSession` backed by the file identified by `file_token`
135    /// (obtained from `fuchsia.io/Node.GetToken`).
136    pub fn r#open_session(
137        &self,
138        mut file_token: fidl::Event,
139        mut mapping_vmo: fidl::Vmo,
140        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
141        ___deadline: zx::MonotonicInstant,
142    ) -> Result<FileMapperOpenSessionResult, fidl::Error> {
143        let _response = self.client.send_query::<
144            FileMapperOpenSessionRequest,
145            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
146            FileMapperMarker,
147        >(
148            (file_token, mapping_vmo, session,),
149            0x1b4cfd70270fbc63,
150            fidl::encoding::DynamicFlags::FLEXIBLE,
151            ___deadline,
152        )?
153        .into_result::<FileMapperMarker>("open_session")?;
154        Ok(_response.map(|x| x))
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl From<FileMapperSynchronousProxy> for zx::NullableHandle {
160    fn from(value: FileMapperSynchronousProxy) -> Self {
161        value.into_channel().into()
162    }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl From<fidl::Channel> for FileMapperSynchronousProxy {
167    fn from(value: fidl::Channel) -> Self {
168        Self::new(value)
169    }
170}
171
172#[cfg(target_os = "fuchsia")]
173impl fidl::endpoints::FromClient for FileMapperSynchronousProxy {
174    type Protocol = FileMapperMarker;
175
176    fn from_client(value: fidl::endpoints::ClientEnd<FileMapperMarker>) -> Self {
177        Self::new(value.into_channel())
178    }
179}
180
181#[derive(Debug, Clone)]
182pub struct FileMapperProxy {
183    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
184}
185
186impl fidl::endpoints::Proxy for FileMapperProxy {
187    type Protocol = FileMapperMarker;
188
189    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
190        Self::new(inner)
191    }
192
193    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
194        self.client.into_channel().map_err(|client| Self { client })
195    }
196
197    fn as_channel(&self) -> &::fidl::AsyncChannel {
198        self.client.as_channel()
199    }
200}
201
202impl FileMapperProxy {
203    /// Create a new Proxy for fuchsia.storage.mapping/FileMapper.
204    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
205        let protocol_name = <FileMapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
206        Self { client: fidl::client::Client::new(channel, protocol_name) }
207    }
208
209    /// Get a Stream of events from the remote end of the protocol.
210    ///
211    /// # Panics
212    ///
213    /// Panics if the event stream was already taken.
214    pub fn take_event_stream(&self) -> FileMapperEventStream {
215        FileMapperEventStream { event_receiver: self.client.take_event_receiver() }
216    }
217
218    /// Opens a child `MapperSession` backed by the file identified by `file_token`
219    /// (obtained from `fuchsia.io/Node.GetToken`).
220    pub fn r#open_session(
221        &self,
222        mut file_token: fidl::Event,
223        mut mapping_vmo: fidl::Vmo,
224        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
225    ) -> fidl::client::QueryResponseFut<
226        FileMapperOpenSessionResult,
227        fidl::encoding::DefaultFuchsiaResourceDialect,
228    > {
229        FileMapperProxyInterface::r#open_session(self, file_token, mapping_vmo, session)
230    }
231}
232
233impl FileMapperProxyInterface for FileMapperProxy {
234    type OpenSessionResponseFut = fidl::client::QueryResponseFut<
235        FileMapperOpenSessionResult,
236        fidl::encoding::DefaultFuchsiaResourceDialect,
237    >;
238    fn r#open_session(
239        &self,
240        mut file_token: fidl::Event,
241        mut mapping_vmo: fidl::Vmo,
242        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
243    ) -> Self::OpenSessionResponseFut {
244        fn _decode(
245            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
246        ) -> Result<FileMapperOpenSessionResult, fidl::Error> {
247            let _response = fidl::client::decode_transaction_body::<
248                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
249                fidl::encoding::DefaultFuchsiaResourceDialect,
250                0x1b4cfd70270fbc63,
251            >(_buf?)?
252            .into_result::<FileMapperMarker>("open_session")?;
253            Ok(_response.map(|x| x))
254        }
255        self.client
256            .send_query_and_decode::<FileMapperOpenSessionRequest, FileMapperOpenSessionResult>(
257                (file_token, mapping_vmo, session),
258                0x1b4cfd70270fbc63,
259                fidl::encoding::DynamicFlags::FLEXIBLE,
260                _decode,
261            )
262    }
263}
264
265pub struct FileMapperEventStream {
266    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
267}
268
269impl std::marker::Unpin for FileMapperEventStream {}
270
271impl futures::stream::FusedStream for FileMapperEventStream {
272    fn is_terminated(&self) -> bool {
273        self.event_receiver.is_terminated()
274    }
275}
276
277impl futures::Stream for FileMapperEventStream {
278    type Item = Result<FileMapperEvent, fidl::Error>;
279
280    fn poll_next(
281        mut self: std::pin::Pin<&mut Self>,
282        cx: &mut std::task::Context<'_>,
283    ) -> std::task::Poll<Option<Self::Item>> {
284        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
285            &mut self.event_receiver,
286            cx
287        )?) {
288            Some(buf) => std::task::Poll::Ready(Some(FileMapperEvent::decode(buf))),
289            None => std::task::Poll::Ready(None),
290        }
291    }
292}
293
294#[derive(Debug)]
295pub enum FileMapperEvent {
296    #[non_exhaustive]
297    _UnknownEvent {
298        /// Ordinal of the event that was sent.
299        ordinal: u64,
300    },
301}
302
303impl FileMapperEvent {
304    /// Decodes a message buffer as a [`FileMapperEvent`].
305    fn decode(
306        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
307    ) -> Result<FileMapperEvent, fidl::Error> {
308        let (bytes, _handles) = buf.split_mut();
309        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310        debug_assert_eq!(tx_header.tx_id, 0);
311        match tx_header.ordinal {
312            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
313                Ok(FileMapperEvent::_UnknownEvent { ordinal: tx_header.ordinal })
314            }
315            _ => Err(fidl::Error::UnknownOrdinal {
316                ordinal: tx_header.ordinal,
317                protocol_name: <FileMapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
318            }),
319        }
320    }
321}
322
323/// A Stream of incoming requests for fuchsia.storage.mapping/FileMapper.
324pub struct FileMapperRequestStream {
325    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
326    is_terminated: bool,
327}
328
329impl std::marker::Unpin for FileMapperRequestStream {}
330
331impl futures::stream::FusedStream for FileMapperRequestStream {
332    fn is_terminated(&self) -> bool {
333        self.is_terminated
334    }
335}
336
337impl fidl::endpoints::RequestStream for FileMapperRequestStream {
338    type Protocol = FileMapperMarker;
339    type ControlHandle = FileMapperControlHandle;
340
341    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
342        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
343    }
344
345    fn control_handle(&self) -> Self::ControlHandle {
346        FileMapperControlHandle { inner: self.inner.clone() }
347    }
348
349    fn into_inner(
350        self,
351    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
352    {
353        (self.inner, self.is_terminated)
354    }
355
356    fn from_inner(
357        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
358        is_terminated: bool,
359    ) -> Self {
360        Self { inner, is_terminated }
361    }
362}
363
364impl futures::Stream for FileMapperRequestStream {
365    type Item = Result<FileMapperRequest, fidl::Error>;
366
367    fn poll_next(
368        mut self: std::pin::Pin<&mut Self>,
369        cx: &mut std::task::Context<'_>,
370    ) -> std::task::Poll<Option<Self::Item>> {
371        let this = &mut *self;
372        if this.inner.check_shutdown(cx) {
373            this.is_terminated = true;
374            return std::task::Poll::Ready(None);
375        }
376        if this.is_terminated {
377            panic!("polled FileMapperRequestStream after completion");
378        }
379        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
380            |bytes, handles| {
381                match this.inner.channel().read_etc(cx, bytes, handles) {
382                    std::task::Poll::Ready(Ok(())) => {}
383                    std::task::Poll::Pending => return std::task::Poll::Pending,
384                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
385                        this.is_terminated = true;
386                        return std::task::Poll::Ready(None);
387                    }
388                    std::task::Poll::Ready(Err(e)) => {
389                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
390                            e.into(),
391                        ))));
392                    }
393                }
394
395                // A message has been received from the channel
396                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
397
398                std::task::Poll::Ready(Some(match header.ordinal {
399                    0x1b4cfd70270fbc63 => {
400                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
401                        let mut req = fidl::new_empty!(
402                            FileMapperOpenSessionRequest,
403                            fidl::encoding::DefaultFuchsiaResourceDialect
404                        );
405                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FileMapperOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
406                        let control_handle = FileMapperControlHandle { inner: this.inner.clone() };
407                        Ok(FileMapperRequest::OpenSession {
408                            file_token: req.file_token,
409                            mapping_vmo: req.mapping_vmo,
410                            session: req.session,
411
412                            responder: FileMapperOpenSessionResponder {
413                                control_handle: std::mem::ManuallyDrop::new(control_handle),
414                                tx_id: header.tx_id,
415                            },
416                        })
417                    }
418                    _ if header.tx_id == 0
419                        && header
420                            .dynamic_flags()
421                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
422                    {
423                        Ok(FileMapperRequest::_UnknownMethod {
424                            ordinal: header.ordinal,
425                            control_handle: FileMapperControlHandle { inner: this.inner.clone() },
426                            method_type: fidl::MethodType::OneWay,
427                        })
428                    }
429                    _ if header
430                        .dynamic_flags()
431                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
432                    {
433                        this.inner.send_framework_err(
434                            fidl::encoding::FrameworkErr::UnknownMethod,
435                            header.tx_id,
436                            header.ordinal,
437                            header.dynamic_flags(),
438                            (bytes, handles),
439                        )?;
440                        Ok(FileMapperRequest::_UnknownMethod {
441                            ordinal: header.ordinal,
442                            control_handle: FileMapperControlHandle { inner: this.inner.clone() },
443                            method_type: fidl::MethodType::TwoWay,
444                        })
445                    }
446                    _ => Err(fidl::Error::UnknownOrdinal {
447                        ordinal: header.ordinal,
448                        protocol_name:
449                            <FileMapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
450                    }),
451                }))
452            },
453        )
454    }
455}
456
457#[derive(Debug)]
458pub enum FileMapperRequest {
459    /// Opens a child `MapperSession` backed by the file identified by `file_token`
460    /// (obtained from `fuchsia.io/Node.GetToken`).
461    OpenSession {
462        file_token: fidl::Event,
463        mapping_vmo: fidl::Vmo,
464        session: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
465        responder: FileMapperOpenSessionResponder,
466    },
467    /// An interaction was received which does not match any known method.
468    #[non_exhaustive]
469    _UnknownMethod {
470        /// Ordinal of the method that was called.
471        ordinal: u64,
472        control_handle: FileMapperControlHandle,
473        method_type: fidl::MethodType,
474    },
475}
476
477impl FileMapperRequest {
478    #[allow(irrefutable_let_patterns)]
479    pub fn into_open_session(
480        self,
481    ) -> Option<(
482        fidl::Event,
483        fidl::Vmo,
484        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
485        FileMapperOpenSessionResponder,
486    )> {
487        if let FileMapperRequest::OpenSession { file_token, mapping_vmo, session, responder } = self
488        {
489            Some((file_token, mapping_vmo, session, responder))
490        } else {
491            None
492        }
493    }
494
495    /// Name of the method defined in FIDL
496    pub fn method_name(&self) -> &'static str {
497        match *self {
498            FileMapperRequest::OpenSession { .. } => "open_session",
499            FileMapperRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
500                "unknown one-way method"
501            }
502            FileMapperRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
503                "unknown two-way method"
504            }
505        }
506    }
507}
508
509#[derive(Debug, Clone)]
510pub struct FileMapperControlHandle {
511    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
512}
513
514impl FileMapperControlHandle {
515    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
516        self.inner.shutdown_with_epitaph(status.into())
517    }
518}
519
520impl fidl::endpoints::ControlHandle for FileMapperControlHandle {
521    fn shutdown(&self) {
522        self.inner.shutdown()
523    }
524
525    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
526        self.inner.shutdown_with_epitaph(status)
527    }
528
529    fn is_closed(&self) -> bool {
530        self.inner.channel().is_closed()
531    }
532    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
533        self.inner.channel().on_closed()
534    }
535
536    #[cfg(target_os = "fuchsia")]
537    fn signal_peer(
538        &self,
539        clear_mask: zx::Signals,
540        set_mask: zx::Signals,
541    ) -> Result<(), zx_status::Status> {
542        use fidl::Peered;
543        self.inner.channel().signal_peer(clear_mask, set_mask)
544    }
545}
546
547impl FileMapperControlHandle {}
548
549#[must_use = "FIDL methods require a response to be sent"]
550#[derive(Debug)]
551pub struct FileMapperOpenSessionResponder {
552    control_handle: std::mem::ManuallyDrop<FileMapperControlHandle>,
553    tx_id: u32,
554}
555
556/// Set the the channel to be shutdown (see [`FileMapperControlHandle::shutdown`])
557/// if the responder is dropped without sending a response, so that the client
558/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
559impl std::ops::Drop for FileMapperOpenSessionResponder {
560    fn drop(&mut self) {
561        self.control_handle.shutdown();
562        // Safety: drops once, never accessed again
563        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
564    }
565}
566
567impl fidl::endpoints::Responder for FileMapperOpenSessionResponder {
568    type ControlHandle = FileMapperControlHandle;
569
570    fn control_handle(&self) -> &FileMapperControlHandle {
571        &self.control_handle
572    }
573
574    fn drop_without_shutdown(mut self) {
575        // Safety: drops once, never accessed again due to mem::forget
576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
577        // Prevent Drop from running (which would shut down the channel)
578        std::mem::forget(self);
579    }
580}
581
582impl FileMapperOpenSessionResponder {
583    /// Sends a response to the FIDL transaction.
584    ///
585    /// Sets the channel to shutdown if an error occurs.
586    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
587        let _result = self.send_raw(result);
588        if _result.is_err() {
589            self.control_handle.shutdown();
590        }
591        self.drop_without_shutdown();
592        _result
593    }
594
595    /// Similar to "send" but does not shutdown the channel if an error occurs.
596    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
597        let _result = self.send_raw(result);
598        self.drop_without_shutdown();
599        _result
600    }
601
602    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
603        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
604            fidl::encoding::EmptyStruct,
605            i32,
606        >>(
607            fidl::encoding::FlexibleResult::new(result),
608            self.tx_id,
609            0x1b4cfd70270fbc63,
610            fidl::encoding::DynamicFlags::FLEXIBLE,
611        )
612    }
613}
614
615#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
616pub struct MappingProviderMarker;
617
618impl fidl::endpoints::ProtocolMarker for MappingProviderMarker {
619    type Proxy = MappingProviderProxy;
620    type RequestStream = MappingProviderRequestStream;
621    #[cfg(target_os = "fuchsia")]
622    type SynchronousProxy = MappingProviderSynchronousProxy;
623
624    const DEBUG_NAME: &'static str = "fuchsia.storage.mapping.MappingProvider";
625}
626impl fidl::endpoints::DiscoverableProtocolMarker for MappingProviderMarker {}
627pub type MappingProviderOpenSessionResult = Result<fidl::Vmo, i32>;
628
629pub trait MappingProviderProxyInterface: Send + Sync {
630    type OpenSessionResponseFut: std::future::Future<Output = Result<MappingProviderOpenSessionResult, fidl::Error>>
631        + Send;
632    fn r#open_session(
633        &self,
634        session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
635    ) -> Self::OpenSessionResponseFut;
636}
637#[derive(Debug)]
638#[cfg(target_os = "fuchsia")]
639pub struct MappingProviderSynchronousProxy {
640    client: fidl::client::sync::Client,
641}
642
643#[cfg(target_os = "fuchsia")]
644impl fidl::endpoints::SynchronousProxy for MappingProviderSynchronousProxy {
645    type Proxy = MappingProviderProxy;
646    type Protocol = MappingProviderMarker;
647
648    fn from_channel(inner: fidl::Channel) -> Self {
649        Self::new(inner)
650    }
651
652    fn into_channel(self) -> fidl::Channel {
653        self.client.into_channel()
654    }
655
656    fn as_channel(&self) -> &fidl::Channel {
657        self.client.as_channel()
658    }
659}
660
661#[cfg(target_os = "fuchsia")]
662impl MappingProviderSynchronousProxy {
663    pub fn new(channel: fidl::Channel) -> Self {
664        Self { client: fidl::client::sync::Client::new(channel) }
665    }
666
667    pub fn into_channel(self) -> fidl::Channel {
668        self.client.into_channel()
669    }
670
671    /// Waits until an event arrives and returns it. It is safe for other
672    /// threads to make concurrent requests while waiting for an event.
673    pub fn wait_for_event(
674        &self,
675        deadline: zx::MonotonicInstant,
676    ) -> Result<MappingProviderEvent, fidl::Error> {
677        MappingProviderEvent::decode(self.client.wait_for_event::<MappingProviderMarker>(deadline)?)
678    }
679
680    /// Establishes a new mapping session, returning the mapping VMO.
681    pub fn r#open_session(
682        &self,
683        mut session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
684        ___deadline: zx::MonotonicInstant,
685    ) -> Result<MappingProviderOpenSessionResult, fidl::Error> {
686        let _response = self.client.send_query::<
687            MappingProviderOpenSessionRequest,
688            fidl::encoding::FlexibleResultType<MappingProviderOpenSessionResponse, i32>,
689            MappingProviderMarker,
690        >(
691            (session,),
692            0x392ee248d504919a,
693            fidl::encoding::DynamicFlags::FLEXIBLE,
694            ___deadline,
695        )?
696        .into_result::<MappingProviderMarker>("open_session")?;
697        Ok(_response.map(|x| x.mapping_vmo))
698    }
699}
700
701#[cfg(target_os = "fuchsia")]
702impl From<MappingProviderSynchronousProxy> for zx::NullableHandle {
703    fn from(value: MappingProviderSynchronousProxy) -> Self {
704        value.into_channel().into()
705    }
706}
707
708#[cfg(target_os = "fuchsia")]
709impl From<fidl::Channel> for MappingProviderSynchronousProxy {
710    fn from(value: fidl::Channel) -> Self {
711        Self::new(value)
712    }
713}
714
715#[cfg(target_os = "fuchsia")]
716impl fidl::endpoints::FromClient for MappingProviderSynchronousProxy {
717    type Protocol = MappingProviderMarker;
718
719    fn from_client(value: fidl::endpoints::ClientEnd<MappingProviderMarker>) -> Self {
720        Self::new(value.into_channel())
721    }
722}
723
724#[derive(Debug, Clone)]
725pub struct MappingProviderProxy {
726    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
727}
728
729impl fidl::endpoints::Proxy for MappingProviderProxy {
730    type Protocol = MappingProviderMarker;
731
732    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
733        Self::new(inner)
734    }
735
736    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
737        self.client.into_channel().map_err(|client| Self { client })
738    }
739
740    fn as_channel(&self) -> &::fidl::AsyncChannel {
741        self.client.as_channel()
742    }
743}
744
745impl MappingProviderProxy {
746    /// Create a new Proxy for fuchsia.storage.mapping/MappingProvider.
747    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
748        let protocol_name = <MappingProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
749        Self { client: fidl::client::Client::new(channel, protocol_name) }
750    }
751
752    /// Get a Stream of events from the remote end of the protocol.
753    ///
754    /// # Panics
755    ///
756    /// Panics if the event stream was already taken.
757    pub fn take_event_stream(&self) -> MappingProviderEventStream {
758        MappingProviderEventStream { event_receiver: self.client.take_event_receiver() }
759    }
760
761    /// Establishes a new mapping session, returning the mapping VMO.
762    pub fn r#open_session(
763        &self,
764        mut session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
765    ) -> fidl::client::QueryResponseFut<
766        MappingProviderOpenSessionResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    > {
769        MappingProviderProxyInterface::r#open_session(self, session)
770    }
771}
772
773impl MappingProviderProxyInterface for MappingProviderProxy {
774    type OpenSessionResponseFut = fidl::client::QueryResponseFut<
775        MappingProviderOpenSessionResult,
776        fidl::encoding::DefaultFuchsiaResourceDialect,
777    >;
778    fn r#open_session(
779        &self,
780        mut session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
781    ) -> Self::OpenSessionResponseFut {
782        fn _decode(
783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
784        ) -> Result<MappingProviderOpenSessionResult, fidl::Error> {
785            let _response = fidl::client::decode_transaction_body::<
786                fidl::encoding::FlexibleResultType<MappingProviderOpenSessionResponse, i32>,
787                fidl::encoding::DefaultFuchsiaResourceDialect,
788                0x392ee248d504919a,
789            >(_buf?)?
790            .into_result::<MappingProviderMarker>("open_session")?;
791            Ok(_response.map(|x| x.mapping_vmo))
792        }
793        self.client.send_query_and_decode::<
794            MappingProviderOpenSessionRequest,
795            MappingProviderOpenSessionResult,
796        >(
797            (session,),
798            0x392ee248d504919a,
799            fidl::encoding::DynamicFlags::FLEXIBLE,
800            _decode,
801        )
802    }
803}
804
805pub struct MappingProviderEventStream {
806    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
807}
808
809impl std::marker::Unpin for MappingProviderEventStream {}
810
811impl futures::stream::FusedStream for MappingProviderEventStream {
812    fn is_terminated(&self) -> bool {
813        self.event_receiver.is_terminated()
814    }
815}
816
817impl futures::Stream for MappingProviderEventStream {
818    type Item = Result<MappingProviderEvent, fidl::Error>;
819
820    fn poll_next(
821        mut self: std::pin::Pin<&mut Self>,
822        cx: &mut std::task::Context<'_>,
823    ) -> std::task::Poll<Option<Self::Item>> {
824        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
825            &mut self.event_receiver,
826            cx
827        )?) {
828            Some(buf) => std::task::Poll::Ready(Some(MappingProviderEvent::decode(buf))),
829            None => std::task::Poll::Ready(None),
830        }
831    }
832}
833
834#[derive(Debug)]
835pub enum MappingProviderEvent {
836    #[non_exhaustive]
837    _UnknownEvent {
838        /// Ordinal of the event that was sent.
839        ordinal: u64,
840    },
841}
842
843impl MappingProviderEvent {
844    /// Decodes a message buffer as a [`MappingProviderEvent`].
845    fn decode(
846        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
847    ) -> Result<MappingProviderEvent, fidl::Error> {
848        let (bytes, _handles) = buf.split_mut();
849        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
850        debug_assert_eq!(tx_header.tx_id, 0);
851        match tx_header.ordinal {
852            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
853                Ok(MappingProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
854            }
855            _ => Err(fidl::Error::UnknownOrdinal {
856                ordinal: tx_header.ordinal,
857                protocol_name:
858                    <MappingProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
859            }),
860        }
861    }
862}
863
864/// A Stream of incoming requests for fuchsia.storage.mapping/MappingProvider.
865pub struct MappingProviderRequestStream {
866    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
867    is_terminated: bool,
868}
869
870impl std::marker::Unpin for MappingProviderRequestStream {}
871
872impl futures::stream::FusedStream for MappingProviderRequestStream {
873    fn is_terminated(&self) -> bool {
874        self.is_terminated
875    }
876}
877
878impl fidl::endpoints::RequestStream for MappingProviderRequestStream {
879    type Protocol = MappingProviderMarker;
880    type ControlHandle = MappingProviderControlHandle;
881
882    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
883        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
884    }
885
886    fn control_handle(&self) -> Self::ControlHandle {
887        MappingProviderControlHandle { inner: self.inner.clone() }
888    }
889
890    fn into_inner(
891        self,
892    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
893    {
894        (self.inner, self.is_terminated)
895    }
896
897    fn from_inner(
898        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
899        is_terminated: bool,
900    ) -> Self {
901        Self { inner, is_terminated }
902    }
903}
904
905impl futures::Stream for MappingProviderRequestStream {
906    type Item = Result<MappingProviderRequest, fidl::Error>;
907
908    fn poll_next(
909        mut self: std::pin::Pin<&mut Self>,
910        cx: &mut std::task::Context<'_>,
911    ) -> std::task::Poll<Option<Self::Item>> {
912        let this = &mut *self;
913        if this.inner.check_shutdown(cx) {
914            this.is_terminated = true;
915            return std::task::Poll::Ready(None);
916        }
917        if this.is_terminated {
918            panic!("polled MappingProviderRequestStream after completion");
919        }
920        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
921            |bytes, handles| {
922                match this.inner.channel().read_etc(cx, bytes, handles) {
923                    std::task::Poll::Ready(Ok(())) => {}
924                    std::task::Poll::Pending => return std::task::Poll::Pending,
925                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
926                        this.is_terminated = true;
927                        return std::task::Poll::Ready(None);
928                    }
929                    std::task::Poll::Ready(Err(e)) => {
930                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
931                            e.into(),
932                        ))));
933                    }
934                }
935
936                // A message has been received from the channel
937                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
938
939                std::task::Poll::Ready(Some(match header.ordinal {
940                    0x392ee248d504919a => {
941                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
942                        let mut req = fidl::new_empty!(
943                            MappingProviderOpenSessionRequest,
944                            fidl::encoding::DefaultFuchsiaResourceDialect
945                        );
946                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MappingProviderOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
947                        let control_handle =
948                            MappingProviderControlHandle { inner: this.inner.clone() };
949                        Ok(MappingProviderRequest::OpenSession {
950                            session: req.session,
951
952                            responder: MappingProviderOpenSessionResponder {
953                                control_handle: std::mem::ManuallyDrop::new(control_handle),
954                                tx_id: header.tx_id,
955                            },
956                        })
957                    }
958                    _ if header.tx_id == 0
959                        && header
960                            .dynamic_flags()
961                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
962                    {
963                        Ok(MappingProviderRequest::_UnknownMethod {
964                            ordinal: header.ordinal,
965                            control_handle: MappingProviderControlHandle {
966                                inner: this.inner.clone(),
967                            },
968                            method_type: fidl::MethodType::OneWay,
969                        })
970                    }
971                    _ if header
972                        .dynamic_flags()
973                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
974                    {
975                        this.inner.send_framework_err(
976                            fidl::encoding::FrameworkErr::UnknownMethod,
977                            header.tx_id,
978                            header.ordinal,
979                            header.dynamic_flags(),
980                            (bytes, handles),
981                        )?;
982                        Ok(MappingProviderRequest::_UnknownMethod {
983                            ordinal: header.ordinal,
984                            control_handle: MappingProviderControlHandle {
985                                inner: this.inner.clone(),
986                            },
987                            method_type: fidl::MethodType::TwoWay,
988                        })
989                    }
990                    _ => Err(fidl::Error::UnknownOrdinal {
991                        ordinal: header.ordinal,
992                        protocol_name:
993                            <MappingProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
994                    }),
995                }))
996            },
997        )
998    }
999}
1000
1001#[derive(Debug)]
1002pub enum MappingProviderRequest {
1003    /// Establishes a new mapping session, returning the mapping VMO.
1004    OpenSession {
1005        session: fidl::endpoints::ServerEnd<MappingSessionMarker>,
1006        responder: MappingProviderOpenSessionResponder,
1007    },
1008    /// An interaction was received which does not match any known method.
1009    #[non_exhaustive]
1010    _UnknownMethod {
1011        /// Ordinal of the method that was called.
1012        ordinal: u64,
1013        control_handle: MappingProviderControlHandle,
1014        method_type: fidl::MethodType,
1015    },
1016}
1017
1018impl MappingProviderRequest {
1019    #[allow(irrefutable_let_patterns)]
1020    pub fn into_open_session(
1021        self,
1022    ) -> Option<(
1023        fidl::endpoints::ServerEnd<MappingSessionMarker>,
1024        MappingProviderOpenSessionResponder,
1025    )> {
1026        if let MappingProviderRequest::OpenSession { session, responder } = self {
1027            Some((session, responder))
1028        } else {
1029            None
1030        }
1031    }
1032
1033    /// Name of the method defined in FIDL
1034    pub fn method_name(&self) -> &'static str {
1035        match *self {
1036            MappingProviderRequest::OpenSession { .. } => "open_session",
1037            MappingProviderRequest::_UnknownMethod {
1038                method_type: fidl::MethodType::OneWay,
1039                ..
1040            } => "unknown one-way method",
1041            MappingProviderRequest::_UnknownMethod {
1042                method_type: fidl::MethodType::TwoWay,
1043                ..
1044            } => "unknown two-way method",
1045        }
1046    }
1047}
1048
1049#[derive(Debug, Clone)]
1050pub struct MappingProviderControlHandle {
1051    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1052}
1053
1054impl MappingProviderControlHandle {
1055    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1056        self.inner.shutdown_with_epitaph(status.into())
1057    }
1058}
1059
1060impl fidl::endpoints::ControlHandle for MappingProviderControlHandle {
1061    fn shutdown(&self) {
1062        self.inner.shutdown()
1063    }
1064
1065    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1066        self.inner.shutdown_with_epitaph(status)
1067    }
1068
1069    fn is_closed(&self) -> bool {
1070        self.inner.channel().is_closed()
1071    }
1072    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1073        self.inner.channel().on_closed()
1074    }
1075
1076    #[cfg(target_os = "fuchsia")]
1077    fn signal_peer(
1078        &self,
1079        clear_mask: zx::Signals,
1080        set_mask: zx::Signals,
1081    ) -> Result<(), zx_status::Status> {
1082        use fidl::Peered;
1083        self.inner.channel().signal_peer(clear_mask, set_mask)
1084    }
1085}
1086
1087impl MappingProviderControlHandle {}
1088
1089#[must_use = "FIDL methods require a response to be sent"]
1090#[derive(Debug)]
1091pub struct MappingProviderOpenSessionResponder {
1092    control_handle: std::mem::ManuallyDrop<MappingProviderControlHandle>,
1093    tx_id: u32,
1094}
1095
1096/// Set the the channel to be shutdown (see [`MappingProviderControlHandle::shutdown`])
1097/// if the responder is dropped without sending a response, so that the client
1098/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1099impl std::ops::Drop for MappingProviderOpenSessionResponder {
1100    fn drop(&mut self) {
1101        self.control_handle.shutdown();
1102        // Safety: drops once, never accessed again
1103        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1104    }
1105}
1106
1107impl fidl::endpoints::Responder for MappingProviderOpenSessionResponder {
1108    type ControlHandle = MappingProviderControlHandle;
1109
1110    fn control_handle(&self) -> &MappingProviderControlHandle {
1111        &self.control_handle
1112    }
1113
1114    fn drop_without_shutdown(mut self) {
1115        // Safety: drops once, never accessed again due to mem::forget
1116        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1117        // Prevent Drop from running (which would shut down the channel)
1118        std::mem::forget(self);
1119    }
1120}
1121
1122impl MappingProviderOpenSessionResponder {
1123    /// Sends a response to the FIDL transaction.
1124    ///
1125    /// Sets the channel to shutdown if an error occurs.
1126    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1127        let _result = self.send_raw(result);
1128        if _result.is_err() {
1129            self.control_handle.shutdown();
1130        }
1131        self.drop_without_shutdown();
1132        _result
1133    }
1134
1135    /// Similar to "send" but does not shutdown the channel if an error occurs.
1136    pub fn send_no_shutdown_on_err(
1137        self,
1138        mut result: Result<fidl::Vmo, i32>,
1139    ) -> Result<(), fidl::Error> {
1140        let _result = self.send_raw(result);
1141        self.drop_without_shutdown();
1142        _result
1143    }
1144
1145    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1146        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1147            MappingProviderOpenSessionResponse,
1148            i32,
1149        >>(
1150            fidl::encoding::FlexibleResult::new(result.map(|mapping_vmo| (mapping_vmo,))),
1151            self.tx_id,
1152            0x392ee248d504919a,
1153            fidl::encoding::DynamicFlags::FLEXIBLE,
1154        )
1155    }
1156}
1157
1158#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1159pub struct MappingSessionMarker;
1160
1161impl fidl::endpoints::ProtocolMarker for MappingSessionMarker {
1162    type Proxy = MappingSessionProxy;
1163    type RequestStream = MappingSessionRequestStream;
1164    #[cfg(target_os = "fuchsia")]
1165    type SynchronousProxy = MappingSessionSynchronousProxy;
1166
1167    const DEBUG_NAME: &'static str = "(anonymous) MappingSession";
1168}
1169pub type MappingSessionOpenResult = Result<u64, i32>;
1170pub type MappingSessionCloseResult = Result<(), i32>;
1171pub type MappingSessionGetProfileResult = Result<fidl::Vmo, i32>;
1172pub type MappingSessionWriteProfileResult = Result<(), i32>;
1173
1174pub trait MappingSessionProxyInterface: Send + Sync {
1175    type OpenResponseFut: std::future::Future<Output = Result<MappingSessionOpenResult, fidl::Error>>
1176        + Send;
1177    fn r#open(&self, key: u64, identifier: &[u8]) -> Self::OpenResponseFut;
1178    type CloseResponseFut: std::future::Future<Output = Result<MappingSessionCloseResult, fidl::Error>>
1179        + Send;
1180    fn r#close(&self, key: u64) -> Self::CloseResponseFut;
1181    type GetProfileResponseFut: std::future::Future<Output = Result<MappingSessionGetProfileResult, fidl::Error>>
1182        + Send;
1183    fn r#get_profile(&self, name: &str) -> Self::GetProfileResponseFut;
1184    type WriteProfileResponseFut: std::future::Future<Output = Result<MappingSessionWriteProfileResult, fidl::Error>>
1185        + Send;
1186    fn r#write_profile(&self, name: &str, profile_vmo: fidl::Vmo) -> Self::WriteProfileResponseFut;
1187}
1188#[derive(Debug)]
1189#[cfg(target_os = "fuchsia")]
1190pub struct MappingSessionSynchronousProxy {
1191    client: fidl::client::sync::Client,
1192}
1193
1194#[cfg(target_os = "fuchsia")]
1195impl fidl::endpoints::SynchronousProxy for MappingSessionSynchronousProxy {
1196    type Proxy = MappingSessionProxy;
1197    type Protocol = MappingSessionMarker;
1198
1199    fn from_channel(inner: fidl::Channel) -> Self {
1200        Self::new(inner)
1201    }
1202
1203    fn into_channel(self) -> fidl::Channel {
1204        self.client.into_channel()
1205    }
1206
1207    fn as_channel(&self) -> &fidl::Channel {
1208        self.client.as_channel()
1209    }
1210}
1211
1212#[cfg(target_os = "fuchsia")]
1213impl MappingSessionSynchronousProxy {
1214    pub fn new(channel: fidl::Channel) -> Self {
1215        Self { client: fidl::client::sync::Client::new(channel) }
1216    }
1217
1218    pub fn into_channel(self) -> fidl::Channel {
1219        self.client.into_channel()
1220    }
1221
1222    /// Waits until an event arrives and returns it. It is safe for other
1223    /// threads to make concurrent requests while waiting for an event.
1224    pub fn wait_for_event(
1225        &self,
1226        deadline: zx::MonotonicInstant,
1227    ) -> Result<MappingSessionEvent, fidl::Error> {
1228        MappingSessionEvent::decode(self.client.wait_for_event::<MappingSessionMarker>(deadline)?)
1229    }
1230
1231    /// Registers a node's extents in the mapping session, returning its uncompressed size in bytes.
1232    ///
1233    /// The filesystem resolves the `identifier` to locate the node on disk and transmits its
1234    /// extent mappings to the block driver associated with `key`.
1235    pub fn r#open(
1236        &self,
1237        mut key: u64,
1238        mut identifier: &[u8],
1239        ___deadline: zx::MonotonicInstant,
1240    ) -> Result<MappingSessionOpenResult, fidl::Error> {
1241        let _response = self.client.send_query::<
1242            MappingSessionOpenRequest,
1243            fidl::encoding::FlexibleResultType<MappingSessionOpenResponse, i32>,
1244            MappingSessionMarker,
1245        >(
1246            (key, identifier,),
1247            0x1b3f5b2b1e68472b,
1248            fidl::encoding::DynamicFlags::FLEXIBLE,
1249            ___deadline,
1250        )?
1251        .into_result::<MappingSessionMarker>("open")?;
1252        Ok(_response.map(|x| x.size))
1253    }
1254
1255    /// Unregisters a node's extents from the session by its session-unique key.
1256    pub fn r#close(
1257        &self,
1258        mut key: u64,
1259        ___deadline: zx::MonotonicInstant,
1260    ) -> Result<MappingSessionCloseResult, fidl::Error> {
1261        let _response = self.client.send_query::<
1262            MappingSessionCloseRequest,
1263            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1264            MappingSessionMarker,
1265        >(
1266            (key,),
1267            0x34708ae0c1044d20,
1268            fidl::encoding::DynamicFlags::FLEXIBLE,
1269            ___deadline,
1270        )?
1271        .into_result::<MappingSessionMarker>("close")?;
1272        Ok(_response.map(|x| x))
1273    }
1274
1275    /// Reads the named profile from the volume into a VMO, or returns `ZX_ERR_NOT_FOUND` if the
1276    /// profile does not exist.
1277    pub fn r#get_profile(
1278        &self,
1279        mut name: &str,
1280        ___deadline: zx::MonotonicInstant,
1281    ) -> Result<MappingSessionGetProfileResult, fidl::Error> {
1282        let _response = self.client.send_query::<
1283            MappingSessionGetProfileRequest,
1284            fidl::encoding::FlexibleResultType<MappingSessionGetProfileResponse, i32>,
1285            MappingSessionMarker,
1286        >(
1287            (name,),
1288            0x282c8645f3a3f77f,
1289            fidl::encoding::DynamicFlags::FLEXIBLE,
1290            ___deadline,
1291        )?
1292        .into_result::<MappingSessionMarker>("get_profile")?;
1293        Ok(_response.map(|x| x.profile_vmo))
1294    }
1295
1296    /// Writes `profile_vmo` as the named profile on the volume.
1297    pub fn r#write_profile(
1298        &self,
1299        mut name: &str,
1300        mut profile_vmo: fidl::Vmo,
1301        ___deadline: zx::MonotonicInstant,
1302    ) -> Result<MappingSessionWriteProfileResult, fidl::Error> {
1303        let _response = self.client.send_query::<
1304            MappingSessionWriteProfileRequest,
1305            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1306            MappingSessionMarker,
1307        >(
1308            (name, profile_vmo,),
1309            0x1ee027e4661e86de,
1310            fidl::encoding::DynamicFlags::FLEXIBLE,
1311            ___deadline,
1312        )?
1313        .into_result::<MappingSessionMarker>("write_profile")?;
1314        Ok(_response.map(|x| x))
1315    }
1316}
1317
1318#[cfg(target_os = "fuchsia")]
1319impl From<MappingSessionSynchronousProxy> for zx::NullableHandle {
1320    fn from(value: MappingSessionSynchronousProxy) -> Self {
1321        value.into_channel().into()
1322    }
1323}
1324
1325#[cfg(target_os = "fuchsia")]
1326impl From<fidl::Channel> for MappingSessionSynchronousProxy {
1327    fn from(value: fidl::Channel) -> Self {
1328        Self::new(value)
1329    }
1330}
1331
1332#[cfg(target_os = "fuchsia")]
1333impl fidl::endpoints::FromClient for MappingSessionSynchronousProxy {
1334    type Protocol = MappingSessionMarker;
1335
1336    fn from_client(value: fidl::endpoints::ClientEnd<MappingSessionMarker>) -> Self {
1337        Self::new(value.into_channel())
1338    }
1339}
1340
1341#[derive(Debug, Clone)]
1342pub struct MappingSessionProxy {
1343    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1344}
1345
1346impl fidl::endpoints::Proxy for MappingSessionProxy {
1347    type Protocol = MappingSessionMarker;
1348
1349    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1350        Self::new(inner)
1351    }
1352
1353    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1354        self.client.into_channel().map_err(|client| Self { client })
1355    }
1356
1357    fn as_channel(&self) -> &::fidl::AsyncChannel {
1358        self.client.as_channel()
1359    }
1360}
1361
1362impl MappingSessionProxy {
1363    /// Create a new Proxy for fuchsia.storage.mapping/MappingSession.
1364    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1365        let protocol_name = <MappingSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1366        Self { client: fidl::client::Client::new(channel, protocol_name) }
1367    }
1368
1369    /// Get a Stream of events from the remote end of the protocol.
1370    ///
1371    /// # Panics
1372    ///
1373    /// Panics if the event stream was already taken.
1374    pub fn take_event_stream(&self) -> MappingSessionEventStream {
1375        MappingSessionEventStream { event_receiver: self.client.take_event_receiver() }
1376    }
1377
1378    /// Registers a node's extents in the mapping session, returning its uncompressed size in bytes.
1379    ///
1380    /// The filesystem resolves the `identifier` to locate the node on disk and transmits its
1381    /// extent mappings to the block driver associated with `key`.
1382    pub fn r#open(
1383        &self,
1384        mut key: u64,
1385        mut identifier: &[u8],
1386    ) -> fidl::client::QueryResponseFut<
1387        MappingSessionOpenResult,
1388        fidl::encoding::DefaultFuchsiaResourceDialect,
1389    > {
1390        MappingSessionProxyInterface::r#open(self, key, identifier)
1391    }
1392
1393    /// Unregisters a node's extents from the session by its session-unique key.
1394    pub fn r#close(
1395        &self,
1396        mut key: u64,
1397    ) -> fidl::client::QueryResponseFut<
1398        MappingSessionCloseResult,
1399        fidl::encoding::DefaultFuchsiaResourceDialect,
1400    > {
1401        MappingSessionProxyInterface::r#close(self, key)
1402    }
1403
1404    /// Reads the named profile from the volume into a VMO, or returns `ZX_ERR_NOT_FOUND` if the
1405    /// profile does not exist.
1406    pub fn r#get_profile(
1407        &self,
1408        mut name: &str,
1409    ) -> fidl::client::QueryResponseFut<
1410        MappingSessionGetProfileResult,
1411        fidl::encoding::DefaultFuchsiaResourceDialect,
1412    > {
1413        MappingSessionProxyInterface::r#get_profile(self, name)
1414    }
1415
1416    /// Writes `profile_vmo` as the named profile on the volume.
1417    pub fn r#write_profile(
1418        &self,
1419        mut name: &str,
1420        mut profile_vmo: fidl::Vmo,
1421    ) -> fidl::client::QueryResponseFut<
1422        MappingSessionWriteProfileResult,
1423        fidl::encoding::DefaultFuchsiaResourceDialect,
1424    > {
1425        MappingSessionProxyInterface::r#write_profile(self, name, profile_vmo)
1426    }
1427}
1428
1429impl MappingSessionProxyInterface for MappingSessionProxy {
1430    type OpenResponseFut = fidl::client::QueryResponseFut<
1431        MappingSessionOpenResult,
1432        fidl::encoding::DefaultFuchsiaResourceDialect,
1433    >;
1434    fn r#open(&self, mut key: u64, mut identifier: &[u8]) -> Self::OpenResponseFut {
1435        fn _decode(
1436            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1437        ) -> Result<MappingSessionOpenResult, fidl::Error> {
1438            let _response = fidl::client::decode_transaction_body::<
1439                fidl::encoding::FlexibleResultType<MappingSessionOpenResponse, i32>,
1440                fidl::encoding::DefaultFuchsiaResourceDialect,
1441                0x1b3f5b2b1e68472b,
1442            >(_buf?)?
1443            .into_result::<MappingSessionMarker>("open")?;
1444            Ok(_response.map(|x| x.size))
1445        }
1446        self.client.send_query_and_decode::<MappingSessionOpenRequest, MappingSessionOpenResult>(
1447            (key, identifier),
1448            0x1b3f5b2b1e68472b,
1449            fidl::encoding::DynamicFlags::FLEXIBLE,
1450            _decode,
1451        )
1452    }
1453
1454    type CloseResponseFut = fidl::client::QueryResponseFut<
1455        MappingSessionCloseResult,
1456        fidl::encoding::DefaultFuchsiaResourceDialect,
1457    >;
1458    fn r#close(&self, mut key: u64) -> Self::CloseResponseFut {
1459        fn _decode(
1460            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1461        ) -> Result<MappingSessionCloseResult, fidl::Error> {
1462            let _response = fidl::client::decode_transaction_body::<
1463                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1464                fidl::encoding::DefaultFuchsiaResourceDialect,
1465                0x34708ae0c1044d20,
1466            >(_buf?)?
1467            .into_result::<MappingSessionMarker>("close")?;
1468            Ok(_response.map(|x| x))
1469        }
1470        self.client.send_query_and_decode::<MappingSessionCloseRequest, MappingSessionCloseResult>(
1471            (key,),
1472            0x34708ae0c1044d20,
1473            fidl::encoding::DynamicFlags::FLEXIBLE,
1474            _decode,
1475        )
1476    }
1477
1478    type GetProfileResponseFut = fidl::client::QueryResponseFut<
1479        MappingSessionGetProfileResult,
1480        fidl::encoding::DefaultFuchsiaResourceDialect,
1481    >;
1482    fn r#get_profile(&self, mut name: &str) -> Self::GetProfileResponseFut {
1483        fn _decode(
1484            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1485        ) -> Result<MappingSessionGetProfileResult, fidl::Error> {
1486            let _response = fidl::client::decode_transaction_body::<
1487                fidl::encoding::FlexibleResultType<MappingSessionGetProfileResponse, i32>,
1488                fidl::encoding::DefaultFuchsiaResourceDialect,
1489                0x282c8645f3a3f77f,
1490            >(_buf?)?
1491            .into_result::<MappingSessionMarker>("get_profile")?;
1492            Ok(_response.map(|x| x.profile_vmo))
1493        }
1494        self.client.send_query_and_decode::<
1495            MappingSessionGetProfileRequest,
1496            MappingSessionGetProfileResult,
1497        >(
1498            (name,),
1499            0x282c8645f3a3f77f,
1500            fidl::encoding::DynamicFlags::FLEXIBLE,
1501            _decode,
1502        )
1503    }
1504
1505    type WriteProfileResponseFut = fidl::client::QueryResponseFut<
1506        MappingSessionWriteProfileResult,
1507        fidl::encoding::DefaultFuchsiaResourceDialect,
1508    >;
1509    fn r#write_profile(
1510        &self,
1511        mut name: &str,
1512        mut profile_vmo: fidl::Vmo,
1513    ) -> Self::WriteProfileResponseFut {
1514        fn _decode(
1515            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1516        ) -> Result<MappingSessionWriteProfileResult, fidl::Error> {
1517            let _response = fidl::client::decode_transaction_body::<
1518                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1519                fidl::encoding::DefaultFuchsiaResourceDialect,
1520                0x1ee027e4661e86de,
1521            >(_buf?)?
1522            .into_result::<MappingSessionMarker>("write_profile")?;
1523            Ok(_response.map(|x| x))
1524        }
1525        self.client.send_query_and_decode::<
1526            MappingSessionWriteProfileRequest,
1527            MappingSessionWriteProfileResult,
1528        >(
1529            (name, profile_vmo,),
1530            0x1ee027e4661e86de,
1531            fidl::encoding::DynamicFlags::FLEXIBLE,
1532            _decode,
1533        )
1534    }
1535}
1536
1537pub struct MappingSessionEventStream {
1538    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1539}
1540
1541impl std::marker::Unpin for MappingSessionEventStream {}
1542
1543impl futures::stream::FusedStream for MappingSessionEventStream {
1544    fn is_terminated(&self) -> bool {
1545        self.event_receiver.is_terminated()
1546    }
1547}
1548
1549impl futures::Stream for MappingSessionEventStream {
1550    type Item = Result<MappingSessionEvent, fidl::Error>;
1551
1552    fn poll_next(
1553        mut self: std::pin::Pin<&mut Self>,
1554        cx: &mut std::task::Context<'_>,
1555    ) -> std::task::Poll<Option<Self::Item>> {
1556        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1557            &mut self.event_receiver,
1558            cx
1559        )?) {
1560            Some(buf) => std::task::Poll::Ready(Some(MappingSessionEvent::decode(buf))),
1561            None => std::task::Poll::Ready(None),
1562        }
1563    }
1564}
1565
1566#[derive(Debug)]
1567pub enum MappingSessionEvent {
1568    #[non_exhaustive]
1569    _UnknownEvent {
1570        /// Ordinal of the event that was sent.
1571        ordinal: u64,
1572    },
1573}
1574
1575impl MappingSessionEvent {
1576    /// Decodes a message buffer as a [`MappingSessionEvent`].
1577    fn decode(
1578        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1579    ) -> Result<MappingSessionEvent, fidl::Error> {
1580        let (bytes, _handles) = buf.split_mut();
1581        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1582        debug_assert_eq!(tx_header.tx_id, 0);
1583        match tx_header.ordinal {
1584            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1585                Ok(MappingSessionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1586            }
1587            _ => Err(fidl::Error::UnknownOrdinal {
1588                ordinal: tx_header.ordinal,
1589                protocol_name:
1590                    <MappingSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1591            }),
1592        }
1593    }
1594}
1595
1596/// A Stream of incoming requests for fuchsia.storage.mapping/MappingSession.
1597pub struct MappingSessionRequestStream {
1598    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1599    is_terminated: bool,
1600}
1601
1602impl std::marker::Unpin for MappingSessionRequestStream {}
1603
1604impl futures::stream::FusedStream for MappingSessionRequestStream {
1605    fn is_terminated(&self) -> bool {
1606        self.is_terminated
1607    }
1608}
1609
1610impl fidl::endpoints::RequestStream for MappingSessionRequestStream {
1611    type Protocol = MappingSessionMarker;
1612    type ControlHandle = MappingSessionControlHandle;
1613
1614    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1615        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1616    }
1617
1618    fn control_handle(&self) -> Self::ControlHandle {
1619        MappingSessionControlHandle { inner: self.inner.clone() }
1620    }
1621
1622    fn into_inner(
1623        self,
1624    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1625    {
1626        (self.inner, self.is_terminated)
1627    }
1628
1629    fn from_inner(
1630        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1631        is_terminated: bool,
1632    ) -> Self {
1633        Self { inner, is_terminated }
1634    }
1635}
1636
1637impl futures::Stream for MappingSessionRequestStream {
1638    type Item = Result<MappingSessionRequest, fidl::Error>;
1639
1640    fn poll_next(
1641        mut self: std::pin::Pin<&mut Self>,
1642        cx: &mut std::task::Context<'_>,
1643    ) -> std::task::Poll<Option<Self::Item>> {
1644        let this = &mut *self;
1645        if this.inner.check_shutdown(cx) {
1646            this.is_terminated = true;
1647            return std::task::Poll::Ready(None);
1648        }
1649        if this.is_terminated {
1650            panic!("polled MappingSessionRequestStream after completion");
1651        }
1652        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1653            |bytes, handles| {
1654                match this.inner.channel().read_etc(cx, bytes, handles) {
1655                    std::task::Poll::Ready(Ok(())) => {}
1656                    std::task::Poll::Pending => return std::task::Poll::Pending,
1657                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1658                        this.is_terminated = true;
1659                        return std::task::Poll::Ready(None);
1660                    }
1661                    std::task::Poll::Ready(Err(e)) => {
1662                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1663                            e.into(),
1664                        ))));
1665                    }
1666                }
1667
1668                // A message has been received from the channel
1669                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1670
1671                std::task::Poll::Ready(Some(match header.ordinal {
1672                    0x1b3f5b2b1e68472b => {
1673                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1674                        let mut req = fidl::new_empty!(
1675                            MappingSessionOpenRequest,
1676                            fidl::encoding::DefaultFuchsiaResourceDialect
1677                        );
1678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MappingSessionOpenRequest>(&header, _body_bytes, handles, &mut req)?;
1679                        let control_handle =
1680                            MappingSessionControlHandle { inner: this.inner.clone() };
1681                        Ok(MappingSessionRequest::Open {
1682                            key: req.key,
1683                            identifier: req.identifier,
1684
1685                            responder: MappingSessionOpenResponder {
1686                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1687                                tx_id: header.tx_id,
1688                            },
1689                        })
1690                    }
1691                    0x34708ae0c1044d20 => {
1692                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1693                        let mut req = fidl::new_empty!(
1694                            MappingSessionCloseRequest,
1695                            fidl::encoding::DefaultFuchsiaResourceDialect
1696                        );
1697                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MappingSessionCloseRequest>(&header, _body_bytes, handles, &mut req)?;
1698                        let control_handle =
1699                            MappingSessionControlHandle { inner: this.inner.clone() };
1700                        Ok(MappingSessionRequest::Close {
1701                            key: req.key,
1702
1703                            responder: MappingSessionCloseResponder {
1704                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1705                                tx_id: header.tx_id,
1706                            },
1707                        })
1708                    }
1709                    0x282c8645f3a3f77f => {
1710                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1711                        let mut req = fidl::new_empty!(
1712                            MappingSessionGetProfileRequest,
1713                            fidl::encoding::DefaultFuchsiaResourceDialect
1714                        );
1715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MappingSessionGetProfileRequest>(&header, _body_bytes, handles, &mut req)?;
1716                        let control_handle =
1717                            MappingSessionControlHandle { inner: this.inner.clone() };
1718                        Ok(MappingSessionRequest::GetProfile {
1719                            name: req.name,
1720
1721                            responder: MappingSessionGetProfileResponder {
1722                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1723                                tx_id: header.tx_id,
1724                            },
1725                        })
1726                    }
1727                    0x1ee027e4661e86de => {
1728                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1729                        let mut req = fidl::new_empty!(
1730                            MappingSessionWriteProfileRequest,
1731                            fidl::encoding::DefaultFuchsiaResourceDialect
1732                        );
1733                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MappingSessionWriteProfileRequest>(&header, _body_bytes, handles, &mut req)?;
1734                        let control_handle =
1735                            MappingSessionControlHandle { inner: this.inner.clone() };
1736                        Ok(MappingSessionRequest::WriteProfile {
1737                            name: req.name,
1738                            profile_vmo: req.profile_vmo,
1739
1740                            responder: MappingSessionWriteProfileResponder {
1741                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1742                                tx_id: header.tx_id,
1743                            },
1744                        })
1745                    }
1746                    _ if header.tx_id == 0
1747                        && header
1748                            .dynamic_flags()
1749                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1750                    {
1751                        Ok(MappingSessionRequest::_UnknownMethod {
1752                            ordinal: header.ordinal,
1753                            control_handle: MappingSessionControlHandle {
1754                                inner: this.inner.clone(),
1755                            },
1756                            method_type: fidl::MethodType::OneWay,
1757                        })
1758                    }
1759                    _ if header
1760                        .dynamic_flags()
1761                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1762                    {
1763                        this.inner.send_framework_err(
1764                            fidl::encoding::FrameworkErr::UnknownMethod,
1765                            header.tx_id,
1766                            header.ordinal,
1767                            header.dynamic_flags(),
1768                            (bytes, handles),
1769                        )?;
1770                        Ok(MappingSessionRequest::_UnknownMethod {
1771                            ordinal: header.ordinal,
1772                            control_handle: MappingSessionControlHandle {
1773                                inner: this.inner.clone(),
1774                            },
1775                            method_type: fidl::MethodType::TwoWay,
1776                        })
1777                    }
1778                    _ => Err(fidl::Error::UnknownOrdinal {
1779                        ordinal: header.ordinal,
1780                        protocol_name:
1781                            <MappingSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1782                    }),
1783                }))
1784            },
1785        )
1786    }
1787}
1788
1789#[derive(Debug)]
1790pub enum MappingSessionRequest {
1791    /// Registers a node's extents in the mapping session, returning its uncompressed size in bytes.
1792    ///
1793    /// The filesystem resolves the `identifier` to locate the node on disk and transmits its
1794    /// extent mappings to the block driver associated with `key`.
1795    Open { key: u64, identifier: Vec<u8>, responder: MappingSessionOpenResponder },
1796    /// Unregisters a node's extents from the session by its session-unique key.
1797    Close { key: u64, responder: MappingSessionCloseResponder },
1798    /// Reads the named profile from the volume into a VMO, or returns `ZX_ERR_NOT_FOUND` if the
1799    /// profile does not exist.
1800    GetProfile { name: String, responder: MappingSessionGetProfileResponder },
1801    /// Writes `profile_vmo` as the named profile on the volume.
1802    WriteProfile {
1803        name: String,
1804        profile_vmo: fidl::Vmo,
1805        responder: MappingSessionWriteProfileResponder,
1806    },
1807    /// An interaction was received which does not match any known method.
1808    #[non_exhaustive]
1809    _UnknownMethod {
1810        /// Ordinal of the method that was called.
1811        ordinal: u64,
1812        control_handle: MappingSessionControlHandle,
1813        method_type: fidl::MethodType,
1814    },
1815}
1816
1817impl MappingSessionRequest {
1818    #[allow(irrefutable_let_patterns)]
1819    pub fn into_open(self) -> Option<(u64, Vec<u8>, MappingSessionOpenResponder)> {
1820        if let MappingSessionRequest::Open { key, identifier, responder } = self {
1821            Some((key, identifier, responder))
1822        } else {
1823            None
1824        }
1825    }
1826
1827    #[allow(irrefutable_let_patterns)]
1828    pub fn into_close(self) -> Option<(u64, MappingSessionCloseResponder)> {
1829        if let MappingSessionRequest::Close { key, responder } = self {
1830            Some((key, responder))
1831        } else {
1832            None
1833        }
1834    }
1835
1836    #[allow(irrefutable_let_patterns)]
1837    pub fn into_get_profile(self) -> Option<(String, MappingSessionGetProfileResponder)> {
1838        if let MappingSessionRequest::GetProfile { name, responder } = self {
1839            Some((name, responder))
1840        } else {
1841            None
1842        }
1843    }
1844
1845    #[allow(irrefutable_let_patterns)]
1846    pub fn into_write_profile(
1847        self,
1848    ) -> Option<(String, fidl::Vmo, MappingSessionWriteProfileResponder)> {
1849        if let MappingSessionRequest::WriteProfile { name, profile_vmo, responder } = self {
1850            Some((name, profile_vmo, responder))
1851        } else {
1852            None
1853        }
1854    }
1855
1856    /// Name of the method defined in FIDL
1857    pub fn method_name(&self) -> &'static str {
1858        match *self {
1859            MappingSessionRequest::Open { .. } => "open",
1860            MappingSessionRequest::Close { .. } => "close",
1861            MappingSessionRequest::GetProfile { .. } => "get_profile",
1862            MappingSessionRequest::WriteProfile { .. } => "write_profile",
1863            MappingSessionRequest::_UnknownMethod {
1864                method_type: fidl::MethodType::OneWay, ..
1865            } => "unknown one-way method",
1866            MappingSessionRequest::_UnknownMethod {
1867                method_type: fidl::MethodType::TwoWay, ..
1868            } => "unknown two-way method",
1869        }
1870    }
1871}
1872
1873#[derive(Debug, Clone)]
1874pub struct MappingSessionControlHandle {
1875    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1876}
1877
1878impl MappingSessionControlHandle {
1879    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1880        self.inner.shutdown_with_epitaph(status.into())
1881    }
1882}
1883
1884impl fidl::endpoints::ControlHandle for MappingSessionControlHandle {
1885    fn shutdown(&self) {
1886        self.inner.shutdown()
1887    }
1888
1889    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1890        self.inner.shutdown_with_epitaph(status)
1891    }
1892
1893    fn is_closed(&self) -> bool {
1894        self.inner.channel().is_closed()
1895    }
1896    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1897        self.inner.channel().on_closed()
1898    }
1899
1900    #[cfg(target_os = "fuchsia")]
1901    fn signal_peer(
1902        &self,
1903        clear_mask: zx::Signals,
1904        set_mask: zx::Signals,
1905    ) -> Result<(), zx_status::Status> {
1906        use fidl::Peered;
1907        self.inner.channel().signal_peer(clear_mask, set_mask)
1908    }
1909}
1910
1911impl MappingSessionControlHandle {}
1912
1913#[must_use = "FIDL methods require a response to be sent"]
1914#[derive(Debug)]
1915pub struct MappingSessionOpenResponder {
1916    control_handle: std::mem::ManuallyDrop<MappingSessionControlHandle>,
1917    tx_id: u32,
1918}
1919
1920/// Set the the channel to be shutdown (see [`MappingSessionControlHandle::shutdown`])
1921/// if the responder is dropped without sending a response, so that the client
1922/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1923impl std::ops::Drop for MappingSessionOpenResponder {
1924    fn drop(&mut self) {
1925        self.control_handle.shutdown();
1926        // Safety: drops once, never accessed again
1927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1928    }
1929}
1930
1931impl fidl::endpoints::Responder for MappingSessionOpenResponder {
1932    type ControlHandle = MappingSessionControlHandle;
1933
1934    fn control_handle(&self) -> &MappingSessionControlHandle {
1935        &self.control_handle
1936    }
1937
1938    fn drop_without_shutdown(mut self) {
1939        // Safety: drops once, never accessed again due to mem::forget
1940        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1941        // Prevent Drop from running (which would shut down the channel)
1942        std::mem::forget(self);
1943    }
1944}
1945
1946impl MappingSessionOpenResponder {
1947    /// Sends a response to the FIDL transaction.
1948    ///
1949    /// Sets the channel to shutdown if an error occurs.
1950    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1951        let _result = self.send_raw(result);
1952        if _result.is_err() {
1953            self.control_handle.shutdown();
1954        }
1955        self.drop_without_shutdown();
1956        _result
1957    }
1958
1959    /// Similar to "send" but does not shutdown the channel if an error occurs.
1960    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1961        let _result = self.send_raw(result);
1962        self.drop_without_shutdown();
1963        _result
1964    }
1965
1966    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
1967        self.control_handle
1968            .inner
1969            .send::<fidl::encoding::FlexibleResultType<MappingSessionOpenResponse, i32>>(
1970                fidl::encoding::FlexibleResult::new(result.map(|size| (size,))),
1971                self.tx_id,
1972                0x1b3f5b2b1e68472b,
1973                fidl::encoding::DynamicFlags::FLEXIBLE,
1974            )
1975    }
1976}
1977
1978#[must_use = "FIDL methods require a response to be sent"]
1979#[derive(Debug)]
1980pub struct MappingSessionCloseResponder {
1981    control_handle: std::mem::ManuallyDrop<MappingSessionControlHandle>,
1982    tx_id: u32,
1983}
1984
1985/// Set the the channel to be shutdown (see [`MappingSessionControlHandle::shutdown`])
1986/// if the responder is dropped without sending a response, so that the client
1987/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1988impl std::ops::Drop for MappingSessionCloseResponder {
1989    fn drop(&mut self) {
1990        self.control_handle.shutdown();
1991        // Safety: drops once, never accessed again
1992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1993    }
1994}
1995
1996impl fidl::endpoints::Responder for MappingSessionCloseResponder {
1997    type ControlHandle = MappingSessionControlHandle;
1998
1999    fn control_handle(&self) -> &MappingSessionControlHandle {
2000        &self.control_handle
2001    }
2002
2003    fn drop_without_shutdown(mut self) {
2004        // Safety: drops once, never accessed again due to mem::forget
2005        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2006        // Prevent Drop from running (which would shut down the channel)
2007        std::mem::forget(self);
2008    }
2009}
2010
2011impl MappingSessionCloseResponder {
2012    /// Sends a response to the FIDL transaction.
2013    ///
2014    /// Sets the channel to shutdown if an error occurs.
2015    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2016        let _result = self.send_raw(result);
2017        if _result.is_err() {
2018            self.control_handle.shutdown();
2019        }
2020        self.drop_without_shutdown();
2021        _result
2022    }
2023
2024    /// Similar to "send" but does not shutdown the channel if an error occurs.
2025    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2026        let _result = self.send_raw(result);
2027        self.drop_without_shutdown();
2028        _result
2029    }
2030
2031    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2032        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2033            fidl::encoding::EmptyStruct,
2034            i32,
2035        >>(
2036            fidl::encoding::FlexibleResult::new(result),
2037            self.tx_id,
2038            0x34708ae0c1044d20,
2039            fidl::encoding::DynamicFlags::FLEXIBLE,
2040        )
2041    }
2042}
2043
2044#[must_use = "FIDL methods require a response to be sent"]
2045#[derive(Debug)]
2046pub struct MappingSessionGetProfileResponder {
2047    control_handle: std::mem::ManuallyDrop<MappingSessionControlHandle>,
2048    tx_id: u32,
2049}
2050
2051/// Set the the channel to be shutdown (see [`MappingSessionControlHandle::shutdown`])
2052/// if the responder is dropped without sending a response, so that the client
2053/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2054impl std::ops::Drop for MappingSessionGetProfileResponder {
2055    fn drop(&mut self) {
2056        self.control_handle.shutdown();
2057        // Safety: drops once, never accessed again
2058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2059    }
2060}
2061
2062impl fidl::endpoints::Responder for MappingSessionGetProfileResponder {
2063    type ControlHandle = MappingSessionControlHandle;
2064
2065    fn control_handle(&self) -> &MappingSessionControlHandle {
2066        &self.control_handle
2067    }
2068
2069    fn drop_without_shutdown(mut self) {
2070        // Safety: drops once, never accessed again due to mem::forget
2071        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2072        // Prevent Drop from running (which would shut down the channel)
2073        std::mem::forget(self);
2074    }
2075}
2076
2077impl MappingSessionGetProfileResponder {
2078    /// Sends a response to the FIDL transaction.
2079    ///
2080    /// Sets the channel to shutdown if an error occurs.
2081    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
2082        let _result = self.send_raw(result);
2083        if _result.is_err() {
2084            self.control_handle.shutdown();
2085        }
2086        self.drop_without_shutdown();
2087        _result
2088    }
2089
2090    /// Similar to "send" but does not shutdown the channel if an error occurs.
2091    pub fn send_no_shutdown_on_err(
2092        self,
2093        mut result: Result<fidl::Vmo, i32>,
2094    ) -> Result<(), fidl::Error> {
2095        let _result = self.send_raw(result);
2096        self.drop_without_shutdown();
2097        _result
2098    }
2099
2100    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
2101        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2102            MappingSessionGetProfileResponse,
2103            i32,
2104        >>(
2105            fidl::encoding::FlexibleResult::new(result.map(|profile_vmo| (profile_vmo,))),
2106            self.tx_id,
2107            0x282c8645f3a3f77f,
2108            fidl::encoding::DynamicFlags::FLEXIBLE,
2109        )
2110    }
2111}
2112
2113#[must_use = "FIDL methods require a response to be sent"]
2114#[derive(Debug)]
2115pub struct MappingSessionWriteProfileResponder {
2116    control_handle: std::mem::ManuallyDrop<MappingSessionControlHandle>,
2117    tx_id: u32,
2118}
2119
2120/// Set the the channel to be shutdown (see [`MappingSessionControlHandle::shutdown`])
2121/// if the responder is dropped without sending a response, so that the client
2122/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2123impl std::ops::Drop for MappingSessionWriteProfileResponder {
2124    fn drop(&mut self) {
2125        self.control_handle.shutdown();
2126        // Safety: drops once, never accessed again
2127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2128    }
2129}
2130
2131impl fidl::endpoints::Responder for MappingSessionWriteProfileResponder {
2132    type ControlHandle = MappingSessionControlHandle;
2133
2134    fn control_handle(&self) -> &MappingSessionControlHandle {
2135        &self.control_handle
2136    }
2137
2138    fn drop_without_shutdown(mut self) {
2139        // Safety: drops once, never accessed again due to mem::forget
2140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2141        // Prevent Drop from running (which would shut down the channel)
2142        std::mem::forget(self);
2143    }
2144}
2145
2146impl MappingSessionWriteProfileResponder {
2147    /// Sends a response to the FIDL transaction.
2148    ///
2149    /// Sets the channel to shutdown if an error occurs.
2150    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2151        let _result = self.send_raw(result);
2152        if _result.is_err() {
2153            self.control_handle.shutdown();
2154        }
2155        self.drop_without_shutdown();
2156        _result
2157    }
2158
2159    /// Similar to "send" but does not shutdown the channel if an error occurs.
2160    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2161        let _result = self.send_raw(result);
2162        self.drop_without_shutdown();
2163        _result
2164    }
2165
2166    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2167        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2168            fidl::encoding::EmptyStruct,
2169            i32,
2170        >>(
2171            fidl::encoding::FlexibleResult::new(result),
2172            self.tx_id,
2173            0x1ee027e4661e86de,
2174            fidl::encoding::DynamicFlags::FLEXIBLE,
2175        )
2176    }
2177}
2178
2179mod internal {
2180    use super::*;
2181
2182    impl fidl::encoding::ResourceTypeMarker for FileMapperOpenSessionRequest {
2183        type Borrowed<'a> = &'a mut Self;
2184        fn take_or_borrow<'a>(
2185            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2186        ) -> Self::Borrowed<'a> {
2187            value
2188        }
2189    }
2190
2191    unsafe impl fidl::encoding::TypeMarker for FileMapperOpenSessionRequest {
2192        type Owned = Self;
2193
2194        #[inline(always)]
2195        fn inline_align(_context: fidl::encoding::Context) -> usize {
2196            4
2197        }
2198
2199        #[inline(always)]
2200        fn inline_size(_context: fidl::encoding::Context) -> usize {
2201            12
2202        }
2203    }
2204
2205    unsafe impl
2206        fidl::encoding::Encode<
2207            FileMapperOpenSessionRequest,
2208            fidl::encoding::DefaultFuchsiaResourceDialect,
2209        > for &mut FileMapperOpenSessionRequest
2210    {
2211        #[inline]
2212        unsafe fn encode(
2213            self,
2214            encoder: &mut fidl::encoding::Encoder<
2215                '_,
2216                fidl::encoding::DefaultFuchsiaResourceDialect,
2217            >,
2218            offset: usize,
2219            _depth: fidl::encoding::Depth,
2220        ) -> fidl::Result<()> {
2221            encoder.debug_check_bounds::<FileMapperOpenSessionRequest>(offset);
2222            // Delegate to tuple encoding.
2223            fidl::encoding::Encode::<
2224                FileMapperOpenSessionRequest,
2225                fidl::encoding::DefaultFuchsiaResourceDialect,
2226            >::encode(
2227                (
2228                    <fidl::encoding::HandleType<
2229                        fidl::Event,
2230                        { fidl::ObjectType::EVENT.into_raw() },
2231                        2147483648,
2232                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2233                        &mut self.file_token
2234                    ),
2235                    <fidl::encoding::HandleType<
2236                        fidl::Vmo,
2237                        { fidl::ObjectType::VMO.into_raw() },
2238                        2147483648,
2239                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2240                        &mut self.mapping_vmo
2241                    ),
2242                    <fidl::encoding::Endpoint<
2243                        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
2244                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2245                        &mut self.session
2246                    ),
2247                ),
2248                encoder,
2249                offset,
2250                _depth,
2251            )
2252        }
2253    }
2254    unsafe impl<
2255        T0: fidl::encoding::Encode<
2256                fidl::encoding::HandleType<
2257                    fidl::Event,
2258                    { fidl::ObjectType::EVENT.into_raw() },
2259                    2147483648,
2260                >,
2261                fidl::encoding::DefaultFuchsiaResourceDialect,
2262            >,
2263        T1: fidl::encoding::Encode<
2264                fidl::encoding::HandleType<
2265                    fidl::Vmo,
2266                    { fidl::ObjectType::VMO.into_raw() },
2267                    2147483648,
2268                >,
2269                fidl::encoding::DefaultFuchsiaResourceDialect,
2270            >,
2271        T2: fidl::encoding::Encode<
2272                fidl::encoding::Endpoint<
2273                    fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
2274                >,
2275                fidl::encoding::DefaultFuchsiaResourceDialect,
2276            >,
2277    >
2278        fidl::encoding::Encode<
2279            FileMapperOpenSessionRequest,
2280            fidl::encoding::DefaultFuchsiaResourceDialect,
2281        > for (T0, T1, T2)
2282    {
2283        #[inline]
2284        unsafe fn encode(
2285            self,
2286            encoder: &mut fidl::encoding::Encoder<
2287                '_,
2288                fidl::encoding::DefaultFuchsiaResourceDialect,
2289            >,
2290            offset: usize,
2291            depth: fidl::encoding::Depth,
2292        ) -> fidl::Result<()> {
2293            encoder.debug_check_bounds::<FileMapperOpenSessionRequest>(offset);
2294            // Zero out padding regions. There's no need to apply masks
2295            // because the unmasked parts will be overwritten by fields.
2296            // Write the fields.
2297            self.0.encode(encoder, offset + 0, depth)?;
2298            self.1.encode(encoder, offset + 4, depth)?;
2299            self.2.encode(encoder, offset + 8, depth)?;
2300            Ok(())
2301        }
2302    }
2303
2304    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2305        for FileMapperOpenSessionRequest
2306    {
2307        #[inline(always)]
2308        fn new_empty() -> Self {
2309            Self {
2310                file_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2311                mapping_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2312                session: fidl::new_empty!(
2313                    fidl::encoding::Endpoint<
2314                        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
2315                    >,
2316                    fidl::encoding::DefaultFuchsiaResourceDialect
2317                ),
2318            }
2319        }
2320
2321        #[inline]
2322        unsafe fn decode(
2323            &mut self,
2324            decoder: &mut fidl::encoding::Decoder<
2325                '_,
2326                fidl::encoding::DefaultFuchsiaResourceDialect,
2327            >,
2328            offset: usize,
2329            _depth: fidl::encoding::Depth,
2330        ) -> fidl::Result<()> {
2331            decoder.debug_check_bounds::<Self>(offset);
2332            // Verify that padding bytes are zero.
2333            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.file_token, decoder, offset + 0, _depth)?;
2334            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mapping_vmo, decoder, offset + 4, _depth)?;
2335            fidl::decode!(
2336                fidl::encoding::Endpoint<
2337                    fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::MapperSessionMarker>,
2338                >,
2339                fidl::encoding::DefaultFuchsiaResourceDialect,
2340                &mut self.session,
2341                decoder,
2342                offset + 8,
2343                _depth
2344            )?;
2345            Ok(())
2346        }
2347    }
2348
2349    impl fidl::encoding::ResourceTypeMarker for MappingProviderOpenSessionRequest {
2350        type Borrowed<'a> = &'a mut Self;
2351        fn take_or_borrow<'a>(
2352            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2353        ) -> Self::Borrowed<'a> {
2354            value
2355        }
2356    }
2357
2358    unsafe impl fidl::encoding::TypeMarker for MappingProviderOpenSessionRequest {
2359        type Owned = Self;
2360
2361        #[inline(always)]
2362        fn inline_align(_context: fidl::encoding::Context) -> usize {
2363            4
2364        }
2365
2366        #[inline(always)]
2367        fn inline_size(_context: fidl::encoding::Context) -> usize {
2368            4
2369        }
2370    }
2371
2372    unsafe impl
2373        fidl::encoding::Encode<
2374            MappingProviderOpenSessionRequest,
2375            fidl::encoding::DefaultFuchsiaResourceDialect,
2376        > for &mut MappingProviderOpenSessionRequest
2377    {
2378        #[inline]
2379        unsafe fn encode(
2380            self,
2381            encoder: &mut fidl::encoding::Encoder<
2382                '_,
2383                fidl::encoding::DefaultFuchsiaResourceDialect,
2384            >,
2385            offset: usize,
2386            _depth: fidl::encoding::Depth,
2387        ) -> fidl::Result<()> {
2388            encoder.debug_check_bounds::<MappingProviderOpenSessionRequest>(offset);
2389            // Delegate to tuple encoding.
2390            fidl::encoding::Encode::<MappingProviderOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2391                (
2392                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MappingSessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
2393                ),
2394                encoder, offset, _depth
2395            )
2396        }
2397    }
2398    unsafe impl<
2399        T0: fidl::encoding::Encode<
2400                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MappingSessionMarker>>,
2401                fidl::encoding::DefaultFuchsiaResourceDialect,
2402            >,
2403    >
2404        fidl::encoding::Encode<
2405            MappingProviderOpenSessionRequest,
2406            fidl::encoding::DefaultFuchsiaResourceDialect,
2407        > for (T0,)
2408    {
2409        #[inline]
2410        unsafe fn encode(
2411            self,
2412            encoder: &mut fidl::encoding::Encoder<
2413                '_,
2414                fidl::encoding::DefaultFuchsiaResourceDialect,
2415            >,
2416            offset: usize,
2417            depth: fidl::encoding::Depth,
2418        ) -> fidl::Result<()> {
2419            encoder.debug_check_bounds::<MappingProviderOpenSessionRequest>(offset);
2420            // Zero out padding regions. There's no need to apply masks
2421            // because the unmasked parts will be overwritten by fields.
2422            // Write the fields.
2423            self.0.encode(encoder, offset + 0, depth)?;
2424            Ok(())
2425        }
2426    }
2427
2428    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2429        for MappingProviderOpenSessionRequest
2430    {
2431        #[inline(always)]
2432        fn new_empty() -> Self {
2433            Self {
2434                session: fidl::new_empty!(
2435                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MappingSessionMarker>>,
2436                    fidl::encoding::DefaultFuchsiaResourceDialect
2437                ),
2438            }
2439        }
2440
2441        #[inline]
2442        unsafe fn decode(
2443            &mut self,
2444            decoder: &mut fidl::encoding::Decoder<
2445                '_,
2446                fidl::encoding::DefaultFuchsiaResourceDialect,
2447            >,
2448            offset: usize,
2449            _depth: fidl::encoding::Depth,
2450        ) -> fidl::Result<()> {
2451            decoder.debug_check_bounds::<Self>(offset);
2452            // Verify that padding bytes are zero.
2453            fidl::decode!(
2454                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MappingSessionMarker>>,
2455                fidl::encoding::DefaultFuchsiaResourceDialect,
2456                &mut self.session,
2457                decoder,
2458                offset + 0,
2459                _depth
2460            )?;
2461            Ok(())
2462        }
2463    }
2464
2465    impl fidl::encoding::ResourceTypeMarker for MappingProviderOpenSessionResponse {
2466        type Borrowed<'a> = &'a mut Self;
2467        fn take_or_borrow<'a>(
2468            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2469        ) -> Self::Borrowed<'a> {
2470            value
2471        }
2472    }
2473
2474    unsafe impl fidl::encoding::TypeMarker for MappingProviderOpenSessionResponse {
2475        type Owned = Self;
2476
2477        #[inline(always)]
2478        fn inline_align(_context: fidl::encoding::Context) -> usize {
2479            4
2480        }
2481
2482        #[inline(always)]
2483        fn inline_size(_context: fidl::encoding::Context) -> usize {
2484            4
2485        }
2486    }
2487
2488    unsafe impl
2489        fidl::encoding::Encode<
2490            MappingProviderOpenSessionResponse,
2491            fidl::encoding::DefaultFuchsiaResourceDialect,
2492        > for &mut MappingProviderOpenSessionResponse
2493    {
2494        #[inline]
2495        unsafe fn encode(
2496            self,
2497            encoder: &mut fidl::encoding::Encoder<
2498                '_,
2499                fidl::encoding::DefaultFuchsiaResourceDialect,
2500            >,
2501            offset: usize,
2502            _depth: fidl::encoding::Depth,
2503        ) -> fidl::Result<()> {
2504            encoder.debug_check_bounds::<MappingProviderOpenSessionResponse>(offset);
2505            // Delegate to tuple encoding.
2506            fidl::encoding::Encode::<
2507                MappingProviderOpenSessionResponse,
2508                fidl::encoding::DefaultFuchsiaResourceDialect,
2509            >::encode(
2510                (<fidl::encoding::HandleType<
2511                    fidl::Vmo,
2512                    { fidl::ObjectType::VMO.into_raw() },
2513                    2147483648,
2514                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2515                    &mut self.mapping_vmo
2516                ),),
2517                encoder,
2518                offset,
2519                _depth,
2520            )
2521        }
2522    }
2523    unsafe impl<
2524        T0: fidl::encoding::Encode<
2525                fidl::encoding::HandleType<
2526                    fidl::Vmo,
2527                    { fidl::ObjectType::VMO.into_raw() },
2528                    2147483648,
2529                >,
2530                fidl::encoding::DefaultFuchsiaResourceDialect,
2531            >,
2532    >
2533        fidl::encoding::Encode<
2534            MappingProviderOpenSessionResponse,
2535            fidl::encoding::DefaultFuchsiaResourceDialect,
2536        > for (T0,)
2537    {
2538        #[inline]
2539        unsafe fn encode(
2540            self,
2541            encoder: &mut fidl::encoding::Encoder<
2542                '_,
2543                fidl::encoding::DefaultFuchsiaResourceDialect,
2544            >,
2545            offset: usize,
2546            depth: fidl::encoding::Depth,
2547        ) -> fidl::Result<()> {
2548            encoder.debug_check_bounds::<MappingProviderOpenSessionResponse>(offset);
2549            // Zero out padding regions. There's no need to apply masks
2550            // because the unmasked parts will be overwritten by fields.
2551            // Write the fields.
2552            self.0.encode(encoder, offset + 0, depth)?;
2553            Ok(())
2554        }
2555    }
2556
2557    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2558        for MappingProviderOpenSessionResponse
2559    {
2560        #[inline(always)]
2561        fn new_empty() -> Self {
2562            Self {
2563                mapping_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2564            }
2565        }
2566
2567        #[inline]
2568        unsafe fn decode(
2569            &mut self,
2570            decoder: &mut fidl::encoding::Decoder<
2571                '_,
2572                fidl::encoding::DefaultFuchsiaResourceDialect,
2573            >,
2574            offset: usize,
2575            _depth: fidl::encoding::Depth,
2576        ) -> fidl::Result<()> {
2577            decoder.debug_check_bounds::<Self>(offset);
2578            // Verify that padding bytes are zero.
2579            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mapping_vmo, decoder, offset + 0, _depth)?;
2580            Ok(())
2581        }
2582    }
2583
2584    impl fidl::encoding::ResourceTypeMarker for MappingSessionWriteProfileRequest {
2585        type Borrowed<'a> = &'a mut Self;
2586        fn take_or_borrow<'a>(
2587            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2588        ) -> Self::Borrowed<'a> {
2589            value
2590        }
2591    }
2592
2593    unsafe impl fidl::encoding::TypeMarker for MappingSessionWriteProfileRequest {
2594        type Owned = Self;
2595
2596        #[inline(always)]
2597        fn inline_align(_context: fidl::encoding::Context) -> usize {
2598            8
2599        }
2600
2601        #[inline(always)]
2602        fn inline_size(_context: fidl::encoding::Context) -> usize {
2603            24
2604        }
2605    }
2606
2607    unsafe impl
2608        fidl::encoding::Encode<
2609            MappingSessionWriteProfileRequest,
2610            fidl::encoding::DefaultFuchsiaResourceDialect,
2611        > for &mut MappingSessionWriteProfileRequest
2612    {
2613        #[inline]
2614        unsafe fn encode(
2615            self,
2616            encoder: &mut fidl::encoding::Encoder<
2617                '_,
2618                fidl::encoding::DefaultFuchsiaResourceDialect,
2619            >,
2620            offset: usize,
2621            _depth: fidl::encoding::Depth,
2622        ) -> fidl::Result<()> {
2623            encoder.debug_check_bounds::<MappingSessionWriteProfileRequest>(offset);
2624            // Delegate to tuple encoding.
2625            fidl::encoding::Encode::<
2626                MappingSessionWriteProfileRequest,
2627                fidl::encoding::DefaultFuchsiaResourceDialect,
2628            >::encode(
2629                (
2630                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
2631                        &self.name,
2632                    ),
2633                    <fidl::encoding::HandleType<
2634                        fidl::Vmo,
2635                        { fidl::ObjectType::VMO.into_raw() },
2636                        2147483648,
2637                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2638                        &mut self.profile_vmo
2639                    ),
2640                ),
2641                encoder,
2642                offset,
2643                _depth,
2644            )
2645        }
2646    }
2647    unsafe impl<
2648        T0: fidl::encoding::Encode<
2649                fidl::encoding::UnboundedString,
2650                fidl::encoding::DefaultFuchsiaResourceDialect,
2651            >,
2652        T1: fidl::encoding::Encode<
2653                fidl::encoding::HandleType<
2654                    fidl::Vmo,
2655                    { fidl::ObjectType::VMO.into_raw() },
2656                    2147483648,
2657                >,
2658                fidl::encoding::DefaultFuchsiaResourceDialect,
2659            >,
2660    >
2661        fidl::encoding::Encode<
2662            MappingSessionWriteProfileRequest,
2663            fidl::encoding::DefaultFuchsiaResourceDialect,
2664        > for (T0, T1)
2665    {
2666        #[inline]
2667        unsafe fn encode(
2668            self,
2669            encoder: &mut fidl::encoding::Encoder<
2670                '_,
2671                fidl::encoding::DefaultFuchsiaResourceDialect,
2672            >,
2673            offset: usize,
2674            depth: fidl::encoding::Depth,
2675        ) -> fidl::Result<()> {
2676            encoder.debug_check_bounds::<MappingSessionWriteProfileRequest>(offset);
2677            // Zero out padding regions. There's no need to apply masks
2678            // because the unmasked parts will be overwritten by fields.
2679            unsafe {
2680                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2681                (ptr as *mut u64).write_unaligned(0);
2682            }
2683            // Write the fields.
2684            self.0.encode(encoder, offset + 0, depth)?;
2685            self.1.encode(encoder, offset + 16, depth)?;
2686            Ok(())
2687        }
2688    }
2689
2690    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2691        for MappingSessionWriteProfileRequest
2692    {
2693        #[inline(always)]
2694        fn new_empty() -> Self {
2695            Self {
2696                name: fidl::new_empty!(
2697                    fidl::encoding::UnboundedString,
2698                    fidl::encoding::DefaultFuchsiaResourceDialect
2699                ),
2700                profile_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2701            }
2702        }
2703
2704        #[inline]
2705        unsafe fn decode(
2706            &mut self,
2707            decoder: &mut fidl::encoding::Decoder<
2708                '_,
2709                fidl::encoding::DefaultFuchsiaResourceDialect,
2710            >,
2711            offset: usize,
2712            _depth: fidl::encoding::Depth,
2713        ) -> fidl::Result<()> {
2714            decoder.debug_check_bounds::<Self>(offset);
2715            // Verify that padding bytes are zero.
2716            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2717            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2718            let mask = 0xffffffff00000000u64;
2719            let maskedval = padval & mask;
2720            if maskedval != 0 {
2721                return Err(fidl::Error::NonZeroPadding {
2722                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2723                });
2724            }
2725            fidl::decode!(
2726                fidl::encoding::UnboundedString,
2727                fidl::encoding::DefaultFuchsiaResourceDialect,
2728                &mut self.name,
2729                decoder,
2730                offset + 0,
2731                _depth
2732            )?;
2733            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.profile_vmo, decoder, offset + 16, _depth)?;
2734            Ok(())
2735        }
2736    }
2737
2738    impl fidl::encoding::ResourceTypeMarker for MappingSessionGetProfileResponse {
2739        type Borrowed<'a> = &'a mut Self;
2740        fn take_or_borrow<'a>(
2741            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2742        ) -> Self::Borrowed<'a> {
2743            value
2744        }
2745    }
2746
2747    unsafe impl fidl::encoding::TypeMarker for MappingSessionGetProfileResponse {
2748        type Owned = Self;
2749
2750        #[inline(always)]
2751        fn inline_align(_context: fidl::encoding::Context) -> usize {
2752            4
2753        }
2754
2755        #[inline(always)]
2756        fn inline_size(_context: fidl::encoding::Context) -> usize {
2757            4
2758        }
2759    }
2760
2761    unsafe impl
2762        fidl::encoding::Encode<
2763            MappingSessionGetProfileResponse,
2764            fidl::encoding::DefaultFuchsiaResourceDialect,
2765        > for &mut MappingSessionGetProfileResponse
2766    {
2767        #[inline]
2768        unsafe fn encode(
2769            self,
2770            encoder: &mut fidl::encoding::Encoder<
2771                '_,
2772                fidl::encoding::DefaultFuchsiaResourceDialect,
2773            >,
2774            offset: usize,
2775            _depth: fidl::encoding::Depth,
2776        ) -> fidl::Result<()> {
2777            encoder.debug_check_bounds::<MappingSessionGetProfileResponse>(offset);
2778            // Delegate to tuple encoding.
2779            fidl::encoding::Encode::<
2780                MappingSessionGetProfileResponse,
2781                fidl::encoding::DefaultFuchsiaResourceDialect,
2782            >::encode(
2783                (<fidl::encoding::HandleType<
2784                    fidl::Vmo,
2785                    { fidl::ObjectType::VMO.into_raw() },
2786                    2147483648,
2787                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2788                    &mut self.profile_vmo
2789                ),),
2790                encoder,
2791                offset,
2792                _depth,
2793            )
2794        }
2795    }
2796    unsafe impl<
2797        T0: fidl::encoding::Encode<
2798                fidl::encoding::HandleType<
2799                    fidl::Vmo,
2800                    { fidl::ObjectType::VMO.into_raw() },
2801                    2147483648,
2802                >,
2803                fidl::encoding::DefaultFuchsiaResourceDialect,
2804            >,
2805    >
2806        fidl::encoding::Encode<
2807            MappingSessionGetProfileResponse,
2808            fidl::encoding::DefaultFuchsiaResourceDialect,
2809        > for (T0,)
2810    {
2811        #[inline]
2812        unsafe fn encode(
2813            self,
2814            encoder: &mut fidl::encoding::Encoder<
2815                '_,
2816                fidl::encoding::DefaultFuchsiaResourceDialect,
2817            >,
2818            offset: usize,
2819            depth: fidl::encoding::Depth,
2820        ) -> fidl::Result<()> {
2821            encoder.debug_check_bounds::<MappingSessionGetProfileResponse>(offset);
2822            // Zero out padding regions. There's no need to apply masks
2823            // because the unmasked parts will be overwritten by fields.
2824            // Write the fields.
2825            self.0.encode(encoder, offset + 0, depth)?;
2826            Ok(())
2827        }
2828    }
2829
2830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2831        for MappingSessionGetProfileResponse
2832    {
2833        #[inline(always)]
2834        fn new_empty() -> Self {
2835            Self {
2836                profile_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2837            }
2838        }
2839
2840        #[inline]
2841        unsafe fn decode(
2842            &mut self,
2843            decoder: &mut fidl::encoding::Decoder<
2844                '_,
2845                fidl::encoding::DefaultFuchsiaResourceDialect,
2846            >,
2847            offset: usize,
2848            _depth: fidl::encoding::Depth,
2849        ) -> fidl::Result<()> {
2850            decoder.debug_check_bounds::<Self>(offset);
2851            // Verify that padding bytes are zero.
2852            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.profile_vmo, decoder, offset + 0, _depth)?;
2853            Ok(())
2854        }
2855    }
2856}