fidl_fuchsia_fxfs/
fidl_fuchsia_fxfs.rs

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