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 {
4248            Some((responder))
4249        } else {
4250            None
4251        }
4252    }
4253
4254    #[allow(irrefutable_let_patterns)]
4255    pub fn into_delete_profile(self) -> Option<(String, String, DebugDeleteProfileResponder)> {
4256        if let DebugRequest::DeleteProfile { volume, profile, responder } = self {
4257            Some((volume, profile, responder))
4258        } else {
4259            None
4260        }
4261    }
4262
4263    #[allow(irrefutable_let_patterns)]
4264    pub fn into_stop_profile_tasks(self) -> Option<(DebugStopProfileTasksResponder)> {
4265        if let DebugRequest::StopProfileTasks { responder } = self {
4266            Some((responder))
4267        } else {
4268            None
4269        }
4270    }
4271
4272    /// Name of the method defined in FIDL
4273    pub fn method_name(&self) -> &'static str {
4274        match *self {
4275            DebugRequest::Compact { .. } => "compact",
4276            DebugRequest::DeleteProfile { .. } => "delete_profile",
4277            DebugRequest::StopProfileTasks { .. } => "stop_profile_tasks",
4278        }
4279    }
4280}
4281
4282#[derive(Debug, Clone)]
4283pub struct DebugControlHandle {
4284    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4285}
4286
4287impl fidl::endpoints::ControlHandle for DebugControlHandle {
4288    fn shutdown(&self) {
4289        self.inner.shutdown()
4290    }
4291    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4292        self.inner.shutdown_with_epitaph(status)
4293    }
4294
4295    fn is_closed(&self) -> bool {
4296        self.inner.channel().is_closed()
4297    }
4298    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4299        self.inner.channel().on_closed()
4300    }
4301
4302    #[cfg(target_os = "fuchsia")]
4303    fn signal_peer(
4304        &self,
4305        clear_mask: zx::Signals,
4306        set_mask: zx::Signals,
4307    ) -> Result<(), zx_status::Status> {
4308        use fidl::Peered;
4309        self.inner.channel().signal_peer(clear_mask, set_mask)
4310    }
4311}
4312
4313impl DebugControlHandle {}
4314
4315#[must_use = "FIDL methods require a response to be sent"]
4316#[derive(Debug)]
4317pub struct DebugCompactResponder {
4318    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4319    tx_id: u32,
4320}
4321
4322/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4323/// if the responder is dropped without sending a response, so that the client
4324/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4325impl std::ops::Drop for DebugCompactResponder {
4326    fn drop(&mut self) {
4327        self.control_handle.shutdown();
4328        // Safety: drops once, never accessed again
4329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4330    }
4331}
4332
4333impl fidl::endpoints::Responder for DebugCompactResponder {
4334    type ControlHandle = DebugControlHandle;
4335
4336    fn control_handle(&self) -> &DebugControlHandle {
4337        &self.control_handle
4338    }
4339
4340    fn drop_without_shutdown(mut self) {
4341        // Safety: drops once, never accessed again due to mem::forget
4342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4343        // Prevent Drop from running (which would shut down the channel)
4344        std::mem::forget(self);
4345    }
4346}
4347
4348impl DebugCompactResponder {
4349    /// Sends a response to the FIDL transaction.
4350    ///
4351    /// Sets the channel to shutdown if an error occurs.
4352    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4353        let _result = self.send_raw(result);
4354        if _result.is_err() {
4355            self.control_handle.shutdown();
4356        }
4357        self.drop_without_shutdown();
4358        _result
4359    }
4360
4361    /// Similar to "send" but does not shutdown the channel if an error occurs.
4362    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4363        let _result = self.send_raw(result);
4364        self.drop_without_shutdown();
4365        _result
4366    }
4367
4368    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4369        self.control_handle
4370            .inner
4371            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4372                result,
4373                self.tx_id,
4374                0x6553eb197306e489,
4375                fidl::encoding::DynamicFlags::empty(),
4376            )
4377    }
4378}
4379
4380#[must_use = "FIDL methods require a response to be sent"]
4381#[derive(Debug)]
4382pub struct DebugDeleteProfileResponder {
4383    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4384    tx_id: u32,
4385}
4386
4387/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4388/// if the responder is dropped without sending a response, so that the client
4389/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4390impl std::ops::Drop for DebugDeleteProfileResponder {
4391    fn drop(&mut self) {
4392        self.control_handle.shutdown();
4393        // Safety: drops once, never accessed again
4394        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4395    }
4396}
4397
4398impl fidl::endpoints::Responder for DebugDeleteProfileResponder {
4399    type ControlHandle = DebugControlHandle;
4400
4401    fn control_handle(&self) -> &DebugControlHandle {
4402        &self.control_handle
4403    }
4404
4405    fn drop_without_shutdown(mut self) {
4406        // Safety: drops once, never accessed again due to mem::forget
4407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4408        // Prevent Drop from running (which would shut down the channel)
4409        std::mem::forget(self);
4410    }
4411}
4412
4413impl DebugDeleteProfileResponder {
4414    /// Sends a response to the FIDL transaction.
4415    ///
4416    /// Sets the channel to shutdown if an error occurs.
4417    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4418        let _result = self.send_raw(result);
4419        if _result.is_err() {
4420            self.control_handle.shutdown();
4421        }
4422        self.drop_without_shutdown();
4423        _result
4424    }
4425
4426    /// Similar to "send" but does not shutdown the channel if an error occurs.
4427    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4428        let _result = self.send_raw(result);
4429        self.drop_without_shutdown();
4430        _result
4431    }
4432
4433    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4434        self.control_handle
4435            .inner
4436            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4437                result,
4438                self.tx_id,
4439                0x54d9d4c9cf300a1e,
4440                fidl::encoding::DynamicFlags::empty(),
4441            )
4442    }
4443}
4444
4445#[must_use = "FIDL methods require a response to be sent"]
4446#[derive(Debug)]
4447pub struct DebugStopProfileTasksResponder {
4448    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4449    tx_id: u32,
4450}
4451
4452/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4453/// if the responder is dropped without sending a response, so that the client
4454/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4455impl std::ops::Drop for DebugStopProfileTasksResponder {
4456    fn drop(&mut self) {
4457        self.control_handle.shutdown();
4458        // Safety: drops once, never accessed again
4459        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4460    }
4461}
4462
4463impl fidl::endpoints::Responder for DebugStopProfileTasksResponder {
4464    type ControlHandle = DebugControlHandle;
4465
4466    fn control_handle(&self) -> &DebugControlHandle {
4467        &self.control_handle
4468    }
4469
4470    fn drop_without_shutdown(mut self) {
4471        // Safety: drops once, never accessed again due to mem::forget
4472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4473        // Prevent Drop from running (which would shut down the channel)
4474        std::mem::forget(self);
4475    }
4476}
4477
4478impl DebugStopProfileTasksResponder {
4479    /// Sends a response to the FIDL transaction.
4480    ///
4481    /// Sets the channel to shutdown if an error occurs.
4482    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4483        let _result = self.send_raw(result);
4484        if _result.is_err() {
4485            self.control_handle.shutdown();
4486        }
4487        self.drop_without_shutdown();
4488        _result
4489    }
4490
4491    /// Similar to "send" but does not shutdown the channel if an error occurs.
4492    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4493        let _result = self.send_raw(result);
4494        self.drop_without_shutdown();
4495        _result
4496    }
4497
4498    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4499        self.control_handle
4500            .inner
4501            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4502                result,
4503                self.tx_id,
4504                0x1657b945dd629177,
4505                fidl::encoding::DynamicFlags::empty(),
4506            )
4507    }
4508}
4509
4510#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4511pub struct FileBackedVolumeProviderMarker;
4512
4513impl fidl::endpoints::ProtocolMarker for FileBackedVolumeProviderMarker {
4514    type Proxy = FileBackedVolumeProviderProxy;
4515    type RequestStream = FileBackedVolumeProviderRequestStream;
4516    #[cfg(target_os = "fuchsia")]
4517    type SynchronousProxy = FileBackedVolumeProviderSynchronousProxy;
4518
4519    const DEBUG_NAME: &'static str = "fuchsia.fxfs.FileBackedVolumeProvider";
4520}
4521impl fidl::endpoints::DiscoverableProtocolMarker for FileBackedVolumeProviderMarker {}
4522
4523pub trait FileBackedVolumeProviderProxyInterface: Send + Sync {
4524    fn r#open(
4525        &self,
4526        parent_directory_token: fidl::Handle,
4527        name: &str,
4528        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4529    ) -> Result<(), fidl::Error>;
4530}
4531#[derive(Debug)]
4532#[cfg(target_os = "fuchsia")]
4533pub struct FileBackedVolumeProviderSynchronousProxy {
4534    client: fidl::client::sync::Client,
4535}
4536
4537#[cfg(target_os = "fuchsia")]
4538impl fidl::endpoints::SynchronousProxy for FileBackedVolumeProviderSynchronousProxy {
4539    type Proxy = FileBackedVolumeProviderProxy;
4540    type Protocol = FileBackedVolumeProviderMarker;
4541
4542    fn from_channel(inner: fidl::Channel) -> Self {
4543        Self::new(inner)
4544    }
4545
4546    fn into_channel(self) -> fidl::Channel {
4547        self.client.into_channel()
4548    }
4549
4550    fn as_channel(&self) -> &fidl::Channel {
4551        self.client.as_channel()
4552    }
4553}
4554
4555#[cfg(target_os = "fuchsia")]
4556impl FileBackedVolumeProviderSynchronousProxy {
4557    pub fn new(channel: fidl::Channel) -> Self {
4558        let protocol_name =
4559            <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4560        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4561    }
4562
4563    pub fn into_channel(self) -> fidl::Channel {
4564        self.client.into_channel()
4565    }
4566
4567    /// Waits until an event arrives and returns it. It is safe for other
4568    /// threads to make concurrent requests while waiting for an event.
4569    pub fn wait_for_event(
4570        &self,
4571        deadline: zx::MonotonicInstant,
4572    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
4573        FileBackedVolumeProviderEvent::decode(self.client.wait_for_event(deadline)?)
4574    }
4575
4576    /// Opens a file as a block device and starts serving block requests.
4577    ///
4578    /// `name` must refer to an existing file in the directory represented by
4579    /// `parent_directory_token`.
4580    ///
4581    /// The block size of the device will match the underlying filesystem's block size.  If the
4582    /// file's size is not a multiple of the block size, the apparent size of the device will be
4583    /// rounded down.
4584    ///
4585    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4586    /// directory connection must have the `MODIFY_DIRECTORY` right.
4587    ///
4588    /// Errors will be sent as an epitaph on `server_end`.
4589    pub fn r#open(
4590        &self,
4591        mut parent_directory_token: fidl::Handle,
4592        mut name: &str,
4593        mut server_end: fidl::endpoints::ServerEnd<
4594            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4595        >,
4596    ) -> Result<(), fidl::Error> {
4597        self.client.send::<FileBackedVolumeProviderOpenRequest>(
4598            (parent_directory_token, name, server_end),
4599            0x67120b9fc9f319ee,
4600            fidl::encoding::DynamicFlags::empty(),
4601        )
4602    }
4603}
4604
4605#[cfg(target_os = "fuchsia")]
4606impl From<FileBackedVolumeProviderSynchronousProxy> for zx::Handle {
4607    fn from(value: FileBackedVolumeProviderSynchronousProxy) -> Self {
4608        value.into_channel().into()
4609    }
4610}
4611
4612#[cfg(target_os = "fuchsia")]
4613impl From<fidl::Channel> for FileBackedVolumeProviderSynchronousProxy {
4614    fn from(value: fidl::Channel) -> Self {
4615        Self::new(value)
4616    }
4617}
4618
4619#[cfg(target_os = "fuchsia")]
4620impl fidl::endpoints::FromClient for FileBackedVolumeProviderSynchronousProxy {
4621    type Protocol = FileBackedVolumeProviderMarker;
4622
4623    fn from_client(value: fidl::endpoints::ClientEnd<FileBackedVolumeProviderMarker>) -> Self {
4624        Self::new(value.into_channel())
4625    }
4626}
4627
4628#[derive(Debug, Clone)]
4629pub struct FileBackedVolumeProviderProxy {
4630    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4631}
4632
4633impl fidl::endpoints::Proxy for FileBackedVolumeProviderProxy {
4634    type Protocol = FileBackedVolumeProviderMarker;
4635
4636    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4637        Self::new(inner)
4638    }
4639
4640    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4641        self.client.into_channel().map_err(|client| Self { client })
4642    }
4643
4644    fn as_channel(&self) -> &::fidl::AsyncChannel {
4645        self.client.as_channel()
4646    }
4647}
4648
4649impl FileBackedVolumeProviderProxy {
4650    /// Create a new Proxy for fuchsia.fxfs/FileBackedVolumeProvider.
4651    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4652        let protocol_name =
4653            <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4654        Self { client: fidl::client::Client::new(channel, protocol_name) }
4655    }
4656
4657    /// Get a Stream of events from the remote end of the protocol.
4658    ///
4659    /// # Panics
4660    ///
4661    /// Panics if the event stream was already taken.
4662    pub fn take_event_stream(&self) -> FileBackedVolumeProviderEventStream {
4663        FileBackedVolumeProviderEventStream { event_receiver: self.client.take_event_receiver() }
4664    }
4665
4666    /// Opens a file as a block device and starts serving block requests.
4667    ///
4668    /// `name` must refer to an existing file in the directory represented by
4669    /// `parent_directory_token`.
4670    ///
4671    /// The block size of the device will match the underlying filesystem's block size.  If the
4672    /// file's size is not a multiple of the block size, the apparent size of the device will be
4673    /// rounded down.
4674    ///
4675    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4676    /// directory connection must have the `MODIFY_DIRECTORY` right.
4677    ///
4678    /// Errors will be sent as an epitaph on `server_end`.
4679    pub fn r#open(
4680        &self,
4681        mut parent_directory_token: fidl::Handle,
4682        mut name: &str,
4683        mut server_end: fidl::endpoints::ServerEnd<
4684            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4685        >,
4686    ) -> Result<(), fidl::Error> {
4687        FileBackedVolumeProviderProxyInterface::r#open(
4688            self,
4689            parent_directory_token,
4690            name,
4691            server_end,
4692        )
4693    }
4694}
4695
4696impl FileBackedVolumeProviderProxyInterface for FileBackedVolumeProviderProxy {
4697    fn r#open(
4698        &self,
4699        mut parent_directory_token: fidl::Handle,
4700        mut name: &str,
4701        mut server_end: fidl::endpoints::ServerEnd<
4702            fidl_fuchsia_hardware_block_volume::VolumeMarker,
4703        >,
4704    ) -> Result<(), fidl::Error> {
4705        self.client.send::<FileBackedVolumeProviderOpenRequest>(
4706            (parent_directory_token, name, server_end),
4707            0x67120b9fc9f319ee,
4708            fidl::encoding::DynamicFlags::empty(),
4709        )
4710    }
4711}
4712
4713pub struct FileBackedVolumeProviderEventStream {
4714    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4715}
4716
4717impl std::marker::Unpin for FileBackedVolumeProviderEventStream {}
4718
4719impl futures::stream::FusedStream for FileBackedVolumeProviderEventStream {
4720    fn is_terminated(&self) -> bool {
4721        self.event_receiver.is_terminated()
4722    }
4723}
4724
4725impl futures::Stream for FileBackedVolumeProviderEventStream {
4726    type Item = Result<FileBackedVolumeProviderEvent, fidl::Error>;
4727
4728    fn poll_next(
4729        mut self: std::pin::Pin<&mut Self>,
4730        cx: &mut std::task::Context<'_>,
4731    ) -> std::task::Poll<Option<Self::Item>> {
4732        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4733            &mut self.event_receiver,
4734            cx
4735        )?) {
4736            Some(buf) => std::task::Poll::Ready(Some(FileBackedVolumeProviderEvent::decode(buf))),
4737            None => std::task::Poll::Ready(None),
4738        }
4739    }
4740}
4741
4742#[derive(Debug)]
4743pub enum FileBackedVolumeProviderEvent {}
4744
4745impl FileBackedVolumeProviderEvent {
4746    /// Decodes a message buffer as a [`FileBackedVolumeProviderEvent`].
4747    fn decode(
4748        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4749    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
4750        let (bytes, _handles) = buf.split_mut();
4751        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4752        debug_assert_eq!(tx_header.tx_id, 0);
4753        match tx_header.ordinal {
4754            _ => Err(fidl::Error::UnknownOrdinal {
4755                ordinal: tx_header.ordinal,
4756                protocol_name:
4757                    <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4758            }),
4759        }
4760    }
4761}
4762
4763/// A Stream of incoming requests for fuchsia.fxfs/FileBackedVolumeProvider.
4764pub struct FileBackedVolumeProviderRequestStream {
4765    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4766    is_terminated: bool,
4767}
4768
4769impl std::marker::Unpin for FileBackedVolumeProviderRequestStream {}
4770
4771impl futures::stream::FusedStream for FileBackedVolumeProviderRequestStream {
4772    fn is_terminated(&self) -> bool {
4773        self.is_terminated
4774    }
4775}
4776
4777impl fidl::endpoints::RequestStream for FileBackedVolumeProviderRequestStream {
4778    type Protocol = FileBackedVolumeProviderMarker;
4779    type ControlHandle = FileBackedVolumeProviderControlHandle;
4780
4781    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4782        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4783    }
4784
4785    fn control_handle(&self) -> Self::ControlHandle {
4786        FileBackedVolumeProviderControlHandle { inner: self.inner.clone() }
4787    }
4788
4789    fn into_inner(
4790        self,
4791    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4792    {
4793        (self.inner, self.is_terminated)
4794    }
4795
4796    fn from_inner(
4797        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4798        is_terminated: bool,
4799    ) -> Self {
4800        Self { inner, is_terminated }
4801    }
4802}
4803
4804impl futures::Stream for FileBackedVolumeProviderRequestStream {
4805    type Item = Result<FileBackedVolumeProviderRequest, fidl::Error>;
4806
4807    fn poll_next(
4808        mut self: std::pin::Pin<&mut Self>,
4809        cx: &mut std::task::Context<'_>,
4810    ) -> std::task::Poll<Option<Self::Item>> {
4811        let this = &mut *self;
4812        if this.inner.check_shutdown(cx) {
4813            this.is_terminated = true;
4814            return std::task::Poll::Ready(None);
4815        }
4816        if this.is_terminated {
4817            panic!("polled FileBackedVolumeProviderRequestStream after completion");
4818        }
4819        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4820            |bytes, handles| {
4821                match this.inner.channel().read_etc(cx, bytes, handles) {
4822                    std::task::Poll::Ready(Ok(())) => {}
4823                    std::task::Poll::Pending => return std::task::Poll::Pending,
4824                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4825                        this.is_terminated = true;
4826                        return std::task::Poll::Ready(None);
4827                    }
4828                    std::task::Poll::Ready(Err(e)) => {
4829                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4830                            e.into(),
4831                        ))))
4832                    }
4833                }
4834
4835                // A message has been received from the channel
4836                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4837
4838                std::task::Poll::Ready(Some(match header.ordinal {
4839                0x67120b9fc9f319ee => {
4840                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4841                    let mut req = fidl::new_empty!(FileBackedVolumeProviderOpenRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4842                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FileBackedVolumeProviderOpenRequest>(&header, _body_bytes, handles, &mut req)?;
4843                    let control_handle = FileBackedVolumeProviderControlHandle {
4844                        inner: this.inner.clone(),
4845                    };
4846                    Ok(FileBackedVolumeProviderRequest::Open {parent_directory_token: req.parent_directory_token,
4847name: req.name,
4848server_end: req.server_end,
4849
4850                        control_handle,
4851                    })
4852                }
4853                _ => Err(fidl::Error::UnknownOrdinal {
4854                    ordinal: header.ordinal,
4855                    protocol_name: <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4856                }),
4857            }))
4858            },
4859        )
4860    }
4861}
4862
4863/// A protocol to serve the Volume protocol on a file-backed device.
4864#[derive(Debug)]
4865pub enum FileBackedVolumeProviderRequest {
4866    /// Opens a file as a block device and starts serving block requests.
4867    ///
4868    /// `name` must refer to an existing file in the directory represented by
4869    /// `parent_directory_token`.
4870    ///
4871    /// The block size of the device will match the underlying filesystem's block size.  If the
4872    /// file's size is not a multiple of the block size, the apparent size of the device will be
4873    /// rounded down.
4874    ///
4875    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4876    /// directory connection must have the `MODIFY_DIRECTORY` right.
4877    ///
4878    /// Errors will be sent as an epitaph on `server_end`.
4879    Open {
4880        parent_directory_token: fidl::Handle,
4881        name: String,
4882        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4883        control_handle: FileBackedVolumeProviderControlHandle,
4884    },
4885}
4886
4887impl FileBackedVolumeProviderRequest {
4888    #[allow(irrefutable_let_patterns)]
4889    pub fn into_open(
4890        self,
4891    ) -> Option<(
4892        fidl::Handle,
4893        String,
4894        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
4895        FileBackedVolumeProviderControlHandle,
4896    )> {
4897        if let FileBackedVolumeProviderRequest::Open {
4898            parent_directory_token,
4899            name,
4900            server_end,
4901            control_handle,
4902        } = self
4903        {
4904            Some((parent_directory_token, name, server_end, control_handle))
4905        } else {
4906            None
4907        }
4908    }
4909
4910    /// Name of the method defined in FIDL
4911    pub fn method_name(&self) -> &'static str {
4912        match *self {
4913            FileBackedVolumeProviderRequest::Open { .. } => "open",
4914        }
4915    }
4916}
4917
4918#[derive(Debug, Clone)]
4919pub struct FileBackedVolumeProviderControlHandle {
4920    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4921}
4922
4923impl fidl::endpoints::ControlHandle for FileBackedVolumeProviderControlHandle {
4924    fn shutdown(&self) {
4925        self.inner.shutdown()
4926    }
4927    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4928        self.inner.shutdown_with_epitaph(status)
4929    }
4930
4931    fn is_closed(&self) -> bool {
4932        self.inner.channel().is_closed()
4933    }
4934    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4935        self.inner.channel().on_closed()
4936    }
4937
4938    #[cfg(target_os = "fuchsia")]
4939    fn signal_peer(
4940        &self,
4941        clear_mask: zx::Signals,
4942        set_mask: zx::Signals,
4943    ) -> Result<(), zx_status::Status> {
4944        use fidl::Peered;
4945        self.inner.channel().signal_peer(clear_mask, set_mask)
4946    }
4947}
4948
4949impl FileBackedVolumeProviderControlHandle {}
4950
4951#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4952pub struct ProjectIdMarker;
4953
4954impl fidl::endpoints::ProtocolMarker for ProjectIdMarker {
4955    type Proxy = ProjectIdProxy;
4956    type RequestStream = ProjectIdRequestStream;
4957    #[cfg(target_os = "fuchsia")]
4958    type SynchronousProxy = ProjectIdSynchronousProxy;
4959
4960    const DEBUG_NAME: &'static str = "fuchsia.fxfs.ProjectId";
4961}
4962impl fidl::endpoints::DiscoverableProtocolMarker for ProjectIdMarker {}
4963pub type ProjectIdSetLimitResult = Result<(), i32>;
4964pub type ProjectIdClearResult = Result<(), i32>;
4965pub type ProjectIdSetForNodeResult = Result<(), i32>;
4966pub type ProjectIdGetForNodeResult = Result<u64, i32>;
4967pub type ProjectIdClearForNodeResult = Result<(), i32>;
4968pub type ProjectIdListResult = Result<(Vec<u64>, Option<Box<ProjectIterToken>>), i32>;
4969pub type ProjectIdInfoResult = Result<(BytesAndNodes, BytesAndNodes), i32>;
4970
4971pub trait ProjectIdProxyInterface: Send + Sync {
4972    type SetLimitResponseFut: std::future::Future<Output = Result<ProjectIdSetLimitResult, fidl::Error>>
4973        + Send;
4974    fn r#set_limit(&self, project_id: u64, bytes: u64, nodes: u64) -> Self::SetLimitResponseFut;
4975    type ClearResponseFut: std::future::Future<Output = Result<ProjectIdClearResult, fidl::Error>>
4976        + Send;
4977    fn r#clear(&self, project_id: u64) -> Self::ClearResponseFut;
4978    type SetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdSetForNodeResult, fidl::Error>>
4979        + Send;
4980    fn r#set_for_node(&self, node_id: u64, project_id: u64) -> Self::SetForNodeResponseFut;
4981    type GetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdGetForNodeResult, fidl::Error>>
4982        + Send;
4983    fn r#get_for_node(&self, node_id: u64) -> Self::GetForNodeResponseFut;
4984    type ClearForNodeResponseFut: std::future::Future<Output = Result<ProjectIdClearForNodeResult, fidl::Error>>
4985        + Send;
4986    fn r#clear_for_node(&self, node_id: u64) -> Self::ClearForNodeResponseFut;
4987    type ListResponseFut: std::future::Future<Output = Result<ProjectIdListResult, fidl::Error>>
4988        + Send;
4989    fn r#list(&self, token: Option<&ProjectIterToken>) -> Self::ListResponseFut;
4990    type InfoResponseFut: std::future::Future<Output = Result<ProjectIdInfoResult, fidl::Error>>
4991        + Send;
4992    fn r#info(&self, project_id: u64) -> Self::InfoResponseFut;
4993}
4994#[derive(Debug)]
4995#[cfg(target_os = "fuchsia")]
4996pub struct ProjectIdSynchronousProxy {
4997    client: fidl::client::sync::Client,
4998}
4999
5000#[cfg(target_os = "fuchsia")]
5001impl fidl::endpoints::SynchronousProxy for ProjectIdSynchronousProxy {
5002    type Proxy = ProjectIdProxy;
5003    type Protocol = ProjectIdMarker;
5004
5005    fn from_channel(inner: fidl::Channel) -> Self {
5006        Self::new(inner)
5007    }
5008
5009    fn into_channel(self) -> fidl::Channel {
5010        self.client.into_channel()
5011    }
5012
5013    fn as_channel(&self) -> &fidl::Channel {
5014        self.client.as_channel()
5015    }
5016}
5017
5018#[cfg(target_os = "fuchsia")]
5019impl ProjectIdSynchronousProxy {
5020    pub fn new(channel: fidl::Channel) -> Self {
5021        let protocol_name = <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5022        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5023    }
5024
5025    pub fn into_channel(self) -> fidl::Channel {
5026        self.client.into_channel()
5027    }
5028
5029    /// Waits until an event arrives and returns it. It is safe for other
5030    /// threads to make concurrent requests while waiting for an event.
5031    pub fn wait_for_event(
5032        &self,
5033        deadline: zx::MonotonicInstant,
5034    ) -> Result<ProjectIdEvent, fidl::Error> {
5035        ProjectIdEvent::decode(self.client.wait_for_event(deadline)?)
5036    }
5037
5038    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5039    /// current usage is accepted but may in the future prevent further increases. Returns
5040    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5041    pub fn r#set_limit(
5042        &self,
5043        mut project_id: u64,
5044        mut bytes: u64,
5045        mut nodes: u64,
5046        ___deadline: zx::MonotonicInstant,
5047    ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
5048        let _response = self.client.send_query::<
5049            ProjectIdSetLimitRequest,
5050            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5051        >(
5052            (project_id, bytes, nodes,),
5053            0x20b0fc1e0413876f,
5054            fidl::encoding::DynamicFlags::empty(),
5055            ___deadline,
5056        )?;
5057        Ok(_response.map(|x| x))
5058    }
5059
5060    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5061    /// currently tracked. It will succeed even if the project is still in use more by one or more
5062    /// nodes.
5063    pub fn r#clear(
5064        &self,
5065        mut project_id: u64,
5066        ___deadline: zx::MonotonicInstant,
5067    ) -> Result<ProjectIdClearResult, fidl::Error> {
5068        let _response = self.client.send_query::<
5069            ProjectIdClearRequest,
5070            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5071        >(
5072            (project_id,),
5073            0x165b5f1e707863c1,
5074            fidl::encoding::DynamicFlags::empty(),
5075            ___deadline,
5076        )?;
5077        Ok(_response.map(|x| x))
5078    }
5079
5080    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5081    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5082    pub fn r#set_for_node(
5083        &self,
5084        mut node_id: u64,
5085        mut project_id: u64,
5086        ___deadline: zx::MonotonicInstant,
5087    ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
5088        let _response = self.client.send_query::<
5089            ProjectIdSetForNodeRequest,
5090            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5091        >(
5092            (node_id, project_id,),
5093            0x4d7a8442dc58324c,
5094            fidl::encoding::DynamicFlags::empty(),
5095            ___deadline,
5096        )?;
5097        Ok(_response.map(|x| x))
5098    }
5099
5100    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5101    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5102    /// currently applied.
5103    pub fn r#get_for_node(
5104        &self,
5105        mut node_id: u64,
5106        ___deadline: zx::MonotonicInstant,
5107    ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
5108        let _response = self.client.send_query::<
5109            ProjectIdGetForNodeRequest,
5110            fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
5111        >(
5112            (node_id,),
5113            0x644073bdf2542573,
5114            fidl::encoding::DynamicFlags::empty(),
5115            ___deadline,
5116        )?;
5117        Ok(_response.map(|x| x.project_id))
5118    }
5119
5120    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5121    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5122    /// have no project id applied to it.
5123    pub fn r#clear_for_node(
5124        &self,
5125        mut node_id: u64,
5126        ___deadline: zx::MonotonicInstant,
5127    ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
5128        let _response = self.client.send_query::<
5129            ProjectIdClearForNodeRequest,
5130            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5131        >(
5132            (node_id,),
5133            0x3f2ca287bbfe6a62,
5134            fidl::encoding::DynamicFlags::empty(),
5135            ___deadline,
5136        )?;
5137        Ok(_response.map(|x| x))
5138    }
5139
5140    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5141    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5142    /// previously provided `next_token` the iteration continues where it left off. If there are
5143    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5144    pub fn r#list(
5145        &self,
5146        mut token: Option<&ProjectIterToken>,
5147        ___deadline: zx::MonotonicInstant,
5148    ) -> Result<ProjectIdListResult, fidl::Error> {
5149        let _response = self.client.send_query::<
5150            ProjectIdListRequest,
5151            fidl::encoding::ResultType<ProjectIdListResponse, i32>,
5152        >(
5153            (token,),
5154            0x5505f95a36d522cc,
5155            fidl::encoding::DynamicFlags::empty(),
5156            ___deadline,
5157        )?;
5158        Ok(_response.map(|x| (x.entries, x.next_token)))
5159    }
5160
5161    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5162    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5163    pub fn r#info(
5164        &self,
5165        mut project_id: u64,
5166        ___deadline: zx::MonotonicInstant,
5167    ) -> Result<ProjectIdInfoResult, fidl::Error> {
5168        let _response = self.client.send_query::<
5169            ProjectIdInfoRequest,
5170            fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
5171        >(
5172            (project_id,),
5173            0x51b47743c9e2d1ab,
5174            fidl::encoding::DynamicFlags::empty(),
5175            ___deadline,
5176        )?;
5177        Ok(_response.map(|x| (x.limit, x.usage)))
5178    }
5179}
5180
5181#[cfg(target_os = "fuchsia")]
5182impl From<ProjectIdSynchronousProxy> for zx::Handle {
5183    fn from(value: ProjectIdSynchronousProxy) -> Self {
5184        value.into_channel().into()
5185    }
5186}
5187
5188#[cfg(target_os = "fuchsia")]
5189impl From<fidl::Channel> for ProjectIdSynchronousProxy {
5190    fn from(value: fidl::Channel) -> Self {
5191        Self::new(value)
5192    }
5193}
5194
5195#[cfg(target_os = "fuchsia")]
5196impl fidl::endpoints::FromClient for ProjectIdSynchronousProxy {
5197    type Protocol = ProjectIdMarker;
5198
5199    fn from_client(value: fidl::endpoints::ClientEnd<ProjectIdMarker>) -> Self {
5200        Self::new(value.into_channel())
5201    }
5202}
5203
5204#[derive(Debug, Clone)]
5205pub struct ProjectIdProxy {
5206    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5207}
5208
5209impl fidl::endpoints::Proxy for ProjectIdProxy {
5210    type Protocol = ProjectIdMarker;
5211
5212    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5213        Self::new(inner)
5214    }
5215
5216    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5217        self.client.into_channel().map_err(|client| Self { client })
5218    }
5219
5220    fn as_channel(&self) -> &::fidl::AsyncChannel {
5221        self.client.as_channel()
5222    }
5223}
5224
5225impl ProjectIdProxy {
5226    /// Create a new Proxy for fuchsia.fxfs/ProjectId.
5227    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5228        let protocol_name = <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5229        Self { client: fidl::client::Client::new(channel, protocol_name) }
5230    }
5231
5232    /// Get a Stream of events from the remote end of the protocol.
5233    ///
5234    /// # Panics
5235    ///
5236    /// Panics if the event stream was already taken.
5237    pub fn take_event_stream(&self) -> ProjectIdEventStream {
5238        ProjectIdEventStream { event_receiver: self.client.take_event_receiver() }
5239    }
5240
5241    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5242    /// current usage is accepted but may in the future prevent further increases. Returns
5243    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5244    pub fn r#set_limit(
5245        &self,
5246        mut project_id: u64,
5247        mut bytes: u64,
5248        mut nodes: u64,
5249    ) -> fidl::client::QueryResponseFut<
5250        ProjectIdSetLimitResult,
5251        fidl::encoding::DefaultFuchsiaResourceDialect,
5252    > {
5253        ProjectIdProxyInterface::r#set_limit(self, project_id, bytes, nodes)
5254    }
5255
5256    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5257    /// currently tracked. It will succeed even if the project is still in use more by one or more
5258    /// nodes.
5259    pub fn r#clear(
5260        &self,
5261        mut project_id: u64,
5262    ) -> fidl::client::QueryResponseFut<
5263        ProjectIdClearResult,
5264        fidl::encoding::DefaultFuchsiaResourceDialect,
5265    > {
5266        ProjectIdProxyInterface::r#clear(self, project_id)
5267    }
5268
5269    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5270    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5271    pub fn r#set_for_node(
5272        &self,
5273        mut node_id: u64,
5274        mut project_id: u64,
5275    ) -> fidl::client::QueryResponseFut<
5276        ProjectIdSetForNodeResult,
5277        fidl::encoding::DefaultFuchsiaResourceDialect,
5278    > {
5279        ProjectIdProxyInterface::r#set_for_node(self, node_id, project_id)
5280    }
5281
5282    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5283    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5284    /// currently applied.
5285    pub fn r#get_for_node(
5286        &self,
5287        mut node_id: u64,
5288    ) -> fidl::client::QueryResponseFut<
5289        ProjectIdGetForNodeResult,
5290        fidl::encoding::DefaultFuchsiaResourceDialect,
5291    > {
5292        ProjectIdProxyInterface::r#get_for_node(self, node_id)
5293    }
5294
5295    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5296    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5297    /// have no project id applied to it.
5298    pub fn r#clear_for_node(
5299        &self,
5300        mut node_id: u64,
5301    ) -> fidl::client::QueryResponseFut<
5302        ProjectIdClearForNodeResult,
5303        fidl::encoding::DefaultFuchsiaResourceDialect,
5304    > {
5305        ProjectIdProxyInterface::r#clear_for_node(self, node_id)
5306    }
5307
5308    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5309    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5310    /// previously provided `next_token` the iteration continues where it left off. If there are
5311    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5312    pub fn r#list(
5313        &self,
5314        mut token: Option<&ProjectIterToken>,
5315    ) -> fidl::client::QueryResponseFut<
5316        ProjectIdListResult,
5317        fidl::encoding::DefaultFuchsiaResourceDialect,
5318    > {
5319        ProjectIdProxyInterface::r#list(self, token)
5320    }
5321
5322    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5323    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5324    pub fn r#info(
5325        &self,
5326        mut project_id: u64,
5327    ) -> fidl::client::QueryResponseFut<
5328        ProjectIdInfoResult,
5329        fidl::encoding::DefaultFuchsiaResourceDialect,
5330    > {
5331        ProjectIdProxyInterface::r#info(self, project_id)
5332    }
5333}
5334
5335impl ProjectIdProxyInterface for ProjectIdProxy {
5336    type SetLimitResponseFut = fidl::client::QueryResponseFut<
5337        ProjectIdSetLimitResult,
5338        fidl::encoding::DefaultFuchsiaResourceDialect,
5339    >;
5340    fn r#set_limit(
5341        &self,
5342        mut project_id: u64,
5343        mut bytes: u64,
5344        mut nodes: u64,
5345    ) -> Self::SetLimitResponseFut {
5346        fn _decode(
5347            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5348        ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
5349            let _response = fidl::client::decode_transaction_body::<
5350                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5351                fidl::encoding::DefaultFuchsiaResourceDialect,
5352                0x20b0fc1e0413876f,
5353            >(_buf?)?;
5354            Ok(_response.map(|x| x))
5355        }
5356        self.client.send_query_and_decode::<ProjectIdSetLimitRequest, ProjectIdSetLimitResult>(
5357            (project_id, bytes, nodes),
5358            0x20b0fc1e0413876f,
5359            fidl::encoding::DynamicFlags::empty(),
5360            _decode,
5361        )
5362    }
5363
5364    type ClearResponseFut = fidl::client::QueryResponseFut<
5365        ProjectIdClearResult,
5366        fidl::encoding::DefaultFuchsiaResourceDialect,
5367    >;
5368    fn r#clear(&self, mut project_id: u64) -> Self::ClearResponseFut {
5369        fn _decode(
5370            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5371        ) -> Result<ProjectIdClearResult, fidl::Error> {
5372            let _response = fidl::client::decode_transaction_body::<
5373                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5374                fidl::encoding::DefaultFuchsiaResourceDialect,
5375                0x165b5f1e707863c1,
5376            >(_buf?)?;
5377            Ok(_response.map(|x| x))
5378        }
5379        self.client.send_query_and_decode::<ProjectIdClearRequest, ProjectIdClearResult>(
5380            (project_id,),
5381            0x165b5f1e707863c1,
5382            fidl::encoding::DynamicFlags::empty(),
5383            _decode,
5384        )
5385    }
5386
5387    type SetForNodeResponseFut = fidl::client::QueryResponseFut<
5388        ProjectIdSetForNodeResult,
5389        fidl::encoding::DefaultFuchsiaResourceDialect,
5390    >;
5391    fn r#set_for_node(&self, mut node_id: u64, mut project_id: u64) -> Self::SetForNodeResponseFut {
5392        fn _decode(
5393            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5394        ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
5395            let _response = fidl::client::decode_transaction_body::<
5396                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5397                fidl::encoding::DefaultFuchsiaResourceDialect,
5398                0x4d7a8442dc58324c,
5399            >(_buf?)?;
5400            Ok(_response.map(|x| x))
5401        }
5402        self.client.send_query_and_decode::<ProjectIdSetForNodeRequest, ProjectIdSetForNodeResult>(
5403            (node_id, project_id),
5404            0x4d7a8442dc58324c,
5405            fidl::encoding::DynamicFlags::empty(),
5406            _decode,
5407        )
5408    }
5409
5410    type GetForNodeResponseFut = fidl::client::QueryResponseFut<
5411        ProjectIdGetForNodeResult,
5412        fidl::encoding::DefaultFuchsiaResourceDialect,
5413    >;
5414    fn r#get_for_node(&self, mut node_id: u64) -> Self::GetForNodeResponseFut {
5415        fn _decode(
5416            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5417        ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
5418            let _response = fidl::client::decode_transaction_body::<
5419                fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
5420                fidl::encoding::DefaultFuchsiaResourceDialect,
5421                0x644073bdf2542573,
5422            >(_buf?)?;
5423            Ok(_response.map(|x| x.project_id))
5424        }
5425        self.client.send_query_and_decode::<ProjectIdGetForNodeRequest, ProjectIdGetForNodeResult>(
5426            (node_id,),
5427            0x644073bdf2542573,
5428            fidl::encoding::DynamicFlags::empty(),
5429            _decode,
5430        )
5431    }
5432
5433    type ClearForNodeResponseFut = fidl::client::QueryResponseFut<
5434        ProjectIdClearForNodeResult,
5435        fidl::encoding::DefaultFuchsiaResourceDialect,
5436    >;
5437    fn r#clear_for_node(&self, mut node_id: u64) -> Self::ClearForNodeResponseFut {
5438        fn _decode(
5439            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5440        ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
5441            let _response = fidl::client::decode_transaction_body::<
5442                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5443                fidl::encoding::DefaultFuchsiaResourceDialect,
5444                0x3f2ca287bbfe6a62,
5445            >(_buf?)?;
5446            Ok(_response.map(|x| x))
5447        }
5448        self.client
5449            .send_query_and_decode::<ProjectIdClearForNodeRequest, ProjectIdClearForNodeResult>(
5450                (node_id,),
5451                0x3f2ca287bbfe6a62,
5452                fidl::encoding::DynamicFlags::empty(),
5453                _decode,
5454            )
5455    }
5456
5457    type ListResponseFut = fidl::client::QueryResponseFut<
5458        ProjectIdListResult,
5459        fidl::encoding::DefaultFuchsiaResourceDialect,
5460    >;
5461    fn r#list(&self, mut token: Option<&ProjectIterToken>) -> Self::ListResponseFut {
5462        fn _decode(
5463            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5464        ) -> Result<ProjectIdListResult, fidl::Error> {
5465            let _response = fidl::client::decode_transaction_body::<
5466                fidl::encoding::ResultType<ProjectIdListResponse, i32>,
5467                fidl::encoding::DefaultFuchsiaResourceDialect,
5468                0x5505f95a36d522cc,
5469            >(_buf?)?;
5470            Ok(_response.map(|x| (x.entries, x.next_token)))
5471        }
5472        self.client.send_query_and_decode::<ProjectIdListRequest, ProjectIdListResult>(
5473            (token,),
5474            0x5505f95a36d522cc,
5475            fidl::encoding::DynamicFlags::empty(),
5476            _decode,
5477        )
5478    }
5479
5480    type InfoResponseFut = fidl::client::QueryResponseFut<
5481        ProjectIdInfoResult,
5482        fidl::encoding::DefaultFuchsiaResourceDialect,
5483    >;
5484    fn r#info(&self, mut project_id: u64) -> Self::InfoResponseFut {
5485        fn _decode(
5486            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5487        ) -> Result<ProjectIdInfoResult, fidl::Error> {
5488            let _response = fidl::client::decode_transaction_body::<
5489                fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
5490                fidl::encoding::DefaultFuchsiaResourceDialect,
5491                0x51b47743c9e2d1ab,
5492            >(_buf?)?;
5493            Ok(_response.map(|x| (x.limit, x.usage)))
5494        }
5495        self.client.send_query_and_decode::<ProjectIdInfoRequest, ProjectIdInfoResult>(
5496            (project_id,),
5497            0x51b47743c9e2d1ab,
5498            fidl::encoding::DynamicFlags::empty(),
5499            _decode,
5500        )
5501    }
5502}
5503
5504pub struct ProjectIdEventStream {
5505    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5506}
5507
5508impl std::marker::Unpin for ProjectIdEventStream {}
5509
5510impl futures::stream::FusedStream for ProjectIdEventStream {
5511    fn is_terminated(&self) -> bool {
5512        self.event_receiver.is_terminated()
5513    }
5514}
5515
5516impl futures::Stream for ProjectIdEventStream {
5517    type Item = Result<ProjectIdEvent, fidl::Error>;
5518
5519    fn poll_next(
5520        mut self: std::pin::Pin<&mut Self>,
5521        cx: &mut std::task::Context<'_>,
5522    ) -> std::task::Poll<Option<Self::Item>> {
5523        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5524            &mut self.event_receiver,
5525            cx
5526        )?) {
5527            Some(buf) => std::task::Poll::Ready(Some(ProjectIdEvent::decode(buf))),
5528            None => std::task::Poll::Ready(None),
5529        }
5530    }
5531}
5532
5533#[derive(Debug)]
5534pub enum ProjectIdEvent {}
5535
5536impl ProjectIdEvent {
5537    /// Decodes a message buffer as a [`ProjectIdEvent`].
5538    fn decode(
5539        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5540    ) -> Result<ProjectIdEvent, fidl::Error> {
5541        let (bytes, _handles) = buf.split_mut();
5542        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5543        debug_assert_eq!(tx_header.tx_id, 0);
5544        match tx_header.ordinal {
5545            _ => Err(fidl::Error::UnknownOrdinal {
5546                ordinal: tx_header.ordinal,
5547                protocol_name: <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5548            }),
5549        }
5550    }
5551}
5552
5553/// A Stream of incoming requests for fuchsia.fxfs/ProjectId.
5554pub struct ProjectIdRequestStream {
5555    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5556    is_terminated: bool,
5557}
5558
5559impl std::marker::Unpin for ProjectIdRequestStream {}
5560
5561impl futures::stream::FusedStream for ProjectIdRequestStream {
5562    fn is_terminated(&self) -> bool {
5563        self.is_terminated
5564    }
5565}
5566
5567impl fidl::endpoints::RequestStream for ProjectIdRequestStream {
5568    type Protocol = ProjectIdMarker;
5569    type ControlHandle = ProjectIdControlHandle;
5570
5571    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5572        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5573    }
5574
5575    fn control_handle(&self) -> Self::ControlHandle {
5576        ProjectIdControlHandle { inner: self.inner.clone() }
5577    }
5578
5579    fn into_inner(
5580        self,
5581    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5582    {
5583        (self.inner, self.is_terminated)
5584    }
5585
5586    fn from_inner(
5587        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5588        is_terminated: bool,
5589    ) -> Self {
5590        Self { inner, is_terminated }
5591    }
5592}
5593
5594impl futures::Stream for ProjectIdRequestStream {
5595    type Item = Result<ProjectIdRequest, fidl::Error>;
5596
5597    fn poll_next(
5598        mut self: std::pin::Pin<&mut Self>,
5599        cx: &mut std::task::Context<'_>,
5600    ) -> std::task::Poll<Option<Self::Item>> {
5601        let this = &mut *self;
5602        if this.inner.check_shutdown(cx) {
5603            this.is_terminated = true;
5604            return std::task::Poll::Ready(None);
5605        }
5606        if this.is_terminated {
5607            panic!("polled ProjectIdRequestStream after completion");
5608        }
5609        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5610            |bytes, handles| {
5611                match this.inner.channel().read_etc(cx, bytes, handles) {
5612                    std::task::Poll::Ready(Ok(())) => {}
5613                    std::task::Poll::Pending => return std::task::Poll::Pending,
5614                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5615                        this.is_terminated = true;
5616                        return std::task::Poll::Ready(None);
5617                    }
5618                    std::task::Poll::Ready(Err(e)) => {
5619                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5620                            e.into(),
5621                        ))))
5622                    }
5623                }
5624
5625                // A message has been received from the channel
5626                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5627
5628                std::task::Poll::Ready(Some(match header.ordinal {
5629                    0x20b0fc1e0413876f => {
5630                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5631                        let mut req = fidl::new_empty!(
5632                            ProjectIdSetLimitRequest,
5633                            fidl::encoding::DefaultFuchsiaResourceDialect
5634                        );
5635                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetLimitRequest>(&header, _body_bytes, handles, &mut req)?;
5636                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5637                        Ok(ProjectIdRequest::SetLimit {
5638                            project_id: req.project_id,
5639                            bytes: req.bytes,
5640                            nodes: req.nodes,
5641
5642                            responder: ProjectIdSetLimitResponder {
5643                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5644                                tx_id: header.tx_id,
5645                            },
5646                        })
5647                    }
5648                    0x165b5f1e707863c1 => {
5649                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5650                        let mut req = fidl::new_empty!(
5651                            ProjectIdClearRequest,
5652                            fidl::encoding::DefaultFuchsiaResourceDialect
5653                        );
5654                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearRequest>(&header, _body_bytes, handles, &mut req)?;
5655                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5656                        Ok(ProjectIdRequest::Clear {
5657                            project_id: req.project_id,
5658
5659                            responder: ProjectIdClearResponder {
5660                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5661                                tx_id: header.tx_id,
5662                            },
5663                        })
5664                    }
5665                    0x4d7a8442dc58324c => {
5666                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5667                        let mut req = fidl::new_empty!(
5668                            ProjectIdSetForNodeRequest,
5669                            fidl::encoding::DefaultFuchsiaResourceDialect
5670                        );
5671                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5672                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5673                        Ok(ProjectIdRequest::SetForNode {
5674                            node_id: req.node_id,
5675                            project_id: req.project_id,
5676
5677                            responder: ProjectIdSetForNodeResponder {
5678                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5679                                tx_id: header.tx_id,
5680                            },
5681                        })
5682                    }
5683                    0x644073bdf2542573 => {
5684                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5685                        let mut req = fidl::new_empty!(
5686                            ProjectIdGetForNodeRequest,
5687                            fidl::encoding::DefaultFuchsiaResourceDialect
5688                        );
5689                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdGetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5690                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5691                        Ok(ProjectIdRequest::GetForNode {
5692                            node_id: req.node_id,
5693
5694                            responder: ProjectIdGetForNodeResponder {
5695                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5696                                tx_id: header.tx_id,
5697                            },
5698                        })
5699                    }
5700                    0x3f2ca287bbfe6a62 => {
5701                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5702                        let mut req = fidl::new_empty!(
5703                            ProjectIdClearForNodeRequest,
5704                            fidl::encoding::DefaultFuchsiaResourceDialect
5705                        );
5706                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5707                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5708                        Ok(ProjectIdRequest::ClearForNode {
5709                            node_id: req.node_id,
5710
5711                            responder: ProjectIdClearForNodeResponder {
5712                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5713                                tx_id: header.tx_id,
5714                            },
5715                        })
5716                    }
5717                    0x5505f95a36d522cc => {
5718                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5719                        let mut req = fidl::new_empty!(
5720                            ProjectIdListRequest,
5721                            fidl::encoding::DefaultFuchsiaResourceDialect
5722                        );
5723                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdListRequest>(&header, _body_bytes, handles, &mut req)?;
5724                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5725                        Ok(ProjectIdRequest::List {
5726                            token: req.token,
5727
5728                            responder: ProjectIdListResponder {
5729                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5730                                tx_id: header.tx_id,
5731                            },
5732                        })
5733                    }
5734                    0x51b47743c9e2d1ab => {
5735                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5736                        let mut req = fidl::new_empty!(
5737                            ProjectIdInfoRequest,
5738                            fidl::encoding::DefaultFuchsiaResourceDialect
5739                        );
5740                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5741                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5742                        Ok(ProjectIdRequest::Info {
5743                            project_id: req.project_id,
5744
5745                            responder: ProjectIdInfoResponder {
5746                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5747                                tx_id: header.tx_id,
5748                            },
5749                        })
5750                    }
5751                    _ => Err(fidl::Error::UnknownOrdinal {
5752                        ordinal: header.ordinal,
5753                        protocol_name:
5754                            <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5755                    }),
5756                }))
5757            },
5758        )
5759    }
5760}
5761
5762#[derive(Debug)]
5763pub enum ProjectIdRequest {
5764    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5765    /// current usage is accepted but may in the future prevent further increases. Returns
5766    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5767    SetLimit { project_id: u64, bytes: u64, nodes: u64, responder: ProjectIdSetLimitResponder },
5768    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5769    /// currently tracked. It will succeed even if the project is still in use more by one or more
5770    /// nodes.
5771    Clear { project_id: u64, responder: ProjectIdClearResponder },
5772    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5773    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5774    SetForNode { node_id: u64, project_id: u64, responder: ProjectIdSetForNodeResponder },
5775    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5776    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5777    /// currently applied.
5778    GetForNode { node_id: u64, responder: ProjectIdGetForNodeResponder },
5779    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5780    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5781    /// have no project id applied to it.
5782    ClearForNode { node_id: u64, responder: ProjectIdClearForNodeResponder },
5783    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5784    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5785    /// previously provided `next_token` the iteration continues where it left off. If there are
5786    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5787    List { token: Option<Box<ProjectIterToken>>, responder: ProjectIdListResponder },
5788    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5789    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5790    Info { project_id: u64, responder: ProjectIdInfoResponder },
5791}
5792
5793impl ProjectIdRequest {
5794    #[allow(irrefutable_let_patterns)]
5795    pub fn into_set_limit(self) -> Option<(u64, u64, u64, ProjectIdSetLimitResponder)> {
5796        if let ProjectIdRequest::SetLimit { project_id, bytes, nodes, responder } = self {
5797            Some((project_id, bytes, nodes, responder))
5798        } else {
5799            None
5800        }
5801    }
5802
5803    #[allow(irrefutable_let_patterns)]
5804    pub fn into_clear(self) -> Option<(u64, ProjectIdClearResponder)> {
5805        if let ProjectIdRequest::Clear { project_id, responder } = self {
5806            Some((project_id, responder))
5807        } else {
5808            None
5809        }
5810    }
5811
5812    #[allow(irrefutable_let_patterns)]
5813    pub fn into_set_for_node(self) -> Option<(u64, u64, ProjectIdSetForNodeResponder)> {
5814        if let ProjectIdRequest::SetForNode { node_id, project_id, responder } = self {
5815            Some((node_id, project_id, responder))
5816        } else {
5817            None
5818        }
5819    }
5820
5821    #[allow(irrefutable_let_patterns)]
5822    pub fn into_get_for_node(self) -> Option<(u64, ProjectIdGetForNodeResponder)> {
5823        if let ProjectIdRequest::GetForNode { node_id, responder } = self {
5824            Some((node_id, responder))
5825        } else {
5826            None
5827        }
5828    }
5829
5830    #[allow(irrefutable_let_patterns)]
5831    pub fn into_clear_for_node(self) -> Option<(u64, ProjectIdClearForNodeResponder)> {
5832        if let ProjectIdRequest::ClearForNode { node_id, responder } = self {
5833            Some((node_id, responder))
5834        } else {
5835            None
5836        }
5837    }
5838
5839    #[allow(irrefutable_let_patterns)]
5840    pub fn into_list(self) -> Option<(Option<Box<ProjectIterToken>>, ProjectIdListResponder)> {
5841        if let ProjectIdRequest::List { token, responder } = self {
5842            Some((token, responder))
5843        } else {
5844            None
5845        }
5846    }
5847
5848    #[allow(irrefutable_let_patterns)]
5849    pub fn into_info(self) -> Option<(u64, ProjectIdInfoResponder)> {
5850        if let ProjectIdRequest::Info { project_id, responder } = self {
5851            Some((project_id, responder))
5852        } else {
5853            None
5854        }
5855    }
5856
5857    /// Name of the method defined in FIDL
5858    pub fn method_name(&self) -> &'static str {
5859        match *self {
5860            ProjectIdRequest::SetLimit { .. } => "set_limit",
5861            ProjectIdRequest::Clear { .. } => "clear",
5862            ProjectIdRequest::SetForNode { .. } => "set_for_node",
5863            ProjectIdRequest::GetForNode { .. } => "get_for_node",
5864            ProjectIdRequest::ClearForNode { .. } => "clear_for_node",
5865            ProjectIdRequest::List { .. } => "list",
5866            ProjectIdRequest::Info { .. } => "info",
5867        }
5868    }
5869}
5870
5871#[derive(Debug, Clone)]
5872pub struct ProjectIdControlHandle {
5873    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5874}
5875
5876impl fidl::endpoints::ControlHandle for ProjectIdControlHandle {
5877    fn shutdown(&self) {
5878        self.inner.shutdown()
5879    }
5880    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5881        self.inner.shutdown_with_epitaph(status)
5882    }
5883
5884    fn is_closed(&self) -> bool {
5885        self.inner.channel().is_closed()
5886    }
5887    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5888        self.inner.channel().on_closed()
5889    }
5890
5891    #[cfg(target_os = "fuchsia")]
5892    fn signal_peer(
5893        &self,
5894        clear_mask: zx::Signals,
5895        set_mask: zx::Signals,
5896    ) -> Result<(), zx_status::Status> {
5897        use fidl::Peered;
5898        self.inner.channel().signal_peer(clear_mask, set_mask)
5899    }
5900}
5901
5902impl ProjectIdControlHandle {}
5903
5904#[must_use = "FIDL methods require a response to be sent"]
5905#[derive(Debug)]
5906pub struct ProjectIdSetLimitResponder {
5907    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5908    tx_id: u32,
5909}
5910
5911/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5912/// if the responder is dropped without sending a response, so that the client
5913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5914impl std::ops::Drop for ProjectIdSetLimitResponder {
5915    fn drop(&mut self) {
5916        self.control_handle.shutdown();
5917        // Safety: drops once, never accessed again
5918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5919    }
5920}
5921
5922impl fidl::endpoints::Responder for ProjectIdSetLimitResponder {
5923    type ControlHandle = ProjectIdControlHandle;
5924
5925    fn control_handle(&self) -> &ProjectIdControlHandle {
5926        &self.control_handle
5927    }
5928
5929    fn drop_without_shutdown(mut self) {
5930        // Safety: drops once, never accessed again due to mem::forget
5931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5932        // Prevent Drop from running (which would shut down the channel)
5933        std::mem::forget(self);
5934    }
5935}
5936
5937impl ProjectIdSetLimitResponder {
5938    /// Sends a response to the FIDL transaction.
5939    ///
5940    /// Sets the channel to shutdown if an error occurs.
5941    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5942        let _result = self.send_raw(result);
5943        if _result.is_err() {
5944            self.control_handle.shutdown();
5945        }
5946        self.drop_without_shutdown();
5947        _result
5948    }
5949
5950    /// Similar to "send" but does not shutdown the channel if an error occurs.
5951    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5952        let _result = self.send_raw(result);
5953        self.drop_without_shutdown();
5954        _result
5955    }
5956
5957    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5958        self.control_handle
5959            .inner
5960            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5961                result,
5962                self.tx_id,
5963                0x20b0fc1e0413876f,
5964                fidl::encoding::DynamicFlags::empty(),
5965            )
5966    }
5967}
5968
5969#[must_use = "FIDL methods require a response to be sent"]
5970#[derive(Debug)]
5971pub struct ProjectIdClearResponder {
5972    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5973    tx_id: u32,
5974}
5975
5976/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5977/// if the responder is dropped without sending a response, so that the client
5978/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5979impl std::ops::Drop for ProjectIdClearResponder {
5980    fn drop(&mut self) {
5981        self.control_handle.shutdown();
5982        // Safety: drops once, never accessed again
5983        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5984    }
5985}
5986
5987impl fidl::endpoints::Responder for ProjectIdClearResponder {
5988    type ControlHandle = ProjectIdControlHandle;
5989
5990    fn control_handle(&self) -> &ProjectIdControlHandle {
5991        &self.control_handle
5992    }
5993
5994    fn drop_without_shutdown(mut self) {
5995        // Safety: drops once, never accessed again due to mem::forget
5996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5997        // Prevent Drop from running (which would shut down the channel)
5998        std::mem::forget(self);
5999    }
6000}
6001
6002impl ProjectIdClearResponder {
6003    /// Sends a response to the FIDL transaction.
6004    ///
6005    /// Sets the channel to shutdown if an error occurs.
6006    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6007        let _result = self.send_raw(result);
6008        if _result.is_err() {
6009            self.control_handle.shutdown();
6010        }
6011        self.drop_without_shutdown();
6012        _result
6013    }
6014
6015    /// Similar to "send" but does not shutdown the channel if an error occurs.
6016    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6017        let _result = self.send_raw(result);
6018        self.drop_without_shutdown();
6019        _result
6020    }
6021
6022    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6023        self.control_handle
6024            .inner
6025            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6026                result,
6027                self.tx_id,
6028                0x165b5f1e707863c1,
6029                fidl::encoding::DynamicFlags::empty(),
6030            )
6031    }
6032}
6033
6034#[must_use = "FIDL methods require a response to be sent"]
6035#[derive(Debug)]
6036pub struct ProjectIdSetForNodeResponder {
6037    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6038    tx_id: u32,
6039}
6040
6041/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6042/// if the responder is dropped without sending a response, so that the client
6043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6044impl std::ops::Drop for ProjectIdSetForNodeResponder {
6045    fn drop(&mut self) {
6046        self.control_handle.shutdown();
6047        // Safety: drops once, never accessed again
6048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6049    }
6050}
6051
6052impl fidl::endpoints::Responder for ProjectIdSetForNodeResponder {
6053    type ControlHandle = ProjectIdControlHandle;
6054
6055    fn control_handle(&self) -> &ProjectIdControlHandle {
6056        &self.control_handle
6057    }
6058
6059    fn drop_without_shutdown(mut self) {
6060        // Safety: drops once, never accessed again due to mem::forget
6061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6062        // Prevent Drop from running (which would shut down the channel)
6063        std::mem::forget(self);
6064    }
6065}
6066
6067impl ProjectIdSetForNodeResponder {
6068    /// Sends a response to the FIDL transaction.
6069    ///
6070    /// Sets the channel to shutdown if an error occurs.
6071    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6072        let _result = self.send_raw(result);
6073        if _result.is_err() {
6074            self.control_handle.shutdown();
6075        }
6076        self.drop_without_shutdown();
6077        _result
6078    }
6079
6080    /// Similar to "send" but does not shutdown the channel if an error occurs.
6081    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6082        let _result = self.send_raw(result);
6083        self.drop_without_shutdown();
6084        _result
6085    }
6086
6087    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6088        self.control_handle
6089            .inner
6090            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6091                result,
6092                self.tx_id,
6093                0x4d7a8442dc58324c,
6094                fidl::encoding::DynamicFlags::empty(),
6095            )
6096    }
6097}
6098
6099#[must_use = "FIDL methods require a response to be sent"]
6100#[derive(Debug)]
6101pub struct ProjectIdGetForNodeResponder {
6102    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6103    tx_id: u32,
6104}
6105
6106/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6107/// if the responder is dropped without sending a response, so that the client
6108/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6109impl std::ops::Drop for ProjectIdGetForNodeResponder {
6110    fn drop(&mut self) {
6111        self.control_handle.shutdown();
6112        // Safety: drops once, never accessed again
6113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6114    }
6115}
6116
6117impl fidl::endpoints::Responder for ProjectIdGetForNodeResponder {
6118    type ControlHandle = ProjectIdControlHandle;
6119
6120    fn control_handle(&self) -> &ProjectIdControlHandle {
6121        &self.control_handle
6122    }
6123
6124    fn drop_without_shutdown(mut self) {
6125        // Safety: drops once, never accessed again due to mem::forget
6126        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6127        // Prevent Drop from running (which would shut down the channel)
6128        std::mem::forget(self);
6129    }
6130}
6131
6132impl ProjectIdGetForNodeResponder {
6133    /// Sends a response to the FIDL transaction.
6134    ///
6135    /// Sets the channel to shutdown if an error occurs.
6136    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6137        let _result = self.send_raw(result);
6138        if _result.is_err() {
6139            self.control_handle.shutdown();
6140        }
6141        self.drop_without_shutdown();
6142        _result
6143    }
6144
6145    /// Similar to "send" but does not shutdown the channel if an error occurs.
6146    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6147        let _result = self.send_raw(result);
6148        self.drop_without_shutdown();
6149        _result
6150    }
6151
6152    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6153        self.control_handle
6154            .inner
6155            .send::<fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>>(
6156                result.map(|project_id| (project_id,)),
6157                self.tx_id,
6158                0x644073bdf2542573,
6159                fidl::encoding::DynamicFlags::empty(),
6160            )
6161    }
6162}
6163
6164#[must_use = "FIDL methods require a response to be sent"]
6165#[derive(Debug)]
6166pub struct ProjectIdClearForNodeResponder {
6167    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6168    tx_id: u32,
6169}
6170
6171/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6172/// if the responder is dropped without sending a response, so that the client
6173/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6174impl std::ops::Drop for ProjectIdClearForNodeResponder {
6175    fn drop(&mut self) {
6176        self.control_handle.shutdown();
6177        // Safety: drops once, never accessed again
6178        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6179    }
6180}
6181
6182impl fidl::endpoints::Responder for ProjectIdClearForNodeResponder {
6183    type ControlHandle = ProjectIdControlHandle;
6184
6185    fn control_handle(&self) -> &ProjectIdControlHandle {
6186        &self.control_handle
6187    }
6188
6189    fn drop_without_shutdown(mut self) {
6190        // Safety: drops once, never accessed again due to mem::forget
6191        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6192        // Prevent Drop from running (which would shut down the channel)
6193        std::mem::forget(self);
6194    }
6195}
6196
6197impl ProjectIdClearForNodeResponder {
6198    /// Sends a response to the FIDL transaction.
6199    ///
6200    /// Sets the channel to shutdown if an error occurs.
6201    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6202        let _result = self.send_raw(result);
6203        if _result.is_err() {
6204            self.control_handle.shutdown();
6205        }
6206        self.drop_without_shutdown();
6207        _result
6208    }
6209
6210    /// Similar to "send" but does not shutdown the channel if an error occurs.
6211    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6212        let _result = self.send_raw(result);
6213        self.drop_without_shutdown();
6214        _result
6215    }
6216
6217    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6218        self.control_handle
6219            .inner
6220            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6221                result,
6222                self.tx_id,
6223                0x3f2ca287bbfe6a62,
6224                fidl::encoding::DynamicFlags::empty(),
6225            )
6226    }
6227}
6228
6229#[must_use = "FIDL methods require a response to be sent"]
6230#[derive(Debug)]
6231pub struct ProjectIdListResponder {
6232    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6233    tx_id: u32,
6234}
6235
6236/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6237/// if the responder is dropped without sending a response, so that the client
6238/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6239impl std::ops::Drop for ProjectIdListResponder {
6240    fn drop(&mut self) {
6241        self.control_handle.shutdown();
6242        // Safety: drops once, never accessed again
6243        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6244    }
6245}
6246
6247impl fidl::endpoints::Responder for ProjectIdListResponder {
6248    type ControlHandle = ProjectIdControlHandle;
6249
6250    fn control_handle(&self) -> &ProjectIdControlHandle {
6251        &self.control_handle
6252    }
6253
6254    fn drop_without_shutdown(mut self) {
6255        // Safety: drops once, never accessed again due to mem::forget
6256        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6257        // Prevent Drop from running (which would shut down the channel)
6258        std::mem::forget(self);
6259    }
6260}
6261
6262impl ProjectIdListResponder {
6263    /// Sends a response to the FIDL transaction.
6264    ///
6265    /// Sets the channel to shutdown if an error occurs.
6266    pub fn send(
6267        self,
6268        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6269    ) -> Result<(), fidl::Error> {
6270        let _result = self.send_raw(result);
6271        if _result.is_err() {
6272            self.control_handle.shutdown();
6273        }
6274        self.drop_without_shutdown();
6275        _result
6276    }
6277
6278    /// Similar to "send" but does not shutdown the channel if an error occurs.
6279    pub fn send_no_shutdown_on_err(
6280        self,
6281        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6282    ) -> Result<(), fidl::Error> {
6283        let _result = self.send_raw(result);
6284        self.drop_without_shutdown();
6285        _result
6286    }
6287
6288    fn send_raw(
6289        &self,
6290        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6291    ) -> Result<(), fidl::Error> {
6292        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdListResponse, i32>>(
6293            result,
6294            self.tx_id,
6295            0x5505f95a36d522cc,
6296            fidl::encoding::DynamicFlags::empty(),
6297        )
6298    }
6299}
6300
6301#[must_use = "FIDL methods require a response to be sent"]
6302#[derive(Debug)]
6303pub struct ProjectIdInfoResponder {
6304    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6305    tx_id: u32,
6306}
6307
6308/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6309/// if the responder is dropped without sending a response, so that the client
6310/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6311impl std::ops::Drop for ProjectIdInfoResponder {
6312    fn drop(&mut self) {
6313        self.control_handle.shutdown();
6314        // Safety: drops once, never accessed again
6315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6316    }
6317}
6318
6319impl fidl::endpoints::Responder for ProjectIdInfoResponder {
6320    type ControlHandle = ProjectIdControlHandle;
6321
6322    fn control_handle(&self) -> &ProjectIdControlHandle {
6323        &self.control_handle
6324    }
6325
6326    fn drop_without_shutdown(mut self) {
6327        // Safety: drops once, never accessed again due to mem::forget
6328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6329        // Prevent Drop from running (which would shut down the channel)
6330        std::mem::forget(self);
6331    }
6332}
6333
6334impl ProjectIdInfoResponder {
6335    /// Sends a response to the FIDL transaction.
6336    ///
6337    /// Sets the channel to shutdown if an error occurs.
6338    pub fn send(
6339        self,
6340        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6341    ) -> Result<(), fidl::Error> {
6342        let _result = self.send_raw(result);
6343        if _result.is_err() {
6344            self.control_handle.shutdown();
6345        }
6346        self.drop_without_shutdown();
6347        _result
6348    }
6349
6350    /// Similar to "send" but does not shutdown the channel if an error occurs.
6351    pub fn send_no_shutdown_on_err(
6352        self,
6353        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6354    ) -> Result<(), fidl::Error> {
6355        let _result = self.send_raw(result);
6356        self.drop_without_shutdown();
6357        _result
6358    }
6359
6360    fn send_raw(
6361        &self,
6362        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6363    ) -> Result<(), fidl::Error> {
6364        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdInfoResponse, i32>>(
6365            result,
6366            self.tx_id,
6367            0x51b47743c9e2d1ab,
6368            fidl::encoding::DynamicFlags::empty(),
6369        )
6370    }
6371}
6372
6373mod internal {
6374    use super::*;
6375
6376    impl fidl::encoding::ResourceTypeMarker for BlobCreatorCreateResponse {
6377        type Borrowed<'a> = &'a mut Self;
6378        fn take_or_borrow<'a>(
6379            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6380        ) -> Self::Borrowed<'a> {
6381            value
6382        }
6383    }
6384
6385    unsafe impl fidl::encoding::TypeMarker for BlobCreatorCreateResponse {
6386        type Owned = Self;
6387
6388        #[inline(always)]
6389        fn inline_align(_context: fidl::encoding::Context) -> usize {
6390            4
6391        }
6392
6393        #[inline(always)]
6394        fn inline_size(_context: fidl::encoding::Context) -> usize {
6395            4
6396        }
6397    }
6398
6399    unsafe impl
6400        fidl::encoding::Encode<
6401            BlobCreatorCreateResponse,
6402            fidl::encoding::DefaultFuchsiaResourceDialect,
6403        > for &mut BlobCreatorCreateResponse
6404    {
6405        #[inline]
6406        unsafe fn encode(
6407            self,
6408            encoder: &mut fidl::encoding::Encoder<
6409                '_,
6410                fidl::encoding::DefaultFuchsiaResourceDialect,
6411            >,
6412            offset: usize,
6413            _depth: fidl::encoding::Depth,
6414        ) -> fidl::Result<()> {
6415            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
6416            // Delegate to tuple encoding.
6417            fidl::encoding::Encode::<BlobCreatorCreateResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6418                (
6419                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
6420                ),
6421                encoder, offset, _depth
6422            )
6423        }
6424    }
6425    unsafe impl<
6426            T0: fidl::encoding::Encode<
6427                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
6428                fidl::encoding::DefaultFuchsiaResourceDialect,
6429            >,
6430        >
6431        fidl::encoding::Encode<
6432            BlobCreatorCreateResponse,
6433            fidl::encoding::DefaultFuchsiaResourceDialect,
6434        > for (T0,)
6435    {
6436        #[inline]
6437        unsafe fn encode(
6438            self,
6439            encoder: &mut fidl::encoding::Encoder<
6440                '_,
6441                fidl::encoding::DefaultFuchsiaResourceDialect,
6442            >,
6443            offset: usize,
6444            depth: fidl::encoding::Depth,
6445        ) -> fidl::Result<()> {
6446            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
6447            // Zero out padding regions. There's no need to apply masks
6448            // because the unmasked parts will be overwritten by fields.
6449            // Write the fields.
6450            self.0.encode(encoder, offset + 0, depth)?;
6451            Ok(())
6452        }
6453    }
6454
6455    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6456        for BlobCreatorCreateResponse
6457    {
6458        #[inline(always)]
6459        fn new_empty() -> Self {
6460            Self {
6461                writer: fidl::new_empty!(
6462                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
6463                    fidl::encoding::DefaultFuchsiaResourceDialect
6464                ),
6465            }
6466        }
6467
6468        #[inline]
6469        unsafe fn decode(
6470            &mut self,
6471            decoder: &mut fidl::encoding::Decoder<
6472                '_,
6473                fidl::encoding::DefaultFuchsiaResourceDialect,
6474            >,
6475            offset: usize,
6476            _depth: fidl::encoding::Depth,
6477        ) -> fidl::Result<()> {
6478            decoder.debug_check_bounds::<Self>(offset);
6479            // Verify that padding bytes are zero.
6480            fidl::decode!(
6481                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
6482                fidl::encoding::DefaultFuchsiaResourceDialect,
6483                &mut self.writer,
6484                decoder,
6485                offset + 0,
6486                _depth
6487            )?;
6488            Ok(())
6489        }
6490    }
6491
6492    impl fidl::encoding::ResourceTypeMarker for BlobReaderGetVmoResponse {
6493        type Borrowed<'a> = &'a mut Self;
6494        fn take_or_borrow<'a>(
6495            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6496        ) -> Self::Borrowed<'a> {
6497            value
6498        }
6499    }
6500
6501    unsafe impl fidl::encoding::TypeMarker for BlobReaderGetVmoResponse {
6502        type Owned = Self;
6503
6504        #[inline(always)]
6505        fn inline_align(_context: fidl::encoding::Context) -> usize {
6506            4
6507        }
6508
6509        #[inline(always)]
6510        fn inline_size(_context: fidl::encoding::Context) -> usize {
6511            4
6512        }
6513    }
6514
6515    unsafe impl
6516        fidl::encoding::Encode<
6517            BlobReaderGetVmoResponse,
6518            fidl::encoding::DefaultFuchsiaResourceDialect,
6519        > for &mut BlobReaderGetVmoResponse
6520    {
6521        #[inline]
6522        unsafe fn encode(
6523            self,
6524            encoder: &mut fidl::encoding::Encoder<
6525                '_,
6526                fidl::encoding::DefaultFuchsiaResourceDialect,
6527            >,
6528            offset: usize,
6529            _depth: fidl::encoding::Depth,
6530        ) -> fidl::Result<()> {
6531            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
6532            // Delegate to tuple encoding.
6533            fidl::encoding::Encode::<
6534                BlobReaderGetVmoResponse,
6535                fidl::encoding::DefaultFuchsiaResourceDialect,
6536            >::encode(
6537                (<fidl::encoding::HandleType<
6538                    fidl::Vmo,
6539                    { fidl::ObjectType::VMO.into_raw() },
6540                    2147483648,
6541                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6542                    &mut self.vmo
6543                ),),
6544                encoder,
6545                offset,
6546                _depth,
6547            )
6548        }
6549    }
6550    unsafe impl<
6551            T0: fidl::encoding::Encode<
6552                fidl::encoding::HandleType<
6553                    fidl::Vmo,
6554                    { fidl::ObjectType::VMO.into_raw() },
6555                    2147483648,
6556                >,
6557                fidl::encoding::DefaultFuchsiaResourceDialect,
6558            >,
6559        >
6560        fidl::encoding::Encode<
6561            BlobReaderGetVmoResponse,
6562            fidl::encoding::DefaultFuchsiaResourceDialect,
6563        > for (T0,)
6564    {
6565        #[inline]
6566        unsafe fn encode(
6567            self,
6568            encoder: &mut fidl::encoding::Encoder<
6569                '_,
6570                fidl::encoding::DefaultFuchsiaResourceDialect,
6571            >,
6572            offset: usize,
6573            depth: fidl::encoding::Depth,
6574        ) -> fidl::Result<()> {
6575            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
6576            // Zero out padding regions. There's no need to apply masks
6577            // because the unmasked parts will be overwritten by fields.
6578            // Write the fields.
6579            self.0.encode(encoder, offset + 0, depth)?;
6580            Ok(())
6581        }
6582    }
6583
6584    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6585        for BlobReaderGetVmoResponse
6586    {
6587        #[inline(always)]
6588        fn new_empty() -> Self {
6589            Self {
6590                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6591            }
6592        }
6593
6594        #[inline]
6595        unsafe fn decode(
6596            &mut self,
6597            decoder: &mut fidl::encoding::Decoder<
6598                '_,
6599                fidl::encoding::DefaultFuchsiaResourceDialect,
6600            >,
6601            offset: usize,
6602            _depth: fidl::encoding::Depth,
6603        ) -> fidl::Result<()> {
6604            decoder.debug_check_bounds::<Self>(offset);
6605            // Verify that padding bytes are zero.
6606            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
6607            Ok(())
6608        }
6609    }
6610
6611    impl fidl::encoding::ResourceTypeMarker for BlobVolumeWriterWriteRequest {
6612        type Borrowed<'a> = &'a mut Self;
6613        fn take_or_borrow<'a>(
6614            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6615        ) -> Self::Borrowed<'a> {
6616            value
6617        }
6618    }
6619
6620    unsafe impl fidl::encoding::TypeMarker for BlobVolumeWriterWriteRequest {
6621        type Owned = Self;
6622
6623        #[inline(always)]
6624        fn inline_align(_context: fidl::encoding::Context) -> usize {
6625            4
6626        }
6627
6628        #[inline(always)]
6629        fn inline_size(_context: fidl::encoding::Context) -> usize {
6630            4
6631        }
6632    }
6633
6634    unsafe impl
6635        fidl::encoding::Encode<
6636            BlobVolumeWriterWriteRequest,
6637            fidl::encoding::DefaultFuchsiaResourceDialect,
6638        > for &mut BlobVolumeWriterWriteRequest
6639    {
6640        #[inline]
6641        unsafe fn encode(
6642            self,
6643            encoder: &mut fidl::encoding::Encoder<
6644                '_,
6645                fidl::encoding::DefaultFuchsiaResourceDialect,
6646            >,
6647            offset: usize,
6648            _depth: fidl::encoding::Depth,
6649        ) -> fidl::Result<()> {
6650            encoder.debug_check_bounds::<BlobVolumeWriterWriteRequest>(offset);
6651            // Delegate to tuple encoding.
6652            fidl::encoding::Encode::<
6653                BlobVolumeWriterWriteRequest,
6654                fidl::encoding::DefaultFuchsiaResourceDialect,
6655            >::encode(
6656                (<fidl::encoding::HandleType<
6657                    fidl::Vmo,
6658                    { fidl::ObjectType::VMO.into_raw() },
6659                    2147483648,
6660                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6661                    &mut self.payload
6662                ),),
6663                encoder,
6664                offset,
6665                _depth,
6666            )
6667        }
6668    }
6669    unsafe impl<
6670            T0: fidl::encoding::Encode<
6671                fidl::encoding::HandleType<
6672                    fidl::Vmo,
6673                    { fidl::ObjectType::VMO.into_raw() },
6674                    2147483648,
6675                >,
6676                fidl::encoding::DefaultFuchsiaResourceDialect,
6677            >,
6678        >
6679        fidl::encoding::Encode<
6680            BlobVolumeWriterWriteRequest,
6681            fidl::encoding::DefaultFuchsiaResourceDialect,
6682        > for (T0,)
6683    {
6684        #[inline]
6685        unsafe fn encode(
6686            self,
6687            encoder: &mut fidl::encoding::Encoder<
6688                '_,
6689                fidl::encoding::DefaultFuchsiaResourceDialect,
6690            >,
6691            offset: usize,
6692            depth: fidl::encoding::Depth,
6693        ) -> fidl::Result<()> {
6694            encoder.debug_check_bounds::<BlobVolumeWriterWriteRequest>(offset);
6695            // Zero out padding regions. There's no need to apply masks
6696            // because the unmasked parts will be overwritten by fields.
6697            // Write the fields.
6698            self.0.encode(encoder, offset + 0, depth)?;
6699            Ok(())
6700        }
6701    }
6702
6703    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6704        for BlobVolumeWriterWriteRequest
6705    {
6706        #[inline(always)]
6707        fn new_empty() -> Self {
6708            Self {
6709                payload: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6710            }
6711        }
6712
6713        #[inline]
6714        unsafe fn decode(
6715            &mut self,
6716            decoder: &mut fidl::encoding::Decoder<
6717                '_,
6718                fidl::encoding::DefaultFuchsiaResourceDialect,
6719            >,
6720            offset: usize,
6721            _depth: fidl::encoding::Depth,
6722        ) -> fidl::Result<()> {
6723            decoder.debug_check_bounds::<Self>(offset);
6724            // Verify that padding bytes are zero.
6725            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload, decoder, offset + 0, _depth)?;
6726            Ok(())
6727        }
6728    }
6729
6730    impl fidl::encoding::ResourceTypeMarker for BlobWriterGetVmoResponse {
6731        type Borrowed<'a> = &'a mut Self;
6732        fn take_or_borrow<'a>(
6733            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6734        ) -> Self::Borrowed<'a> {
6735            value
6736        }
6737    }
6738
6739    unsafe impl fidl::encoding::TypeMarker for BlobWriterGetVmoResponse {
6740        type Owned = Self;
6741
6742        #[inline(always)]
6743        fn inline_align(_context: fidl::encoding::Context) -> usize {
6744            4
6745        }
6746
6747        #[inline(always)]
6748        fn inline_size(_context: fidl::encoding::Context) -> usize {
6749            4
6750        }
6751    }
6752
6753    unsafe impl
6754        fidl::encoding::Encode<
6755            BlobWriterGetVmoResponse,
6756            fidl::encoding::DefaultFuchsiaResourceDialect,
6757        > for &mut BlobWriterGetVmoResponse
6758    {
6759        #[inline]
6760        unsafe fn encode(
6761            self,
6762            encoder: &mut fidl::encoding::Encoder<
6763                '_,
6764                fidl::encoding::DefaultFuchsiaResourceDialect,
6765            >,
6766            offset: usize,
6767            _depth: fidl::encoding::Depth,
6768        ) -> fidl::Result<()> {
6769            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
6770            // Delegate to tuple encoding.
6771            fidl::encoding::Encode::<
6772                BlobWriterGetVmoResponse,
6773                fidl::encoding::DefaultFuchsiaResourceDialect,
6774            >::encode(
6775                (<fidl::encoding::HandleType<
6776                    fidl::Vmo,
6777                    { fidl::ObjectType::VMO.into_raw() },
6778                    2147483648,
6779                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6780                    &mut self.vmo
6781                ),),
6782                encoder,
6783                offset,
6784                _depth,
6785            )
6786        }
6787    }
6788    unsafe impl<
6789            T0: fidl::encoding::Encode<
6790                fidl::encoding::HandleType<
6791                    fidl::Vmo,
6792                    { fidl::ObjectType::VMO.into_raw() },
6793                    2147483648,
6794                >,
6795                fidl::encoding::DefaultFuchsiaResourceDialect,
6796            >,
6797        >
6798        fidl::encoding::Encode<
6799            BlobWriterGetVmoResponse,
6800            fidl::encoding::DefaultFuchsiaResourceDialect,
6801        > for (T0,)
6802    {
6803        #[inline]
6804        unsafe fn encode(
6805            self,
6806            encoder: &mut fidl::encoding::Encoder<
6807                '_,
6808                fidl::encoding::DefaultFuchsiaResourceDialect,
6809            >,
6810            offset: usize,
6811            depth: fidl::encoding::Depth,
6812        ) -> fidl::Result<()> {
6813            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
6814            // Zero out padding regions. There's no need to apply masks
6815            // because the unmasked parts will be overwritten by fields.
6816            // Write the fields.
6817            self.0.encode(encoder, offset + 0, depth)?;
6818            Ok(())
6819        }
6820    }
6821
6822    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6823        for BlobWriterGetVmoResponse
6824    {
6825        #[inline(always)]
6826        fn new_empty() -> Self {
6827            Self {
6828                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6829            }
6830        }
6831
6832        #[inline]
6833        unsafe fn decode(
6834            &mut self,
6835            decoder: &mut fidl::encoding::Decoder<
6836                '_,
6837                fidl::encoding::DefaultFuchsiaResourceDialect,
6838            >,
6839            offset: usize,
6840            _depth: fidl::encoding::Depth,
6841        ) -> fidl::Result<()> {
6842            decoder.debug_check_bounds::<Self>(offset);
6843            // Verify that padding bytes are zero.
6844            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
6845            Ok(())
6846        }
6847    }
6848
6849    impl fidl::encoding::ResourceTypeMarker for FileBackedVolumeProviderOpenRequest {
6850        type Borrowed<'a> = &'a mut Self;
6851        fn take_or_borrow<'a>(
6852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6853        ) -> Self::Borrowed<'a> {
6854            value
6855        }
6856    }
6857
6858    unsafe impl fidl::encoding::TypeMarker for FileBackedVolumeProviderOpenRequest {
6859        type Owned = Self;
6860
6861        #[inline(always)]
6862        fn inline_align(_context: fidl::encoding::Context) -> usize {
6863            8
6864        }
6865
6866        #[inline(always)]
6867        fn inline_size(_context: fidl::encoding::Context) -> usize {
6868            32
6869        }
6870    }
6871
6872    unsafe impl
6873        fidl::encoding::Encode<
6874            FileBackedVolumeProviderOpenRequest,
6875            fidl::encoding::DefaultFuchsiaResourceDialect,
6876        > for &mut FileBackedVolumeProviderOpenRequest
6877    {
6878        #[inline]
6879        unsafe fn encode(
6880            self,
6881            encoder: &mut fidl::encoding::Encoder<
6882                '_,
6883                fidl::encoding::DefaultFuchsiaResourceDialect,
6884            >,
6885            offset: usize,
6886            _depth: fidl::encoding::Depth,
6887        ) -> fidl::Result<()> {
6888            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
6889            // Delegate to tuple encoding.
6890            fidl::encoding::Encode::<
6891                FileBackedVolumeProviderOpenRequest,
6892                fidl::encoding::DefaultFuchsiaResourceDialect,
6893            >::encode(
6894                (
6895                    <fidl::encoding::HandleType<
6896                        fidl::Handle,
6897                        { fidl::ObjectType::NONE.into_raw() },
6898                        2147483648,
6899                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6900                        &mut self.parent_directory_token,
6901                    ),
6902                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
6903                        &self.name,
6904                    ),
6905                    <fidl::encoding::Endpoint<
6906                        fidl::endpoints::ServerEnd<
6907                            fidl_fuchsia_hardware_block_volume::VolumeMarker,
6908                        >,
6909                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6910                        &mut self.server_end
6911                    ),
6912                ),
6913                encoder,
6914                offset,
6915                _depth,
6916            )
6917        }
6918    }
6919    unsafe impl<
6920            T0: fidl::encoding::Encode<
6921                fidl::encoding::HandleType<
6922                    fidl::Handle,
6923                    { fidl::ObjectType::NONE.into_raw() },
6924                    2147483648,
6925                >,
6926                fidl::encoding::DefaultFuchsiaResourceDialect,
6927            >,
6928            T1: fidl::encoding::Encode<
6929                fidl::encoding::BoundedString<255>,
6930                fidl::encoding::DefaultFuchsiaResourceDialect,
6931            >,
6932            T2: fidl::encoding::Encode<
6933                fidl::encoding::Endpoint<
6934                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
6935                >,
6936                fidl::encoding::DefaultFuchsiaResourceDialect,
6937            >,
6938        >
6939        fidl::encoding::Encode<
6940            FileBackedVolumeProviderOpenRequest,
6941            fidl::encoding::DefaultFuchsiaResourceDialect,
6942        > for (T0, T1, T2)
6943    {
6944        #[inline]
6945        unsafe fn encode(
6946            self,
6947            encoder: &mut fidl::encoding::Encoder<
6948                '_,
6949                fidl::encoding::DefaultFuchsiaResourceDialect,
6950            >,
6951            offset: usize,
6952            depth: fidl::encoding::Depth,
6953        ) -> fidl::Result<()> {
6954            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
6955            // Zero out padding regions. There's no need to apply masks
6956            // because the unmasked parts will be overwritten by fields.
6957            unsafe {
6958                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
6959                (ptr as *mut u64).write_unaligned(0);
6960            }
6961            unsafe {
6962                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
6963                (ptr as *mut u64).write_unaligned(0);
6964            }
6965            // Write the fields.
6966            self.0.encode(encoder, offset + 0, depth)?;
6967            self.1.encode(encoder, offset + 8, depth)?;
6968            self.2.encode(encoder, offset + 24, depth)?;
6969            Ok(())
6970        }
6971    }
6972
6973    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6974        for FileBackedVolumeProviderOpenRequest
6975    {
6976        #[inline(always)]
6977        fn new_empty() -> Self {
6978            Self {
6979                parent_directory_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6980                name: fidl::new_empty!(
6981                    fidl::encoding::BoundedString<255>,
6982                    fidl::encoding::DefaultFuchsiaResourceDialect
6983                ),
6984                server_end: fidl::new_empty!(
6985                    fidl::encoding::Endpoint<
6986                        fidl::endpoints::ServerEnd<
6987                            fidl_fuchsia_hardware_block_volume::VolumeMarker,
6988                        >,
6989                    >,
6990                    fidl::encoding::DefaultFuchsiaResourceDialect
6991                ),
6992            }
6993        }
6994
6995        #[inline]
6996        unsafe fn decode(
6997            &mut self,
6998            decoder: &mut fidl::encoding::Decoder<
6999                '_,
7000                fidl::encoding::DefaultFuchsiaResourceDialect,
7001            >,
7002            offset: usize,
7003            _depth: fidl::encoding::Depth,
7004        ) -> fidl::Result<()> {
7005            decoder.debug_check_bounds::<Self>(offset);
7006            // Verify that padding bytes are zero.
7007            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7008            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7009            let mask = 0xffffffff00000000u64;
7010            let maskedval = padval & mask;
7011            if maskedval != 0 {
7012                return Err(fidl::Error::NonZeroPadding {
7013                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7014                });
7015            }
7016            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
7017            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7018            let mask = 0xffffffff00000000u64;
7019            let maskedval = padval & mask;
7020            if maskedval != 0 {
7021                return Err(fidl::Error::NonZeroPadding {
7022                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
7023                });
7024            }
7025            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)?;
7026            fidl::decode!(
7027                fidl::encoding::BoundedString<255>,
7028                fidl::encoding::DefaultFuchsiaResourceDialect,
7029                &mut self.name,
7030                decoder,
7031                offset + 8,
7032                _depth
7033            )?;
7034            fidl::decode!(
7035                fidl::encoding::Endpoint<
7036                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block_volume::VolumeMarker>,
7037                >,
7038                fidl::encoding::DefaultFuchsiaResourceDialect,
7039                &mut self.server_end,
7040                decoder,
7041                offset + 24,
7042                _depth
7043            )?;
7044            Ok(())
7045        }
7046    }
7047}