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