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 DebugRecordReplayProfileResult = Result<(), i32>;
2828pub type DebugStopProfileTasksResult = Result<(), i32>;
2829
2830pub trait DebugProxyInterface: Send + Sync {
2831    type CompactResponseFut: std::future::Future<Output = Result<DebugCompactResult, fidl::Error>>
2832        + Send;
2833    fn r#compact(&self) -> Self::CompactResponseFut;
2834    type DeleteProfileResponseFut: std::future::Future<Output = Result<DebugDeleteProfileResult, fidl::Error>>
2835        + Send;
2836    fn r#delete_profile(&self, volume: &str, profile: &str) -> Self::DeleteProfileResponseFut;
2837    type RecordReplayProfileResponseFut: std::future::Future<Output = Result<DebugRecordReplayProfileResult, fidl::Error>>
2838        + Send;
2839    fn r#record_replay_profile(
2840        &self,
2841        volume: Option<&str>,
2842        profile: &str,
2843        duration_secs: u32,
2844    ) -> Self::RecordReplayProfileResponseFut;
2845    type StopProfileTasksResponseFut: std::future::Future<Output = Result<DebugStopProfileTasksResult, fidl::Error>>
2846        + Send;
2847    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut;
2848}
2849
2850#[derive(Debug, Clone)]
2851pub struct DebugProxy {
2852    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
2853}
2854
2855impl fdomain_client::fidl::Proxy for DebugProxy {
2856    type Protocol = DebugMarker;
2857
2858    fn from_channel(inner: fdomain_client::Channel) -> Self {
2859        Self::new(inner)
2860    }
2861
2862    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
2863        self.client.into_channel().map_err(|client| Self { client })
2864    }
2865
2866    fn as_channel(&self) -> &fdomain_client::Channel {
2867        self.client.as_channel()
2868    }
2869}
2870
2871impl DebugProxy {
2872    /// Create a new Proxy for fuchsia.fxfs/Debug.
2873    pub fn new(channel: fdomain_client::Channel) -> Self {
2874        let protocol_name = <DebugMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
2875        Self { client: fidl::client::Client::new(channel, protocol_name) }
2876    }
2877
2878    /// Get a Stream of events from the remote end of the protocol.
2879    ///
2880    /// # Panics
2881    ///
2882    /// Panics if the event stream was already taken.
2883    pub fn take_event_stream(&self) -> DebugEventStream {
2884        DebugEventStream { event_receiver: self.client.take_event_receiver() }
2885    }
2886
2887    /// Forces a compaction.
2888    pub fn r#compact(
2889        &self,
2890    ) -> fidl::client::QueryResponseFut<
2891        DebugCompactResult,
2892        fdomain_client::fidl::FDomainResourceDialect,
2893    > {
2894        DebugProxyInterface::r#compact(self)
2895    }
2896
2897    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
2898    /// active profile recording or replay.
2899    pub fn r#delete_profile(
2900        &self,
2901        mut volume: &str,
2902        mut profile: &str,
2903    ) -> fidl::client::QueryResponseFut<
2904        DebugDeleteProfileResult,
2905        fdomain_client::fidl::FDomainResourceDialect,
2906    > {
2907        DebugProxyInterface::r#delete_profile(self, volume, profile)
2908    }
2909
2910    /// Begins recording a profile for a named volume for up to the given duration in seconds. If a
2911    /// profile already exists under the given name then it will begin replaying it as well. Fails
2912    /// if the volume isn't mounted or there is active profile recording or replay on the volume.
2913    pub fn r#record_replay_profile(
2914        &self,
2915        mut volume: Option<&str>,
2916        mut profile: &str,
2917        mut duration_secs: u32,
2918    ) -> fidl::client::QueryResponseFut<
2919        DebugRecordReplayProfileResult,
2920        fdomain_client::fidl::FDomainResourceDialect,
2921    > {
2922        DebugProxyInterface::r#record_replay_profile(self, volume, profile, duration_secs)
2923    }
2924
2925    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
2926    /// persisted.
2927    pub fn r#stop_profile_tasks(
2928        &self,
2929    ) -> fidl::client::QueryResponseFut<
2930        DebugStopProfileTasksResult,
2931        fdomain_client::fidl::FDomainResourceDialect,
2932    > {
2933        DebugProxyInterface::r#stop_profile_tasks(self)
2934    }
2935}
2936
2937impl DebugProxyInterface for DebugProxy {
2938    type CompactResponseFut = fidl::client::QueryResponseFut<
2939        DebugCompactResult,
2940        fdomain_client::fidl::FDomainResourceDialect,
2941    >;
2942    fn r#compact(&self) -> Self::CompactResponseFut {
2943        fn _decode(
2944            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2945        ) -> Result<DebugCompactResult, fidl::Error> {
2946            let _response = fidl::client::decode_transaction_body::<
2947                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2948                fdomain_client::fidl::FDomainResourceDialect,
2949                0x6553eb197306e489,
2950            >(_buf?)?;
2951            Ok(_response.map(|x| x))
2952        }
2953        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DebugCompactResult>(
2954            (),
2955            0x6553eb197306e489,
2956            fidl::encoding::DynamicFlags::empty(),
2957            _decode,
2958        )
2959    }
2960
2961    type DeleteProfileResponseFut = fidl::client::QueryResponseFut<
2962        DebugDeleteProfileResult,
2963        fdomain_client::fidl::FDomainResourceDialect,
2964    >;
2965    fn r#delete_profile(
2966        &self,
2967        mut volume: &str,
2968        mut profile: &str,
2969    ) -> Self::DeleteProfileResponseFut {
2970        fn _decode(
2971            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2972        ) -> Result<DebugDeleteProfileResult, fidl::Error> {
2973            let _response = fidl::client::decode_transaction_body::<
2974                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2975                fdomain_client::fidl::FDomainResourceDialect,
2976                0x54d9d4c9cf300a1e,
2977            >(_buf?)?;
2978            Ok(_response.map(|x| x))
2979        }
2980        self.client.send_query_and_decode::<DebugDeleteProfileRequest, DebugDeleteProfileResult>(
2981            (volume, profile),
2982            0x54d9d4c9cf300a1e,
2983            fidl::encoding::DynamicFlags::empty(),
2984            _decode,
2985        )
2986    }
2987
2988    type RecordReplayProfileResponseFut = fidl::client::QueryResponseFut<
2989        DebugRecordReplayProfileResult,
2990        fdomain_client::fidl::FDomainResourceDialect,
2991    >;
2992    fn r#record_replay_profile(
2993        &self,
2994        mut volume: Option<&str>,
2995        mut profile: &str,
2996        mut duration_secs: u32,
2997    ) -> Self::RecordReplayProfileResponseFut {
2998        fn _decode(
2999            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3000        ) -> Result<DebugRecordReplayProfileResult, fidl::Error> {
3001            let _response = fidl::client::decode_transaction_body::<
3002                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3003                fdomain_client::fidl::FDomainResourceDialect,
3004                0x1f9ca9da4b679591,
3005            >(_buf?)?;
3006            Ok(_response.map(|x| x))
3007        }
3008        self.client.send_query_and_decode::<
3009            DebugRecordReplayProfileRequest,
3010            DebugRecordReplayProfileResult,
3011        >(
3012            (volume, profile, duration_secs,),
3013            0x1f9ca9da4b679591,
3014            fidl::encoding::DynamicFlags::empty(),
3015            _decode,
3016        )
3017    }
3018
3019    type StopProfileTasksResponseFut = fidl::client::QueryResponseFut<
3020        DebugStopProfileTasksResult,
3021        fdomain_client::fidl::FDomainResourceDialect,
3022    >;
3023    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut {
3024        fn _decode(
3025            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3026        ) -> Result<DebugStopProfileTasksResult, fidl::Error> {
3027            let _response = fidl::client::decode_transaction_body::<
3028                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3029                fdomain_client::fidl::FDomainResourceDialect,
3030                0x1657b945dd629177,
3031            >(_buf?)?;
3032            Ok(_response.map(|x| x))
3033        }
3034        self.client
3035            .send_query_and_decode::<fidl::encoding::EmptyPayload, DebugStopProfileTasksResult>(
3036                (),
3037                0x1657b945dd629177,
3038                fidl::encoding::DynamicFlags::empty(),
3039                _decode,
3040            )
3041    }
3042}
3043
3044pub struct DebugEventStream {
3045    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3046}
3047
3048impl std::marker::Unpin for DebugEventStream {}
3049
3050impl futures::stream::FusedStream for DebugEventStream {
3051    fn is_terminated(&self) -> bool {
3052        self.event_receiver.is_terminated()
3053    }
3054}
3055
3056impl futures::Stream for DebugEventStream {
3057    type Item = Result<DebugEvent, fidl::Error>;
3058
3059    fn poll_next(
3060        mut self: std::pin::Pin<&mut Self>,
3061        cx: &mut std::task::Context<'_>,
3062    ) -> std::task::Poll<Option<Self::Item>> {
3063        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3064            &mut self.event_receiver,
3065            cx
3066        )?) {
3067            Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
3068            None => std::task::Poll::Ready(None),
3069        }
3070    }
3071}
3072
3073#[derive(Debug)]
3074pub enum DebugEvent {}
3075
3076impl DebugEvent {
3077    /// Decodes a message buffer as a [`DebugEvent`].
3078    fn decode(
3079        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3080    ) -> Result<DebugEvent, fidl::Error> {
3081        let (bytes, _handles) = buf.split_mut();
3082        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3083        debug_assert_eq!(tx_header.tx_id, 0);
3084        match tx_header.ordinal {
3085            _ => Err(fidl::Error::UnknownOrdinal {
3086                ordinal: tx_header.ordinal,
3087                protocol_name: <DebugMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3088            }),
3089        }
3090    }
3091}
3092
3093/// A Stream of incoming requests for fuchsia.fxfs/Debug.
3094pub struct DebugRequestStream {
3095    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3096    is_terminated: bool,
3097}
3098
3099impl std::marker::Unpin for DebugRequestStream {}
3100
3101impl futures::stream::FusedStream for DebugRequestStream {
3102    fn is_terminated(&self) -> bool {
3103        self.is_terminated
3104    }
3105}
3106
3107impl fdomain_client::fidl::RequestStream for DebugRequestStream {
3108    type Protocol = DebugMarker;
3109    type ControlHandle = DebugControlHandle;
3110
3111    fn from_channel(channel: fdomain_client::Channel) -> Self {
3112        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3113    }
3114
3115    fn control_handle(&self) -> Self::ControlHandle {
3116        DebugControlHandle { inner: self.inner.clone() }
3117    }
3118
3119    fn into_inner(
3120        self,
3121    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3122    {
3123        (self.inner, self.is_terminated)
3124    }
3125
3126    fn from_inner(
3127        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3128        is_terminated: bool,
3129    ) -> Self {
3130        Self { inner, is_terminated }
3131    }
3132}
3133
3134impl futures::Stream for DebugRequestStream {
3135    type Item = Result<DebugRequest, fidl::Error>;
3136
3137    fn poll_next(
3138        mut self: std::pin::Pin<&mut Self>,
3139        cx: &mut std::task::Context<'_>,
3140    ) -> std::task::Poll<Option<Self::Item>> {
3141        let this = &mut *self;
3142        if this.inner.check_shutdown(cx) {
3143            this.is_terminated = true;
3144            return std::task::Poll::Ready(None);
3145        }
3146        if this.is_terminated {
3147            panic!("polled DebugRequestStream after completion");
3148        }
3149        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3150            |bytes, handles| {
3151                match this.inner.channel().read_etc(cx, bytes, handles) {
3152                    std::task::Poll::Ready(Ok(())) => {}
3153                    std::task::Poll::Pending => return std::task::Poll::Pending,
3154                    std::task::Poll::Ready(Err(None)) => {
3155                        this.is_terminated = true;
3156                        return std::task::Poll::Ready(None);
3157                    }
3158                    std::task::Poll::Ready(Err(Some(e))) => {
3159                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3160                            e.into(),
3161                        ))));
3162                    }
3163                }
3164
3165                // A message has been received from the channel
3166                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3167
3168                std::task::Poll::Ready(Some(match header.ordinal {
3169                    0x6553eb197306e489 => {
3170                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3171                        let mut req = fidl::new_empty!(
3172                            fidl::encoding::EmptyPayload,
3173                            fdomain_client::fidl::FDomainResourceDialect
3174                        );
3175                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3176                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3177                        Ok(DebugRequest::Compact {
3178                            responder: DebugCompactResponder {
3179                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3180                                tx_id: header.tx_id,
3181                            },
3182                        })
3183                    }
3184                    0x54d9d4c9cf300a1e => {
3185                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3186                        let mut req = fidl::new_empty!(
3187                            DebugDeleteProfileRequest,
3188                            fdomain_client::fidl::FDomainResourceDialect
3189                        );
3190                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<DebugDeleteProfileRequest>(&header, _body_bytes, handles, &mut req)?;
3191                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3192                        Ok(DebugRequest::DeleteProfile {
3193                            volume: req.volume,
3194                            profile: req.profile,
3195
3196                            responder: DebugDeleteProfileResponder {
3197                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3198                                tx_id: header.tx_id,
3199                            },
3200                        })
3201                    }
3202                    0x1f9ca9da4b679591 => {
3203                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3204                        let mut req = fidl::new_empty!(
3205                            DebugRecordReplayProfileRequest,
3206                            fdomain_client::fidl::FDomainResourceDialect
3207                        );
3208                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<DebugRecordReplayProfileRequest>(&header, _body_bytes, handles, &mut req)?;
3209                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3210                        Ok(DebugRequest::RecordReplayProfile {
3211                            volume: req.volume,
3212                            profile: req.profile,
3213                            duration_secs: req.duration_secs,
3214
3215                            responder: DebugRecordReplayProfileResponder {
3216                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3217                                tx_id: header.tx_id,
3218                            },
3219                        })
3220                    }
3221                    0x1657b945dd629177 => {
3222                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3223                        let mut req = fidl::new_empty!(
3224                            fidl::encoding::EmptyPayload,
3225                            fdomain_client::fidl::FDomainResourceDialect
3226                        );
3227                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3228                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
3229                        Ok(DebugRequest::StopProfileTasks {
3230                            responder: DebugStopProfileTasksResponder {
3231                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3232                                tx_id: header.tx_id,
3233                            },
3234                        })
3235                    }
3236                    _ => Err(fidl::Error::UnknownOrdinal {
3237                        ordinal: header.ordinal,
3238                        protocol_name:
3239                            <DebugMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3240                    }),
3241                }))
3242            },
3243        )
3244    }
3245}
3246
3247/// This is an internal protocol for on-device debugging and testing only.
3248/// See `ffx fxfs help` for more details.
3249#[derive(Debug)]
3250pub enum DebugRequest {
3251    /// Forces a compaction.
3252    Compact { responder: DebugCompactResponder },
3253    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3254    /// active profile recording or replay.
3255    DeleteProfile { volume: String, profile: String, responder: DebugDeleteProfileResponder },
3256    /// Begins recording a profile for a named volume for up to the given duration in seconds. If a
3257    /// profile already exists under the given name then it will begin replaying it as well. Fails
3258    /// if the volume isn't mounted or there is active profile recording or replay on the volume.
3259    RecordReplayProfile {
3260        volume: Option<String>,
3261        profile: String,
3262        duration_secs: u32,
3263        responder: DebugRecordReplayProfileResponder,
3264    },
3265    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3266    /// persisted.
3267    StopProfileTasks { responder: DebugStopProfileTasksResponder },
3268}
3269
3270impl DebugRequest {
3271    #[allow(irrefutable_let_patterns)]
3272    pub fn into_compact(self) -> Option<(DebugCompactResponder)> {
3273        if let DebugRequest::Compact { responder } = self { Some((responder)) } else { None }
3274    }
3275
3276    #[allow(irrefutable_let_patterns)]
3277    pub fn into_delete_profile(self) -> Option<(String, String, DebugDeleteProfileResponder)> {
3278        if let DebugRequest::DeleteProfile { volume, profile, responder } = self {
3279            Some((volume, profile, responder))
3280        } else {
3281            None
3282        }
3283    }
3284
3285    #[allow(irrefutable_let_patterns)]
3286    pub fn into_record_replay_profile(
3287        self,
3288    ) -> Option<(Option<String>, String, u32, DebugRecordReplayProfileResponder)> {
3289        if let DebugRequest::RecordReplayProfile { volume, profile, duration_secs, responder } =
3290            self
3291        {
3292            Some((volume, profile, duration_secs, responder))
3293        } else {
3294            None
3295        }
3296    }
3297
3298    #[allow(irrefutable_let_patterns)]
3299    pub fn into_stop_profile_tasks(self) -> Option<(DebugStopProfileTasksResponder)> {
3300        if let DebugRequest::StopProfileTasks { responder } = self {
3301            Some((responder))
3302        } else {
3303            None
3304        }
3305    }
3306
3307    /// Name of the method defined in FIDL
3308    pub fn method_name(&self) -> &'static str {
3309        match *self {
3310            DebugRequest::Compact { .. } => "compact",
3311            DebugRequest::DeleteProfile { .. } => "delete_profile",
3312            DebugRequest::RecordReplayProfile { .. } => "record_replay_profile",
3313            DebugRequest::StopProfileTasks { .. } => "stop_profile_tasks",
3314        }
3315    }
3316}
3317
3318#[derive(Debug, Clone)]
3319pub struct DebugControlHandle {
3320    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3321}
3322
3323impl fdomain_client::fidl::ControlHandle for DebugControlHandle {
3324    fn shutdown(&self) {
3325        self.inner.shutdown()
3326    }
3327
3328    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3329        self.inner.shutdown_with_epitaph(status)
3330    }
3331
3332    fn is_closed(&self) -> bool {
3333        self.inner.channel().is_closed()
3334    }
3335    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3336        self.inner.channel().on_closed()
3337    }
3338}
3339
3340impl DebugControlHandle {}
3341
3342#[must_use = "FIDL methods require a response to be sent"]
3343#[derive(Debug)]
3344pub struct DebugCompactResponder {
3345    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3346    tx_id: u32,
3347}
3348
3349/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3350/// if the responder is dropped without sending a response, so that the client
3351/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3352impl std::ops::Drop for DebugCompactResponder {
3353    fn drop(&mut self) {
3354        self.control_handle.shutdown();
3355        // Safety: drops once, never accessed again
3356        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3357    }
3358}
3359
3360impl fdomain_client::fidl::Responder for DebugCompactResponder {
3361    type ControlHandle = DebugControlHandle;
3362
3363    fn control_handle(&self) -> &DebugControlHandle {
3364        &self.control_handle
3365    }
3366
3367    fn drop_without_shutdown(mut self) {
3368        // Safety: drops once, never accessed again due to mem::forget
3369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3370        // Prevent Drop from running (which would shut down the channel)
3371        std::mem::forget(self);
3372    }
3373}
3374
3375impl DebugCompactResponder {
3376    /// Sends a response to the FIDL transaction.
3377    ///
3378    /// Sets the channel to shutdown if an error occurs.
3379    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3380        let _result = self.send_raw(result);
3381        if _result.is_err() {
3382            self.control_handle.shutdown();
3383        }
3384        self.drop_without_shutdown();
3385        _result
3386    }
3387
3388    /// Similar to "send" but does not shutdown the channel if an error occurs.
3389    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3390        let _result = self.send_raw(result);
3391        self.drop_without_shutdown();
3392        _result
3393    }
3394
3395    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3396        self.control_handle
3397            .inner
3398            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3399                result,
3400                self.tx_id,
3401                0x6553eb197306e489,
3402                fidl::encoding::DynamicFlags::empty(),
3403            )
3404    }
3405}
3406
3407#[must_use = "FIDL methods require a response to be sent"]
3408#[derive(Debug)]
3409pub struct DebugDeleteProfileResponder {
3410    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3411    tx_id: u32,
3412}
3413
3414/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3415/// if the responder is dropped without sending a response, so that the client
3416/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3417impl std::ops::Drop for DebugDeleteProfileResponder {
3418    fn drop(&mut self) {
3419        self.control_handle.shutdown();
3420        // Safety: drops once, never accessed again
3421        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3422    }
3423}
3424
3425impl fdomain_client::fidl::Responder for DebugDeleteProfileResponder {
3426    type ControlHandle = DebugControlHandle;
3427
3428    fn control_handle(&self) -> &DebugControlHandle {
3429        &self.control_handle
3430    }
3431
3432    fn drop_without_shutdown(mut self) {
3433        // Safety: drops once, never accessed again due to mem::forget
3434        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3435        // Prevent Drop from running (which would shut down the channel)
3436        std::mem::forget(self);
3437    }
3438}
3439
3440impl DebugDeleteProfileResponder {
3441    /// Sends a response to the FIDL transaction.
3442    ///
3443    /// Sets the channel to shutdown if an error occurs.
3444    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3445        let _result = self.send_raw(result);
3446        if _result.is_err() {
3447            self.control_handle.shutdown();
3448        }
3449        self.drop_without_shutdown();
3450        _result
3451    }
3452
3453    /// Similar to "send" but does not shutdown the channel if an error occurs.
3454    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3455        let _result = self.send_raw(result);
3456        self.drop_without_shutdown();
3457        _result
3458    }
3459
3460    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3461        self.control_handle
3462            .inner
3463            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3464                result,
3465                self.tx_id,
3466                0x54d9d4c9cf300a1e,
3467                fidl::encoding::DynamicFlags::empty(),
3468            )
3469    }
3470}
3471
3472#[must_use = "FIDL methods require a response to be sent"]
3473#[derive(Debug)]
3474pub struct DebugRecordReplayProfileResponder {
3475    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3476    tx_id: u32,
3477}
3478
3479/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3480/// if the responder is dropped without sending a response, so that the client
3481/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3482impl std::ops::Drop for DebugRecordReplayProfileResponder {
3483    fn drop(&mut self) {
3484        self.control_handle.shutdown();
3485        // Safety: drops once, never accessed again
3486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3487    }
3488}
3489
3490impl fdomain_client::fidl::Responder for DebugRecordReplayProfileResponder {
3491    type ControlHandle = DebugControlHandle;
3492
3493    fn control_handle(&self) -> &DebugControlHandle {
3494        &self.control_handle
3495    }
3496
3497    fn drop_without_shutdown(mut self) {
3498        // Safety: drops once, never accessed again due to mem::forget
3499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3500        // Prevent Drop from running (which would shut down the channel)
3501        std::mem::forget(self);
3502    }
3503}
3504
3505impl DebugRecordReplayProfileResponder {
3506    /// Sends a response to the FIDL transaction.
3507    ///
3508    /// Sets the channel to shutdown if an error occurs.
3509    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3510        let _result = self.send_raw(result);
3511        if _result.is_err() {
3512            self.control_handle.shutdown();
3513        }
3514        self.drop_without_shutdown();
3515        _result
3516    }
3517
3518    /// Similar to "send" but does not shutdown the channel if an error occurs.
3519    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3520        let _result = self.send_raw(result);
3521        self.drop_without_shutdown();
3522        _result
3523    }
3524
3525    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3526        self.control_handle
3527            .inner
3528            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3529                result,
3530                self.tx_id,
3531                0x1f9ca9da4b679591,
3532                fidl::encoding::DynamicFlags::empty(),
3533            )
3534    }
3535}
3536
3537#[must_use = "FIDL methods require a response to be sent"]
3538#[derive(Debug)]
3539pub struct DebugStopProfileTasksResponder {
3540    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
3541    tx_id: u32,
3542}
3543
3544/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
3545/// if the responder is dropped without sending a response, so that the client
3546/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3547impl std::ops::Drop for DebugStopProfileTasksResponder {
3548    fn drop(&mut self) {
3549        self.control_handle.shutdown();
3550        // Safety: drops once, never accessed again
3551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3552    }
3553}
3554
3555impl fdomain_client::fidl::Responder for DebugStopProfileTasksResponder {
3556    type ControlHandle = DebugControlHandle;
3557
3558    fn control_handle(&self) -> &DebugControlHandle {
3559        &self.control_handle
3560    }
3561
3562    fn drop_without_shutdown(mut self) {
3563        // Safety: drops once, never accessed again due to mem::forget
3564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3565        // Prevent Drop from running (which would shut down the channel)
3566        std::mem::forget(self);
3567    }
3568}
3569
3570impl DebugStopProfileTasksResponder {
3571    /// Sends a response to the FIDL transaction.
3572    ///
3573    /// Sets the channel to shutdown if an error occurs.
3574    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3575        let _result = self.send_raw(result);
3576        if _result.is_err() {
3577            self.control_handle.shutdown();
3578        }
3579        self.drop_without_shutdown();
3580        _result
3581    }
3582
3583    /// Similar to "send" but does not shutdown the channel if an error occurs.
3584    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3585        let _result = self.send_raw(result);
3586        self.drop_without_shutdown();
3587        _result
3588    }
3589
3590    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3591        self.control_handle
3592            .inner
3593            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3594                result,
3595                self.tx_id,
3596                0x1657b945dd629177,
3597                fidl::encoding::DynamicFlags::empty(),
3598            )
3599    }
3600}
3601
3602#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3603pub struct FileBackedVolumeProviderMarker;
3604
3605impl fdomain_client::fidl::ProtocolMarker for FileBackedVolumeProviderMarker {
3606    type Proxy = FileBackedVolumeProviderProxy;
3607    type RequestStream = FileBackedVolumeProviderRequestStream;
3608
3609    const DEBUG_NAME: &'static str = "fuchsia.fxfs.FileBackedVolumeProvider";
3610}
3611impl fdomain_client::fidl::DiscoverableProtocolMarker for FileBackedVolumeProviderMarker {}
3612
3613pub trait FileBackedVolumeProviderProxyInterface: Send + Sync {
3614    fn r#open(
3615        &self,
3616        parent_directory_token: fdomain_client::NullableHandle,
3617        name: &str,
3618        server_end: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
3619    ) -> Result<(), fidl::Error>;
3620}
3621
3622#[derive(Debug, Clone)]
3623pub struct FileBackedVolumeProviderProxy {
3624    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3625}
3626
3627impl fdomain_client::fidl::Proxy for FileBackedVolumeProviderProxy {
3628    type Protocol = FileBackedVolumeProviderMarker;
3629
3630    fn from_channel(inner: fdomain_client::Channel) -> Self {
3631        Self::new(inner)
3632    }
3633
3634    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3635        self.client.into_channel().map_err(|client| Self { client })
3636    }
3637
3638    fn as_channel(&self) -> &fdomain_client::Channel {
3639        self.client.as_channel()
3640    }
3641}
3642
3643impl FileBackedVolumeProviderProxy {
3644    /// Create a new Proxy for fuchsia.fxfs/FileBackedVolumeProvider.
3645    pub fn new(channel: fdomain_client::Channel) -> Self {
3646        let protocol_name =
3647            <FileBackedVolumeProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3648        Self { client: fidl::client::Client::new(channel, protocol_name) }
3649    }
3650
3651    /// Get a Stream of events from the remote end of the protocol.
3652    ///
3653    /// # Panics
3654    ///
3655    /// Panics if the event stream was already taken.
3656    pub fn take_event_stream(&self) -> FileBackedVolumeProviderEventStream {
3657        FileBackedVolumeProviderEventStream { event_receiver: self.client.take_event_receiver() }
3658    }
3659
3660    /// Opens a file as a block device and starts serving block requests.
3661    ///
3662    /// `name` must refer to an existing file in the directory represented by
3663    /// `parent_directory_token`.
3664    ///
3665    /// The block size of the device will match the underlying filesystem's block size.  If the
3666    /// file's size is not a multiple of the block size, the apparent size of the device will be
3667    /// rounded down.
3668    ///
3669    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
3670    /// directory connection must have the `MODIFY_DIRECTORY` right.
3671    ///
3672    /// Errors will be sent as an epitaph on `server_end`.
3673    pub fn r#open(
3674        &self,
3675        mut parent_directory_token: fdomain_client::NullableHandle,
3676        mut name: &str,
3677        mut server_end: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
3678    ) -> Result<(), fidl::Error> {
3679        FileBackedVolumeProviderProxyInterface::r#open(
3680            self,
3681            parent_directory_token,
3682            name,
3683            server_end,
3684        )
3685    }
3686}
3687
3688impl FileBackedVolumeProviderProxyInterface for FileBackedVolumeProviderProxy {
3689    fn r#open(
3690        &self,
3691        mut parent_directory_token: fdomain_client::NullableHandle,
3692        mut name: &str,
3693        mut server_end: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
3694    ) -> Result<(), fidl::Error> {
3695        self.client.send::<FileBackedVolumeProviderOpenRequest>(
3696            (parent_directory_token, name, server_end),
3697            0x67120b9fc9f319ee,
3698            fidl::encoding::DynamicFlags::empty(),
3699        )
3700    }
3701}
3702
3703pub struct FileBackedVolumeProviderEventStream {
3704    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3705}
3706
3707impl std::marker::Unpin for FileBackedVolumeProviderEventStream {}
3708
3709impl futures::stream::FusedStream for FileBackedVolumeProviderEventStream {
3710    fn is_terminated(&self) -> bool {
3711        self.event_receiver.is_terminated()
3712    }
3713}
3714
3715impl futures::Stream for FileBackedVolumeProviderEventStream {
3716    type Item = Result<FileBackedVolumeProviderEvent, fidl::Error>;
3717
3718    fn poll_next(
3719        mut self: std::pin::Pin<&mut Self>,
3720        cx: &mut std::task::Context<'_>,
3721    ) -> std::task::Poll<Option<Self::Item>> {
3722        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3723            &mut self.event_receiver,
3724            cx
3725        )?) {
3726            Some(buf) => std::task::Poll::Ready(Some(FileBackedVolumeProviderEvent::decode(buf))),
3727            None => std::task::Poll::Ready(None),
3728        }
3729    }
3730}
3731
3732#[derive(Debug)]
3733pub enum FileBackedVolumeProviderEvent {}
3734
3735impl FileBackedVolumeProviderEvent {
3736    /// Decodes a message buffer as a [`FileBackedVolumeProviderEvent`].
3737    fn decode(
3738        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3739    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
3740        let (bytes, _handles) = buf.split_mut();
3741        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3742        debug_assert_eq!(tx_header.tx_id, 0);
3743        match tx_header.ordinal {
3744            _ => Err(fidl::Error::UnknownOrdinal {
3745                ordinal: tx_header.ordinal,
3746                protocol_name: <FileBackedVolumeProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3747            })
3748        }
3749    }
3750}
3751
3752/// A Stream of incoming requests for fuchsia.fxfs/FileBackedVolumeProvider.
3753pub struct FileBackedVolumeProviderRequestStream {
3754    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3755    is_terminated: bool,
3756}
3757
3758impl std::marker::Unpin for FileBackedVolumeProviderRequestStream {}
3759
3760impl futures::stream::FusedStream for FileBackedVolumeProviderRequestStream {
3761    fn is_terminated(&self) -> bool {
3762        self.is_terminated
3763    }
3764}
3765
3766impl fdomain_client::fidl::RequestStream for FileBackedVolumeProviderRequestStream {
3767    type Protocol = FileBackedVolumeProviderMarker;
3768    type ControlHandle = FileBackedVolumeProviderControlHandle;
3769
3770    fn from_channel(channel: fdomain_client::Channel) -> Self {
3771        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3772    }
3773
3774    fn control_handle(&self) -> Self::ControlHandle {
3775        FileBackedVolumeProviderControlHandle { inner: self.inner.clone() }
3776    }
3777
3778    fn into_inner(
3779        self,
3780    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3781    {
3782        (self.inner, self.is_terminated)
3783    }
3784
3785    fn from_inner(
3786        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3787        is_terminated: bool,
3788    ) -> Self {
3789        Self { inner, is_terminated }
3790    }
3791}
3792
3793impl futures::Stream for FileBackedVolumeProviderRequestStream {
3794    type Item = Result<FileBackedVolumeProviderRequest, fidl::Error>;
3795
3796    fn poll_next(
3797        mut self: std::pin::Pin<&mut Self>,
3798        cx: &mut std::task::Context<'_>,
3799    ) -> std::task::Poll<Option<Self::Item>> {
3800        let this = &mut *self;
3801        if this.inner.check_shutdown(cx) {
3802            this.is_terminated = true;
3803            return std::task::Poll::Ready(None);
3804        }
3805        if this.is_terminated {
3806            panic!("polled FileBackedVolumeProviderRequestStream after completion");
3807        }
3808        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3809            |bytes, handles| {
3810                match this.inner.channel().read_etc(cx, bytes, handles) {
3811                    std::task::Poll::Ready(Ok(())) => {}
3812                    std::task::Poll::Pending => return std::task::Poll::Pending,
3813                    std::task::Poll::Ready(Err(None)) => {
3814                        this.is_terminated = true;
3815                        return std::task::Poll::Ready(None);
3816                    }
3817                    std::task::Poll::Ready(Err(Some(e))) => {
3818                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3819                            e.into(),
3820                        ))));
3821                    }
3822                }
3823
3824                // A message has been received from the channel
3825                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3826
3827                std::task::Poll::Ready(Some(match header.ordinal {
3828                0x67120b9fc9f319ee => {
3829                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3830                    let mut req = fidl::new_empty!(FileBackedVolumeProviderOpenRequest, fdomain_client::fidl::FDomainResourceDialect);
3831                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<FileBackedVolumeProviderOpenRequest>(&header, _body_bytes, handles, &mut req)?;
3832                    let control_handle = FileBackedVolumeProviderControlHandle {
3833                        inner: this.inner.clone(),
3834                    };
3835                    Ok(FileBackedVolumeProviderRequest::Open {parent_directory_token: req.parent_directory_token,
3836name: req.name,
3837server_end: req.server_end,
3838
3839                        control_handle,
3840                    })
3841                }
3842                _ => Err(fidl::Error::UnknownOrdinal {
3843                    ordinal: header.ordinal,
3844                    protocol_name: <FileBackedVolumeProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3845                }),
3846            }))
3847            },
3848        )
3849    }
3850}
3851
3852/// A protocol to serve the Volume protocol on a file-backed device.
3853#[derive(Debug)]
3854pub enum FileBackedVolumeProviderRequest {
3855    /// Opens a file as a block device and starts serving block requests.
3856    ///
3857    /// `name` must refer to an existing file in the directory represented by
3858    /// `parent_directory_token`.
3859    ///
3860    /// The block size of the device will match the underlying filesystem's block size.  If the
3861    /// file's size is not a multiple of the block size, the apparent size of the device will be
3862    /// rounded down.
3863    ///
3864    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
3865    /// directory connection must have the `MODIFY_DIRECTORY` right.
3866    ///
3867    /// Errors will be sent as an epitaph on `server_end`.
3868    Open {
3869        parent_directory_token: fdomain_client::NullableHandle,
3870        name: String,
3871        server_end: fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
3872        control_handle: FileBackedVolumeProviderControlHandle,
3873    },
3874}
3875
3876impl FileBackedVolumeProviderRequest {
3877    #[allow(irrefutable_let_patterns)]
3878    pub fn into_open(
3879        self,
3880    ) -> Option<(
3881        fdomain_client::NullableHandle,
3882        String,
3883        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
3884        FileBackedVolumeProviderControlHandle,
3885    )> {
3886        if let FileBackedVolumeProviderRequest::Open {
3887            parent_directory_token,
3888            name,
3889            server_end,
3890            control_handle,
3891        } = self
3892        {
3893            Some((parent_directory_token, name, server_end, control_handle))
3894        } else {
3895            None
3896        }
3897    }
3898
3899    /// Name of the method defined in FIDL
3900    pub fn method_name(&self) -> &'static str {
3901        match *self {
3902            FileBackedVolumeProviderRequest::Open { .. } => "open",
3903        }
3904    }
3905}
3906
3907#[derive(Debug, Clone)]
3908pub struct FileBackedVolumeProviderControlHandle {
3909    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3910}
3911
3912impl fdomain_client::fidl::ControlHandle for FileBackedVolumeProviderControlHandle {
3913    fn shutdown(&self) {
3914        self.inner.shutdown()
3915    }
3916
3917    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3918        self.inner.shutdown_with_epitaph(status)
3919    }
3920
3921    fn is_closed(&self) -> bool {
3922        self.inner.channel().is_closed()
3923    }
3924    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3925        self.inner.channel().on_closed()
3926    }
3927}
3928
3929impl FileBackedVolumeProviderControlHandle {}
3930
3931#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3932pub struct ProjectIdMarker;
3933
3934impl fdomain_client::fidl::ProtocolMarker for ProjectIdMarker {
3935    type Proxy = ProjectIdProxy;
3936    type RequestStream = ProjectIdRequestStream;
3937
3938    const DEBUG_NAME: &'static str = "fuchsia.fxfs.ProjectId";
3939}
3940impl fdomain_client::fidl::DiscoverableProtocolMarker for ProjectIdMarker {}
3941pub type ProjectIdSetLimitResult = Result<(), i32>;
3942pub type ProjectIdClearResult = Result<(), i32>;
3943pub type ProjectIdSetForNodeResult = Result<(), i32>;
3944pub type ProjectIdGetForNodeResult = Result<u64, i32>;
3945pub type ProjectIdClearForNodeResult = Result<(), i32>;
3946pub type ProjectIdListResult = Result<(Vec<u64>, Option<Box<ProjectIterToken>>), i32>;
3947pub type ProjectIdInfoResult = Result<(BytesAndNodes, BytesAndNodes), i32>;
3948
3949pub trait ProjectIdProxyInterface: Send + Sync {
3950    type SetLimitResponseFut: std::future::Future<Output = Result<ProjectIdSetLimitResult, fidl::Error>>
3951        + Send;
3952    fn r#set_limit(&self, project_id: u64, bytes: u64, nodes: u64) -> Self::SetLimitResponseFut;
3953    type ClearResponseFut: std::future::Future<Output = Result<ProjectIdClearResult, fidl::Error>>
3954        + Send;
3955    fn r#clear(&self, project_id: u64) -> Self::ClearResponseFut;
3956    type SetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdSetForNodeResult, fidl::Error>>
3957        + Send;
3958    fn r#set_for_node(&self, node_id: u64, project_id: u64) -> Self::SetForNodeResponseFut;
3959    type GetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdGetForNodeResult, fidl::Error>>
3960        + Send;
3961    fn r#get_for_node(&self, node_id: u64) -> Self::GetForNodeResponseFut;
3962    type ClearForNodeResponseFut: std::future::Future<Output = Result<ProjectIdClearForNodeResult, fidl::Error>>
3963        + Send;
3964    fn r#clear_for_node(&self, node_id: u64) -> Self::ClearForNodeResponseFut;
3965    type ListResponseFut: std::future::Future<Output = Result<ProjectIdListResult, fidl::Error>>
3966        + Send;
3967    fn r#list(&self, token: Option<&ProjectIterToken>) -> Self::ListResponseFut;
3968    type InfoResponseFut: std::future::Future<Output = Result<ProjectIdInfoResult, fidl::Error>>
3969        + Send;
3970    fn r#info(&self, project_id: u64) -> Self::InfoResponseFut;
3971}
3972
3973#[derive(Debug, Clone)]
3974pub struct ProjectIdProxy {
3975    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3976}
3977
3978impl fdomain_client::fidl::Proxy for ProjectIdProxy {
3979    type Protocol = ProjectIdMarker;
3980
3981    fn from_channel(inner: fdomain_client::Channel) -> Self {
3982        Self::new(inner)
3983    }
3984
3985    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3986        self.client.into_channel().map_err(|client| Self { client })
3987    }
3988
3989    fn as_channel(&self) -> &fdomain_client::Channel {
3990        self.client.as_channel()
3991    }
3992}
3993
3994impl ProjectIdProxy {
3995    /// Create a new Proxy for fuchsia.fxfs/ProjectId.
3996    pub fn new(channel: fdomain_client::Channel) -> Self {
3997        let protocol_name = <ProjectIdMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3998        Self { client: fidl::client::Client::new(channel, protocol_name) }
3999    }
4000
4001    /// Get a Stream of events from the remote end of the protocol.
4002    ///
4003    /// # Panics
4004    ///
4005    /// Panics if the event stream was already taken.
4006    pub fn take_event_stream(&self) -> ProjectIdEventStream {
4007        ProjectIdEventStream { event_receiver: self.client.take_event_receiver() }
4008    }
4009
4010    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
4011    /// current usage is accepted but may in the future prevent further increases. Returns
4012    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4013    pub fn r#set_limit(
4014        &self,
4015        mut project_id: u64,
4016        mut bytes: u64,
4017        mut nodes: u64,
4018    ) -> fidl::client::QueryResponseFut<
4019        ProjectIdSetLimitResult,
4020        fdomain_client::fidl::FDomainResourceDialect,
4021    > {
4022        ProjectIdProxyInterface::r#set_limit(self, project_id, bytes, nodes)
4023    }
4024
4025    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
4026    /// currently tracked. It will succeed even if the project is still in use more by one or more
4027    /// nodes.
4028    pub fn r#clear(
4029        &self,
4030        mut project_id: u64,
4031    ) -> fidl::client::QueryResponseFut<
4032        ProjectIdClearResult,
4033        fdomain_client::fidl::FDomainResourceDialect,
4034    > {
4035        ProjectIdProxyInterface::r#clear(self, project_id)
4036    }
4037
4038    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
4039    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4040    pub fn r#set_for_node(
4041        &self,
4042        mut node_id: u64,
4043        mut project_id: u64,
4044    ) -> fidl::client::QueryResponseFut<
4045        ProjectIdSetForNodeResult,
4046        fdomain_client::fidl::FDomainResourceDialect,
4047    > {
4048        ProjectIdProxyInterface::r#set_for_node(self, node_id, project_id)
4049    }
4050
4051    /// Get the project id based on a given node_id from a GetAttrs call.This will return
4052    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
4053    /// currently applied.
4054    pub fn r#get_for_node(
4055        &self,
4056        mut node_id: u64,
4057    ) -> fidl::client::QueryResponseFut<
4058        ProjectIdGetForNodeResult,
4059        fdomain_client::fidl::FDomainResourceDialect,
4060    > {
4061        ProjectIdProxyInterface::r#get_for_node(self, node_id)
4062    }
4063
4064    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
4065    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
4066    /// have no project id applied to it.
4067    pub fn r#clear_for_node(
4068        &self,
4069        mut node_id: u64,
4070    ) -> fidl::client::QueryResponseFut<
4071        ProjectIdClearForNodeResult,
4072        fdomain_client::fidl::FDomainResourceDialect,
4073    > {
4074        ProjectIdProxyInterface::r#clear_for_node(self, node_id)
4075    }
4076
4077    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
4078    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
4079    /// previously provided `next_token` the iteration continues where it left off. If there are
4080    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
4081    pub fn r#list(
4082        &self,
4083        mut token: Option<&ProjectIterToken>,
4084    ) -> fidl::client::QueryResponseFut<
4085        ProjectIdListResult,
4086        fdomain_client::fidl::FDomainResourceDialect,
4087    > {
4088        ProjectIdProxyInterface::r#list(self, token)
4089    }
4090
4091    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
4092    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
4093    pub fn r#info(
4094        &self,
4095        mut project_id: u64,
4096    ) -> fidl::client::QueryResponseFut<
4097        ProjectIdInfoResult,
4098        fdomain_client::fidl::FDomainResourceDialect,
4099    > {
4100        ProjectIdProxyInterface::r#info(self, project_id)
4101    }
4102}
4103
4104impl ProjectIdProxyInterface for ProjectIdProxy {
4105    type SetLimitResponseFut = fidl::client::QueryResponseFut<
4106        ProjectIdSetLimitResult,
4107        fdomain_client::fidl::FDomainResourceDialect,
4108    >;
4109    fn r#set_limit(
4110        &self,
4111        mut project_id: u64,
4112        mut bytes: u64,
4113        mut nodes: u64,
4114    ) -> Self::SetLimitResponseFut {
4115        fn _decode(
4116            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4117        ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
4118            let _response = fidl::client::decode_transaction_body::<
4119                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4120                fdomain_client::fidl::FDomainResourceDialect,
4121                0x20b0fc1e0413876f,
4122            >(_buf?)?;
4123            Ok(_response.map(|x| x))
4124        }
4125        self.client.send_query_and_decode::<ProjectIdSetLimitRequest, ProjectIdSetLimitResult>(
4126            (project_id, bytes, nodes),
4127            0x20b0fc1e0413876f,
4128            fidl::encoding::DynamicFlags::empty(),
4129            _decode,
4130        )
4131    }
4132
4133    type ClearResponseFut = fidl::client::QueryResponseFut<
4134        ProjectIdClearResult,
4135        fdomain_client::fidl::FDomainResourceDialect,
4136    >;
4137    fn r#clear(&self, mut project_id: u64) -> Self::ClearResponseFut {
4138        fn _decode(
4139            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4140        ) -> Result<ProjectIdClearResult, fidl::Error> {
4141            let _response = fidl::client::decode_transaction_body::<
4142                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4143                fdomain_client::fidl::FDomainResourceDialect,
4144                0x165b5f1e707863c1,
4145            >(_buf?)?;
4146            Ok(_response.map(|x| x))
4147        }
4148        self.client.send_query_and_decode::<ProjectIdClearRequest, ProjectIdClearResult>(
4149            (project_id,),
4150            0x165b5f1e707863c1,
4151            fidl::encoding::DynamicFlags::empty(),
4152            _decode,
4153        )
4154    }
4155
4156    type SetForNodeResponseFut = fidl::client::QueryResponseFut<
4157        ProjectIdSetForNodeResult,
4158        fdomain_client::fidl::FDomainResourceDialect,
4159    >;
4160    fn r#set_for_node(&self, mut node_id: u64, mut project_id: u64) -> Self::SetForNodeResponseFut {
4161        fn _decode(
4162            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4163        ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
4164            let _response = fidl::client::decode_transaction_body::<
4165                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4166                fdomain_client::fidl::FDomainResourceDialect,
4167                0x4d7a8442dc58324c,
4168            >(_buf?)?;
4169            Ok(_response.map(|x| x))
4170        }
4171        self.client.send_query_and_decode::<ProjectIdSetForNodeRequest, ProjectIdSetForNodeResult>(
4172            (node_id, project_id),
4173            0x4d7a8442dc58324c,
4174            fidl::encoding::DynamicFlags::empty(),
4175            _decode,
4176        )
4177    }
4178
4179    type GetForNodeResponseFut = fidl::client::QueryResponseFut<
4180        ProjectIdGetForNodeResult,
4181        fdomain_client::fidl::FDomainResourceDialect,
4182    >;
4183    fn r#get_for_node(&self, mut node_id: u64) -> Self::GetForNodeResponseFut {
4184        fn _decode(
4185            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4186        ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
4187            let _response = fidl::client::decode_transaction_body::<
4188                fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
4189                fdomain_client::fidl::FDomainResourceDialect,
4190                0x644073bdf2542573,
4191            >(_buf?)?;
4192            Ok(_response.map(|x| x.project_id))
4193        }
4194        self.client.send_query_and_decode::<ProjectIdGetForNodeRequest, ProjectIdGetForNodeResult>(
4195            (node_id,),
4196            0x644073bdf2542573,
4197            fidl::encoding::DynamicFlags::empty(),
4198            _decode,
4199        )
4200    }
4201
4202    type ClearForNodeResponseFut = fidl::client::QueryResponseFut<
4203        ProjectIdClearForNodeResult,
4204        fdomain_client::fidl::FDomainResourceDialect,
4205    >;
4206    fn r#clear_for_node(&self, mut node_id: u64) -> Self::ClearForNodeResponseFut {
4207        fn _decode(
4208            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4209        ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
4210            let _response = fidl::client::decode_transaction_body::<
4211                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4212                fdomain_client::fidl::FDomainResourceDialect,
4213                0x3f2ca287bbfe6a62,
4214            >(_buf?)?;
4215            Ok(_response.map(|x| x))
4216        }
4217        self.client
4218            .send_query_and_decode::<ProjectIdClearForNodeRequest, ProjectIdClearForNodeResult>(
4219                (node_id,),
4220                0x3f2ca287bbfe6a62,
4221                fidl::encoding::DynamicFlags::empty(),
4222                _decode,
4223            )
4224    }
4225
4226    type ListResponseFut = fidl::client::QueryResponseFut<
4227        ProjectIdListResult,
4228        fdomain_client::fidl::FDomainResourceDialect,
4229    >;
4230    fn r#list(&self, mut token: Option<&ProjectIterToken>) -> Self::ListResponseFut {
4231        fn _decode(
4232            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4233        ) -> Result<ProjectIdListResult, fidl::Error> {
4234            let _response = fidl::client::decode_transaction_body::<
4235                fidl::encoding::ResultType<ProjectIdListResponse, i32>,
4236                fdomain_client::fidl::FDomainResourceDialect,
4237                0x5505f95a36d522cc,
4238            >(_buf?)?;
4239            Ok(_response.map(|x| (x.entries, x.next_token)))
4240        }
4241        self.client.send_query_and_decode::<ProjectIdListRequest, ProjectIdListResult>(
4242            (token,),
4243            0x5505f95a36d522cc,
4244            fidl::encoding::DynamicFlags::empty(),
4245            _decode,
4246        )
4247    }
4248
4249    type InfoResponseFut = fidl::client::QueryResponseFut<
4250        ProjectIdInfoResult,
4251        fdomain_client::fidl::FDomainResourceDialect,
4252    >;
4253    fn r#info(&self, mut project_id: u64) -> Self::InfoResponseFut {
4254        fn _decode(
4255            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4256        ) -> Result<ProjectIdInfoResult, fidl::Error> {
4257            let _response = fidl::client::decode_transaction_body::<
4258                fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
4259                fdomain_client::fidl::FDomainResourceDialect,
4260                0x51b47743c9e2d1ab,
4261            >(_buf?)?;
4262            Ok(_response.map(|x| (x.limit, x.usage)))
4263        }
4264        self.client.send_query_and_decode::<ProjectIdInfoRequest, ProjectIdInfoResult>(
4265            (project_id,),
4266            0x51b47743c9e2d1ab,
4267            fidl::encoding::DynamicFlags::empty(),
4268            _decode,
4269        )
4270    }
4271}
4272
4273pub struct ProjectIdEventStream {
4274    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4275}
4276
4277impl std::marker::Unpin for ProjectIdEventStream {}
4278
4279impl futures::stream::FusedStream for ProjectIdEventStream {
4280    fn is_terminated(&self) -> bool {
4281        self.event_receiver.is_terminated()
4282    }
4283}
4284
4285impl futures::Stream for ProjectIdEventStream {
4286    type Item = Result<ProjectIdEvent, fidl::Error>;
4287
4288    fn poll_next(
4289        mut self: std::pin::Pin<&mut Self>,
4290        cx: &mut std::task::Context<'_>,
4291    ) -> std::task::Poll<Option<Self::Item>> {
4292        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4293            &mut self.event_receiver,
4294            cx
4295        )?) {
4296            Some(buf) => std::task::Poll::Ready(Some(ProjectIdEvent::decode(buf))),
4297            None => std::task::Poll::Ready(None),
4298        }
4299    }
4300}
4301
4302#[derive(Debug)]
4303pub enum ProjectIdEvent {}
4304
4305impl ProjectIdEvent {
4306    /// Decodes a message buffer as a [`ProjectIdEvent`].
4307    fn decode(
4308        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4309    ) -> Result<ProjectIdEvent, fidl::Error> {
4310        let (bytes, _handles) = buf.split_mut();
4311        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4312        debug_assert_eq!(tx_header.tx_id, 0);
4313        match tx_header.ordinal {
4314            _ => Err(fidl::Error::UnknownOrdinal {
4315                ordinal: tx_header.ordinal,
4316                protocol_name:
4317                    <ProjectIdMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4318            }),
4319        }
4320    }
4321}
4322
4323/// A Stream of incoming requests for fuchsia.fxfs/ProjectId.
4324pub struct ProjectIdRequestStream {
4325    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4326    is_terminated: bool,
4327}
4328
4329impl std::marker::Unpin for ProjectIdRequestStream {}
4330
4331impl futures::stream::FusedStream for ProjectIdRequestStream {
4332    fn is_terminated(&self) -> bool {
4333        self.is_terminated
4334    }
4335}
4336
4337impl fdomain_client::fidl::RequestStream for ProjectIdRequestStream {
4338    type Protocol = ProjectIdMarker;
4339    type ControlHandle = ProjectIdControlHandle;
4340
4341    fn from_channel(channel: fdomain_client::Channel) -> Self {
4342        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4343    }
4344
4345    fn control_handle(&self) -> Self::ControlHandle {
4346        ProjectIdControlHandle { inner: self.inner.clone() }
4347    }
4348
4349    fn into_inner(
4350        self,
4351    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4352    {
4353        (self.inner, self.is_terminated)
4354    }
4355
4356    fn from_inner(
4357        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4358        is_terminated: bool,
4359    ) -> Self {
4360        Self { inner, is_terminated }
4361    }
4362}
4363
4364impl futures::Stream for ProjectIdRequestStream {
4365    type Item = Result<ProjectIdRequest, fidl::Error>;
4366
4367    fn poll_next(
4368        mut self: std::pin::Pin<&mut Self>,
4369        cx: &mut std::task::Context<'_>,
4370    ) -> std::task::Poll<Option<Self::Item>> {
4371        let this = &mut *self;
4372        if this.inner.check_shutdown(cx) {
4373            this.is_terminated = true;
4374            return std::task::Poll::Ready(None);
4375        }
4376        if this.is_terminated {
4377            panic!("polled ProjectIdRequestStream after completion");
4378        }
4379        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
4380            |bytes, handles| {
4381                match this.inner.channel().read_etc(cx, bytes, handles) {
4382                    std::task::Poll::Ready(Ok(())) => {}
4383                    std::task::Poll::Pending => return std::task::Poll::Pending,
4384                    std::task::Poll::Ready(Err(None)) => {
4385                        this.is_terminated = true;
4386                        return std::task::Poll::Ready(None);
4387                    }
4388                    std::task::Poll::Ready(Err(Some(e))) => {
4389                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4390                            e.into(),
4391                        ))));
4392                    }
4393                }
4394
4395                // A message has been received from the channel
4396                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4397
4398                std::task::Poll::Ready(Some(match header.ordinal {
4399                    0x20b0fc1e0413876f => {
4400                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4401                        let mut req = fidl::new_empty!(
4402                            ProjectIdSetLimitRequest,
4403                            fdomain_client::fidl::FDomainResourceDialect
4404                        );
4405                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdSetLimitRequest>(&header, _body_bytes, handles, &mut req)?;
4406                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4407                        Ok(ProjectIdRequest::SetLimit {
4408                            project_id: req.project_id,
4409                            bytes: req.bytes,
4410                            nodes: req.nodes,
4411
4412                            responder: ProjectIdSetLimitResponder {
4413                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4414                                tx_id: header.tx_id,
4415                            },
4416                        })
4417                    }
4418                    0x165b5f1e707863c1 => {
4419                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4420                        let mut req = fidl::new_empty!(
4421                            ProjectIdClearRequest,
4422                            fdomain_client::fidl::FDomainResourceDialect
4423                        );
4424                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdClearRequest>(&header, _body_bytes, handles, &mut req)?;
4425                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4426                        Ok(ProjectIdRequest::Clear {
4427                            project_id: req.project_id,
4428
4429                            responder: ProjectIdClearResponder {
4430                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4431                                tx_id: header.tx_id,
4432                            },
4433                        })
4434                    }
4435                    0x4d7a8442dc58324c => {
4436                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4437                        let mut req = fidl::new_empty!(
4438                            ProjectIdSetForNodeRequest,
4439                            fdomain_client::fidl::FDomainResourceDialect
4440                        );
4441                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdSetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
4442                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4443                        Ok(ProjectIdRequest::SetForNode {
4444                            node_id: req.node_id,
4445                            project_id: req.project_id,
4446
4447                            responder: ProjectIdSetForNodeResponder {
4448                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4449                                tx_id: header.tx_id,
4450                            },
4451                        })
4452                    }
4453                    0x644073bdf2542573 => {
4454                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4455                        let mut req = fidl::new_empty!(
4456                            ProjectIdGetForNodeRequest,
4457                            fdomain_client::fidl::FDomainResourceDialect
4458                        );
4459                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdGetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
4460                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4461                        Ok(ProjectIdRequest::GetForNode {
4462                            node_id: req.node_id,
4463
4464                            responder: ProjectIdGetForNodeResponder {
4465                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4466                                tx_id: header.tx_id,
4467                            },
4468                        })
4469                    }
4470                    0x3f2ca287bbfe6a62 => {
4471                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4472                        let mut req = fidl::new_empty!(
4473                            ProjectIdClearForNodeRequest,
4474                            fdomain_client::fidl::FDomainResourceDialect
4475                        );
4476                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdClearForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
4477                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4478                        Ok(ProjectIdRequest::ClearForNode {
4479                            node_id: req.node_id,
4480
4481                            responder: ProjectIdClearForNodeResponder {
4482                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4483                                tx_id: header.tx_id,
4484                            },
4485                        })
4486                    }
4487                    0x5505f95a36d522cc => {
4488                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4489                        let mut req = fidl::new_empty!(
4490                            ProjectIdListRequest,
4491                            fdomain_client::fidl::FDomainResourceDialect
4492                        );
4493                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdListRequest>(&header, _body_bytes, handles, &mut req)?;
4494                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4495                        Ok(ProjectIdRequest::List {
4496                            token: req.token,
4497
4498                            responder: ProjectIdListResponder {
4499                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4500                                tx_id: header.tx_id,
4501                            },
4502                        })
4503                    }
4504                    0x51b47743c9e2d1ab => {
4505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4506                        let mut req = fidl::new_empty!(
4507                            ProjectIdInfoRequest,
4508                            fdomain_client::fidl::FDomainResourceDialect
4509                        );
4510                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProjectIdInfoRequest>(&header, _body_bytes, handles, &mut req)?;
4511                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
4512                        Ok(ProjectIdRequest::Info {
4513                            project_id: req.project_id,
4514
4515                            responder: ProjectIdInfoResponder {
4516                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4517                                tx_id: header.tx_id,
4518                            },
4519                        })
4520                    }
4521                    _ => Err(fidl::Error::UnknownOrdinal {
4522                        ordinal: header.ordinal,
4523                        protocol_name:
4524                            <ProjectIdMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4525                    }),
4526                }))
4527            },
4528        )
4529    }
4530}
4531
4532#[derive(Debug)]
4533pub enum ProjectIdRequest {
4534    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
4535    /// current usage is accepted but may in the future prevent further increases. Returns
4536    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4537    SetLimit { project_id: u64, bytes: u64, nodes: u64, responder: ProjectIdSetLimitResponder },
4538    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
4539    /// currently tracked. It will succeed even if the project is still in use more by one or more
4540    /// nodes.
4541    Clear { project_id: u64, responder: ProjectIdClearResponder },
4542    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
4543    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
4544    SetForNode { node_id: u64, project_id: u64, responder: ProjectIdSetForNodeResponder },
4545    /// Get the project id based on a given node_id from a GetAttrs call.This will return
4546    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
4547    /// currently applied.
4548    GetForNode { node_id: u64, responder: ProjectIdGetForNodeResponder },
4549    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
4550    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
4551    /// have no project id applied to it.
4552    ClearForNode { node_id: u64, responder: ProjectIdClearForNodeResponder },
4553    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
4554    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
4555    /// previously provided `next_token` the iteration continues where it left off. If there are
4556    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
4557    List { token: Option<Box<ProjectIterToken>>, responder: ProjectIdListResponder },
4558    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
4559    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
4560    Info { project_id: u64, responder: ProjectIdInfoResponder },
4561}
4562
4563impl ProjectIdRequest {
4564    #[allow(irrefutable_let_patterns)]
4565    pub fn into_set_limit(self) -> Option<(u64, u64, u64, ProjectIdSetLimitResponder)> {
4566        if let ProjectIdRequest::SetLimit { project_id, bytes, nodes, responder } = self {
4567            Some((project_id, bytes, nodes, responder))
4568        } else {
4569            None
4570        }
4571    }
4572
4573    #[allow(irrefutable_let_patterns)]
4574    pub fn into_clear(self) -> Option<(u64, ProjectIdClearResponder)> {
4575        if let ProjectIdRequest::Clear { project_id, responder } = self {
4576            Some((project_id, responder))
4577        } else {
4578            None
4579        }
4580    }
4581
4582    #[allow(irrefutable_let_patterns)]
4583    pub fn into_set_for_node(self) -> Option<(u64, u64, ProjectIdSetForNodeResponder)> {
4584        if let ProjectIdRequest::SetForNode { node_id, project_id, responder } = self {
4585            Some((node_id, project_id, responder))
4586        } else {
4587            None
4588        }
4589    }
4590
4591    #[allow(irrefutable_let_patterns)]
4592    pub fn into_get_for_node(self) -> Option<(u64, ProjectIdGetForNodeResponder)> {
4593        if let ProjectIdRequest::GetForNode { node_id, responder } = self {
4594            Some((node_id, responder))
4595        } else {
4596            None
4597        }
4598    }
4599
4600    #[allow(irrefutable_let_patterns)]
4601    pub fn into_clear_for_node(self) -> Option<(u64, ProjectIdClearForNodeResponder)> {
4602        if let ProjectIdRequest::ClearForNode { node_id, responder } = self {
4603            Some((node_id, responder))
4604        } else {
4605            None
4606        }
4607    }
4608
4609    #[allow(irrefutable_let_patterns)]
4610    pub fn into_list(self) -> Option<(Option<Box<ProjectIterToken>>, ProjectIdListResponder)> {
4611        if let ProjectIdRequest::List { token, responder } = self {
4612            Some((token, responder))
4613        } else {
4614            None
4615        }
4616    }
4617
4618    #[allow(irrefutable_let_patterns)]
4619    pub fn into_info(self) -> Option<(u64, ProjectIdInfoResponder)> {
4620        if let ProjectIdRequest::Info { project_id, responder } = self {
4621            Some((project_id, responder))
4622        } else {
4623            None
4624        }
4625    }
4626
4627    /// Name of the method defined in FIDL
4628    pub fn method_name(&self) -> &'static str {
4629        match *self {
4630            ProjectIdRequest::SetLimit { .. } => "set_limit",
4631            ProjectIdRequest::Clear { .. } => "clear",
4632            ProjectIdRequest::SetForNode { .. } => "set_for_node",
4633            ProjectIdRequest::GetForNode { .. } => "get_for_node",
4634            ProjectIdRequest::ClearForNode { .. } => "clear_for_node",
4635            ProjectIdRequest::List { .. } => "list",
4636            ProjectIdRequest::Info { .. } => "info",
4637        }
4638    }
4639}
4640
4641#[derive(Debug, Clone)]
4642pub struct ProjectIdControlHandle {
4643    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4644}
4645
4646impl fdomain_client::fidl::ControlHandle for ProjectIdControlHandle {
4647    fn shutdown(&self) {
4648        self.inner.shutdown()
4649    }
4650
4651    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4652        self.inner.shutdown_with_epitaph(status)
4653    }
4654
4655    fn is_closed(&self) -> bool {
4656        self.inner.channel().is_closed()
4657    }
4658    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4659        self.inner.channel().on_closed()
4660    }
4661}
4662
4663impl ProjectIdControlHandle {}
4664
4665#[must_use = "FIDL methods require a response to be sent"]
4666#[derive(Debug)]
4667pub struct ProjectIdSetLimitResponder {
4668    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4669    tx_id: u32,
4670}
4671
4672/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4673/// if the responder is dropped without sending a response, so that the client
4674/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4675impl std::ops::Drop for ProjectIdSetLimitResponder {
4676    fn drop(&mut self) {
4677        self.control_handle.shutdown();
4678        // Safety: drops once, never accessed again
4679        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4680    }
4681}
4682
4683impl fdomain_client::fidl::Responder for ProjectIdSetLimitResponder {
4684    type ControlHandle = ProjectIdControlHandle;
4685
4686    fn control_handle(&self) -> &ProjectIdControlHandle {
4687        &self.control_handle
4688    }
4689
4690    fn drop_without_shutdown(mut self) {
4691        // Safety: drops once, never accessed again due to mem::forget
4692        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4693        // Prevent Drop from running (which would shut down the channel)
4694        std::mem::forget(self);
4695    }
4696}
4697
4698impl ProjectIdSetLimitResponder {
4699    /// Sends a response to the FIDL transaction.
4700    ///
4701    /// Sets the channel to shutdown if an error occurs.
4702    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4703        let _result = self.send_raw(result);
4704        if _result.is_err() {
4705            self.control_handle.shutdown();
4706        }
4707        self.drop_without_shutdown();
4708        _result
4709    }
4710
4711    /// Similar to "send" but does not shutdown the channel if an error occurs.
4712    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4713        let _result = self.send_raw(result);
4714        self.drop_without_shutdown();
4715        _result
4716    }
4717
4718    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4719        self.control_handle
4720            .inner
4721            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4722                result,
4723                self.tx_id,
4724                0x20b0fc1e0413876f,
4725                fidl::encoding::DynamicFlags::empty(),
4726            )
4727    }
4728}
4729
4730#[must_use = "FIDL methods require a response to be sent"]
4731#[derive(Debug)]
4732pub struct ProjectIdClearResponder {
4733    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4734    tx_id: u32,
4735}
4736
4737/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4738/// if the responder is dropped without sending a response, so that the client
4739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4740impl std::ops::Drop for ProjectIdClearResponder {
4741    fn drop(&mut self) {
4742        self.control_handle.shutdown();
4743        // Safety: drops once, never accessed again
4744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4745    }
4746}
4747
4748impl fdomain_client::fidl::Responder for ProjectIdClearResponder {
4749    type ControlHandle = ProjectIdControlHandle;
4750
4751    fn control_handle(&self) -> &ProjectIdControlHandle {
4752        &self.control_handle
4753    }
4754
4755    fn drop_without_shutdown(mut self) {
4756        // Safety: drops once, never accessed again due to mem::forget
4757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4758        // Prevent Drop from running (which would shut down the channel)
4759        std::mem::forget(self);
4760    }
4761}
4762
4763impl ProjectIdClearResponder {
4764    /// Sends a response to the FIDL transaction.
4765    ///
4766    /// Sets the channel to shutdown if an error occurs.
4767    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4768        let _result = self.send_raw(result);
4769        if _result.is_err() {
4770            self.control_handle.shutdown();
4771        }
4772        self.drop_without_shutdown();
4773        _result
4774    }
4775
4776    /// Similar to "send" but does not shutdown the channel if an error occurs.
4777    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4778        let _result = self.send_raw(result);
4779        self.drop_without_shutdown();
4780        _result
4781    }
4782
4783    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4784        self.control_handle
4785            .inner
4786            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4787                result,
4788                self.tx_id,
4789                0x165b5f1e707863c1,
4790                fidl::encoding::DynamicFlags::empty(),
4791            )
4792    }
4793}
4794
4795#[must_use = "FIDL methods require a response to be sent"]
4796#[derive(Debug)]
4797pub struct ProjectIdSetForNodeResponder {
4798    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4799    tx_id: u32,
4800}
4801
4802/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4803/// if the responder is dropped without sending a response, so that the client
4804/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4805impl std::ops::Drop for ProjectIdSetForNodeResponder {
4806    fn drop(&mut self) {
4807        self.control_handle.shutdown();
4808        // Safety: drops once, never accessed again
4809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4810    }
4811}
4812
4813impl fdomain_client::fidl::Responder for ProjectIdSetForNodeResponder {
4814    type ControlHandle = ProjectIdControlHandle;
4815
4816    fn control_handle(&self) -> &ProjectIdControlHandle {
4817        &self.control_handle
4818    }
4819
4820    fn drop_without_shutdown(mut self) {
4821        // Safety: drops once, never accessed again due to mem::forget
4822        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4823        // Prevent Drop from running (which would shut down the channel)
4824        std::mem::forget(self);
4825    }
4826}
4827
4828impl ProjectIdSetForNodeResponder {
4829    /// Sends a response to the FIDL transaction.
4830    ///
4831    /// Sets the channel to shutdown if an error occurs.
4832    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4833        let _result = self.send_raw(result);
4834        if _result.is_err() {
4835            self.control_handle.shutdown();
4836        }
4837        self.drop_without_shutdown();
4838        _result
4839    }
4840
4841    /// Similar to "send" but does not shutdown the channel if an error occurs.
4842    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4843        let _result = self.send_raw(result);
4844        self.drop_without_shutdown();
4845        _result
4846    }
4847
4848    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4849        self.control_handle
4850            .inner
4851            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4852                result,
4853                self.tx_id,
4854                0x4d7a8442dc58324c,
4855                fidl::encoding::DynamicFlags::empty(),
4856            )
4857    }
4858}
4859
4860#[must_use = "FIDL methods require a response to be sent"]
4861#[derive(Debug)]
4862pub struct ProjectIdGetForNodeResponder {
4863    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4864    tx_id: u32,
4865}
4866
4867/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4868/// if the responder is dropped without sending a response, so that the client
4869/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4870impl std::ops::Drop for ProjectIdGetForNodeResponder {
4871    fn drop(&mut self) {
4872        self.control_handle.shutdown();
4873        // Safety: drops once, never accessed again
4874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4875    }
4876}
4877
4878impl fdomain_client::fidl::Responder for ProjectIdGetForNodeResponder {
4879    type ControlHandle = ProjectIdControlHandle;
4880
4881    fn control_handle(&self) -> &ProjectIdControlHandle {
4882        &self.control_handle
4883    }
4884
4885    fn drop_without_shutdown(mut self) {
4886        // Safety: drops once, never accessed again due to mem::forget
4887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4888        // Prevent Drop from running (which would shut down the channel)
4889        std::mem::forget(self);
4890    }
4891}
4892
4893impl ProjectIdGetForNodeResponder {
4894    /// Sends a response to the FIDL transaction.
4895    ///
4896    /// Sets the channel to shutdown if an error occurs.
4897    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
4898        let _result = self.send_raw(result);
4899        if _result.is_err() {
4900            self.control_handle.shutdown();
4901        }
4902        self.drop_without_shutdown();
4903        _result
4904    }
4905
4906    /// Similar to "send" but does not shutdown the channel if an error occurs.
4907    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
4908        let _result = self.send_raw(result);
4909        self.drop_without_shutdown();
4910        _result
4911    }
4912
4913    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
4914        self.control_handle
4915            .inner
4916            .send::<fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>>(
4917                result.map(|project_id| (project_id,)),
4918                self.tx_id,
4919                0x644073bdf2542573,
4920                fidl::encoding::DynamicFlags::empty(),
4921            )
4922    }
4923}
4924
4925#[must_use = "FIDL methods require a response to be sent"]
4926#[derive(Debug)]
4927pub struct ProjectIdClearForNodeResponder {
4928    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4929    tx_id: u32,
4930}
4931
4932/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4933/// if the responder is dropped without sending a response, so that the client
4934/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4935impl std::ops::Drop for ProjectIdClearForNodeResponder {
4936    fn drop(&mut self) {
4937        self.control_handle.shutdown();
4938        // Safety: drops once, never accessed again
4939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4940    }
4941}
4942
4943impl fdomain_client::fidl::Responder for ProjectIdClearForNodeResponder {
4944    type ControlHandle = ProjectIdControlHandle;
4945
4946    fn control_handle(&self) -> &ProjectIdControlHandle {
4947        &self.control_handle
4948    }
4949
4950    fn drop_without_shutdown(mut self) {
4951        // Safety: drops once, never accessed again due to mem::forget
4952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4953        // Prevent Drop from running (which would shut down the channel)
4954        std::mem::forget(self);
4955    }
4956}
4957
4958impl ProjectIdClearForNodeResponder {
4959    /// Sends a response to the FIDL transaction.
4960    ///
4961    /// Sets the channel to shutdown if an error occurs.
4962    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4963        let _result = self.send_raw(result);
4964        if _result.is_err() {
4965            self.control_handle.shutdown();
4966        }
4967        self.drop_without_shutdown();
4968        _result
4969    }
4970
4971    /// Similar to "send" but does not shutdown the channel if an error occurs.
4972    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4973        let _result = self.send_raw(result);
4974        self.drop_without_shutdown();
4975        _result
4976    }
4977
4978    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4979        self.control_handle
4980            .inner
4981            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4982                result,
4983                self.tx_id,
4984                0x3f2ca287bbfe6a62,
4985                fidl::encoding::DynamicFlags::empty(),
4986            )
4987    }
4988}
4989
4990#[must_use = "FIDL methods require a response to be sent"]
4991#[derive(Debug)]
4992pub struct ProjectIdListResponder {
4993    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
4994    tx_id: u32,
4995}
4996
4997/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
4998/// if the responder is dropped without sending a response, so that the client
4999/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5000impl std::ops::Drop for ProjectIdListResponder {
5001    fn drop(&mut self) {
5002        self.control_handle.shutdown();
5003        // Safety: drops once, never accessed again
5004        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5005    }
5006}
5007
5008impl fdomain_client::fidl::Responder for ProjectIdListResponder {
5009    type ControlHandle = ProjectIdControlHandle;
5010
5011    fn control_handle(&self) -> &ProjectIdControlHandle {
5012        &self.control_handle
5013    }
5014
5015    fn drop_without_shutdown(mut self) {
5016        // Safety: drops once, never accessed again due to mem::forget
5017        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5018        // Prevent Drop from running (which would shut down the channel)
5019        std::mem::forget(self);
5020    }
5021}
5022
5023impl ProjectIdListResponder {
5024    /// Sends a response to the FIDL transaction.
5025    ///
5026    /// Sets the channel to shutdown if an error occurs.
5027    pub fn send(
5028        self,
5029        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5030    ) -> Result<(), fidl::Error> {
5031        let _result = self.send_raw(result);
5032        if _result.is_err() {
5033            self.control_handle.shutdown();
5034        }
5035        self.drop_without_shutdown();
5036        _result
5037    }
5038
5039    /// Similar to "send" but does not shutdown the channel if an error occurs.
5040    pub fn send_no_shutdown_on_err(
5041        self,
5042        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5043    ) -> Result<(), fidl::Error> {
5044        let _result = self.send_raw(result);
5045        self.drop_without_shutdown();
5046        _result
5047    }
5048
5049    fn send_raw(
5050        &self,
5051        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
5052    ) -> Result<(), fidl::Error> {
5053        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdListResponse, i32>>(
5054            result,
5055            self.tx_id,
5056            0x5505f95a36d522cc,
5057            fidl::encoding::DynamicFlags::empty(),
5058        )
5059    }
5060}
5061
5062#[must_use = "FIDL methods require a response to be sent"]
5063#[derive(Debug)]
5064pub struct ProjectIdInfoResponder {
5065    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
5066    tx_id: u32,
5067}
5068
5069/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
5070/// if the responder is dropped without sending a response, so that the client
5071/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5072impl std::ops::Drop for ProjectIdInfoResponder {
5073    fn drop(&mut self) {
5074        self.control_handle.shutdown();
5075        // Safety: drops once, never accessed again
5076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5077    }
5078}
5079
5080impl fdomain_client::fidl::Responder for ProjectIdInfoResponder {
5081    type ControlHandle = ProjectIdControlHandle;
5082
5083    fn control_handle(&self) -> &ProjectIdControlHandle {
5084        &self.control_handle
5085    }
5086
5087    fn drop_without_shutdown(mut self) {
5088        // Safety: drops once, never accessed again due to mem::forget
5089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5090        // Prevent Drop from running (which would shut down the channel)
5091        std::mem::forget(self);
5092    }
5093}
5094
5095impl ProjectIdInfoResponder {
5096    /// Sends a response to the FIDL transaction.
5097    ///
5098    /// Sets the channel to shutdown if an error occurs.
5099    pub fn send(
5100        self,
5101        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5102    ) -> Result<(), fidl::Error> {
5103        let _result = self.send_raw(result);
5104        if _result.is_err() {
5105            self.control_handle.shutdown();
5106        }
5107        self.drop_without_shutdown();
5108        _result
5109    }
5110
5111    /// Similar to "send" but does not shutdown the channel if an error occurs.
5112    pub fn send_no_shutdown_on_err(
5113        self,
5114        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5115    ) -> Result<(), fidl::Error> {
5116        let _result = self.send_raw(result);
5117        self.drop_without_shutdown();
5118        _result
5119    }
5120
5121    fn send_raw(
5122        &self,
5123        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
5124    ) -> Result<(), fidl::Error> {
5125        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdInfoResponse, i32>>(
5126            result,
5127            self.tx_id,
5128            0x51b47743c9e2d1ab,
5129            fidl::encoding::DynamicFlags::empty(),
5130        )
5131    }
5132}
5133
5134#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5135pub struct VolumeInstallerMarker;
5136
5137impl fdomain_client::fidl::ProtocolMarker for VolumeInstallerMarker {
5138    type Proxy = VolumeInstallerProxy;
5139    type RequestStream = VolumeInstallerRequestStream;
5140
5141    const DEBUG_NAME: &'static str = "fuchsia.fxfs.VolumeInstaller";
5142}
5143impl fdomain_client::fidl::DiscoverableProtocolMarker for VolumeInstallerMarker {}
5144pub type VolumeInstallerInstallResult = Result<(), i32>;
5145
5146pub trait VolumeInstallerProxyInterface: Send + Sync {
5147    type InstallResponseFut: std::future::Future<Output = Result<VolumeInstallerInstallResult, fidl::Error>>
5148        + Send;
5149    fn r#install(&self, src: &str, image_file: &str, dst: &str) -> Self::InstallResponseFut;
5150}
5151
5152#[derive(Debug, Clone)]
5153pub struct VolumeInstallerProxy {
5154    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
5155}
5156
5157impl fdomain_client::fidl::Proxy for VolumeInstallerProxy {
5158    type Protocol = VolumeInstallerMarker;
5159
5160    fn from_channel(inner: fdomain_client::Channel) -> Self {
5161        Self::new(inner)
5162    }
5163
5164    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
5165        self.client.into_channel().map_err(|client| Self { client })
5166    }
5167
5168    fn as_channel(&self) -> &fdomain_client::Channel {
5169        self.client.as_channel()
5170    }
5171}
5172
5173impl VolumeInstallerProxy {
5174    /// Create a new Proxy for fuchsia.fxfs/VolumeInstaller.
5175    pub fn new(channel: fdomain_client::Channel) -> Self {
5176        let protocol_name =
5177            <VolumeInstallerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
5178        Self { client: fidl::client::Client::new(channel, protocol_name) }
5179    }
5180
5181    /// Get a Stream of events from the remote end of the protocol.
5182    ///
5183    /// # Panics
5184    ///
5185    /// Panics if the event stream was already taken.
5186    pub fn take_event_stream(&self) -> VolumeInstallerEventStream {
5187        VolumeInstallerEventStream { event_receiver: self.client.take_event_receiver() }
5188    }
5189
5190    /// Using the partition image in `image_file` contained in the volume `src`, overwrites the
5191    /// volume `dst` with a volume of the same name from the image. On success, `src` will no longer
5192    /// exist. There must be no objects in `src` other than the image that contain extents.
5193    /// Neither `src` nor `dst` can be mounted or otherwise in-use.
5194    ///
5195    /// *WARNING*: This will delete the existing contents of `dst`.
5196    pub fn r#install(
5197        &self,
5198        mut src: &str,
5199        mut image_file: &str,
5200        mut dst: &str,
5201    ) -> fidl::client::QueryResponseFut<
5202        VolumeInstallerInstallResult,
5203        fdomain_client::fidl::FDomainResourceDialect,
5204    > {
5205        VolumeInstallerProxyInterface::r#install(self, src, image_file, dst)
5206    }
5207}
5208
5209impl VolumeInstallerProxyInterface for VolumeInstallerProxy {
5210    type InstallResponseFut = fidl::client::QueryResponseFut<
5211        VolumeInstallerInstallResult,
5212        fdomain_client::fidl::FDomainResourceDialect,
5213    >;
5214    fn r#install(
5215        &self,
5216        mut src: &str,
5217        mut image_file: &str,
5218        mut dst: &str,
5219    ) -> Self::InstallResponseFut {
5220        fn _decode(
5221            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5222        ) -> Result<VolumeInstallerInstallResult, fidl::Error> {
5223            let _response = fidl::client::decode_transaction_body::<
5224                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5225                fdomain_client::fidl::FDomainResourceDialect,
5226                0x4c340be8a504ee1c,
5227            >(_buf?)?;
5228            Ok(_response.map(|x| x))
5229        }
5230        self.client
5231            .send_query_and_decode::<VolumeInstallerInstallRequest, VolumeInstallerInstallResult>(
5232                (src, image_file, dst),
5233                0x4c340be8a504ee1c,
5234                fidl::encoding::DynamicFlags::empty(),
5235                _decode,
5236            )
5237    }
5238}
5239
5240pub struct VolumeInstallerEventStream {
5241    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5242}
5243
5244impl std::marker::Unpin for VolumeInstallerEventStream {}
5245
5246impl futures::stream::FusedStream for VolumeInstallerEventStream {
5247    fn is_terminated(&self) -> bool {
5248        self.event_receiver.is_terminated()
5249    }
5250}
5251
5252impl futures::Stream for VolumeInstallerEventStream {
5253    type Item = Result<VolumeInstallerEvent, fidl::Error>;
5254
5255    fn poll_next(
5256        mut self: std::pin::Pin<&mut Self>,
5257        cx: &mut std::task::Context<'_>,
5258    ) -> std::task::Poll<Option<Self::Item>> {
5259        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5260            &mut self.event_receiver,
5261            cx
5262        )?) {
5263            Some(buf) => std::task::Poll::Ready(Some(VolumeInstallerEvent::decode(buf))),
5264            None => std::task::Poll::Ready(None),
5265        }
5266    }
5267}
5268
5269#[derive(Debug)]
5270pub enum VolumeInstallerEvent {}
5271
5272impl VolumeInstallerEvent {
5273    /// Decodes a message buffer as a [`VolumeInstallerEvent`].
5274    fn decode(
5275        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5276    ) -> Result<VolumeInstallerEvent, fidl::Error> {
5277        let (bytes, _handles) = buf.split_mut();
5278        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5279        debug_assert_eq!(tx_header.tx_id, 0);
5280        match tx_header.ordinal {
5281            _ => Err(fidl::Error::UnknownOrdinal {
5282                ordinal: tx_header.ordinal,
5283                protocol_name:
5284                    <VolumeInstallerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5285            }),
5286        }
5287    }
5288}
5289
5290/// A Stream of incoming requests for fuchsia.fxfs/VolumeInstaller.
5291pub struct VolumeInstallerRequestStream {
5292    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5293    is_terminated: bool,
5294}
5295
5296impl std::marker::Unpin for VolumeInstallerRequestStream {}
5297
5298impl futures::stream::FusedStream for VolumeInstallerRequestStream {
5299    fn is_terminated(&self) -> bool {
5300        self.is_terminated
5301    }
5302}
5303
5304impl fdomain_client::fidl::RequestStream for VolumeInstallerRequestStream {
5305    type Protocol = VolumeInstallerMarker;
5306    type ControlHandle = VolumeInstallerControlHandle;
5307
5308    fn from_channel(channel: fdomain_client::Channel) -> Self {
5309        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5310    }
5311
5312    fn control_handle(&self) -> Self::ControlHandle {
5313        VolumeInstallerControlHandle { inner: self.inner.clone() }
5314    }
5315
5316    fn into_inner(
5317        self,
5318    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5319    {
5320        (self.inner, self.is_terminated)
5321    }
5322
5323    fn from_inner(
5324        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5325        is_terminated: bool,
5326    ) -> Self {
5327        Self { inner, is_terminated }
5328    }
5329}
5330
5331impl futures::Stream for VolumeInstallerRequestStream {
5332    type Item = Result<VolumeInstallerRequest, fidl::Error>;
5333
5334    fn poll_next(
5335        mut self: std::pin::Pin<&mut Self>,
5336        cx: &mut std::task::Context<'_>,
5337    ) -> std::task::Poll<Option<Self::Item>> {
5338        let this = &mut *self;
5339        if this.inner.check_shutdown(cx) {
5340            this.is_terminated = true;
5341            return std::task::Poll::Ready(None);
5342        }
5343        if this.is_terminated {
5344            panic!("polled VolumeInstallerRequestStream after completion");
5345        }
5346        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5347            |bytes, handles| {
5348                match this.inner.channel().read_etc(cx, bytes, handles) {
5349                    std::task::Poll::Ready(Ok(())) => {}
5350                    std::task::Poll::Pending => return std::task::Poll::Pending,
5351                    std::task::Poll::Ready(Err(None)) => {
5352                        this.is_terminated = true;
5353                        return std::task::Poll::Ready(None);
5354                    }
5355                    std::task::Poll::Ready(Err(Some(e))) => {
5356                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5357                            e.into(),
5358                        ))));
5359                    }
5360                }
5361
5362                // A message has been received from the channel
5363                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5364
5365                std::task::Poll::Ready(Some(match header.ordinal {
5366                0x4c340be8a504ee1c => {
5367                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5368                    let mut req = fidl::new_empty!(VolumeInstallerInstallRequest, fdomain_client::fidl::FDomainResourceDialect);
5369                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<VolumeInstallerInstallRequest>(&header, _body_bytes, handles, &mut req)?;
5370                    let control_handle = VolumeInstallerControlHandle {
5371                        inner: this.inner.clone(),
5372                    };
5373                    Ok(VolumeInstallerRequest::Install {src: req.src,
5374image_file: req.image_file,
5375dst: req.dst,
5376
5377                        responder: VolumeInstallerInstallResponder {
5378                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5379                            tx_id: header.tx_id,
5380                        },
5381                    })
5382                }
5383                _ => Err(fidl::Error::UnknownOrdinal {
5384                    ordinal: header.ordinal,
5385                    protocol_name: <VolumeInstallerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5386                }),
5387            }))
5388            },
5389        )
5390    }
5391}
5392
5393/// Allows installing a volume from an fxfs partition image.
5394#[derive(Debug)]
5395pub enum VolumeInstallerRequest {
5396    /// Using the partition image in `image_file` contained in the volume `src`, overwrites the
5397    /// volume `dst` with a volume of the same name from the image. On success, `src` will no longer
5398    /// exist. There must be no objects in `src` other than the image that contain extents.
5399    /// Neither `src` nor `dst` can be mounted or otherwise in-use.
5400    ///
5401    /// *WARNING*: This will delete the existing contents of `dst`.
5402    Install {
5403        src: String,
5404        image_file: String,
5405        dst: String,
5406        responder: VolumeInstallerInstallResponder,
5407    },
5408}
5409
5410impl VolumeInstallerRequest {
5411    #[allow(irrefutable_let_patterns)]
5412    pub fn into_install(self) -> Option<(String, String, String, VolumeInstallerInstallResponder)> {
5413        if let VolumeInstallerRequest::Install { src, image_file, dst, responder } = self {
5414            Some((src, image_file, dst, responder))
5415        } else {
5416            None
5417        }
5418    }
5419
5420    /// Name of the method defined in FIDL
5421    pub fn method_name(&self) -> &'static str {
5422        match *self {
5423            VolumeInstallerRequest::Install { .. } => "install",
5424        }
5425    }
5426}
5427
5428#[derive(Debug, Clone)]
5429pub struct VolumeInstallerControlHandle {
5430    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5431}
5432
5433impl fdomain_client::fidl::ControlHandle for VolumeInstallerControlHandle {
5434    fn shutdown(&self) {
5435        self.inner.shutdown()
5436    }
5437
5438    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5439        self.inner.shutdown_with_epitaph(status)
5440    }
5441
5442    fn is_closed(&self) -> bool {
5443        self.inner.channel().is_closed()
5444    }
5445    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
5446        self.inner.channel().on_closed()
5447    }
5448}
5449
5450impl VolumeInstallerControlHandle {}
5451
5452#[must_use = "FIDL methods require a response to be sent"]
5453#[derive(Debug)]
5454pub struct VolumeInstallerInstallResponder {
5455    control_handle: std::mem::ManuallyDrop<VolumeInstallerControlHandle>,
5456    tx_id: u32,
5457}
5458
5459/// Set the the channel to be shutdown (see [`VolumeInstallerControlHandle::shutdown`])
5460/// if the responder is dropped without sending a response, so that the client
5461/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5462impl std::ops::Drop for VolumeInstallerInstallResponder {
5463    fn drop(&mut self) {
5464        self.control_handle.shutdown();
5465        // Safety: drops once, never accessed again
5466        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5467    }
5468}
5469
5470impl fdomain_client::fidl::Responder for VolumeInstallerInstallResponder {
5471    type ControlHandle = VolumeInstallerControlHandle;
5472
5473    fn control_handle(&self) -> &VolumeInstallerControlHandle {
5474        &self.control_handle
5475    }
5476
5477    fn drop_without_shutdown(mut self) {
5478        // Safety: drops once, never accessed again due to mem::forget
5479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5480        // Prevent Drop from running (which would shut down the channel)
5481        std::mem::forget(self);
5482    }
5483}
5484
5485impl VolumeInstallerInstallResponder {
5486    /// Sends a response to the FIDL transaction.
5487    ///
5488    /// Sets the channel to shutdown if an error occurs.
5489    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5490        let _result = self.send_raw(result);
5491        if _result.is_err() {
5492            self.control_handle.shutdown();
5493        }
5494        self.drop_without_shutdown();
5495        _result
5496    }
5497
5498    /// Similar to "send" but does not shutdown the channel if an error occurs.
5499    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5500        let _result = self.send_raw(result);
5501        self.drop_without_shutdown();
5502        _result
5503    }
5504
5505    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5506        self.control_handle
5507            .inner
5508            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5509                result,
5510                self.tx_id,
5511                0x4c340be8a504ee1c,
5512                fidl::encoding::DynamicFlags::empty(),
5513            )
5514    }
5515}
5516
5517mod internal {
5518    use super::*;
5519
5520    impl fidl::encoding::ResourceTypeMarker for BlobCreatorCreateResponse {
5521        type Borrowed<'a> = &'a mut Self;
5522        fn take_or_borrow<'a>(
5523            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5524        ) -> Self::Borrowed<'a> {
5525            value
5526        }
5527    }
5528
5529    unsafe impl fidl::encoding::TypeMarker for BlobCreatorCreateResponse {
5530        type Owned = Self;
5531
5532        #[inline(always)]
5533        fn inline_align(_context: fidl::encoding::Context) -> usize {
5534            4
5535        }
5536
5537        #[inline(always)]
5538        fn inline_size(_context: fidl::encoding::Context) -> usize {
5539            4
5540        }
5541    }
5542
5543    unsafe impl
5544        fidl::encoding::Encode<
5545            BlobCreatorCreateResponse,
5546            fdomain_client::fidl::FDomainResourceDialect,
5547        > for &mut BlobCreatorCreateResponse
5548    {
5549        #[inline]
5550        unsafe fn encode(
5551            self,
5552            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5553            offset: usize,
5554            _depth: fidl::encoding::Depth,
5555        ) -> fidl::Result<()> {
5556            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
5557            // Delegate to tuple encoding.
5558            fidl::encoding::Encode::<BlobCreatorCreateResponse, fdomain_client::fidl::FDomainResourceDialect>::encode(
5559                (
5560                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
5561                ),
5562                encoder, offset, _depth
5563            )
5564        }
5565    }
5566    unsafe impl<
5567        T0: fidl::encoding::Encode<
5568                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BlobWriterMarker>>,
5569                fdomain_client::fidl::FDomainResourceDialect,
5570            >,
5571    >
5572        fidl::encoding::Encode<
5573            BlobCreatorCreateResponse,
5574            fdomain_client::fidl::FDomainResourceDialect,
5575        > for (T0,)
5576    {
5577        #[inline]
5578        unsafe fn encode(
5579            self,
5580            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5581            offset: usize,
5582            depth: fidl::encoding::Depth,
5583        ) -> fidl::Result<()> {
5584            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
5585            // Zero out padding regions. There's no need to apply masks
5586            // because the unmasked parts will be overwritten by fields.
5587            // Write the fields.
5588            self.0.encode(encoder, offset + 0, depth)?;
5589            Ok(())
5590        }
5591    }
5592
5593    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5594        for BlobCreatorCreateResponse
5595    {
5596        #[inline(always)]
5597        fn new_empty() -> Self {
5598            Self {
5599                writer: fidl::new_empty!(
5600                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BlobWriterMarker>>,
5601                    fdomain_client::fidl::FDomainResourceDialect
5602                ),
5603            }
5604        }
5605
5606        #[inline]
5607        unsafe fn decode(
5608            &mut self,
5609            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5610            offset: usize,
5611            _depth: fidl::encoding::Depth,
5612        ) -> fidl::Result<()> {
5613            decoder.debug_check_bounds::<Self>(offset);
5614            // Verify that padding bytes are zero.
5615            fidl::decode!(
5616                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BlobWriterMarker>>,
5617                fdomain_client::fidl::FDomainResourceDialect,
5618                &mut self.writer,
5619                decoder,
5620                offset + 0,
5621                _depth
5622            )?;
5623            Ok(())
5624        }
5625    }
5626
5627    impl fidl::encoding::ResourceTypeMarker for BlobReaderGetVmoResponse {
5628        type Borrowed<'a> = &'a mut Self;
5629        fn take_or_borrow<'a>(
5630            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5631        ) -> Self::Borrowed<'a> {
5632            value
5633        }
5634    }
5635
5636    unsafe impl fidl::encoding::TypeMarker for BlobReaderGetVmoResponse {
5637        type Owned = Self;
5638
5639        #[inline(always)]
5640        fn inline_align(_context: fidl::encoding::Context) -> usize {
5641            4
5642        }
5643
5644        #[inline(always)]
5645        fn inline_size(_context: fidl::encoding::Context) -> usize {
5646            4
5647        }
5648    }
5649
5650    unsafe impl
5651        fidl::encoding::Encode<
5652            BlobReaderGetVmoResponse,
5653            fdomain_client::fidl::FDomainResourceDialect,
5654        > for &mut BlobReaderGetVmoResponse
5655    {
5656        #[inline]
5657        unsafe fn encode(
5658            self,
5659            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5660            offset: usize,
5661            _depth: fidl::encoding::Depth,
5662        ) -> fidl::Result<()> {
5663            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
5664            // Delegate to tuple encoding.
5665            fidl::encoding::Encode::<
5666                BlobReaderGetVmoResponse,
5667                fdomain_client::fidl::FDomainResourceDialect,
5668            >::encode(
5669                (<fidl::encoding::HandleType<
5670                    fdomain_client::Vmo,
5671                    { fidl::ObjectType::VMO.into_raw() },
5672                    2147483648,
5673                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5674                    &mut self.vmo
5675                ),),
5676                encoder,
5677                offset,
5678                _depth,
5679            )
5680        }
5681    }
5682    unsafe impl<
5683        T0: fidl::encoding::Encode<
5684                fidl::encoding::HandleType<
5685                    fdomain_client::Vmo,
5686                    { fidl::ObjectType::VMO.into_raw() },
5687                    2147483648,
5688                >,
5689                fdomain_client::fidl::FDomainResourceDialect,
5690            >,
5691    >
5692        fidl::encoding::Encode<
5693            BlobReaderGetVmoResponse,
5694            fdomain_client::fidl::FDomainResourceDialect,
5695        > for (T0,)
5696    {
5697        #[inline]
5698        unsafe fn encode(
5699            self,
5700            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5701            offset: usize,
5702            depth: fidl::encoding::Depth,
5703        ) -> fidl::Result<()> {
5704            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
5705            // Zero out padding regions. There's no need to apply masks
5706            // because the unmasked parts will be overwritten by fields.
5707            // Write the fields.
5708            self.0.encode(encoder, offset + 0, depth)?;
5709            Ok(())
5710        }
5711    }
5712
5713    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5714        for BlobReaderGetVmoResponse
5715    {
5716        #[inline(always)]
5717        fn new_empty() -> Self {
5718            Self {
5719                vmo: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
5720            }
5721        }
5722
5723        #[inline]
5724        unsafe fn decode(
5725            &mut self,
5726            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5727            offset: usize,
5728            _depth: fidl::encoding::Depth,
5729        ) -> fidl::Result<()> {
5730            decoder.debug_check_bounds::<Self>(offset);
5731            // Verify that padding bytes are zero.
5732            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)?;
5733            Ok(())
5734        }
5735    }
5736
5737    impl fidl::encoding::ResourceTypeMarker for BlobWriterGetVmoResponse {
5738        type Borrowed<'a> = &'a mut Self;
5739        fn take_or_borrow<'a>(
5740            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5741        ) -> Self::Borrowed<'a> {
5742            value
5743        }
5744    }
5745
5746    unsafe impl fidl::encoding::TypeMarker for BlobWriterGetVmoResponse {
5747        type Owned = Self;
5748
5749        #[inline(always)]
5750        fn inline_align(_context: fidl::encoding::Context) -> usize {
5751            4
5752        }
5753
5754        #[inline(always)]
5755        fn inline_size(_context: fidl::encoding::Context) -> usize {
5756            4
5757        }
5758    }
5759
5760    unsafe impl
5761        fidl::encoding::Encode<
5762            BlobWriterGetVmoResponse,
5763            fdomain_client::fidl::FDomainResourceDialect,
5764        > for &mut BlobWriterGetVmoResponse
5765    {
5766        #[inline]
5767        unsafe fn encode(
5768            self,
5769            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5770            offset: usize,
5771            _depth: fidl::encoding::Depth,
5772        ) -> fidl::Result<()> {
5773            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
5774            // Delegate to tuple encoding.
5775            fidl::encoding::Encode::<
5776                BlobWriterGetVmoResponse,
5777                fdomain_client::fidl::FDomainResourceDialect,
5778            >::encode(
5779                (<fidl::encoding::HandleType<
5780                    fdomain_client::Vmo,
5781                    { fidl::ObjectType::VMO.into_raw() },
5782                    2147483648,
5783                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5784                    &mut self.vmo
5785                ),),
5786                encoder,
5787                offset,
5788                _depth,
5789            )
5790        }
5791    }
5792    unsafe impl<
5793        T0: fidl::encoding::Encode<
5794                fidl::encoding::HandleType<
5795                    fdomain_client::Vmo,
5796                    { fidl::ObjectType::VMO.into_raw() },
5797                    2147483648,
5798                >,
5799                fdomain_client::fidl::FDomainResourceDialect,
5800            >,
5801    >
5802        fidl::encoding::Encode<
5803            BlobWriterGetVmoResponse,
5804            fdomain_client::fidl::FDomainResourceDialect,
5805        > for (T0,)
5806    {
5807        #[inline]
5808        unsafe fn encode(
5809            self,
5810            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5811            offset: usize,
5812            depth: fidl::encoding::Depth,
5813        ) -> fidl::Result<()> {
5814            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
5815            // Zero out padding regions. There's no need to apply masks
5816            // because the unmasked parts will be overwritten by fields.
5817            // Write the fields.
5818            self.0.encode(encoder, offset + 0, depth)?;
5819            Ok(())
5820        }
5821    }
5822
5823    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5824        for BlobWriterGetVmoResponse
5825    {
5826        #[inline(always)]
5827        fn new_empty() -> Self {
5828            Self {
5829                vmo: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
5830            }
5831        }
5832
5833        #[inline]
5834        unsafe fn decode(
5835            &mut self,
5836            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5837            offset: usize,
5838            _depth: fidl::encoding::Depth,
5839        ) -> fidl::Result<()> {
5840            decoder.debug_check_bounds::<Self>(offset);
5841            // Verify that padding bytes are zero.
5842            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)?;
5843            Ok(())
5844        }
5845    }
5846
5847    impl fidl::encoding::ResourceTypeMarker for FileBackedVolumeProviderOpenRequest {
5848        type Borrowed<'a> = &'a mut Self;
5849        fn take_or_borrow<'a>(
5850            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5851        ) -> Self::Borrowed<'a> {
5852            value
5853        }
5854    }
5855
5856    unsafe impl fidl::encoding::TypeMarker for FileBackedVolumeProviderOpenRequest {
5857        type Owned = Self;
5858
5859        #[inline(always)]
5860        fn inline_align(_context: fidl::encoding::Context) -> usize {
5861            8
5862        }
5863
5864        #[inline(always)]
5865        fn inline_size(_context: fidl::encoding::Context) -> usize {
5866            32
5867        }
5868    }
5869
5870    unsafe impl
5871        fidl::encoding::Encode<
5872            FileBackedVolumeProviderOpenRequest,
5873            fdomain_client::fidl::FDomainResourceDialect,
5874        > for &mut FileBackedVolumeProviderOpenRequest
5875    {
5876        #[inline]
5877        unsafe fn encode(
5878            self,
5879            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5880            offset: usize,
5881            _depth: fidl::encoding::Depth,
5882        ) -> fidl::Result<()> {
5883            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
5884            // Delegate to tuple encoding.
5885            fidl::encoding::Encode::<
5886                FileBackedVolumeProviderOpenRequest,
5887                fdomain_client::fidl::FDomainResourceDialect,
5888            >::encode(
5889                (
5890                    <fidl::encoding::HandleType<
5891                        fdomain_client::NullableHandle,
5892                        { fidl::ObjectType::NONE.into_raw() },
5893                        2147483648,
5894                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5895                        &mut self.parent_directory_token,
5896                    ),
5897                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
5898                        &self.name,
5899                    ),
5900                    <fidl::encoding::Endpoint<
5901                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
5902                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5903                        &mut self.server_end
5904                    ),
5905                ),
5906                encoder,
5907                offset,
5908                _depth,
5909            )
5910        }
5911    }
5912    unsafe impl<
5913        T0: fidl::encoding::Encode<
5914                fidl::encoding::HandleType<
5915                    fdomain_client::NullableHandle,
5916                    { fidl::ObjectType::NONE.into_raw() },
5917                    2147483648,
5918                >,
5919                fdomain_client::fidl::FDomainResourceDialect,
5920            >,
5921        T1: fidl::encoding::Encode<
5922                fidl::encoding::BoundedString<255>,
5923                fdomain_client::fidl::FDomainResourceDialect,
5924            >,
5925        T2: fidl::encoding::Encode<
5926                fidl::encoding::Endpoint<
5927                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
5928                >,
5929                fdomain_client::fidl::FDomainResourceDialect,
5930            >,
5931    >
5932        fidl::encoding::Encode<
5933            FileBackedVolumeProviderOpenRequest,
5934            fdomain_client::fidl::FDomainResourceDialect,
5935        > for (T0, T1, T2)
5936    {
5937        #[inline]
5938        unsafe fn encode(
5939            self,
5940            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5941            offset: usize,
5942            depth: fidl::encoding::Depth,
5943        ) -> fidl::Result<()> {
5944            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
5945            // Zero out padding regions. There's no need to apply masks
5946            // because the unmasked parts will be overwritten by fields.
5947            unsafe {
5948                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
5949                (ptr as *mut u64).write_unaligned(0);
5950            }
5951            unsafe {
5952                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
5953                (ptr as *mut u64).write_unaligned(0);
5954            }
5955            // Write the fields.
5956            self.0.encode(encoder, offset + 0, depth)?;
5957            self.1.encode(encoder, offset + 8, depth)?;
5958            self.2.encode(encoder, offset + 24, depth)?;
5959            Ok(())
5960        }
5961    }
5962
5963    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5964        for FileBackedVolumeProviderOpenRequest
5965    {
5966        #[inline(always)]
5967        fn new_empty() -> Self {
5968            Self {
5969                parent_directory_token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
5970                name: fidl::new_empty!(
5971                    fidl::encoding::BoundedString<255>,
5972                    fdomain_client::fidl::FDomainResourceDialect
5973                ),
5974                server_end: fidl::new_empty!(
5975                    fidl::encoding::Endpoint<
5976                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
5977                    >,
5978                    fdomain_client::fidl::FDomainResourceDialect
5979                ),
5980            }
5981        }
5982
5983        #[inline]
5984        unsafe fn decode(
5985            &mut self,
5986            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5987            offset: usize,
5988            _depth: fidl::encoding::Depth,
5989        ) -> fidl::Result<()> {
5990            decoder.debug_check_bounds::<Self>(offset);
5991            // Verify that padding bytes are zero.
5992            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
5993            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5994            let mask = 0xffffffff00000000u64;
5995            let maskedval = padval & mask;
5996            if maskedval != 0 {
5997                return Err(fidl::Error::NonZeroPadding {
5998                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
5999                });
6000            }
6001            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
6002            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6003            let mask = 0xffffffff00000000u64;
6004            let maskedval = padval & mask;
6005            if maskedval != 0 {
6006                return Err(fidl::Error::NonZeroPadding {
6007                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
6008                });
6009            }
6010            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)?;
6011            fidl::decode!(
6012                fidl::encoding::BoundedString<255>,
6013                fdomain_client::fidl::FDomainResourceDialect,
6014                &mut self.name,
6015                decoder,
6016                offset + 8,
6017                _depth
6018            )?;
6019            fidl::decode!(
6020                fidl::encoding::Endpoint<
6021                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_storage_block::BlockMarker>,
6022                >,
6023                fdomain_client::fidl::FDomainResourceDialect,
6024                &mut self.server_end,
6025                decoder,
6026                offset + 24,
6027                _depth
6028            )?;
6029            Ok(())
6030        }
6031    }
6032}