Skip to main content

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