fidl_fuchsia_fxfs/
fidl_fuchsia_fxfs.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_fxfs__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct BlobCreatorCreateResponse {
16    pub writer: fidl::endpoints::ClientEnd<BlobWriterMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobCreatorCreateResponse {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct BlobReaderGetVmoResponse {
23    pub vmo: fidl::Vmo,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobReaderGetVmoResponse {}
27
28#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct BlobWriterGetVmoResponse {
30    pub vmo: fidl::Vmo,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobWriterGetVmoResponse {}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct FileBackedVolumeProviderOpenRequest {
37    pub parent_directory_token: fidl::Handle,
38    pub name: String,
39    pub server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for FileBackedVolumeProviderOpenRequest
44{
45}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
48pub struct BlobCreatorMarker;
49
50impl fidl::endpoints::ProtocolMarker for BlobCreatorMarker {
51    type Proxy = BlobCreatorProxy;
52    type RequestStream = BlobCreatorRequestStream;
53    #[cfg(target_os = "fuchsia")]
54    type SynchronousProxy = BlobCreatorSynchronousProxy;
55
56    const DEBUG_NAME: &'static str = "fuchsia.fxfs.BlobCreator";
57}
58impl fidl::endpoints::DiscoverableProtocolMarker for BlobCreatorMarker {}
59pub type BlobCreatorCreateResult =
60    Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>;
61
62pub trait BlobCreatorProxyInterface: Send + Sync {
63    type CreateResponseFut: std::future::Future<Output = Result<BlobCreatorCreateResult, fidl::Error>>
64        + Send;
65    fn r#create(&self, hash: &[u8; 32], allow_existing: bool) -> Self::CreateResponseFut;
66}
67#[derive(Debug)]
68#[cfg(target_os = "fuchsia")]
69pub struct BlobCreatorSynchronousProxy {
70    client: fidl::client::sync::Client,
71}
72
73#[cfg(target_os = "fuchsia")]
74impl fidl::endpoints::SynchronousProxy for BlobCreatorSynchronousProxy {
75    type Proxy = BlobCreatorProxy;
76    type Protocol = BlobCreatorMarker;
77
78    fn from_channel(inner: fidl::Channel) -> Self {
79        Self::new(inner)
80    }
81
82    fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    fn as_channel(&self) -> &fidl::Channel {
87        self.client.as_channel()
88    }
89}
90
91#[cfg(target_os = "fuchsia")]
92impl BlobCreatorSynchronousProxy {
93    pub fn new(channel: fidl::Channel) -> Self {
94        let protocol_name = <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
95        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<BlobCreatorEvent, fidl::Error> {
108        BlobCreatorEvent::decode(self.client.wait_for_event(deadline)?)
109    }
110
111    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
112    /// overwrite the existing blob if there is one. The server may fail this request with
113    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
114    /// hash which has not been closed or completed. The client will truncate the blob with
115    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
116    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
117    /// server that some number of bytes has been written to the vmo.
118    pub fn r#create(
119        &self,
120        mut hash: &[u8; 32],
121        mut allow_existing: bool,
122        ___deadline: zx::MonotonicInstant,
123    ) -> Result<BlobCreatorCreateResult, fidl::Error> {
124        let _response = self.client.send_query::<
125            BlobCreatorCreateRequest,
126            fidl::encoding::ResultType<BlobCreatorCreateResponse, CreateBlobError>,
127        >(
128            (hash, allow_existing,),
129            0x4288fe720cca70d7,
130            fidl::encoding::DynamicFlags::empty(),
131            ___deadline,
132        )?;
133        Ok(_response.map(|x| x.writer))
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<BlobCreatorSynchronousProxy> for zx::Handle {
139    fn from(value: BlobCreatorSynchronousProxy) -> Self {
140        value.into_channel().into()
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<fidl::Channel> for BlobCreatorSynchronousProxy {
146    fn from(value: fidl::Channel) -> Self {
147        Self::new(value)
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl fidl::endpoints::FromClient for BlobCreatorSynchronousProxy {
153    type Protocol = BlobCreatorMarker;
154
155    fn from_client(value: fidl::endpoints::ClientEnd<BlobCreatorMarker>) -> Self {
156        Self::new(value.into_channel())
157    }
158}
159
160#[derive(Debug, Clone)]
161pub struct BlobCreatorProxy {
162    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
163}
164
165impl fidl::endpoints::Proxy for BlobCreatorProxy {
166    type Protocol = BlobCreatorMarker;
167
168    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
169        Self::new(inner)
170    }
171
172    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
173        self.client.into_channel().map_err(|client| Self { client })
174    }
175
176    fn as_channel(&self) -> &::fidl::AsyncChannel {
177        self.client.as_channel()
178    }
179}
180
181impl BlobCreatorProxy {
182    /// Create a new Proxy for fuchsia.fxfs/BlobCreator.
183    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
184        let protocol_name = <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
185        Self { client: fidl::client::Client::new(channel, protocol_name) }
186    }
187
188    /// Get a Stream of events from the remote end of the protocol.
189    ///
190    /// # Panics
191    ///
192    /// Panics if the event stream was already taken.
193    pub fn take_event_stream(&self) -> BlobCreatorEventStream {
194        BlobCreatorEventStream { event_receiver: self.client.take_event_receiver() }
195    }
196
197    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
198    /// overwrite the existing blob if there is one. The server may fail this request with
199    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
200    /// hash which has not been closed or completed. The client will truncate the blob with
201    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
202    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
203    /// server that some number of bytes has been written to the vmo.
204    pub fn r#create(
205        &self,
206        mut hash: &[u8; 32],
207        mut allow_existing: bool,
208    ) -> fidl::client::QueryResponseFut<
209        BlobCreatorCreateResult,
210        fidl::encoding::DefaultFuchsiaResourceDialect,
211    > {
212        BlobCreatorProxyInterface::r#create(self, hash, allow_existing)
213    }
214}
215
216impl BlobCreatorProxyInterface for BlobCreatorProxy {
217    type CreateResponseFut = fidl::client::QueryResponseFut<
218        BlobCreatorCreateResult,
219        fidl::encoding::DefaultFuchsiaResourceDialect,
220    >;
221    fn r#create(&self, mut hash: &[u8; 32], mut allow_existing: bool) -> Self::CreateResponseFut {
222        fn _decode(
223            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
224        ) -> Result<BlobCreatorCreateResult, fidl::Error> {
225            let _response = fidl::client::decode_transaction_body::<
226                fidl::encoding::ResultType<BlobCreatorCreateResponse, CreateBlobError>,
227                fidl::encoding::DefaultFuchsiaResourceDialect,
228                0x4288fe720cca70d7,
229            >(_buf?)?;
230            Ok(_response.map(|x| x.writer))
231        }
232        self.client.send_query_and_decode::<BlobCreatorCreateRequest, BlobCreatorCreateResult>(
233            (hash, allow_existing),
234            0x4288fe720cca70d7,
235            fidl::encoding::DynamicFlags::empty(),
236            _decode,
237        )
238    }
239}
240
241pub struct BlobCreatorEventStream {
242    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
243}
244
245impl std::marker::Unpin for BlobCreatorEventStream {}
246
247impl futures::stream::FusedStream for BlobCreatorEventStream {
248    fn is_terminated(&self) -> bool {
249        self.event_receiver.is_terminated()
250    }
251}
252
253impl futures::Stream for BlobCreatorEventStream {
254    type Item = Result<BlobCreatorEvent, fidl::Error>;
255
256    fn poll_next(
257        mut self: std::pin::Pin<&mut Self>,
258        cx: &mut std::task::Context<'_>,
259    ) -> std::task::Poll<Option<Self::Item>> {
260        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
261            &mut self.event_receiver,
262            cx
263        )?) {
264            Some(buf) => std::task::Poll::Ready(Some(BlobCreatorEvent::decode(buf))),
265            None => std::task::Poll::Ready(None),
266        }
267    }
268}
269
270#[derive(Debug)]
271pub enum BlobCreatorEvent {}
272
273impl BlobCreatorEvent {
274    /// Decodes a message buffer as a [`BlobCreatorEvent`].
275    fn decode(
276        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
277    ) -> Result<BlobCreatorEvent, fidl::Error> {
278        let (bytes, _handles) = buf.split_mut();
279        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
280        debug_assert_eq!(tx_header.tx_id, 0);
281        match tx_header.ordinal {
282            _ => Err(fidl::Error::UnknownOrdinal {
283                ordinal: tx_header.ordinal,
284                protocol_name: <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
285            }),
286        }
287    }
288}
289
290/// A Stream of incoming requests for fuchsia.fxfs/BlobCreator.
291pub struct BlobCreatorRequestStream {
292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293    is_terminated: bool,
294}
295
296impl std::marker::Unpin for BlobCreatorRequestStream {}
297
298impl futures::stream::FusedStream for BlobCreatorRequestStream {
299    fn is_terminated(&self) -> bool {
300        self.is_terminated
301    }
302}
303
304impl fidl::endpoints::RequestStream for BlobCreatorRequestStream {
305    type Protocol = BlobCreatorMarker;
306    type ControlHandle = BlobCreatorControlHandle;
307
308    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
309        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
310    }
311
312    fn control_handle(&self) -> Self::ControlHandle {
313        BlobCreatorControlHandle { inner: self.inner.clone() }
314    }
315
316    fn into_inner(
317        self,
318    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
319    {
320        (self.inner, self.is_terminated)
321    }
322
323    fn from_inner(
324        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
325        is_terminated: bool,
326    ) -> Self {
327        Self { inner, is_terminated }
328    }
329}
330
331impl futures::Stream for BlobCreatorRequestStream {
332    type Item = Result<BlobCreatorRequest, fidl::Error>;
333
334    fn poll_next(
335        mut self: std::pin::Pin<&mut Self>,
336        cx: &mut std::task::Context<'_>,
337    ) -> std::task::Poll<Option<Self::Item>> {
338        let this = &mut *self;
339        if this.inner.check_shutdown(cx) {
340            this.is_terminated = true;
341            return std::task::Poll::Ready(None);
342        }
343        if this.is_terminated {
344            panic!("polled BlobCreatorRequestStream after completion");
345        }
346        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
347            |bytes, handles| {
348                match this.inner.channel().read_etc(cx, bytes, handles) {
349                    std::task::Poll::Ready(Ok(())) => {}
350                    std::task::Poll::Pending => return std::task::Poll::Pending,
351                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
352                        this.is_terminated = true;
353                        return std::task::Poll::Ready(None);
354                    }
355                    std::task::Poll::Ready(Err(e)) => {
356                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
357                            e.into(),
358                        ))));
359                    }
360                }
361
362                // A message has been received from the channel
363                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
364
365                std::task::Poll::Ready(Some(match header.ordinal {
366                    0x4288fe720cca70d7 => {
367                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
368                        let mut req = fidl::new_empty!(
369                            BlobCreatorCreateRequest,
370                            fidl::encoding::DefaultFuchsiaResourceDialect
371                        );
372                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobCreatorCreateRequest>(&header, _body_bytes, handles, &mut req)?;
373                        let control_handle = BlobCreatorControlHandle { inner: this.inner.clone() };
374                        Ok(BlobCreatorRequest::Create {
375                            hash: req.hash,
376                            allow_existing: req.allow_existing,
377
378                            responder: BlobCreatorCreateResponder {
379                                control_handle: std::mem::ManuallyDrop::new(control_handle),
380                                tx_id: header.tx_id,
381                            },
382                        })
383                    }
384                    _ => Err(fidl::Error::UnknownOrdinal {
385                        ordinal: header.ordinal,
386                        protocol_name:
387                            <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
388                    }),
389                }))
390            },
391        )
392    }
393}
394
395#[derive(Debug)]
396pub enum BlobCreatorRequest {
397    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
398    /// overwrite the existing blob if there is one. The server may fail this request with
399    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
400    /// hash which has not been closed or completed. The client will truncate the blob with
401    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
402    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
403    /// server that some number of bytes has been written to the vmo.
404    Create { hash: [u8; 32], allow_existing: bool, responder: BlobCreatorCreateResponder },
405}
406
407impl BlobCreatorRequest {
408    #[allow(irrefutable_let_patterns)]
409    pub fn into_create(self) -> Option<([u8; 32], bool, BlobCreatorCreateResponder)> {
410        if let BlobCreatorRequest::Create { hash, allow_existing, responder } = self {
411            Some((hash, allow_existing, responder))
412        } else {
413            None
414        }
415    }
416
417    /// Name of the method defined in FIDL
418    pub fn method_name(&self) -> &'static str {
419        match *self {
420            BlobCreatorRequest::Create { .. } => "create",
421        }
422    }
423}
424
425#[derive(Debug, Clone)]
426pub struct BlobCreatorControlHandle {
427    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
428}
429
430impl fidl::endpoints::ControlHandle for BlobCreatorControlHandle {
431    fn shutdown(&self) {
432        self.inner.shutdown()
433    }
434    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
435        self.inner.shutdown_with_epitaph(status)
436    }
437
438    fn is_closed(&self) -> bool {
439        self.inner.channel().is_closed()
440    }
441    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
442        self.inner.channel().on_closed()
443    }
444
445    #[cfg(target_os = "fuchsia")]
446    fn signal_peer(
447        &self,
448        clear_mask: zx::Signals,
449        set_mask: zx::Signals,
450    ) -> Result<(), zx_status::Status> {
451        use fidl::Peered;
452        self.inner.channel().signal_peer(clear_mask, set_mask)
453    }
454}
455
456impl BlobCreatorControlHandle {}
457
458#[must_use = "FIDL methods require a response to be sent"]
459#[derive(Debug)]
460pub struct BlobCreatorCreateResponder {
461    control_handle: std::mem::ManuallyDrop<BlobCreatorControlHandle>,
462    tx_id: u32,
463}
464
465/// Set the the channel to be shutdown (see [`BlobCreatorControlHandle::shutdown`])
466/// if the responder is dropped without sending a response, so that the client
467/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
468impl std::ops::Drop for BlobCreatorCreateResponder {
469    fn drop(&mut self) {
470        self.control_handle.shutdown();
471        // Safety: drops once, never accessed again
472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
473    }
474}
475
476impl fidl::endpoints::Responder for BlobCreatorCreateResponder {
477    type ControlHandle = BlobCreatorControlHandle;
478
479    fn control_handle(&self) -> &BlobCreatorControlHandle {
480        &self.control_handle
481    }
482
483    fn drop_without_shutdown(mut self) {
484        // Safety: drops once, never accessed again due to mem::forget
485        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
486        // Prevent Drop from running (which would shut down the channel)
487        std::mem::forget(self);
488    }
489}
490
491impl BlobCreatorCreateResponder {
492    /// Sends a response to the FIDL transaction.
493    ///
494    /// Sets the channel to shutdown if an error occurs.
495    pub fn send(
496        self,
497        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
498    ) -> Result<(), fidl::Error> {
499        let _result = self.send_raw(result);
500        if _result.is_err() {
501            self.control_handle.shutdown();
502        }
503        self.drop_without_shutdown();
504        _result
505    }
506
507    /// Similar to "send" but does not shutdown the channel if an error occurs.
508    pub fn send_no_shutdown_on_err(
509        self,
510        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
511    ) -> Result<(), fidl::Error> {
512        let _result = self.send_raw(result);
513        self.drop_without_shutdown();
514        _result
515    }
516
517    fn send_raw(
518        &self,
519        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
520    ) -> Result<(), fidl::Error> {
521        self.control_handle.inner.send::<fidl::encoding::ResultType<
522            BlobCreatorCreateResponse,
523            CreateBlobError,
524        >>(
525            result.map(|writer| (writer,)),
526            self.tx_id,
527            0x4288fe720cca70d7,
528            fidl::encoding::DynamicFlags::empty(),
529        )
530    }
531}
532
533#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
534pub struct BlobReaderMarker;
535
536impl fidl::endpoints::ProtocolMarker for BlobReaderMarker {
537    type Proxy = BlobReaderProxy;
538    type RequestStream = BlobReaderRequestStream;
539    #[cfg(target_os = "fuchsia")]
540    type SynchronousProxy = BlobReaderSynchronousProxy;
541
542    const DEBUG_NAME: &'static str = "fuchsia.fxfs.BlobReader";
543}
544impl fidl::endpoints::DiscoverableProtocolMarker for BlobReaderMarker {}
545pub type BlobReaderGetVmoResult = Result<fidl::Vmo, i32>;
546
547pub trait BlobReaderProxyInterface: Send + Sync {
548    type GetVmoResponseFut: std::future::Future<Output = Result<BlobReaderGetVmoResult, fidl::Error>>
549        + Send;
550    fn r#get_vmo(&self, blob_hash: &[u8; 32]) -> Self::GetVmoResponseFut;
551}
552#[derive(Debug)]
553#[cfg(target_os = "fuchsia")]
554pub struct BlobReaderSynchronousProxy {
555    client: fidl::client::sync::Client,
556}
557
558#[cfg(target_os = "fuchsia")]
559impl fidl::endpoints::SynchronousProxy for BlobReaderSynchronousProxy {
560    type Proxy = BlobReaderProxy;
561    type Protocol = BlobReaderMarker;
562
563    fn from_channel(inner: fidl::Channel) -> Self {
564        Self::new(inner)
565    }
566
567    fn into_channel(self) -> fidl::Channel {
568        self.client.into_channel()
569    }
570
571    fn as_channel(&self) -> &fidl::Channel {
572        self.client.as_channel()
573    }
574}
575
576#[cfg(target_os = "fuchsia")]
577impl BlobReaderSynchronousProxy {
578    pub fn new(channel: fidl::Channel) -> Self {
579        let protocol_name = <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
580        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
581    }
582
583    pub fn into_channel(self) -> fidl::Channel {
584        self.client.into_channel()
585    }
586
587    /// Waits until an event arrives and returns it. It is safe for other
588    /// threads to make concurrent requests while waiting for an event.
589    pub fn wait_for_event(
590        &self,
591        deadline: zx::MonotonicInstant,
592    ) -> Result<BlobReaderEvent, fidl::Error> {
593        BlobReaderEvent::decode(self.client.wait_for_event(deadline)?)
594    }
595
596    /// Given the hash of a blob, returns a VMO with its contents.
597    pub fn r#get_vmo(
598        &self,
599        mut blob_hash: &[u8; 32],
600        ___deadline: zx::MonotonicInstant,
601    ) -> Result<BlobReaderGetVmoResult, fidl::Error> {
602        let _response = self.client.send_query::<
603            BlobReaderGetVmoRequest,
604            fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>,
605        >(
606            (blob_hash,),
607            0x2fa72823ef7f11f4,
608            fidl::encoding::DynamicFlags::empty(),
609            ___deadline,
610        )?;
611        Ok(_response.map(|x| x.vmo))
612    }
613}
614
615#[cfg(target_os = "fuchsia")]
616impl From<BlobReaderSynchronousProxy> for zx::Handle {
617    fn from(value: BlobReaderSynchronousProxy) -> Self {
618        value.into_channel().into()
619    }
620}
621
622#[cfg(target_os = "fuchsia")]
623impl From<fidl::Channel> for BlobReaderSynchronousProxy {
624    fn from(value: fidl::Channel) -> Self {
625        Self::new(value)
626    }
627}
628
629#[cfg(target_os = "fuchsia")]
630impl fidl::endpoints::FromClient for BlobReaderSynchronousProxy {
631    type Protocol = BlobReaderMarker;
632
633    fn from_client(value: fidl::endpoints::ClientEnd<BlobReaderMarker>) -> Self {
634        Self::new(value.into_channel())
635    }
636}
637
638#[derive(Debug, Clone)]
639pub struct BlobReaderProxy {
640    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
641}
642
643impl fidl::endpoints::Proxy for BlobReaderProxy {
644    type Protocol = BlobReaderMarker;
645
646    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
647        Self::new(inner)
648    }
649
650    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
651        self.client.into_channel().map_err(|client| Self { client })
652    }
653
654    fn as_channel(&self) -> &::fidl::AsyncChannel {
655        self.client.as_channel()
656    }
657}
658
659impl BlobReaderProxy {
660    /// Create a new Proxy for fuchsia.fxfs/BlobReader.
661    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
662        let protocol_name = <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
663        Self { client: fidl::client::Client::new(channel, protocol_name) }
664    }
665
666    /// Get a Stream of events from the remote end of the protocol.
667    ///
668    /// # Panics
669    ///
670    /// Panics if the event stream was already taken.
671    pub fn take_event_stream(&self) -> BlobReaderEventStream {
672        BlobReaderEventStream { event_receiver: self.client.take_event_receiver() }
673    }
674
675    /// Given the hash of a blob, returns a VMO with its contents.
676    pub fn r#get_vmo(
677        &self,
678        mut blob_hash: &[u8; 32],
679    ) -> fidl::client::QueryResponseFut<
680        BlobReaderGetVmoResult,
681        fidl::encoding::DefaultFuchsiaResourceDialect,
682    > {
683        BlobReaderProxyInterface::r#get_vmo(self, blob_hash)
684    }
685}
686
687impl BlobReaderProxyInterface for BlobReaderProxy {
688    type GetVmoResponseFut = fidl::client::QueryResponseFut<
689        BlobReaderGetVmoResult,
690        fidl::encoding::DefaultFuchsiaResourceDialect,
691    >;
692    fn r#get_vmo(&self, mut blob_hash: &[u8; 32]) -> Self::GetVmoResponseFut {
693        fn _decode(
694            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
695        ) -> Result<BlobReaderGetVmoResult, fidl::Error> {
696            let _response = fidl::client::decode_transaction_body::<
697                fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>,
698                fidl::encoding::DefaultFuchsiaResourceDialect,
699                0x2fa72823ef7f11f4,
700            >(_buf?)?;
701            Ok(_response.map(|x| x.vmo))
702        }
703        self.client.send_query_and_decode::<BlobReaderGetVmoRequest, BlobReaderGetVmoResult>(
704            (blob_hash,),
705            0x2fa72823ef7f11f4,
706            fidl::encoding::DynamicFlags::empty(),
707            _decode,
708        )
709    }
710}
711
712pub struct BlobReaderEventStream {
713    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
714}
715
716impl std::marker::Unpin for BlobReaderEventStream {}
717
718impl futures::stream::FusedStream for BlobReaderEventStream {
719    fn is_terminated(&self) -> bool {
720        self.event_receiver.is_terminated()
721    }
722}
723
724impl futures::Stream for BlobReaderEventStream {
725    type Item = Result<BlobReaderEvent, fidl::Error>;
726
727    fn poll_next(
728        mut self: std::pin::Pin<&mut Self>,
729        cx: &mut std::task::Context<'_>,
730    ) -> std::task::Poll<Option<Self::Item>> {
731        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
732            &mut self.event_receiver,
733            cx
734        )?) {
735            Some(buf) => std::task::Poll::Ready(Some(BlobReaderEvent::decode(buf))),
736            None => std::task::Poll::Ready(None),
737        }
738    }
739}
740
741#[derive(Debug)]
742pub enum BlobReaderEvent {}
743
744impl BlobReaderEvent {
745    /// Decodes a message buffer as a [`BlobReaderEvent`].
746    fn decode(
747        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
748    ) -> Result<BlobReaderEvent, fidl::Error> {
749        let (bytes, _handles) = buf.split_mut();
750        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
751        debug_assert_eq!(tx_header.tx_id, 0);
752        match tx_header.ordinal {
753            _ => Err(fidl::Error::UnknownOrdinal {
754                ordinal: tx_header.ordinal,
755                protocol_name: <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
756            }),
757        }
758    }
759}
760
761/// A Stream of incoming requests for fuchsia.fxfs/BlobReader.
762pub struct BlobReaderRequestStream {
763    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
764    is_terminated: bool,
765}
766
767impl std::marker::Unpin for BlobReaderRequestStream {}
768
769impl futures::stream::FusedStream for BlobReaderRequestStream {
770    fn is_terminated(&self) -> bool {
771        self.is_terminated
772    }
773}
774
775impl fidl::endpoints::RequestStream for BlobReaderRequestStream {
776    type Protocol = BlobReaderMarker;
777    type ControlHandle = BlobReaderControlHandle;
778
779    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
780        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
781    }
782
783    fn control_handle(&self) -> Self::ControlHandle {
784        BlobReaderControlHandle { inner: self.inner.clone() }
785    }
786
787    fn into_inner(
788        self,
789    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
790    {
791        (self.inner, self.is_terminated)
792    }
793
794    fn from_inner(
795        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
796        is_terminated: bool,
797    ) -> Self {
798        Self { inner, is_terminated }
799    }
800}
801
802impl futures::Stream for BlobReaderRequestStream {
803    type Item = Result<BlobReaderRequest, fidl::Error>;
804
805    fn poll_next(
806        mut self: std::pin::Pin<&mut Self>,
807        cx: &mut std::task::Context<'_>,
808    ) -> std::task::Poll<Option<Self::Item>> {
809        let this = &mut *self;
810        if this.inner.check_shutdown(cx) {
811            this.is_terminated = true;
812            return std::task::Poll::Ready(None);
813        }
814        if this.is_terminated {
815            panic!("polled BlobReaderRequestStream after completion");
816        }
817        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
818            |bytes, handles| {
819                match this.inner.channel().read_etc(cx, bytes, handles) {
820                    std::task::Poll::Ready(Ok(())) => {}
821                    std::task::Poll::Pending => return std::task::Poll::Pending,
822                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
823                        this.is_terminated = true;
824                        return std::task::Poll::Ready(None);
825                    }
826                    std::task::Poll::Ready(Err(e)) => {
827                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
828                            e.into(),
829                        ))));
830                    }
831                }
832
833                // A message has been received from the channel
834                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
835
836                std::task::Poll::Ready(Some(match header.ordinal {
837                    0x2fa72823ef7f11f4 => {
838                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
839                        let mut req = fidl::new_empty!(
840                            BlobReaderGetVmoRequest,
841                            fidl::encoding::DefaultFuchsiaResourceDialect
842                        );
843                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobReaderGetVmoRequest>(&header, _body_bytes, handles, &mut req)?;
844                        let control_handle = BlobReaderControlHandle { inner: this.inner.clone() };
845                        Ok(BlobReaderRequest::GetVmo {
846                            blob_hash: req.blob_hash,
847
848                            responder: BlobReaderGetVmoResponder {
849                                control_handle: std::mem::ManuallyDrop::new(control_handle),
850                                tx_id: header.tx_id,
851                            },
852                        })
853                    }
854                    _ => Err(fidl::Error::UnknownOrdinal {
855                        ordinal: header.ordinal,
856                        protocol_name:
857                            <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
858                    }),
859                }))
860            },
861        )
862    }
863}
864
865#[derive(Debug)]
866pub enum BlobReaderRequest {
867    /// Given the hash of a blob, returns a VMO with its contents.
868    GetVmo { blob_hash: [u8; 32], responder: BlobReaderGetVmoResponder },
869}
870
871impl BlobReaderRequest {
872    #[allow(irrefutable_let_patterns)]
873    pub fn into_get_vmo(self) -> Option<([u8; 32], BlobReaderGetVmoResponder)> {
874        if let BlobReaderRequest::GetVmo { blob_hash, responder } = self {
875            Some((blob_hash, responder))
876        } else {
877            None
878        }
879    }
880
881    /// Name of the method defined in FIDL
882    pub fn method_name(&self) -> &'static str {
883        match *self {
884            BlobReaderRequest::GetVmo { .. } => "get_vmo",
885        }
886    }
887}
888
889#[derive(Debug, Clone)]
890pub struct BlobReaderControlHandle {
891    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
892}
893
894impl fidl::endpoints::ControlHandle for BlobReaderControlHandle {
895    fn shutdown(&self) {
896        self.inner.shutdown()
897    }
898    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
899        self.inner.shutdown_with_epitaph(status)
900    }
901
902    fn is_closed(&self) -> bool {
903        self.inner.channel().is_closed()
904    }
905    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
906        self.inner.channel().on_closed()
907    }
908
909    #[cfg(target_os = "fuchsia")]
910    fn signal_peer(
911        &self,
912        clear_mask: zx::Signals,
913        set_mask: zx::Signals,
914    ) -> Result<(), zx_status::Status> {
915        use fidl::Peered;
916        self.inner.channel().signal_peer(clear_mask, set_mask)
917    }
918}
919
920impl BlobReaderControlHandle {}
921
922#[must_use = "FIDL methods require a response to be sent"]
923#[derive(Debug)]
924pub struct BlobReaderGetVmoResponder {
925    control_handle: std::mem::ManuallyDrop<BlobReaderControlHandle>,
926    tx_id: u32,
927}
928
929/// Set the the channel to be shutdown (see [`BlobReaderControlHandle::shutdown`])
930/// if the responder is dropped without sending a response, so that the client
931/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
932impl std::ops::Drop for BlobReaderGetVmoResponder {
933    fn drop(&mut self) {
934        self.control_handle.shutdown();
935        // Safety: drops once, never accessed again
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937    }
938}
939
940impl fidl::endpoints::Responder for BlobReaderGetVmoResponder {
941    type ControlHandle = BlobReaderControlHandle;
942
943    fn control_handle(&self) -> &BlobReaderControlHandle {
944        &self.control_handle
945    }
946
947    fn drop_without_shutdown(mut self) {
948        // Safety: drops once, never accessed again due to mem::forget
949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950        // Prevent Drop from running (which would shut down the channel)
951        std::mem::forget(self);
952    }
953}
954
955impl BlobReaderGetVmoResponder {
956    /// Sends a response to the FIDL transaction.
957    ///
958    /// Sets the channel to shutdown if an error occurs.
959    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
960        let _result = self.send_raw(result);
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(
970        self,
971        mut result: Result<fidl::Vmo, i32>,
972    ) -> Result<(), fidl::Error> {
973        let _result = self.send_raw(result);
974        self.drop_without_shutdown();
975        _result
976    }
977
978    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
979        self.control_handle.inner.send::<fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>>(
980            result.map(|vmo| (vmo,)),
981            self.tx_id,
982            0x2fa72823ef7f11f4,
983            fidl::encoding::DynamicFlags::empty(),
984        )
985    }
986}
987
988#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
989pub struct BlobWriterMarker;
990
991impl fidl::endpoints::ProtocolMarker for BlobWriterMarker {
992    type Proxy = BlobWriterProxy;
993    type RequestStream = BlobWriterRequestStream;
994    #[cfg(target_os = "fuchsia")]
995    type SynchronousProxy = BlobWriterSynchronousProxy;
996
997    const DEBUG_NAME: &'static str = "(anonymous) BlobWriter";
998}
999pub type BlobWriterGetVmoResult = Result<fidl::Vmo, i32>;
1000pub type BlobWriterBytesReadyResult = Result<(), i32>;
1001
1002pub trait BlobWriterProxyInterface: Send + Sync {
1003    type GetVmoResponseFut: std::future::Future<Output = Result<BlobWriterGetVmoResult, fidl::Error>>
1004        + Send;
1005    fn r#get_vmo(&self, size: u64) -> Self::GetVmoResponseFut;
1006    type BytesReadyResponseFut: std::future::Future<Output = Result<BlobWriterBytesReadyResult, fidl::Error>>
1007        + Send;
1008    fn r#bytes_ready(&self, bytes_written: u64) -> Self::BytesReadyResponseFut;
1009}
1010#[derive(Debug)]
1011#[cfg(target_os = "fuchsia")]
1012pub struct BlobWriterSynchronousProxy {
1013    client: fidl::client::sync::Client,
1014}
1015
1016#[cfg(target_os = "fuchsia")]
1017impl fidl::endpoints::SynchronousProxy for BlobWriterSynchronousProxy {
1018    type Proxy = BlobWriterProxy;
1019    type Protocol = BlobWriterMarker;
1020
1021    fn from_channel(inner: fidl::Channel) -> Self {
1022        Self::new(inner)
1023    }
1024
1025    fn into_channel(self) -> fidl::Channel {
1026        self.client.into_channel()
1027    }
1028
1029    fn as_channel(&self) -> &fidl::Channel {
1030        self.client.as_channel()
1031    }
1032}
1033
1034#[cfg(target_os = "fuchsia")]
1035impl BlobWriterSynchronousProxy {
1036    pub fn new(channel: fidl::Channel) -> Self {
1037        let protocol_name = <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1038        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1039    }
1040
1041    pub fn into_channel(self) -> fidl::Channel {
1042        self.client.into_channel()
1043    }
1044
1045    /// Waits until an event arrives and returns it. It is safe for other
1046    /// threads to make concurrent requests while waiting for an event.
1047    pub fn wait_for_event(
1048        &self,
1049        deadline: zx::MonotonicInstant,
1050    ) -> Result<BlobWriterEvent, fidl::Error> {
1051        BlobWriterEvent::decode(self.client.wait_for_event(deadline)?)
1052    }
1053
1054    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1055    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1056    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1057    /// server that some number of bytes have been written.
1058    ///
1059    /// Ring Buffer Semantics
1060    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1061    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1062    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1063    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1064    /// until the BytesReady request corresponding to that range has completed.
1065    pub fn r#get_vmo(
1066        &self,
1067        mut size: u64,
1068        ___deadline: zx::MonotonicInstant,
1069    ) -> Result<BlobWriterGetVmoResult, fidl::Error> {
1070        let _response = self.client.send_query::<
1071            BlobWriterGetVmoRequest,
1072            fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>,
1073        >(
1074            (size,),
1075            0x50c8988b12b6f893,
1076            fidl::encoding::DynamicFlags::empty(),
1077            ___deadline,
1078        )?;
1079        Ok(_response.map(|x| x.vmo))
1080    }
1081
1082    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1083    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1084    /// blob will be readable when the final BytesReady response is received by the client.
1085    pub fn r#bytes_ready(
1086        &self,
1087        mut bytes_written: u64,
1088        ___deadline: zx::MonotonicInstant,
1089    ) -> Result<BlobWriterBytesReadyResult, fidl::Error> {
1090        let _response = self.client.send_query::<
1091            BlobWriterBytesReadyRequest,
1092            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1093        >(
1094            (bytes_written,),
1095            0x7b308b473606c573,
1096            fidl::encoding::DynamicFlags::empty(),
1097            ___deadline,
1098        )?;
1099        Ok(_response.map(|x| x))
1100    }
1101}
1102
1103#[cfg(target_os = "fuchsia")]
1104impl From<BlobWriterSynchronousProxy> for zx::Handle {
1105    fn from(value: BlobWriterSynchronousProxy) -> Self {
1106        value.into_channel().into()
1107    }
1108}
1109
1110#[cfg(target_os = "fuchsia")]
1111impl From<fidl::Channel> for BlobWriterSynchronousProxy {
1112    fn from(value: fidl::Channel) -> Self {
1113        Self::new(value)
1114    }
1115}
1116
1117#[cfg(target_os = "fuchsia")]
1118impl fidl::endpoints::FromClient for BlobWriterSynchronousProxy {
1119    type Protocol = BlobWriterMarker;
1120
1121    fn from_client(value: fidl::endpoints::ClientEnd<BlobWriterMarker>) -> Self {
1122        Self::new(value.into_channel())
1123    }
1124}
1125
1126#[derive(Debug, Clone)]
1127pub struct BlobWriterProxy {
1128    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1129}
1130
1131impl fidl::endpoints::Proxy for BlobWriterProxy {
1132    type Protocol = BlobWriterMarker;
1133
1134    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1135        Self::new(inner)
1136    }
1137
1138    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1139        self.client.into_channel().map_err(|client| Self { client })
1140    }
1141
1142    fn as_channel(&self) -> &::fidl::AsyncChannel {
1143        self.client.as_channel()
1144    }
1145}
1146
1147impl BlobWriterProxy {
1148    /// Create a new Proxy for fuchsia.fxfs/BlobWriter.
1149    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1150        let protocol_name = <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1151        Self { client: fidl::client::Client::new(channel, protocol_name) }
1152    }
1153
1154    /// Get a Stream of events from the remote end of the protocol.
1155    ///
1156    /// # Panics
1157    ///
1158    /// Panics if the event stream was already taken.
1159    pub fn take_event_stream(&self) -> BlobWriterEventStream {
1160        BlobWriterEventStream { event_receiver: self.client.take_event_receiver() }
1161    }
1162
1163    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1164    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1165    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1166    /// server that some number of bytes have been written.
1167    ///
1168    /// Ring Buffer Semantics
1169    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1170    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1171    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1172    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1173    /// until the BytesReady request corresponding to that range has completed.
1174    pub fn r#get_vmo(
1175        &self,
1176        mut size: u64,
1177    ) -> fidl::client::QueryResponseFut<
1178        BlobWriterGetVmoResult,
1179        fidl::encoding::DefaultFuchsiaResourceDialect,
1180    > {
1181        BlobWriterProxyInterface::r#get_vmo(self, size)
1182    }
1183
1184    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1185    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1186    /// blob will be readable when the final BytesReady response is received by the client.
1187    pub fn r#bytes_ready(
1188        &self,
1189        mut bytes_written: u64,
1190    ) -> fidl::client::QueryResponseFut<
1191        BlobWriterBytesReadyResult,
1192        fidl::encoding::DefaultFuchsiaResourceDialect,
1193    > {
1194        BlobWriterProxyInterface::r#bytes_ready(self, bytes_written)
1195    }
1196}
1197
1198impl BlobWriterProxyInterface for BlobWriterProxy {
1199    type GetVmoResponseFut = fidl::client::QueryResponseFut<
1200        BlobWriterGetVmoResult,
1201        fidl::encoding::DefaultFuchsiaResourceDialect,
1202    >;
1203    fn r#get_vmo(&self, mut size: u64) -> Self::GetVmoResponseFut {
1204        fn _decode(
1205            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1206        ) -> Result<BlobWriterGetVmoResult, fidl::Error> {
1207            let _response = fidl::client::decode_transaction_body::<
1208                fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>,
1209                fidl::encoding::DefaultFuchsiaResourceDialect,
1210                0x50c8988b12b6f893,
1211            >(_buf?)?;
1212            Ok(_response.map(|x| x.vmo))
1213        }
1214        self.client.send_query_and_decode::<BlobWriterGetVmoRequest, BlobWriterGetVmoResult>(
1215            (size,),
1216            0x50c8988b12b6f893,
1217            fidl::encoding::DynamicFlags::empty(),
1218            _decode,
1219        )
1220    }
1221
1222    type BytesReadyResponseFut = fidl::client::QueryResponseFut<
1223        BlobWriterBytesReadyResult,
1224        fidl::encoding::DefaultFuchsiaResourceDialect,
1225    >;
1226    fn r#bytes_ready(&self, mut bytes_written: u64) -> Self::BytesReadyResponseFut {
1227        fn _decode(
1228            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1229        ) -> Result<BlobWriterBytesReadyResult, fidl::Error> {
1230            let _response = fidl::client::decode_transaction_body::<
1231                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1232                fidl::encoding::DefaultFuchsiaResourceDialect,
1233                0x7b308b473606c573,
1234            >(_buf?)?;
1235            Ok(_response.map(|x| x))
1236        }
1237        self.client
1238            .send_query_and_decode::<BlobWriterBytesReadyRequest, BlobWriterBytesReadyResult>(
1239                (bytes_written,),
1240                0x7b308b473606c573,
1241                fidl::encoding::DynamicFlags::empty(),
1242                _decode,
1243            )
1244    }
1245}
1246
1247pub struct BlobWriterEventStream {
1248    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1249}
1250
1251impl std::marker::Unpin for BlobWriterEventStream {}
1252
1253impl futures::stream::FusedStream for BlobWriterEventStream {
1254    fn is_terminated(&self) -> bool {
1255        self.event_receiver.is_terminated()
1256    }
1257}
1258
1259impl futures::Stream for BlobWriterEventStream {
1260    type Item = Result<BlobWriterEvent, fidl::Error>;
1261
1262    fn poll_next(
1263        mut self: std::pin::Pin<&mut Self>,
1264        cx: &mut std::task::Context<'_>,
1265    ) -> std::task::Poll<Option<Self::Item>> {
1266        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1267            &mut self.event_receiver,
1268            cx
1269        )?) {
1270            Some(buf) => std::task::Poll::Ready(Some(BlobWriterEvent::decode(buf))),
1271            None => std::task::Poll::Ready(None),
1272        }
1273    }
1274}
1275
1276#[derive(Debug)]
1277pub enum BlobWriterEvent {}
1278
1279impl BlobWriterEvent {
1280    /// Decodes a message buffer as a [`BlobWriterEvent`].
1281    fn decode(
1282        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1283    ) -> Result<BlobWriterEvent, fidl::Error> {
1284        let (bytes, _handles) = buf.split_mut();
1285        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1286        debug_assert_eq!(tx_header.tx_id, 0);
1287        match tx_header.ordinal {
1288            _ => Err(fidl::Error::UnknownOrdinal {
1289                ordinal: tx_header.ordinal,
1290                protocol_name: <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1291            }),
1292        }
1293    }
1294}
1295
1296/// A Stream of incoming requests for fuchsia.fxfs/BlobWriter.
1297pub struct BlobWriterRequestStream {
1298    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1299    is_terminated: bool,
1300}
1301
1302impl std::marker::Unpin for BlobWriterRequestStream {}
1303
1304impl futures::stream::FusedStream for BlobWriterRequestStream {
1305    fn is_terminated(&self) -> bool {
1306        self.is_terminated
1307    }
1308}
1309
1310impl fidl::endpoints::RequestStream for BlobWriterRequestStream {
1311    type Protocol = BlobWriterMarker;
1312    type ControlHandle = BlobWriterControlHandle;
1313
1314    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1315        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1316    }
1317
1318    fn control_handle(&self) -> Self::ControlHandle {
1319        BlobWriterControlHandle { inner: self.inner.clone() }
1320    }
1321
1322    fn into_inner(
1323        self,
1324    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1325    {
1326        (self.inner, self.is_terminated)
1327    }
1328
1329    fn from_inner(
1330        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1331        is_terminated: bool,
1332    ) -> Self {
1333        Self { inner, is_terminated }
1334    }
1335}
1336
1337impl futures::Stream for BlobWriterRequestStream {
1338    type Item = Result<BlobWriterRequest, fidl::Error>;
1339
1340    fn poll_next(
1341        mut self: std::pin::Pin<&mut Self>,
1342        cx: &mut std::task::Context<'_>,
1343    ) -> std::task::Poll<Option<Self::Item>> {
1344        let this = &mut *self;
1345        if this.inner.check_shutdown(cx) {
1346            this.is_terminated = true;
1347            return std::task::Poll::Ready(None);
1348        }
1349        if this.is_terminated {
1350            panic!("polled BlobWriterRequestStream after completion");
1351        }
1352        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1353            |bytes, handles| {
1354                match this.inner.channel().read_etc(cx, bytes, handles) {
1355                    std::task::Poll::Ready(Ok(())) => {}
1356                    std::task::Poll::Pending => return std::task::Poll::Pending,
1357                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1358                        this.is_terminated = true;
1359                        return std::task::Poll::Ready(None);
1360                    }
1361                    std::task::Poll::Ready(Err(e)) => {
1362                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1363                            e.into(),
1364                        ))));
1365                    }
1366                }
1367
1368                // A message has been received from the channel
1369                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1370
1371                std::task::Poll::Ready(Some(match header.ordinal {
1372                    0x50c8988b12b6f893 => {
1373                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1374                        let mut req = fidl::new_empty!(
1375                            BlobWriterGetVmoRequest,
1376                            fidl::encoding::DefaultFuchsiaResourceDialect
1377                        );
1378                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobWriterGetVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1379                        let control_handle = BlobWriterControlHandle { inner: this.inner.clone() };
1380                        Ok(BlobWriterRequest::GetVmo {
1381                            size: req.size,
1382
1383                            responder: BlobWriterGetVmoResponder {
1384                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1385                                tx_id: header.tx_id,
1386                            },
1387                        })
1388                    }
1389                    0x7b308b473606c573 => {
1390                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1391                        let mut req = fidl::new_empty!(
1392                            BlobWriterBytesReadyRequest,
1393                            fidl::encoding::DefaultFuchsiaResourceDialect
1394                        );
1395                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobWriterBytesReadyRequest>(&header, _body_bytes, handles, &mut req)?;
1396                        let control_handle = BlobWriterControlHandle { inner: this.inner.clone() };
1397                        Ok(BlobWriterRequest::BytesReady {
1398                            bytes_written: req.bytes_written,
1399
1400                            responder: BlobWriterBytesReadyResponder {
1401                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1402                                tx_id: header.tx_id,
1403                            },
1404                        })
1405                    }
1406                    _ => Err(fidl::Error::UnknownOrdinal {
1407                        ordinal: header.ordinal,
1408                        protocol_name:
1409                            <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1410                    }),
1411                }))
1412            },
1413        )
1414    }
1415}
1416
1417#[derive(Debug)]
1418pub enum BlobWriterRequest {
1419    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1420    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1421    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1422    /// server that some number of bytes have been written.
1423    ///
1424    /// Ring Buffer Semantics
1425    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1426    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1427    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1428    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1429    /// until the BytesReady request corresponding to that range has completed.
1430    GetVmo { size: u64, responder: BlobWriterGetVmoResponder },
1431    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1432    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1433    /// blob will be readable when the final BytesReady response is received by the client.
1434    BytesReady { bytes_written: u64, responder: BlobWriterBytesReadyResponder },
1435}
1436
1437impl BlobWriterRequest {
1438    #[allow(irrefutable_let_patterns)]
1439    pub fn into_get_vmo(self) -> Option<(u64, BlobWriterGetVmoResponder)> {
1440        if let BlobWriterRequest::GetVmo { size, responder } = self {
1441            Some((size, responder))
1442        } else {
1443            None
1444        }
1445    }
1446
1447    #[allow(irrefutable_let_patterns)]
1448    pub fn into_bytes_ready(self) -> Option<(u64, BlobWriterBytesReadyResponder)> {
1449        if let BlobWriterRequest::BytesReady { bytes_written, responder } = self {
1450            Some((bytes_written, responder))
1451        } else {
1452            None
1453        }
1454    }
1455
1456    /// Name of the method defined in FIDL
1457    pub fn method_name(&self) -> &'static str {
1458        match *self {
1459            BlobWriterRequest::GetVmo { .. } => "get_vmo",
1460            BlobWriterRequest::BytesReady { .. } => "bytes_ready",
1461        }
1462    }
1463}
1464
1465#[derive(Debug, Clone)]
1466pub struct BlobWriterControlHandle {
1467    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1468}
1469
1470impl fidl::endpoints::ControlHandle for BlobWriterControlHandle {
1471    fn shutdown(&self) {
1472        self.inner.shutdown()
1473    }
1474    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1475        self.inner.shutdown_with_epitaph(status)
1476    }
1477
1478    fn is_closed(&self) -> bool {
1479        self.inner.channel().is_closed()
1480    }
1481    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1482        self.inner.channel().on_closed()
1483    }
1484
1485    #[cfg(target_os = "fuchsia")]
1486    fn signal_peer(
1487        &self,
1488        clear_mask: zx::Signals,
1489        set_mask: zx::Signals,
1490    ) -> Result<(), zx_status::Status> {
1491        use fidl::Peered;
1492        self.inner.channel().signal_peer(clear_mask, set_mask)
1493    }
1494}
1495
1496impl BlobWriterControlHandle {}
1497
1498#[must_use = "FIDL methods require a response to be sent"]
1499#[derive(Debug)]
1500pub struct BlobWriterGetVmoResponder {
1501    control_handle: std::mem::ManuallyDrop<BlobWriterControlHandle>,
1502    tx_id: u32,
1503}
1504
1505/// Set the the channel to be shutdown (see [`BlobWriterControlHandle::shutdown`])
1506/// if the responder is dropped without sending a response, so that the client
1507/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1508impl std::ops::Drop for BlobWriterGetVmoResponder {
1509    fn drop(&mut self) {
1510        self.control_handle.shutdown();
1511        // Safety: drops once, never accessed again
1512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1513    }
1514}
1515
1516impl fidl::endpoints::Responder for BlobWriterGetVmoResponder {
1517    type ControlHandle = BlobWriterControlHandle;
1518
1519    fn control_handle(&self) -> &BlobWriterControlHandle {
1520        &self.control_handle
1521    }
1522
1523    fn drop_without_shutdown(mut self) {
1524        // Safety: drops once, never accessed again due to mem::forget
1525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1526        // Prevent Drop from running (which would shut down the channel)
1527        std::mem::forget(self);
1528    }
1529}
1530
1531impl BlobWriterGetVmoResponder {
1532    /// Sends a response to the FIDL transaction.
1533    ///
1534    /// Sets the channel to shutdown if an error occurs.
1535    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1536        let _result = self.send_raw(result);
1537        if _result.is_err() {
1538            self.control_handle.shutdown();
1539        }
1540        self.drop_without_shutdown();
1541        _result
1542    }
1543
1544    /// Similar to "send" but does not shutdown the channel if an error occurs.
1545    pub fn send_no_shutdown_on_err(
1546        self,
1547        mut result: Result<fidl::Vmo, i32>,
1548    ) -> Result<(), fidl::Error> {
1549        let _result = self.send_raw(result);
1550        self.drop_without_shutdown();
1551        _result
1552    }
1553
1554    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1555        self.control_handle.inner.send::<fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>>(
1556            result.map(|vmo| (vmo,)),
1557            self.tx_id,
1558            0x50c8988b12b6f893,
1559            fidl::encoding::DynamicFlags::empty(),
1560        )
1561    }
1562}
1563
1564#[must_use = "FIDL methods require a response to be sent"]
1565#[derive(Debug)]
1566pub struct BlobWriterBytesReadyResponder {
1567    control_handle: std::mem::ManuallyDrop<BlobWriterControlHandle>,
1568    tx_id: u32,
1569}
1570
1571/// Set the the channel to be shutdown (see [`BlobWriterControlHandle::shutdown`])
1572/// if the responder is dropped without sending a response, so that the client
1573/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1574impl std::ops::Drop for BlobWriterBytesReadyResponder {
1575    fn drop(&mut self) {
1576        self.control_handle.shutdown();
1577        // Safety: drops once, never accessed again
1578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1579    }
1580}
1581
1582impl fidl::endpoints::Responder for BlobWriterBytesReadyResponder {
1583    type ControlHandle = BlobWriterControlHandle;
1584
1585    fn control_handle(&self) -> &BlobWriterControlHandle {
1586        &self.control_handle
1587    }
1588
1589    fn drop_without_shutdown(mut self) {
1590        // Safety: drops once, never accessed again due to mem::forget
1591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1592        // Prevent Drop from running (which would shut down the channel)
1593        std::mem::forget(self);
1594    }
1595}
1596
1597impl BlobWriterBytesReadyResponder {
1598    /// Sends a response to the FIDL transaction.
1599    ///
1600    /// Sets the channel to shutdown if an error occurs.
1601    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1602        let _result = self.send_raw(result);
1603        if _result.is_err() {
1604            self.control_handle.shutdown();
1605        }
1606        self.drop_without_shutdown();
1607        _result
1608    }
1609
1610    /// Similar to "send" but does not shutdown the channel if an error occurs.
1611    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1612        let _result = self.send_raw(result);
1613        self.drop_without_shutdown();
1614        _result
1615    }
1616
1617    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1618        self.control_handle
1619            .inner
1620            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1621                result,
1622                self.tx_id,
1623                0x7b308b473606c573,
1624                fidl::encoding::DynamicFlags::empty(),
1625            )
1626    }
1627}
1628
1629#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1630pub struct CryptMarker;
1631
1632impl fidl::endpoints::ProtocolMarker for CryptMarker {
1633    type Proxy = CryptProxy;
1634    type RequestStream = CryptRequestStream;
1635    #[cfg(target_os = "fuchsia")]
1636    type SynchronousProxy = CryptSynchronousProxy;
1637
1638    const DEBUG_NAME: &'static str = "fuchsia.fxfs.Crypt";
1639}
1640impl fidl::endpoints::DiscoverableProtocolMarker for CryptMarker {}
1641pub type CryptCreateKeyResult = Result<([u8; 16], Vec<u8>, Vec<u8>), i32>;
1642pub type CryptCreateKeyWithIdResult = Result<(WrappedKey, Vec<u8>), i32>;
1643pub type CryptUnwrapKeyResult = Result<Vec<u8>, i32>;
1644
1645pub trait CryptProxyInterface: Send + Sync {
1646    type CreateKeyResponseFut: std::future::Future<Output = Result<CryptCreateKeyResult, fidl::Error>>
1647        + Send;
1648    fn r#create_key(&self, owner: u64, purpose: KeyPurpose) -> Self::CreateKeyResponseFut;
1649    type CreateKeyWithIdResponseFut: std::future::Future<Output = Result<CryptCreateKeyWithIdResult, fidl::Error>>
1650        + Send;
1651    fn r#create_key_with_id(
1652        &self,
1653        owner: u64,
1654        wrapping_key_id: &[u8; 16],
1655        object_type: ObjectType,
1656    ) -> Self::CreateKeyWithIdResponseFut;
1657    type UnwrapKeyResponseFut: std::future::Future<Output = Result<CryptUnwrapKeyResult, fidl::Error>>
1658        + Send;
1659    fn r#unwrap_key(&self, owner: u64, wrapped_key: &WrappedKey) -> Self::UnwrapKeyResponseFut;
1660}
1661#[derive(Debug)]
1662#[cfg(target_os = "fuchsia")]
1663pub struct CryptSynchronousProxy {
1664    client: fidl::client::sync::Client,
1665}
1666
1667#[cfg(target_os = "fuchsia")]
1668impl fidl::endpoints::SynchronousProxy for CryptSynchronousProxy {
1669    type Proxy = CryptProxy;
1670    type Protocol = CryptMarker;
1671
1672    fn from_channel(inner: fidl::Channel) -> Self {
1673        Self::new(inner)
1674    }
1675
1676    fn into_channel(self) -> fidl::Channel {
1677        self.client.into_channel()
1678    }
1679
1680    fn as_channel(&self) -> &fidl::Channel {
1681        self.client.as_channel()
1682    }
1683}
1684
1685#[cfg(target_os = "fuchsia")]
1686impl CryptSynchronousProxy {
1687    pub fn new(channel: fidl::Channel) -> Self {
1688        let protocol_name = <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1689        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1690    }
1691
1692    pub fn into_channel(self) -> fidl::Channel {
1693        self.client.into_channel()
1694    }
1695
1696    /// Waits until an event arrives and returns it. It is safe for other
1697    /// threads to make concurrent requests while waiting for an event.
1698    pub fn wait_for_event(
1699        &self,
1700        deadline: zx::MonotonicInstant,
1701    ) -> Result<CryptEvent, fidl::Error> {
1702        CryptEvent::decode(self.client.wait_for_event(deadline)?)
1703    }
1704
1705    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1706    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
1707    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
1708    /// meaning to Fxfs.
1709    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
1710    pub fn r#create_key(
1711        &self,
1712        mut owner: u64,
1713        mut purpose: KeyPurpose,
1714        ___deadline: zx::MonotonicInstant,
1715    ) -> Result<CryptCreateKeyResult, fidl::Error> {
1716        let _response = self.client.send_query::<
1717            CryptCreateKeyRequest,
1718            fidl::encoding::ResultType<CryptCreateKeyResponse, i32>,
1719        >(
1720            (owner, purpose,),
1721            0x6ec69b3aee7fdbba,
1722            fidl::encoding::DynamicFlags::empty(),
1723            ___deadline,
1724        )?;
1725        Ok(_response.map(|x| (x.wrapping_key_id, x.wrapped_key, x.unwrapped_key)))
1726    }
1727
1728    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1729    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
1730    /// The `wrapping_key_id` has no meaning to Fxfs.
1731    pub fn r#create_key_with_id(
1732        &self,
1733        mut owner: u64,
1734        mut wrapping_key_id: &[u8; 16],
1735        mut object_type: ObjectType,
1736        ___deadline: zx::MonotonicInstant,
1737    ) -> Result<CryptCreateKeyWithIdResult, fidl::Error> {
1738        let _response = self.client.send_query::<
1739            CryptCreateKeyWithIdRequest,
1740            fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>,
1741        >(
1742            (owner, wrapping_key_id, object_type,),
1743            0x21e8076688700b50,
1744            fidl::encoding::DynamicFlags::empty(),
1745            ___deadline,
1746        )?;
1747        Ok(_response.map(|x| (x.wrapped_key, x.unwrapped_key)))
1748    }
1749
1750    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
1751    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
1752    /// it will just return an unwrapped key that won't actually decrpyt the data.
1753    pub fn r#unwrap_key(
1754        &self,
1755        mut owner: u64,
1756        mut wrapped_key: &WrappedKey,
1757        ___deadline: zx::MonotonicInstant,
1758    ) -> Result<CryptUnwrapKeyResult, fidl::Error> {
1759        let _response = self.client.send_query::<
1760            CryptUnwrapKeyRequest,
1761            fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>,
1762        >(
1763            (owner, wrapped_key,),
1764            0x6ec34e2b64d46be9,
1765            fidl::encoding::DynamicFlags::empty(),
1766            ___deadline,
1767        )?;
1768        Ok(_response.map(|x| x.unwrapped_key))
1769    }
1770}
1771
1772#[cfg(target_os = "fuchsia")]
1773impl From<CryptSynchronousProxy> for zx::Handle {
1774    fn from(value: CryptSynchronousProxy) -> Self {
1775        value.into_channel().into()
1776    }
1777}
1778
1779#[cfg(target_os = "fuchsia")]
1780impl From<fidl::Channel> for CryptSynchronousProxy {
1781    fn from(value: fidl::Channel) -> Self {
1782        Self::new(value)
1783    }
1784}
1785
1786#[cfg(target_os = "fuchsia")]
1787impl fidl::endpoints::FromClient for CryptSynchronousProxy {
1788    type Protocol = CryptMarker;
1789
1790    fn from_client(value: fidl::endpoints::ClientEnd<CryptMarker>) -> Self {
1791        Self::new(value.into_channel())
1792    }
1793}
1794
1795#[derive(Debug, Clone)]
1796pub struct CryptProxy {
1797    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1798}
1799
1800impl fidl::endpoints::Proxy for CryptProxy {
1801    type Protocol = CryptMarker;
1802
1803    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1804        Self::new(inner)
1805    }
1806
1807    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1808        self.client.into_channel().map_err(|client| Self { client })
1809    }
1810
1811    fn as_channel(&self) -> &::fidl::AsyncChannel {
1812        self.client.as_channel()
1813    }
1814}
1815
1816impl CryptProxy {
1817    /// Create a new Proxy for fuchsia.fxfs/Crypt.
1818    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1819        let protocol_name = <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1820        Self { client: fidl::client::Client::new(channel, protocol_name) }
1821    }
1822
1823    /// Get a Stream of events from the remote end of the protocol.
1824    ///
1825    /// # Panics
1826    ///
1827    /// Panics if the event stream was already taken.
1828    pub fn take_event_stream(&self) -> CryptEventStream {
1829        CryptEventStream { event_receiver: self.client.take_event_receiver() }
1830    }
1831
1832    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1833    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
1834    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
1835    /// meaning to Fxfs.
1836    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
1837    pub fn r#create_key(
1838        &self,
1839        mut owner: u64,
1840        mut purpose: KeyPurpose,
1841    ) -> fidl::client::QueryResponseFut<
1842        CryptCreateKeyResult,
1843        fidl::encoding::DefaultFuchsiaResourceDialect,
1844    > {
1845        CryptProxyInterface::r#create_key(self, owner, purpose)
1846    }
1847
1848    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1849    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
1850    /// The `wrapping_key_id` has no meaning to Fxfs.
1851    pub fn r#create_key_with_id(
1852        &self,
1853        mut owner: u64,
1854        mut wrapping_key_id: &[u8; 16],
1855        mut object_type: ObjectType,
1856    ) -> fidl::client::QueryResponseFut<
1857        CryptCreateKeyWithIdResult,
1858        fidl::encoding::DefaultFuchsiaResourceDialect,
1859    > {
1860        CryptProxyInterface::r#create_key_with_id(self, owner, wrapping_key_id, object_type)
1861    }
1862
1863    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
1864    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
1865    /// it will just return an unwrapped key that won't actually decrpyt the data.
1866    pub fn r#unwrap_key(
1867        &self,
1868        mut owner: u64,
1869        mut wrapped_key: &WrappedKey,
1870    ) -> fidl::client::QueryResponseFut<
1871        CryptUnwrapKeyResult,
1872        fidl::encoding::DefaultFuchsiaResourceDialect,
1873    > {
1874        CryptProxyInterface::r#unwrap_key(self, owner, wrapped_key)
1875    }
1876}
1877
1878impl CryptProxyInterface for CryptProxy {
1879    type CreateKeyResponseFut = fidl::client::QueryResponseFut<
1880        CryptCreateKeyResult,
1881        fidl::encoding::DefaultFuchsiaResourceDialect,
1882    >;
1883    fn r#create_key(&self, mut owner: u64, mut purpose: KeyPurpose) -> Self::CreateKeyResponseFut {
1884        fn _decode(
1885            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1886        ) -> Result<CryptCreateKeyResult, fidl::Error> {
1887            let _response = fidl::client::decode_transaction_body::<
1888                fidl::encoding::ResultType<CryptCreateKeyResponse, i32>,
1889                fidl::encoding::DefaultFuchsiaResourceDialect,
1890                0x6ec69b3aee7fdbba,
1891            >(_buf?)?;
1892            Ok(_response.map(|x| (x.wrapping_key_id, x.wrapped_key, x.unwrapped_key)))
1893        }
1894        self.client.send_query_and_decode::<CryptCreateKeyRequest, CryptCreateKeyResult>(
1895            (owner, purpose),
1896            0x6ec69b3aee7fdbba,
1897            fidl::encoding::DynamicFlags::empty(),
1898            _decode,
1899        )
1900    }
1901
1902    type CreateKeyWithIdResponseFut = fidl::client::QueryResponseFut<
1903        CryptCreateKeyWithIdResult,
1904        fidl::encoding::DefaultFuchsiaResourceDialect,
1905    >;
1906    fn r#create_key_with_id(
1907        &self,
1908        mut owner: u64,
1909        mut wrapping_key_id: &[u8; 16],
1910        mut object_type: ObjectType,
1911    ) -> Self::CreateKeyWithIdResponseFut {
1912        fn _decode(
1913            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1914        ) -> Result<CryptCreateKeyWithIdResult, fidl::Error> {
1915            let _response = fidl::client::decode_transaction_body::<
1916                fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>,
1917                fidl::encoding::DefaultFuchsiaResourceDialect,
1918                0x21e8076688700b50,
1919            >(_buf?)?;
1920            Ok(_response.map(|x| (x.wrapped_key, x.unwrapped_key)))
1921        }
1922        self.client
1923            .send_query_and_decode::<CryptCreateKeyWithIdRequest, CryptCreateKeyWithIdResult>(
1924                (owner, wrapping_key_id, object_type),
1925                0x21e8076688700b50,
1926                fidl::encoding::DynamicFlags::empty(),
1927                _decode,
1928            )
1929    }
1930
1931    type UnwrapKeyResponseFut = fidl::client::QueryResponseFut<
1932        CryptUnwrapKeyResult,
1933        fidl::encoding::DefaultFuchsiaResourceDialect,
1934    >;
1935    fn r#unwrap_key(
1936        &self,
1937        mut owner: u64,
1938        mut wrapped_key: &WrappedKey,
1939    ) -> Self::UnwrapKeyResponseFut {
1940        fn _decode(
1941            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1942        ) -> Result<CryptUnwrapKeyResult, fidl::Error> {
1943            let _response = fidl::client::decode_transaction_body::<
1944                fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>,
1945                fidl::encoding::DefaultFuchsiaResourceDialect,
1946                0x6ec34e2b64d46be9,
1947            >(_buf?)?;
1948            Ok(_response.map(|x| x.unwrapped_key))
1949        }
1950        self.client.send_query_and_decode::<CryptUnwrapKeyRequest, CryptUnwrapKeyResult>(
1951            (owner, wrapped_key),
1952            0x6ec34e2b64d46be9,
1953            fidl::encoding::DynamicFlags::empty(),
1954            _decode,
1955        )
1956    }
1957}
1958
1959pub struct CryptEventStream {
1960    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1961}
1962
1963impl std::marker::Unpin for CryptEventStream {}
1964
1965impl futures::stream::FusedStream for CryptEventStream {
1966    fn is_terminated(&self) -> bool {
1967        self.event_receiver.is_terminated()
1968    }
1969}
1970
1971impl futures::Stream for CryptEventStream {
1972    type Item = Result<CryptEvent, fidl::Error>;
1973
1974    fn poll_next(
1975        mut self: std::pin::Pin<&mut Self>,
1976        cx: &mut std::task::Context<'_>,
1977    ) -> std::task::Poll<Option<Self::Item>> {
1978        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1979            &mut self.event_receiver,
1980            cx
1981        )?) {
1982            Some(buf) => std::task::Poll::Ready(Some(CryptEvent::decode(buf))),
1983            None => std::task::Poll::Ready(None),
1984        }
1985    }
1986}
1987
1988#[derive(Debug)]
1989pub enum CryptEvent {}
1990
1991impl CryptEvent {
1992    /// Decodes a message buffer as a [`CryptEvent`].
1993    fn decode(
1994        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1995    ) -> Result<CryptEvent, fidl::Error> {
1996        let (bytes, _handles) = buf.split_mut();
1997        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1998        debug_assert_eq!(tx_header.tx_id, 0);
1999        match tx_header.ordinal {
2000            _ => Err(fidl::Error::UnknownOrdinal {
2001                ordinal: tx_header.ordinal,
2002                protocol_name: <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2003            }),
2004        }
2005    }
2006}
2007
2008/// A Stream of incoming requests for fuchsia.fxfs/Crypt.
2009pub struct CryptRequestStream {
2010    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2011    is_terminated: bool,
2012}
2013
2014impl std::marker::Unpin for CryptRequestStream {}
2015
2016impl futures::stream::FusedStream for CryptRequestStream {
2017    fn is_terminated(&self) -> bool {
2018        self.is_terminated
2019    }
2020}
2021
2022impl fidl::endpoints::RequestStream for CryptRequestStream {
2023    type Protocol = CryptMarker;
2024    type ControlHandle = CryptControlHandle;
2025
2026    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2027        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2028    }
2029
2030    fn control_handle(&self) -> Self::ControlHandle {
2031        CryptControlHandle { inner: self.inner.clone() }
2032    }
2033
2034    fn into_inner(
2035        self,
2036    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2037    {
2038        (self.inner, self.is_terminated)
2039    }
2040
2041    fn from_inner(
2042        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2043        is_terminated: bool,
2044    ) -> Self {
2045        Self { inner, is_terminated }
2046    }
2047}
2048
2049impl futures::Stream for CryptRequestStream {
2050    type Item = Result<CryptRequest, fidl::Error>;
2051
2052    fn poll_next(
2053        mut self: std::pin::Pin<&mut Self>,
2054        cx: &mut std::task::Context<'_>,
2055    ) -> std::task::Poll<Option<Self::Item>> {
2056        let this = &mut *self;
2057        if this.inner.check_shutdown(cx) {
2058            this.is_terminated = true;
2059            return std::task::Poll::Ready(None);
2060        }
2061        if this.is_terminated {
2062            panic!("polled CryptRequestStream after completion");
2063        }
2064        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2065            |bytes, handles| {
2066                match this.inner.channel().read_etc(cx, bytes, handles) {
2067                    std::task::Poll::Ready(Ok(())) => {}
2068                    std::task::Poll::Pending => return std::task::Poll::Pending,
2069                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2070                        this.is_terminated = true;
2071                        return std::task::Poll::Ready(None);
2072                    }
2073                    std::task::Poll::Ready(Err(e)) => {
2074                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2075                            e.into(),
2076                        ))));
2077                    }
2078                }
2079
2080                // A message has been received from the channel
2081                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2082
2083                std::task::Poll::Ready(Some(match header.ordinal {
2084                    0x6ec69b3aee7fdbba => {
2085                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2086                        let mut req = fidl::new_empty!(
2087                            CryptCreateKeyRequest,
2088                            fidl::encoding::DefaultFuchsiaResourceDialect
2089                        );
2090                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptCreateKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2091                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2092                        Ok(CryptRequest::CreateKey {
2093                            owner: req.owner,
2094                            purpose: req.purpose,
2095
2096                            responder: CryptCreateKeyResponder {
2097                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2098                                tx_id: header.tx_id,
2099                            },
2100                        })
2101                    }
2102                    0x21e8076688700b50 => {
2103                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2104                        let mut req = fidl::new_empty!(
2105                            CryptCreateKeyWithIdRequest,
2106                            fidl::encoding::DefaultFuchsiaResourceDialect
2107                        );
2108                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptCreateKeyWithIdRequest>(&header, _body_bytes, handles, &mut req)?;
2109                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2110                        Ok(CryptRequest::CreateKeyWithId {
2111                            owner: req.owner,
2112                            wrapping_key_id: req.wrapping_key_id,
2113                            object_type: req.object_type,
2114
2115                            responder: CryptCreateKeyWithIdResponder {
2116                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2117                                tx_id: header.tx_id,
2118                            },
2119                        })
2120                    }
2121                    0x6ec34e2b64d46be9 => {
2122                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2123                        let mut req = fidl::new_empty!(
2124                            CryptUnwrapKeyRequest,
2125                            fidl::encoding::DefaultFuchsiaResourceDialect
2126                        );
2127                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptUnwrapKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2128                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2129                        Ok(CryptRequest::UnwrapKey {
2130                            owner: req.owner,
2131                            wrapped_key: req.wrapped_key,
2132
2133                            responder: CryptUnwrapKeyResponder {
2134                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2135                                tx_id: header.tx_id,
2136                            },
2137                        })
2138                    }
2139                    _ => Err(fidl::Error::UnknownOrdinal {
2140                        ordinal: header.ordinal,
2141                        protocol_name: <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2142                    }),
2143                }))
2144            },
2145        )
2146    }
2147}
2148
2149#[derive(Debug)]
2150pub enum CryptRequest {
2151    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2152    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
2153    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
2154    /// meaning to Fxfs.
2155    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
2156    CreateKey { owner: u64, purpose: KeyPurpose, responder: CryptCreateKeyResponder },
2157    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2158    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
2159    /// The `wrapping_key_id` has no meaning to Fxfs.
2160    CreateKeyWithId {
2161        owner: u64,
2162        wrapping_key_id: [u8; 16],
2163        object_type: ObjectType,
2164        responder: CryptCreateKeyWithIdResponder,
2165    },
2166    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
2167    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
2168    /// it will just return an unwrapped key that won't actually decrpyt the data.
2169    UnwrapKey { owner: u64, wrapped_key: WrappedKey, responder: CryptUnwrapKeyResponder },
2170}
2171
2172impl CryptRequest {
2173    #[allow(irrefutable_let_patterns)]
2174    pub fn into_create_key(self) -> Option<(u64, KeyPurpose, CryptCreateKeyResponder)> {
2175        if let CryptRequest::CreateKey { owner, purpose, responder } = self {
2176            Some((owner, purpose, responder))
2177        } else {
2178            None
2179        }
2180    }
2181
2182    #[allow(irrefutable_let_patterns)]
2183    pub fn into_create_key_with_id(
2184        self,
2185    ) -> Option<(u64, [u8; 16], ObjectType, CryptCreateKeyWithIdResponder)> {
2186        if let CryptRequest::CreateKeyWithId { owner, wrapping_key_id, object_type, responder } =
2187            self
2188        {
2189            Some((owner, wrapping_key_id, object_type, responder))
2190        } else {
2191            None
2192        }
2193    }
2194
2195    #[allow(irrefutable_let_patterns)]
2196    pub fn into_unwrap_key(self) -> Option<(u64, WrappedKey, CryptUnwrapKeyResponder)> {
2197        if let CryptRequest::UnwrapKey { owner, wrapped_key, responder } = self {
2198            Some((owner, wrapped_key, responder))
2199        } else {
2200            None
2201        }
2202    }
2203
2204    /// Name of the method defined in FIDL
2205    pub fn method_name(&self) -> &'static str {
2206        match *self {
2207            CryptRequest::CreateKey { .. } => "create_key",
2208            CryptRequest::CreateKeyWithId { .. } => "create_key_with_id",
2209            CryptRequest::UnwrapKey { .. } => "unwrap_key",
2210        }
2211    }
2212}
2213
2214#[derive(Debug, Clone)]
2215pub struct CryptControlHandle {
2216    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2217}
2218
2219impl fidl::endpoints::ControlHandle for CryptControlHandle {
2220    fn shutdown(&self) {
2221        self.inner.shutdown()
2222    }
2223    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2224        self.inner.shutdown_with_epitaph(status)
2225    }
2226
2227    fn is_closed(&self) -> bool {
2228        self.inner.channel().is_closed()
2229    }
2230    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2231        self.inner.channel().on_closed()
2232    }
2233
2234    #[cfg(target_os = "fuchsia")]
2235    fn signal_peer(
2236        &self,
2237        clear_mask: zx::Signals,
2238        set_mask: zx::Signals,
2239    ) -> Result<(), zx_status::Status> {
2240        use fidl::Peered;
2241        self.inner.channel().signal_peer(clear_mask, set_mask)
2242    }
2243}
2244
2245impl CryptControlHandle {}
2246
2247#[must_use = "FIDL methods require a response to be sent"]
2248#[derive(Debug)]
2249pub struct CryptCreateKeyResponder {
2250    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2251    tx_id: u32,
2252}
2253
2254/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2255/// if the responder is dropped without sending a response, so that the client
2256/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2257impl std::ops::Drop for CryptCreateKeyResponder {
2258    fn drop(&mut self) {
2259        self.control_handle.shutdown();
2260        // Safety: drops once, never accessed again
2261        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2262    }
2263}
2264
2265impl fidl::endpoints::Responder for CryptCreateKeyResponder {
2266    type ControlHandle = CryptControlHandle;
2267
2268    fn control_handle(&self) -> &CryptControlHandle {
2269        &self.control_handle
2270    }
2271
2272    fn drop_without_shutdown(mut self) {
2273        // Safety: drops once, never accessed again due to mem::forget
2274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2275        // Prevent Drop from running (which would shut down the channel)
2276        std::mem::forget(self);
2277    }
2278}
2279
2280impl CryptCreateKeyResponder {
2281    /// Sends a response to the FIDL transaction.
2282    ///
2283    /// Sets the channel to shutdown if an error occurs.
2284    pub fn send(
2285        self,
2286        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2287    ) -> Result<(), fidl::Error> {
2288        let _result = self.send_raw(result);
2289        if _result.is_err() {
2290            self.control_handle.shutdown();
2291        }
2292        self.drop_without_shutdown();
2293        _result
2294    }
2295
2296    /// Similar to "send" but does not shutdown the channel if an error occurs.
2297    pub fn send_no_shutdown_on_err(
2298        self,
2299        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2300    ) -> Result<(), fidl::Error> {
2301        let _result = self.send_raw(result);
2302        self.drop_without_shutdown();
2303        _result
2304    }
2305
2306    fn send_raw(
2307        &self,
2308        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2309    ) -> Result<(), fidl::Error> {
2310        self.control_handle.inner.send::<fidl::encoding::ResultType<CryptCreateKeyResponse, i32>>(
2311            result,
2312            self.tx_id,
2313            0x6ec69b3aee7fdbba,
2314            fidl::encoding::DynamicFlags::empty(),
2315        )
2316    }
2317}
2318
2319#[must_use = "FIDL methods require a response to be sent"]
2320#[derive(Debug)]
2321pub struct CryptCreateKeyWithIdResponder {
2322    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2323    tx_id: u32,
2324}
2325
2326/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2327/// if the responder is dropped without sending a response, so that the client
2328/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2329impl std::ops::Drop for CryptCreateKeyWithIdResponder {
2330    fn drop(&mut self) {
2331        self.control_handle.shutdown();
2332        // Safety: drops once, never accessed again
2333        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2334    }
2335}
2336
2337impl fidl::endpoints::Responder for CryptCreateKeyWithIdResponder {
2338    type ControlHandle = CryptControlHandle;
2339
2340    fn control_handle(&self) -> &CryptControlHandle {
2341        &self.control_handle
2342    }
2343
2344    fn drop_without_shutdown(mut self) {
2345        // Safety: drops once, never accessed again due to mem::forget
2346        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2347        // Prevent Drop from running (which would shut down the channel)
2348        std::mem::forget(self);
2349    }
2350}
2351
2352impl CryptCreateKeyWithIdResponder {
2353    /// Sends a response to the FIDL transaction.
2354    ///
2355    /// Sets the channel to shutdown if an error occurs.
2356    pub fn send(self, mut result: Result<(&WrappedKey, &[u8]), i32>) -> Result<(), fidl::Error> {
2357        let _result = self.send_raw(result);
2358        if _result.is_err() {
2359            self.control_handle.shutdown();
2360        }
2361        self.drop_without_shutdown();
2362        _result
2363    }
2364
2365    /// Similar to "send" but does not shutdown the channel if an error occurs.
2366    pub fn send_no_shutdown_on_err(
2367        self,
2368        mut result: Result<(&WrappedKey, &[u8]), i32>,
2369    ) -> Result<(), fidl::Error> {
2370        let _result = self.send_raw(result);
2371        self.drop_without_shutdown();
2372        _result
2373    }
2374
2375    fn send_raw(&self, mut result: Result<(&WrappedKey, &[u8]), i32>) -> Result<(), fidl::Error> {
2376        self.control_handle
2377            .inner
2378            .send::<fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>>(
2379                result,
2380                self.tx_id,
2381                0x21e8076688700b50,
2382                fidl::encoding::DynamicFlags::empty(),
2383            )
2384    }
2385}
2386
2387#[must_use = "FIDL methods require a response to be sent"]
2388#[derive(Debug)]
2389pub struct CryptUnwrapKeyResponder {
2390    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2391    tx_id: u32,
2392}
2393
2394/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2395/// if the responder is dropped without sending a response, so that the client
2396/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2397impl std::ops::Drop for CryptUnwrapKeyResponder {
2398    fn drop(&mut self) {
2399        self.control_handle.shutdown();
2400        // Safety: drops once, never accessed again
2401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2402    }
2403}
2404
2405impl fidl::endpoints::Responder for CryptUnwrapKeyResponder {
2406    type ControlHandle = CryptControlHandle;
2407
2408    fn control_handle(&self) -> &CryptControlHandle {
2409        &self.control_handle
2410    }
2411
2412    fn drop_without_shutdown(mut self) {
2413        // Safety: drops once, never accessed again due to mem::forget
2414        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2415        // Prevent Drop from running (which would shut down the channel)
2416        std::mem::forget(self);
2417    }
2418}
2419
2420impl CryptUnwrapKeyResponder {
2421    /// Sends a response to the FIDL transaction.
2422    ///
2423    /// Sets the channel to shutdown if an error occurs.
2424    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2425        let _result = self.send_raw(result);
2426        if _result.is_err() {
2427            self.control_handle.shutdown();
2428        }
2429        self.drop_without_shutdown();
2430        _result
2431    }
2432
2433    /// Similar to "send" but does not shutdown the channel if an error occurs.
2434    pub fn send_no_shutdown_on_err(
2435        self,
2436        mut result: Result<&[u8], i32>,
2437    ) -> Result<(), fidl::Error> {
2438        let _result = self.send_raw(result);
2439        self.drop_without_shutdown();
2440        _result
2441    }
2442
2443    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2444        self.control_handle.inner.send::<fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>>(
2445            result.map(|unwrapped_key| (unwrapped_key,)),
2446            self.tx_id,
2447            0x6ec34e2b64d46be9,
2448            fidl::encoding::DynamicFlags::empty(),
2449        )
2450    }
2451}
2452
2453#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2454pub struct CryptManagementMarker;
2455
2456impl fidl::endpoints::ProtocolMarker for CryptManagementMarker {
2457    type Proxy = CryptManagementProxy;
2458    type RequestStream = CryptManagementRequestStream;
2459    #[cfg(target_os = "fuchsia")]
2460    type SynchronousProxy = CryptManagementSynchronousProxy;
2461
2462    const DEBUG_NAME: &'static str = "fuchsia.fxfs.CryptManagement";
2463}
2464impl fidl::endpoints::DiscoverableProtocolMarker for CryptManagementMarker {}
2465pub type CryptManagementAddWrappingKeyResult = Result<(), i32>;
2466pub type CryptManagementSetActiveKeyResult = Result<(), i32>;
2467pub type CryptManagementForgetWrappingKeyResult = Result<(), i32>;
2468
2469pub trait CryptManagementProxyInterface: Send + Sync {
2470    type AddWrappingKeyResponseFut: std::future::Future<Output = Result<CryptManagementAddWrappingKeyResult, fidl::Error>>
2471        + Send;
2472    fn r#add_wrapping_key(
2473        &self,
2474        wrapping_key_id: &[u8; 16],
2475        key: &[u8],
2476    ) -> Self::AddWrappingKeyResponseFut;
2477    type SetActiveKeyResponseFut: std::future::Future<Output = Result<CryptManagementSetActiveKeyResult, fidl::Error>>
2478        + Send;
2479    fn r#set_active_key(
2480        &self,
2481        purpose: KeyPurpose,
2482        wrapping_key_id: &[u8; 16],
2483    ) -> Self::SetActiveKeyResponseFut;
2484    type ForgetWrappingKeyResponseFut: std::future::Future<Output = Result<CryptManagementForgetWrappingKeyResult, fidl::Error>>
2485        + Send;
2486    fn r#forget_wrapping_key(
2487        &self,
2488        wrapping_key_id: &[u8; 16],
2489    ) -> Self::ForgetWrappingKeyResponseFut;
2490}
2491#[derive(Debug)]
2492#[cfg(target_os = "fuchsia")]
2493pub struct CryptManagementSynchronousProxy {
2494    client: fidl::client::sync::Client,
2495}
2496
2497#[cfg(target_os = "fuchsia")]
2498impl fidl::endpoints::SynchronousProxy for CryptManagementSynchronousProxy {
2499    type Proxy = CryptManagementProxy;
2500    type Protocol = CryptManagementMarker;
2501
2502    fn from_channel(inner: fidl::Channel) -> Self {
2503        Self::new(inner)
2504    }
2505
2506    fn into_channel(self) -> fidl::Channel {
2507        self.client.into_channel()
2508    }
2509
2510    fn as_channel(&self) -> &fidl::Channel {
2511        self.client.as_channel()
2512    }
2513}
2514
2515#[cfg(target_os = "fuchsia")]
2516impl CryptManagementSynchronousProxy {
2517    pub fn new(channel: fidl::Channel) -> Self {
2518        let protocol_name = <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2519        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2520    }
2521
2522    pub fn into_channel(self) -> fidl::Channel {
2523        self.client.into_channel()
2524    }
2525
2526    /// Waits until an event arrives and returns it. It is safe for other
2527    /// threads to make concurrent requests while waiting for an event.
2528    pub fn wait_for_event(
2529        &self,
2530        deadline: zx::MonotonicInstant,
2531    ) -> Result<CryptManagementEvent, fidl::Error> {
2532        CryptManagementEvent::decode(self.client.wait_for_event(deadline)?)
2533    }
2534
2535    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
2536    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
2537    /// CryptManagement::SetActiveKeys is called.
2538    pub fn r#add_wrapping_key(
2539        &self,
2540        mut wrapping_key_id: &[u8; 16],
2541        mut key: &[u8],
2542        ___deadline: zx::MonotonicInstant,
2543    ) -> Result<CryptManagementAddWrappingKeyResult, fidl::Error> {
2544        let _response = self.client.send_query::<
2545            CryptManagementAddWrappingKeyRequest,
2546            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2547        >(
2548            (wrapping_key_id, key,),
2549            0x59a5076762318bf,
2550            fidl::encoding::DynamicFlags::empty(),
2551            ___deadline,
2552        )?;
2553        Ok(_response.map(|x| x))
2554    }
2555
2556    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
2557    /// describes which active key to modify.
2558    pub fn r#set_active_key(
2559        &self,
2560        mut purpose: KeyPurpose,
2561        mut wrapping_key_id: &[u8; 16],
2562        ___deadline: zx::MonotonicInstant,
2563    ) -> Result<CryptManagementSetActiveKeyResult, fidl::Error> {
2564        let _response = self.client.send_query::<
2565            CryptManagementSetActiveKeyRequest,
2566            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2567        >(
2568            (purpose, wrapping_key_id,),
2569            0x5e81d600442f2872,
2570            fidl::encoding::DynamicFlags::empty(),
2571            ___deadline,
2572        )?;
2573        Ok(_response.map(|x| x))
2574    }
2575
2576    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
2577    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
2578    /// If either the data or metadata part of the key is active, an error is returned.
2579    pub fn r#forget_wrapping_key(
2580        &self,
2581        mut wrapping_key_id: &[u8; 16],
2582        ___deadline: zx::MonotonicInstant,
2583    ) -> Result<CryptManagementForgetWrappingKeyResult, fidl::Error> {
2584        let _response = self.client.send_query::<
2585            CryptManagementForgetWrappingKeyRequest,
2586            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2587        >(
2588            (wrapping_key_id,),
2589            0x436d6d27696dfcf4,
2590            fidl::encoding::DynamicFlags::empty(),
2591            ___deadline,
2592        )?;
2593        Ok(_response.map(|x| x))
2594    }
2595}
2596
2597#[cfg(target_os = "fuchsia")]
2598impl From<CryptManagementSynchronousProxy> for zx::Handle {
2599    fn from(value: CryptManagementSynchronousProxy) -> Self {
2600        value.into_channel().into()
2601    }
2602}
2603
2604#[cfg(target_os = "fuchsia")]
2605impl From<fidl::Channel> for CryptManagementSynchronousProxy {
2606    fn from(value: fidl::Channel) -> Self {
2607        Self::new(value)
2608    }
2609}
2610
2611#[cfg(target_os = "fuchsia")]
2612impl fidl::endpoints::FromClient for CryptManagementSynchronousProxy {
2613    type Protocol = CryptManagementMarker;
2614
2615    fn from_client(value: fidl::endpoints::ClientEnd<CryptManagementMarker>) -> Self {
2616        Self::new(value.into_channel())
2617    }
2618}
2619
2620#[derive(Debug, Clone)]
2621pub struct CryptManagementProxy {
2622    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2623}
2624
2625impl fidl::endpoints::Proxy for CryptManagementProxy {
2626    type Protocol = CryptManagementMarker;
2627
2628    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2629        Self::new(inner)
2630    }
2631
2632    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2633        self.client.into_channel().map_err(|client| Self { client })
2634    }
2635
2636    fn as_channel(&self) -> &::fidl::AsyncChannel {
2637        self.client.as_channel()
2638    }
2639}
2640
2641impl CryptManagementProxy {
2642    /// Create a new Proxy for fuchsia.fxfs/CryptManagement.
2643    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2644        let protocol_name = <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2645        Self { client: fidl::client::Client::new(channel, protocol_name) }
2646    }
2647
2648    /// Get a Stream of events from the remote end of the protocol.
2649    ///
2650    /// # Panics
2651    ///
2652    /// Panics if the event stream was already taken.
2653    pub fn take_event_stream(&self) -> CryptManagementEventStream {
2654        CryptManagementEventStream { event_receiver: self.client.take_event_receiver() }
2655    }
2656
2657    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
2658    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
2659    /// CryptManagement::SetActiveKeys is called.
2660    pub fn r#add_wrapping_key(
2661        &self,
2662        mut wrapping_key_id: &[u8; 16],
2663        mut key: &[u8],
2664    ) -> fidl::client::QueryResponseFut<
2665        CryptManagementAddWrappingKeyResult,
2666        fidl::encoding::DefaultFuchsiaResourceDialect,
2667    > {
2668        CryptManagementProxyInterface::r#add_wrapping_key(self, wrapping_key_id, key)
2669    }
2670
2671    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
2672    /// describes which active key to modify.
2673    pub fn r#set_active_key(
2674        &self,
2675        mut purpose: KeyPurpose,
2676        mut wrapping_key_id: &[u8; 16],
2677    ) -> fidl::client::QueryResponseFut<
2678        CryptManagementSetActiveKeyResult,
2679        fidl::encoding::DefaultFuchsiaResourceDialect,
2680    > {
2681        CryptManagementProxyInterface::r#set_active_key(self, purpose, wrapping_key_id)
2682    }
2683
2684    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
2685    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
2686    /// If either the data or metadata part of the key is active, an error is returned.
2687    pub fn r#forget_wrapping_key(
2688        &self,
2689        mut wrapping_key_id: &[u8; 16],
2690    ) -> fidl::client::QueryResponseFut<
2691        CryptManagementForgetWrappingKeyResult,
2692        fidl::encoding::DefaultFuchsiaResourceDialect,
2693    > {
2694        CryptManagementProxyInterface::r#forget_wrapping_key(self, wrapping_key_id)
2695    }
2696}
2697
2698impl CryptManagementProxyInterface for CryptManagementProxy {
2699    type AddWrappingKeyResponseFut = fidl::client::QueryResponseFut<
2700        CryptManagementAddWrappingKeyResult,
2701        fidl::encoding::DefaultFuchsiaResourceDialect,
2702    >;
2703    fn r#add_wrapping_key(
2704        &self,
2705        mut wrapping_key_id: &[u8; 16],
2706        mut key: &[u8],
2707    ) -> Self::AddWrappingKeyResponseFut {
2708        fn _decode(
2709            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2710        ) -> Result<CryptManagementAddWrappingKeyResult, fidl::Error> {
2711            let _response = fidl::client::decode_transaction_body::<
2712                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2713                fidl::encoding::DefaultFuchsiaResourceDialect,
2714                0x59a5076762318bf,
2715            >(_buf?)?;
2716            Ok(_response.map(|x| x))
2717        }
2718        self.client.send_query_and_decode::<
2719            CryptManagementAddWrappingKeyRequest,
2720            CryptManagementAddWrappingKeyResult,
2721        >(
2722            (wrapping_key_id, key,),
2723            0x59a5076762318bf,
2724            fidl::encoding::DynamicFlags::empty(),
2725            _decode,
2726        )
2727    }
2728
2729    type SetActiveKeyResponseFut = fidl::client::QueryResponseFut<
2730        CryptManagementSetActiveKeyResult,
2731        fidl::encoding::DefaultFuchsiaResourceDialect,
2732    >;
2733    fn r#set_active_key(
2734        &self,
2735        mut purpose: KeyPurpose,
2736        mut wrapping_key_id: &[u8; 16],
2737    ) -> Self::SetActiveKeyResponseFut {
2738        fn _decode(
2739            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2740        ) -> Result<CryptManagementSetActiveKeyResult, fidl::Error> {
2741            let _response = fidl::client::decode_transaction_body::<
2742                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2743                fidl::encoding::DefaultFuchsiaResourceDialect,
2744                0x5e81d600442f2872,
2745            >(_buf?)?;
2746            Ok(_response.map(|x| x))
2747        }
2748        self.client.send_query_and_decode::<
2749            CryptManagementSetActiveKeyRequest,
2750            CryptManagementSetActiveKeyResult,
2751        >(
2752            (purpose, wrapping_key_id,),
2753            0x5e81d600442f2872,
2754            fidl::encoding::DynamicFlags::empty(),
2755            _decode,
2756        )
2757    }
2758
2759    type ForgetWrappingKeyResponseFut = fidl::client::QueryResponseFut<
2760        CryptManagementForgetWrappingKeyResult,
2761        fidl::encoding::DefaultFuchsiaResourceDialect,
2762    >;
2763    fn r#forget_wrapping_key(
2764        &self,
2765        mut wrapping_key_id: &[u8; 16],
2766    ) -> Self::ForgetWrappingKeyResponseFut {
2767        fn _decode(
2768            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2769        ) -> Result<CryptManagementForgetWrappingKeyResult, fidl::Error> {
2770            let _response = fidl::client::decode_transaction_body::<
2771                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2772                fidl::encoding::DefaultFuchsiaResourceDialect,
2773                0x436d6d27696dfcf4,
2774            >(_buf?)?;
2775            Ok(_response.map(|x| x))
2776        }
2777        self.client.send_query_and_decode::<
2778            CryptManagementForgetWrappingKeyRequest,
2779            CryptManagementForgetWrappingKeyResult,
2780        >(
2781            (wrapping_key_id,),
2782            0x436d6d27696dfcf4,
2783            fidl::encoding::DynamicFlags::empty(),
2784            _decode,
2785        )
2786    }
2787}
2788
2789pub struct CryptManagementEventStream {
2790    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2791}
2792
2793impl std::marker::Unpin for CryptManagementEventStream {}
2794
2795impl futures::stream::FusedStream for CryptManagementEventStream {
2796    fn is_terminated(&self) -> bool {
2797        self.event_receiver.is_terminated()
2798    }
2799}
2800
2801impl futures::Stream for CryptManagementEventStream {
2802    type Item = Result<CryptManagementEvent, fidl::Error>;
2803
2804    fn poll_next(
2805        mut self: std::pin::Pin<&mut Self>,
2806        cx: &mut std::task::Context<'_>,
2807    ) -> std::task::Poll<Option<Self::Item>> {
2808        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2809            &mut self.event_receiver,
2810            cx
2811        )?) {
2812            Some(buf) => std::task::Poll::Ready(Some(CryptManagementEvent::decode(buf))),
2813            None => std::task::Poll::Ready(None),
2814        }
2815    }
2816}
2817
2818#[derive(Debug)]
2819pub enum CryptManagementEvent {}
2820
2821impl CryptManagementEvent {
2822    /// Decodes a message buffer as a [`CryptManagementEvent`].
2823    fn decode(
2824        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2825    ) -> Result<CryptManagementEvent, fidl::Error> {
2826        let (bytes, _handles) = buf.split_mut();
2827        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2828        debug_assert_eq!(tx_header.tx_id, 0);
2829        match tx_header.ordinal {
2830            _ => Err(fidl::Error::UnknownOrdinal {
2831                ordinal: tx_header.ordinal,
2832                protocol_name:
2833                    <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2834            }),
2835        }
2836    }
2837}
2838
2839/// A Stream of incoming requests for fuchsia.fxfs/CryptManagement.
2840pub struct CryptManagementRequestStream {
2841    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2842    is_terminated: bool,
2843}
2844
2845impl std::marker::Unpin for CryptManagementRequestStream {}
2846
2847impl futures::stream::FusedStream for CryptManagementRequestStream {
2848    fn is_terminated(&self) -> bool {
2849        self.is_terminated
2850    }
2851}
2852
2853impl fidl::endpoints::RequestStream for CryptManagementRequestStream {
2854    type Protocol = CryptManagementMarker;
2855    type ControlHandle = CryptManagementControlHandle;
2856
2857    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2858        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2859    }
2860
2861    fn control_handle(&self) -> Self::ControlHandle {
2862        CryptManagementControlHandle { inner: self.inner.clone() }
2863    }
2864
2865    fn into_inner(
2866        self,
2867    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2868    {
2869        (self.inner, self.is_terminated)
2870    }
2871
2872    fn from_inner(
2873        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2874        is_terminated: bool,
2875    ) -> Self {
2876        Self { inner, is_terminated }
2877    }
2878}
2879
2880impl futures::Stream for CryptManagementRequestStream {
2881    type Item = Result<CryptManagementRequest, fidl::Error>;
2882
2883    fn poll_next(
2884        mut self: std::pin::Pin<&mut Self>,
2885        cx: &mut std::task::Context<'_>,
2886    ) -> std::task::Poll<Option<Self::Item>> {
2887        let this = &mut *self;
2888        if this.inner.check_shutdown(cx) {
2889            this.is_terminated = true;
2890            return std::task::Poll::Ready(None);
2891        }
2892        if this.is_terminated {
2893            panic!("polled CryptManagementRequestStream after completion");
2894        }
2895        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2896            |bytes, handles| {
2897                match this.inner.channel().read_etc(cx, bytes, handles) {
2898                    std::task::Poll::Ready(Ok(())) => {}
2899                    std::task::Poll::Pending => return std::task::Poll::Pending,
2900                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2901                        this.is_terminated = true;
2902                        return std::task::Poll::Ready(None);
2903                    }
2904                    std::task::Poll::Ready(Err(e)) => {
2905                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2906                            e.into(),
2907                        ))));
2908                    }
2909                }
2910
2911                // A message has been received from the channel
2912                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2913
2914                std::task::Poll::Ready(Some(match header.ordinal {
2915                    0x59a5076762318bf => {
2916                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2917                        let mut req = fidl::new_empty!(
2918                            CryptManagementAddWrappingKeyRequest,
2919                            fidl::encoding::DefaultFuchsiaResourceDialect
2920                        );
2921                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementAddWrappingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2922                        let control_handle =
2923                            CryptManagementControlHandle { inner: this.inner.clone() };
2924                        Ok(CryptManagementRequest::AddWrappingKey {
2925                            wrapping_key_id: req.wrapping_key_id,
2926                            key: req.key,
2927
2928                            responder: CryptManagementAddWrappingKeyResponder {
2929                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2930                                tx_id: header.tx_id,
2931                            },
2932                        })
2933                    }
2934                    0x5e81d600442f2872 => {
2935                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2936                        let mut req = fidl::new_empty!(
2937                            CryptManagementSetActiveKeyRequest,
2938                            fidl::encoding::DefaultFuchsiaResourceDialect
2939                        );
2940                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementSetActiveKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2941                        let control_handle =
2942                            CryptManagementControlHandle { inner: this.inner.clone() };
2943                        Ok(CryptManagementRequest::SetActiveKey {
2944                            purpose: req.purpose,
2945                            wrapping_key_id: req.wrapping_key_id,
2946
2947                            responder: CryptManagementSetActiveKeyResponder {
2948                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2949                                tx_id: header.tx_id,
2950                            },
2951                        })
2952                    }
2953                    0x436d6d27696dfcf4 => {
2954                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2955                        let mut req = fidl::new_empty!(
2956                            CryptManagementForgetWrappingKeyRequest,
2957                            fidl::encoding::DefaultFuchsiaResourceDialect
2958                        );
2959                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementForgetWrappingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2960                        let control_handle =
2961                            CryptManagementControlHandle { inner: this.inner.clone() };
2962                        Ok(CryptManagementRequest::ForgetWrappingKey {
2963                            wrapping_key_id: req.wrapping_key_id,
2964
2965                            responder: CryptManagementForgetWrappingKeyResponder {
2966                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2967                                tx_id: header.tx_id,
2968                            },
2969                        })
2970                    }
2971                    _ => Err(fidl::Error::UnknownOrdinal {
2972                        ordinal: header.ordinal,
2973                        protocol_name:
2974                            <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2975                    }),
2976                }))
2977            },
2978        )
2979    }
2980}
2981
2982#[derive(Debug)]
2983pub enum CryptManagementRequest {
2984    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
2985    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
2986    /// CryptManagement::SetActiveKeys is called.
2987    AddWrappingKey {
2988        wrapping_key_id: [u8; 16],
2989        key: Vec<u8>,
2990        responder: CryptManagementAddWrappingKeyResponder,
2991    },
2992    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
2993    /// describes which active key to modify.
2994    SetActiveKey {
2995        purpose: KeyPurpose,
2996        wrapping_key_id: [u8; 16],
2997        responder: CryptManagementSetActiveKeyResponder,
2998    },
2999    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
3000    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
3001    /// If either the data or metadata part of the key is active, an error is returned.
3002    ForgetWrappingKey {
3003        wrapping_key_id: [u8; 16],
3004        responder: CryptManagementForgetWrappingKeyResponder,
3005    },
3006}
3007
3008impl CryptManagementRequest {
3009    #[allow(irrefutable_let_patterns)]
3010    pub fn into_add_wrapping_key(
3011        self,
3012    ) -> Option<([u8; 16], Vec<u8>, CryptManagementAddWrappingKeyResponder)> {
3013        if let CryptManagementRequest::AddWrappingKey { wrapping_key_id, key, responder } = self {
3014            Some((wrapping_key_id, key, responder))
3015        } else {
3016            None
3017        }
3018    }
3019
3020    #[allow(irrefutable_let_patterns)]
3021    pub fn into_set_active_key(
3022        self,
3023    ) -> Option<(KeyPurpose, [u8; 16], CryptManagementSetActiveKeyResponder)> {
3024        if let CryptManagementRequest::SetActiveKey { purpose, wrapping_key_id, responder } = self {
3025            Some((purpose, wrapping_key_id, responder))
3026        } else {
3027            None
3028        }
3029    }
3030
3031    #[allow(irrefutable_let_patterns)]
3032    pub fn into_forget_wrapping_key(
3033        self,
3034    ) -> Option<([u8; 16], CryptManagementForgetWrappingKeyResponder)> {
3035        if let CryptManagementRequest::ForgetWrappingKey { wrapping_key_id, responder } = self {
3036            Some((wrapping_key_id, responder))
3037        } else {
3038            None
3039        }
3040    }
3041
3042    /// Name of the method defined in FIDL
3043    pub fn method_name(&self) -> &'static str {
3044        match *self {
3045            CryptManagementRequest::AddWrappingKey { .. } => "add_wrapping_key",
3046            CryptManagementRequest::SetActiveKey { .. } => "set_active_key",
3047            CryptManagementRequest::ForgetWrappingKey { .. } => "forget_wrapping_key",
3048        }
3049    }
3050}
3051
3052#[derive(Debug, Clone)]
3053pub struct CryptManagementControlHandle {
3054    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3055}
3056
3057impl fidl::endpoints::ControlHandle for CryptManagementControlHandle {
3058    fn shutdown(&self) {
3059        self.inner.shutdown()
3060    }
3061    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3062        self.inner.shutdown_with_epitaph(status)
3063    }
3064
3065    fn is_closed(&self) -> bool {
3066        self.inner.channel().is_closed()
3067    }
3068    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3069        self.inner.channel().on_closed()
3070    }
3071
3072    #[cfg(target_os = "fuchsia")]
3073    fn signal_peer(
3074        &self,
3075        clear_mask: zx::Signals,
3076        set_mask: zx::Signals,
3077    ) -> Result<(), zx_status::Status> {
3078        use fidl::Peered;
3079        self.inner.channel().signal_peer(clear_mask, set_mask)
3080    }
3081}
3082
3083impl CryptManagementControlHandle {}
3084
3085#[must_use = "FIDL methods require a response to be sent"]
3086#[derive(Debug)]
3087pub struct CryptManagementAddWrappingKeyResponder {
3088    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3089    tx_id: u32,
3090}
3091
3092/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3093/// if the responder is dropped without sending a response, so that the client
3094/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3095impl std::ops::Drop for CryptManagementAddWrappingKeyResponder {
3096    fn drop(&mut self) {
3097        self.control_handle.shutdown();
3098        // Safety: drops once, never accessed again
3099        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3100    }
3101}
3102
3103impl fidl::endpoints::Responder for CryptManagementAddWrappingKeyResponder {
3104    type ControlHandle = CryptManagementControlHandle;
3105
3106    fn control_handle(&self) -> &CryptManagementControlHandle {
3107        &self.control_handle
3108    }
3109
3110    fn drop_without_shutdown(mut self) {
3111        // Safety: drops once, never accessed again due to mem::forget
3112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3113        // Prevent Drop from running (which would shut down the channel)
3114        std::mem::forget(self);
3115    }
3116}
3117
3118impl CryptManagementAddWrappingKeyResponder {
3119    /// Sends a response to the FIDL transaction.
3120    ///
3121    /// Sets the channel to shutdown if an error occurs.
3122    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3123        let _result = self.send_raw(result);
3124        if _result.is_err() {
3125            self.control_handle.shutdown();
3126        }
3127        self.drop_without_shutdown();
3128        _result
3129    }
3130
3131    /// Similar to "send" but does not shutdown the channel if an error occurs.
3132    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3133        let _result = self.send_raw(result);
3134        self.drop_without_shutdown();
3135        _result
3136    }
3137
3138    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3139        self.control_handle
3140            .inner
3141            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3142                result,
3143                self.tx_id,
3144                0x59a5076762318bf,
3145                fidl::encoding::DynamicFlags::empty(),
3146            )
3147    }
3148}
3149
3150#[must_use = "FIDL methods require a response to be sent"]
3151#[derive(Debug)]
3152pub struct CryptManagementSetActiveKeyResponder {
3153    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3154    tx_id: u32,
3155}
3156
3157/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3158/// if the responder is dropped without sending a response, so that the client
3159/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3160impl std::ops::Drop for CryptManagementSetActiveKeyResponder {
3161    fn drop(&mut self) {
3162        self.control_handle.shutdown();
3163        // Safety: drops once, never accessed again
3164        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3165    }
3166}
3167
3168impl fidl::endpoints::Responder for CryptManagementSetActiveKeyResponder {
3169    type ControlHandle = CryptManagementControlHandle;
3170
3171    fn control_handle(&self) -> &CryptManagementControlHandle {
3172        &self.control_handle
3173    }
3174
3175    fn drop_without_shutdown(mut self) {
3176        // Safety: drops once, never accessed again due to mem::forget
3177        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3178        // Prevent Drop from running (which would shut down the channel)
3179        std::mem::forget(self);
3180    }
3181}
3182
3183impl CryptManagementSetActiveKeyResponder {
3184    /// Sends a response to the FIDL transaction.
3185    ///
3186    /// Sets the channel to shutdown if an error occurs.
3187    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3188        let _result = self.send_raw(result);
3189        if _result.is_err() {
3190            self.control_handle.shutdown();
3191        }
3192        self.drop_without_shutdown();
3193        _result
3194    }
3195
3196    /// Similar to "send" but does not shutdown the channel if an error occurs.
3197    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3198        let _result = self.send_raw(result);
3199        self.drop_without_shutdown();
3200        _result
3201    }
3202
3203    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3204        self.control_handle
3205            .inner
3206            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3207                result,
3208                self.tx_id,
3209                0x5e81d600442f2872,
3210                fidl::encoding::DynamicFlags::empty(),
3211            )
3212    }
3213}
3214
3215#[must_use = "FIDL methods require a response to be sent"]
3216#[derive(Debug)]
3217pub struct CryptManagementForgetWrappingKeyResponder {
3218    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3219    tx_id: u32,
3220}
3221
3222/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3223/// if the responder is dropped without sending a response, so that the client
3224/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3225impl std::ops::Drop for CryptManagementForgetWrappingKeyResponder {
3226    fn drop(&mut self) {
3227        self.control_handle.shutdown();
3228        // Safety: drops once, never accessed again
3229        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3230    }
3231}
3232
3233impl fidl::endpoints::Responder for CryptManagementForgetWrappingKeyResponder {
3234    type ControlHandle = CryptManagementControlHandle;
3235
3236    fn control_handle(&self) -> &CryptManagementControlHandle {
3237        &self.control_handle
3238    }
3239
3240    fn drop_without_shutdown(mut self) {
3241        // Safety: drops once, never accessed again due to mem::forget
3242        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3243        // Prevent Drop from running (which would shut down the channel)
3244        std::mem::forget(self);
3245    }
3246}
3247
3248impl CryptManagementForgetWrappingKeyResponder {
3249    /// Sends a response to the FIDL transaction.
3250    ///
3251    /// Sets the channel to shutdown if an error occurs.
3252    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3253        let _result = self.send_raw(result);
3254        if _result.is_err() {
3255            self.control_handle.shutdown();
3256        }
3257        self.drop_without_shutdown();
3258        _result
3259    }
3260
3261    /// Similar to "send" but does not shutdown the channel if an error occurs.
3262    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3263        let _result = self.send_raw(result);
3264        self.drop_without_shutdown();
3265        _result
3266    }
3267
3268    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3269        self.control_handle
3270            .inner
3271            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3272                result,
3273                self.tx_id,
3274                0x436d6d27696dfcf4,
3275                fidl::encoding::DynamicFlags::empty(),
3276            )
3277    }
3278}
3279
3280#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3281pub struct DebugMarker;
3282
3283impl fidl::endpoints::ProtocolMarker for DebugMarker {
3284    type Proxy = DebugProxy;
3285    type RequestStream = DebugRequestStream;
3286    #[cfg(target_os = "fuchsia")]
3287    type SynchronousProxy = DebugSynchronousProxy;
3288
3289    const DEBUG_NAME: &'static str = "fuchsia.fxfs.Debug";
3290}
3291impl fidl::endpoints::DiscoverableProtocolMarker for DebugMarker {}
3292pub type DebugCompactResult = Result<(), i32>;
3293pub type DebugDeleteProfileResult = Result<(), i32>;
3294pub type DebugStopProfileTasksResult = Result<(), i32>;
3295
3296pub trait DebugProxyInterface: Send + Sync {
3297    type CompactResponseFut: std::future::Future<Output = Result<DebugCompactResult, fidl::Error>>
3298        + Send;
3299    fn r#compact(&self) -> Self::CompactResponseFut;
3300    type DeleteProfileResponseFut: std::future::Future<Output = Result<DebugDeleteProfileResult, fidl::Error>>
3301        + Send;
3302    fn r#delete_profile(&self, volume: &str, profile: &str) -> Self::DeleteProfileResponseFut;
3303    type StopProfileTasksResponseFut: std::future::Future<Output = Result<DebugStopProfileTasksResult, fidl::Error>>
3304        + Send;
3305    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut;
3306}
3307#[derive(Debug)]
3308#[cfg(target_os = "fuchsia")]
3309pub struct DebugSynchronousProxy {
3310    client: fidl::client::sync::Client,
3311}
3312
3313#[cfg(target_os = "fuchsia")]
3314impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
3315    type Proxy = DebugProxy;
3316    type Protocol = DebugMarker;
3317
3318    fn from_channel(inner: fidl::Channel) -> Self {
3319        Self::new(inner)
3320    }
3321
3322    fn into_channel(self) -> fidl::Channel {
3323        self.client.into_channel()
3324    }
3325
3326    fn as_channel(&self) -> &fidl::Channel {
3327        self.client.as_channel()
3328    }
3329}
3330
3331#[cfg(target_os = "fuchsia")]
3332impl DebugSynchronousProxy {
3333    pub fn new(channel: fidl::Channel) -> Self {
3334        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3335        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3336    }
3337
3338    pub fn into_channel(self) -> fidl::Channel {
3339        self.client.into_channel()
3340    }
3341
3342    /// Waits until an event arrives and returns it. It is safe for other
3343    /// threads to make concurrent requests while waiting for an event.
3344    pub fn wait_for_event(
3345        &self,
3346        deadline: zx::MonotonicInstant,
3347    ) -> Result<DebugEvent, fidl::Error> {
3348        DebugEvent::decode(self.client.wait_for_event(deadline)?)
3349    }
3350
3351    /// Forces a compaction.
3352    pub fn r#compact(
3353        &self,
3354        ___deadline: zx::MonotonicInstant,
3355    ) -> Result<DebugCompactResult, fidl::Error> {
3356        let _response = self.client.send_query::<
3357            fidl::encoding::EmptyPayload,
3358            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3359        >(
3360            (),
3361            0x6553eb197306e489,
3362            fidl::encoding::DynamicFlags::empty(),
3363            ___deadline,
3364        )?;
3365        Ok(_response.map(|x| x))
3366    }
3367
3368    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3369    /// active profile recording or replay.
3370    pub fn r#delete_profile(
3371        &self,
3372        mut volume: &str,
3373        mut profile: &str,
3374        ___deadline: zx::MonotonicInstant,
3375    ) -> Result<DebugDeleteProfileResult, fidl::Error> {
3376        let _response = self.client.send_query::<
3377            DebugDeleteProfileRequest,
3378            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3379        >(
3380            (volume, profile,),
3381            0x54d9d4c9cf300a1e,
3382            fidl::encoding::DynamicFlags::empty(),
3383            ___deadline,
3384        )?;
3385        Ok(_response.map(|x| x))
3386    }
3387
3388    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3389    /// persisted.
3390    pub fn r#stop_profile_tasks(
3391        &self,
3392        ___deadline: zx::MonotonicInstant,
3393    ) -> Result<DebugStopProfileTasksResult, fidl::Error> {
3394        let _response = self.client.send_query::<
3395            fidl::encoding::EmptyPayload,
3396            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3397        >(
3398            (),
3399            0x1657b945dd629177,
3400            fidl::encoding::DynamicFlags::empty(),
3401            ___deadline,
3402        )?;
3403        Ok(_response.map(|x| x))
3404    }
3405}
3406
3407#[cfg(target_os = "fuchsia")]
3408impl From<DebugSynchronousProxy> for zx::Handle {
3409    fn from(value: DebugSynchronousProxy) -> Self {
3410        value.into_channel().into()
3411    }
3412}
3413
3414#[cfg(target_os = "fuchsia")]
3415impl From<fidl::Channel> for DebugSynchronousProxy {
3416    fn from(value: fidl::Channel) -> Self {
3417        Self::new(value)
3418    }
3419}
3420
3421#[cfg(target_os = "fuchsia")]
3422impl fidl::endpoints::FromClient for DebugSynchronousProxy {
3423    type Protocol = DebugMarker;
3424
3425    fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
3426        Self::new(value.into_channel())
3427    }
3428}
3429
3430#[derive(Debug, Clone)]
3431pub struct DebugProxy {
3432    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3433}
3434
3435impl fidl::endpoints::Proxy for DebugProxy {
3436    type Protocol = DebugMarker;
3437
3438    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3439        Self::new(inner)
3440    }
3441
3442    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3443        self.client.into_channel().map_err(|client| Self { client })
3444    }
3445
3446    fn as_channel(&self) -> &::fidl::AsyncChannel {
3447        self.client.as_channel()
3448    }
3449}
3450
3451impl DebugProxy {
3452    /// Create a new Proxy for fuchsia.fxfs/Debug.
3453    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3454        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3455        Self { client: fidl::client::Client::new(channel, protocol_name) }
3456    }
3457
3458    /// Get a Stream of events from the remote end of the protocol.
3459    ///
3460    /// # Panics
3461    ///
3462    /// Panics if the event stream was already taken.
3463    pub fn take_event_stream(&self) -> DebugEventStream {
3464        DebugEventStream { event_receiver: self.client.take_event_receiver() }
3465    }
3466
3467    /// Forces a compaction.
3468    pub fn r#compact(
3469        &self,
3470    ) -> fidl::client::QueryResponseFut<
3471        DebugCompactResult,
3472        fidl::encoding::DefaultFuchsiaResourceDialect,
3473    > {
3474        DebugProxyInterface::r#compact(self)
3475    }
3476
3477    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3478    /// active profile recording or replay.
3479    pub fn r#delete_profile(
3480        &self,
3481        mut volume: &str,
3482        mut profile: &str,
3483    ) -> fidl::client::QueryResponseFut<
3484        DebugDeleteProfileResult,
3485        fidl::encoding::DefaultFuchsiaResourceDialect,
3486    > {
3487        DebugProxyInterface::r#delete_profile(self, volume, profile)
3488    }
3489
3490    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3491    /// persisted.
3492    pub fn r#stop_profile_tasks(
3493        &self,
3494    ) -> fidl::client::QueryResponseFut<
3495        DebugStopProfileTasksResult,
3496        fidl::encoding::DefaultFuchsiaResourceDialect,
3497    > {
3498        DebugProxyInterface::r#stop_profile_tasks(self)
3499    }
3500}
3501
3502impl DebugProxyInterface for DebugProxy {
3503    type CompactResponseFut = fidl::client::QueryResponseFut<
3504        DebugCompactResult,
3505        fidl::encoding::DefaultFuchsiaResourceDialect,
3506    >;
3507    fn r#compact(&self) -> Self::CompactResponseFut {
3508        fn _decode(
3509            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3510        ) -> Result<DebugCompactResult, fidl::Error> {
3511            let _response = fidl::client::decode_transaction_body::<
3512                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3513                fidl::encoding::DefaultFuchsiaResourceDialect,
3514                0x6553eb197306e489,
3515            >(_buf?)?;
3516            Ok(_response.map(|x| x))
3517        }
3518        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DebugCompactResult>(
3519            (),
3520            0x6553eb197306e489,
3521            fidl::encoding::DynamicFlags::empty(),
3522            _decode,
3523        )
3524    }
3525
3526    type DeleteProfileResponseFut = fidl::client::QueryResponseFut<
3527        DebugDeleteProfileResult,
3528        fidl::encoding::DefaultFuchsiaResourceDialect,
3529    >;
3530    fn r#delete_profile(
3531        &self,
3532        mut volume: &str,
3533        mut profile: &str,
3534    ) -> Self::DeleteProfileResponseFut {
3535        fn _decode(
3536            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3537        ) -> Result<DebugDeleteProfileResult, fidl::Error> {
3538            let _response = fidl::client::decode_transaction_body::<
3539                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3540                fidl::encoding::DefaultFuchsiaResourceDialect,
3541                0x54d9d4c9cf300a1e,
3542            >(_buf?)?;
3543            Ok(_response.map(|x| x))
3544        }
3545        self.client.send_query_and_decode::<DebugDeleteProfileRequest, DebugDeleteProfileResult>(
3546            (volume, profile),
3547            0x54d9d4c9cf300a1e,
3548            fidl::encoding::DynamicFlags::empty(),
3549            _decode,
3550        )
3551    }
3552
3553    type StopProfileTasksResponseFut = fidl::client::QueryResponseFut<
3554        DebugStopProfileTasksResult,
3555        fidl::encoding::DefaultFuchsiaResourceDialect,
3556    >;
3557    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut {
3558        fn _decode(
3559            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3560        ) -> Result<DebugStopProfileTasksResult, fidl::Error> {
3561            let _response = fidl::client::decode_transaction_body::<
3562                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3563                fidl::encoding::DefaultFuchsiaResourceDialect,
3564                0x1657b945dd629177,
3565            >(_buf?)?;
3566            Ok(_response.map(|x| x))
3567        }
3568        self.client
3569            .send_query_and_decode::<fidl::encoding::EmptyPayload, DebugStopProfileTasksResult>(
3570                (),
3571                0x1657b945dd629177,
3572                fidl::encoding::DynamicFlags::empty(),
3573                _decode,
3574            )
3575    }
3576}
3577
3578pub struct DebugEventStream {
3579    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3580}
3581
3582impl std::marker::Unpin for DebugEventStream {}
3583
3584impl futures::stream::FusedStream for DebugEventStream {
3585    fn is_terminated(&self) -> bool {
3586        self.event_receiver.is_terminated()
3587    }
3588}
3589
3590impl futures::Stream for DebugEventStream {
3591    type Item = Result<DebugEvent, fidl::Error>;
3592
3593    fn poll_next(
3594        mut self: std::pin::Pin<&mut Self>,
3595        cx: &mut std::task::Context<'_>,
3596    ) -> std::task::Poll<Option<Self::Item>> {
3597        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3598            &mut self.event_receiver,
3599            cx
3600        )?) {
3601            Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
3602            None => std::task::Poll::Ready(None),
3603        }
3604    }
3605}
3606
3607#[derive(Debug)]
3608pub enum DebugEvent {}
3609
3610impl DebugEvent {
3611    /// Decodes a message buffer as a [`DebugEvent`].
3612    fn decode(
3613        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3614    ) -> Result<DebugEvent, fidl::Error> {
3615        let (bytes, _handles) = buf.split_mut();
3616        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3617        debug_assert_eq!(tx_header.tx_id, 0);
3618        match tx_header.ordinal {
3619            _ => Err(fidl::Error::UnknownOrdinal {
3620                ordinal: tx_header.ordinal,
3621                protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3622            }),
3623        }
3624    }
3625}
3626
3627/// A Stream of incoming requests for fuchsia.fxfs/Debug.
3628pub struct DebugRequestStream {
3629    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3630    is_terminated: bool,
3631}
3632
3633impl std::marker::Unpin for DebugRequestStream {}
3634
3635impl futures::stream::FusedStream for DebugRequestStream {
3636    fn is_terminated(&self) -> bool {
3637        self.is_terminated
3638    }
3639}
3640
3641impl fidl::endpoints::RequestStream for DebugRequestStream {
3642    type Protocol = DebugMarker;
3643    type ControlHandle = DebugControlHandle;
3644
3645    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3646        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3647    }
3648
3649    fn control_handle(&self) -> Self::ControlHandle {
3650        DebugControlHandle { inner: self.inner.clone() }
3651    }
3652
3653    fn into_inner(
3654        self,
3655    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3656    {
3657        (self.inner, self.is_terminated)
3658    }
3659
3660    fn from_inner(
3661        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3662        is_terminated: bool,
3663    ) -> Self {
3664        Self { inner, is_terminated }
3665    }
3666}
3667
3668impl futures::Stream for DebugRequestStream {
3669    type Item = Result<DebugRequest, fidl::Error>;
3670
3671    fn poll_next(
3672        mut self: std::pin::Pin<&mut Self>,
3673        cx: &mut std::task::Context<'_>,
3674    ) -> std::task::Poll<Option<Self::Item>> {
3675        let this = &mut *self;
3676        if this.inner.check_shutdown(cx) {
3677            this.is_terminated = true;
3678            return std::task::Poll::Ready(None);
3679        }
3680        if this.is_terminated {
3681            panic!("polled DebugRequestStream after completion");
3682        }
3683        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3684            |bytes, handles| {
3685                match this.inner.channel().read_etc(cx, bytes, handles) {
3686                    std::task::Poll::Ready(Ok(())) => {}
3687                    std::task::Poll::Pending => return std::task::Poll::Pending,
3688                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3689                        this.is_terminated = true;
3690                        return std::task::Poll::Ready(None);
3691                    }
3692                    std::task::Poll::Ready(Err(e)) => {
3693                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3694                            e.into(),
3695                        ))));
3696                    }
3697                }
3698
3699                // A message has been received from the channel
3700                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3701
3702                std::task::Poll::Ready(Some(match header.ordinal {
3703                    0x6553eb197306e489 => {
3704                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3705                        let mut req = fidl::new_empty!(
3706                            fidl::encoding::EmptyPayload,
3707                            fidl::encoding::DefaultFuchsiaResourceDialect
3708                        );
3709                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3710                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3711                        Ok(DebugRequest::Compact {
3712                            responder: DebugCompactResponder {
3713                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3714                                tx_id: header.tx_id,
3715                            },
3716                        })
3717                    }
3718                    0x54d9d4c9cf300a1e => {
3719                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3720                        let mut req = fidl::new_empty!(
3721                            DebugDeleteProfileRequest,
3722                            fidl::encoding::DefaultFuchsiaResourceDialect
3723                        );
3724                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugDeleteProfileRequest>(&header, _body_bytes, handles, &mut req)?;
3725                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3726                        Ok(DebugRequest::DeleteProfile {
3727                            volume: req.volume,
3728                            profile: req.profile,
3729
3730                            responder: DebugDeleteProfileResponder {
3731                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3732                                tx_id: header.tx_id,
3733                            },
3734                        })
3735                    }
3736                    0x1657b945dd629177 => {
3737                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3738                        let mut req = fidl::new_empty!(
3739                            fidl::encoding::EmptyPayload,
3740                            fidl::encoding::DefaultFuchsiaResourceDialect
3741                        );
3742                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3743                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3744                        Ok(DebugRequest::StopProfileTasks {
3745                            responder: DebugStopProfileTasksResponder {
3746                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3747                                tx_id: header.tx_id,
3748                            },
3749                        })
3750                    }
3751                    _ => Err(fidl::Error::UnknownOrdinal {
3752                        ordinal: header.ordinal,
3753                        protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3754                    }),
3755                }))
3756            },
3757        )
3758    }
3759}
3760
3761/// This is an internal protocol for on-device debugging and testing only.
3762/// See `ffx fxfs help` for more details.
3763#[derive(Debug)]
3764pub enum DebugRequest {
3765    /// Forces a compaction.
3766    Compact { responder: DebugCompactResponder },
3767    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3768    /// active profile recording or replay.
3769    DeleteProfile { volume: String, profile: String, responder: DebugDeleteProfileResponder },
3770    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3771    /// persisted.
3772    StopProfileTasks { responder: DebugStopProfileTasksResponder },
3773}
3774
3775impl DebugRequest {
3776    #[allow(irrefutable_let_patterns)]
3777    pub fn into_compact(self) -> Option<(DebugCompactResponder)> {
3778        if let DebugRequest::Compact { responder } = self { Some((responder)) } else { None }
3779    }
3780
3781    #[allow(irrefutable_let_patterns)]
3782    pub fn into_delete_profile(self) -> Option<(String, String, DebugDeleteProfileResponder)> {
3783        if let DebugRequest::DeleteProfile { volume, profile, responder } = self {
3784            Some((volume, profile, responder))
3785        } else {
3786            None
3787        }
3788    }
3789
3790    #[allow(irrefutable_let_patterns)]
3791    pub fn into_stop_profile_tasks(self) -> Option<(DebugStopProfileTasksResponder)> {
3792        if let DebugRequest::StopProfileTasks { responder } = self {
3793            Some((responder))
3794        } else {
3795            None
3796        }
3797    }
3798
3799    /// Name of the method defined in FIDL
3800    pub fn method_name(&self) -> &'static str {
3801        match *self {
3802            DebugRequest::Compact { .. } => "compact",
3803            DebugRequest::DeleteProfile { .. } => "delete_profile",
3804            DebugRequest::StopProfileTasks { .. } => "stop_profile_tasks",
3805        }
3806    }
3807}
3808
3809#[derive(Debug, Clone)]
3810pub struct DebugControlHandle {
3811    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3812}
3813
3814impl fidl::endpoints::ControlHandle for DebugControlHandle {
3815    fn shutdown(&self) {
3816        self.inner.shutdown()
3817    }
3818    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3819        self.inner.shutdown_with_epitaph(status)
3820    }
3821
3822    fn is_closed(&self) -> bool {
3823        self.inner.channel().is_closed()
3824    }
3825    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3826        self.inner.channel().on_closed()
3827    }
3828
3829    #[cfg(target_os = "fuchsia")]
3830    fn signal_peer(
3831        &self,
3832        clear_mask: zx::Signals,
3833        set_mask: zx::Signals,
3834    ) -> Result<(), zx_status::Status> {
3835        use fidl::Peered;
3836        self.inner.channel().signal_peer(clear_mask, set_mask)
3837    }
3838}
3839
3840impl DebugControlHandle {}
3841
3842#[must_use = "FIDL methods require a response to be sent"]
3843#[derive(Debug)]
3844pub struct DebugCompactResponder {
3845    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3846    tx_id: u32,
3847}
3848
3849/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3850/// if the responder is dropped without sending a response, so that the client
3851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3852impl std::ops::Drop for DebugCompactResponder {
3853    fn drop(&mut self) {
3854        self.control_handle.shutdown();
3855        // Safety: drops once, never accessed again
3856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3857    }
3858}
3859
3860impl fidl::endpoints::Responder for DebugCompactResponder {
3861    type ControlHandle = DebugControlHandle;
3862
3863    fn control_handle(&self) -> &DebugControlHandle {
3864        &self.control_handle
3865    }
3866
3867    fn drop_without_shutdown(mut self) {
3868        // Safety: drops once, never accessed again due to mem::forget
3869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3870        // Prevent Drop from running (which would shut down the channel)
3871        std::mem::forget(self);
3872    }
3873}
3874
3875impl DebugCompactResponder {
3876    /// Sends a response to the FIDL transaction.
3877    ///
3878    /// Sets the channel to shutdown if an error occurs.
3879    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3880        let _result = self.send_raw(result);
3881        if _result.is_err() {
3882            self.control_handle.shutdown();
3883        }
3884        self.drop_without_shutdown();
3885        _result
3886    }
3887
3888    /// Similar to "send" but does not shutdown the channel if an error occurs.
3889    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3890        let _result = self.send_raw(result);
3891        self.drop_without_shutdown();
3892        _result
3893    }
3894
3895    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3896        self.control_handle
3897            .inner
3898            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3899                result,
3900                self.tx_id,
3901                0x6553eb197306e489,
3902                fidl::encoding::DynamicFlags::empty(),
3903            )
3904    }
3905}
3906
3907#[must_use = "FIDL methods require a response to be sent"]
3908#[derive(Debug)]
3909pub struct DebugDeleteProfileResponder {
3910    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3911    tx_id: u32,
3912}
3913
3914/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3915/// if the responder is dropped without sending a response, so that the client
3916/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3917impl std::ops::Drop for DebugDeleteProfileResponder {
3918    fn drop(&mut self) {
3919        self.control_handle.shutdown();
3920        // Safety: drops once, never accessed again
3921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3922    }
3923}
3924
3925impl fidl::endpoints::Responder for DebugDeleteProfileResponder {
3926    type ControlHandle = DebugControlHandle;
3927
3928    fn control_handle(&self) -> &DebugControlHandle {
3929        &self.control_handle
3930    }
3931
3932    fn drop_without_shutdown(mut self) {
3933        // Safety: drops once, never accessed again due to mem::forget
3934        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3935        // Prevent Drop from running (which would shut down the channel)
3936        std::mem::forget(self);
3937    }
3938}
3939
3940impl DebugDeleteProfileResponder {
3941    /// Sends a response to the FIDL transaction.
3942    ///
3943    /// Sets the channel to shutdown if an error occurs.
3944    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3945        let _result = self.send_raw(result);
3946        if _result.is_err() {
3947            self.control_handle.shutdown();
3948        }
3949        self.drop_without_shutdown();
3950        _result
3951    }
3952
3953    /// Similar to "send" but does not shutdown the channel if an error occurs.
3954    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3955        let _result = self.send_raw(result);
3956        self.drop_without_shutdown();
3957        _result
3958    }
3959
3960    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3961        self.control_handle
3962            .inner
3963            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3964                result,
3965                self.tx_id,
3966                0x54d9d4c9cf300a1e,
3967                fidl::encoding::DynamicFlags::empty(),
3968            )
3969    }
3970}
3971
3972#[must_use = "FIDL methods require a response to be sent"]
3973#[derive(Debug)]
3974pub struct DebugStopProfileTasksResponder {
3975    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3976    tx_id: u32,
3977}
3978
3979/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3980/// if the responder is dropped without sending a response, so that the client
3981/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3982impl std::ops::Drop for DebugStopProfileTasksResponder {
3983    fn drop(&mut self) {
3984        self.control_handle.shutdown();
3985        // Safety: drops once, never accessed again
3986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3987    }
3988}
3989
3990impl fidl::endpoints::Responder for DebugStopProfileTasksResponder {
3991    type ControlHandle = DebugControlHandle;
3992
3993    fn control_handle(&self) -> &DebugControlHandle {
3994        &self.control_handle
3995    }
3996
3997    fn drop_without_shutdown(mut self) {
3998        // Safety: drops once, never accessed again due to mem::forget
3999        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4000        // Prevent Drop from running (which would shut down the channel)
4001        std::mem::forget(self);
4002    }
4003}
4004
4005impl DebugStopProfileTasksResponder {
4006    /// Sends a response to the FIDL transaction.
4007    ///
4008    /// Sets the channel to shutdown if an error occurs.
4009    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4010        let _result = self.send_raw(result);
4011        if _result.is_err() {
4012            self.control_handle.shutdown();
4013        }
4014        self.drop_without_shutdown();
4015        _result
4016    }
4017
4018    /// Similar to "send" but does not shutdown the channel if an error occurs.
4019    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4020        let _result = self.send_raw(result);
4021        self.drop_without_shutdown();
4022        _result
4023    }
4024
4025    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4026        self.control_handle
4027            .inner
4028            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4029                result,
4030                self.tx_id,
4031                0x1657b945dd629177,
4032                fidl::encoding::DynamicFlags::empty(),
4033            )
4034    }
4035}
4036
4037#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4038pub struct FileBackedVolumeProviderMarker;
4039
4040impl fidl::endpoints::ProtocolMarker for FileBackedVolumeProviderMarker {
4041    type Proxy = FileBackedVolumeProviderProxy;
4042    type RequestStream = FileBackedVolumeProviderRequestStream;
4043    #[cfg(target_os = "fuchsia")]
4044    type SynchronousProxy = FileBackedVolumeProviderSynchronousProxy;
4045
4046    const DEBUG_NAME: &'static str = "fuchsia.fxfs.FileBackedVolumeProvider";
4047}
4048impl fidl::endpoints::DiscoverableProtocolMarker for FileBackedVolumeProviderMarker {}
4049
4050pub trait FileBackedVolumeProviderProxyInterface: Send + Sync {
4051    fn r#open(
4052        &self,
4053        parent_directory_token: fidl::Handle,
4054        name: &str,
4055        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4056    ) -> Result<(), fidl::Error>;
4057}
4058#[derive(Debug)]
4059#[cfg(target_os = "fuchsia")]
4060pub struct FileBackedVolumeProviderSynchronousProxy {
4061    client: fidl::client::sync::Client,
4062}
4063
4064#[cfg(target_os = "fuchsia")]
4065impl fidl::endpoints::SynchronousProxy for FileBackedVolumeProviderSynchronousProxy {
4066    type Proxy = FileBackedVolumeProviderProxy;
4067    type Protocol = FileBackedVolumeProviderMarker;
4068
4069    fn from_channel(inner: fidl::Channel) -> Self {
4070        Self::new(inner)
4071    }
4072
4073    fn into_channel(self) -> fidl::Channel {
4074        self.client.into_channel()
4075    }
4076
4077    fn as_channel(&self) -> &fidl::Channel {
4078        self.client.as_channel()
4079    }
4080}
4081
4082#[cfg(target_os = "fuchsia")]
4083impl FileBackedVolumeProviderSynchronousProxy {
4084    pub fn new(channel: fidl::Channel) -> Self {
4085        let protocol_name =
4086            <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4087        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4088    }
4089
4090    pub fn into_channel(self) -> fidl::Channel {
4091        self.client.into_channel()
4092    }
4093
4094    /// Waits until an event arrives and returns it. It is safe for other
4095    /// threads to make concurrent requests while waiting for an event.
4096    pub fn wait_for_event(
4097        &self,
4098        deadline: zx::MonotonicInstant,
4099    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
4100        FileBackedVolumeProviderEvent::decode(self.client.wait_for_event(deadline)?)
4101    }
4102
4103    /// Opens a file as a block device and starts serving block requests.
4104    ///
4105    /// `name` must refer to an existing file in the directory represented by
4106    /// `parent_directory_token`.
4107    ///
4108    /// The block size of the device will match the underlying filesystem's block size.  If the
4109    /// file's size is not a multiple of the block size, the apparent size of the device will be
4110    /// rounded down.
4111    ///
4112    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4113    /// directory connection must have the `MODIFY_DIRECTORY` right.
4114    ///
4115    /// Errors will be sent as an epitaph on `server_end`.
4116    pub fn r#open(
4117        &self,
4118        mut parent_directory_token: fidl::Handle,
4119        mut name: &str,
4120        mut server_end: fidl::endpoints::ServerEnd<
4121            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4122        >,
4123    ) -> Result<(), fidl::Error> {
4124        self.client.send::<FileBackedVolumeProviderOpenRequest>(
4125            (parent_directory_token, name, server_end),
4126            0x67120b9fc9f319ee,
4127            fidl::encoding::DynamicFlags::empty(),
4128        )
4129    }
4130}
4131
4132#[cfg(target_os = "fuchsia")]
4133impl From<FileBackedVolumeProviderSynchronousProxy> for zx::Handle {
4134    fn from(value: FileBackedVolumeProviderSynchronousProxy) -> Self {
4135        value.into_channel().into()
4136    }
4137}
4138
4139#[cfg(target_os = "fuchsia")]
4140impl From<fidl::Channel> for FileBackedVolumeProviderSynchronousProxy {
4141    fn from(value: fidl::Channel) -> Self {
4142        Self::new(value)
4143    }
4144}
4145
4146#[cfg(target_os = "fuchsia")]
4147impl fidl::endpoints::FromClient for FileBackedVolumeProviderSynchronousProxy {
4148    type Protocol = FileBackedVolumeProviderMarker;
4149
4150    fn from_client(value: fidl::endpoints::ClientEnd<FileBackedVolumeProviderMarker>) -> Self {
4151        Self::new(value.into_channel())
4152    }
4153}
4154
4155#[derive(Debug, Clone)]
4156pub struct FileBackedVolumeProviderProxy {
4157    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4158}
4159
4160impl fidl::endpoints::Proxy for FileBackedVolumeProviderProxy {
4161    type Protocol = FileBackedVolumeProviderMarker;
4162
4163    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4164        Self::new(inner)
4165    }
4166
4167    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4168        self.client.into_channel().map_err(|client| Self { client })
4169    }
4170
4171    fn as_channel(&self) -> &::fidl::AsyncChannel {
4172        self.client.as_channel()
4173    }
4174}
4175
4176impl FileBackedVolumeProviderProxy {
4177    /// Create a new Proxy for fuchsia.fxfs/FileBackedVolumeProvider.
4178    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4179        let protocol_name =
4180            <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4181        Self { client: fidl::client::Client::new(channel, protocol_name) }
4182    }
4183
4184    /// Get a Stream of events from the remote end of the protocol.
4185    ///
4186    /// # Panics
4187    ///
4188    /// Panics if the event stream was already taken.
4189    pub fn take_event_stream(&self) -> FileBackedVolumeProviderEventStream {
4190        FileBackedVolumeProviderEventStream { event_receiver: self.client.take_event_receiver() }
4191    }
4192
4193    /// Opens a file as a block device and starts serving block requests.
4194    ///
4195    /// `name` must refer to an existing file in the directory represented by
4196    /// `parent_directory_token`.
4197    ///
4198    /// The block size of the device will match the underlying filesystem's block size.  If the
4199    /// file's size is not a multiple of the block size, the apparent size of the device will be
4200    /// rounded down.
4201    ///
4202    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4203    /// directory connection must have the `MODIFY_DIRECTORY` right.
4204    ///
4205    /// Errors will be sent as an epitaph on `server_end`.
4206    pub fn r#open(
4207        &self,
4208        mut parent_directory_token: fidl::Handle,
4209        mut name: &str,
4210        mut server_end: fidl::endpoints::ServerEnd<
4211            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4212        >,
4213    ) -> Result<(), fidl::Error> {
4214        FileBackedVolumeProviderProxyInterface::r#open(
4215            self,
4216            parent_directory_token,
4217            name,
4218            server_end,
4219        )
4220    }
4221}
4222
4223impl FileBackedVolumeProviderProxyInterface for FileBackedVolumeProviderProxy {
4224    fn r#open(
4225        &self,
4226        mut parent_directory_token: fidl::Handle,
4227        mut name: &str,
4228        mut server_end: fidl::endpoints::ServerEnd<
4229            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4230        >,
4231    ) -> Result<(), fidl::Error> {
4232        self.client.send::<FileBackedVolumeProviderOpenRequest>(
4233            (parent_directory_token, name, server_end),
4234            0x67120b9fc9f319ee,
4235            fidl::encoding::DynamicFlags::empty(),
4236        )
4237    }
4238}
4239
4240pub struct FileBackedVolumeProviderEventStream {
4241    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4242}
4243
4244impl std::marker::Unpin for FileBackedVolumeProviderEventStream {}
4245
4246impl futures::stream::FusedStream for FileBackedVolumeProviderEventStream {
4247    fn is_terminated(&self) -> bool {
4248        self.event_receiver.is_terminated()
4249    }
4250}
4251
4252impl futures::Stream for FileBackedVolumeProviderEventStream {
4253    type Item = Result<FileBackedVolumeProviderEvent, fidl::Error>;
4254
4255    fn poll_next(
4256        mut self: std::pin::Pin<&mut Self>,
4257        cx: &mut std::task::Context<'_>,
4258    ) -> std::task::Poll<Option<Self::Item>> {
4259        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4260            &mut self.event_receiver,
4261            cx
4262        )?) {
4263            Some(buf) => std::task::Poll::Ready(Some(FileBackedVolumeProviderEvent::decode(buf))),
4264            None => std::task::Poll::Ready(None),
4265        }
4266    }
4267}
4268
4269#[derive(Debug)]
4270pub enum FileBackedVolumeProviderEvent {}
4271
4272impl FileBackedVolumeProviderEvent {
4273    /// Decodes a message buffer as a [`FileBackedVolumeProviderEvent`].
4274    fn decode(
4275        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4276    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
4277        let (bytes, _handles) = buf.split_mut();
4278        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4279        debug_assert_eq!(tx_header.tx_id, 0);
4280        match tx_header.ordinal {
4281            _ => Err(fidl::Error::UnknownOrdinal {
4282                ordinal: tx_header.ordinal,
4283                protocol_name:
4284                    <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4285            }),
4286        }
4287    }
4288}
4289
4290/// A Stream of incoming requests for fuchsia.fxfs/FileBackedVolumeProvider.
4291pub struct FileBackedVolumeProviderRequestStream {
4292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4293    is_terminated: bool,
4294}
4295
4296impl std::marker::Unpin for FileBackedVolumeProviderRequestStream {}
4297
4298impl futures::stream::FusedStream for FileBackedVolumeProviderRequestStream {
4299    fn is_terminated(&self) -> bool {
4300        self.is_terminated
4301    }
4302}
4303
4304impl fidl::endpoints::RequestStream for FileBackedVolumeProviderRequestStream {
4305    type Protocol = FileBackedVolumeProviderMarker;
4306    type ControlHandle = FileBackedVolumeProviderControlHandle;
4307
4308    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4309        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4310    }
4311
4312    fn control_handle(&self) -> Self::ControlHandle {
4313        FileBackedVolumeProviderControlHandle { inner: self.inner.clone() }
4314    }
4315
4316    fn into_inner(
4317        self,
4318    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4319    {
4320        (self.inner, self.is_terminated)
4321    }
4322
4323    fn from_inner(
4324        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4325        is_terminated: bool,
4326    ) -> Self {
4327        Self { inner, is_terminated }
4328    }
4329}
4330
4331impl futures::Stream for FileBackedVolumeProviderRequestStream {
4332    type Item = Result<FileBackedVolumeProviderRequest, fidl::Error>;
4333
4334    fn poll_next(
4335        mut self: std::pin::Pin<&mut Self>,
4336        cx: &mut std::task::Context<'_>,
4337    ) -> std::task::Poll<Option<Self::Item>> {
4338        let this = &mut *self;
4339        if this.inner.check_shutdown(cx) {
4340            this.is_terminated = true;
4341            return std::task::Poll::Ready(None);
4342        }
4343        if this.is_terminated {
4344            panic!("polled FileBackedVolumeProviderRequestStream after completion");
4345        }
4346        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4347            |bytes, handles| {
4348                match this.inner.channel().read_etc(cx, bytes, handles) {
4349                    std::task::Poll::Ready(Ok(())) => {}
4350                    std::task::Poll::Pending => return std::task::Poll::Pending,
4351                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4352                        this.is_terminated = true;
4353                        return std::task::Poll::Ready(None);
4354                    }
4355                    std::task::Poll::Ready(Err(e)) => {
4356                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4357                            e.into(),
4358                        ))));
4359                    }
4360                }
4361
4362                // A message has been received from the channel
4363                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4364
4365                std::task::Poll::Ready(Some(match header.ordinal {
4366                0x67120b9fc9f319ee => {
4367                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4368                    let mut req = fidl::new_empty!(FileBackedVolumeProviderOpenRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4369                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FileBackedVolumeProviderOpenRequest>(&header, _body_bytes, handles, &mut req)?;
4370                    let control_handle = FileBackedVolumeProviderControlHandle {
4371                        inner: this.inner.clone(),
4372                    };
4373                    Ok(FileBackedVolumeProviderRequest::Open {parent_directory_token: req.parent_directory_token,
4374name: req.name,
4375server_end: req.server_end,
4376
4377                        control_handle,
4378                    })
4379                }
4380                _ => Err(fidl::Error::UnknownOrdinal {
4381                    ordinal: header.ordinal,
4382                    protocol_name: <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4383                }),
4384            }))
4385            },
4386        )
4387    }
4388}
4389
4390/// A protocol to serve the Volume protocol on a file-backed device.
4391#[derive(Debug)]
4392pub enum FileBackedVolumeProviderRequest {
4393    /// Opens a file as a block device and starts serving block requests.
4394    ///
4395    /// `name` must refer to an existing file in the directory represented by
4396    /// `parent_directory_token`.
4397    ///
4398    /// The block size of the device will match the underlying filesystem's block size.  If the
4399    /// file's size is not a multiple of the block size, the apparent size of the device will be
4400    /// rounded down.
4401    ///
4402    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4403    /// directory connection must have the `MODIFY_DIRECTORY` right.
4404    ///
4405    /// Errors will be sent as an epitaph on `server_end`.
4406    Open {
4407        parent_directory_token: fidl::Handle,
4408        name: String,
4409        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4410        control_handle: FileBackedVolumeProviderControlHandle,
4411    },
4412}
4413
4414impl FileBackedVolumeProviderRequest {
4415    #[allow(irrefutable_let_patterns)]
4416    pub fn into_open(
4417        self,
4418    ) -> Option<(
4419        fidl::Handle,
4420        String,
4421        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4422        FileBackedVolumeProviderControlHandle,
4423    )> {
4424        if let FileBackedVolumeProviderRequest::Open {
4425            parent_directory_token,
4426            name,
4427            server_end,
4428            control_handle,
4429        } = self
4430        {
4431            Some((parent_directory_token, name, server_end, control_handle))
4432        } else {
4433            None
4434        }
4435    }
4436
4437    /// Name of the method defined in FIDL
4438    pub fn method_name(&self) -> &'static str {
4439        match *self {
4440            FileBackedVolumeProviderRequest::Open { .. } => "open",
4441        }
4442    }
4443}
4444
4445#[derive(Debug, Clone)]
4446pub struct FileBackedVolumeProviderControlHandle {
4447    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4448}
4449
4450impl fidl::endpoints::ControlHandle for FileBackedVolumeProviderControlHandle {
4451    fn shutdown(&self) {
4452        self.inner.shutdown()
4453    }
4454    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4455        self.inner.shutdown_with_epitaph(status)
4456    }
4457
4458    fn is_closed(&self) -> bool {
4459        self.inner.channel().is_closed()
4460    }
4461    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4462        self.inner.channel().on_closed()
4463    }
4464
4465    #[cfg(target_os = "fuchsia")]
4466    fn signal_peer(
4467        &self,
4468        clear_mask: zx::Signals,
4469        set_mask: zx::Signals,
4470    ) -> Result<(), zx_status::Status> {
4471        use fidl::Peered;
4472        self.inner.channel().signal_peer(clear_mask, set_mask)
4473    }
4474}
4475
4476impl FileBackedVolumeProviderControlHandle {}
4477
4478#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4479pub struct ProjectIdMarker;
4480
4481impl fidl::endpoints::ProtocolMarker for ProjectIdMarker {
4482    type Proxy = ProjectIdProxy;
4483    type RequestStream = ProjectIdRequestStream;
4484    #[cfg(target_os = "fuchsia")]
4485    type SynchronousProxy = ProjectIdSynchronousProxy;
4486
4487    const DEBUG_NAME: &'static str = "fuchsia.fxfs.ProjectId";
4488}
4489impl fidl::endpoints::DiscoverableProtocolMarker for ProjectIdMarker {}
4490pub type ProjectIdSetLimitResult = Result<(), i32>;
4491pub type ProjectIdClearResult = Result<(), i32>;
4492pub type ProjectIdSetForNodeResult = Result<(), i32>;
4493pub type ProjectIdGetForNodeResult = Result<u64, i32>;
4494pub type ProjectIdClearForNodeResult = Result<(), i32>;
4495pub type ProjectIdListResult = Result<(Vec<u64>, Option<Box<ProjectIterToken>>), i32>;
4496pub type ProjectIdInfoResult = Result<(BytesAndNodes, BytesAndNodes), i32>;
4497
4498pub trait ProjectIdProxyInterface: Send + Sync {
4499    type SetLimitResponseFut: std::future::Future<Output = Result<ProjectIdSetLimitResult, fidl::Error>>
4500        + Send;
4501    fn r#set_limit(&self, project_id: u64, bytes: u64, nodes: u64) -> Self::SetLimitResponseFut;
4502    type ClearResponseFut: std::future::Future<Output = Result<ProjectIdClearResult, fidl::Error>>
4503        + Send;
4504    fn r#clear(&self, project_id: u64) -> Self::ClearResponseFut;
4505    type SetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdSetForNodeResult, fidl::Error>>
4506        + Send;
4507    fn r#set_for_node(&self, node_id: u64, project_id: u64) -> Self::SetForNodeResponseFut;
4508    type GetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdGetForNodeResult, fidl::Error>>
4509        + Send;
4510    fn r#get_for_node(&self, node_id: u64) -> Self::GetForNodeResponseFut;
4511    type ClearForNodeResponseFut: std::future::Future<Output = Result<ProjectIdClearForNodeResult, fidl::Error>>
4512        + Send;
4513    fn r#clear_for_node(&self, node_id: u64) -> Self::ClearForNodeResponseFut;
4514    type ListResponseFut: std::future::Future<Output = Result<ProjectIdListResult, fidl::Error>>
4515        + Send;
4516    fn r#list(&self, token: Option<&ProjectIterToken>) -> Self::ListResponseFut;
4517    type InfoResponseFut: std::future::Future<Output = Result<ProjectIdInfoResult, fidl::Error>>
4518        + Send;
4519    fn r#info(&self, project_id: u64) -> Self::InfoResponseFut;
4520}
4521#[derive(Debug)]
4522#[cfg(target_os = "fuchsia")]
4523pub struct ProjectIdSynchronousProxy {
4524    client: fidl::client::sync::Client,
4525}
4526
4527#[cfg(target_os = "fuchsia")]
4528impl fidl::endpoints::SynchronousProxy for ProjectIdSynchronousProxy {
4529    type Proxy = ProjectIdProxy;
4530    type Protocol = ProjectIdMarker;
4531
4532    fn from_channel(inner: fidl::Channel) -> Self {
4533        Self::new(inner)
4534    }
4535
4536    fn into_channel(self) -> fidl::Channel {
4537        self.client.into_channel()
4538    }
4539
4540    fn as_channel(&self) -> &fidl::Channel {
4541        self.client.as_channel()
4542    }
4543}
4544
4545#[cfg(target_os = "fuchsia")]
4546impl ProjectIdSynchronousProxy {
4547    pub fn new(channel: fidl::Channel) -> Self {
4548        let protocol_name = <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4549        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4550    }
4551
4552    pub fn into_channel(self) -> fidl::Channel {
4553        self.client.into_channel()
4554    }
4555
4556    /// Waits until an event arrives and returns it. It is safe for other
4557    /// threads to make concurrent requests while waiting for an event.
4558    pub fn wait_for_event(
4559        &self,
4560        deadline: zx::MonotonicInstant,
4561    ) -> Result<ProjectIdEvent, fidl::Error> {
4562        ProjectIdEvent::decode(self.client.wait_for_event(deadline)?)
4563    }
4564
4565    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
4566    /// current usage is accepted but may in the future prevent further increases. Returns
4567    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4568    pub fn r#set_limit(
4569        &self,
4570        mut project_id: u64,
4571        mut bytes: u64,
4572        mut nodes: u64,
4573        ___deadline: zx::MonotonicInstant,
4574    ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
4575        let _response = self.client.send_query::<
4576            ProjectIdSetLimitRequest,
4577            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4578        >(
4579            (project_id, bytes, nodes,),
4580            0x20b0fc1e0413876f,
4581            fidl::encoding::DynamicFlags::empty(),
4582            ___deadline,
4583        )?;
4584        Ok(_response.map(|x| x))
4585    }
4586
4587    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
4588    /// currently tracked. It will succeed even if the project is still in use more by one or more
4589    /// nodes.
4590    pub fn r#clear(
4591        &self,
4592        mut project_id: u64,
4593        ___deadline: zx::MonotonicInstant,
4594    ) -> Result<ProjectIdClearResult, fidl::Error> {
4595        let _response = self.client.send_query::<
4596            ProjectIdClearRequest,
4597            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4598        >(
4599            (project_id,),
4600            0x165b5f1e707863c1,
4601            fidl::encoding::DynamicFlags::empty(),
4602            ___deadline,
4603        )?;
4604        Ok(_response.map(|x| x))
4605    }
4606
4607    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
4608    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4609    pub fn r#set_for_node(
4610        &self,
4611        mut node_id: u64,
4612        mut project_id: u64,
4613        ___deadline: zx::MonotonicInstant,
4614    ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
4615        let _response = self.client.send_query::<
4616            ProjectIdSetForNodeRequest,
4617            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4618        >(
4619            (node_id, project_id,),
4620            0x4d7a8442dc58324c,
4621            fidl::encoding::DynamicFlags::empty(),
4622            ___deadline,
4623        )?;
4624        Ok(_response.map(|x| x))
4625    }
4626
4627    /// Get the project id based on a given node_id from a GetAttrs call.This will return
4628    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
4629    /// currently applied.
4630    pub fn r#get_for_node(
4631        &self,
4632        mut node_id: u64,
4633        ___deadline: zx::MonotonicInstant,
4634    ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
4635        let _response = self.client.send_query::<
4636            ProjectIdGetForNodeRequest,
4637            fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
4638        >(
4639            (node_id,),
4640            0x644073bdf2542573,
4641            fidl::encoding::DynamicFlags::empty(),
4642            ___deadline,
4643        )?;
4644        Ok(_response.map(|x| x.project_id))
4645    }
4646
4647    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
4648    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
4649    /// have no project id applied to it.
4650    pub fn r#clear_for_node(
4651        &self,
4652        mut node_id: u64,
4653        ___deadline: zx::MonotonicInstant,
4654    ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
4655        let _response = self.client.send_query::<
4656            ProjectIdClearForNodeRequest,
4657            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4658        >(
4659            (node_id,),
4660            0x3f2ca287bbfe6a62,
4661            fidl::encoding::DynamicFlags::empty(),
4662            ___deadline,
4663        )?;
4664        Ok(_response.map(|x| x))
4665    }
4666
4667    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
4668    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
4669    /// previously provided `next_token` the iteration continues where it left off. If there are
4670    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
4671    pub fn r#list(
4672        &self,
4673        mut token: Option<&ProjectIterToken>,
4674        ___deadline: zx::MonotonicInstant,
4675    ) -> Result<ProjectIdListResult, fidl::Error> {
4676        let _response = self.client.send_query::<
4677            ProjectIdListRequest,
4678            fidl::encoding::ResultType<ProjectIdListResponse, i32>,
4679        >(
4680            (token,),
4681            0x5505f95a36d522cc,
4682            fidl::encoding::DynamicFlags::empty(),
4683            ___deadline,
4684        )?;
4685        Ok(_response.map(|x| (x.entries, x.next_token)))
4686    }
4687
4688    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
4689    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
4690    pub fn r#info(
4691        &self,
4692        mut project_id: u64,
4693        ___deadline: zx::MonotonicInstant,
4694    ) -> Result<ProjectIdInfoResult, fidl::Error> {
4695        let _response = self.client.send_query::<
4696            ProjectIdInfoRequest,
4697            fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
4698        >(
4699            (project_id,),
4700            0x51b47743c9e2d1ab,
4701            fidl::encoding::DynamicFlags::empty(),
4702            ___deadline,
4703        )?;
4704        Ok(_response.map(|x| (x.limit, x.usage)))
4705    }
4706}
4707
4708#[cfg(target_os = "fuchsia")]
4709impl From<ProjectIdSynchronousProxy> for zx::Handle {
4710    fn from(value: ProjectIdSynchronousProxy) -> Self {
4711        value.into_channel().into()
4712    }
4713}
4714
4715#[cfg(target_os = "fuchsia")]
4716impl From<fidl::Channel> for ProjectIdSynchronousProxy {
4717    fn from(value: fidl::Channel) -> Self {
4718        Self::new(value)
4719    }
4720}
4721
4722#[cfg(target_os = "fuchsia")]
4723impl fidl::endpoints::FromClient for ProjectIdSynchronousProxy {
4724    type Protocol = ProjectIdMarker;
4725
4726    fn from_client(value: fidl::endpoints::ClientEnd<ProjectIdMarker>) -> Self {
4727        Self::new(value.into_channel())
4728    }
4729}
4730
4731#[derive(Debug, Clone)]
4732pub struct ProjectIdProxy {
4733    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4734}
4735
4736impl fidl::endpoints::Proxy for ProjectIdProxy {
4737    type Protocol = ProjectIdMarker;
4738
4739    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4740        Self::new(inner)
4741    }
4742
4743    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4744        self.client.into_channel().map_err(|client| Self { client })
4745    }
4746
4747    fn as_channel(&self) -> &::fidl::AsyncChannel {
4748        self.client.as_channel()
4749    }
4750}
4751
4752impl ProjectIdProxy {
4753    /// Create a new Proxy for fuchsia.fxfs/ProjectId.
4754    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4755        let protocol_name = <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4756        Self { client: fidl::client::Client::new(channel, protocol_name) }
4757    }
4758
4759    /// Get a Stream of events from the remote end of the protocol.
4760    ///
4761    /// # Panics
4762    ///
4763    /// Panics if the event stream was already taken.
4764    pub fn take_event_stream(&self) -> ProjectIdEventStream {
4765        ProjectIdEventStream { event_receiver: self.client.take_event_receiver() }
4766    }
4767
4768    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
4769    /// current usage is accepted but may in the future prevent further increases. Returns
4770    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4771    pub fn r#set_limit(
4772        &self,
4773        mut project_id: u64,
4774        mut bytes: u64,
4775        mut nodes: u64,
4776    ) -> fidl::client::QueryResponseFut<
4777        ProjectIdSetLimitResult,
4778        fidl::encoding::DefaultFuchsiaResourceDialect,
4779    > {
4780        ProjectIdProxyInterface::r#set_limit(self, project_id, bytes, nodes)
4781    }
4782
4783    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
4784    /// currently tracked. It will succeed even if the project is still in use more by one or more
4785    /// nodes.
4786    pub fn r#clear(
4787        &self,
4788        mut project_id: u64,
4789    ) -> fidl::client::QueryResponseFut<
4790        ProjectIdClearResult,
4791        fidl::encoding::DefaultFuchsiaResourceDialect,
4792    > {
4793        ProjectIdProxyInterface::r#clear(self, project_id)
4794    }
4795
4796    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
4797    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4798    pub fn r#set_for_node(
4799        &self,
4800        mut node_id: u64,
4801        mut project_id: u64,
4802    ) -> fidl::client::QueryResponseFut<
4803        ProjectIdSetForNodeResult,
4804        fidl::encoding::DefaultFuchsiaResourceDialect,
4805    > {
4806        ProjectIdProxyInterface::r#set_for_node(self, node_id, project_id)
4807    }
4808
4809    /// Get the project id based on a given node_id from a GetAttrs call.This will return
4810    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
4811    /// currently applied.
4812    pub fn r#get_for_node(
4813        &self,
4814        mut node_id: u64,
4815    ) -> fidl::client::QueryResponseFut<
4816        ProjectIdGetForNodeResult,
4817        fidl::encoding::DefaultFuchsiaResourceDialect,
4818    > {
4819        ProjectIdProxyInterface::r#get_for_node(self, node_id)
4820    }
4821
4822    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
4823    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
4824    /// have no project id applied to it.
4825    pub fn r#clear_for_node(
4826        &self,
4827        mut node_id: u64,
4828    ) -> fidl::client::QueryResponseFut<
4829        ProjectIdClearForNodeResult,
4830        fidl::encoding::DefaultFuchsiaResourceDialect,
4831    > {
4832        ProjectIdProxyInterface::r#clear_for_node(self, node_id)
4833    }
4834
4835    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
4836    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
4837    /// previously provided `next_token` the iteration continues where it left off. If there are
4838    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
4839    pub fn r#list(
4840        &self,
4841        mut token: Option<&ProjectIterToken>,
4842    ) -> fidl::client::QueryResponseFut<
4843        ProjectIdListResult,
4844        fidl::encoding::DefaultFuchsiaResourceDialect,
4845    > {
4846        ProjectIdProxyInterface::r#list(self, token)
4847    }
4848
4849    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
4850    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
4851    pub fn r#info(
4852        &self,
4853        mut project_id: u64,
4854    ) -> fidl::client::QueryResponseFut<
4855        ProjectIdInfoResult,
4856        fidl::encoding::DefaultFuchsiaResourceDialect,
4857    > {
4858        ProjectIdProxyInterface::r#info(self, project_id)
4859    }
4860}
4861
4862impl ProjectIdProxyInterface for ProjectIdProxy {
4863    type SetLimitResponseFut = fidl::client::QueryResponseFut<
4864        ProjectIdSetLimitResult,
4865        fidl::encoding::DefaultFuchsiaResourceDialect,
4866    >;
4867    fn r#set_limit(
4868        &self,
4869        mut project_id: u64,
4870        mut bytes: u64,
4871        mut nodes: u64,
4872    ) -> Self::SetLimitResponseFut {
4873        fn _decode(
4874            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4875        ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
4876            let _response = fidl::client::decode_transaction_body::<
4877                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4878                fidl::encoding::DefaultFuchsiaResourceDialect,
4879                0x20b0fc1e0413876f,
4880            >(_buf?)?;
4881            Ok(_response.map(|x| x))
4882        }
4883        self.client.send_query_and_decode::<ProjectIdSetLimitRequest, ProjectIdSetLimitResult>(
4884            (project_id, bytes, nodes),
4885            0x20b0fc1e0413876f,
4886            fidl::encoding::DynamicFlags::empty(),
4887            _decode,
4888        )
4889    }
4890
4891    type ClearResponseFut = fidl::client::QueryResponseFut<
4892        ProjectIdClearResult,
4893        fidl::encoding::DefaultFuchsiaResourceDialect,
4894    >;
4895    fn r#clear(&self, mut project_id: u64) -> Self::ClearResponseFut {
4896        fn _decode(
4897            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4898        ) -> Result<ProjectIdClearResult, fidl::Error> {
4899            let _response = fidl::client::decode_transaction_body::<
4900                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4901                fidl::encoding::DefaultFuchsiaResourceDialect,
4902                0x165b5f1e707863c1,
4903            >(_buf?)?;
4904            Ok(_response.map(|x| x))
4905        }
4906        self.client.send_query_and_decode::<ProjectIdClearRequest, ProjectIdClearResult>(
4907            (project_id,),
4908            0x165b5f1e707863c1,
4909            fidl::encoding::DynamicFlags::empty(),
4910            _decode,
4911        )
4912    }
4913
4914    type SetForNodeResponseFut = fidl::client::QueryResponseFut<
4915        ProjectIdSetForNodeResult,
4916        fidl::encoding::DefaultFuchsiaResourceDialect,
4917    >;
4918    fn r#set_for_node(&self, mut node_id: u64, mut project_id: u64) -> Self::SetForNodeResponseFut {
4919        fn _decode(
4920            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4921        ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
4922            let _response = fidl::client::decode_transaction_body::<
4923                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4924                fidl::encoding::DefaultFuchsiaResourceDialect,
4925                0x4d7a8442dc58324c,
4926            >(_buf?)?;
4927            Ok(_response.map(|x| x))
4928        }
4929        self.client.send_query_and_decode::<ProjectIdSetForNodeRequest, ProjectIdSetForNodeResult>(
4930            (node_id, project_id),
4931            0x4d7a8442dc58324c,
4932            fidl::encoding::DynamicFlags::empty(),
4933            _decode,
4934        )
4935    }
4936
4937    type GetForNodeResponseFut = fidl::client::QueryResponseFut<
4938        ProjectIdGetForNodeResult,
4939        fidl::encoding::DefaultFuchsiaResourceDialect,
4940    >;
4941    fn r#get_for_node(&self, mut node_id: u64) -> Self::GetForNodeResponseFut {
4942        fn _decode(
4943            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4944        ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
4945            let _response = fidl::client::decode_transaction_body::<
4946                fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
4947                fidl::encoding::DefaultFuchsiaResourceDialect,
4948                0x644073bdf2542573,
4949            >(_buf?)?;
4950            Ok(_response.map(|x| x.project_id))
4951        }
4952        self.client.send_query_and_decode::<ProjectIdGetForNodeRequest, ProjectIdGetForNodeResult>(
4953            (node_id,),
4954            0x644073bdf2542573,
4955            fidl::encoding::DynamicFlags::empty(),
4956            _decode,
4957        )
4958    }
4959
4960    type ClearForNodeResponseFut = fidl::client::QueryResponseFut<
4961        ProjectIdClearForNodeResult,
4962        fidl::encoding::DefaultFuchsiaResourceDialect,
4963    >;
4964    fn r#clear_for_node(&self, mut node_id: u64) -> Self::ClearForNodeResponseFut {
4965        fn _decode(
4966            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4967        ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
4968            let _response = fidl::client::decode_transaction_body::<
4969                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4970                fidl::encoding::DefaultFuchsiaResourceDialect,
4971                0x3f2ca287bbfe6a62,
4972            >(_buf?)?;
4973            Ok(_response.map(|x| x))
4974        }
4975        self.client
4976            .send_query_and_decode::<ProjectIdClearForNodeRequest, ProjectIdClearForNodeResult>(
4977                (node_id,),
4978                0x3f2ca287bbfe6a62,
4979                fidl::encoding::DynamicFlags::empty(),
4980                _decode,
4981            )
4982    }
4983
4984    type ListResponseFut = fidl::client::QueryResponseFut<
4985        ProjectIdListResult,
4986        fidl::encoding::DefaultFuchsiaResourceDialect,
4987    >;
4988    fn r#list(&self, mut token: Option<&ProjectIterToken>) -> Self::ListResponseFut {
4989        fn _decode(
4990            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4991        ) -> Result<ProjectIdListResult, fidl::Error> {
4992            let _response = fidl::client::decode_transaction_body::<
4993                fidl::encoding::ResultType<ProjectIdListResponse, i32>,
4994                fidl::encoding::DefaultFuchsiaResourceDialect,
4995                0x5505f95a36d522cc,
4996            >(_buf?)?;
4997            Ok(_response.map(|x| (x.entries, x.next_token)))
4998        }
4999        self.client.send_query_and_decode::<ProjectIdListRequest, ProjectIdListResult>(
5000            (token,),
5001            0x5505f95a36d522cc,
5002            fidl::encoding::DynamicFlags::empty(),
5003            _decode,
5004        )
5005    }
5006
5007    type InfoResponseFut = fidl::client::QueryResponseFut<
5008        ProjectIdInfoResult,
5009        fidl::encoding::DefaultFuchsiaResourceDialect,
5010    >;
5011    fn r#info(&self, mut project_id: u64) -> Self::InfoResponseFut {
5012        fn _decode(
5013            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5014        ) -> Result<ProjectIdInfoResult, fidl::Error> {
5015            let _response = fidl::client::decode_transaction_body::<
5016                fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
5017                fidl::encoding::DefaultFuchsiaResourceDialect,
5018                0x51b47743c9e2d1ab,
5019            >(_buf?)?;
5020            Ok(_response.map(|x| (x.limit, x.usage)))
5021        }
5022        self.client.send_query_and_decode::<ProjectIdInfoRequest, ProjectIdInfoResult>(
5023            (project_id,),
5024            0x51b47743c9e2d1ab,
5025            fidl::encoding::DynamicFlags::empty(),
5026            _decode,
5027        )
5028    }
5029}
5030
5031pub struct ProjectIdEventStream {
5032    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5033}
5034
5035impl std::marker::Unpin for ProjectIdEventStream {}
5036
5037impl futures::stream::FusedStream for ProjectIdEventStream {
5038    fn is_terminated(&self) -> bool {
5039        self.event_receiver.is_terminated()
5040    }
5041}
5042
5043impl futures::Stream for ProjectIdEventStream {
5044    type Item = Result<ProjectIdEvent, fidl::Error>;
5045
5046    fn poll_next(
5047        mut self: std::pin::Pin<&mut Self>,
5048        cx: &mut std::task::Context<'_>,
5049    ) -> std::task::Poll<Option<Self::Item>> {
5050        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5051            &mut self.event_receiver,
5052            cx
5053        )?) {
5054            Some(buf) => std::task::Poll::Ready(Some(ProjectIdEvent::decode(buf))),
5055            None => std::task::Poll::Ready(None),
5056        }
5057    }
5058}
5059
5060#[derive(Debug)]
5061pub enum ProjectIdEvent {}
5062
5063impl ProjectIdEvent {
5064    /// Decodes a message buffer as a [`ProjectIdEvent`].
5065    fn decode(
5066        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5067    ) -> Result<ProjectIdEvent, fidl::Error> {
5068        let (bytes, _handles) = buf.split_mut();
5069        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5070        debug_assert_eq!(tx_header.tx_id, 0);
5071        match tx_header.ordinal {
5072            _ => Err(fidl::Error::UnknownOrdinal {
5073                ordinal: tx_header.ordinal,
5074                protocol_name: <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5075            }),
5076        }
5077    }
5078}
5079
5080/// A Stream of incoming requests for fuchsia.fxfs/ProjectId.
5081pub struct ProjectIdRequestStream {
5082    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5083    is_terminated: bool,
5084}
5085
5086impl std::marker::Unpin for ProjectIdRequestStream {}
5087
5088impl futures::stream::FusedStream for ProjectIdRequestStream {
5089    fn is_terminated(&self) -> bool {
5090        self.is_terminated
5091    }
5092}
5093
5094impl fidl::endpoints::RequestStream for ProjectIdRequestStream {
5095    type Protocol = ProjectIdMarker;
5096    type ControlHandle = ProjectIdControlHandle;
5097
5098    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5099        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5100    }
5101
5102    fn control_handle(&self) -> Self::ControlHandle {
5103        ProjectIdControlHandle { inner: self.inner.clone() }
5104    }
5105
5106    fn into_inner(
5107        self,
5108    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5109    {
5110        (self.inner, self.is_terminated)
5111    }
5112
5113    fn from_inner(
5114        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5115        is_terminated: bool,
5116    ) -> Self {
5117        Self { inner, is_terminated }
5118    }
5119}
5120
5121impl futures::Stream for ProjectIdRequestStream {
5122    type Item = Result<ProjectIdRequest, fidl::Error>;
5123
5124    fn poll_next(
5125        mut self: std::pin::Pin<&mut Self>,
5126        cx: &mut std::task::Context<'_>,
5127    ) -> std::task::Poll<Option<Self::Item>> {
5128        let this = &mut *self;
5129        if this.inner.check_shutdown(cx) {
5130            this.is_terminated = true;
5131            return std::task::Poll::Ready(None);
5132        }
5133        if this.is_terminated {
5134            panic!("polled ProjectIdRequestStream after completion");
5135        }
5136        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5137            |bytes, handles| {
5138                match this.inner.channel().read_etc(cx, bytes, handles) {
5139                    std::task::Poll::Ready(Ok(())) => {}
5140                    std::task::Poll::Pending => return std::task::Poll::Pending,
5141                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5142                        this.is_terminated = true;
5143                        return std::task::Poll::Ready(None);
5144                    }
5145                    std::task::Poll::Ready(Err(e)) => {
5146                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5147                            e.into(),
5148                        ))));
5149                    }
5150                }
5151
5152                // A message has been received from the channel
5153                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5154
5155                std::task::Poll::Ready(Some(match header.ordinal {
5156                    0x20b0fc1e0413876f => {
5157                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5158                        let mut req = fidl::new_empty!(
5159                            ProjectIdSetLimitRequest,
5160                            fidl::encoding::DefaultFuchsiaResourceDialect
5161                        );
5162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetLimitRequest>(&header, _body_bytes, handles, &mut req)?;
5163                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5164                        Ok(ProjectIdRequest::SetLimit {
5165                            project_id: req.project_id,
5166                            bytes: req.bytes,
5167                            nodes: req.nodes,
5168
5169                            responder: ProjectIdSetLimitResponder {
5170                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5171                                tx_id: header.tx_id,
5172                            },
5173                        })
5174                    }
5175                    0x165b5f1e707863c1 => {
5176                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5177                        let mut req = fidl::new_empty!(
5178                            ProjectIdClearRequest,
5179                            fidl::encoding::DefaultFuchsiaResourceDialect
5180                        );
5181                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearRequest>(&header, _body_bytes, handles, &mut req)?;
5182                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5183                        Ok(ProjectIdRequest::Clear {
5184                            project_id: req.project_id,
5185
5186                            responder: ProjectIdClearResponder {
5187                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5188                                tx_id: header.tx_id,
5189                            },
5190                        })
5191                    }
5192                    0x4d7a8442dc58324c => {
5193                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5194                        let mut req = fidl::new_empty!(
5195                            ProjectIdSetForNodeRequest,
5196                            fidl::encoding::DefaultFuchsiaResourceDialect
5197                        );
5198                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5199                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5200                        Ok(ProjectIdRequest::SetForNode {
5201                            node_id: req.node_id,
5202                            project_id: req.project_id,
5203
5204                            responder: ProjectIdSetForNodeResponder {
5205                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5206                                tx_id: header.tx_id,
5207                            },
5208                        })
5209                    }
5210                    0x644073bdf2542573 => {
5211                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5212                        let mut req = fidl::new_empty!(
5213                            ProjectIdGetForNodeRequest,
5214                            fidl::encoding::DefaultFuchsiaResourceDialect
5215                        );
5216                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdGetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5217                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5218                        Ok(ProjectIdRequest::GetForNode {
5219                            node_id: req.node_id,
5220
5221                            responder: ProjectIdGetForNodeResponder {
5222                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5223                                tx_id: header.tx_id,
5224                            },
5225                        })
5226                    }
5227                    0x3f2ca287bbfe6a62 => {
5228                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5229                        let mut req = fidl::new_empty!(
5230                            ProjectIdClearForNodeRequest,
5231                            fidl::encoding::DefaultFuchsiaResourceDialect
5232                        );
5233                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5234                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5235                        Ok(ProjectIdRequest::ClearForNode {
5236                            node_id: req.node_id,
5237
5238                            responder: ProjectIdClearForNodeResponder {
5239                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5240                                tx_id: header.tx_id,
5241                            },
5242                        })
5243                    }
5244                    0x5505f95a36d522cc => {
5245                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5246                        let mut req = fidl::new_empty!(
5247                            ProjectIdListRequest,
5248                            fidl::encoding::DefaultFuchsiaResourceDialect
5249                        );
5250                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdListRequest>(&header, _body_bytes, handles, &mut req)?;
5251                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5252                        Ok(ProjectIdRequest::List {
5253                            token: req.token,
5254
5255                            responder: ProjectIdListResponder {
5256                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5257                                tx_id: header.tx_id,
5258                            },
5259                        })
5260                    }
5261                    0x51b47743c9e2d1ab => {
5262                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5263                        let mut req = fidl::new_empty!(
5264                            ProjectIdInfoRequest,
5265                            fidl::encoding::DefaultFuchsiaResourceDialect
5266                        );
5267                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5268                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5269                        Ok(ProjectIdRequest::Info {
5270                            project_id: req.project_id,
5271
5272                            responder: ProjectIdInfoResponder {
5273                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5274                                tx_id: header.tx_id,
5275                            },
5276                        })
5277                    }
5278                    _ => Err(fidl::Error::UnknownOrdinal {
5279                        ordinal: header.ordinal,
5280                        protocol_name:
5281                            <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5282                    }),
5283                }))
5284            },
5285        )
5286    }
5287}
5288
5289#[derive(Debug)]
5290pub enum ProjectIdRequest {
5291    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5292    /// current usage is accepted but may in the future prevent further increases. Returns
5293    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5294    SetLimit { project_id: u64, bytes: u64, nodes: u64, responder: ProjectIdSetLimitResponder },
5295    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5296    /// currently tracked. It will succeed even if the project is still in use more by one or more
5297    /// nodes.
5298    Clear { project_id: u64, responder: ProjectIdClearResponder },
5299    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5300    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5301    SetForNode { node_id: u64, project_id: u64, responder: ProjectIdSetForNodeResponder },
5302    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5303    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5304    /// currently applied.
5305    GetForNode { node_id: u64, responder: ProjectIdGetForNodeResponder },
5306    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5307    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5308    /// have no project id applied to it.
5309    ClearForNode { node_id: u64, responder: ProjectIdClearForNodeResponder },
5310    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5311    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5312    /// previously provided `next_token` the iteration continues where it left off. If there are
5313    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5314    List { token: Option<Box<ProjectIterToken>>, responder: ProjectIdListResponder },
5315    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5316    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5317    Info { project_id: u64, responder: ProjectIdInfoResponder },
5318}
5319
5320impl ProjectIdRequest {
5321    #[allow(irrefutable_let_patterns)]
5322    pub fn into_set_limit(self) -> Option<(u64, u64, u64, ProjectIdSetLimitResponder)> {
5323        if let ProjectIdRequest::SetLimit { project_id, bytes, nodes, responder } = self {
5324            Some((project_id, bytes, nodes, responder))
5325        } else {
5326            None
5327        }
5328    }
5329
5330    #[allow(irrefutable_let_patterns)]
5331    pub fn into_clear(self) -> Option<(u64, ProjectIdClearResponder)> {
5332        if let ProjectIdRequest::Clear { project_id, responder } = self {
5333            Some((project_id, responder))
5334        } else {
5335            None
5336        }
5337    }
5338
5339    #[allow(irrefutable_let_patterns)]
5340    pub fn into_set_for_node(self) -> Option<(u64, u64, ProjectIdSetForNodeResponder)> {
5341        if let ProjectIdRequest::SetForNode { node_id, project_id, responder } = self {
5342            Some((node_id, project_id, responder))
5343        } else {
5344            None
5345        }
5346    }
5347
5348    #[allow(irrefutable_let_patterns)]
5349    pub fn into_get_for_node(self) -> Option<(u64, ProjectIdGetForNodeResponder)> {
5350        if let ProjectIdRequest::GetForNode { node_id, responder } = self {
5351            Some((node_id, responder))
5352        } else {
5353            None
5354        }
5355    }
5356
5357    #[allow(irrefutable_let_patterns)]
5358    pub fn into_clear_for_node(self) -> Option<(u64, ProjectIdClearForNodeResponder)> {
5359        if let ProjectIdRequest::ClearForNode { node_id, responder } = self {
5360            Some((node_id, responder))
5361        } else {
5362            None
5363        }
5364    }
5365
5366    #[allow(irrefutable_let_patterns)]
5367    pub fn into_list(self) -> Option<(Option<Box<ProjectIterToken>>, ProjectIdListResponder)> {
5368        if let ProjectIdRequest::List { token, responder } = self {
5369            Some((token, responder))
5370        } else {
5371            None
5372        }
5373    }
5374
5375    #[allow(irrefutable_let_patterns)]
5376    pub fn into_info(self) -> Option<(u64, ProjectIdInfoResponder)> {
5377        if let ProjectIdRequest::Info { project_id, responder } = self {
5378            Some((project_id, responder))
5379        } else {
5380            None
5381        }
5382    }
5383
5384    /// Name of the method defined in FIDL
5385    pub fn method_name(&self) -> &'static str {
5386        match *self {
5387            ProjectIdRequest::SetLimit { .. } => "set_limit",
5388            ProjectIdRequest::Clear { .. } => "clear",
5389            ProjectIdRequest::SetForNode { .. } => "set_for_node",
5390            ProjectIdRequest::GetForNode { .. } => "get_for_node",
5391            ProjectIdRequest::ClearForNode { .. } => "clear_for_node",
5392            ProjectIdRequest::List { .. } => "list",
5393            ProjectIdRequest::Info { .. } => "info",
5394        }
5395    }
5396}
5397
5398#[derive(Debug, Clone)]
5399pub struct ProjectIdControlHandle {
5400    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5401}
5402
5403impl fidl::endpoints::ControlHandle for ProjectIdControlHandle {
5404    fn shutdown(&self) {
5405        self.inner.shutdown()
5406    }
5407    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5408        self.inner.shutdown_with_epitaph(status)
5409    }
5410
5411    fn is_closed(&self) -> bool {
5412        self.inner.channel().is_closed()
5413    }
5414    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5415        self.inner.channel().on_closed()
5416    }
5417
5418    #[cfg(target_os = "fuchsia")]
5419    fn signal_peer(
5420        &self,
5421        clear_mask: zx::Signals,
5422        set_mask: zx::Signals,
5423    ) -> Result<(), zx_status::Status> {
5424        use fidl::Peered;
5425        self.inner.channel().signal_peer(clear_mask, set_mask)
5426    }
5427}
5428
5429impl ProjectIdControlHandle {}
5430
5431#[must_use = "FIDL methods require a response to be sent"]
5432#[derive(Debug)]
5433pub struct ProjectIdSetLimitResponder {
5434    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5435    tx_id: u32,
5436}
5437
5438/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5439/// if the responder is dropped without sending a response, so that the client
5440/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5441impl std::ops::Drop for ProjectIdSetLimitResponder {
5442    fn drop(&mut self) {
5443        self.control_handle.shutdown();
5444        // Safety: drops once, never accessed again
5445        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5446    }
5447}
5448
5449impl fidl::endpoints::Responder for ProjectIdSetLimitResponder {
5450    type ControlHandle = ProjectIdControlHandle;
5451
5452    fn control_handle(&self) -> &ProjectIdControlHandle {
5453        &self.control_handle
5454    }
5455
5456    fn drop_without_shutdown(mut self) {
5457        // Safety: drops once, never accessed again due to mem::forget
5458        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5459        // Prevent Drop from running (which would shut down the channel)
5460        std::mem::forget(self);
5461    }
5462}
5463
5464impl ProjectIdSetLimitResponder {
5465    /// Sends a response to the FIDL transaction.
5466    ///
5467    /// Sets the channel to shutdown if an error occurs.
5468    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5469        let _result = self.send_raw(result);
5470        if _result.is_err() {
5471            self.control_handle.shutdown();
5472        }
5473        self.drop_without_shutdown();
5474        _result
5475    }
5476
5477    /// Similar to "send" but does not shutdown the channel if an error occurs.
5478    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5479        let _result = self.send_raw(result);
5480        self.drop_without_shutdown();
5481        _result
5482    }
5483
5484    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5485        self.control_handle
5486            .inner
5487            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5488                result,
5489                self.tx_id,
5490                0x20b0fc1e0413876f,
5491                fidl::encoding::DynamicFlags::empty(),
5492            )
5493    }
5494}
5495
5496#[must_use = "FIDL methods require a response to be sent"]
5497#[derive(Debug)]
5498pub struct ProjectIdClearResponder {
5499    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5500    tx_id: u32,
5501}
5502
5503/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5504/// if the responder is dropped without sending a response, so that the client
5505/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5506impl std::ops::Drop for ProjectIdClearResponder {
5507    fn drop(&mut self) {
5508        self.control_handle.shutdown();
5509        // Safety: drops once, never accessed again
5510        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5511    }
5512}
5513
5514impl fidl::endpoints::Responder for ProjectIdClearResponder {
5515    type ControlHandle = ProjectIdControlHandle;
5516
5517    fn control_handle(&self) -> &ProjectIdControlHandle {
5518        &self.control_handle
5519    }
5520
5521    fn drop_without_shutdown(mut self) {
5522        // Safety: drops once, never accessed again due to mem::forget
5523        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5524        // Prevent Drop from running (which would shut down the channel)
5525        std::mem::forget(self);
5526    }
5527}
5528
5529impl ProjectIdClearResponder {
5530    /// Sends a response to the FIDL transaction.
5531    ///
5532    /// Sets the channel to shutdown if an error occurs.
5533    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5534        let _result = self.send_raw(result);
5535        if _result.is_err() {
5536            self.control_handle.shutdown();
5537        }
5538        self.drop_without_shutdown();
5539        _result
5540    }
5541
5542    /// Similar to "send" but does not shutdown the channel if an error occurs.
5543    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5544        let _result = self.send_raw(result);
5545        self.drop_without_shutdown();
5546        _result
5547    }
5548
5549    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5550        self.control_handle
5551            .inner
5552            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5553                result,
5554                self.tx_id,
5555                0x165b5f1e707863c1,
5556                fidl::encoding::DynamicFlags::empty(),
5557            )
5558    }
5559}
5560
5561#[must_use = "FIDL methods require a response to be sent"]
5562#[derive(Debug)]
5563pub struct ProjectIdSetForNodeResponder {
5564    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5565    tx_id: u32,
5566}
5567
5568/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5569/// if the responder is dropped without sending a response, so that the client
5570/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5571impl std::ops::Drop for ProjectIdSetForNodeResponder {
5572    fn drop(&mut self) {
5573        self.control_handle.shutdown();
5574        // Safety: drops once, never accessed again
5575        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5576    }
5577}
5578
5579impl fidl::endpoints::Responder for ProjectIdSetForNodeResponder {
5580    type ControlHandle = ProjectIdControlHandle;
5581
5582    fn control_handle(&self) -> &ProjectIdControlHandle {
5583        &self.control_handle
5584    }
5585
5586    fn drop_without_shutdown(mut self) {
5587        // Safety: drops once, never accessed again due to mem::forget
5588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5589        // Prevent Drop from running (which would shut down the channel)
5590        std::mem::forget(self);
5591    }
5592}
5593
5594impl ProjectIdSetForNodeResponder {
5595    /// Sends a response to the FIDL transaction.
5596    ///
5597    /// Sets the channel to shutdown if an error occurs.
5598    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5599        let _result = self.send_raw(result);
5600        if _result.is_err() {
5601            self.control_handle.shutdown();
5602        }
5603        self.drop_without_shutdown();
5604        _result
5605    }
5606
5607    /// Similar to "send" but does not shutdown the channel if an error occurs.
5608    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5609        let _result = self.send_raw(result);
5610        self.drop_without_shutdown();
5611        _result
5612    }
5613
5614    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5615        self.control_handle
5616            .inner
5617            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5618                result,
5619                self.tx_id,
5620                0x4d7a8442dc58324c,
5621                fidl::encoding::DynamicFlags::empty(),
5622            )
5623    }
5624}
5625
5626#[must_use = "FIDL methods require a response to be sent"]
5627#[derive(Debug)]
5628pub struct ProjectIdGetForNodeResponder {
5629    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5630    tx_id: u32,
5631}
5632
5633/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5634/// if the responder is dropped without sending a response, so that the client
5635/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5636impl std::ops::Drop for ProjectIdGetForNodeResponder {
5637    fn drop(&mut self) {
5638        self.control_handle.shutdown();
5639        // Safety: drops once, never accessed again
5640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5641    }
5642}
5643
5644impl fidl::endpoints::Responder for ProjectIdGetForNodeResponder {
5645    type ControlHandle = ProjectIdControlHandle;
5646
5647    fn control_handle(&self) -> &ProjectIdControlHandle {
5648        &self.control_handle
5649    }
5650
5651    fn drop_without_shutdown(mut self) {
5652        // Safety: drops once, never accessed again due to mem::forget
5653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5654        // Prevent Drop from running (which would shut down the channel)
5655        std::mem::forget(self);
5656    }
5657}
5658
5659impl ProjectIdGetForNodeResponder {
5660    /// Sends a response to the FIDL transaction.
5661    ///
5662    /// Sets the channel to shutdown if an error occurs.
5663    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
5664        let _result = self.send_raw(result);
5665        if _result.is_err() {
5666            self.control_handle.shutdown();
5667        }
5668        self.drop_without_shutdown();
5669        _result
5670    }
5671
5672    /// Similar to "send" but does not shutdown the channel if an error occurs.
5673    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
5674        let _result = self.send_raw(result);
5675        self.drop_without_shutdown();
5676        _result
5677    }
5678
5679    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
5680        self.control_handle
5681            .inner
5682            .send::<fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>>(
5683                result.map(|project_id| (project_id,)),
5684                self.tx_id,
5685                0x644073bdf2542573,
5686                fidl::encoding::DynamicFlags::empty(),
5687            )
5688    }
5689}
5690
5691#[must_use = "FIDL methods require a response to be sent"]
5692#[derive(Debug)]
5693pub struct ProjectIdClearForNodeResponder {
5694    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5695    tx_id: u32,
5696}
5697
5698/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5699/// if the responder is dropped without sending a response, so that the client
5700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5701impl std::ops::Drop for ProjectIdClearForNodeResponder {
5702    fn drop(&mut self) {
5703        self.control_handle.shutdown();
5704        // Safety: drops once, never accessed again
5705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5706    }
5707}
5708
5709impl fidl::endpoints::Responder for ProjectIdClearForNodeResponder {
5710    type ControlHandle = ProjectIdControlHandle;
5711
5712    fn control_handle(&self) -> &ProjectIdControlHandle {
5713        &self.control_handle
5714    }
5715
5716    fn drop_without_shutdown(mut self) {
5717        // Safety: drops once, never accessed again due to mem::forget
5718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5719        // Prevent Drop from running (which would shut down the channel)
5720        std::mem::forget(self);
5721    }
5722}
5723
5724impl ProjectIdClearForNodeResponder {
5725    /// Sends a response to the FIDL transaction.
5726    ///
5727    /// Sets the channel to shutdown if an error occurs.
5728    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5729        let _result = self.send_raw(result);
5730        if _result.is_err() {
5731            self.control_handle.shutdown();
5732        }
5733        self.drop_without_shutdown();
5734        _result
5735    }
5736
5737    /// Similar to "send" but does not shutdown the channel if an error occurs.
5738    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5739        let _result = self.send_raw(result);
5740        self.drop_without_shutdown();
5741        _result
5742    }
5743
5744    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5745        self.control_handle
5746            .inner
5747            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5748                result,
5749                self.tx_id,
5750                0x3f2ca287bbfe6a62,
5751                fidl::encoding::DynamicFlags::empty(),
5752            )
5753    }
5754}
5755
5756#[must_use = "FIDL methods require a response to be sent"]
5757#[derive(Debug)]
5758pub struct ProjectIdListResponder {
5759    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5760    tx_id: u32,
5761}
5762
5763/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5764/// if the responder is dropped without sending a response, so that the client
5765/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5766impl std::ops::Drop for ProjectIdListResponder {
5767    fn drop(&mut self) {
5768        self.control_handle.shutdown();
5769        // Safety: drops once, never accessed again
5770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5771    }
5772}
5773
5774impl fidl::endpoints::Responder for ProjectIdListResponder {
5775    type ControlHandle = ProjectIdControlHandle;
5776
5777    fn control_handle(&self) -> &ProjectIdControlHandle {
5778        &self.control_handle
5779    }
5780
5781    fn drop_without_shutdown(mut self) {
5782        // Safety: drops once, never accessed again due to mem::forget
5783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5784        // Prevent Drop from running (which would shut down the channel)
5785        std::mem::forget(self);
5786    }
5787}
5788
5789impl ProjectIdListResponder {
5790    /// Sends a response to the FIDL transaction.
5791    ///
5792    /// Sets the channel to shutdown if an error occurs.
5793    pub fn send(
5794        self,
5795        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5796    ) -> Result<(), fidl::Error> {
5797        let _result = self.send_raw(result);
5798        if _result.is_err() {
5799            self.control_handle.shutdown();
5800        }
5801        self.drop_without_shutdown();
5802        _result
5803    }
5804
5805    /// Similar to "send" but does not shutdown the channel if an error occurs.
5806    pub fn send_no_shutdown_on_err(
5807        self,
5808        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5809    ) -> Result<(), fidl::Error> {
5810        let _result = self.send_raw(result);
5811        self.drop_without_shutdown();
5812        _result
5813    }
5814
5815    fn send_raw(
5816        &self,
5817        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5818    ) -> Result<(), fidl::Error> {
5819        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdListResponse, i32>>(
5820            result,
5821            self.tx_id,
5822            0x5505f95a36d522cc,
5823            fidl::encoding::DynamicFlags::empty(),
5824        )
5825    }
5826}
5827
5828#[must_use = "FIDL methods require a response to be sent"]
5829#[derive(Debug)]
5830pub struct ProjectIdInfoResponder {
5831    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5832    tx_id: u32,
5833}
5834
5835/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5836/// if the responder is dropped without sending a response, so that the client
5837/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5838impl std::ops::Drop for ProjectIdInfoResponder {
5839    fn drop(&mut self) {
5840        self.control_handle.shutdown();
5841        // Safety: drops once, never accessed again
5842        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5843    }
5844}
5845
5846impl fidl::endpoints::Responder for ProjectIdInfoResponder {
5847    type ControlHandle = ProjectIdControlHandle;
5848
5849    fn control_handle(&self) -> &ProjectIdControlHandle {
5850        &self.control_handle
5851    }
5852
5853    fn drop_without_shutdown(mut self) {
5854        // Safety: drops once, never accessed again due to mem::forget
5855        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5856        // Prevent Drop from running (which would shut down the channel)
5857        std::mem::forget(self);
5858    }
5859}
5860
5861impl ProjectIdInfoResponder {
5862    /// Sends a response to the FIDL transaction.
5863    ///
5864    /// Sets the channel to shutdown if an error occurs.
5865    pub fn send(
5866        self,
5867        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5868    ) -> Result<(), fidl::Error> {
5869        let _result = self.send_raw(result);
5870        if _result.is_err() {
5871            self.control_handle.shutdown();
5872        }
5873        self.drop_without_shutdown();
5874        _result
5875    }
5876
5877    /// Similar to "send" but does not shutdown the channel if an error occurs.
5878    pub fn send_no_shutdown_on_err(
5879        self,
5880        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5881    ) -> Result<(), fidl::Error> {
5882        let _result = self.send_raw(result);
5883        self.drop_without_shutdown();
5884        _result
5885    }
5886
5887    fn send_raw(
5888        &self,
5889        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5890    ) -> Result<(), fidl::Error> {
5891        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdInfoResponse, i32>>(
5892            result,
5893            self.tx_id,
5894            0x51b47743c9e2d1ab,
5895            fidl::encoding::DynamicFlags::empty(),
5896        )
5897    }
5898}
5899
5900mod internal {
5901    use super::*;
5902
5903    impl fidl::encoding::ResourceTypeMarker for BlobCreatorCreateResponse {
5904        type Borrowed<'a> = &'a mut Self;
5905        fn take_or_borrow<'a>(
5906            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5907        ) -> Self::Borrowed<'a> {
5908            value
5909        }
5910    }
5911
5912    unsafe impl fidl::encoding::TypeMarker for BlobCreatorCreateResponse {
5913        type Owned = Self;
5914
5915        #[inline(always)]
5916        fn inline_align(_context: fidl::encoding::Context) -> usize {
5917            4
5918        }
5919
5920        #[inline(always)]
5921        fn inline_size(_context: fidl::encoding::Context) -> usize {
5922            4
5923        }
5924    }
5925
5926    unsafe impl
5927        fidl::encoding::Encode<
5928            BlobCreatorCreateResponse,
5929            fidl::encoding::DefaultFuchsiaResourceDialect,
5930        > for &mut BlobCreatorCreateResponse
5931    {
5932        #[inline]
5933        unsafe fn encode(
5934            self,
5935            encoder: &mut fidl::encoding::Encoder<
5936                '_,
5937                fidl::encoding::DefaultFuchsiaResourceDialect,
5938            >,
5939            offset: usize,
5940            _depth: fidl::encoding::Depth,
5941        ) -> fidl::Result<()> {
5942            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
5943            // Delegate to tuple encoding.
5944            fidl::encoding::Encode::<BlobCreatorCreateResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5945                (
5946                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
5947                ),
5948                encoder, offset, _depth
5949            )
5950        }
5951    }
5952    unsafe impl<
5953        T0: fidl::encoding::Encode<
5954                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
5955                fidl::encoding::DefaultFuchsiaResourceDialect,
5956            >,
5957    >
5958        fidl::encoding::Encode<
5959            BlobCreatorCreateResponse,
5960            fidl::encoding::DefaultFuchsiaResourceDialect,
5961        > for (T0,)
5962    {
5963        #[inline]
5964        unsafe fn encode(
5965            self,
5966            encoder: &mut fidl::encoding::Encoder<
5967                '_,
5968                fidl::encoding::DefaultFuchsiaResourceDialect,
5969            >,
5970            offset: usize,
5971            depth: fidl::encoding::Depth,
5972        ) -> fidl::Result<()> {
5973            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
5974            // Zero out padding regions. There's no need to apply masks
5975            // because the unmasked parts will be overwritten by fields.
5976            // Write the fields.
5977            self.0.encode(encoder, offset + 0, depth)?;
5978            Ok(())
5979        }
5980    }
5981
5982    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5983        for BlobCreatorCreateResponse
5984    {
5985        #[inline(always)]
5986        fn new_empty() -> Self {
5987            Self {
5988                writer: fidl::new_empty!(
5989                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
5990                    fidl::encoding::DefaultFuchsiaResourceDialect
5991                ),
5992            }
5993        }
5994
5995        #[inline]
5996        unsafe fn decode(
5997            &mut self,
5998            decoder: &mut fidl::encoding::Decoder<
5999                '_,
6000                fidl::encoding::DefaultFuchsiaResourceDialect,
6001            >,
6002            offset: usize,
6003            _depth: fidl::encoding::Depth,
6004        ) -> fidl::Result<()> {
6005            decoder.debug_check_bounds::<Self>(offset);
6006            // Verify that padding bytes are zero.
6007            fidl::decode!(
6008                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
6009                fidl::encoding::DefaultFuchsiaResourceDialect,
6010                &mut self.writer,
6011                decoder,
6012                offset + 0,
6013                _depth
6014            )?;
6015            Ok(())
6016        }
6017    }
6018
6019    impl fidl::encoding::ResourceTypeMarker for BlobReaderGetVmoResponse {
6020        type Borrowed<'a> = &'a mut Self;
6021        fn take_or_borrow<'a>(
6022            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6023        ) -> Self::Borrowed<'a> {
6024            value
6025        }
6026    }
6027
6028    unsafe impl fidl::encoding::TypeMarker for BlobReaderGetVmoResponse {
6029        type Owned = Self;
6030
6031        #[inline(always)]
6032        fn inline_align(_context: fidl::encoding::Context) -> usize {
6033            4
6034        }
6035
6036        #[inline(always)]
6037        fn inline_size(_context: fidl::encoding::Context) -> usize {
6038            4
6039        }
6040    }
6041
6042    unsafe impl
6043        fidl::encoding::Encode<
6044            BlobReaderGetVmoResponse,
6045            fidl::encoding::DefaultFuchsiaResourceDialect,
6046        > for &mut BlobReaderGetVmoResponse
6047    {
6048        #[inline]
6049        unsafe fn encode(
6050            self,
6051            encoder: &mut fidl::encoding::Encoder<
6052                '_,
6053                fidl::encoding::DefaultFuchsiaResourceDialect,
6054            >,
6055            offset: usize,
6056            _depth: fidl::encoding::Depth,
6057        ) -> fidl::Result<()> {
6058            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
6059            // Delegate to tuple encoding.
6060            fidl::encoding::Encode::<
6061                BlobReaderGetVmoResponse,
6062                fidl::encoding::DefaultFuchsiaResourceDialect,
6063            >::encode(
6064                (<fidl::encoding::HandleType<
6065                    fidl::Vmo,
6066                    { fidl::ObjectType::VMO.into_raw() },
6067                    2147483648,
6068                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6069                    &mut self.vmo
6070                ),),
6071                encoder,
6072                offset,
6073                _depth,
6074            )
6075        }
6076    }
6077    unsafe impl<
6078        T0: fidl::encoding::Encode<
6079                fidl::encoding::HandleType<
6080                    fidl::Vmo,
6081                    { fidl::ObjectType::VMO.into_raw() },
6082                    2147483648,
6083                >,
6084                fidl::encoding::DefaultFuchsiaResourceDialect,
6085            >,
6086    >
6087        fidl::encoding::Encode<
6088            BlobReaderGetVmoResponse,
6089            fidl::encoding::DefaultFuchsiaResourceDialect,
6090        > for (T0,)
6091    {
6092        #[inline]
6093        unsafe fn encode(
6094            self,
6095            encoder: &mut fidl::encoding::Encoder<
6096                '_,
6097                fidl::encoding::DefaultFuchsiaResourceDialect,
6098            >,
6099            offset: usize,
6100            depth: fidl::encoding::Depth,
6101        ) -> fidl::Result<()> {
6102            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
6103            // Zero out padding regions. There's no need to apply masks
6104            // because the unmasked parts will be overwritten by fields.
6105            // Write the fields.
6106            self.0.encode(encoder, offset + 0, depth)?;
6107            Ok(())
6108        }
6109    }
6110
6111    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6112        for BlobReaderGetVmoResponse
6113    {
6114        #[inline(always)]
6115        fn new_empty() -> Self {
6116            Self {
6117                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6118            }
6119        }
6120
6121        #[inline]
6122        unsafe fn decode(
6123            &mut self,
6124            decoder: &mut fidl::encoding::Decoder<
6125                '_,
6126                fidl::encoding::DefaultFuchsiaResourceDialect,
6127            >,
6128            offset: usize,
6129            _depth: fidl::encoding::Depth,
6130        ) -> fidl::Result<()> {
6131            decoder.debug_check_bounds::<Self>(offset);
6132            // Verify that padding bytes are zero.
6133            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
6134            Ok(())
6135        }
6136    }
6137
6138    impl fidl::encoding::ResourceTypeMarker for BlobWriterGetVmoResponse {
6139        type Borrowed<'a> = &'a mut Self;
6140        fn take_or_borrow<'a>(
6141            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6142        ) -> Self::Borrowed<'a> {
6143            value
6144        }
6145    }
6146
6147    unsafe impl fidl::encoding::TypeMarker for BlobWriterGetVmoResponse {
6148        type Owned = Self;
6149
6150        #[inline(always)]
6151        fn inline_align(_context: fidl::encoding::Context) -> usize {
6152            4
6153        }
6154
6155        #[inline(always)]
6156        fn inline_size(_context: fidl::encoding::Context) -> usize {
6157            4
6158        }
6159    }
6160
6161    unsafe impl
6162        fidl::encoding::Encode<
6163            BlobWriterGetVmoResponse,
6164            fidl::encoding::DefaultFuchsiaResourceDialect,
6165        > for &mut BlobWriterGetVmoResponse
6166    {
6167        #[inline]
6168        unsafe fn encode(
6169            self,
6170            encoder: &mut fidl::encoding::Encoder<
6171                '_,
6172                fidl::encoding::DefaultFuchsiaResourceDialect,
6173            >,
6174            offset: usize,
6175            _depth: fidl::encoding::Depth,
6176        ) -> fidl::Result<()> {
6177            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
6178            // Delegate to tuple encoding.
6179            fidl::encoding::Encode::<
6180                BlobWriterGetVmoResponse,
6181                fidl::encoding::DefaultFuchsiaResourceDialect,
6182            >::encode(
6183                (<fidl::encoding::HandleType<
6184                    fidl::Vmo,
6185                    { fidl::ObjectType::VMO.into_raw() },
6186                    2147483648,
6187                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6188                    &mut self.vmo
6189                ),),
6190                encoder,
6191                offset,
6192                _depth,
6193            )
6194        }
6195    }
6196    unsafe impl<
6197        T0: fidl::encoding::Encode<
6198                fidl::encoding::HandleType<
6199                    fidl::Vmo,
6200                    { fidl::ObjectType::VMO.into_raw() },
6201                    2147483648,
6202                >,
6203                fidl::encoding::DefaultFuchsiaResourceDialect,
6204            >,
6205    >
6206        fidl::encoding::Encode<
6207            BlobWriterGetVmoResponse,
6208            fidl::encoding::DefaultFuchsiaResourceDialect,
6209        > for (T0,)
6210    {
6211        #[inline]
6212        unsafe fn encode(
6213            self,
6214            encoder: &mut fidl::encoding::Encoder<
6215                '_,
6216                fidl::encoding::DefaultFuchsiaResourceDialect,
6217            >,
6218            offset: usize,
6219            depth: fidl::encoding::Depth,
6220        ) -> fidl::Result<()> {
6221            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
6222            // Zero out padding regions. There's no need to apply masks
6223            // because the unmasked parts will be overwritten by fields.
6224            // Write the fields.
6225            self.0.encode(encoder, offset + 0, depth)?;
6226            Ok(())
6227        }
6228    }
6229
6230    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6231        for BlobWriterGetVmoResponse
6232    {
6233        #[inline(always)]
6234        fn new_empty() -> Self {
6235            Self {
6236                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6237            }
6238        }
6239
6240        #[inline]
6241        unsafe fn decode(
6242            &mut self,
6243            decoder: &mut fidl::encoding::Decoder<
6244                '_,
6245                fidl::encoding::DefaultFuchsiaResourceDialect,
6246            >,
6247            offset: usize,
6248            _depth: fidl::encoding::Depth,
6249        ) -> fidl::Result<()> {
6250            decoder.debug_check_bounds::<Self>(offset);
6251            // Verify that padding bytes are zero.
6252            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
6253            Ok(())
6254        }
6255    }
6256
6257    impl fidl::encoding::ResourceTypeMarker for FileBackedVolumeProviderOpenRequest {
6258        type Borrowed<'a> = &'a mut Self;
6259        fn take_or_borrow<'a>(
6260            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6261        ) -> Self::Borrowed<'a> {
6262            value
6263        }
6264    }
6265
6266    unsafe impl fidl::encoding::TypeMarker for FileBackedVolumeProviderOpenRequest {
6267        type Owned = Self;
6268
6269        #[inline(always)]
6270        fn inline_align(_context: fidl::encoding::Context) -> usize {
6271            8
6272        }
6273
6274        #[inline(always)]
6275        fn inline_size(_context: fidl::encoding::Context) -> usize {
6276            32
6277        }
6278    }
6279
6280    unsafe impl
6281        fidl::encoding::Encode<
6282            FileBackedVolumeProviderOpenRequest,
6283            fidl::encoding::DefaultFuchsiaResourceDialect,
6284        > for &mut FileBackedVolumeProviderOpenRequest
6285    {
6286        #[inline]
6287        unsafe fn encode(
6288            self,
6289            encoder: &mut fidl::encoding::Encoder<
6290                '_,
6291                fidl::encoding::DefaultFuchsiaResourceDialect,
6292            >,
6293            offset: usize,
6294            _depth: fidl::encoding::Depth,
6295        ) -> fidl::Result<()> {
6296            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
6297            // Delegate to tuple encoding.
6298            fidl::encoding::Encode::<
6299                FileBackedVolumeProviderOpenRequest,
6300                fidl::encoding::DefaultFuchsiaResourceDialect,
6301            >::encode(
6302                (
6303                    <fidl::encoding::HandleType<
6304                        fidl::Handle,
6305                        { fidl::ObjectType::NONE.into_raw() },
6306                        2147483648,
6307                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6308                        &mut self.parent_directory_token,
6309                    ),
6310                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
6311                        &self.name,
6312                    ),
6313                    <fidl::encoding::Endpoint<
6314                        fidl::endpoints::ServerEnd<
6315                            fidl_fuchsia_hardware_block_volume::VolumeMarker,
6316                        >,
6317                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6318                        &mut self.server_end
6319                    ),
6320                ),
6321                encoder,
6322                offset,
6323                _depth,
6324            )
6325        }
6326    }
6327    unsafe impl<
6328        T0: fidl::encoding::Encode<
6329                fidl::encoding::HandleType<
6330                    fidl::Handle,
6331                    { fidl::ObjectType::NONE.into_raw() },
6332                    2147483648,
6333                >,
6334                fidl::encoding::DefaultFuchsiaResourceDialect,
6335            >,
6336        T1: fidl::encoding::Encode<
6337                fidl::encoding::BoundedString<255>,
6338                fidl::encoding::DefaultFuchsiaResourceDialect,
6339            >,
6340        T2: fidl::encoding::Encode<
6341                fidl::encoding::Endpoint<
6342                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
6343                >,
6344                fidl::encoding::DefaultFuchsiaResourceDialect,
6345            >,
6346    >
6347        fidl::encoding::Encode<
6348            FileBackedVolumeProviderOpenRequest,
6349            fidl::encoding::DefaultFuchsiaResourceDialect,
6350        > for (T0, T1, T2)
6351    {
6352        #[inline]
6353        unsafe fn encode(
6354            self,
6355            encoder: &mut fidl::encoding::Encoder<
6356                '_,
6357                fidl::encoding::DefaultFuchsiaResourceDialect,
6358            >,
6359            offset: usize,
6360            depth: fidl::encoding::Depth,
6361        ) -> fidl::Result<()> {
6362            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
6363            // Zero out padding regions. There's no need to apply masks
6364            // because the unmasked parts will be overwritten by fields.
6365            unsafe {
6366                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
6367                (ptr as *mut u64).write_unaligned(0);
6368            }
6369            unsafe {
6370                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
6371                (ptr as *mut u64).write_unaligned(0);
6372            }
6373            // Write the fields.
6374            self.0.encode(encoder, offset + 0, depth)?;
6375            self.1.encode(encoder, offset + 8, depth)?;
6376            self.2.encode(encoder, offset + 24, depth)?;
6377            Ok(())
6378        }
6379    }
6380
6381    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6382        for FileBackedVolumeProviderOpenRequest
6383    {
6384        #[inline(always)]
6385        fn new_empty() -> Self {
6386            Self {
6387                parent_directory_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6388                name: fidl::new_empty!(
6389                    fidl::encoding::BoundedString<255>,
6390                    fidl::encoding::DefaultFuchsiaResourceDialect
6391                ),
6392                server_end: fidl::new_empty!(
6393                    fidl::encoding::Endpoint<
6394                        fidl::endpoints::ServerEnd<
6395                            fidl_fuchsia_hardware_block_volume::VolumeMarker,
6396                        >,
6397                    >,
6398                    fidl::encoding::DefaultFuchsiaResourceDialect
6399                ),
6400            }
6401        }
6402
6403        #[inline]
6404        unsafe fn decode(
6405            &mut self,
6406            decoder: &mut fidl::encoding::Decoder<
6407                '_,
6408                fidl::encoding::DefaultFuchsiaResourceDialect,
6409            >,
6410            offset: usize,
6411            _depth: fidl::encoding::Depth,
6412        ) -> fidl::Result<()> {
6413            decoder.debug_check_bounds::<Self>(offset);
6414            // Verify that padding bytes are zero.
6415            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
6416            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6417            let mask = 0xffffffff00000000u64;
6418            let maskedval = padval & mask;
6419            if maskedval != 0 {
6420                return Err(fidl::Error::NonZeroPadding {
6421                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
6422                });
6423            }
6424            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
6425            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6426            let mask = 0xffffffff00000000u64;
6427            let maskedval = padval & mask;
6428            if maskedval != 0 {
6429                return Err(fidl::Error::NonZeroPadding {
6430                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
6431                });
6432            }
6433            fidl::decode!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parent_directory_token, decoder, offset + 0, _depth)?;
6434            fidl::decode!(
6435                fidl::encoding::BoundedString<255>,
6436                fidl::encoding::DefaultFuchsiaResourceDialect,
6437                &mut self.name,
6438                decoder,
6439                offset + 8,
6440                _depth
6441            )?;
6442            fidl::decode!(
6443                fidl::encoding::Endpoint<
6444                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
6445                >,
6446                fidl::encoding::DefaultFuchsiaResourceDialect,
6447                &mut self.server_end,
6448                decoder,
6449                offset + 24,
6450                _depth
6451            )?;
6452            Ok(())
6453        }
6454    }
6455}