Skip to main content

fidl_fuchsia_fxfs/
fidl_fuchsia_fxfs.rs

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