Skip to main content

fdomain_fuchsia_sysmem/
fdomain_fuchsia_sysmem.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_sysmem_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct AllocatorAllocateNonSharedCollectionRequest {
15    pub collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
16}
17
18impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
19    for AllocatorAllocateNonSharedCollectionRequest
20{
21}
22
23#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct AllocatorAllocateSharedCollectionRequest {
25    pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
26}
27
28impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
29    for AllocatorAllocateSharedCollectionRequest
30{
31}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct AllocatorBindSharedCollectionRequest {
35    pub token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
36    pub buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
40    for AllocatorBindSharedCollectionRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AllocatorConnectToSysmem2AllocatorRequest {
46    pub allocator_request:
47        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
48}
49
50impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
51    for AllocatorConnectToSysmem2AllocatorRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct BufferCollectionAttachLifetimeTrackingRequest {
57    pub server_end: fdomain_client::EventPair,
58    pub buffers_remaining: u32,
59}
60
61impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
62    for BufferCollectionAttachLifetimeTrackingRequest
63{
64}
65
66#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct BufferCollectionAttachTokenRequest {
68    pub rights_attenuation_mask: u32,
69    pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
70}
71
72impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
73    for BufferCollectionAttachTokenRequest
74{
75}
76
77/// Deprecated. Use ['fuchsia.sysmem2.BufferCollectionInfo'].
78///
79/// This type is deprecated for new code but still used by some camera code.
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct BufferCollectionInfo {
82    /// The number of buffers in the collection.
83    pub buffer_count: u32,
84    /// Describes how the contents of buffers are represented.
85    /// All buffers within the collection have the same format.
86    pub format: BufferFormat,
87    /// VMO handles for each buffer in the collection.
88    /// The VMOs are only present when the buffers are backed by VMOs.
89    ///
90    /// If present, all the VMOs after `buffer_count` are invalid handles.
91    /// All buffer VMO handles have identical size and access rights.
92    /// The VMO access rights are determined based on the usages which the
93    /// client specified when allocating the buffer collection.  For example,
94    /// a client which expressed a read-only usage will receive VMOs without
95    /// write rights.
96    pub vmos: [Option<fdomain_client::Vmo>; 64],
97    /// The size of each VMO provided.
98    /// This property is only present when the buffers are backed by VMOs.
99    pub vmo_size: u64,
100}
101
102impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo {}
103
104/// Information about a buffer collection and its buffers.
105#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106pub struct BufferCollectionInfo2 {
107    /// The total number of buffers.
108    pub buffer_count: u32,
109    /// These settings apply to all the buffers in the initial buffer allocation.
110    pub settings: SingleBufferSettings,
111    /// VMO handles (and vmo_usable_start offset) for each buffer in the
112    /// collection.
113    ///
114    /// If present, all the VMOs at or after index `buffer_count` are invalid
115    /// (0) handles.
116    ///
117    /// All buffer VMO handles have identical size and access rights.  The size
118    /// is in settings.buffer_settings.size_bytes.
119    ///
120    /// The VMO access rights are determined based on the usages which the
121    /// client specified when allocating the buffer collection.  For example,
122    /// a client which expressed a read-only usage will receive VMOs without
123    /// write rights.  In addition, the rights can be attenuated by the
124    /// parameter to BufferCollectionToken.Duplicate() calls.
125    pub buffers: [VmoBuffer; 64],
126}
127
128impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo2 {}
129
130#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
132    pub group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
133}
134
135impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
136    for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
137{
138}
139
140#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
141pub struct BufferCollectionTokenDuplicateRequest {
142    pub rights_attenuation_mask: u32,
143    pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
144}
145
146impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
147    for BufferCollectionTokenDuplicateRequest
148{
149}
150
151#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152pub struct BufferCollectionTokenDuplicateSyncResponse {
153    pub tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
154}
155
156impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
157    for BufferCollectionTokenDuplicateSyncResponse
158{
159}
160
161#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
162pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
163    pub tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
164}
165
166impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
167    for BufferCollectionTokenGroupCreateChildrenSyncResponse
168{
169}
170
171#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
172pub struct BufferCollectionWaitForBuffersAllocatedResponse {
173    pub status: i32,
174    pub buffer_collection_info: BufferCollectionInfo2,
175}
176
177impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
178    for BufferCollectionWaitForBuffersAllocatedResponse
179{
180}
181
182#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
183pub struct NodeGetNodeRefResponse {
184    pub node_ref: fdomain_client::Event,
185}
186
187impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeGetNodeRefResponse {}
188
189#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
190pub struct NodeIsAlternateForRequest {
191    pub node_ref: fdomain_client::Event,
192}
193
194impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeIsAlternateForRequest {}
195
196/// There is no current replacement for this type, but if your use case needs
197/// incremental buffer allocation within a single collection, please reach out.
198#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
199pub struct SingleBufferInfo {
200    pub settings: SingleBufferSettings,
201    pub buffer: VmoBuffer,
202}
203
204impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for SingleBufferInfo {}
205
206#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
207pub struct VmoBuffer {
208    /// The same VMO can be used by more than one CodecBuffer (only of the same
209    /// buffer_lifetime_ordinal), but each vmo handle must be a separate handle.
210    ///
211    /// The vmo field can be 0 if this is a VmoBuffer in BufferCollectionInfo_2
212    /// that's at or beyond BufferCollectionInfo_2.buffer_count.
213    pub vmo: Option<fdomain_client::Vmo>,
214    /// Offset within the VMO of the first usable byte.  Must be < the VMO's
215    /// size in bytes, and leave sufficient room for
216    /// BufferMemorySettings.size_bytes before the end of the VMO.
217    pub vmo_usable_start: u64,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {}
221
222#[derive(Debug, Default, PartialEq)]
223pub struct BufferCollectionTokenGroupCreateChildRequest {
224    /// Must be set.
225    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
226    /// If not set, the default is ZX_RIGHT_SAME_RIGHTS.
227    pub rights_attenuation_mask: Option<u32>,
228    #[doc(hidden)]
229    pub __source_breaking: fidl::marker::SourceBreaking,
230}
231
232impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
233    for BufferCollectionTokenGroupCreateChildRequest
234{
235}
236
237#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
238pub struct AllocatorMarker;
239
240impl fdomain_client::fidl::ProtocolMarker for AllocatorMarker {
241    type Proxy = AllocatorProxy;
242    type RequestStream = AllocatorRequestStream;
243
244    const DEBUG_NAME: &'static str = "fuchsia.sysmem.Allocator";
245}
246impl fdomain_client::fidl::DiscoverableProtocolMarker for AllocatorMarker {}
247
248pub trait AllocatorProxyInterface: Send + Sync {
249    fn r#allocate_non_shared_collection(
250        &self,
251        collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
252    ) -> Result<(), fidl::Error>;
253    fn r#allocate_shared_collection(
254        &self,
255        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
256    ) -> Result<(), fidl::Error>;
257    fn r#bind_shared_collection(
258        &self,
259        token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
260        buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
261    ) -> Result<(), fidl::Error>;
262    type ValidateBufferCollectionTokenResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
263        + Send;
264    fn r#validate_buffer_collection_token(
265        &self,
266        token_server_koid: u64,
267    ) -> Self::ValidateBufferCollectionTokenResponseFut;
268    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
269    fn r#connect_to_sysmem2_allocator(
270        &self,
271        allocator_request: fdomain_client::fidl::ServerEnd<
272            fdomain_fuchsia_sysmem2::AllocatorMarker,
273        >,
274    ) -> Result<(), fidl::Error>;
275}
276
277#[derive(Debug, Clone)]
278pub struct AllocatorProxy {
279    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
280}
281
282impl fdomain_client::fidl::Proxy for AllocatorProxy {
283    type Protocol = AllocatorMarker;
284
285    fn from_channel(inner: fdomain_client::Channel) -> Self {
286        Self::new(inner)
287    }
288
289    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
290        self.client.into_channel().map_err(|client| Self { client })
291    }
292
293    fn as_channel(&self) -> &fdomain_client::Channel {
294        self.client.as_channel()
295    }
296}
297
298impl AllocatorProxy {
299    /// Create a new Proxy for fuchsia.sysmem/Allocator.
300    pub fn new(channel: fdomain_client::Channel) -> Self {
301        let protocol_name = <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
302        Self { client: fidl::client::Client::new(channel, protocol_name) }
303    }
304
305    /// Get a Stream of events from the remote end of the protocol.
306    ///
307    /// # Panics
308    ///
309    /// Panics if the event stream was already taken.
310    pub fn take_event_stream(&self) -> AllocatorEventStream {
311        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
312    }
313
314    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
315    /// who is also the only participant (from the point of view of sysmem).
316    ///
317    /// This call exists mainly for temp/testing purposes.  This call skips the
318    /// BufferCollectionToken stage, so there's no way to allow another
319    /// participant to specify its constraints.
320    ///
321    /// Real clients are encouraged to use AllocateSharedCollection() instead,
322    /// and to let relevant participants directly convey their own constraints to
323    /// sysmem.
324    ///
325    /// `collection_request` is the server end of the BufferCollection FIDL
326    /// channel.  The client can call SetConstraints() and then
327    /// WaitForBuffersAllocated() on the client end of this channel to specify
328    /// constraints and then determine success/failure and get the
329    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
330    /// keep the client end of this channel open while using the
331    /// BufferCollection, and should notice when this channel closes and stop
332    /// using the BufferCollection ASAP.
333    pub fn r#allocate_non_shared_collection(
334        &self,
335        mut collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
336    ) -> Result<(), fidl::Error> {
337        AllocatorProxyInterface::r#allocate_non_shared_collection(self, collection_request)
338    }
339
340    /// Creates a logical BufferCollectionToken which can be shared among
341    /// participants (using BufferCollectionToken.Duplicate()), and then
342    /// converted into a BufferCollection using BindSharedCollection().
343    ///
344    /// Success/failure to populate the BufferCollection with buffers is
345    /// determined via the BufferCollection interface.
346    pub fn r#allocate_shared_collection(
347        &self,
348        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
349    ) -> Result<(), fidl::Error> {
350        AllocatorProxyInterface::r#allocate_shared_collection(self, token_request)
351    }
352
353    /// Convert a BufferCollectionToken into a connection to the logical
354    /// BufferCollection.  The BufferCollection hasn't yet been populated with
355    /// buffers - the participant must first also send SetConstraints() via the
356    /// client end of buffer_collection.
357    ///
358    /// All BufferCollectionToken(s) duplicated from a logical
359    /// BufferCollectionToken created via AllocateSharedCollection() must be
360    /// turned in via BindSharedCollection() before the logical BufferCollection
361    /// will be populated with buffers.
362    ///
363    /// `token` the client endpoint of a channel whose server end was sent to
364    /// sysmem using AllocateSharedCollection or whose server end was sent to
365    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
366    /// "exchanged" for a channel to the logical BufferCollection.
367    ///
368    /// `buffer_collection_request` the server end of a BufferCollection
369    /// channel.  The sender retains the client end as usual.  The
370    /// BufferCollection channel is a single participant's connection to the
371    /// logical BufferCollection.  There typically will be other participants
372    /// with their own BufferCollection channel to the logical BufferCollection.
373    pub fn r#bind_shared_collection(
374        &self,
375        mut token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
376        mut buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
377    ) -> Result<(), fidl::Error> {
378        AllocatorProxyInterface::r#bind_shared_collection(self, token, buffer_collection_request)
379    }
380
381    /// Validate that a BufferCollectionToken is known to the sysmem server.
382    ///
383    /// This can be used in cases where BindSharedCollection() won't be called
384    /// until after BufferCollectionToken.Duplicate() +
385    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
386    /// whether an incoming token is valid (so far).
387    ///
388    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
389    /// sysmem risks the Sync() hanging forever.
390    ///
391    /// Given that an incoming token can become invalid at any time if any
392    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
393    /// authors of client code are encouraged to consider not calling
394    /// ValidateBufferCollectionToken() and instead dealing with async failure
395    /// of the BufferCollection.Sync() after all the
396    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
397    /// sending any duplicate tokens to other processes).
398    ///
399    /// Regardless of the result of this call, this call has no effect on the
400    /// token with the referenced koid.
401    ///
402    /// A true result from this call doesn't guarantee that the token remains
403    /// valid for any duration afterwards.
404    ///
405    /// Client code will zx_object_get_info() on the client's token handle,
406    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
407    /// which then gets passed to ValidateBufferCollectionToken().
408    ///
409    /// If ValidateBufferCollectionToken() returns true, the token was known at
410    /// the time the sysmem server processed the call, but may no longer be
411    /// valid/known by the time the client code receives the response.
412    ///
413    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
414    /// at the time the sysmem server processed the call, but the token may
415    /// become known by the time the client code receives the response.  However
416    /// client code is not required to mitigate the possibility that the token
417    /// may become known late, since the source of the token should have synced
418    /// the token to sysmem before sending the token to the client code.
419    ///
420    /// If calling ValidateBufferCollectionToken() fails in some way, there will
421    /// be a zx_status_t from the FIDL layer.
422    ///
423    /// `token_server_koid` the koid of the server end of a channel that might
424    /// be a BufferCollectionToken channel.  This can be obtained from
425    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
426    pub fn r#validate_buffer_collection_token(
427        &self,
428        mut token_server_koid: u64,
429    ) -> fidl::client::QueryResponseFut<bool, fdomain_client::fidl::FDomainResourceDialect> {
430        AllocatorProxyInterface::r#validate_buffer_collection_token(self, token_server_koid)
431    }
432
433    /// Set information about the current client that can be used by sysmem to
434    /// help debug leaking memory and hangs waiting for constraints. |name| can
435    /// be an arbitrary string, but the current process name (see
436    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
437    /// arbitrary id, but the current process ID (see
438    /// fsl::GetCurrentProcessKoid()) is a good default.
439    ///
440    /// This information is propagated to all BufferCollections created using
441    /// BindSharedCollection() or AllocateNonSharedCollection() from this
442    /// allocator. It does not affect BufferCollectionTokens, since they are
443    /// often passed cross-process and should have their names managed manually.
444    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
445        AllocatorProxyInterface::r#set_debug_client_info(self, name, id)
446    }
447
448    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
449    /// `Allocator`.
450    ///
451    /// This is mainly useful in situations where library code is handed a
452    /// sysmem(1) allocator, but the library code has been updated to use
453    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
454    /// `Allocator` instead, but client code isn't always in the same repo, so
455    /// this message allows the library to still accept the sysmem(1) Allocator
456    /// temporarily.
457    ///
458    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
459    /// `Allocator`.
460    pub fn r#connect_to_sysmem2_allocator(
461        &self,
462        mut allocator_request: fdomain_client::fidl::ServerEnd<
463            fdomain_fuchsia_sysmem2::AllocatorMarker,
464        >,
465    ) -> Result<(), fidl::Error> {
466        AllocatorProxyInterface::r#connect_to_sysmem2_allocator(self, allocator_request)
467    }
468}
469
470impl AllocatorProxyInterface for AllocatorProxy {
471    fn r#allocate_non_shared_collection(
472        &self,
473        mut collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
474    ) -> Result<(), fidl::Error> {
475        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
476            (collection_request,),
477            0x20f79299bbb4d2c6,
478            fidl::encoding::DynamicFlags::empty(),
479        )
480    }
481
482    fn r#allocate_shared_collection(
483        &self,
484        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
485    ) -> Result<(), fidl::Error> {
486        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
487            (token_request,),
488            0x7a757a57bfda0f71,
489            fidl::encoding::DynamicFlags::empty(),
490        )
491    }
492
493    fn r#bind_shared_collection(
494        &self,
495        mut token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
496        mut buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
497    ) -> Result<(), fidl::Error> {
498        self.client.send::<AllocatorBindSharedCollectionRequest>(
499            (token, buffer_collection_request),
500            0x146eca7ec46ff4ee,
501            fidl::encoding::DynamicFlags::empty(),
502        )
503    }
504
505    type ValidateBufferCollectionTokenResponseFut =
506        fidl::client::QueryResponseFut<bool, fdomain_client::fidl::FDomainResourceDialect>;
507    fn r#validate_buffer_collection_token(
508        &self,
509        mut token_server_koid: u64,
510    ) -> Self::ValidateBufferCollectionTokenResponseFut {
511        fn _decode(
512            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
513        ) -> Result<bool, fidl::Error> {
514            let _response = fidl::client::decode_transaction_body::<
515                AllocatorValidateBufferCollectionTokenResponse,
516                fdomain_client::fidl::FDomainResourceDialect,
517                0x575b279b0236faea,
518            >(_buf?)?;
519            Ok(_response.is_known)
520        }
521        self.client.send_query_and_decode::<AllocatorValidateBufferCollectionTokenRequest, bool>(
522            (token_server_koid,),
523            0x575b279b0236faea,
524            fidl::encoding::DynamicFlags::empty(),
525            _decode,
526        )
527    }
528
529    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
530        self.client.send::<AllocatorSetDebugClientInfoRequest>(
531            (name, id),
532            0x419f0d5b30728b26,
533            fidl::encoding::DynamicFlags::empty(),
534        )
535    }
536
537    fn r#connect_to_sysmem2_allocator(
538        &self,
539        mut allocator_request: fdomain_client::fidl::ServerEnd<
540            fdomain_fuchsia_sysmem2::AllocatorMarker,
541        >,
542    ) -> Result<(), fidl::Error> {
543        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
544            (allocator_request,),
545            0x13db3e3abac2e24,
546            fidl::encoding::DynamicFlags::empty(),
547        )
548    }
549}
550
551pub struct AllocatorEventStream {
552    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
553}
554
555impl std::marker::Unpin for AllocatorEventStream {}
556
557impl futures::stream::FusedStream for AllocatorEventStream {
558    fn is_terminated(&self) -> bool {
559        self.event_receiver.is_terminated()
560    }
561}
562
563impl futures::Stream for AllocatorEventStream {
564    type Item = Result<AllocatorEvent, fidl::Error>;
565
566    fn poll_next(
567        mut self: std::pin::Pin<&mut Self>,
568        cx: &mut std::task::Context<'_>,
569    ) -> std::task::Poll<Option<Self::Item>> {
570        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
571            &mut self.event_receiver,
572            cx
573        )?) {
574            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
575            None => std::task::Poll::Ready(None),
576        }
577    }
578}
579
580#[derive(Debug)]
581pub enum AllocatorEvent {}
582
583impl AllocatorEvent {
584    /// Decodes a message buffer as a [`AllocatorEvent`].
585    fn decode(
586        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
587    ) -> Result<AllocatorEvent, fidl::Error> {
588        let (bytes, _handles) = buf.split_mut();
589        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
590        debug_assert_eq!(tx_header.tx_id, 0);
591        match tx_header.ordinal {
592            _ => Err(fidl::Error::UnknownOrdinal {
593                ordinal: tx_header.ordinal,
594                protocol_name:
595                    <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
596            }),
597        }
598    }
599}
600
601/// A Stream of incoming requests for fuchsia.sysmem/Allocator.
602pub struct AllocatorRequestStream {
603    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
604    is_terminated: bool,
605}
606
607impl std::marker::Unpin for AllocatorRequestStream {}
608
609impl futures::stream::FusedStream for AllocatorRequestStream {
610    fn is_terminated(&self) -> bool {
611        self.is_terminated
612    }
613}
614
615impl fdomain_client::fidl::RequestStream for AllocatorRequestStream {
616    type Protocol = AllocatorMarker;
617    type ControlHandle = AllocatorControlHandle;
618
619    fn from_channel(channel: fdomain_client::Channel) -> Self {
620        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
621    }
622
623    fn control_handle(&self) -> Self::ControlHandle {
624        AllocatorControlHandle { inner: self.inner.clone() }
625    }
626
627    fn into_inner(
628        self,
629    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
630    {
631        (self.inner, self.is_terminated)
632    }
633
634    fn from_inner(
635        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
636        is_terminated: bool,
637    ) -> Self {
638        Self { inner, is_terminated }
639    }
640}
641
642impl futures::Stream for AllocatorRequestStream {
643    type Item = Result<AllocatorRequest, fidl::Error>;
644
645    fn poll_next(
646        mut self: std::pin::Pin<&mut Self>,
647        cx: &mut std::task::Context<'_>,
648    ) -> std::task::Poll<Option<Self::Item>> {
649        let this = &mut *self;
650        if this.inner.check_shutdown(cx) {
651            this.is_terminated = true;
652            return std::task::Poll::Ready(None);
653        }
654        if this.is_terminated {
655            panic!("polled AllocatorRequestStream after completion");
656        }
657        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
658            |bytes, handles| {
659                match this.inner.channel().read_etc(cx, bytes, handles) {
660                    std::task::Poll::Ready(Ok(())) => {}
661                    std::task::Poll::Pending => return std::task::Poll::Pending,
662                    std::task::Poll::Ready(Err(None)) => {
663                        this.is_terminated = true;
664                        return std::task::Poll::Ready(None);
665                    }
666                    std::task::Poll::Ready(Err(Some(e))) => {
667                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
668                            e.into(),
669                        ))));
670                    }
671                }
672
673                // A message has been received from the channel
674                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
675
676                std::task::Poll::Ready(Some(match header.ordinal {
677                    0x20f79299bbb4d2c6 => {
678                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
679                        let mut req = fidl::new_empty!(
680                            AllocatorAllocateNonSharedCollectionRequest,
681                            fdomain_client::fidl::FDomainResourceDialect
682                        );
683                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
684                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
685                        Ok(AllocatorRequest::AllocateNonSharedCollection {
686                            collection_request: req.collection_request,
687
688                            control_handle,
689                        })
690                    }
691                    0x7a757a57bfda0f71 => {
692                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
693                        let mut req = fidl::new_empty!(
694                            AllocatorAllocateSharedCollectionRequest,
695                            fdomain_client::fidl::FDomainResourceDialect
696                        );
697                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
698                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
699                        Ok(AllocatorRequest::AllocateSharedCollection {
700                            token_request: req.token_request,
701
702                            control_handle,
703                        })
704                    }
705                    0x146eca7ec46ff4ee => {
706                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
707                        let mut req = fidl::new_empty!(
708                            AllocatorBindSharedCollectionRequest,
709                            fdomain_client::fidl::FDomainResourceDialect
710                        );
711                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
712                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
713                        Ok(AllocatorRequest::BindSharedCollection {
714                            token: req.token,
715                            buffer_collection_request: req.buffer_collection_request,
716
717                            control_handle,
718                        })
719                    }
720                    0x575b279b0236faea => {
721                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
722                        let mut req = fidl::new_empty!(
723                            AllocatorValidateBufferCollectionTokenRequest,
724                            fdomain_client::fidl::FDomainResourceDialect
725                        );
726                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
727                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
728                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
729                            token_server_koid: req.token_server_koid,
730
731                            responder: AllocatorValidateBufferCollectionTokenResponder {
732                                control_handle: std::mem::ManuallyDrop::new(control_handle),
733                                tx_id: header.tx_id,
734                            },
735                        })
736                    }
737                    0x419f0d5b30728b26 => {
738                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
739                        let mut req = fidl::new_empty!(
740                            AllocatorSetDebugClientInfoRequest,
741                            fdomain_client::fidl::FDomainResourceDialect
742                        );
743                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
744                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
745                        Ok(AllocatorRequest::SetDebugClientInfo {
746                            name: req.name,
747                            id: req.id,
748
749                            control_handle,
750                        })
751                    }
752                    0x13db3e3abac2e24 => {
753                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
754                        let mut req = fidl::new_empty!(
755                            AllocatorConnectToSysmem2AllocatorRequest,
756                            fdomain_client::fidl::FDomainResourceDialect
757                        );
758                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorConnectToSysmem2AllocatorRequest>(&header, _body_bytes, handles, &mut req)?;
759                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
760                        Ok(AllocatorRequest::ConnectToSysmem2Allocator {
761                            allocator_request: req.allocator_request,
762
763                            control_handle,
764                        })
765                    }
766                    _ => Err(fidl::Error::UnknownOrdinal {
767                        ordinal: header.ordinal,
768                        protocol_name:
769                            <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
770                    }),
771                }))
772            },
773        )
774    }
775}
776
777/// Allocates system memory buffers.
778#[derive(Debug)]
779pub enum AllocatorRequest {
780    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
781    /// who is also the only participant (from the point of view of sysmem).
782    ///
783    /// This call exists mainly for temp/testing purposes.  This call skips the
784    /// BufferCollectionToken stage, so there's no way to allow another
785    /// participant to specify its constraints.
786    ///
787    /// Real clients are encouraged to use AllocateSharedCollection() instead,
788    /// and to let relevant participants directly convey their own constraints to
789    /// sysmem.
790    ///
791    /// `collection_request` is the server end of the BufferCollection FIDL
792    /// channel.  The client can call SetConstraints() and then
793    /// WaitForBuffersAllocated() on the client end of this channel to specify
794    /// constraints and then determine success/failure and get the
795    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
796    /// keep the client end of this channel open while using the
797    /// BufferCollection, and should notice when this channel closes and stop
798    /// using the BufferCollection ASAP.
799    AllocateNonSharedCollection {
800        collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
801        control_handle: AllocatorControlHandle,
802    },
803    /// Creates a logical BufferCollectionToken which can be shared among
804    /// participants (using BufferCollectionToken.Duplicate()), and then
805    /// converted into a BufferCollection using BindSharedCollection().
806    ///
807    /// Success/failure to populate the BufferCollection with buffers is
808    /// determined via the BufferCollection interface.
809    AllocateSharedCollection {
810        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
811        control_handle: AllocatorControlHandle,
812    },
813    /// Convert a BufferCollectionToken into a connection to the logical
814    /// BufferCollection.  The BufferCollection hasn't yet been populated with
815    /// buffers - the participant must first also send SetConstraints() via the
816    /// client end of buffer_collection.
817    ///
818    /// All BufferCollectionToken(s) duplicated from a logical
819    /// BufferCollectionToken created via AllocateSharedCollection() must be
820    /// turned in via BindSharedCollection() before the logical BufferCollection
821    /// will be populated with buffers.
822    ///
823    /// `token` the client endpoint of a channel whose server end was sent to
824    /// sysmem using AllocateSharedCollection or whose server end was sent to
825    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
826    /// "exchanged" for a channel to the logical BufferCollection.
827    ///
828    /// `buffer_collection_request` the server end of a BufferCollection
829    /// channel.  The sender retains the client end as usual.  The
830    /// BufferCollection channel is a single participant's connection to the
831    /// logical BufferCollection.  There typically will be other participants
832    /// with their own BufferCollection channel to the logical BufferCollection.
833    BindSharedCollection {
834        token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
835        buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
836        control_handle: AllocatorControlHandle,
837    },
838    /// Validate that a BufferCollectionToken is known to the sysmem server.
839    ///
840    /// This can be used in cases where BindSharedCollection() won't be called
841    /// until after BufferCollectionToken.Duplicate() +
842    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
843    /// whether an incoming token is valid (so far).
844    ///
845    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
846    /// sysmem risks the Sync() hanging forever.
847    ///
848    /// Given that an incoming token can become invalid at any time if any
849    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
850    /// authors of client code are encouraged to consider not calling
851    /// ValidateBufferCollectionToken() and instead dealing with async failure
852    /// of the BufferCollection.Sync() after all the
853    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
854    /// sending any duplicate tokens to other processes).
855    ///
856    /// Regardless of the result of this call, this call has no effect on the
857    /// token with the referenced koid.
858    ///
859    /// A true result from this call doesn't guarantee that the token remains
860    /// valid for any duration afterwards.
861    ///
862    /// Client code will zx_object_get_info() on the client's token handle,
863    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
864    /// which then gets passed to ValidateBufferCollectionToken().
865    ///
866    /// If ValidateBufferCollectionToken() returns true, the token was known at
867    /// the time the sysmem server processed the call, but may no longer be
868    /// valid/known by the time the client code receives the response.
869    ///
870    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
871    /// at the time the sysmem server processed the call, but the token may
872    /// become known by the time the client code receives the response.  However
873    /// client code is not required to mitigate the possibility that the token
874    /// may become known late, since the source of the token should have synced
875    /// the token to sysmem before sending the token to the client code.
876    ///
877    /// If calling ValidateBufferCollectionToken() fails in some way, there will
878    /// be a zx_status_t from the FIDL layer.
879    ///
880    /// `token_server_koid` the koid of the server end of a channel that might
881    /// be a BufferCollectionToken channel.  This can be obtained from
882    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
883    ValidateBufferCollectionToken {
884        token_server_koid: u64,
885        responder: AllocatorValidateBufferCollectionTokenResponder,
886    },
887    /// Set information about the current client that can be used by sysmem to
888    /// help debug leaking memory and hangs waiting for constraints. |name| can
889    /// be an arbitrary string, but the current process name (see
890    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
891    /// arbitrary id, but the current process ID (see
892    /// fsl::GetCurrentProcessKoid()) is a good default.
893    ///
894    /// This information is propagated to all BufferCollections created using
895    /// BindSharedCollection() or AllocateNonSharedCollection() from this
896    /// allocator. It does not affect BufferCollectionTokens, since they are
897    /// often passed cross-process and should have their names managed manually.
898    SetDebugClientInfo { name: String, id: u64, control_handle: AllocatorControlHandle },
899    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
900    /// `Allocator`.
901    ///
902    /// This is mainly useful in situations where library code is handed a
903    /// sysmem(1) allocator, but the library code has been updated to use
904    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
905    /// `Allocator` instead, but client code isn't always in the same repo, so
906    /// this message allows the library to still accept the sysmem(1) Allocator
907    /// temporarily.
908    ///
909    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
910    /// `Allocator`.
911    ConnectToSysmem2Allocator {
912        allocator_request:
913            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
914        control_handle: AllocatorControlHandle,
915    },
916}
917
918impl AllocatorRequest {
919    #[allow(irrefutable_let_patterns)]
920    pub fn into_allocate_non_shared_collection(
921        self,
922    ) -> Option<(fdomain_client::fidl::ServerEnd<BufferCollectionMarker>, AllocatorControlHandle)>
923    {
924        if let AllocatorRequest::AllocateNonSharedCollection {
925            collection_request,
926            control_handle,
927        } = self
928        {
929            Some((collection_request, control_handle))
930        } else {
931            None
932        }
933    }
934
935    #[allow(irrefutable_let_patterns)]
936    pub fn into_allocate_shared_collection(
937        self,
938    ) -> Option<(
939        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
940        AllocatorControlHandle,
941    )> {
942        if let AllocatorRequest::AllocateSharedCollection { token_request, control_handle } = self {
943            Some((token_request, control_handle))
944        } else {
945            None
946        }
947    }
948
949    #[allow(irrefutable_let_patterns)]
950    pub fn into_bind_shared_collection(
951        self,
952    ) -> Option<(
953        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
954        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
955        AllocatorControlHandle,
956    )> {
957        if let AllocatorRequest::BindSharedCollection {
958            token,
959            buffer_collection_request,
960            control_handle,
961        } = self
962        {
963            Some((token, buffer_collection_request, control_handle))
964        } else {
965            None
966        }
967    }
968
969    #[allow(irrefutable_let_patterns)]
970    pub fn into_validate_buffer_collection_token(
971        self,
972    ) -> Option<(u64, AllocatorValidateBufferCollectionTokenResponder)> {
973        if let AllocatorRequest::ValidateBufferCollectionToken { token_server_koid, responder } =
974            self
975        {
976            Some((token_server_koid, responder))
977        } else {
978            None
979        }
980    }
981
982    #[allow(irrefutable_let_patterns)]
983    pub fn into_set_debug_client_info(self) -> Option<(String, u64, AllocatorControlHandle)> {
984        if let AllocatorRequest::SetDebugClientInfo { name, id, control_handle } = self {
985            Some((name, id, control_handle))
986        } else {
987            None
988        }
989    }
990
991    #[allow(irrefutable_let_patterns)]
992    pub fn into_connect_to_sysmem2_allocator(
993        self,
994    ) -> Option<(
995        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
996        AllocatorControlHandle,
997    )> {
998        if let AllocatorRequest::ConnectToSysmem2Allocator { allocator_request, control_handle } =
999            self
1000        {
1001            Some((allocator_request, control_handle))
1002        } else {
1003            None
1004        }
1005    }
1006
1007    /// Name of the method defined in FIDL
1008    pub fn method_name(&self) -> &'static str {
1009        match *self {
1010            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1011                "allocate_non_shared_collection"
1012            }
1013            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1014            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1015            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1016                "validate_buffer_collection_token"
1017            }
1018            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1019            AllocatorRequest::ConnectToSysmem2Allocator { .. } => "connect_to_sysmem2_allocator",
1020        }
1021    }
1022}
1023
1024#[derive(Debug, Clone)]
1025pub struct AllocatorControlHandle {
1026    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1027}
1028
1029impl AllocatorControlHandle {
1030    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1031        self.inner.shutdown_with_epitaph(status.into())
1032    }
1033}
1034
1035impl fdomain_client::fidl::ControlHandle for AllocatorControlHandle {
1036    fn shutdown(&self) {
1037        self.inner.shutdown()
1038    }
1039
1040    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1041        self.inner.shutdown_with_epitaph(status)
1042    }
1043
1044    fn is_closed(&self) -> bool {
1045        self.inner.channel().is_closed()
1046    }
1047    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1048        self.inner.channel().on_closed()
1049    }
1050}
1051
1052impl AllocatorControlHandle {}
1053
1054#[must_use = "FIDL methods require a response to be sent"]
1055#[derive(Debug)]
1056pub struct AllocatorValidateBufferCollectionTokenResponder {
1057    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1058    tx_id: u32,
1059}
1060
1061/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1062/// if the responder is dropped without sending a response, so that the client
1063/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1064impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1065    fn drop(&mut self) {
1066        self.control_handle.shutdown();
1067        // Safety: drops once, never accessed again
1068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1069    }
1070}
1071
1072impl fdomain_client::fidl::Responder for AllocatorValidateBufferCollectionTokenResponder {
1073    type ControlHandle = AllocatorControlHandle;
1074
1075    fn control_handle(&self) -> &AllocatorControlHandle {
1076        &self.control_handle
1077    }
1078
1079    fn drop_without_shutdown(mut self) {
1080        // Safety: drops once, never accessed again due to mem::forget
1081        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1082        // Prevent Drop from running (which would shut down the channel)
1083        std::mem::forget(self);
1084    }
1085}
1086
1087impl AllocatorValidateBufferCollectionTokenResponder {
1088    /// Sends a response to the FIDL transaction.
1089    ///
1090    /// Sets the channel to shutdown if an error occurs.
1091    pub fn send(self, mut is_known: bool) -> Result<(), fidl::Error> {
1092        let _result = self.send_raw(is_known);
1093        if _result.is_err() {
1094            self.control_handle.shutdown();
1095        }
1096        self.drop_without_shutdown();
1097        _result
1098    }
1099
1100    /// Similar to "send" but does not shutdown the channel if an error occurs.
1101    pub fn send_no_shutdown_on_err(self, mut is_known: bool) -> Result<(), fidl::Error> {
1102        let _result = self.send_raw(is_known);
1103        self.drop_without_shutdown();
1104        _result
1105    }
1106
1107    fn send_raw(&self, mut is_known: bool) -> Result<(), fidl::Error> {
1108        self.control_handle.inner.send::<AllocatorValidateBufferCollectionTokenResponse>(
1109            (is_known,),
1110            self.tx_id,
1111            0x575b279b0236faea,
1112            fidl::encoding::DynamicFlags::empty(),
1113        )
1114    }
1115}
1116
1117#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1118pub struct BufferCollectionMarker;
1119
1120impl fdomain_client::fidl::ProtocolMarker for BufferCollectionMarker {
1121    type Proxy = BufferCollectionProxy;
1122    type RequestStream = BufferCollectionRequestStream;
1123
1124    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1125}
1126
1127pub trait BufferCollectionProxyInterface: Send + Sync {
1128    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1129    fn r#sync(&self) -> Self::SyncResponseFut;
1130    fn r#close(&self) -> Result<(), fidl::Error>;
1131    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
1132    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
1133    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
1134    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1135    type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
1136        + Send;
1137    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1138    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1139        + Send;
1140    fn r#is_alternate_for(
1141        &self,
1142        node_ref: fdomain_client::Event,
1143    ) -> Self::IsAlternateForResponseFut;
1144    fn r#set_constraints(
1145        &self,
1146        has_constraints: bool,
1147        constraints: &BufferCollectionConstraints,
1148    ) -> Result<(), fidl::Error>;
1149    type WaitForBuffersAllocatedResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1150        + Send;
1151    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut;
1152    type CheckBuffersAllocatedResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1153        + Send;
1154    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut;
1155    fn r#attach_token(
1156        &self,
1157        rights_attenuation_mask: u32,
1158        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1159    ) -> Result<(), fidl::Error>;
1160    fn r#attach_lifetime_tracking(
1161        &self,
1162        server_end: fdomain_client::EventPair,
1163        buffers_remaining: u32,
1164    ) -> Result<(), fidl::Error>;
1165}
1166
1167#[derive(Debug, Clone)]
1168pub struct BufferCollectionProxy {
1169    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1170}
1171
1172impl fdomain_client::fidl::Proxy for BufferCollectionProxy {
1173    type Protocol = BufferCollectionMarker;
1174
1175    fn from_channel(inner: fdomain_client::Channel) -> Self {
1176        Self::new(inner)
1177    }
1178
1179    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1180        self.client.into_channel().map_err(|client| Self { client })
1181    }
1182
1183    fn as_channel(&self) -> &fdomain_client::Channel {
1184        self.client.as_channel()
1185    }
1186}
1187
1188impl BufferCollectionProxy {
1189    /// Create a new Proxy for fuchsia.sysmem/BufferCollection.
1190    pub fn new(channel: fdomain_client::Channel) -> Self {
1191        let protocol_name =
1192            <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1193        Self { client: fidl::client::Client::new(channel, protocol_name) }
1194    }
1195
1196    /// Get a Stream of events from the remote end of the protocol.
1197    ///
1198    /// # Panics
1199    ///
1200    /// Panics if the event stream was already taken.
1201    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
1202        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
1203    }
1204
1205    /// Ensure that previous messages, including Duplicate() messages on a
1206    /// token, collection, or group, have been received server side.
1207    ///
1208    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
1209    /// valid sysmem token risks the Sync() hanging forever.  See
1210    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
1211    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
1212    /// Another way is to pass the token to BindSharedCollection(), which also
1213    /// validates the token as part of exchanging it for a BufferCollection
1214    /// channel, and BufferCollection Sync() can then be used.
1215    ///
1216    /// After a Sync(), it's then safe to send the client end of token_request
1217    /// to another participant knowing the server will recognize the token when
1218    /// it's sent into BindSharedCollection() by the other participant.
1219    ///
1220    /// Other options include waiting for each token.Duplicate() to complete
1221    /// individually (using separate call to token.Sync() after each), or
1222    /// calling Sync() on BufferCollection after the token has been turned in
1223    /// via BindSharedCollection().
1224    ///
1225    /// Another way to mitigate is to avoid calling Sync() on the token, and
1226    /// instead later deal with potential failure of BufferCollection.Sync() if
1227    /// the original token was invalid.  This option can be preferable from a
1228    /// performance point of view, but requires client code to delay sending
1229    /// tokens duplicated from this token until after client code has converted
1230    /// the duplicating token to a BufferCollection and received successful
1231    /// response from BufferCollection.Sync().
1232    ///
1233    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
1234    /// When BufferCollection.Sync() isn't feasible, the caller must already
1235    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
1236    /// hang forever.  See ValidateBufferCollectionToken() to check token
1237    /// validity first if the token isn't already known to be (is/was) valid.
1238    pub fn r#sync(
1239        &self,
1240    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1241        BufferCollectionProxyInterface::r#sync(self)
1242    }
1243
1244    /// On a BufferCollectionToken channel:
1245    ///
1246    /// Normally a participant will convert a BufferCollectionToken into a
1247    /// BufferCollection view, but a participant is also free to Close() the
1248    /// token (and then close the channel immediately or shortly later in
1249    /// response to server closing its end), which avoids causing logical buffer
1250    /// collection failure.  Normally an unexpected token channel close will
1251    /// cause logical buffer collection failure (the only exceptions being
1252    /// certain cases involving AttachToken() or SetDispensable()).
1253    ///
1254    /// On a BufferCollection channel:
1255    ///
1256    /// By default the server handles unexpected failure of a BufferCollection
1257    /// by failing the whole logical buffer collection.  Partly this is to
1258    /// expedite closing VMO handles to reclaim memory when any participant
1259    /// fails.  If a participant would like to cleanly close a BufferCollection
1260    /// view without causing logical buffer collection failure, the participant
1261    /// can send Close() before closing the client end of the BufferCollection
1262    /// channel.  If this is the last BufferCollection view, the logical buffer
1263    /// collection will still go away.  The Close() can occur before or after
1264    /// SetConstraints().  If before SetConstraints(), the buffer collection
1265    /// won't require constraints from this node in order to allocate.  If
1266    /// after SetConstraints(), the constraints are retained and aggregated
1267    /// along with any subsequent logical allocation(s), despite the lack of
1268    /// channel connection.
1269    ///
1270    /// On a BufferCollectionTokenGroup channel:
1271    ///
1272    /// By default, unexpected failure of a BufferCollectionTokenGroup will
1273    /// trigger failure of the logical BufferCollectionTokenGroup and will
1274    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
1275    /// channel without failing the logical group or propagating failure, send
1276    /// Close() before closing the channel client endpoint.
1277    ///
1278    /// If Close() occurs before AllChildrenPresent(), the logical buffer
1279    /// collection will still fail despite the Close() (because sysmem can't be
1280    /// sure whether all relevant children were created, so it's ambiguous
1281    /// whether all relevant constraints will be provided to sysmem).  If
1282    /// Close() occurs after AllChildrenPresent(), the children and all their
1283    /// constraints remain intact (just as they would if the
1284    /// BufferCollectionTokenGroup channel had remained open), and the close
1285    /// doesn't trigger or propagate failure.
1286    pub fn r#close(&self) -> Result<(), fidl::Error> {
1287        BufferCollectionProxyInterface::r#close(self)
1288    }
1289
1290    /// Set a name for VMOs in this buffer collection. The name may be truncated
1291    /// shorter. The name only affects VMOs allocated after it's set - this call
1292    /// does not rename existing VMOs. If multiple clients set different names
1293    /// then the larger priority value will win.
1294    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1295        BufferCollectionProxyInterface::r#set_name(self, priority, name)
1296    }
1297
1298    /// Set information about the current client that can be used by sysmem to
1299    /// help debug leaking memory and hangs waiting for constraints. |name| can
1300    /// be an arbitrary string, but the current process name (see
1301    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1302    /// arbitrary id, but the current process ID (see
1303    /// fsl::GetCurrentProcessKoid()) is a good default.
1304    ///
1305    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
1306    /// indicate which client is closing their channel first, leading to
1307    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
1308    /// over, but if happening earlier than expected, the
1309    /// client-channel-specific name can help diagnose where the failure is
1310    /// first coming from, from sysmem's point of view).
1311    ///
1312    /// By default (unless overriden by this message or using
1313    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
1314    /// parent Node at the time the child Node is created.  While this can be
1315    /// better than nothing, it's often better for each participant to use
1316    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
1317    /// info directly relevant to the current client.  Also, SetVerboseLogging()
1318    /// can be used to help disambiguate if a Node is suspected of having info
1319    /// that was copied from its parent.
1320    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1321        BufferCollectionProxyInterface::r#set_debug_client_info(self, name, id)
1322    }
1323
1324    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
1325    /// after creating a collection. Clients can call this method to change
1326    /// when the log is printed. If multiple client set the deadline, it's
1327    /// unspecified which deadline will take effect.
1328    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1329        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
1330    }
1331
1332    /// Verbose logging includes constraints set via SetConstraints() from each
1333    /// client along with info set via SetDebugClientInfo() and the structure of
1334    /// the tree of Node(s).
1335    ///
1336    /// Normally sysmem prints only a single line complaint when aggregation
1337    /// fails, with just the specific detailed reason that aggregation failed,
1338    /// with minimal context.  While this is often enough to diagnose a problem
1339    /// if only a small change was made and the system had been working before
1340    /// the small change, it's often not particularly helpful for getting a new
1341    /// buffer collection to work for the first time.  Especially with more
1342    /// complex trees of nodes, involving things like AttachToken(),
1343    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
1344    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
1345    /// looks like and why it's failing a logical allocation, or why a tree or
1346    /// sub-tree is failing sooner than expected.
1347    ///
1348    /// The intent of the extra logging is to be acceptable from a performance
1349    /// point of view, if only enabled on a low number of buffer collections.
1350    /// If we're not tracking down a bug, we shouldn't send this message.
1351    ///
1352    /// If too many participants leave verbose logging enabled, we may end up
1353    /// needing to require that system-wide sysmem verbose logging be permitted
1354    /// via some other setting, to avoid sysmem spamming the log too much due to
1355    /// this message.
1356    ///
1357    /// This may be a NOP for some nodes due to intentional policy associated
1358    /// with the node, if we don't trust a node enough to let it turn on verbose
1359    /// logging.
1360    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1361        BufferCollectionProxyInterface::r#set_verbose_logging(self)
1362    }
1363
1364    /// This gets an event handle that can be used as a parameter to
1365    /// IsAlternateFor() called on any Node.  The client will not be granted the
1366    /// right to signal this event, as this handle should only be used as proof
1367    /// that the client obtained this handle from this Node.
1368    ///
1369    /// Because this is a get not a set, no Sync() is needed between the
1370    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
1371    /// potentially being on different channels.
1372    ///
1373    /// See also IsAlternateFor().
1374    pub fn r#get_node_ref(
1375        &self,
1376    ) -> fidl::client::QueryResponseFut<
1377        fdomain_client::Event,
1378        fdomain_client::fidl::FDomainResourceDialect,
1379    > {
1380        BufferCollectionProxyInterface::r#get_node_ref(self)
1381    }
1382
1383    /// This checks whether the calling node is in a subtree rooted at a
1384    /// different child token of a common parent BufferCollectionTokenGroup, in
1385    /// relation to the passed-in node_ref.
1386    ///
1387    /// This call is for assisting with admission control de-duplication, and
1388    /// with debugging.
1389    ///
1390    /// The node_ref must be obtained using GetNodeRef() of a
1391    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
1392    ///
1393    /// The node_ref can be a duplicated handle; it's not necessary to call
1394    /// GetNodeRef() for every call to IsAlternateFor().
1395    ///
1396    /// If a calling token may not actually be a valid token at all due to
1397    /// a potentially hostile/untrusted provider of the token, call
1398    /// ValidateBufferCollectionToken() first instead of potentially getting
1399    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
1400    /// token not being a real token (not really talking to sysmem).  Another
1401    /// option is to call BindSharedCollection with this token first which also
1402    /// validates the token along with converting it to a BufferCollection, then
1403    /// call BufferCollection IsAlternateFor().
1404    ///
1405    /// error values:
1406    ///
1407    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
1408    /// buffer collection as the calling Node.  Before logical allocation and
1409    /// within the same logical allocation sub-tree, this essentially means that
1410    /// the node_ref was never part of this logical buffer collection, since
1411    /// before logical allocation all node_refs that come into existence remain
1412    /// in existence at least until logical allocation (including Node(s) that
1413    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
1414    /// to be returned, this Node's channel needs to still be connected server
1415    /// side, which won't be the case if the whole logical allocation has
1416    /// failed.  After logical allocation or in a different logical allocation
1417    /// sub-tree there are additional potential reasons for this error.  For
1418    /// example a different logical allocation (separated from this Node(s)
1419    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
1420    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
1421    /// exist and may select a different child sub-tree than the sub-tree the
1422    /// node_ref is in causing deletion of the node_ref Node.  The only time
1423    /// sysmem keeps a Node around after that Node has no corresponding channel
1424    /// is when Close() is used and the Node's sub-tree has not yet failed.
1425    /// Another reason for this error is if the node_ref is an eventpair handle
1426    /// with sufficient rights, but isn't actually a real node_ref obtained from
1427    /// GetNodeRef().
1428    ///
1429    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
1430    /// eventpair handle, or doesn't have the needed rights expected on a real
1431    /// node_ref.
1432    ///
1433    /// No other failing status codes are returned by this call.  However,
1434    /// sysmem may add additional codes in future, so the client should have
1435    /// sensible default handling for any failing status code.
1436    ///
1437    /// On success, is_alternate has the following meaning:
1438    ///   * true - The first parent node in common between the calling node and
1439    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
1440    ///     the calling Node and the node_ref Node will _not_ have both their
1441    ///     constraints apply - rather sysmem will choose one or the other of
1442    ///     the constraints - never both.  This is because only one child of
1443    ///     a BufferCollectionTokenGroup is selected during logical allocation,
1444    ///     with only that one child's sub-tree contributing to constraints
1445    ///     aggregation.
1446    ///   * false - The first parent node in common between the calling Node and
1447    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
1448    ///     this means the first parent node in common is a
1449    ///     BufferCollectionToken or BufferCollection (regardless of not
1450    ///     Close()ed or Close()ed).  This means that the calling Node and the
1451    ///     node_ref Node _may_ have both their constraints apply during
1452    ///     constraints aggregation of the logical allocation, if both Node(s)
1453    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
1454    ///     In this case, there is no BufferCollectionTokenGroup that will
1455    ///     directly prevent the two Node(s) from both being selected and their
1456    ///     constraints both aggregated, but even when false, one or both
1457    ///     Node(s) may still be eliminated from consideration if one or both
1458    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
1459    ///     which selects a child sub-tree other than the sub-tree containing
1460    ///     the calling Node or node_ref Node.
1461    pub fn r#is_alternate_for(
1462        &self,
1463        mut node_ref: fdomain_client::Event,
1464    ) -> fidl::client::QueryResponseFut<
1465        NodeIsAlternateForResult,
1466        fdomain_client::fidl::FDomainResourceDialect,
1467    > {
1468        BufferCollectionProxyInterface::r#is_alternate_for(self, node_ref)
1469    }
1470
1471    /// Provide BufferCollectionConstraints to the logical BufferCollection.
1472    ///
1473    /// A participant may only call SetConstraints() once.
1474    ///
1475    /// Sometimes the initiator is a participant only in the sense of wanting to
1476    /// keep an eye on success/failure to populate with buffers, and zx.Status
1477    /// on failure.  In that case, `has_constraints` can be false, and
1478    /// `constraints` will be ignored.
1479    ///
1480    /// VMO handles will not be provided to the client that sends null
1481    /// constraints - that can be intentional for an initiator that doesn't need
1482    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
1483    /// adjusting which portion of a buffer is considered valid and similar, but
1484    /// the initiator can't hold a VMO handle open to prevent the logical
1485    /// BufferCollection from cleaning up if the logical BufferCollection needs
1486    /// to go away regardless of the initiator's degree of involvement for
1487    /// whatever reason.
1488    ///
1489    /// For population of buffers to be attempted, all holders of a
1490    /// BufferCollection client channel need to call SetConstraints() before
1491    /// sysmem will attempt to allocate buffers.
1492    ///
1493    /// `has_constraints` if false, the constraints are effectively null, and
1494    /// `constraints` are ignored.  The sender of null constraints won't get any
1495    /// VMO handles in BufferCollectionInfo, but can still find out how many
1496    /// buffers were allocated and can still refer to buffers by their
1497    /// buffer_index.
1498    ///
1499    /// `constraints` are constraints on the buffer collection.
1500    pub fn r#set_constraints(
1501        &self,
1502        mut has_constraints: bool,
1503        mut constraints: &BufferCollectionConstraints,
1504    ) -> Result<(), fidl::Error> {
1505        BufferCollectionProxyInterface::r#set_constraints(self, has_constraints, constraints)
1506    }
1507
1508    /// This request completes when buffers have been allocated, responds with
1509    /// some failure detail if allocation has been attempted but failed.
1510    ///
1511    /// The following must occur before buffers will be allocated:
1512    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
1513    ///     must be turned in via BindSharedCollection().
1514    ///   * All BufferCollection(s) of the logical BufferCollection must have
1515    ///     had SetConstraints() sent to them.
1516    ///
1517    /// Returns `ZX_OK` if successful.
1518    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
1519    /// fulfilled due to resource exhaustion.
1520    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
1521    /// obtain the buffers it requested.
1522    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
1523    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
1524    /// satisfied, perhaps due to hardware limitations.
1525    ///
1526    /// `buffer_collection_info` has the VMO handles and other related info.
1527    pub fn r#wait_for_buffers_allocated(
1528        &self,
1529    ) -> fidl::client::QueryResponseFut<
1530        (i32, BufferCollectionInfo2),
1531        fdomain_client::fidl::FDomainResourceDialect,
1532    > {
1533        BufferCollectionProxyInterface::r#wait_for_buffers_allocated(self)
1534    }
1535
1536    /// This returns the same result code as WaitForBuffersAllocated if the
1537    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
1538    /// if WaitForBuffersAllocated would block.
1539    pub fn r#check_buffers_allocated(
1540        &self,
1541    ) -> fidl::client::QueryResponseFut<i32, fdomain_client::fidl::FDomainResourceDialect> {
1542        BufferCollectionProxyInterface::r#check_buffers_allocated(self)
1543    }
1544
1545    /// Create a new token, for trying to add a new participant to an existing
1546    /// collection, if the existing collection's buffer counts, constraints,
1547    /// and participants allow.
1548    ///
1549    /// This can be useful in replacing a failed participant, and/or in
1550    /// adding/re-adding a participant after buffers have already been
1551    /// allocated.
1552    ///
1553    /// Failure of an attached token / collection does not propagate to the
1554    /// parent of the attached token.  Failure does propagate from a normal
1555    /// child of a dispensable token to the dispensable token.  Failure
1556    /// of a child is blocked from reaching its parent if the child is attached,
1557    /// or if the child is dispensable and the failure occurred after logical
1558    /// allocation.
1559    ///
1560    /// An initiator may in some scenarios choose to initially use a dispensable
1561    /// token for a given instance of a participant, and then later if the first
1562    /// instance of that participant fails, a new second instance of that
1563    /// participant my be given a token created with AttachToken().
1564    ///
1565    /// From the point of view of the client end of the BufferCollectionToken
1566    /// channel, the token acts like any other token.  The client can
1567    /// Duplicate() the token as needed, and can send the token to a different
1568    /// process.  The token should be converted to a BufferCollection channel
1569    /// as normal by calling BindSharedCollection().  SetConstraints() should
1570    /// be called on that BufferCollection channel.
1571    ///
1572    /// A success result from WaitForBuffersAllocated() means the new
1573    /// participant's constraints were satisfiable using the already-existing
1574    /// buffer collection, the already-established BufferCollectionInfo
1575    /// including image format constraints, and the already-existing other
1576    /// participants and their buffer counts.  A failure result means the new
1577    /// participant's constraints cannot be satisfied using the existing
1578    /// buffer collection and its already-logically-allocated participants.
1579    /// Creating a new collection instead may allow all participant's
1580    /// constraints to be satisfied, assuming SetDispensable() is used in place
1581    /// of AttachToken(), or a normal token is used.
1582    ///
1583    /// A token created with AttachToken() performs constraints aggregation with
1584    /// all constraints currently in effect on the buffer collection, plus the
1585    /// attached token under consideration plus child tokens under the attached
1586    /// token which are not themselves an attached token or under such a token.
1587    ///
1588    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
1589    /// first-come first-served, but a child can't logically allocate before
1590    /// all its parents have sent SetConstraints().
1591    ///
1592    /// See also SetDispensable(), which in contrast to AttachToken(), has the
1593    /// created token + children participate in constraints aggregation along
1594    /// with its parent.
1595    ///
1596    /// The newly created token needs to be Sync()ed to sysmem before the new
1597    /// token can be passed to BindSharedCollection().  The Sync() of the new
1598    /// token can be accomplished with BufferCollection.Sync() on this
1599    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
1600    /// token also works.  A BufferCollectionToken.Sync() can be started after
1601    /// any BufferCollectionToken.Duplicate() messages have been sent via the
1602    /// newly created token, to also sync those additional tokens to sysmem
1603    /// using a single round-trip.
1604    ///
1605    /// These values for rights_attenuation_mask result in no attenuation (note
1606    /// that 0 is not on this list; 0 will output an ERROR to the system log
1607    /// to help diagnose the bug in client code):
1608    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
1609    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
1610    pub fn r#attach_token(
1611        &self,
1612        mut rights_attenuation_mask: u32,
1613        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1614    ) -> Result<(), fidl::Error> {
1615        BufferCollectionProxyInterface::r#attach_token(self, rights_attenuation_mask, token_request)
1616    }
1617
1618    /// AttachLifetimeTracking:
1619    ///
1620    /// AttachLifetimeTracking() is intended to allow a client to wait until an
1621    /// old logical buffer collection is fully or mostly deallocated before
1622    /// attempting allocation of a new logical buffer collection.
1623    ///
1624    /// Attach an eventpair endpoint to the logical buffer collection, so that
1625    /// the server_end will be closed when the number of buffers allocated
1626    /// drops to 'buffers_remaining'.  The server_end won't close until after
1627    /// logical allocation has completed.
1628    ///
1629    /// If logical allocation fails, such as for an attached sub-tree (using
1630    /// AttachToken()), the server_end will close during that failure regardless
1631    /// of the number of buffers potenitally allocated in the overall logical
1632    /// buffer collection.
1633    ///
1634    /// The lifetime signalled by this event includes asynchronous cleanup of
1635    /// allocated buffers, and this asynchronous cleanup cannot occur until all
1636    /// holders of VMO handles to the buffers have closed those VMO handles.
1637    /// Therefore clients should take care not to become blocked forever waiting
1638    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
1639    /// participants using the logical buffer collection are less trusted or
1640    /// less reliable.
1641    ///
1642    /// The buffers_remaining parameter allows waiting for all but
1643    /// buffers_remaining buffers to be fully deallocated.  This can be useful
1644    /// in situations where a known number of buffers are intentionally not
1645    /// closed so that the data can continue to be used, such as for keeping the
1646    /// last available video picture displayed in the UI even if the video
1647    /// stream was using protected output buffers.  It's outside the scope of
1648    /// the BufferCollection interface (at least for now) to determine how many
1649    /// buffers may be held without closing, but it'll typically be in the range
1650    /// 0-2.
1651    ///
1652    /// This mechanism is meant to be compatible with other protocols providing
1653    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
1654    /// same event can be sent to more than one AttachLifetimeTracking(), and
1655    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
1656    /// over conditions are met (all holders of duplicates have closed their
1657    /// handle(s)).
1658    ///
1659    /// There is no way to cancel an attach.  Closing the client end of the
1660    /// eventpair doesn't subtract from the number of pending attach(es).
1661    ///
1662    /// Closing the client's end doesn't result in any action by the server.
1663    /// If the server listens to events from the client end at all, it is for
1664    /// debug logging only.
1665    ///
1666    /// The server intentionally doesn't "trust" any bits signalled by the
1667    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
1668    /// which can't be triggered early, and is only triggered when all handles
1669    /// to server_end are closed.  No meaning is associated with any of the
1670    /// other signal bits, and clients should functionally ignore any other
1671    /// signal bits on either end of the eventpair or its peer.
1672    ///
1673    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
1674    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
1675    /// transfer without causing CodecFactory channel failure).
1676    pub fn r#attach_lifetime_tracking(
1677        &self,
1678        mut server_end: fdomain_client::EventPair,
1679        mut buffers_remaining: u32,
1680    ) -> Result<(), fidl::Error> {
1681        BufferCollectionProxyInterface::r#attach_lifetime_tracking(
1682            self,
1683            server_end,
1684            buffers_remaining,
1685        )
1686    }
1687}
1688
1689impl BufferCollectionProxyInterface for BufferCollectionProxy {
1690    type SyncResponseFut =
1691        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1692    fn r#sync(&self) -> Self::SyncResponseFut {
1693        fn _decode(
1694            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1695        ) -> Result<(), fidl::Error> {
1696            let _response = fidl::client::decode_transaction_body::<
1697                fidl::encoding::EmptyPayload,
1698                fdomain_client::fidl::FDomainResourceDialect,
1699                0x4577e238ae26291,
1700            >(_buf?)?;
1701            Ok(_response)
1702        }
1703        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1704            (),
1705            0x4577e238ae26291,
1706            fidl::encoding::DynamicFlags::empty(),
1707            _decode,
1708        )
1709    }
1710
1711    fn r#close(&self) -> Result<(), fidl::Error> {
1712        self.client.send::<fidl::encoding::EmptyPayload>(
1713            (),
1714            0x5b1d7a4f5681fca7,
1715            fidl::encoding::DynamicFlags::empty(),
1716        )
1717    }
1718
1719    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1720        self.client.send::<NodeSetNameRequest>(
1721            (priority, name),
1722            0x77a41bb6217e2443,
1723            fidl::encoding::DynamicFlags::empty(),
1724        )
1725    }
1726
1727    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1728        self.client.send::<NodeSetDebugClientInfoRequest>(
1729            (name, id),
1730            0x7275759070eb5ee2,
1731            fidl::encoding::DynamicFlags::empty(),
1732        )
1733    }
1734
1735    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1736        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
1737            (deadline,),
1738            0x46d38f4772638867,
1739            fidl::encoding::DynamicFlags::empty(),
1740        )
1741    }
1742
1743    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1744        self.client.send::<fidl::encoding::EmptyPayload>(
1745            (),
1746            0x6bfbe2cf1701d288,
1747            fidl::encoding::DynamicFlags::empty(),
1748        )
1749    }
1750
1751    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
1752        fdomain_client::Event,
1753        fdomain_client::fidl::FDomainResourceDialect,
1754    >;
1755    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
1756        fn _decode(
1757            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1758        ) -> Result<fdomain_client::Event, fidl::Error> {
1759            let _response = fidl::client::decode_transaction_body::<
1760                NodeGetNodeRefResponse,
1761                fdomain_client::fidl::FDomainResourceDialect,
1762                0x467b7c75c35c3b84,
1763            >(_buf?)?;
1764            Ok(_response.node_ref)
1765        }
1766        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
1767            (),
1768            0x467b7c75c35c3b84,
1769            fidl::encoding::DynamicFlags::empty(),
1770            _decode,
1771        )
1772    }
1773
1774    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
1775        NodeIsAlternateForResult,
1776        fdomain_client::fidl::FDomainResourceDialect,
1777    >;
1778    fn r#is_alternate_for(
1779        &self,
1780        mut node_ref: fdomain_client::Event,
1781    ) -> Self::IsAlternateForResponseFut {
1782        fn _decode(
1783            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1784        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
1785            let _response = fidl::client::decode_transaction_body::<
1786                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
1787                fdomain_client::fidl::FDomainResourceDialect,
1788                0x33a2a7aff2776c07,
1789            >(_buf?)?;
1790            Ok(_response.map(|x| x.is_alternate))
1791        }
1792        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
1793            (node_ref,),
1794            0x33a2a7aff2776c07,
1795            fidl::encoding::DynamicFlags::empty(),
1796            _decode,
1797        )
1798    }
1799
1800    fn r#set_constraints(
1801        &self,
1802        mut has_constraints: bool,
1803        mut constraints: &BufferCollectionConstraints,
1804    ) -> Result<(), fidl::Error> {
1805        self.client.send::<BufferCollectionSetConstraintsRequest>(
1806            (has_constraints, constraints),
1807            0x4d9c3406c213227b,
1808            fidl::encoding::DynamicFlags::empty(),
1809        )
1810    }
1811
1812    type WaitForBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
1813        (i32, BufferCollectionInfo2),
1814        fdomain_client::fidl::FDomainResourceDialect,
1815    >;
1816    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut {
1817        fn _decode(
1818            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1819        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1820            let _response = fidl::client::decode_transaction_body::<
1821                BufferCollectionWaitForBuffersAllocatedResponse,
1822                fdomain_client::fidl::FDomainResourceDialect,
1823                0x714667ea2a29a3a2,
1824            >(_buf?)?;
1825            Ok((_response.status, _response.buffer_collection_info))
1826        }
1827        self.client
1828            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
1829                (),
1830                0x714667ea2a29a3a2,
1831                fidl::encoding::DynamicFlags::empty(),
1832                _decode,
1833            )
1834    }
1835
1836    type CheckBuffersAllocatedResponseFut =
1837        fidl::client::QueryResponseFut<i32, fdomain_client::fidl::FDomainResourceDialect>;
1838    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut {
1839        fn _decode(
1840            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1841        ) -> Result<i32, fidl::Error> {
1842            let _response = fidl::client::decode_transaction_body::<
1843                BufferCollectionCheckBuffersAllocatedResponse,
1844                fdomain_client::fidl::FDomainResourceDialect,
1845                0x245bb81f79189e9,
1846            >(_buf?)?;
1847            Ok(_response.status)
1848        }
1849        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
1850            (),
1851            0x245bb81f79189e9,
1852            fidl::encoding::DynamicFlags::empty(),
1853            _decode,
1854        )
1855    }
1856
1857    fn r#attach_token(
1858        &self,
1859        mut rights_attenuation_mask: u32,
1860        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1861    ) -> Result<(), fidl::Error> {
1862        self.client.send::<BufferCollectionAttachTokenRequest>(
1863            (rights_attenuation_mask, token_request),
1864            0x6f5adcca4ac7443e,
1865            fidl::encoding::DynamicFlags::empty(),
1866        )
1867    }
1868
1869    fn r#attach_lifetime_tracking(
1870        &self,
1871        mut server_end: fdomain_client::EventPair,
1872        mut buffers_remaining: u32,
1873    ) -> Result<(), fidl::Error> {
1874        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
1875            (server_end, buffers_remaining),
1876            0x170d0f1d89d50989,
1877            fidl::encoding::DynamicFlags::empty(),
1878        )
1879    }
1880}
1881
1882pub struct BufferCollectionEventStream {
1883    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1884}
1885
1886impl std::marker::Unpin for BufferCollectionEventStream {}
1887
1888impl futures::stream::FusedStream for BufferCollectionEventStream {
1889    fn is_terminated(&self) -> bool {
1890        self.event_receiver.is_terminated()
1891    }
1892}
1893
1894impl futures::Stream for BufferCollectionEventStream {
1895    type Item = Result<BufferCollectionEvent, fidl::Error>;
1896
1897    fn poll_next(
1898        mut self: std::pin::Pin<&mut Self>,
1899        cx: &mut std::task::Context<'_>,
1900    ) -> std::task::Poll<Option<Self::Item>> {
1901        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1902            &mut self.event_receiver,
1903            cx
1904        )?) {
1905            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
1906            None => std::task::Poll::Ready(None),
1907        }
1908    }
1909}
1910
1911#[derive(Debug)]
1912pub enum BufferCollectionEvent {}
1913
1914impl BufferCollectionEvent {
1915    /// Decodes a message buffer as a [`BufferCollectionEvent`].
1916    fn decode(
1917        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1918    ) -> Result<BufferCollectionEvent, fidl::Error> {
1919        let (bytes, _handles) = buf.split_mut();
1920        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1921        debug_assert_eq!(tx_header.tx_id, 0);
1922        match tx_header.ordinal {
1923            _ => Err(fidl::Error::UnknownOrdinal {
1924                ordinal: tx_header.ordinal,
1925                protocol_name:
1926                    <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1927            }),
1928        }
1929    }
1930}
1931
1932/// A Stream of incoming requests for fuchsia.sysmem/BufferCollection.
1933pub struct BufferCollectionRequestStream {
1934    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1935    is_terminated: bool,
1936}
1937
1938impl std::marker::Unpin for BufferCollectionRequestStream {}
1939
1940impl futures::stream::FusedStream for BufferCollectionRequestStream {
1941    fn is_terminated(&self) -> bool {
1942        self.is_terminated
1943    }
1944}
1945
1946impl fdomain_client::fidl::RequestStream for BufferCollectionRequestStream {
1947    type Protocol = BufferCollectionMarker;
1948    type ControlHandle = BufferCollectionControlHandle;
1949
1950    fn from_channel(channel: fdomain_client::Channel) -> Self {
1951        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1952    }
1953
1954    fn control_handle(&self) -> Self::ControlHandle {
1955        BufferCollectionControlHandle { inner: self.inner.clone() }
1956    }
1957
1958    fn into_inner(
1959        self,
1960    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1961    {
1962        (self.inner, self.is_terminated)
1963    }
1964
1965    fn from_inner(
1966        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1967        is_terminated: bool,
1968    ) -> Self {
1969        Self { inner, is_terminated }
1970    }
1971}
1972
1973impl futures::Stream for BufferCollectionRequestStream {
1974    type Item = Result<BufferCollectionRequest, fidl::Error>;
1975
1976    fn poll_next(
1977        mut self: std::pin::Pin<&mut Self>,
1978        cx: &mut std::task::Context<'_>,
1979    ) -> std::task::Poll<Option<Self::Item>> {
1980        let this = &mut *self;
1981        if this.inner.check_shutdown(cx) {
1982            this.is_terminated = true;
1983            return std::task::Poll::Ready(None);
1984        }
1985        if this.is_terminated {
1986            panic!("polled BufferCollectionRequestStream after completion");
1987        }
1988        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1989            |bytes, handles| {
1990                match this.inner.channel().read_etc(cx, bytes, handles) {
1991                    std::task::Poll::Ready(Ok(())) => {}
1992                    std::task::Poll::Pending => return std::task::Poll::Pending,
1993                    std::task::Poll::Ready(Err(None)) => {
1994                        this.is_terminated = true;
1995                        return std::task::Poll::Ready(None);
1996                    }
1997                    std::task::Poll::Ready(Err(Some(e))) => {
1998                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1999                            e.into(),
2000                        ))));
2001                    }
2002                }
2003
2004                // A message has been received from the channel
2005                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2006
2007                std::task::Poll::Ready(Some(match header.ordinal {
2008                0x4577e238ae26291 => {
2009                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2010                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2011                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2012                    let control_handle = BufferCollectionControlHandle {
2013                        inner: this.inner.clone(),
2014                    };
2015                    Ok(BufferCollectionRequest::Sync {
2016                        responder: BufferCollectionSyncResponder {
2017                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2018                            tx_id: header.tx_id,
2019                        },
2020                    })
2021                }
2022                0x5b1d7a4f5681fca7 => {
2023                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2024                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2025                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2026                    let control_handle = BufferCollectionControlHandle {
2027                        inner: this.inner.clone(),
2028                    };
2029                    Ok(BufferCollectionRequest::Close {
2030                        control_handle,
2031                    })
2032                }
2033                0x77a41bb6217e2443 => {
2034                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2035                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
2036                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2037                    let control_handle = BufferCollectionControlHandle {
2038                        inner: this.inner.clone(),
2039                    };
2040                    Ok(BufferCollectionRequest::SetName {priority: req.priority,
2041name: req.name,
2042
2043                        control_handle,
2044                    })
2045                }
2046                0x7275759070eb5ee2 => {
2047                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2048                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
2049                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
2050                    let control_handle = BufferCollectionControlHandle {
2051                        inner: this.inner.clone(),
2052                    };
2053                    Ok(BufferCollectionRequest::SetDebugClientInfo {name: req.name,
2054id: req.id,
2055
2056                        control_handle,
2057                    })
2058                }
2059                0x46d38f4772638867 => {
2060                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2061                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
2062                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2063                    let control_handle = BufferCollectionControlHandle {
2064                        inner: this.inner.clone(),
2065                    };
2066                    Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
2067
2068                        control_handle,
2069                    })
2070                }
2071                0x6bfbe2cf1701d288 => {
2072                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2073                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2074                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2075                    let control_handle = BufferCollectionControlHandle {
2076                        inner: this.inner.clone(),
2077                    };
2078                    Ok(BufferCollectionRequest::SetVerboseLogging {
2079                        control_handle,
2080                    })
2081                }
2082                0x467b7c75c35c3b84 => {
2083                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2084                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2085                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2086                    let control_handle = BufferCollectionControlHandle {
2087                        inner: this.inner.clone(),
2088                    };
2089                    Ok(BufferCollectionRequest::GetNodeRef {
2090                        responder: BufferCollectionGetNodeRefResponder {
2091                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2092                            tx_id: header.tx_id,
2093                        },
2094                    })
2095                }
2096                0x33a2a7aff2776c07 => {
2097                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2098                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
2099                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
2100                    let control_handle = BufferCollectionControlHandle {
2101                        inner: this.inner.clone(),
2102                    };
2103                    Ok(BufferCollectionRequest::IsAlternateFor {node_ref: req.node_ref,
2104
2105                        responder: BufferCollectionIsAlternateForResponder {
2106                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2107                            tx_id: header.tx_id,
2108                        },
2109                    })
2110                }
2111                0x4d9c3406c213227b => {
2112                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2113                    let mut req = fidl::new_empty!(BufferCollectionSetConstraintsRequest, fdomain_client::fidl::FDomainResourceDialect);
2114                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
2115                    let control_handle = BufferCollectionControlHandle {
2116                        inner: this.inner.clone(),
2117                    };
2118                    Ok(BufferCollectionRequest::SetConstraints {has_constraints: req.has_constraints,
2119constraints: req.constraints,
2120
2121                        control_handle,
2122                    })
2123                }
2124                0x714667ea2a29a3a2 => {
2125                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2126                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2127                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2128                    let control_handle = BufferCollectionControlHandle {
2129                        inner: this.inner.clone(),
2130                    };
2131                    Ok(BufferCollectionRequest::WaitForBuffersAllocated {
2132                        responder: BufferCollectionWaitForBuffersAllocatedResponder {
2133                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2134                            tx_id: header.tx_id,
2135                        },
2136                    })
2137                }
2138                0x245bb81f79189e9 => {
2139                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2140                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2141                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2142                    let control_handle = BufferCollectionControlHandle {
2143                        inner: this.inner.clone(),
2144                    };
2145                    Ok(BufferCollectionRequest::CheckBuffersAllocated {
2146                        responder: BufferCollectionCheckBuffersAllocatedResponder {
2147                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2148                            tx_id: header.tx_id,
2149                        },
2150                    })
2151                }
2152                0x6f5adcca4ac7443e => {
2153                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2154                    let mut req = fidl::new_empty!(BufferCollectionAttachTokenRequest, fdomain_client::fidl::FDomainResourceDialect);
2155                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
2156                    let control_handle = BufferCollectionControlHandle {
2157                        inner: this.inner.clone(),
2158                    };
2159                    Ok(BufferCollectionRequest::AttachToken {rights_attenuation_mask: req.rights_attenuation_mask,
2160token_request: req.token_request,
2161
2162                        control_handle,
2163                    })
2164                }
2165                0x170d0f1d89d50989 => {
2166                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2167                    let mut req = fidl::new_empty!(BufferCollectionAttachLifetimeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
2168                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
2169                    let control_handle = BufferCollectionControlHandle {
2170                        inner: this.inner.clone(),
2171                    };
2172                    Ok(BufferCollectionRequest::AttachLifetimeTracking {server_end: req.server_end,
2173buffers_remaining: req.buffers_remaining,
2174
2175                        control_handle,
2176                    })
2177                }
2178                _ => Err(fidl::Error::UnknownOrdinal {
2179                    ordinal: header.ordinal,
2180                    protocol_name: <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2181                }),
2182            }))
2183            },
2184        )
2185    }
2186}
2187
2188/// BufferCollection is a connection directly from a participant to sysmem re.
2189/// a logical BufferCollection; typically the logical BufferCollection is shared
2190/// with other participants.  In other words, an instance of the BufferCollection
2191/// interface is a view of a "logical buffer collection".
2192///
2193/// This connection exists to facilitate async indication of when the logical
2194/// BufferCollection has been populated with buffers.
2195///
2196/// Also, the channel's closure by the server is an indication to the client
2197/// that the client should close all VMO handles that were obtained from the
2198/// BufferCollection ASAP.
2199///
2200/// Also, this interface may in future allow specifying constraints in other
2201/// ways, and may allow for back-and-forth negotiation of constraints to some
2202/// degree.
2203///
2204/// This interface may in future allow for more than 64 VMO handles per
2205/// BufferCollection, but currently the limit is 64.
2206///
2207/// This interface may in future allow for allocating/deallocating single
2208/// buffers.
2209///
2210/// Some initiators may wait a short duration until all old logical
2211/// BufferCollection VMO handles have closed (or until the short duration times
2212/// out) before allocating a new BufferCollection, to help control physical
2213/// memory fragmentation and avoid overlap of buffer allocation lifetimes for
2214/// the old and new collections. Collections can be large enough that it's worth
2215/// avoiding allocation overlap (in time).
2216#[derive(Debug)]
2217pub enum BufferCollectionRequest {
2218    /// Ensure that previous messages, including Duplicate() messages on a
2219    /// token, collection, or group, have been received server side.
2220    ///
2221    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
2222    /// valid sysmem token risks the Sync() hanging forever.  See
2223    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
2224    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
2225    /// Another way is to pass the token to BindSharedCollection(), which also
2226    /// validates the token as part of exchanging it for a BufferCollection
2227    /// channel, and BufferCollection Sync() can then be used.
2228    ///
2229    /// After a Sync(), it's then safe to send the client end of token_request
2230    /// to another participant knowing the server will recognize the token when
2231    /// it's sent into BindSharedCollection() by the other participant.
2232    ///
2233    /// Other options include waiting for each token.Duplicate() to complete
2234    /// individually (using separate call to token.Sync() after each), or
2235    /// calling Sync() on BufferCollection after the token has been turned in
2236    /// via BindSharedCollection().
2237    ///
2238    /// Another way to mitigate is to avoid calling Sync() on the token, and
2239    /// instead later deal with potential failure of BufferCollection.Sync() if
2240    /// the original token was invalid.  This option can be preferable from a
2241    /// performance point of view, but requires client code to delay sending
2242    /// tokens duplicated from this token until after client code has converted
2243    /// the duplicating token to a BufferCollection and received successful
2244    /// response from BufferCollection.Sync().
2245    ///
2246    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
2247    /// When BufferCollection.Sync() isn't feasible, the caller must already
2248    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
2249    /// hang forever.  See ValidateBufferCollectionToken() to check token
2250    /// validity first if the token isn't already known to be (is/was) valid.
2251    Sync { responder: BufferCollectionSyncResponder },
2252    /// On a BufferCollectionToken channel:
2253    ///
2254    /// Normally a participant will convert a BufferCollectionToken into a
2255    /// BufferCollection view, but a participant is also free to Close() the
2256    /// token (and then close the channel immediately or shortly later in
2257    /// response to server closing its end), which avoids causing logical buffer
2258    /// collection failure.  Normally an unexpected token channel close will
2259    /// cause logical buffer collection failure (the only exceptions being
2260    /// certain cases involving AttachToken() or SetDispensable()).
2261    ///
2262    /// On a BufferCollection channel:
2263    ///
2264    /// By default the server handles unexpected failure of a BufferCollection
2265    /// by failing the whole logical buffer collection.  Partly this is to
2266    /// expedite closing VMO handles to reclaim memory when any participant
2267    /// fails.  If a participant would like to cleanly close a BufferCollection
2268    /// view without causing logical buffer collection failure, the participant
2269    /// can send Close() before closing the client end of the BufferCollection
2270    /// channel.  If this is the last BufferCollection view, the logical buffer
2271    /// collection will still go away.  The Close() can occur before or after
2272    /// SetConstraints().  If before SetConstraints(), the buffer collection
2273    /// won't require constraints from this node in order to allocate.  If
2274    /// after SetConstraints(), the constraints are retained and aggregated
2275    /// along with any subsequent logical allocation(s), despite the lack of
2276    /// channel connection.
2277    ///
2278    /// On a BufferCollectionTokenGroup channel:
2279    ///
2280    /// By default, unexpected failure of a BufferCollectionTokenGroup will
2281    /// trigger failure of the logical BufferCollectionTokenGroup and will
2282    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
2283    /// channel without failing the logical group or propagating failure, send
2284    /// Close() before closing the channel client endpoint.
2285    ///
2286    /// If Close() occurs before AllChildrenPresent(), the logical buffer
2287    /// collection will still fail despite the Close() (because sysmem can't be
2288    /// sure whether all relevant children were created, so it's ambiguous
2289    /// whether all relevant constraints will be provided to sysmem).  If
2290    /// Close() occurs after AllChildrenPresent(), the children and all their
2291    /// constraints remain intact (just as they would if the
2292    /// BufferCollectionTokenGroup channel had remained open), and the close
2293    /// doesn't trigger or propagate failure.
2294    Close { control_handle: BufferCollectionControlHandle },
2295    /// Set a name for VMOs in this buffer collection. The name may be truncated
2296    /// shorter. The name only affects VMOs allocated after it's set - this call
2297    /// does not rename existing VMOs. If multiple clients set different names
2298    /// then the larger priority value will win.
2299    SetName { priority: u32, name: String, control_handle: BufferCollectionControlHandle },
2300    /// Set information about the current client that can be used by sysmem to
2301    /// help debug leaking memory and hangs waiting for constraints. |name| can
2302    /// be an arbitrary string, but the current process name (see
2303    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
2304    /// arbitrary id, but the current process ID (see
2305    /// fsl::GetCurrentProcessKoid()) is a good default.
2306    ///
2307    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
2308    /// indicate which client is closing their channel first, leading to
2309    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
2310    /// over, but if happening earlier than expected, the
2311    /// client-channel-specific name can help diagnose where the failure is
2312    /// first coming from, from sysmem's point of view).
2313    ///
2314    /// By default (unless overriden by this message or using
2315    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
2316    /// parent Node at the time the child Node is created.  While this can be
2317    /// better than nothing, it's often better for each participant to use
2318    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
2319    /// info directly relevant to the current client.  Also, SetVerboseLogging()
2320    /// can be used to help disambiguate if a Node is suspected of having info
2321    /// that was copied from its parent.
2322    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionControlHandle },
2323    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
2324    /// after creating a collection. Clients can call this method to change
2325    /// when the log is printed. If multiple client set the deadline, it's
2326    /// unspecified which deadline will take effect.
2327    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionControlHandle },
2328    /// Verbose logging includes constraints set via SetConstraints() from each
2329    /// client along with info set via SetDebugClientInfo() and the structure of
2330    /// the tree of Node(s).
2331    ///
2332    /// Normally sysmem prints only a single line complaint when aggregation
2333    /// fails, with just the specific detailed reason that aggregation failed,
2334    /// with minimal context.  While this is often enough to diagnose a problem
2335    /// if only a small change was made and the system had been working before
2336    /// the small change, it's often not particularly helpful for getting a new
2337    /// buffer collection to work for the first time.  Especially with more
2338    /// complex trees of nodes, involving things like AttachToken(),
2339    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
2340    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
2341    /// looks like and why it's failing a logical allocation, or why a tree or
2342    /// sub-tree is failing sooner than expected.
2343    ///
2344    /// The intent of the extra logging is to be acceptable from a performance
2345    /// point of view, if only enabled on a low number of buffer collections.
2346    /// If we're not tracking down a bug, we shouldn't send this message.
2347    ///
2348    /// If too many participants leave verbose logging enabled, we may end up
2349    /// needing to require that system-wide sysmem verbose logging be permitted
2350    /// via some other setting, to avoid sysmem spamming the log too much due to
2351    /// this message.
2352    ///
2353    /// This may be a NOP for some nodes due to intentional policy associated
2354    /// with the node, if we don't trust a node enough to let it turn on verbose
2355    /// logging.
2356    SetVerboseLogging { control_handle: BufferCollectionControlHandle },
2357    /// This gets an event handle that can be used as a parameter to
2358    /// IsAlternateFor() called on any Node.  The client will not be granted the
2359    /// right to signal this event, as this handle should only be used as proof
2360    /// that the client obtained this handle from this Node.
2361    ///
2362    /// Because this is a get not a set, no Sync() is needed between the
2363    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
2364    /// potentially being on different channels.
2365    ///
2366    /// See also IsAlternateFor().
2367    GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
2368    /// This checks whether the calling node is in a subtree rooted at a
2369    /// different child token of a common parent BufferCollectionTokenGroup, in
2370    /// relation to the passed-in node_ref.
2371    ///
2372    /// This call is for assisting with admission control de-duplication, and
2373    /// with debugging.
2374    ///
2375    /// The node_ref must be obtained using GetNodeRef() of a
2376    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
2377    ///
2378    /// The node_ref can be a duplicated handle; it's not necessary to call
2379    /// GetNodeRef() for every call to IsAlternateFor().
2380    ///
2381    /// If a calling token may not actually be a valid token at all due to
2382    /// a potentially hostile/untrusted provider of the token, call
2383    /// ValidateBufferCollectionToken() first instead of potentially getting
2384    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
2385    /// token not being a real token (not really talking to sysmem).  Another
2386    /// option is to call BindSharedCollection with this token first which also
2387    /// validates the token along with converting it to a BufferCollection, then
2388    /// call BufferCollection IsAlternateFor().
2389    ///
2390    /// error values:
2391    ///
2392    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
2393    /// buffer collection as the calling Node.  Before logical allocation and
2394    /// within the same logical allocation sub-tree, this essentially means that
2395    /// the node_ref was never part of this logical buffer collection, since
2396    /// before logical allocation all node_refs that come into existence remain
2397    /// in existence at least until logical allocation (including Node(s) that
2398    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
2399    /// to be returned, this Node's channel needs to still be connected server
2400    /// side, which won't be the case if the whole logical allocation has
2401    /// failed.  After logical allocation or in a different logical allocation
2402    /// sub-tree there are additional potential reasons for this error.  For
2403    /// example a different logical allocation (separated from this Node(s)
2404    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
2405    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
2406    /// exist and may select a different child sub-tree than the sub-tree the
2407    /// node_ref is in causing deletion of the node_ref Node.  The only time
2408    /// sysmem keeps a Node around after that Node has no corresponding channel
2409    /// is when Close() is used and the Node's sub-tree has not yet failed.
2410    /// Another reason for this error is if the node_ref is an eventpair handle
2411    /// with sufficient rights, but isn't actually a real node_ref obtained from
2412    /// GetNodeRef().
2413    ///
2414    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
2415    /// eventpair handle, or doesn't have the needed rights expected on a real
2416    /// node_ref.
2417    ///
2418    /// No other failing status codes are returned by this call.  However,
2419    /// sysmem may add additional codes in future, so the client should have
2420    /// sensible default handling for any failing status code.
2421    ///
2422    /// On success, is_alternate has the following meaning:
2423    ///   * true - The first parent node in common between the calling node and
2424    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
2425    ///     the calling Node and the node_ref Node will _not_ have both their
2426    ///     constraints apply - rather sysmem will choose one or the other of
2427    ///     the constraints - never both.  This is because only one child of
2428    ///     a BufferCollectionTokenGroup is selected during logical allocation,
2429    ///     with only that one child's sub-tree contributing to constraints
2430    ///     aggregation.
2431    ///   * false - The first parent node in common between the calling Node and
2432    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
2433    ///     this means the first parent node in common is a
2434    ///     BufferCollectionToken or BufferCollection (regardless of not
2435    ///     Close()ed or Close()ed).  This means that the calling Node and the
2436    ///     node_ref Node _may_ have both their constraints apply during
2437    ///     constraints aggregation of the logical allocation, if both Node(s)
2438    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
2439    ///     In this case, there is no BufferCollectionTokenGroup that will
2440    ///     directly prevent the two Node(s) from both being selected and their
2441    ///     constraints both aggregated, but even when false, one or both
2442    ///     Node(s) may still be eliminated from consideration if one or both
2443    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
2444    ///     which selects a child sub-tree other than the sub-tree containing
2445    ///     the calling Node or node_ref Node.
2446    IsAlternateFor {
2447        node_ref: fdomain_client::Event,
2448        responder: BufferCollectionIsAlternateForResponder,
2449    },
2450    /// Provide BufferCollectionConstraints to the logical BufferCollection.
2451    ///
2452    /// A participant may only call SetConstraints() once.
2453    ///
2454    /// Sometimes the initiator is a participant only in the sense of wanting to
2455    /// keep an eye on success/failure to populate with buffers, and zx.Status
2456    /// on failure.  In that case, `has_constraints` can be false, and
2457    /// `constraints` will be ignored.
2458    ///
2459    /// VMO handles will not be provided to the client that sends null
2460    /// constraints - that can be intentional for an initiator that doesn't need
2461    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
2462    /// adjusting which portion of a buffer is considered valid and similar, but
2463    /// the initiator can't hold a VMO handle open to prevent the logical
2464    /// BufferCollection from cleaning up if the logical BufferCollection needs
2465    /// to go away regardless of the initiator's degree of involvement for
2466    /// whatever reason.
2467    ///
2468    /// For population of buffers to be attempted, all holders of a
2469    /// BufferCollection client channel need to call SetConstraints() before
2470    /// sysmem will attempt to allocate buffers.
2471    ///
2472    /// `has_constraints` if false, the constraints are effectively null, and
2473    /// `constraints` are ignored.  The sender of null constraints won't get any
2474    /// VMO handles in BufferCollectionInfo, but can still find out how many
2475    /// buffers were allocated and can still refer to buffers by their
2476    /// buffer_index.
2477    ///
2478    /// `constraints` are constraints on the buffer collection.
2479    SetConstraints {
2480        has_constraints: bool,
2481        constraints: BufferCollectionConstraints,
2482        control_handle: BufferCollectionControlHandle,
2483    },
2484    /// This request completes when buffers have been allocated, responds with
2485    /// some failure detail if allocation has been attempted but failed.
2486    ///
2487    /// The following must occur before buffers will be allocated:
2488    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
2489    ///     must be turned in via BindSharedCollection().
2490    ///   * All BufferCollection(s) of the logical BufferCollection must have
2491    ///     had SetConstraints() sent to them.
2492    ///
2493    /// Returns `ZX_OK` if successful.
2494    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
2495    /// fulfilled due to resource exhaustion.
2496    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
2497    /// obtain the buffers it requested.
2498    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
2499    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
2500    /// satisfied, perhaps due to hardware limitations.
2501    ///
2502    /// `buffer_collection_info` has the VMO handles and other related info.
2503    WaitForBuffersAllocated { responder: BufferCollectionWaitForBuffersAllocatedResponder },
2504    /// This returns the same result code as WaitForBuffersAllocated if the
2505    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
2506    /// if WaitForBuffersAllocated would block.
2507    CheckBuffersAllocated { responder: BufferCollectionCheckBuffersAllocatedResponder },
2508    /// Create a new token, for trying to add a new participant to an existing
2509    /// collection, if the existing collection's buffer counts, constraints,
2510    /// and participants allow.
2511    ///
2512    /// This can be useful in replacing a failed participant, and/or in
2513    /// adding/re-adding a participant after buffers have already been
2514    /// allocated.
2515    ///
2516    /// Failure of an attached token / collection does not propagate to the
2517    /// parent of the attached token.  Failure does propagate from a normal
2518    /// child of a dispensable token to the dispensable token.  Failure
2519    /// of a child is blocked from reaching its parent if the child is attached,
2520    /// or if the child is dispensable and the failure occurred after logical
2521    /// allocation.
2522    ///
2523    /// An initiator may in some scenarios choose to initially use a dispensable
2524    /// token for a given instance of a participant, and then later if the first
2525    /// instance of that participant fails, a new second instance of that
2526    /// participant my be given a token created with AttachToken().
2527    ///
2528    /// From the point of view of the client end of the BufferCollectionToken
2529    /// channel, the token acts like any other token.  The client can
2530    /// Duplicate() the token as needed, and can send the token to a different
2531    /// process.  The token should be converted to a BufferCollection channel
2532    /// as normal by calling BindSharedCollection().  SetConstraints() should
2533    /// be called on that BufferCollection channel.
2534    ///
2535    /// A success result from WaitForBuffersAllocated() means the new
2536    /// participant's constraints were satisfiable using the already-existing
2537    /// buffer collection, the already-established BufferCollectionInfo
2538    /// including image format constraints, and the already-existing other
2539    /// participants and their buffer counts.  A failure result means the new
2540    /// participant's constraints cannot be satisfied using the existing
2541    /// buffer collection and its already-logically-allocated participants.
2542    /// Creating a new collection instead may allow all participant's
2543    /// constraints to be satisfied, assuming SetDispensable() is used in place
2544    /// of AttachToken(), or a normal token is used.
2545    ///
2546    /// A token created with AttachToken() performs constraints aggregation with
2547    /// all constraints currently in effect on the buffer collection, plus the
2548    /// attached token under consideration plus child tokens under the attached
2549    /// token which are not themselves an attached token or under such a token.
2550    ///
2551    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
2552    /// first-come first-served, but a child can't logically allocate before
2553    /// all its parents have sent SetConstraints().
2554    ///
2555    /// See also SetDispensable(), which in contrast to AttachToken(), has the
2556    /// created token + children participate in constraints aggregation along
2557    /// with its parent.
2558    ///
2559    /// The newly created token needs to be Sync()ed to sysmem before the new
2560    /// token can be passed to BindSharedCollection().  The Sync() of the new
2561    /// token can be accomplished with BufferCollection.Sync() on this
2562    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
2563    /// token also works.  A BufferCollectionToken.Sync() can be started after
2564    /// any BufferCollectionToken.Duplicate() messages have been sent via the
2565    /// newly created token, to also sync those additional tokens to sysmem
2566    /// using a single round-trip.
2567    ///
2568    /// These values for rights_attenuation_mask result in no attenuation (note
2569    /// that 0 is not on this list; 0 will output an ERROR to the system log
2570    /// to help diagnose the bug in client code):
2571    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
2572    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2573    AttachToken {
2574        rights_attenuation_mask: u32,
2575        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
2576        control_handle: BufferCollectionControlHandle,
2577    },
2578    /// AttachLifetimeTracking:
2579    ///
2580    /// AttachLifetimeTracking() is intended to allow a client to wait until an
2581    /// old logical buffer collection is fully or mostly deallocated before
2582    /// attempting allocation of a new logical buffer collection.
2583    ///
2584    /// Attach an eventpair endpoint to the logical buffer collection, so that
2585    /// the server_end will be closed when the number of buffers allocated
2586    /// drops to 'buffers_remaining'.  The server_end won't close until after
2587    /// logical allocation has completed.
2588    ///
2589    /// If logical allocation fails, such as for an attached sub-tree (using
2590    /// AttachToken()), the server_end will close during that failure regardless
2591    /// of the number of buffers potenitally allocated in the overall logical
2592    /// buffer collection.
2593    ///
2594    /// The lifetime signalled by this event includes asynchronous cleanup of
2595    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2596    /// holders of VMO handles to the buffers have closed those VMO handles.
2597    /// Therefore clients should take care not to become blocked forever waiting
2598    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
2599    /// participants using the logical buffer collection are less trusted or
2600    /// less reliable.
2601    ///
2602    /// The buffers_remaining parameter allows waiting for all but
2603    /// buffers_remaining buffers to be fully deallocated.  This can be useful
2604    /// in situations where a known number of buffers are intentionally not
2605    /// closed so that the data can continue to be used, such as for keeping the
2606    /// last available video picture displayed in the UI even if the video
2607    /// stream was using protected output buffers.  It's outside the scope of
2608    /// the BufferCollection interface (at least for now) to determine how many
2609    /// buffers may be held without closing, but it'll typically be in the range
2610    /// 0-2.
2611    ///
2612    /// This mechanism is meant to be compatible with other protocols providing
2613    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2614    /// same event can be sent to more than one AttachLifetimeTracking(), and
2615    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2616    /// over conditions are met (all holders of duplicates have closed their
2617    /// handle(s)).
2618    ///
2619    /// There is no way to cancel an attach.  Closing the client end of the
2620    /// eventpair doesn't subtract from the number of pending attach(es).
2621    ///
2622    /// Closing the client's end doesn't result in any action by the server.
2623    /// If the server listens to events from the client end at all, it is for
2624    /// debug logging only.
2625    ///
2626    /// The server intentionally doesn't "trust" any bits signalled by the
2627    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2628    /// which can't be triggered early, and is only triggered when all handles
2629    /// to server_end are closed.  No meaning is associated with any of the
2630    /// other signal bits, and clients should functionally ignore any other
2631    /// signal bits on either end of the eventpair or its peer.
2632    ///
2633    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2634    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2635    /// transfer without causing CodecFactory channel failure).
2636    AttachLifetimeTracking {
2637        server_end: fdomain_client::EventPair,
2638        buffers_remaining: u32,
2639        control_handle: BufferCollectionControlHandle,
2640    },
2641}
2642
2643impl BufferCollectionRequest {
2644    #[allow(irrefutable_let_patterns)]
2645    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
2646        if let BufferCollectionRequest::Sync { responder } = self {
2647            Some((responder))
2648        } else {
2649            None
2650        }
2651    }
2652
2653    #[allow(irrefutable_let_patterns)]
2654    pub fn into_close(self) -> Option<(BufferCollectionControlHandle)> {
2655        if let BufferCollectionRequest::Close { control_handle } = self {
2656            Some((control_handle))
2657        } else {
2658            None
2659        }
2660    }
2661
2662    #[allow(irrefutable_let_patterns)]
2663    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionControlHandle)> {
2664        if let BufferCollectionRequest::SetName { priority, name, control_handle } = self {
2665            Some((priority, name, control_handle))
2666        } else {
2667            None
2668        }
2669    }
2670
2671    #[allow(irrefutable_let_patterns)]
2672    pub fn into_set_debug_client_info(
2673        self,
2674    ) -> Option<(String, u64, BufferCollectionControlHandle)> {
2675        if let BufferCollectionRequest::SetDebugClientInfo { name, id, control_handle } = self {
2676            Some((name, id, control_handle))
2677        } else {
2678            None
2679        }
2680    }
2681
2682    #[allow(irrefutable_let_patterns)]
2683    pub fn into_set_debug_timeout_log_deadline(
2684        self,
2685    ) -> Option<(i64, BufferCollectionControlHandle)> {
2686        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } =
2687            self
2688        {
2689            Some((deadline, control_handle))
2690        } else {
2691            None
2692        }
2693    }
2694
2695    #[allow(irrefutable_let_patterns)]
2696    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
2697        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
2698            Some((control_handle))
2699        } else {
2700            None
2701        }
2702    }
2703
2704    #[allow(irrefutable_let_patterns)]
2705    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
2706        if let BufferCollectionRequest::GetNodeRef { responder } = self {
2707            Some((responder))
2708        } else {
2709            None
2710        }
2711    }
2712
2713    #[allow(irrefutable_let_patterns)]
2714    pub fn into_is_alternate_for(
2715        self,
2716    ) -> Option<(fdomain_client::Event, BufferCollectionIsAlternateForResponder)> {
2717        if let BufferCollectionRequest::IsAlternateFor { node_ref, responder } = self {
2718            Some((node_ref, responder))
2719        } else {
2720            None
2721        }
2722    }
2723
2724    #[allow(irrefutable_let_patterns)]
2725    pub fn into_set_constraints(
2726        self,
2727    ) -> Option<(bool, BufferCollectionConstraints, BufferCollectionControlHandle)> {
2728        if let BufferCollectionRequest::SetConstraints {
2729            has_constraints,
2730            constraints,
2731            control_handle,
2732        } = self
2733        {
2734            Some((has_constraints, constraints, control_handle))
2735        } else {
2736            None
2737        }
2738    }
2739
2740    #[allow(irrefutable_let_patterns)]
2741    pub fn into_wait_for_buffers_allocated(
2742        self,
2743    ) -> Option<(BufferCollectionWaitForBuffersAllocatedResponder)> {
2744        if let BufferCollectionRequest::WaitForBuffersAllocated { responder } = self {
2745            Some((responder))
2746        } else {
2747            None
2748        }
2749    }
2750
2751    #[allow(irrefutable_let_patterns)]
2752    pub fn into_check_buffers_allocated(
2753        self,
2754    ) -> Option<(BufferCollectionCheckBuffersAllocatedResponder)> {
2755        if let BufferCollectionRequest::CheckBuffersAllocated { responder } = self {
2756            Some((responder))
2757        } else {
2758            None
2759        }
2760    }
2761
2762    #[allow(irrefutable_let_patterns)]
2763    pub fn into_attach_token(
2764        self,
2765    ) -> Option<(
2766        u32,
2767        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
2768        BufferCollectionControlHandle,
2769    )> {
2770        if let BufferCollectionRequest::AttachToken {
2771            rights_attenuation_mask,
2772            token_request,
2773            control_handle,
2774        } = self
2775        {
2776            Some((rights_attenuation_mask, token_request, control_handle))
2777        } else {
2778            None
2779        }
2780    }
2781
2782    #[allow(irrefutable_let_patterns)]
2783    pub fn into_attach_lifetime_tracking(
2784        self,
2785    ) -> Option<(fdomain_client::EventPair, u32, BufferCollectionControlHandle)> {
2786        if let BufferCollectionRequest::AttachLifetimeTracking {
2787            server_end,
2788            buffers_remaining,
2789            control_handle,
2790        } = self
2791        {
2792            Some((server_end, buffers_remaining, control_handle))
2793        } else {
2794            None
2795        }
2796    }
2797
2798    /// Name of the method defined in FIDL
2799    pub fn method_name(&self) -> &'static str {
2800        match *self {
2801            BufferCollectionRequest::Sync { .. } => "sync",
2802            BufferCollectionRequest::Close { .. } => "close",
2803            BufferCollectionRequest::SetName { .. } => "set_name",
2804            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
2805            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
2806                "set_debug_timeout_log_deadline"
2807            }
2808            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
2809            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
2810            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
2811            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
2812            BufferCollectionRequest::WaitForBuffersAllocated { .. } => "wait_for_buffers_allocated",
2813            BufferCollectionRequest::CheckBuffersAllocated { .. } => "check_buffers_allocated",
2814            BufferCollectionRequest::AttachToken { .. } => "attach_token",
2815            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
2816        }
2817    }
2818}
2819
2820#[derive(Debug, Clone)]
2821pub struct BufferCollectionControlHandle {
2822    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2823}
2824
2825impl BufferCollectionControlHandle {
2826    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2827        self.inner.shutdown_with_epitaph(status.into())
2828    }
2829}
2830
2831impl fdomain_client::fidl::ControlHandle for BufferCollectionControlHandle {
2832    fn shutdown(&self) {
2833        self.inner.shutdown()
2834    }
2835
2836    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2837        self.inner.shutdown_with_epitaph(status)
2838    }
2839
2840    fn is_closed(&self) -> bool {
2841        self.inner.channel().is_closed()
2842    }
2843    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2844        self.inner.channel().on_closed()
2845    }
2846}
2847
2848impl BufferCollectionControlHandle {}
2849
2850#[must_use = "FIDL methods require a response to be sent"]
2851#[derive(Debug)]
2852pub struct BufferCollectionSyncResponder {
2853    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2854    tx_id: u32,
2855}
2856
2857/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2858/// if the responder is dropped without sending a response, so that the client
2859/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2860impl std::ops::Drop for BufferCollectionSyncResponder {
2861    fn drop(&mut self) {
2862        self.control_handle.shutdown();
2863        // Safety: drops once, never accessed again
2864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2865    }
2866}
2867
2868impl fdomain_client::fidl::Responder for BufferCollectionSyncResponder {
2869    type ControlHandle = BufferCollectionControlHandle;
2870
2871    fn control_handle(&self) -> &BufferCollectionControlHandle {
2872        &self.control_handle
2873    }
2874
2875    fn drop_without_shutdown(mut self) {
2876        // Safety: drops once, never accessed again due to mem::forget
2877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2878        // Prevent Drop from running (which would shut down the channel)
2879        std::mem::forget(self);
2880    }
2881}
2882
2883impl BufferCollectionSyncResponder {
2884    /// Sends a response to the FIDL transaction.
2885    ///
2886    /// Sets the channel to shutdown if an error occurs.
2887    pub fn send(self) -> Result<(), fidl::Error> {
2888        let _result = self.send_raw();
2889        if _result.is_err() {
2890            self.control_handle.shutdown();
2891        }
2892        self.drop_without_shutdown();
2893        _result
2894    }
2895
2896    /// Similar to "send" but does not shutdown the channel if an error occurs.
2897    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2898        let _result = self.send_raw();
2899        self.drop_without_shutdown();
2900        _result
2901    }
2902
2903    fn send_raw(&self) -> Result<(), fidl::Error> {
2904        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2905            (),
2906            self.tx_id,
2907            0x4577e238ae26291,
2908            fidl::encoding::DynamicFlags::empty(),
2909        )
2910    }
2911}
2912
2913#[must_use = "FIDL methods require a response to be sent"]
2914#[derive(Debug)]
2915pub struct BufferCollectionGetNodeRefResponder {
2916    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2917    tx_id: u32,
2918}
2919
2920/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2921/// if the responder is dropped without sending a response, so that the client
2922/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2923impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
2924    fn drop(&mut self) {
2925        self.control_handle.shutdown();
2926        // Safety: drops once, never accessed again
2927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2928    }
2929}
2930
2931impl fdomain_client::fidl::Responder for BufferCollectionGetNodeRefResponder {
2932    type ControlHandle = BufferCollectionControlHandle;
2933
2934    fn control_handle(&self) -> &BufferCollectionControlHandle {
2935        &self.control_handle
2936    }
2937
2938    fn drop_without_shutdown(mut self) {
2939        // Safety: drops once, never accessed again due to mem::forget
2940        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2941        // Prevent Drop from running (which would shut down the channel)
2942        std::mem::forget(self);
2943    }
2944}
2945
2946impl BufferCollectionGetNodeRefResponder {
2947    /// Sends a response to the FIDL transaction.
2948    ///
2949    /// Sets the channel to shutdown if an error occurs.
2950    pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
2951        let _result = self.send_raw(node_ref);
2952        if _result.is_err() {
2953            self.control_handle.shutdown();
2954        }
2955        self.drop_without_shutdown();
2956        _result
2957    }
2958
2959    /// Similar to "send" but does not shutdown the channel if an error occurs.
2960    pub fn send_no_shutdown_on_err(
2961        self,
2962        mut node_ref: fdomain_client::Event,
2963    ) -> Result<(), fidl::Error> {
2964        let _result = self.send_raw(node_ref);
2965        self.drop_without_shutdown();
2966        _result
2967    }
2968
2969    fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
2970        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
2971            (node_ref,),
2972            self.tx_id,
2973            0x467b7c75c35c3b84,
2974            fidl::encoding::DynamicFlags::empty(),
2975        )
2976    }
2977}
2978
2979#[must_use = "FIDL methods require a response to be sent"]
2980#[derive(Debug)]
2981pub struct BufferCollectionIsAlternateForResponder {
2982    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2983    tx_id: u32,
2984}
2985
2986/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2987/// if the responder is dropped without sending a response, so that the client
2988/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2989impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
2990    fn drop(&mut self) {
2991        self.control_handle.shutdown();
2992        // Safety: drops once, never accessed again
2993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2994    }
2995}
2996
2997impl fdomain_client::fidl::Responder for BufferCollectionIsAlternateForResponder {
2998    type ControlHandle = BufferCollectionControlHandle;
2999
3000    fn control_handle(&self) -> &BufferCollectionControlHandle {
3001        &self.control_handle
3002    }
3003
3004    fn drop_without_shutdown(mut self) {
3005        // Safety: drops once, never accessed again due to mem::forget
3006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3007        // Prevent Drop from running (which would shut down the channel)
3008        std::mem::forget(self);
3009    }
3010}
3011
3012impl BufferCollectionIsAlternateForResponder {
3013    /// Sends a response to the FIDL transaction.
3014    ///
3015    /// Sets the channel to shutdown if an error occurs.
3016    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3017        let _result = self.send_raw(result);
3018        if _result.is_err() {
3019            self.control_handle.shutdown();
3020        }
3021        self.drop_without_shutdown();
3022        _result
3023    }
3024
3025    /// Similar to "send" but does not shutdown the channel if an error occurs.
3026    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3027        let _result = self.send_raw(result);
3028        self.drop_without_shutdown();
3029        _result
3030    }
3031
3032    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3033        self.control_handle
3034            .inner
3035            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
3036                result.map(|is_alternate| (is_alternate,)),
3037                self.tx_id,
3038                0x33a2a7aff2776c07,
3039                fidl::encoding::DynamicFlags::empty(),
3040            )
3041    }
3042}
3043
3044#[must_use = "FIDL methods require a response to be sent"]
3045#[derive(Debug)]
3046pub struct BufferCollectionWaitForBuffersAllocatedResponder {
3047    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3048    tx_id: u32,
3049}
3050
3051/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3052/// if the responder is dropped without sending a response, so that the client
3053/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3054impl std::ops::Drop for BufferCollectionWaitForBuffersAllocatedResponder {
3055    fn drop(&mut self) {
3056        self.control_handle.shutdown();
3057        // Safety: drops once, never accessed again
3058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3059    }
3060}
3061
3062impl fdomain_client::fidl::Responder for BufferCollectionWaitForBuffersAllocatedResponder {
3063    type ControlHandle = BufferCollectionControlHandle;
3064
3065    fn control_handle(&self) -> &BufferCollectionControlHandle {
3066        &self.control_handle
3067    }
3068
3069    fn drop_without_shutdown(mut self) {
3070        // Safety: drops once, never accessed again due to mem::forget
3071        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3072        // Prevent Drop from running (which would shut down the channel)
3073        std::mem::forget(self);
3074    }
3075}
3076
3077impl BufferCollectionWaitForBuffersAllocatedResponder {
3078    /// Sends a response to the FIDL transaction.
3079    ///
3080    /// Sets the channel to shutdown if an error occurs.
3081    pub fn send(
3082        self,
3083        mut status: i32,
3084        mut buffer_collection_info: BufferCollectionInfo2,
3085    ) -> Result<(), fidl::Error> {
3086        let _result = self.send_raw(status, buffer_collection_info);
3087        if _result.is_err() {
3088            self.control_handle.shutdown();
3089        }
3090        self.drop_without_shutdown();
3091        _result
3092    }
3093
3094    /// Similar to "send" but does not shutdown the channel if an error occurs.
3095    pub fn send_no_shutdown_on_err(
3096        self,
3097        mut status: i32,
3098        mut buffer_collection_info: BufferCollectionInfo2,
3099    ) -> Result<(), fidl::Error> {
3100        let _result = self.send_raw(status, buffer_collection_info);
3101        self.drop_without_shutdown();
3102        _result
3103    }
3104
3105    fn send_raw(
3106        &self,
3107        mut status: i32,
3108        mut buffer_collection_info: BufferCollectionInfo2,
3109    ) -> Result<(), fidl::Error> {
3110        self.control_handle.inner.send::<BufferCollectionWaitForBuffersAllocatedResponse>(
3111            (status, &mut buffer_collection_info),
3112            self.tx_id,
3113            0x714667ea2a29a3a2,
3114            fidl::encoding::DynamicFlags::empty(),
3115        )
3116    }
3117}
3118
3119#[must_use = "FIDL methods require a response to be sent"]
3120#[derive(Debug)]
3121pub struct BufferCollectionCheckBuffersAllocatedResponder {
3122    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3123    tx_id: u32,
3124}
3125
3126/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3127/// if the responder is dropped without sending a response, so that the client
3128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3129impl std::ops::Drop for BufferCollectionCheckBuffersAllocatedResponder {
3130    fn drop(&mut self) {
3131        self.control_handle.shutdown();
3132        // Safety: drops once, never accessed again
3133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3134    }
3135}
3136
3137impl fdomain_client::fidl::Responder for BufferCollectionCheckBuffersAllocatedResponder {
3138    type ControlHandle = BufferCollectionControlHandle;
3139
3140    fn control_handle(&self) -> &BufferCollectionControlHandle {
3141        &self.control_handle
3142    }
3143
3144    fn drop_without_shutdown(mut self) {
3145        // Safety: drops once, never accessed again due to mem::forget
3146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3147        // Prevent Drop from running (which would shut down the channel)
3148        std::mem::forget(self);
3149    }
3150}
3151
3152impl BufferCollectionCheckBuffersAllocatedResponder {
3153    /// Sends a response to the FIDL transaction.
3154    ///
3155    /// Sets the channel to shutdown if an error occurs.
3156    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
3157        let _result = self.send_raw(status);
3158        if _result.is_err() {
3159            self.control_handle.shutdown();
3160        }
3161        self.drop_without_shutdown();
3162        _result
3163    }
3164
3165    /// Similar to "send" but does not shutdown the channel if an error occurs.
3166    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
3167        let _result = self.send_raw(status);
3168        self.drop_without_shutdown();
3169        _result
3170    }
3171
3172    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
3173        self.control_handle.inner.send::<BufferCollectionCheckBuffersAllocatedResponse>(
3174            (status,),
3175            self.tx_id,
3176            0x245bb81f79189e9,
3177            fidl::encoding::DynamicFlags::empty(),
3178        )
3179    }
3180}
3181
3182#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3183pub struct BufferCollectionTokenMarker;
3184
3185impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenMarker {
3186    type Proxy = BufferCollectionTokenProxy;
3187    type RequestStream = BufferCollectionTokenRequestStream;
3188
3189    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
3190}
3191
3192pub trait BufferCollectionTokenProxyInterface: Send + Sync {
3193    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3194    fn r#sync(&self) -> Self::SyncResponseFut;
3195    fn r#close(&self) -> Result<(), fidl::Error>;
3196    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
3197    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
3198    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
3199    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
3200    type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
3201        + Send;
3202    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
3203    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
3204        + Send;
3205    fn r#is_alternate_for(
3206        &self,
3207        node_ref: fdomain_client::Event,
3208    ) -> Self::IsAlternateForResponseFut;
3209    type DuplicateSyncResponseFut: std::future::Future<
3210            Output = Result<
3211                Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3212                fidl::Error,
3213            >,
3214        > + Send;
3215    fn r#duplicate_sync(
3216        &self,
3217        rights_attenuation_masks: &[fidl::Rights],
3218    ) -> Self::DuplicateSyncResponseFut;
3219    fn r#duplicate(
3220        &self,
3221        rights_attenuation_mask: u32,
3222        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3223    ) -> Result<(), fidl::Error>;
3224    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
3225    fn r#create_buffer_collection_token_group(
3226        &self,
3227        group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3228    ) -> Result<(), fidl::Error>;
3229}
3230
3231#[derive(Debug, Clone)]
3232pub struct BufferCollectionTokenProxy {
3233    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3234}
3235
3236impl fdomain_client::fidl::Proxy for BufferCollectionTokenProxy {
3237    type Protocol = BufferCollectionTokenMarker;
3238
3239    fn from_channel(inner: fdomain_client::Channel) -> Self {
3240        Self::new(inner)
3241    }
3242
3243    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3244        self.client.into_channel().map_err(|client| Self { client })
3245    }
3246
3247    fn as_channel(&self) -> &fdomain_client::Channel {
3248        self.client.as_channel()
3249    }
3250}
3251
3252impl BufferCollectionTokenProxy {
3253    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionToken.
3254    pub fn new(channel: fdomain_client::Channel) -> Self {
3255        let protocol_name =
3256            <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3257        Self { client: fidl::client::Client::new(channel, protocol_name) }
3258    }
3259
3260    /// Get a Stream of events from the remote end of the protocol.
3261    ///
3262    /// # Panics
3263    ///
3264    /// Panics if the event stream was already taken.
3265    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
3266        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
3267    }
3268
3269    /// Ensure that previous messages, including Duplicate() messages on a
3270    /// token, collection, or group, have been received server side.
3271    ///
3272    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
3273    /// valid sysmem token risks the Sync() hanging forever.  See
3274    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
3275    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
3276    /// Another way is to pass the token to BindSharedCollection(), which also
3277    /// validates the token as part of exchanging it for a BufferCollection
3278    /// channel, and BufferCollection Sync() can then be used.
3279    ///
3280    /// After a Sync(), it's then safe to send the client end of token_request
3281    /// to another participant knowing the server will recognize the token when
3282    /// it's sent into BindSharedCollection() by the other participant.
3283    ///
3284    /// Other options include waiting for each token.Duplicate() to complete
3285    /// individually (using separate call to token.Sync() after each), or
3286    /// calling Sync() on BufferCollection after the token has been turned in
3287    /// via BindSharedCollection().
3288    ///
3289    /// Another way to mitigate is to avoid calling Sync() on the token, and
3290    /// instead later deal with potential failure of BufferCollection.Sync() if
3291    /// the original token was invalid.  This option can be preferable from a
3292    /// performance point of view, but requires client code to delay sending
3293    /// tokens duplicated from this token until after client code has converted
3294    /// the duplicating token to a BufferCollection and received successful
3295    /// response from BufferCollection.Sync().
3296    ///
3297    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
3298    /// When BufferCollection.Sync() isn't feasible, the caller must already
3299    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
3300    /// hang forever.  See ValidateBufferCollectionToken() to check token
3301    /// validity first if the token isn't already known to be (is/was) valid.
3302    pub fn r#sync(
3303        &self,
3304    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
3305        BufferCollectionTokenProxyInterface::r#sync(self)
3306    }
3307
3308    /// On a BufferCollectionToken channel:
3309    ///
3310    /// Normally a participant will convert a BufferCollectionToken into a
3311    /// BufferCollection view, but a participant is also free to Close() the
3312    /// token (and then close the channel immediately or shortly later in
3313    /// response to server closing its end), which avoids causing logical buffer
3314    /// collection failure.  Normally an unexpected token channel close will
3315    /// cause logical buffer collection failure (the only exceptions being
3316    /// certain cases involving AttachToken() or SetDispensable()).
3317    ///
3318    /// On a BufferCollection channel:
3319    ///
3320    /// By default the server handles unexpected failure of a BufferCollection
3321    /// by failing the whole logical buffer collection.  Partly this is to
3322    /// expedite closing VMO handles to reclaim memory when any participant
3323    /// fails.  If a participant would like to cleanly close a BufferCollection
3324    /// view without causing logical buffer collection failure, the participant
3325    /// can send Close() before closing the client end of the BufferCollection
3326    /// channel.  If this is the last BufferCollection view, the logical buffer
3327    /// collection will still go away.  The Close() can occur before or after
3328    /// SetConstraints().  If before SetConstraints(), the buffer collection
3329    /// won't require constraints from this node in order to allocate.  If
3330    /// after SetConstraints(), the constraints are retained and aggregated
3331    /// along with any subsequent logical allocation(s), despite the lack of
3332    /// channel connection.
3333    ///
3334    /// On a BufferCollectionTokenGroup channel:
3335    ///
3336    /// By default, unexpected failure of a BufferCollectionTokenGroup will
3337    /// trigger failure of the logical BufferCollectionTokenGroup and will
3338    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
3339    /// channel without failing the logical group or propagating failure, send
3340    /// Close() before closing the channel client endpoint.
3341    ///
3342    /// If Close() occurs before AllChildrenPresent(), the logical buffer
3343    /// collection will still fail despite the Close() (because sysmem can't be
3344    /// sure whether all relevant children were created, so it's ambiguous
3345    /// whether all relevant constraints will be provided to sysmem).  If
3346    /// Close() occurs after AllChildrenPresent(), the children and all their
3347    /// constraints remain intact (just as they would if the
3348    /// BufferCollectionTokenGroup channel had remained open), and the close
3349    /// doesn't trigger or propagate failure.
3350    pub fn r#close(&self) -> Result<(), fidl::Error> {
3351        BufferCollectionTokenProxyInterface::r#close(self)
3352    }
3353
3354    /// Set a name for VMOs in this buffer collection. The name may be truncated
3355    /// shorter. The name only affects VMOs allocated after it's set - this call
3356    /// does not rename existing VMOs. If multiple clients set different names
3357    /// then the larger priority value will win.
3358    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
3359        BufferCollectionTokenProxyInterface::r#set_name(self, priority, name)
3360    }
3361
3362    /// Set information about the current client that can be used by sysmem to
3363    /// help debug leaking memory and hangs waiting for constraints. |name| can
3364    /// be an arbitrary string, but the current process name (see
3365    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
3366    /// arbitrary id, but the current process ID (see
3367    /// fsl::GetCurrentProcessKoid()) is a good default.
3368    ///
3369    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
3370    /// indicate which client is closing their channel first, leading to
3371    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
3372    /// over, but if happening earlier than expected, the
3373    /// client-channel-specific name can help diagnose where the failure is
3374    /// first coming from, from sysmem's point of view).
3375    ///
3376    /// By default (unless overriden by this message or using
3377    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
3378    /// parent Node at the time the child Node is created.  While this can be
3379    /// better than nothing, it's often better for each participant to use
3380    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
3381    /// info directly relevant to the current client.  Also, SetVerboseLogging()
3382    /// can be used to help disambiguate if a Node is suspected of having info
3383    /// that was copied from its parent.
3384    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
3385        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, name, id)
3386    }
3387
3388    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
3389    /// after creating a collection. Clients can call this method to change
3390    /// when the log is printed. If multiple client set the deadline, it's
3391    /// unspecified which deadline will take effect.
3392    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
3393        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
3394    }
3395
3396    /// Verbose logging includes constraints set via SetConstraints() from each
3397    /// client along with info set via SetDebugClientInfo() and the structure of
3398    /// the tree of Node(s).
3399    ///
3400    /// Normally sysmem prints only a single line complaint when aggregation
3401    /// fails, with just the specific detailed reason that aggregation failed,
3402    /// with minimal context.  While this is often enough to diagnose a problem
3403    /// if only a small change was made and the system had been working before
3404    /// the small change, it's often not particularly helpful for getting a new
3405    /// buffer collection to work for the first time.  Especially with more
3406    /// complex trees of nodes, involving things like AttachToken(),
3407    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
3408    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
3409    /// looks like and why it's failing a logical allocation, or why a tree or
3410    /// sub-tree is failing sooner than expected.
3411    ///
3412    /// The intent of the extra logging is to be acceptable from a performance
3413    /// point of view, if only enabled on a low number of buffer collections.
3414    /// If we're not tracking down a bug, we shouldn't send this message.
3415    ///
3416    /// If too many participants leave verbose logging enabled, we may end up
3417    /// needing to require that system-wide sysmem verbose logging be permitted
3418    /// via some other setting, to avoid sysmem spamming the log too much due to
3419    /// this message.
3420    ///
3421    /// This may be a NOP for some nodes due to intentional policy associated
3422    /// with the node, if we don't trust a node enough to let it turn on verbose
3423    /// logging.
3424    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
3425        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
3426    }
3427
3428    /// This gets an event handle that can be used as a parameter to
3429    /// IsAlternateFor() called on any Node.  The client will not be granted the
3430    /// right to signal this event, as this handle should only be used as proof
3431    /// that the client obtained this handle from this Node.
3432    ///
3433    /// Because this is a get not a set, no Sync() is needed between the
3434    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
3435    /// potentially being on different channels.
3436    ///
3437    /// See also IsAlternateFor().
3438    pub fn r#get_node_ref(
3439        &self,
3440    ) -> fidl::client::QueryResponseFut<
3441        fdomain_client::Event,
3442        fdomain_client::fidl::FDomainResourceDialect,
3443    > {
3444        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
3445    }
3446
3447    /// This checks whether the calling node is in a subtree rooted at a
3448    /// different child token of a common parent BufferCollectionTokenGroup, in
3449    /// relation to the passed-in node_ref.
3450    ///
3451    /// This call is for assisting with admission control de-duplication, and
3452    /// with debugging.
3453    ///
3454    /// The node_ref must be obtained using GetNodeRef() of a
3455    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
3456    ///
3457    /// The node_ref can be a duplicated handle; it's not necessary to call
3458    /// GetNodeRef() for every call to IsAlternateFor().
3459    ///
3460    /// If a calling token may not actually be a valid token at all due to
3461    /// a potentially hostile/untrusted provider of the token, call
3462    /// ValidateBufferCollectionToken() first instead of potentially getting
3463    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
3464    /// token not being a real token (not really talking to sysmem).  Another
3465    /// option is to call BindSharedCollection with this token first which also
3466    /// validates the token along with converting it to a BufferCollection, then
3467    /// call BufferCollection IsAlternateFor().
3468    ///
3469    /// error values:
3470    ///
3471    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
3472    /// buffer collection as the calling Node.  Before logical allocation and
3473    /// within the same logical allocation sub-tree, this essentially means that
3474    /// the node_ref was never part of this logical buffer collection, since
3475    /// before logical allocation all node_refs that come into existence remain
3476    /// in existence at least until logical allocation (including Node(s) that
3477    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
3478    /// to be returned, this Node's channel needs to still be connected server
3479    /// side, which won't be the case if the whole logical allocation has
3480    /// failed.  After logical allocation or in a different logical allocation
3481    /// sub-tree there are additional potential reasons for this error.  For
3482    /// example a different logical allocation (separated from this Node(s)
3483    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
3484    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
3485    /// exist and may select a different child sub-tree than the sub-tree the
3486    /// node_ref is in causing deletion of the node_ref Node.  The only time
3487    /// sysmem keeps a Node around after that Node has no corresponding channel
3488    /// is when Close() is used and the Node's sub-tree has not yet failed.
3489    /// Another reason for this error is if the node_ref is an eventpair handle
3490    /// with sufficient rights, but isn't actually a real node_ref obtained from
3491    /// GetNodeRef().
3492    ///
3493    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
3494    /// eventpair handle, or doesn't have the needed rights expected on a real
3495    /// node_ref.
3496    ///
3497    /// No other failing status codes are returned by this call.  However,
3498    /// sysmem may add additional codes in future, so the client should have
3499    /// sensible default handling for any failing status code.
3500    ///
3501    /// On success, is_alternate has the following meaning:
3502    ///   * true - The first parent node in common between the calling node and
3503    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
3504    ///     the calling Node and the node_ref Node will _not_ have both their
3505    ///     constraints apply - rather sysmem will choose one or the other of
3506    ///     the constraints - never both.  This is because only one child of
3507    ///     a BufferCollectionTokenGroup is selected during logical allocation,
3508    ///     with only that one child's sub-tree contributing to constraints
3509    ///     aggregation.
3510    ///   * false - The first parent node in common between the calling Node and
3511    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
3512    ///     this means the first parent node in common is a
3513    ///     BufferCollectionToken or BufferCollection (regardless of not
3514    ///     Close()ed or Close()ed).  This means that the calling Node and the
3515    ///     node_ref Node _may_ have both their constraints apply during
3516    ///     constraints aggregation of the logical allocation, if both Node(s)
3517    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
3518    ///     In this case, there is no BufferCollectionTokenGroup that will
3519    ///     directly prevent the two Node(s) from both being selected and their
3520    ///     constraints both aggregated, but even when false, one or both
3521    ///     Node(s) may still be eliminated from consideration if one or both
3522    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
3523    ///     which selects a child sub-tree other than the sub-tree containing
3524    ///     the calling Node or node_ref Node.
3525    pub fn r#is_alternate_for(
3526        &self,
3527        mut node_ref: fdomain_client::Event,
3528    ) -> fidl::client::QueryResponseFut<
3529        NodeIsAlternateForResult,
3530        fdomain_client::fidl::FDomainResourceDialect,
3531    > {
3532        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, node_ref)
3533    }
3534
3535    /// This method can be used to add more participants prior to creating a
3536    /// shared BufferCollection. A new token will be returned for each entry in
3537    /// the `rights_attenuation_masks` array. The return value is the client
3538    /// ends of each new participant token.
3539    ///
3540    /// If the calling token may not actually be a valid token at all due to
3541    /// a potentially hostile/untrusted provider of the token, consider using
3542    /// ValidateBufferCollectionToken() first instead of potentially getting
3543    /// stuck indefinitely if DuplicateSync() never responds due to the calling
3544    /// token not being a real token.
3545    ///
3546    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
3547    /// after calling this method.
3548    ///
3549    /// All tokens must be turned in via BindSharedCollection() or Close() for a
3550    /// BufferCollection to be successfully created.
3551    ///
3552    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
3553    /// will be absent in the buffer VMO rights obtainable via the corresponding
3554    /// returned token. This allows an initiator or intermediary participant to
3555    /// attenuate the rights available to a participant. This does not allow a
3556    /// participant to gain rights that the participant doesn't already have.
3557    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
3558    /// attenuation should be applied.
3559    pub fn r#duplicate_sync(
3560        &self,
3561        mut rights_attenuation_masks: &[fidl::Rights],
3562    ) -> fidl::client::QueryResponseFut<
3563        Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3564        fdomain_client::fidl::FDomainResourceDialect,
3565    > {
3566        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, rights_attenuation_masks)
3567    }
3568
3569    /// This method can be used to add a participant prior to creating a shared
3570    /// BufferCollection. It should only be used instead of DuplicateSync in
3571    /// performance sensitive cases where it would be undesireable to wait for
3572    /// sysmem to respond as part of each duplicate.
3573    ///
3574    /// After sending one or more Duplicate() messages, and before sending the
3575    /// created tokens to other participants (or to other Allocator channels),
3576    /// the client should send a Sync() and wait for its response.  The Sync()
3577    /// call can be made on the token, or on the BufferCollection obtained by
3578    /// passing this token to BindSharedCollection().  Either will ensure that
3579    /// the server knows about the tokens created via Duplicate() before the
3580    /// other participant sends the token to the server via separate Allocator
3581    /// channel.
3582    ///
3583    /// All tokens must be turned in via BindSharedCollection() or Close() for a
3584    /// BufferCollection to be successfully created.
3585    ///
3586    /// When a client calls BindSharedCollection() to turn in a
3587    /// BufferCollectionToken, the server will process all Duplicate() messages
3588    /// before closing down the BufferCollectionToken.  This allows the client
3589    /// to Duplicate() and immediately turn in the BufferCollectionToken using
3590    /// BindSharedCollection, then later transfer the client end of token_request
3591    /// to another participant - the server will notice the existence of the
3592    /// token_request before considering this BufferCollectionToken fully closed.
3593    ///
3594    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
3595    /// absent in the buffer VMO rights obtainable via the client end of
3596    /// token_request. This allows an initiator or intermediary participant to
3597    /// attenuate the rights available to a participant. This does not allow a
3598    /// participant to gain rights that the participant doesn't already have.
3599    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
3600    /// attenuation should be applied.
3601    ///
3602    /// These values for rights_attenuation_mask result in no attenuation:
3603    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
3604    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3605    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
3606    ///
3607    /// `token_request` is the server end of a BufferCollectionToken channel.
3608    /// The client end of this channel acts as another participant in creating the
3609    /// shared BufferCollection.
3610    pub fn r#duplicate(
3611        &self,
3612        mut rights_attenuation_mask: u32,
3613        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3614    ) -> Result<(), fidl::Error> {
3615        BufferCollectionTokenProxyInterface::r#duplicate(
3616            self,
3617            rights_attenuation_mask,
3618            token_request,
3619        )
3620    }
3621
3622    /// A dispensable token can fail after buffers are logically allocated
3623    /// without causing failure of its parent (if any).
3624    ///
3625    /// The dispensable token participates in constraints aggregation along with
3626    /// its parent before logical buffer allocation.  If the dispensable token
3627    /// fails before buffers are logically allocated, the failure propagates to
3628    /// the dispensable token's parent.
3629    ///
3630    /// After buffers are logically allocated, failure of the dispensable token
3631    /// (or any child of the dispensable token) does not propagate to the
3632    /// dispensable token's parent.  Failure does propagate from a normal
3633    /// child of a dispensable token to the dispensable token.  Failure
3634    /// of a child is blocked from reaching its parent if the child is attached,
3635    /// or if the child is dispensable and the failure occurred after logical
3636    /// allocation.
3637    ///
3638    /// A dispensable token can be used in cases where a participant needs to
3639    /// provide constraints, but after buffers are allocated, the participant
3640    /// can fail without causing buffer collection failure from the parent's
3641    /// point of view.
3642    ///
3643    /// In contrast, AttachToken() can be used to create a token which does not
3644    /// participate in constraints aggregation with its parent, and whose
3645    /// failure at any time does not propagate to its parent, and whose delay
3646    /// providing constraints does not prevent the parent from completing its
3647    /// buffer allocation.
3648    ///
3649    /// An initiator may in some scenarios choose to initially use a dispensable
3650    /// token for a given instance of a participant, and then later if the first
3651    /// instance of that participant fails, a new second instance of that
3652    /// participant my be given a token created with AttachToken().
3653    ///
3654    /// If a client uses this message, the client should not rely on the
3655    /// client's own BufferCollectionToken or BufferCollection channel to close
3656    /// from the server end due to abrupt failure of any BufferCollectionToken
3657    /// or BufferCollection that the client has SetDispensable() and given out
3658    /// to another process.  For this reason, the client should take extra care
3659    /// to notice failure of that other process via other means.
3660    ///
3661    /// While it is possible (and potentially useful) to SetDispensable() on a
3662    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
3663    /// replace a failed dispensable token that was a direct child of a group
3664    /// with a new token using AttachToken() (since there's no AttachToken() on
3665    /// a group).  Instead, to enable AttachToken() replacement in this case,
3666    /// create an additional non-dispensable token (node) that's a direct child
3667    /// of the group and make the existing dispensable token a child of the
3668    /// additional token (node).  This way, the additional token (node) that is
3669    /// a direct child of the group has BufferCollection.AttachToken() which can
3670    /// be used to replace the failed dispensable token.
3671    ///
3672    /// SetDispensable() on an already-dispensable token is idempotent.
3673    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
3674        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
3675    }
3676
3677    /// Most sysmem clients and many participants don't need to care about this
3678    /// message or about BufferCollectionTokenGroup(s) in general.
3679    ///
3680    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
3681    /// tokens.  The child tokens which are not selected during aggregation will
3682    /// fail (close), which a potential participant should notice when their
3683    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
3684    /// participant to clean up the speculative usage that didn't end up
3685    /// happening (similarly to a normal BufferCollection server end closing
3686    /// on failure of a logical buffer collection).
3687    ///
3688    /// See comments on protocol BufferCollectionTokenGroup.
3689    ///
3690    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
3691    /// applied to the whole group can be achieved with a token for this purpose
3692    /// as a direct parent of the group.
3693    ///
3694    /// group_request - the server end of a BufferCollectionTokenGroup channel
3695    /// to be served by sysmem.
3696    pub fn r#create_buffer_collection_token_group(
3697        &self,
3698        mut group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3699    ) -> Result<(), fidl::Error> {
3700        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(
3701            self,
3702            group_request,
3703        )
3704    }
3705}
3706
3707impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
3708    type SyncResponseFut =
3709        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
3710    fn r#sync(&self) -> Self::SyncResponseFut {
3711        fn _decode(
3712            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3713        ) -> Result<(), fidl::Error> {
3714            let _response = fidl::client::decode_transaction_body::<
3715                fidl::encoding::EmptyPayload,
3716                fdomain_client::fidl::FDomainResourceDialect,
3717                0x4577e238ae26291,
3718            >(_buf?)?;
3719            Ok(_response)
3720        }
3721        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3722            (),
3723            0x4577e238ae26291,
3724            fidl::encoding::DynamicFlags::empty(),
3725            _decode,
3726        )
3727    }
3728
3729    fn r#close(&self) -> Result<(), fidl::Error> {
3730        self.client.send::<fidl::encoding::EmptyPayload>(
3731            (),
3732            0x5b1d7a4f5681fca7,
3733            fidl::encoding::DynamicFlags::empty(),
3734        )
3735    }
3736
3737    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
3738        self.client.send::<NodeSetNameRequest>(
3739            (priority, name),
3740            0x77a41bb6217e2443,
3741            fidl::encoding::DynamicFlags::empty(),
3742        )
3743    }
3744
3745    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
3746        self.client.send::<NodeSetDebugClientInfoRequest>(
3747            (name, id),
3748            0x7275759070eb5ee2,
3749            fidl::encoding::DynamicFlags::empty(),
3750        )
3751    }
3752
3753    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
3754        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
3755            (deadline,),
3756            0x46d38f4772638867,
3757            fidl::encoding::DynamicFlags::empty(),
3758        )
3759    }
3760
3761    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
3762        self.client.send::<fidl::encoding::EmptyPayload>(
3763            (),
3764            0x6bfbe2cf1701d288,
3765            fidl::encoding::DynamicFlags::empty(),
3766        )
3767    }
3768
3769    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
3770        fdomain_client::Event,
3771        fdomain_client::fidl::FDomainResourceDialect,
3772    >;
3773    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
3774        fn _decode(
3775            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3776        ) -> Result<fdomain_client::Event, fidl::Error> {
3777            let _response = fidl::client::decode_transaction_body::<
3778                NodeGetNodeRefResponse,
3779                fdomain_client::fidl::FDomainResourceDialect,
3780                0x467b7c75c35c3b84,
3781            >(_buf?)?;
3782            Ok(_response.node_ref)
3783        }
3784        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
3785            (),
3786            0x467b7c75c35c3b84,
3787            fidl::encoding::DynamicFlags::empty(),
3788            _decode,
3789        )
3790    }
3791
3792    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
3793        NodeIsAlternateForResult,
3794        fdomain_client::fidl::FDomainResourceDialect,
3795    >;
3796    fn r#is_alternate_for(
3797        &self,
3798        mut node_ref: fdomain_client::Event,
3799    ) -> Self::IsAlternateForResponseFut {
3800        fn _decode(
3801            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3802        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
3803            let _response = fidl::client::decode_transaction_body::<
3804                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
3805                fdomain_client::fidl::FDomainResourceDialect,
3806                0x33a2a7aff2776c07,
3807            >(_buf?)?;
3808            Ok(_response.map(|x| x.is_alternate))
3809        }
3810        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
3811            (node_ref,),
3812            0x33a2a7aff2776c07,
3813            fidl::encoding::DynamicFlags::empty(),
3814            _decode,
3815        )
3816    }
3817
3818    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
3819        Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3820        fdomain_client::fidl::FDomainResourceDialect,
3821    >;
3822    fn r#duplicate_sync(
3823        &self,
3824        mut rights_attenuation_masks: &[fidl::Rights],
3825    ) -> Self::DuplicateSyncResponseFut {
3826        fn _decode(
3827            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3828        ) -> Result<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
3829        {
3830            let _response = fidl::client::decode_transaction_body::<
3831                BufferCollectionTokenDuplicateSyncResponse,
3832                fdomain_client::fidl::FDomainResourceDialect,
3833                0x49ed7ab7cc19f18,
3834            >(_buf?)?;
3835            Ok(_response.tokens)
3836        }
3837        self.client.send_query_and_decode::<
3838            BufferCollectionTokenDuplicateSyncRequest,
3839            Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3840        >(
3841            (rights_attenuation_masks,),
3842            0x49ed7ab7cc19f18,
3843            fidl::encoding::DynamicFlags::empty(),
3844            _decode,
3845        )
3846    }
3847
3848    fn r#duplicate(
3849        &self,
3850        mut rights_attenuation_mask: u32,
3851        mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3852    ) -> Result<(), fidl::Error> {
3853        self.client.send::<BufferCollectionTokenDuplicateRequest>(
3854            (rights_attenuation_mask, token_request),
3855            0x2f9f81bdde4b7292,
3856            fidl::encoding::DynamicFlags::empty(),
3857        )
3858    }
3859
3860    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
3861        self.client.send::<fidl::encoding::EmptyPayload>(
3862            (),
3863            0x76e4ec34fc2cf5b3,
3864            fidl::encoding::DynamicFlags::empty(),
3865        )
3866    }
3867
3868    fn r#create_buffer_collection_token_group(
3869        &self,
3870        mut group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3871    ) -> Result<(), fidl::Error> {
3872        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
3873            (group_request,),
3874            0x2f6243e05f22b9a7,
3875            fidl::encoding::DynamicFlags::empty(),
3876        )
3877    }
3878}
3879
3880pub struct BufferCollectionTokenEventStream {
3881    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3882}
3883
3884impl std::marker::Unpin for BufferCollectionTokenEventStream {}
3885
3886impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
3887    fn is_terminated(&self) -> bool {
3888        self.event_receiver.is_terminated()
3889    }
3890}
3891
3892impl futures::Stream for BufferCollectionTokenEventStream {
3893    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
3894
3895    fn poll_next(
3896        mut self: std::pin::Pin<&mut Self>,
3897        cx: &mut std::task::Context<'_>,
3898    ) -> std::task::Poll<Option<Self::Item>> {
3899        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3900            &mut self.event_receiver,
3901            cx
3902        )?) {
3903            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
3904            None => std::task::Poll::Ready(None),
3905        }
3906    }
3907}
3908
3909#[derive(Debug)]
3910pub enum BufferCollectionTokenEvent {}
3911
3912impl BufferCollectionTokenEvent {
3913    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
3914    fn decode(
3915        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3916    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
3917        let (bytes, _handles) = buf.split_mut();
3918        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3919        debug_assert_eq!(tx_header.tx_id, 0);
3920        match tx_header.ordinal {
3921            _ => Err(fidl::Error::UnknownOrdinal {
3922                ordinal: tx_header.ordinal,
3923                protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3924            })
3925        }
3926    }
3927}
3928
3929/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionToken.
3930pub struct BufferCollectionTokenRequestStream {
3931    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3932    is_terminated: bool,
3933}
3934
3935impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
3936
3937impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
3938    fn is_terminated(&self) -> bool {
3939        self.is_terminated
3940    }
3941}
3942
3943impl fdomain_client::fidl::RequestStream for BufferCollectionTokenRequestStream {
3944    type Protocol = BufferCollectionTokenMarker;
3945    type ControlHandle = BufferCollectionTokenControlHandle;
3946
3947    fn from_channel(channel: fdomain_client::Channel) -> Self {
3948        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3949    }
3950
3951    fn control_handle(&self) -> Self::ControlHandle {
3952        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
3953    }
3954
3955    fn into_inner(
3956        self,
3957    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3958    {
3959        (self.inner, self.is_terminated)
3960    }
3961
3962    fn from_inner(
3963        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3964        is_terminated: bool,
3965    ) -> Self {
3966        Self { inner, is_terminated }
3967    }
3968}
3969
3970impl futures::Stream for BufferCollectionTokenRequestStream {
3971    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
3972
3973    fn poll_next(
3974        mut self: std::pin::Pin<&mut Self>,
3975        cx: &mut std::task::Context<'_>,
3976    ) -> std::task::Poll<Option<Self::Item>> {
3977        let this = &mut *self;
3978        if this.inner.check_shutdown(cx) {
3979            this.is_terminated = true;
3980            return std::task::Poll::Ready(None);
3981        }
3982        if this.is_terminated {
3983            panic!("polled BufferCollectionTokenRequestStream after completion");
3984        }
3985        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3986            |bytes, handles| {
3987                match this.inner.channel().read_etc(cx, bytes, handles) {
3988                    std::task::Poll::Ready(Ok(())) => {}
3989                    std::task::Poll::Pending => return std::task::Poll::Pending,
3990                    std::task::Poll::Ready(Err(None)) => {
3991                        this.is_terminated = true;
3992                        return std::task::Poll::Ready(None);
3993                    }
3994                    std::task::Poll::Ready(Err(Some(e))) => {
3995                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3996                            e.into(),
3997                        ))));
3998                    }
3999                }
4000
4001                // A message has been received from the channel
4002                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4003
4004                std::task::Poll::Ready(Some(match header.ordinal {
4005                0x4577e238ae26291 => {
4006                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4007                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4008                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4009                    let control_handle = BufferCollectionTokenControlHandle {
4010                        inner: this.inner.clone(),
4011                    };
4012                    Ok(BufferCollectionTokenRequest::Sync {
4013                        responder: BufferCollectionTokenSyncResponder {
4014                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4015                            tx_id: header.tx_id,
4016                        },
4017                    })
4018                }
4019                0x5b1d7a4f5681fca7 => {
4020                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4021                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4022                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4023                    let control_handle = BufferCollectionTokenControlHandle {
4024                        inner: this.inner.clone(),
4025                    };
4026                    Ok(BufferCollectionTokenRequest::Close {
4027                        control_handle,
4028                    })
4029                }
4030                0x77a41bb6217e2443 => {
4031                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4032                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
4033                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
4034                    let control_handle = BufferCollectionTokenControlHandle {
4035                        inner: this.inner.clone(),
4036                    };
4037                    Ok(BufferCollectionTokenRequest::SetName {priority: req.priority,
4038name: req.name,
4039
4040                        control_handle,
4041                    })
4042                }
4043                0x7275759070eb5ee2 => {
4044                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4045                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
4046                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
4047                    let control_handle = BufferCollectionTokenControlHandle {
4048                        inner: this.inner.clone(),
4049                    };
4050                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {name: req.name,
4051id: req.id,
4052
4053                        control_handle,
4054                    })
4055                }
4056                0x46d38f4772638867 => {
4057                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4058                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
4059                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
4060                    let control_handle = BufferCollectionTokenControlHandle {
4061                        inner: this.inner.clone(),
4062                    };
4063                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
4064
4065                        control_handle,
4066                    })
4067                }
4068                0x6bfbe2cf1701d288 => {
4069                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4070                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4071                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4072                    let control_handle = BufferCollectionTokenControlHandle {
4073                        inner: this.inner.clone(),
4074                    };
4075                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
4076                        control_handle,
4077                    })
4078                }
4079                0x467b7c75c35c3b84 => {
4080                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4081                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4082                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4083                    let control_handle = BufferCollectionTokenControlHandle {
4084                        inner: this.inner.clone(),
4085                    };
4086                    Ok(BufferCollectionTokenRequest::GetNodeRef {
4087                        responder: BufferCollectionTokenGetNodeRefResponder {
4088                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4089                            tx_id: header.tx_id,
4090                        },
4091                    })
4092                }
4093                0x33a2a7aff2776c07 => {
4094                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4095                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
4096                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
4097                    let control_handle = BufferCollectionTokenControlHandle {
4098                        inner: this.inner.clone(),
4099                    };
4100                    Ok(BufferCollectionTokenRequest::IsAlternateFor {node_ref: req.node_ref,
4101
4102                        responder: BufferCollectionTokenIsAlternateForResponder {
4103                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4104                            tx_id: header.tx_id,
4105                        },
4106                    })
4107                }
4108                0x49ed7ab7cc19f18 => {
4109                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4110                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
4111                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
4112                    let control_handle = BufferCollectionTokenControlHandle {
4113                        inner: this.inner.clone(),
4114                    };
4115                    Ok(BufferCollectionTokenRequest::DuplicateSync {rights_attenuation_masks: req.rights_attenuation_masks,
4116
4117                        responder: BufferCollectionTokenDuplicateSyncResponder {
4118                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4119                            tx_id: header.tx_id,
4120                        },
4121                    })
4122                }
4123                0x2f9f81bdde4b7292 => {
4124                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4125                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fdomain_client::fidl::FDomainResourceDialect);
4126                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
4127                    let control_handle = BufferCollectionTokenControlHandle {
4128                        inner: this.inner.clone(),
4129                    };
4130                    Ok(BufferCollectionTokenRequest::Duplicate {rights_attenuation_mask: req.rights_attenuation_mask,
4131token_request: req.token_request,
4132
4133                        control_handle,
4134                    })
4135                }
4136                0x76e4ec34fc2cf5b3 => {
4137                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4138                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4139                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4140                    let control_handle = BufferCollectionTokenControlHandle {
4141                        inner: this.inner.clone(),
4142                    };
4143                    Ok(BufferCollectionTokenRequest::SetDispensable {
4144                        control_handle,
4145                    })
4146                }
4147                0x2f6243e05f22b9a7 => {
4148                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4149                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fdomain_client::fidl::FDomainResourceDialect);
4150                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
4151                    let control_handle = BufferCollectionTokenControlHandle {
4152                        inner: this.inner.clone(),
4153                    };
4154                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {group_request: req.group_request,
4155
4156                        control_handle,
4157                    })
4158                }
4159                _ => Err(fidl::Error::UnknownOrdinal {
4160                    ordinal: header.ordinal,
4161                    protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4162                }),
4163            }))
4164            },
4165        )
4166    }
4167}
4168
4169/// A BufferCollectionToken is not a BufferCollection, but rather a way to
4170/// identify a potential shared BufferCollection prior to the BufferCollection
4171/// being allocated.
4172///
4173/// We use a channel for the BufferCollectionToken instead of a single eventpair
4174/// (pair) because this way we can detect error conditions like a participant
4175/// dying mid-create.
4176///
4177/// The fuchsia.sysmem.BufferCollectionToken type is not yet deprecated due to
4178/// its use in some other protocols (for now), but all the internals of
4179/// fuchsia.sysmem.BufferCollectionToken are deprecated. Token channels serve
4180/// both fuchsia.sysmem.BufferCollectionToken and
4181/// fuchsia.sysmem2.BufferCollectionToken.
4182///
4183/// This protocol will be deprecated once other protocols have switched their
4184/// token fields to fuchsia.sysmem2.BufferCollectionToken.
4185#[derive(Debug)]
4186pub enum BufferCollectionTokenRequest {
4187    /// Ensure that previous messages, including Duplicate() messages on a
4188    /// token, collection, or group, have been received server side.
4189    ///
4190    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4191    /// valid sysmem token risks the Sync() hanging forever.  See
4192    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4193    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4194    /// Another way is to pass the token to BindSharedCollection(), which also
4195    /// validates the token as part of exchanging it for a BufferCollection
4196    /// channel, and BufferCollection Sync() can then be used.
4197    ///
4198    /// After a Sync(), it's then safe to send the client end of token_request
4199    /// to another participant knowing the server will recognize the token when
4200    /// it's sent into BindSharedCollection() by the other participant.
4201    ///
4202    /// Other options include waiting for each token.Duplicate() to complete
4203    /// individually (using separate call to token.Sync() after each), or
4204    /// calling Sync() on BufferCollection after the token has been turned in
4205    /// via BindSharedCollection().
4206    ///
4207    /// Another way to mitigate is to avoid calling Sync() on the token, and
4208    /// instead later deal with potential failure of BufferCollection.Sync() if
4209    /// the original token was invalid.  This option can be preferable from a
4210    /// performance point of view, but requires client code to delay sending
4211    /// tokens duplicated from this token until after client code has converted
4212    /// the duplicating token to a BufferCollection and received successful
4213    /// response from BufferCollection.Sync().
4214    ///
4215    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4216    /// When BufferCollection.Sync() isn't feasible, the caller must already
4217    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4218    /// hang forever.  See ValidateBufferCollectionToken() to check token
4219    /// validity first if the token isn't already known to be (is/was) valid.
4220    Sync { responder: BufferCollectionTokenSyncResponder },
4221    /// On a BufferCollectionToken channel:
4222    ///
4223    /// Normally a participant will convert a BufferCollectionToken into a
4224    /// BufferCollection view, but a participant is also free to Close() the
4225    /// token (and then close the channel immediately or shortly later in
4226    /// response to server closing its end), which avoids causing logical buffer
4227    /// collection failure.  Normally an unexpected token channel close will
4228    /// cause logical buffer collection failure (the only exceptions being
4229    /// certain cases involving AttachToken() or SetDispensable()).
4230    ///
4231    /// On a BufferCollection channel:
4232    ///
4233    /// By default the server handles unexpected failure of a BufferCollection
4234    /// by failing the whole logical buffer collection.  Partly this is to
4235    /// expedite closing VMO handles to reclaim memory when any participant
4236    /// fails.  If a participant would like to cleanly close a BufferCollection
4237    /// view without causing logical buffer collection failure, the participant
4238    /// can send Close() before closing the client end of the BufferCollection
4239    /// channel.  If this is the last BufferCollection view, the logical buffer
4240    /// collection will still go away.  The Close() can occur before or after
4241    /// SetConstraints().  If before SetConstraints(), the buffer collection
4242    /// won't require constraints from this node in order to allocate.  If
4243    /// after SetConstraints(), the constraints are retained and aggregated
4244    /// along with any subsequent logical allocation(s), despite the lack of
4245    /// channel connection.
4246    ///
4247    /// On a BufferCollectionTokenGroup channel:
4248    ///
4249    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4250    /// trigger failure of the logical BufferCollectionTokenGroup and will
4251    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4252    /// channel without failing the logical group or propagating failure, send
4253    /// Close() before closing the channel client endpoint.
4254    ///
4255    /// If Close() occurs before AllChildrenPresent(), the logical buffer
4256    /// collection will still fail despite the Close() (because sysmem can't be
4257    /// sure whether all relevant children were created, so it's ambiguous
4258    /// whether all relevant constraints will be provided to sysmem).  If
4259    /// Close() occurs after AllChildrenPresent(), the children and all their
4260    /// constraints remain intact (just as they would if the
4261    /// BufferCollectionTokenGroup channel had remained open), and the close
4262    /// doesn't trigger or propagate failure.
4263    Close { control_handle: BufferCollectionTokenControlHandle },
4264    /// Set a name for VMOs in this buffer collection. The name may be truncated
4265    /// shorter. The name only affects VMOs allocated after it's set - this call
4266    /// does not rename existing VMOs. If multiple clients set different names
4267    /// then the larger priority value will win.
4268    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenControlHandle },
4269    /// Set information about the current client that can be used by sysmem to
4270    /// help debug leaking memory and hangs waiting for constraints. |name| can
4271    /// be an arbitrary string, but the current process name (see
4272    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4273    /// arbitrary id, but the current process ID (see
4274    /// fsl::GetCurrentProcessKoid()) is a good default.
4275    ///
4276    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4277    /// indicate which client is closing their channel first, leading to
4278    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4279    /// over, but if happening earlier than expected, the
4280    /// client-channel-specific name can help diagnose where the failure is
4281    /// first coming from, from sysmem's point of view).
4282    ///
4283    /// By default (unless overriden by this message or using
4284    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4285    /// parent Node at the time the child Node is created.  While this can be
4286    /// better than nothing, it's often better for each participant to use
4287    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4288    /// info directly relevant to the current client.  Also, SetVerboseLogging()
4289    /// can be used to help disambiguate if a Node is suspected of having info
4290    /// that was copied from its parent.
4291    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionTokenControlHandle },
4292    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4293    /// after creating a collection. Clients can call this method to change
4294    /// when the log is printed. If multiple client set the deadline, it's
4295    /// unspecified which deadline will take effect.
4296    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionTokenControlHandle },
4297    /// Verbose logging includes constraints set via SetConstraints() from each
4298    /// client along with info set via SetDebugClientInfo() and the structure of
4299    /// the tree of Node(s).
4300    ///
4301    /// Normally sysmem prints only a single line complaint when aggregation
4302    /// fails, with just the specific detailed reason that aggregation failed,
4303    /// with minimal context.  While this is often enough to diagnose a problem
4304    /// if only a small change was made and the system had been working before
4305    /// the small change, it's often not particularly helpful for getting a new
4306    /// buffer collection to work for the first time.  Especially with more
4307    /// complex trees of nodes, involving things like AttachToken(),
4308    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4309    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4310    /// looks like and why it's failing a logical allocation, or why a tree or
4311    /// sub-tree is failing sooner than expected.
4312    ///
4313    /// The intent of the extra logging is to be acceptable from a performance
4314    /// point of view, if only enabled on a low number of buffer collections.
4315    /// If we're not tracking down a bug, we shouldn't send this message.
4316    ///
4317    /// If too many participants leave verbose logging enabled, we may end up
4318    /// needing to require that system-wide sysmem verbose logging be permitted
4319    /// via some other setting, to avoid sysmem spamming the log too much due to
4320    /// this message.
4321    ///
4322    /// This may be a NOP for some nodes due to intentional policy associated
4323    /// with the node, if we don't trust a node enough to let it turn on verbose
4324    /// logging.
4325    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
4326    /// This gets an event handle that can be used as a parameter to
4327    /// IsAlternateFor() called on any Node.  The client will not be granted the
4328    /// right to signal this event, as this handle should only be used as proof
4329    /// that the client obtained this handle from this Node.
4330    ///
4331    /// Because this is a get not a set, no Sync() is needed between the
4332    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4333    /// potentially being on different channels.
4334    ///
4335    /// See also IsAlternateFor().
4336    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
4337    /// This checks whether the calling node is in a subtree rooted at a
4338    /// different child token of a common parent BufferCollectionTokenGroup, in
4339    /// relation to the passed-in node_ref.
4340    ///
4341    /// This call is for assisting with admission control de-duplication, and
4342    /// with debugging.
4343    ///
4344    /// The node_ref must be obtained using GetNodeRef() of a
4345    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4346    ///
4347    /// The node_ref can be a duplicated handle; it's not necessary to call
4348    /// GetNodeRef() for every call to IsAlternateFor().
4349    ///
4350    /// If a calling token may not actually be a valid token at all due to
4351    /// a potentially hostile/untrusted provider of the token, call
4352    /// ValidateBufferCollectionToken() first instead of potentially getting
4353    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4354    /// token not being a real token (not really talking to sysmem).  Another
4355    /// option is to call BindSharedCollection with this token first which also
4356    /// validates the token along with converting it to a BufferCollection, then
4357    /// call BufferCollection IsAlternateFor().
4358    ///
4359    /// error values:
4360    ///
4361    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4362    /// buffer collection as the calling Node.  Before logical allocation and
4363    /// within the same logical allocation sub-tree, this essentially means that
4364    /// the node_ref was never part of this logical buffer collection, since
4365    /// before logical allocation all node_refs that come into existence remain
4366    /// in existence at least until logical allocation (including Node(s) that
4367    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4368    /// to be returned, this Node's channel needs to still be connected server
4369    /// side, which won't be the case if the whole logical allocation has
4370    /// failed.  After logical allocation or in a different logical allocation
4371    /// sub-tree there are additional potential reasons for this error.  For
4372    /// example a different logical allocation (separated from this Node(s)
4373    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4374    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4375    /// exist and may select a different child sub-tree than the sub-tree the
4376    /// node_ref is in causing deletion of the node_ref Node.  The only time
4377    /// sysmem keeps a Node around after that Node has no corresponding channel
4378    /// is when Close() is used and the Node's sub-tree has not yet failed.
4379    /// Another reason for this error is if the node_ref is an eventpair handle
4380    /// with sufficient rights, but isn't actually a real node_ref obtained from
4381    /// GetNodeRef().
4382    ///
4383    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4384    /// eventpair handle, or doesn't have the needed rights expected on a real
4385    /// node_ref.
4386    ///
4387    /// No other failing status codes are returned by this call.  However,
4388    /// sysmem may add additional codes in future, so the client should have
4389    /// sensible default handling for any failing status code.
4390    ///
4391    /// On success, is_alternate has the following meaning:
4392    ///   * true - The first parent node in common between the calling node and
4393    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
4394    ///     the calling Node and the node_ref Node will _not_ have both their
4395    ///     constraints apply - rather sysmem will choose one or the other of
4396    ///     the constraints - never both.  This is because only one child of
4397    ///     a BufferCollectionTokenGroup is selected during logical allocation,
4398    ///     with only that one child's sub-tree contributing to constraints
4399    ///     aggregation.
4400    ///   * false - The first parent node in common between the calling Node and
4401    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
4402    ///     this means the first parent node in common is a
4403    ///     BufferCollectionToken or BufferCollection (regardless of not
4404    ///     Close()ed or Close()ed).  This means that the calling Node and the
4405    ///     node_ref Node _may_ have both their constraints apply during
4406    ///     constraints aggregation of the logical allocation, if both Node(s)
4407    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
4408    ///     In this case, there is no BufferCollectionTokenGroup that will
4409    ///     directly prevent the two Node(s) from both being selected and their
4410    ///     constraints both aggregated, but even when false, one or both
4411    ///     Node(s) may still be eliminated from consideration if one or both
4412    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4413    ///     which selects a child sub-tree other than the sub-tree containing
4414    ///     the calling Node or node_ref Node.
4415    IsAlternateFor {
4416        node_ref: fdomain_client::Event,
4417        responder: BufferCollectionTokenIsAlternateForResponder,
4418    },
4419    /// This method can be used to add more participants prior to creating a
4420    /// shared BufferCollection. A new token will be returned for each entry in
4421    /// the `rights_attenuation_masks` array. The return value is the client
4422    /// ends of each new participant token.
4423    ///
4424    /// If the calling token may not actually be a valid token at all due to
4425    /// a potentially hostile/untrusted provider of the token, consider using
4426    /// ValidateBufferCollectionToken() first instead of potentially getting
4427    /// stuck indefinitely if DuplicateSync() never responds due to the calling
4428    /// token not being a real token.
4429    ///
4430    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4431    /// after calling this method.
4432    ///
4433    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4434    /// BufferCollection to be successfully created.
4435    ///
4436    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4437    /// will be absent in the buffer VMO rights obtainable via the corresponding
4438    /// returned token. This allows an initiator or intermediary participant to
4439    /// attenuate the rights available to a participant. This does not allow a
4440    /// participant to gain rights that the participant doesn't already have.
4441    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4442    /// attenuation should be applied.
4443    DuplicateSync {
4444        rights_attenuation_masks: Vec<fidl::Rights>,
4445        responder: BufferCollectionTokenDuplicateSyncResponder,
4446    },
4447    /// This method can be used to add a participant prior to creating a shared
4448    /// BufferCollection. It should only be used instead of DuplicateSync in
4449    /// performance sensitive cases where it would be undesireable to wait for
4450    /// sysmem to respond as part of each duplicate.
4451    ///
4452    /// After sending one or more Duplicate() messages, and before sending the
4453    /// created tokens to other participants (or to other Allocator channels),
4454    /// the client should send a Sync() and wait for its response.  The Sync()
4455    /// call can be made on the token, or on the BufferCollection obtained by
4456    /// passing this token to BindSharedCollection().  Either will ensure that
4457    /// the server knows about the tokens created via Duplicate() before the
4458    /// other participant sends the token to the server via separate Allocator
4459    /// channel.
4460    ///
4461    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4462    /// BufferCollection to be successfully created.
4463    ///
4464    /// When a client calls BindSharedCollection() to turn in a
4465    /// BufferCollectionToken, the server will process all Duplicate() messages
4466    /// before closing down the BufferCollectionToken.  This allows the client
4467    /// to Duplicate() and immediately turn in the BufferCollectionToken using
4468    /// BindSharedCollection, then later transfer the client end of token_request
4469    /// to another participant - the server will notice the existence of the
4470    /// token_request before considering this BufferCollectionToken fully closed.
4471    ///
4472    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
4473    /// absent in the buffer VMO rights obtainable via the client end of
4474    /// token_request. This allows an initiator or intermediary participant to
4475    /// attenuate the rights available to a participant. This does not allow a
4476    /// participant to gain rights that the participant doesn't already have.
4477    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4478    /// attenuation should be applied.
4479    ///
4480    /// These values for rights_attenuation_mask result in no attenuation:
4481    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
4482    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
4483    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
4484    ///
4485    /// `token_request` is the server end of a BufferCollectionToken channel.
4486    /// The client end of this channel acts as another participant in creating the
4487    /// shared BufferCollection.
4488    Duplicate {
4489        rights_attenuation_mask: u32,
4490        token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
4491        control_handle: BufferCollectionTokenControlHandle,
4492    },
4493    /// A dispensable token can fail after buffers are logically allocated
4494    /// without causing failure of its parent (if any).
4495    ///
4496    /// The dispensable token participates in constraints aggregation along with
4497    /// its parent before logical buffer allocation.  If the dispensable token
4498    /// fails before buffers are logically allocated, the failure propagates to
4499    /// the dispensable token's parent.
4500    ///
4501    /// After buffers are logically allocated, failure of the dispensable token
4502    /// (or any child of the dispensable token) does not propagate to the
4503    /// dispensable token's parent.  Failure does propagate from a normal
4504    /// child of a dispensable token to the dispensable token.  Failure
4505    /// of a child is blocked from reaching its parent if the child is attached,
4506    /// or if the child is dispensable and the failure occurred after logical
4507    /// allocation.
4508    ///
4509    /// A dispensable token can be used in cases where a participant needs to
4510    /// provide constraints, but after buffers are allocated, the participant
4511    /// can fail without causing buffer collection failure from the parent's
4512    /// point of view.
4513    ///
4514    /// In contrast, AttachToken() can be used to create a token which does not
4515    /// participate in constraints aggregation with its parent, and whose
4516    /// failure at any time does not propagate to its parent, and whose delay
4517    /// providing constraints does not prevent the parent from completing its
4518    /// buffer allocation.
4519    ///
4520    /// An initiator may in some scenarios choose to initially use a dispensable
4521    /// token for a given instance of a participant, and then later if the first
4522    /// instance of that participant fails, a new second instance of that
4523    /// participant my be given a token created with AttachToken().
4524    ///
4525    /// If a client uses this message, the client should not rely on the
4526    /// client's own BufferCollectionToken or BufferCollection channel to close
4527    /// from the server end due to abrupt failure of any BufferCollectionToken
4528    /// or BufferCollection that the client has SetDispensable() and given out
4529    /// to another process.  For this reason, the client should take extra care
4530    /// to notice failure of that other process via other means.
4531    ///
4532    /// While it is possible (and potentially useful) to SetDispensable() on a
4533    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
4534    /// replace a failed dispensable token that was a direct child of a group
4535    /// with a new token using AttachToken() (since there's no AttachToken() on
4536    /// a group).  Instead, to enable AttachToken() replacement in this case,
4537    /// create an additional non-dispensable token (node) that's a direct child
4538    /// of the group and make the existing dispensable token a child of the
4539    /// additional token (node).  This way, the additional token (node) that is
4540    /// a direct child of the group has BufferCollection.AttachToken() which can
4541    /// be used to replace the failed dispensable token.
4542    ///
4543    /// SetDispensable() on an already-dispensable token is idempotent.
4544    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
4545    /// Most sysmem clients and many participants don't need to care about this
4546    /// message or about BufferCollectionTokenGroup(s) in general.
4547    ///
4548    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
4549    /// tokens.  The child tokens which are not selected during aggregation will
4550    /// fail (close), which a potential participant should notice when their
4551    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
4552    /// participant to clean up the speculative usage that didn't end up
4553    /// happening (similarly to a normal BufferCollection server end closing
4554    /// on failure of a logical buffer collection).
4555    ///
4556    /// See comments on protocol BufferCollectionTokenGroup.
4557    ///
4558    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
4559    /// applied to the whole group can be achieved with a token for this purpose
4560    /// as a direct parent of the group.
4561    ///
4562    /// group_request - the server end of a BufferCollectionTokenGroup channel
4563    /// to be served by sysmem.
4564    CreateBufferCollectionTokenGroup {
4565        group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
4566        control_handle: BufferCollectionTokenControlHandle,
4567    },
4568}
4569
4570impl BufferCollectionTokenRequest {
4571    #[allow(irrefutable_let_patterns)]
4572    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
4573        if let BufferCollectionTokenRequest::Sync { responder } = self {
4574            Some((responder))
4575        } else {
4576            None
4577        }
4578    }
4579
4580    #[allow(irrefutable_let_patterns)]
4581    pub fn into_close(self) -> Option<(BufferCollectionTokenControlHandle)> {
4582        if let BufferCollectionTokenRequest::Close { control_handle } = self {
4583            Some((control_handle))
4584        } else {
4585            None
4586        }
4587    }
4588
4589    #[allow(irrefutable_let_patterns)]
4590    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenControlHandle)> {
4591        if let BufferCollectionTokenRequest::SetName { priority, name, control_handle } = self {
4592            Some((priority, name, control_handle))
4593        } else {
4594            None
4595        }
4596    }
4597
4598    #[allow(irrefutable_let_patterns)]
4599    pub fn into_set_debug_client_info(
4600        self,
4601    ) -> Option<(String, u64, BufferCollectionTokenControlHandle)> {
4602        if let BufferCollectionTokenRequest::SetDebugClientInfo { name, id, control_handle } = self
4603        {
4604            Some((name, id, control_handle))
4605        } else {
4606            None
4607        }
4608    }
4609
4610    #[allow(irrefutable_let_patterns)]
4611    pub fn into_set_debug_timeout_log_deadline(
4612        self,
4613    ) -> Option<(i64, BufferCollectionTokenControlHandle)> {
4614        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
4615            deadline,
4616            control_handle,
4617        } = self
4618        {
4619            Some((deadline, control_handle))
4620        } else {
4621            None
4622        }
4623    }
4624
4625    #[allow(irrefutable_let_patterns)]
4626    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
4627        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
4628            Some((control_handle))
4629        } else {
4630            None
4631        }
4632    }
4633
4634    #[allow(irrefutable_let_patterns)]
4635    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
4636        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
4637            Some((responder))
4638        } else {
4639            None
4640        }
4641    }
4642
4643    #[allow(irrefutable_let_patterns)]
4644    pub fn into_is_alternate_for(
4645        self,
4646    ) -> Option<(fdomain_client::Event, BufferCollectionTokenIsAlternateForResponder)> {
4647        if let BufferCollectionTokenRequest::IsAlternateFor { node_ref, responder } = self {
4648            Some((node_ref, responder))
4649        } else {
4650            None
4651        }
4652    }
4653
4654    #[allow(irrefutable_let_patterns)]
4655    pub fn into_duplicate_sync(
4656        self,
4657    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenDuplicateSyncResponder)> {
4658        if let BufferCollectionTokenRequest::DuplicateSync { rights_attenuation_masks, responder } =
4659            self
4660        {
4661            Some((rights_attenuation_masks, responder))
4662        } else {
4663            None
4664        }
4665    }
4666
4667    #[allow(irrefutable_let_patterns)]
4668    pub fn into_duplicate(
4669        self,
4670    ) -> Option<(
4671        u32,
4672        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
4673        BufferCollectionTokenControlHandle,
4674    )> {
4675        if let BufferCollectionTokenRequest::Duplicate {
4676            rights_attenuation_mask,
4677            token_request,
4678            control_handle,
4679        } = self
4680        {
4681            Some((rights_attenuation_mask, token_request, control_handle))
4682        } else {
4683            None
4684        }
4685    }
4686
4687    #[allow(irrefutable_let_patterns)]
4688    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
4689        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
4690            Some((control_handle))
4691        } else {
4692            None
4693        }
4694    }
4695
4696    #[allow(irrefutable_let_patterns)]
4697    pub fn into_create_buffer_collection_token_group(
4698        self,
4699    ) -> Option<(
4700        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
4701        BufferCollectionTokenControlHandle,
4702    )> {
4703        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
4704            group_request,
4705            control_handle,
4706        } = self
4707        {
4708            Some((group_request, control_handle))
4709        } else {
4710            None
4711        }
4712    }
4713
4714    /// Name of the method defined in FIDL
4715    pub fn method_name(&self) -> &'static str {
4716        match *self {
4717            BufferCollectionTokenRequest::Sync { .. } => "sync",
4718            BufferCollectionTokenRequest::Close { .. } => "close",
4719            BufferCollectionTokenRequest::SetName { .. } => "set_name",
4720            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
4721            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
4722                "set_debug_timeout_log_deadline"
4723            }
4724            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
4725            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
4726            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
4727            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
4728            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
4729            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
4730            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
4731                "create_buffer_collection_token_group"
4732            }
4733        }
4734    }
4735}
4736
4737#[derive(Debug, Clone)]
4738pub struct BufferCollectionTokenControlHandle {
4739    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4740}
4741
4742impl BufferCollectionTokenControlHandle {
4743    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4744        self.inner.shutdown_with_epitaph(status.into())
4745    }
4746}
4747
4748impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenControlHandle {
4749    fn shutdown(&self) {
4750        self.inner.shutdown()
4751    }
4752
4753    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4754        self.inner.shutdown_with_epitaph(status)
4755    }
4756
4757    fn is_closed(&self) -> bool {
4758        self.inner.channel().is_closed()
4759    }
4760    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4761        self.inner.channel().on_closed()
4762    }
4763}
4764
4765impl BufferCollectionTokenControlHandle {}
4766
4767#[must_use = "FIDL methods require a response to be sent"]
4768#[derive(Debug)]
4769pub struct BufferCollectionTokenSyncResponder {
4770    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4771    tx_id: u32,
4772}
4773
4774/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4775/// if the responder is dropped without sending a response, so that the client
4776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4777impl std::ops::Drop for BufferCollectionTokenSyncResponder {
4778    fn drop(&mut self) {
4779        self.control_handle.shutdown();
4780        // Safety: drops once, never accessed again
4781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4782    }
4783}
4784
4785impl fdomain_client::fidl::Responder for BufferCollectionTokenSyncResponder {
4786    type ControlHandle = BufferCollectionTokenControlHandle;
4787
4788    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4789        &self.control_handle
4790    }
4791
4792    fn drop_without_shutdown(mut self) {
4793        // Safety: drops once, never accessed again due to mem::forget
4794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4795        // Prevent Drop from running (which would shut down the channel)
4796        std::mem::forget(self);
4797    }
4798}
4799
4800impl BufferCollectionTokenSyncResponder {
4801    /// Sends a response to the FIDL transaction.
4802    ///
4803    /// Sets the channel to shutdown if an error occurs.
4804    pub fn send(self) -> Result<(), fidl::Error> {
4805        let _result = self.send_raw();
4806        if _result.is_err() {
4807            self.control_handle.shutdown();
4808        }
4809        self.drop_without_shutdown();
4810        _result
4811    }
4812
4813    /// Similar to "send" but does not shutdown the channel if an error occurs.
4814    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4815        let _result = self.send_raw();
4816        self.drop_without_shutdown();
4817        _result
4818    }
4819
4820    fn send_raw(&self) -> Result<(), fidl::Error> {
4821        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4822            (),
4823            self.tx_id,
4824            0x4577e238ae26291,
4825            fidl::encoding::DynamicFlags::empty(),
4826        )
4827    }
4828}
4829
4830#[must_use = "FIDL methods require a response to be sent"]
4831#[derive(Debug)]
4832pub struct BufferCollectionTokenGetNodeRefResponder {
4833    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4834    tx_id: u32,
4835}
4836
4837/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4838/// if the responder is dropped without sending a response, so that the client
4839/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4840impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
4841    fn drop(&mut self) {
4842        self.control_handle.shutdown();
4843        // Safety: drops once, never accessed again
4844        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4845    }
4846}
4847
4848impl fdomain_client::fidl::Responder for BufferCollectionTokenGetNodeRefResponder {
4849    type ControlHandle = BufferCollectionTokenControlHandle;
4850
4851    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4852        &self.control_handle
4853    }
4854
4855    fn drop_without_shutdown(mut self) {
4856        // Safety: drops once, never accessed again due to mem::forget
4857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4858        // Prevent Drop from running (which would shut down the channel)
4859        std::mem::forget(self);
4860    }
4861}
4862
4863impl BufferCollectionTokenGetNodeRefResponder {
4864    /// Sends a response to the FIDL transaction.
4865    ///
4866    /// Sets the channel to shutdown if an error occurs.
4867    pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
4868        let _result = self.send_raw(node_ref);
4869        if _result.is_err() {
4870            self.control_handle.shutdown();
4871        }
4872        self.drop_without_shutdown();
4873        _result
4874    }
4875
4876    /// Similar to "send" but does not shutdown the channel if an error occurs.
4877    pub fn send_no_shutdown_on_err(
4878        self,
4879        mut node_ref: fdomain_client::Event,
4880    ) -> Result<(), fidl::Error> {
4881        let _result = self.send_raw(node_ref);
4882        self.drop_without_shutdown();
4883        _result
4884    }
4885
4886    fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
4887        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
4888            (node_ref,),
4889            self.tx_id,
4890            0x467b7c75c35c3b84,
4891            fidl::encoding::DynamicFlags::empty(),
4892        )
4893    }
4894}
4895
4896#[must_use = "FIDL methods require a response to be sent"]
4897#[derive(Debug)]
4898pub struct BufferCollectionTokenIsAlternateForResponder {
4899    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4900    tx_id: u32,
4901}
4902
4903/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4904/// if the responder is dropped without sending a response, so that the client
4905/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4906impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
4907    fn drop(&mut self) {
4908        self.control_handle.shutdown();
4909        // Safety: drops once, never accessed again
4910        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4911    }
4912}
4913
4914impl fdomain_client::fidl::Responder for BufferCollectionTokenIsAlternateForResponder {
4915    type ControlHandle = BufferCollectionTokenControlHandle;
4916
4917    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4918        &self.control_handle
4919    }
4920
4921    fn drop_without_shutdown(mut self) {
4922        // Safety: drops once, never accessed again due to mem::forget
4923        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4924        // Prevent Drop from running (which would shut down the channel)
4925        std::mem::forget(self);
4926    }
4927}
4928
4929impl BufferCollectionTokenIsAlternateForResponder {
4930    /// Sends a response to the FIDL transaction.
4931    ///
4932    /// Sets the channel to shutdown if an error occurs.
4933    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4934        let _result = self.send_raw(result);
4935        if _result.is_err() {
4936            self.control_handle.shutdown();
4937        }
4938        self.drop_without_shutdown();
4939        _result
4940    }
4941
4942    /// Similar to "send" but does not shutdown the channel if an error occurs.
4943    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4944        let _result = self.send_raw(result);
4945        self.drop_without_shutdown();
4946        _result
4947    }
4948
4949    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4950        self.control_handle
4951            .inner
4952            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
4953                result.map(|is_alternate| (is_alternate,)),
4954                self.tx_id,
4955                0x33a2a7aff2776c07,
4956                fidl::encoding::DynamicFlags::empty(),
4957            )
4958    }
4959}
4960
4961#[must_use = "FIDL methods require a response to be sent"]
4962#[derive(Debug)]
4963pub struct BufferCollectionTokenDuplicateSyncResponder {
4964    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4965    tx_id: u32,
4966}
4967
4968/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4969/// if the responder is dropped without sending a response, so that the client
4970/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4971impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
4972    fn drop(&mut self) {
4973        self.control_handle.shutdown();
4974        // Safety: drops once, never accessed again
4975        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4976    }
4977}
4978
4979impl fdomain_client::fidl::Responder for BufferCollectionTokenDuplicateSyncResponder {
4980    type ControlHandle = BufferCollectionTokenControlHandle;
4981
4982    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4983        &self.control_handle
4984    }
4985
4986    fn drop_without_shutdown(mut self) {
4987        // Safety: drops once, never accessed again due to mem::forget
4988        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4989        // Prevent Drop from running (which would shut down the channel)
4990        std::mem::forget(self);
4991    }
4992}
4993
4994impl BufferCollectionTokenDuplicateSyncResponder {
4995    /// Sends a response to the FIDL transaction.
4996    ///
4997    /// Sets the channel to shutdown if an error occurs.
4998    pub fn send(
4999        self,
5000        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5001    ) -> Result<(), fidl::Error> {
5002        let _result = self.send_raw(tokens);
5003        if _result.is_err() {
5004            self.control_handle.shutdown();
5005        }
5006        self.drop_without_shutdown();
5007        _result
5008    }
5009
5010    /// Similar to "send" but does not shutdown the channel if an error occurs.
5011    pub fn send_no_shutdown_on_err(
5012        self,
5013        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5014    ) -> Result<(), fidl::Error> {
5015        let _result = self.send_raw(tokens);
5016        self.drop_without_shutdown();
5017        _result
5018    }
5019
5020    fn send_raw(
5021        &self,
5022        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5023    ) -> Result<(), fidl::Error> {
5024        self.control_handle.inner.send::<BufferCollectionTokenDuplicateSyncResponse>(
5025            (tokens.as_mut(),),
5026            self.tx_id,
5027            0x49ed7ab7cc19f18,
5028            fidl::encoding::DynamicFlags::empty(),
5029        )
5030    }
5031}
5032
5033#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5034pub struct BufferCollectionTokenGroupMarker;
5035
5036impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenGroupMarker {
5037    type Proxy = BufferCollectionTokenGroupProxy;
5038    type RequestStream = BufferCollectionTokenGroupRequestStream;
5039
5040    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
5041}
5042
5043pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
5044    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5045    fn r#sync(&self) -> Self::SyncResponseFut;
5046    fn r#close(&self) -> Result<(), fidl::Error>;
5047    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
5048    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
5049    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
5050    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
5051    type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
5052        + Send;
5053    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
5054    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
5055        + Send;
5056    fn r#is_alternate_for(
5057        &self,
5058        node_ref: fdomain_client::Event,
5059    ) -> Self::IsAlternateForResponseFut;
5060    fn r#create_child(
5061        &self,
5062        payload: BufferCollectionTokenGroupCreateChildRequest,
5063    ) -> Result<(), fidl::Error>;
5064    type CreateChildrenSyncResponseFut: std::future::Future<
5065            Output = Result<
5066                Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5067                fidl::Error,
5068            >,
5069        > + Send;
5070    fn r#create_children_sync(
5071        &self,
5072        rights_attenuation_masks: &[fidl::Rights],
5073    ) -> Self::CreateChildrenSyncResponseFut;
5074    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
5075}
5076
5077#[derive(Debug, Clone)]
5078pub struct BufferCollectionTokenGroupProxy {
5079    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
5080}
5081
5082impl fdomain_client::fidl::Proxy for BufferCollectionTokenGroupProxy {
5083    type Protocol = BufferCollectionTokenGroupMarker;
5084
5085    fn from_channel(inner: fdomain_client::Channel) -> Self {
5086        Self::new(inner)
5087    }
5088
5089    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
5090        self.client.into_channel().map_err(|client| Self { client })
5091    }
5092
5093    fn as_channel(&self) -> &fdomain_client::Channel {
5094        self.client.as_channel()
5095    }
5096}
5097
5098impl BufferCollectionTokenGroupProxy {
5099    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionTokenGroup.
5100    pub fn new(channel: fdomain_client::Channel) -> Self {
5101        let protocol_name =
5102            <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
5103        Self { client: fidl::client::Client::new(channel, protocol_name) }
5104    }
5105
5106    /// Get a Stream of events from the remote end of the protocol.
5107    ///
5108    /// # Panics
5109    ///
5110    /// Panics if the event stream was already taken.
5111    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
5112        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
5113    }
5114
5115    /// Ensure that previous messages, including Duplicate() messages on a
5116    /// token, collection, or group, have been received server side.
5117    ///
5118    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5119    /// valid sysmem token risks the Sync() hanging forever.  See
5120    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5121    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5122    /// Another way is to pass the token to BindSharedCollection(), which also
5123    /// validates the token as part of exchanging it for a BufferCollection
5124    /// channel, and BufferCollection Sync() can then be used.
5125    ///
5126    /// After a Sync(), it's then safe to send the client end of token_request
5127    /// to another participant knowing the server will recognize the token when
5128    /// it's sent into BindSharedCollection() by the other participant.
5129    ///
5130    /// Other options include waiting for each token.Duplicate() to complete
5131    /// individually (using separate call to token.Sync() after each), or
5132    /// calling Sync() on BufferCollection after the token has been turned in
5133    /// via BindSharedCollection().
5134    ///
5135    /// Another way to mitigate is to avoid calling Sync() on the token, and
5136    /// instead later deal with potential failure of BufferCollection.Sync() if
5137    /// the original token was invalid.  This option can be preferable from a
5138    /// performance point of view, but requires client code to delay sending
5139    /// tokens duplicated from this token until after client code has converted
5140    /// the duplicating token to a BufferCollection and received successful
5141    /// response from BufferCollection.Sync().
5142    ///
5143    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5144    /// When BufferCollection.Sync() isn't feasible, the caller must already
5145    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5146    /// hang forever.  See ValidateBufferCollectionToken() to check token
5147    /// validity first if the token isn't already known to be (is/was) valid.
5148    pub fn r#sync(
5149        &self,
5150    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
5151        BufferCollectionTokenGroupProxyInterface::r#sync(self)
5152    }
5153
5154    /// On a BufferCollectionToken channel:
5155    ///
5156    /// Normally a participant will convert a BufferCollectionToken into a
5157    /// BufferCollection view, but a participant is also free to Close() the
5158    /// token (and then close the channel immediately or shortly later in
5159    /// response to server closing its end), which avoids causing logical buffer
5160    /// collection failure.  Normally an unexpected token channel close will
5161    /// cause logical buffer collection failure (the only exceptions being
5162    /// certain cases involving AttachToken() or SetDispensable()).
5163    ///
5164    /// On a BufferCollection channel:
5165    ///
5166    /// By default the server handles unexpected failure of a BufferCollection
5167    /// by failing the whole logical buffer collection.  Partly this is to
5168    /// expedite closing VMO handles to reclaim memory when any participant
5169    /// fails.  If a participant would like to cleanly close a BufferCollection
5170    /// view without causing logical buffer collection failure, the participant
5171    /// can send Close() before closing the client end of the BufferCollection
5172    /// channel.  If this is the last BufferCollection view, the logical buffer
5173    /// collection will still go away.  The Close() can occur before or after
5174    /// SetConstraints().  If before SetConstraints(), the buffer collection
5175    /// won't require constraints from this node in order to allocate.  If
5176    /// after SetConstraints(), the constraints are retained and aggregated
5177    /// along with any subsequent logical allocation(s), despite the lack of
5178    /// channel connection.
5179    ///
5180    /// On a BufferCollectionTokenGroup channel:
5181    ///
5182    /// By default, unexpected failure of a BufferCollectionTokenGroup will
5183    /// trigger failure of the logical BufferCollectionTokenGroup and will
5184    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
5185    /// channel without failing the logical group or propagating failure, send
5186    /// Close() before closing the channel client endpoint.
5187    ///
5188    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5189    /// collection will still fail despite the Close() (because sysmem can't be
5190    /// sure whether all relevant children were created, so it's ambiguous
5191    /// whether all relevant constraints will be provided to sysmem).  If
5192    /// Close() occurs after AllChildrenPresent(), the children and all their
5193    /// constraints remain intact (just as they would if the
5194    /// BufferCollectionTokenGroup channel had remained open), and the close
5195    /// doesn't trigger or propagate failure.
5196    pub fn r#close(&self) -> Result<(), fidl::Error> {
5197        BufferCollectionTokenGroupProxyInterface::r#close(self)
5198    }
5199
5200    /// Set a name for VMOs in this buffer collection. The name may be truncated
5201    /// shorter. The name only affects VMOs allocated after it's set - this call
5202    /// does not rename existing VMOs. If multiple clients set different names
5203    /// then the larger priority value will win.
5204    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5205        BufferCollectionTokenGroupProxyInterface::r#set_name(self, priority, name)
5206    }
5207
5208    /// Set information about the current client that can be used by sysmem to
5209    /// help debug leaking memory and hangs waiting for constraints. |name| can
5210    /// be an arbitrary string, but the current process name (see
5211    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5212    /// arbitrary id, but the current process ID (see
5213    /// fsl::GetCurrentProcessKoid()) is a good default.
5214    ///
5215    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5216    /// indicate which client is closing their channel first, leading to
5217    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5218    /// over, but if happening earlier than expected, the
5219    /// client-channel-specific name can help diagnose where the failure is
5220    /// first coming from, from sysmem's point of view).
5221    ///
5222    /// By default (unless overriden by this message or using
5223    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5224    /// parent Node at the time the child Node is created.  While this can be
5225    /// better than nothing, it's often better for each participant to use
5226    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5227    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5228    /// can be used to help disambiguate if a Node is suspected of having info
5229    /// that was copied from its parent.
5230    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5231        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, name, id)
5232    }
5233
5234    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5235    /// after creating a collection. Clients can call this method to change
5236    /// when the log is printed. If multiple client set the deadline, it's
5237    /// unspecified which deadline will take effect.
5238    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5239        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
5240    }
5241
5242    /// Verbose logging includes constraints set via SetConstraints() from each
5243    /// client along with info set via SetDebugClientInfo() and the structure of
5244    /// the tree of Node(s).
5245    ///
5246    /// Normally sysmem prints only a single line complaint when aggregation
5247    /// fails, with just the specific detailed reason that aggregation failed,
5248    /// with minimal context.  While this is often enough to diagnose a problem
5249    /// if only a small change was made and the system had been working before
5250    /// the small change, it's often not particularly helpful for getting a new
5251    /// buffer collection to work for the first time.  Especially with more
5252    /// complex trees of nodes, involving things like AttachToken(),
5253    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5254    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5255    /// looks like and why it's failing a logical allocation, or why a tree or
5256    /// sub-tree is failing sooner than expected.
5257    ///
5258    /// The intent of the extra logging is to be acceptable from a performance
5259    /// point of view, if only enabled on a low number of buffer collections.
5260    /// If we're not tracking down a bug, we shouldn't send this message.
5261    ///
5262    /// If too many participants leave verbose logging enabled, we may end up
5263    /// needing to require that system-wide sysmem verbose logging be permitted
5264    /// via some other setting, to avoid sysmem spamming the log too much due to
5265    /// this message.
5266    ///
5267    /// This may be a NOP for some nodes due to intentional policy associated
5268    /// with the node, if we don't trust a node enough to let it turn on verbose
5269    /// logging.
5270    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5271        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
5272    }
5273
5274    /// This gets an event handle that can be used as a parameter to
5275    /// IsAlternateFor() called on any Node.  The client will not be granted the
5276    /// right to signal this event, as this handle should only be used as proof
5277    /// that the client obtained this handle from this Node.
5278    ///
5279    /// Because this is a get not a set, no Sync() is needed between the
5280    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5281    /// potentially being on different channels.
5282    ///
5283    /// See also IsAlternateFor().
5284    pub fn r#get_node_ref(
5285        &self,
5286    ) -> fidl::client::QueryResponseFut<
5287        fdomain_client::Event,
5288        fdomain_client::fidl::FDomainResourceDialect,
5289    > {
5290        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
5291    }
5292
5293    /// This checks whether the calling node is in a subtree rooted at a
5294    /// different child token of a common parent BufferCollectionTokenGroup, in
5295    /// relation to the passed-in node_ref.
5296    ///
5297    /// This call is for assisting with admission control de-duplication, and
5298    /// with debugging.
5299    ///
5300    /// The node_ref must be obtained using GetNodeRef() of a
5301    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
5302    ///
5303    /// The node_ref can be a duplicated handle; it's not necessary to call
5304    /// GetNodeRef() for every call to IsAlternateFor().
5305    ///
5306    /// If a calling token may not actually be a valid token at all due to
5307    /// a potentially hostile/untrusted provider of the token, call
5308    /// ValidateBufferCollectionToken() first instead of potentially getting
5309    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
5310    /// token not being a real token (not really talking to sysmem).  Another
5311    /// option is to call BindSharedCollection with this token first which also
5312    /// validates the token along with converting it to a BufferCollection, then
5313    /// call BufferCollection IsAlternateFor().
5314    ///
5315    /// error values:
5316    ///
5317    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
5318    /// buffer collection as the calling Node.  Before logical allocation and
5319    /// within the same logical allocation sub-tree, this essentially means that
5320    /// the node_ref was never part of this logical buffer collection, since
5321    /// before logical allocation all node_refs that come into existence remain
5322    /// in existence at least until logical allocation (including Node(s) that
5323    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
5324    /// to be returned, this Node's channel needs to still be connected server
5325    /// side, which won't be the case if the whole logical allocation has
5326    /// failed.  After logical allocation or in a different logical allocation
5327    /// sub-tree there are additional potential reasons for this error.  For
5328    /// example a different logical allocation (separated from this Node(s)
5329    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
5330    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
5331    /// exist and may select a different child sub-tree than the sub-tree the
5332    /// node_ref is in causing deletion of the node_ref Node.  The only time
5333    /// sysmem keeps a Node around after that Node has no corresponding channel
5334    /// is when Close() is used and the Node's sub-tree has not yet failed.
5335    /// Another reason for this error is if the node_ref is an eventpair handle
5336    /// with sufficient rights, but isn't actually a real node_ref obtained from
5337    /// GetNodeRef().
5338    ///
5339    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
5340    /// eventpair handle, or doesn't have the needed rights expected on a real
5341    /// node_ref.
5342    ///
5343    /// No other failing status codes are returned by this call.  However,
5344    /// sysmem may add additional codes in future, so the client should have
5345    /// sensible default handling for any failing status code.
5346    ///
5347    /// On success, is_alternate has the following meaning:
5348    ///   * true - The first parent node in common between the calling node and
5349    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
5350    ///     the calling Node and the node_ref Node will _not_ have both their
5351    ///     constraints apply - rather sysmem will choose one or the other of
5352    ///     the constraints - never both.  This is because only one child of
5353    ///     a BufferCollectionTokenGroup is selected during logical allocation,
5354    ///     with only that one child's sub-tree contributing to constraints
5355    ///     aggregation.
5356    ///   * false - The first parent node in common between the calling Node and
5357    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
5358    ///     this means the first parent node in common is a
5359    ///     BufferCollectionToken or BufferCollection (regardless of not
5360    ///     Close()ed or Close()ed).  This means that the calling Node and the
5361    ///     node_ref Node _may_ have both their constraints apply during
5362    ///     constraints aggregation of the logical allocation, if both Node(s)
5363    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
5364    ///     In this case, there is no BufferCollectionTokenGroup that will
5365    ///     directly prevent the two Node(s) from both being selected and their
5366    ///     constraints both aggregated, but even when false, one or both
5367    ///     Node(s) may still be eliminated from consideration if one or both
5368    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
5369    ///     which selects a child sub-tree other than the sub-tree containing
5370    ///     the calling Node or node_ref Node.
5371    pub fn r#is_alternate_for(
5372        &self,
5373        mut node_ref: fdomain_client::Event,
5374    ) -> fidl::client::QueryResponseFut<
5375        NodeIsAlternateForResult,
5376        fdomain_client::fidl::FDomainResourceDialect,
5377    > {
5378        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, node_ref)
5379    }
5380
5381    /// Create a child token.  Before passing the client end of this token to
5382    /// BindSharedCollection(), completion of Sync() after CreateChild() is
5383    /// required.  Or the client can use CreateChildrenSync() which essentially
5384    /// includes the Sync().
5385    ///
5386    /// token_request - the server end of the new token channel.
5387    ///
5388    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
5389    /// allows the holder to get the same rights to buffers as the parent token
5390    /// (of the group) had.
5391    pub fn r#create_child(
5392        &self,
5393        mut payload: BufferCollectionTokenGroupCreateChildRequest,
5394    ) -> Result<(), fidl::Error> {
5395        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
5396    }
5397
5398    /// Create 1 or more child tokens at once, synchronously.  In contrast to
5399    /// CreateChild(), no Sync() completion is required before passing the
5400    /// client end of a returned token to BindSharedCollection().
5401    ///
5402    /// The size of the rights_attentuation_mask determines the number of
5403    /// created child tokens.
5404    ///
5405    /// The lower-index child tokens are higher priority (attempted sooner) than
5406    /// higher-index child tokens.
5407    ///
5408    /// As per all child tokens, successful aggregation will choose exactly one
5409    /// child among all created children (across all children created across
5410    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
5411    ///
5412    /// The maximum permissible total number of children per group, and total
5413    /// number of nodes in an overall tree (from the root) are capped to limits
5414    /// which are not configurable via these protocols.
5415    pub fn r#create_children_sync(
5416        &self,
5417        mut rights_attenuation_masks: &[fidl::Rights],
5418    ) -> fidl::client::QueryResponseFut<
5419        Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5420        fdomain_client::fidl::FDomainResourceDialect,
5421    > {
5422        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(
5423            self,
5424            rights_attenuation_masks,
5425        )
5426    }
5427
5428    /// AllChildrenPresent()
5429    ///
5430    /// After creating all children, the client must call AllChildrenPresent()
5431    /// to inform sysmem that no more children will be created, so that sysmem
5432    /// can know when it's ok to start aggregating constraints.
5433    ///
5434    /// If Close() is to be sent, it should be sent _after_
5435    /// AllChildrenPresent(), else failure of the group and propagation of the
5436    /// failure to the group's parent will still be triggered.
5437    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
5438        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
5439    }
5440}
5441
5442impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
5443    type SyncResponseFut =
5444        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
5445    fn r#sync(&self) -> Self::SyncResponseFut {
5446        fn _decode(
5447            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5448        ) -> Result<(), fidl::Error> {
5449            let _response = fidl::client::decode_transaction_body::<
5450                fidl::encoding::EmptyPayload,
5451                fdomain_client::fidl::FDomainResourceDialect,
5452                0x4577e238ae26291,
5453            >(_buf?)?;
5454            Ok(_response)
5455        }
5456        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5457            (),
5458            0x4577e238ae26291,
5459            fidl::encoding::DynamicFlags::empty(),
5460            _decode,
5461        )
5462    }
5463
5464    fn r#close(&self) -> Result<(), fidl::Error> {
5465        self.client.send::<fidl::encoding::EmptyPayload>(
5466            (),
5467            0x5b1d7a4f5681fca7,
5468            fidl::encoding::DynamicFlags::empty(),
5469        )
5470    }
5471
5472    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5473        self.client.send::<NodeSetNameRequest>(
5474            (priority, name),
5475            0x77a41bb6217e2443,
5476            fidl::encoding::DynamicFlags::empty(),
5477        )
5478    }
5479
5480    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5481        self.client.send::<NodeSetDebugClientInfoRequest>(
5482            (name, id),
5483            0x7275759070eb5ee2,
5484            fidl::encoding::DynamicFlags::empty(),
5485        )
5486    }
5487
5488    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5489        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5490            (deadline,),
5491            0x46d38f4772638867,
5492            fidl::encoding::DynamicFlags::empty(),
5493        )
5494    }
5495
5496    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5497        self.client.send::<fidl::encoding::EmptyPayload>(
5498            (),
5499            0x6bfbe2cf1701d288,
5500            fidl::encoding::DynamicFlags::empty(),
5501        )
5502    }
5503
5504    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
5505        fdomain_client::Event,
5506        fdomain_client::fidl::FDomainResourceDialect,
5507    >;
5508    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5509        fn _decode(
5510            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5511        ) -> Result<fdomain_client::Event, fidl::Error> {
5512            let _response = fidl::client::decode_transaction_body::<
5513                NodeGetNodeRefResponse,
5514                fdomain_client::fidl::FDomainResourceDialect,
5515                0x467b7c75c35c3b84,
5516            >(_buf?)?;
5517            Ok(_response.node_ref)
5518        }
5519        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
5520            (),
5521            0x467b7c75c35c3b84,
5522            fidl::encoding::DynamicFlags::empty(),
5523            _decode,
5524        )
5525    }
5526
5527    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5528        NodeIsAlternateForResult,
5529        fdomain_client::fidl::FDomainResourceDialect,
5530    >;
5531    fn r#is_alternate_for(
5532        &self,
5533        mut node_ref: fdomain_client::Event,
5534    ) -> Self::IsAlternateForResponseFut {
5535        fn _decode(
5536            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5537        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5538            let _response = fidl::client::decode_transaction_body::<
5539                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
5540                fdomain_client::fidl::FDomainResourceDialect,
5541                0x33a2a7aff2776c07,
5542            >(_buf?)?;
5543            Ok(_response.map(|x| x.is_alternate))
5544        }
5545        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5546            (node_ref,),
5547            0x33a2a7aff2776c07,
5548            fidl::encoding::DynamicFlags::empty(),
5549            _decode,
5550        )
5551    }
5552
5553    fn r#create_child(
5554        &self,
5555        mut payload: BufferCollectionTokenGroupCreateChildRequest,
5556    ) -> Result<(), fidl::Error> {
5557        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
5558            &mut payload,
5559            0x2e74f8bcbf59ee59,
5560            fidl::encoding::DynamicFlags::empty(),
5561        )
5562    }
5563
5564    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
5565        Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5566        fdomain_client::fidl::FDomainResourceDialect,
5567    >;
5568    fn r#create_children_sync(
5569        &self,
5570        mut rights_attenuation_masks: &[fidl::Rights],
5571    ) -> Self::CreateChildrenSyncResponseFut {
5572        fn _decode(
5573            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5574        ) -> Result<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
5575        {
5576            let _response = fidl::client::decode_transaction_body::<
5577                BufferCollectionTokenGroupCreateChildrenSyncResponse,
5578                fdomain_client::fidl::FDomainResourceDialect,
5579                0x569dc3ca2a98f535,
5580            >(_buf?)?;
5581            Ok(_response.tokens)
5582        }
5583        self.client.send_query_and_decode::<
5584            BufferCollectionTokenGroupCreateChildrenSyncRequest,
5585            Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5586        >(
5587            (rights_attenuation_masks,),
5588            0x569dc3ca2a98f535,
5589            fidl::encoding::DynamicFlags::empty(),
5590            _decode,
5591        )
5592    }
5593
5594    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
5595        self.client.send::<fidl::encoding::EmptyPayload>(
5596            (),
5597            0x1d41715f6f044b50,
5598            fidl::encoding::DynamicFlags::empty(),
5599        )
5600    }
5601}
5602
5603pub struct BufferCollectionTokenGroupEventStream {
5604    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5605}
5606
5607impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
5608
5609impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
5610    fn is_terminated(&self) -> bool {
5611        self.event_receiver.is_terminated()
5612    }
5613}
5614
5615impl futures::Stream for BufferCollectionTokenGroupEventStream {
5616    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
5617
5618    fn poll_next(
5619        mut self: std::pin::Pin<&mut Self>,
5620        cx: &mut std::task::Context<'_>,
5621    ) -> std::task::Poll<Option<Self::Item>> {
5622        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5623            &mut self.event_receiver,
5624            cx
5625        )?) {
5626            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
5627            None => std::task::Poll::Ready(None),
5628        }
5629    }
5630}
5631
5632#[derive(Debug)]
5633pub enum BufferCollectionTokenGroupEvent {}
5634
5635impl BufferCollectionTokenGroupEvent {
5636    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
5637    fn decode(
5638        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5639    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
5640        let (bytes, _handles) = buf.split_mut();
5641        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5642        debug_assert_eq!(tx_header.tx_id, 0);
5643        match tx_header.ordinal {
5644            _ => Err(fidl::Error::UnknownOrdinal {
5645                ordinal: tx_header.ordinal,
5646                protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5647            })
5648        }
5649    }
5650}
5651
5652/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionTokenGroup.
5653pub struct BufferCollectionTokenGroupRequestStream {
5654    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5655    is_terminated: bool,
5656}
5657
5658impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
5659
5660impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
5661    fn is_terminated(&self) -> bool {
5662        self.is_terminated
5663    }
5664}
5665
5666impl fdomain_client::fidl::RequestStream for BufferCollectionTokenGroupRequestStream {
5667    type Protocol = BufferCollectionTokenGroupMarker;
5668    type ControlHandle = BufferCollectionTokenGroupControlHandle;
5669
5670    fn from_channel(channel: fdomain_client::Channel) -> Self {
5671        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5672    }
5673
5674    fn control_handle(&self) -> Self::ControlHandle {
5675        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
5676    }
5677
5678    fn into_inner(
5679        self,
5680    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5681    {
5682        (self.inner, self.is_terminated)
5683    }
5684
5685    fn from_inner(
5686        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5687        is_terminated: bool,
5688    ) -> Self {
5689        Self { inner, is_terminated }
5690    }
5691}
5692
5693impl futures::Stream for BufferCollectionTokenGroupRequestStream {
5694    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
5695
5696    fn poll_next(
5697        mut self: std::pin::Pin<&mut Self>,
5698        cx: &mut std::task::Context<'_>,
5699    ) -> std::task::Poll<Option<Self::Item>> {
5700        let this = &mut *self;
5701        if this.inner.check_shutdown(cx) {
5702            this.is_terminated = true;
5703            return std::task::Poll::Ready(None);
5704        }
5705        if this.is_terminated {
5706            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
5707        }
5708        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5709            |bytes, handles| {
5710                match this.inner.channel().read_etc(cx, bytes, handles) {
5711                    std::task::Poll::Ready(Ok(())) => {}
5712                    std::task::Poll::Pending => return std::task::Poll::Pending,
5713                    std::task::Poll::Ready(Err(None)) => {
5714                        this.is_terminated = true;
5715                        return std::task::Poll::Ready(None);
5716                    }
5717                    std::task::Poll::Ready(Err(Some(e))) => {
5718                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5719                            e.into(),
5720                        ))));
5721                    }
5722                }
5723
5724                // A message has been received from the channel
5725                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5726
5727                std::task::Poll::Ready(Some(match header.ordinal {
5728                0x4577e238ae26291 => {
5729                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5730                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5731                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5732                    let control_handle = BufferCollectionTokenGroupControlHandle {
5733                        inner: this.inner.clone(),
5734                    };
5735                    Ok(BufferCollectionTokenGroupRequest::Sync {
5736                        responder: BufferCollectionTokenGroupSyncResponder {
5737                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5738                            tx_id: header.tx_id,
5739                        },
5740                    })
5741                }
5742                0x5b1d7a4f5681fca7 => {
5743                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5744                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5745                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5746                    let control_handle = BufferCollectionTokenGroupControlHandle {
5747                        inner: this.inner.clone(),
5748                    };
5749                    Ok(BufferCollectionTokenGroupRequest::Close {
5750                        control_handle,
5751                    })
5752                }
5753                0x77a41bb6217e2443 => {
5754                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5755                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
5756                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5757                    let control_handle = BufferCollectionTokenGroupControlHandle {
5758                        inner: this.inner.clone(),
5759                    };
5760                    Ok(BufferCollectionTokenGroupRequest::SetName {priority: req.priority,
5761name: req.name,
5762
5763                        control_handle,
5764                    })
5765                }
5766                0x7275759070eb5ee2 => {
5767                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5768                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
5769                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5770                    let control_handle = BufferCollectionTokenGroupControlHandle {
5771                        inner: this.inner.clone(),
5772                    };
5773                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {name: req.name,
5774id: req.id,
5775
5776                        control_handle,
5777                    })
5778                }
5779                0x46d38f4772638867 => {
5780                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5781                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
5782                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5783                    let control_handle = BufferCollectionTokenGroupControlHandle {
5784                        inner: this.inner.clone(),
5785                    };
5786                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
5787
5788                        control_handle,
5789                    })
5790                }
5791                0x6bfbe2cf1701d288 => {
5792                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5793                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5794                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5795                    let control_handle = BufferCollectionTokenGroupControlHandle {
5796                        inner: this.inner.clone(),
5797                    };
5798                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
5799                        control_handle,
5800                    })
5801                }
5802                0x467b7c75c35c3b84 => {
5803                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5804                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5805                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5806                    let control_handle = BufferCollectionTokenGroupControlHandle {
5807                        inner: this.inner.clone(),
5808                    };
5809                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
5810                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
5811                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5812                            tx_id: header.tx_id,
5813                        },
5814                    })
5815                }
5816                0x33a2a7aff2776c07 => {
5817                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5818                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
5819                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5820                    let control_handle = BufferCollectionTokenGroupControlHandle {
5821                        inner: this.inner.clone(),
5822                    };
5823                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {node_ref: req.node_ref,
5824
5825                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
5826                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5827                            tx_id: header.tx_id,
5828                        },
5829                    })
5830                }
5831                0x2e74f8bcbf59ee59 => {
5832                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5833                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fdomain_client::fidl::FDomainResourceDialect);
5834                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
5835                    let control_handle = BufferCollectionTokenGroupControlHandle {
5836                        inner: this.inner.clone(),
5837                    };
5838                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
5839                        control_handle,
5840                    })
5841                }
5842                0x569dc3ca2a98f535 => {
5843                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5844                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
5845                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5846                    let control_handle = BufferCollectionTokenGroupControlHandle {
5847                        inner: this.inner.clone(),
5848                    };
5849                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {rights_attenuation_masks: req.rights_attenuation_masks,
5850
5851                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
5852                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5853                            tx_id: header.tx_id,
5854                        },
5855                    })
5856                }
5857                0x1d41715f6f044b50 => {
5858                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5859                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5860                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5861                    let control_handle = BufferCollectionTokenGroupControlHandle {
5862                        inner: this.inner.clone(),
5863                    };
5864                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
5865                        control_handle,
5866                    })
5867                }
5868                _ => Err(fidl::Error::UnknownOrdinal {
5869                    ordinal: header.ordinal,
5870                    protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5871                }),
5872            }))
5873            },
5874        )
5875    }
5876}
5877
5878/// The sysmem implementation is guaranteed to be consistent with a logical /
5879/// conceptual model as follows:
5880///
5881/// As usual, a logical allocation considers either the root and all nodes with
5882/// connectivity to the root that don't transit an AttachToken(), or a sub-tree
5883/// rooted at an AttachToken() token and all nodes with connectivity to that
5884/// subtree that don't transit another AttachToken().  This is called the
5885/// logical allocation pruned sub-tree, or pruned sub-tree for short.
5886///
5887/// During constraints aggregation, each BufferCollectionTokenGroup will select
5888/// a single child token among its children.  The rest of the children will
5889/// appear to fail the logical allocation, while the selected child may succeed.
5890///
5891/// When more than one BufferCollectionTokenGroup exists in the overall logical
5892/// allocation pruned sub-tree, the relative priority between two groups is
5893/// equivalent to their ordering in a DFS pre-order iteration of the tree, with
5894/// parents higher priority than children, and left children higher priority
5895/// than right children.
5896///
5897/// When a particular child of a group is selected (whether provisionally during
5898/// a constraints aggregation attempt, or as a final selection), the
5899/// non-selection of other children of the group can potentially "hide" other
5900/// groups under those non-selected children.
5901///
5902/// Within a logical allocation, aggregation is attempted first by provisionally
5903/// selecting the child 0 of the highest-priority group, and child 0 of the next
5904/// highest-priority group that isn't hidden by the provisional selections so
5905/// far, etc.
5906///
5907/// If that aggregation attempt fails, aggregation will be attempted with the
5908/// ordinal 0 child of all the same groups except the lowest priority non-hidden
5909/// group which will provisionally select its ordinal 1 child (and then child 2
5910/// and so on).  If a new lowest-priority group is un-hidden as provisional
5911/// selections are updated, that newly un-hidden lowest-priority group has all
5912/// its children considered in order, before changing the provisional selection
5913/// in the former lowest-priority group.  In terms of result, this is equivalent
5914/// to systematic enumeration of all possible combinations of choices in a
5915/// counting-like order updating the lowest-priority group the most often and
5916/// the highest-priority group the least often.  Rather than actually attempting
5917/// aggregation with all the combinations, we can skip over combinations which
5918/// are redundant/equivalent due to hiding without any change to the result.
5919///
5920/// Attempted aggregations of enumerated non-equivalent combinations of choices
5921/// continue in this manner until either (a) all aggregation attempts fail in
5922/// which case the overall logical allocation fails, or (b) until an attempted
5923/// aggregation succeeds, in which case buffer allocation (if needed) is
5924/// attempted once.  If buffer allocation based on the first successful
5925/// aggregation fails, the overall logical allocation fails (there is no buffer
5926/// allocation retry / re-attempt).  If buffer allocation succeeds (or is not
5927/// needed), the logical allocation succeeds.
5928///
5929/// If this prioritization scheme cannot reasonably work for your usage of
5930/// sysmem, please contact sysmem folks to discuss potentially adding a way to
5931/// achieve what you need.
5932///
5933/// Please avoid creating a large number of BufferCollectionTokenGroup(s) per
5934/// logical allocation, especially with large number of children overall, and
5935/// especially in cases where aggregation may reasonably be expected to often
5936/// fail using ordinal 0 children and possibly with later children as well.  We
5937/// anticipate mitigating potentially high time complexity of evaluating too
5938/// many child combinations/selections across too many groups by simply failing
5939/// logical allocation beyond a certain (fairly high, but not huge) max number
5940/// of considered group child combinations/selections.  More advanced (and more
5941/// complicated) mitigation is not anticipated to be practically necessary or
5942/// worth the added complexity.  Please contact sysmem folks if the max limit
5943/// is getting hit or if you anticipate it getting hit, to discuss potential
5944/// options.
5945///
5946/// Prefer to use multiple ImageFormatConstraints in a single
5947/// BufferCollectionConstraints when feasible (when a participant just needs to
5948/// express the ability to work with more than a single PixelFormat, with
5949/// sysmem choosing which PixelFormat to use among those supported by all
5950/// participants).
5951///
5952/// Similar to BufferCollectionToken and BufferCollection, closure of the
5953/// BufferCollectionTokenGroup channel without sending Close() first will cause
5954/// logical buffer collection failure (or sub-tree failure if using
5955/// SetDispensable() or AttachToken() and the BufferCollectionTokenGroup is part
5956/// of a sub-tree under such a node that doesn't propagate failure to its
5957/// parent).
5958#[derive(Debug)]
5959pub enum BufferCollectionTokenGroupRequest {
5960    /// Ensure that previous messages, including Duplicate() messages on a
5961    /// token, collection, or group, have been received server side.
5962    ///
5963    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5964    /// valid sysmem token risks the Sync() hanging forever.  See
5965    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5966    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5967    /// Another way is to pass the token to BindSharedCollection(), which also
5968    /// validates the token as part of exchanging it for a BufferCollection
5969    /// channel, and BufferCollection Sync() can then be used.
5970    ///
5971    /// After a Sync(), it's then safe to send the client end of token_request
5972    /// to another participant knowing the server will recognize the token when
5973    /// it's sent into BindSharedCollection() by the other participant.
5974    ///
5975    /// Other options include waiting for each token.Duplicate() to complete
5976    /// individually (using separate call to token.Sync() after each), or
5977    /// calling Sync() on BufferCollection after the token has been turned in
5978    /// via BindSharedCollection().
5979    ///
5980    /// Another way to mitigate is to avoid calling Sync() on the token, and
5981    /// instead later deal with potential failure of BufferCollection.Sync() if
5982    /// the original token was invalid.  This option can be preferable from a
5983    /// performance point of view, but requires client code to delay sending
5984    /// tokens duplicated from this token until after client code has converted
5985    /// the duplicating token to a BufferCollection and received successful
5986    /// response from BufferCollection.Sync().
5987    ///
5988    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5989    /// When BufferCollection.Sync() isn't feasible, the caller must already
5990    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5991    /// hang forever.  See ValidateBufferCollectionToken() to check token
5992    /// validity first if the token isn't already known to be (is/was) valid.
5993    Sync { responder: BufferCollectionTokenGroupSyncResponder },
5994    /// On a BufferCollectionToken channel:
5995    ///
5996    /// Normally a participant will convert a BufferCollectionToken into a
5997    /// BufferCollection view, but a participant is also free to Close() the
5998    /// token (and then close the channel immediately or shortly later in
5999    /// response to server closing its end), which avoids causing logical buffer
6000    /// collection failure.  Normally an unexpected token channel close will
6001    /// cause logical buffer collection failure (the only exceptions being
6002    /// certain cases involving AttachToken() or SetDispensable()).
6003    ///
6004    /// On a BufferCollection channel:
6005    ///
6006    /// By default the server handles unexpected failure of a BufferCollection
6007    /// by failing the whole logical buffer collection.  Partly this is to
6008    /// expedite closing VMO handles to reclaim memory when any participant
6009    /// fails.  If a participant would like to cleanly close a BufferCollection
6010    /// view without causing logical buffer collection failure, the participant
6011    /// can send Close() before closing the client end of the BufferCollection
6012    /// channel.  If this is the last BufferCollection view, the logical buffer
6013    /// collection will still go away.  The Close() can occur before or after
6014    /// SetConstraints().  If before SetConstraints(), the buffer collection
6015    /// won't require constraints from this node in order to allocate.  If
6016    /// after SetConstraints(), the constraints are retained and aggregated
6017    /// along with any subsequent logical allocation(s), despite the lack of
6018    /// channel connection.
6019    ///
6020    /// On a BufferCollectionTokenGroup channel:
6021    ///
6022    /// By default, unexpected failure of a BufferCollectionTokenGroup will
6023    /// trigger failure of the logical BufferCollectionTokenGroup and will
6024    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
6025    /// channel without failing the logical group or propagating failure, send
6026    /// Close() before closing the channel client endpoint.
6027    ///
6028    /// If Close() occurs before AllChildrenPresent(), the logical buffer
6029    /// collection will still fail despite the Close() (because sysmem can't be
6030    /// sure whether all relevant children were created, so it's ambiguous
6031    /// whether all relevant constraints will be provided to sysmem).  If
6032    /// Close() occurs after AllChildrenPresent(), the children and all their
6033    /// constraints remain intact (just as they would if the
6034    /// BufferCollectionTokenGroup channel had remained open), and the close
6035    /// doesn't trigger or propagate failure.
6036    Close { control_handle: BufferCollectionTokenGroupControlHandle },
6037    /// Set a name for VMOs in this buffer collection. The name may be truncated
6038    /// shorter. The name only affects VMOs allocated after it's set - this call
6039    /// does not rename existing VMOs. If multiple clients set different names
6040    /// then the larger priority value will win.
6041    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenGroupControlHandle },
6042    /// Set information about the current client that can be used by sysmem to
6043    /// help debug leaking memory and hangs waiting for constraints. |name| can
6044    /// be an arbitrary string, but the current process name (see
6045    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6046    /// arbitrary id, but the current process ID (see
6047    /// fsl::GetCurrentProcessKoid()) is a good default.
6048    ///
6049    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6050    /// indicate which client is closing their channel first, leading to
6051    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6052    /// over, but if happening earlier than expected, the
6053    /// client-channel-specific name can help diagnose where the failure is
6054    /// first coming from, from sysmem's point of view).
6055    ///
6056    /// By default (unless overriden by this message or using
6057    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6058    /// parent Node at the time the child Node is created.  While this can be
6059    /// better than nothing, it's often better for each participant to use
6060    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6061    /// info directly relevant to the current client.  Also, SetVerboseLogging()
6062    /// can be used to help disambiguate if a Node is suspected of having info
6063    /// that was copied from its parent.
6064    SetDebugClientInfo {
6065        name: String,
6066        id: u64,
6067        control_handle: BufferCollectionTokenGroupControlHandle,
6068    },
6069    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6070    /// after creating a collection. Clients can call this method to change
6071    /// when the log is printed. If multiple client set the deadline, it's
6072    /// unspecified which deadline will take effect.
6073    SetDebugTimeoutLogDeadline {
6074        deadline: i64,
6075        control_handle: BufferCollectionTokenGroupControlHandle,
6076    },
6077    /// Verbose logging includes constraints set via SetConstraints() from each
6078    /// client along with info set via SetDebugClientInfo() and the structure of
6079    /// the tree of Node(s).
6080    ///
6081    /// Normally sysmem prints only a single line complaint when aggregation
6082    /// fails, with just the specific detailed reason that aggregation failed,
6083    /// with minimal context.  While this is often enough to diagnose a problem
6084    /// if only a small change was made and the system had been working before
6085    /// the small change, it's often not particularly helpful for getting a new
6086    /// buffer collection to work for the first time.  Especially with more
6087    /// complex trees of nodes, involving things like AttachToken(),
6088    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6089    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6090    /// looks like and why it's failing a logical allocation, or why a tree or
6091    /// sub-tree is failing sooner than expected.
6092    ///
6093    /// The intent of the extra logging is to be acceptable from a performance
6094    /// point of view, if only enabled on a low number of buffer collections.
6095    /// If we're not tracking down a bug, we shouldn't send this message.
6096    ///
6097    /// If too many participants leave verbose logging enabled, we may end up
6098    /// needing to require that system-wide sysmem verbose logging be permitted
6099    /// via some other setting, to avoid sysmem spamming the log too much due to
6100    /// this message.
6101    ///
6102    /// This may be a NOP for some nodes due to intentional policy associated
6103    /// with the node, if we don't trust a node enough to let it turn on verbose
6104    /// logging.
6105    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
6106    /// This gets an event handle that can be used as a parameter to
6107    /// IsAlternateFor() called on any Node.  The client will not be granted the
6108    /// right to signal this event, as this handle should only be used as proof
6109    /// that the client obtained this handle from this Node.
6110    ///
6111    /// Because this is a get not a set, no Sync() is needed between the
6112    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6113    /// potentially being on different channels.
6114    ///
6115    /// See also IsAlternateFor().
6116    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
6117    /// This checks whether the calling node is in a subtree rooted at a
6118    /// different child token of a common parent BufferCollectionTokenGroup, in
6119    /// relation to the passed-in node_ref.
6120    ///
6121    /// This call is for assisting with admission control de-duplication, and
6122    /// with debugging.
6123    ///
6124    /// The node_ref must be obtained using GetNodeRef() of a
6125    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6126    ///
6127    /// The node_ref can be a duplicated handle; it's not necessary to call
6128    /// GetNodeRef() for every call to IsAlternateFor().
6129    ///
6130    /// If a calling token may not actually be a valid token at all due to
6131    /// a potentially hostile/untrusted provider of the token, call
6132    /// ValidateBufferCollectionToken() first instead of potentially getting
6133    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6134    /// token not being a real token (not really talking to sysmem).  Another
6135    /// option is to call BindSharedCollection with this token first which also
6136    /// validates the token along with converting it to a BufferCollection, then
6137    /// call BufferCollection IsAlternateFor().
6138    ///
6139    /// error values:
6140    ///
6141    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6142    /// buffer collection as the calling Node.  Before logical allocation and
6143    /// within the same logical allocation sub-tree, this essentially means that
6144    /// the node_ref was never part of this logical buffer collection, since
6145    /// before logical allocation all node_refs that come into existence remain
6146    /// in existence at least until logical allocation (including Node(s) that
6147    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6148    /// to be returned, this Node's channel needs to still be connected server
6149    /// side, which won't be the case if the whole logical allocation has
6150    /// failed.  After logical allocation or in a different logical allocation
6151    /// sub-tree there are additional potential reasons for this error.  For
6152    /// example a different logical allocation (separated from this Node(s)
6153    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6154    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6155    /// exist and may select a different child sub-tree than the sub-tree the
6156    /// node_ref is in causing deletion of the node_ref Node.  The only time
6157    /// sysmem keeps a Node around after that Node has no corresponding channel
6158    /// is when Close() is used and the Node's sub-tree has not yet failed.
6159    /// Another reason for this error is if the node_ref is an eventpair handle
6160    /// with sufficient rights, but isn't actually a real node_ref obtained from
6161    /// GetNodeRef().
6162    ///
6163    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6164    /// eventpair handle, or doesn't have the needed rights expected on a real
6165    /// node_ref.
6166    ///
6167    /// No other failing status codes are returned by this call.  However,
6168    /// sysmem may add additional codes in future, so the client should have
6169    /// sensible default handling for any failing status code.
6170    ///
6171    /// On success, is_alternate has the following meaning:
6172    ///   * true - The first parent node in common between the calling node and
6173    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
6174    ///     the calling Node and the node_ref Node will _not_ have both their
6175    ///     constraints apply - rather sysmem will choose one or the other of
6176    ///     the constraints - never both.  This is because only one child of
6177    ///     a BufferCollectionTokenGroup is selected during logical allocation,
6178    ///     with only that one child's sub-tree contributing to constraints
6179    ///     aggregation.
6180    ///   * false - The first parent node in common between the calling Node and
6181    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
6182    ///     this means the first parent node in common is a
6183    ///     BufferCollectionToken or BufferCollection (regardless of not
6184    ///     Close()ed or Close()ed).  This means that the calling Node and the
6185    ///     node_ref Node _may_ have both their constraints apply during
6186    ///     constraints aggregation of the logical allocation, if both Node(s)
6187    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
6188    ///     In this case, there is no BufferCollectionTokenGroup that will
6189    ///     directly prevent the two Node(s) from both being selected and their
6190    ///     constraints both aggregated, but even when false, one or both
6191    ///     Node(s) may still be eliminated from consideration if one or both
6192    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6193    ///     which selects a child sub-tree other than the sub-tree containing
6194    ///     the calling Node or node_ref Node.
6195    IsAlternateFor {
6196        node_ref: fdomain_client::Event,
6197        responder: BufferCollectionTokenGroupIsAlternateForResponder,
6198    },
6199    /// Create a child token.  Before passing the client end of this token to
6200    /// BindSharedCollection(), completion of Sync() after CreateChild() is
6201    /// required.  Or the client can use CreateChildrenSync() which essentially
6202    /// includes the Sync().
6203    ///
6204    /// token_request - the server end of the new token channel.
6205    ///
6206    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
6207    /// allows the holder to get the same rights to buffers as the parent token
6208    /// (of the group) had.
6209    CreateChild {
6210        payload: BufferCollectionTokenGroupCreateChildRequest,
6211        control_handle: BufferCollectionTokenGroupControlHandle,
6212    },
6213    /// Create 1 or more child tokens at once, synchronously.  In contrast to
6214    /// CreateChild(), no Sync() completion is required before passing the
6215    /// client end of a returned token to BindSharedCollection().
6216    ///
6217    /// The size of the rights_attentuation_mask determines the number of
6218    /// created child tokens.
6219    ///
6220    /// The lower-index child tokens are higher priority (attempted sooner) than
6221    /// higher-index child tokens.
6222    ///
6223    /// As per all child tokens, successful aggregation will choose exactly one
6224    /// child among all created children (across all children created across
6225    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
6226    ///
6227    /// The maximum permissible total number of children per group, and total
6228    /// number of nodes in an overall tree (from the root) are capped to limits
6229    /// which are not configurable via these protocols.
6230    CreateChildrenSync {
6231        rights_attenuation_masks: Vec<fidl::Rights>,
6232        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
6233    },
6234    /// AllChildrenPresent()
6235    ///
6236    /// After creating all children, the client must call AllChildrenPresent()
6237    /// to inform sysmem that no more children will be created, so that sysmem
6238    /// can know when it's ok to start aggregating constraints.
6239    ///
6240    /// If Close() is to be sent, it should be sent _after_
6241    /// AllChildrenPresent(), else failure of the group and propagation of the
6242    /// failure to the group's parent will still be triggered.
6243    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
6244}
6245
6246impl BufferCollectionTokenGroupRequest {
6247    #[allow(irrefutable_let_patterns)]
6248    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
6249        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
6250            Some((responder))
6251        } else {
6252            None
6253        }
6254    }
6255
6256    #[allow(irrefutable_let_patterns)]
6257    pub fn into_close(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6258        if let BufferCollectionTokenGroupRequest::Close { control_handle } = self {
6259            Some((control_handle))
6260        } else {
6261            None
6262        }
6263    }
6264
6265    #[allow(irrefutable_let_patterns)]
6266    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenGroupControlHandle)> {
6267        if let BufferCollectionTokenGroupRequest::SetName { priority, name, control_handle } = self
6268        {
6269            Some((priority, name, control_handle))
6270        } else {
6271            None
6272        }
6273    }
6274
6275    #[allow(irrefutable_let_patterns)]
6276    pub fn into_set_debug_client_info(
6277        self,
6278    ) -> Option<(String, u64, BufferCollectionTokenGroupControlHandle)> {
6279        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { name, id, control_handle } =
6280            self
6281        {
6282            Some((name, id, control_handle))
6283        } else {
6284            None
6285        }
6286    }
6287
6288    #[allow(irrefutable_let_patterns)]
6289    pub fn into_set_debug_timeout_log_deadline(
6290        self,
6291    ) -> Option<(i64, BufferCollectionTokenGroupControlHandle)> {
6292        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
6293            deadline,
6294            control_handle,
6295        } = self
6296        {
6297            Some((deadline, control_handle))
6298        } else {
6299            None
6300        }
6301    }
6302
6303    #[allow(irrefutable_let_patterns)]
6304    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6305        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
6306            Some((control_handle))
6307        } else {
6308            None
6309        }
6310    }
6311
6312    #[allow(irrefutable_let_patterns)]
6313    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
6314        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
6315            Some((responder))
6316        } else {
6317            None
6318        }
6319    }
6320
6321    #[allow(irrefutable_let_patterns)]
6322    pub fn into_is_alternate_for(
6323        self,
6324    ) -> Option<(fdomain_client::Event, BufferCollectionTokenGroupIsAlternateForResponder)> {
6325        if let BufferCollectionTokenGroupRequest::IsAlternateFor { node_ref, responder } = self {
6326            Some((node_ref, responder))
6327        } else {
6328            None
6329        }
6330    }
6331
6332    #[allow(irrefutable_let_patterns)]
6333    pub fn into_create_child(
6334        self,
6335    ) -> Option<(
6336        BufferCollectionTokenGroupCreateChildRequest,
6337        BufferCollectionTokenGroupControlHandle,
6338    )> {
6339        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
6340            Some((payload, control_handle))
6341        } else {
6342            None
6343        }
6344    }
6345
6346    #[allow(irrefutable_let_patterns)]
6347    pub fn into_create_children_sync(
6348        self,
6349    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenGroupCreateChildrenSyncResponder)> {
6350        if let BufferCollectionTokenGroupRequest::CreateChildrenSync {
6351            rights_attenuation_masks,
6352            responder,
6353        } = self
6354        {
6355            Some((rights_attenuation_masks, responder))
6356        } else {
6357            None
6358        }
6359    }
6360
6361    #[allow(irrefutable_let_patterns)]
6362    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6363        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
6364            Some((control_handle))
6365        } else {
6366            None
6367        }
6368    }
6369
6370    /// Name of the method defined in FIDL
6371    pub fn method_name(&self) -> &'static str {
6372        match *self {
6373            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
6374            BufferCollectionTokenGroupRequest::Close { .. } => "close",
6375            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
6376            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6377            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
6378                "set_debug_timeout_log_deadline"
6379            }
6380            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6381            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
6382            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
6383            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
6384            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
6385            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
6386        }
6387    }
6388}
6389
6390#[derive(Debug, Clone)]
6391pub struct BufferCollectionTokenGroupControlHandle {
6392    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6393}
6394
6395impl BufferCollectionTokenGroupControlHandle {
6396    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6397        self.inner.shutdown_with_epitaph(status.into())
6398    }
6399}
6400
6401impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenGroupControlHandle {
6402    fn shutdown(&self) {
6403        self.inner.shutdown()
6404    }
6405
6406    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6407        self.inner.shutdown_with_epitaph(status)
6408    }
6409
6410    fn is_closed(&self) -> bool {
6411        self.inner.channel().is_closed()
6412    }
6413    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6414        self.inner.channel().on_closed()
6415    }
6416}
6417
6418impl BufferCollectionTokenGroupControlHandle {}
6419
6420#[must_use = "FIDL methods require a response to be sent"]
6421#[derive(Debug)]
6422pub struct BufferCollectionTokenGroupSyncResponder {
6423    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6424    tx_id: u32,
6425}
6426
6427/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6428/// if the responder is dropped without sending a response, so that the client
6429/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6430impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
6431    fn drop(&mut self) {
6432        self.control_handle.shutdown();
6433        // Safety: drops once, never accessed again
6434        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6435    }
6436}
6437
6438impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupSyncResponder {
6439    type ControlHandle = BufferCollectionTokenGroupControlHandle;
6440
6441    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6442        &self.control_handle
6443    }
6444
6445    fn drop_without_shutdown(mut self) {
6446        // Safety: drops once, never accessed again due to mem::forget
6447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6448        // Prevent Drop from running (which would shut down the channel)
6449        std::mem::forget(self);
6450    }
6451}
6452
6453impl BufferCollectionTokenGroupSyncResponder {
6454    /// Sends a response to the FIDL transaction.
6455    ///
6456    /// Sets the channel to shutdown if an error occurs.
6457    pub fn send(self) -> Result<(), fidl::Error> {
6458        let _result = self.send_raw();
6459        if _result.is_err() {
6460            self.control_handle.shutdown();
6461        }
6462        self.drop_without_shutdown();
6463        _result
6464    }
6465
6466    /// Similar to "send" but does not shutdown the channel if an error occurs.
6467    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6468        let _result = self.send_raw();
6469        self.drop_without_shutdown();
6470        _result
6471    }
6472
6473    fn send_raw(&self) -> Result<(), fidl::Error> {
6474        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6475            (),
6476            self.tx_id,
6477            0x4577e238ae26291,
6478            fidl::encoding::DynamicFlags::empty(),
6479        )
6480    }
6481}
6482
6483#[must_use = "FIDL methods require a response to be sent"]
6484#[derive(Debug)]
6485pub struct BufferCollectionTokenGroupGetNodeRefResponder {
6486    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6487    tx_id: u32,
6488}
6489
6490/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6491/// if the responder is dropped without sending a response, so that the client
6492/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6493impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
6494    fn drop(&mut self) {
6495        self.control_handle.shutdown();
6496        // Safety: drops once, never accessed again
6497        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6498    }
6499}
6500
6501impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
6502    type ControlHandle = BufferCollectionTokenGroupControlHandle;
6503
6504    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6505        &self.control_handle
6506    }
6507
6508    fn drop_without_shutdown(mut self) {
6509        // Safety: drops once, never accessed again due to mem::forget
6510        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6511        // Prevent Drop from running (which would shut down the channel)
6512        std::mem::forget(self);
6513    }
6514}
6515
6516impl BufferCollectionTokenGroupGetNodeRefResponder {
6517    /// Sends a response to the FIDL transaction.
6518    ///
6519    /// Sets the channel to shutdown if an error occurs.
6520    pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
6521        let _result = self.send_raw(node_ref);
6522        if _result.is_err() {
6523            self.control_handle.shutdown();
6524        }
6525        self.drop_without_shutdown();
6526        _result
6527    }
6528
6529    /// Similar to "send" but does not shutdown the channel if an error occurs.
6530    pub fn send_no_shutdown_on_err(
6531        self,
6532        mut node_ref: fdomain_client::Event,
6533    ) -> Result<(), fidl::Error> {
6534        let _result = self.send_raw(node_ref);
6535        self.drop_without_shutdown();
6536        _result
6537    }
6538
6539    fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
6540        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
6541            (node_ref,),
6542            self.tx_id,
6543            0x467b7c75c35c3b84,
6544            fidl::encoding::DynamicFlags::empty(),
6545        )
6546    }
6547}
6548
6549#[must_use = "FIDL methods require a response to be sent"]
6550#[derive(Debug)]
6551pub struct BufferCollectionTokenGroupIsAlternateForResponder {
6552    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6553    tx_id: u32,
6554}
6555
6556/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6557/// if the responder is dropped without sending a response, so that the client
6558/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6559impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
6560    fn drop(&mut self) {
6561        self.control_handle.shutdown();
6562        // Safety: drops once, never accessed again
6563        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6564    }
6565}
6566
6567impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
6568    type ControlHandle = BufferCollectionTokenGroupControlHandle;
6569
6570    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6571        &self.control_handle
6572    }
6573
6574    fn drop_without_shutdown(mut self) {
6575        // Safety: drops once, never accessed again due to mem::forget
6576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6577        // Prevent Drop from running (which would shut down the channel)
6578        std::mem::forget(self);
6579    }
6580}
6581
6582impl BufferCollectionTokenGroupIsAlternateForResponder {
6583    /// Sends a response to the FIDL transaction.
6584    ///
6585    /// Sets the channel to shutdown if an error occurs.
6586    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6587        let _result = self.send_raw(result);
6588        if _result.is_err() {
6589            self.control_handle.shutdown();
6590        }
6591        self.drop_without_shutdown();
6592        _result
6593    }
6594
6595    /// Similar to "send" but does not shutdown the channel if an error occurs.
6596    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6597        let _result = self.send_raw(result);
6598        self.drop_without_shutdown();
6599        _result
6600    }
6601
6602    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6603        self.control_handle
6604            .inner
6605            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
6606                result.map(|is_alternate| (is_alternate,)),
6607                self.tx_id,
6608                0x33a2a7aff2776c07,
6609                fidl::encoding::DynamicFlags::empty(),
6610            )
6611    }
6612}
6613
6614#[must_use = "FIDL methods require a response to be sent"]
6615#[derive(Debug)]
6616pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
6617    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6618    tx_id: u32,
6619}
6620
6621/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6622/// if the responder is dropped without sending a response, so that the client
6623/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6624impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
6625    fn drop(&mut self) {
6626        self.control_handle.shutdown();
6627        // Safety: drops once, never accessed again
6628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6629    }
6630}
6631
6632impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
6633    type ControlHandle = BufferCollectionTokenGroupControlHandle;
6634
6635    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6636        &self.control_handle
6637    }
6638
6639    fn drop_without_shutdown(mut self) {
6640        // Safety: drops once, never accessed again due to mem::forget
6641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6642        // Prevent Drop from running (which would shut down the channel)
6643        std::mem::forget(self);
6644    }
6645}
6646
6647impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
6648    /// Sends a response to the FIDL transaction.
6649    ///
6650    /// Sets the channel to shutdown if an error occurs.
6651    pub fn send(
6652        self,
6653        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6654    ) -> Result<(), fidl::Error> {
6655        let _result = self.send_raw(tokens);
6656        if _result.is_err() {
6657            self.control_handle.shutdown();
6658        }
6659        self.drop_without_shutdown();
6660        _result
6661    }
6662
6663    /// Similar to "send" but does not shutdown the channel if an error occurs.
6664    pub fn send_no_shutdown_on_err(
6665        self,
6666        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6667    ) -> Result<(), fidl::Error> {
6668        let _result = self.send_raw(tokens);
6669        self.drop_without_shutdown();
6670        _result
6671    }
6672
6673    fn send_raw(
6674        &self,
6675        mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6676    ) -> Result<(), fidl::Error> {
6677        self.control_handle.inner.send::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(
6678            (tokens.as_mut(),),
6679            self.tx_id,
6680            0x569dc3ca2a98f535,
6681            fidl::encoding::DynamicFlags::empty(),
6682        )
6683    }
6684}
6685
6686#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6687pub struct NodeMarker;
6688
6689impl fdomain_client::fidl::ProtocolMarker for NodeMarker {
6690    type Proxy = NodeProxy;
6691    type RequestStream = NodeRequestStream;
6692
6693    const DEBUG_NAME: &'static str = "(anonymous) Node";
6694}
6695pub type NodeIsAlternateForResult = Result<bool, i32>;
6696
6697pub trait NodeProxyInterface: Send + Sync {
6698    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6699    fn r#sync(&self) -> Self::SyncResponseFut;
6700    fn r#close(&self) -> Result<(), fidl::Error>;
6701    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
6702    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
6703    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
6704    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
6705    type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
6706        + Send;
6707    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
6708    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
6709        + Send;
6710    fn r#is_alternate_for(
6711        &self,
6712        node_ref: fdomain_client::Event,
6713    ) -> Self::IsAlternateForResponseFut;
6714}
6715
6716#[derive(Debug, Clone)]
6717pub struct NodeProxy {
6718    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6719}
6720
6721impl fdomain_client::fidl::Proxy for NodeProxy {
6722    type Protocol = NodeMarker;
6723
6724    fn from_channel(inner: fdomain_client::Channel) -> Self {
6725        Self::new(inner)
6726    }
6727
6728    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6729        self.client.into_channel().map_err(|client| Self { client })
6730    }
6731
6732    fn as_channel(&self) -> &fdomain_client::Channel {
6733        self.client.as_channel()
6734    }
6735}
6736
6737impl NodeProxy {
6738    /// Create a new Proxy for fuchsia.sysmem/Node.
6739    pub fn new(channel: fdomain_client::Channel) -> Self {
6740        let protocol_name = <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6741        Self { client: fidl::client::Client::new(channel, protocol_name) }
6742    }
6743
6744    /// Get a Stream of events from the remote end of the protocol.
6745    ///
6746    /// # Panics
6747    ///
6748    /// Panics if the event stream was already taken.
6749    pub fn take_event_stream(&self) -> NodeEventStream {
6750        NodeEventStream { event_receiver: self.client.take_event_receiver() }
6751    }
6752
6753    /// Ensure that previous messages, including Duplicate() messages on a
6754    /// token, collection, or group, have been received server side.
6755    ///
6756    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
6757    /// valid sysmem token risks the Sync() hanging forever.  See
6758    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
6759    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
6760    /// Another way is to pass the token to BindSharedCollection(), which also
6761    /// validates the token as part of exchanging it for a BufferCollection
6762    /// channel, and BufferCollection Sync() can then be used.
6763    ///
6764    /// After a Sync(), it's then safe to send the client end of token_request
6765    /// to another participant knowing the server will recognize the token when
6766    /// it's sent into BindSharedCollection() by the other participant.
6767    ///
6768    /// Other options include waiting for each token.Duplicate() to complete
6769    /// individually (using separate call to token.Sync() after each), or
6770    /// calling Sync() on BufferCollection after the token has been turned in
6771    /// via BindSharedCollection().
6772    ///
6773    /// Another way to mitigate is to avoid calling Sync() on the token, and
6774    /// instead later deal with potential failure of BufferCollection.Sync() if
6775    /// the original token was invalid.  This option can be preferable from a
6776    /// performance point of view, but requires client code to delay sending
6777    /// tokens duplicated from this token until after client code has converted
6778    /// the duplicating token to a BufferCollection and received successful
6779    /// response from BufferCollection.Sync().
6780    ///
6781    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
6782    /// When BufferCollection.Sync() isn't feasible, the caller must already
6783    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
6784    /// hang forever.  See ValidateBufferCollectionToken() to check token
6785    /// validity first if the token isn't already known to be (is/was) valid.
6786    pub fn r#sync(
6787        &self,
6788    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6789        NodeProxyInterface::r#sync(self)
6790    }
6791
6792    /// On a BufferCollectionToken channel:
6793    ///
6794    /// Normally a participant will convert a BufferCollectionToken into a
6795    /// BufferCollection view, but a participant is also free to Close() the
6796    /// token (and then close the channel immediately or shortly later in
6797    /// response to server closing its end), which avoids causing logical buffer
6798    /// collection failure.  Normally an unexpected token channel close will
6799    /// cause logical buffer collection failure (the only exceptions being
6800    /// certain cases involving AttachToken() or SetDispensable()).
6801    ///
6802    /// On a BufferCollection channel:
6803    ///
6804    /// By default the server handles unexpected failure of a BufferCollection
6805    /// by failing the whole logical buffer collection.  Partly this is to
6806    /// expedite closing VMO handles to reclaim memory when any participant
6807    /// fails.  If a participant would like to cleanly close a BufferCollection
6808    /// view without causing logical buffer collection failure, the participant
6809    /// can send Close() before closing the client end of the BufferCollection
6810    /// channel.  If this is the last BufferCollection view, the logical buffer
6811    /// collection will still go away.  The Close() can occur before or after
6812    /// SetConstraints().  If before SetConstraints(), the buffer collection
6813    /// won't require constraints from this node in order to allocate.  If
6814    /// after SetConstraints(), the constraints are retained and aggregated
6815    /// along with any subsequent logical allocation(s), despite the lack of
6816    /// channel connection.
6817    ///
6818    /// On a BufferCollectionTokenGroup channel:
6819    ///
6820    /// By default, unexpected failure of a BufferCollectionTokenGroup will
6821    /// trigger failure of the logical BufferCollectionTokenGroup and will
6822    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
6823    /// channel without failing the logical group or propagating failure, send
6824    /// Close() before closing the channel client endpoint.
6825    ///
6826    /// If Close() occurs before AllChildrenPresent(), the logical buffer
6827    /// collection will still fail despite the Close() (because sysmem can't be
6828    /// sure whether all relevant children were created, so it's ambiguous
6829    /// whether all relevant constraints will be provided to sysmem).  If
6830    /// Close() occurs after AllChildrenPresent(), the children and all their
6831    /// constraints remain intact (just as they would if the
6832    /// BufferCollectionTokenGroup channel had remained open), and the close
6833    /// doesn't trigger or propagate failure.
6834    pub fn r#close(&self) -> Result<(), fidl::Error> {
6835        NodeProxyInterface::r#close(self)
6836    }
6837
6838    /// Set a name for VMOs in this buffer collection. The name may be truncated
6839    /// shorter. The name only affects VMOs allocated after it's set - this call
6840    /// does not rename existing VMOs. If multiple clients set different names
6841    /// then the larger priority value will win.
6842    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
6843        NodeProxyInterface::r#set_name(self, priority, name)
6844    }
6845
6846    /// Set information about the current client that can be used by sysmem to
6847    /// help debug leaking memory and hangs waiting for constraints. |name| can
6848    /// be an arbitrary string, but the current process name (see
6849    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6850    /// arbitrary id, but the current process ID (see
6851    /// fsl::GetCurrentProcessKoid()) is a good default.
6852    ///
6853    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6854    /// indicate which client is closing their channel first, leading to
6855    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6856    /// over, but if happening earlier than expected, the
6857    /// client-channel-specific name can help diagnose where the failure is
6858    /// first coming from, from sysmem's point of view).
6859    ///
6860    /// By default (unless overriden by this message or using
6861    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6862    /// parent Node at the time the child Node is created.  While this can be
6863    /// better than nothing, it's often better for each participant to use
6864    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6865    /// info directly relevant to the current client.  Also, SetVerboseLogging()
6866    /// can be used to help disambiguate if a Node is suspected of having info
6867    /// that was copied from its parent.
6868    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
6869        NodeProxyInterface::r#set_debug_client_info(self, name, id)
6870    }
6871
6872    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6873    /// after creating a collection. Clients can call this method to change
6874    /// when the log is printed. If multiple client set the deadline, it's
6875    /// unspecified which deadline will take effect.
6876    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
6877        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
6878    }
6879
6880    /// Verbose logging includes constraints set via SetConstraints() from each
6881    /// client along with info set via SetDebugClientInfo() and the structure of
6882    /// the tree of Node(s).
6883    ///
6884    /// Normally sysmem prints only a single line complaint when aggregation
6885    /// fails, with just the specific detailed reason that aggregation failed,
6886    /// with minimal context.  While this is often enough to diagnose a problem
6887    /// if only a small change was made and the system had been working before
6888    /// the small change, it's often not particularly helpful for getting a new
6889    /// buffer collection to work for the first time.  Especially with more
6890    /// complex trees of nodes, involving things like AttachToken(),
6891    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6892    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6893    /// looks like and why it's failing a logical allocation, or why a tree or
6894    /// sub-tree is failing sooner than expected.
6895    ///
6896    /// The intent of the extra logging is to be acceptable from a performance
6897    /// point of view, if only enabled on a low number of buffer collections.
6898    /// If we're not tracking down a bug, we shouldn't send this message.
6899    ///
6900    /// If too many participants leave verbose logging enabled, we may end up
6901    /// needing to require that system-wide sysmem verbose logging be permitted
6902    /// via some other setting, to avoid sysmem spamming the log too much due to
6903    /// this message.
6904    ///
6905    /// This may be a NOP for some nodes due to intentional policy associated
6906    /// with the node, if we don't trust a node enough to let it turn on verbose
6907    /// logging.
6908    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
6909        NodeProxyInterface::r#set_verbose_logging(self)
6910    }
6911
6912    /// This gets an event handle that can be used as a parameter to
6913    /// IsAlternateFor() called on any Node.  The client will not be granted the
6914    /// right to signal this event, as this handle should only be used as proof
6915    /// that the client obtained this handle from this Node.
6916    ///
6917    /// Because this is a get not a set, no Sync() is needed between the
6918    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6919    /// potentially being on different channels.
6920    ///
6921    /// See also IsAlternateFor().
6922    pub fn r#get_node_ref(
6923        &self,
6924    ) -> fidl::client::QueryResponseFut<
6925        fdomain_client::Event,
6926        fdomain_client::fidl::FDomainResourceDialect,
6927    > {
6928        NodeProxyInterface::r#get_node_ref(self)
6929    }
6930
6931    /// This checks whether the calling node is in a subtree rooted at a
6932    /// different child token of a common parent BufferCollectionTokenGroup, in
6933    /// relation to the passed-in node_ref.
6934    ///
6935    /// This call is for assisting with admission control de-duplication, and
6936    /// with debugging.
6937    ///
6938    /// The node_ref must be obtained using GetNodeRef() of a
6939    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6940    ///
6941    /// The node_ref can be a duplicated handle; it's not necessary to call
6942    /// GetNodeRef() for every call to IsAlternateFor().
6943    ///
6944    /// If a calling token may not actually be a valid token at all due to
6945    /// a potentially hostile/untrusted provider of the token, call
6946    /// ValidateBufferCollectionToken() first instead of potentially getting
6947    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6948    /// token not being a real token (not really talking to sysmem).  Another
6949    /// option is to call BindSharedCollection with this token first which also
6950    /// validates the token along with converting it to a BufferCollection, then
6951    /// call BufferCollection IsAlternateFor().
6952    ///
6953    /// error values:
6954    ///
6955    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6956    /// buffer collection as the calling Node.  Before logical allocation and
6957    /// within the same logical allocation sub-tree, this essentially means that
6958    /// the node_ref was never part of this logical buffer collection, since
6959    /// before logical allocation all node_refs that come into existence remain
6960    /// in existence at least until logical allocation (including Node(s) that
6961    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6962    /// to be returned, this Node's channel needs to still be connected server
6963    /// side, which won't be the case if the whole logical allocation has
6964    /// failed.  After logical allocation or in a different logical allocation
6965    /// sub-tree there are additional potential reasons for this error.  For
6966    /// example a different logical allocation (separated from this Node(s)
6967    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6968    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6969    /// exist and may select a different child sub-tree than the sub-tree the
6970    /// node_ref is in causing deletion of the node_ref Node.  The only time
6971    /// sysmem keeps a Node around after that Node has no corresponding channel
6972    /// is when Close() is used and the Node's sub-tree has not yet failed.
6973    /// Another reason for this error is if the node_ref is an eventpair handle
6974    /// with sufficient rights, but isn't actually a real node_ref obtained from
6975    /// GetNodeRef().
6976    ///
6977    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6978    /// eventpair handle, or doesn't have the needed rights expected on a real
6979    /// node_ref.
6980    ///
6981    /// No other failing status codes are returned by this call.  However,
6982    /// sysmem may add additional codes in future, so the client should have
6983    /// sensible default handling for any failing status code.
6984    ///
6985    /// On success, is_alternate has the following meaning:
6986    ///   * true - The first parent node in common between the calling node and
6987    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
6988    ///     the calling Node and the node_ref Node will _not_ have both their
6989    ///     constraints apply - rather sysmem will choose one or the other of
6990    ///     the constraints - never both.  This is because only one child of
6991    ///     a BufferCollectionTokenGroup is selected during logical allocation,
6992    ///     with only that one child's sub-tree contributing to constraints
6993    ///     aggregation.
6994    ///   * false - The first parent node in common between the calling Node and
6995    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
6996    ///     this means the first parent node in common is a
6997    ///     BufferCollectionToken or BufferCollection (regardless of not
6998    ///     Close()ed or Close()ed).  This means that the calling Node and the
6999    ///     node_ref Node _may_ have both their constraints apply during
7000    ///     constraints aggregation of the logical allocation, if both Node(s)
7001    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7002    ///     In this case, there is no BufferCollectionTokenGroup that will
7003    ///     directly prevent the two Node(s) from both being selected and their
7004    ///     constraints both aggregated, but even when false, one or both
7005    ///     Node(s) may still be eliminated from consideration if one or both
7006    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7007    ///     which selects a child sub-tree other than the sub-tree containing
7008    ///     the calling Node or node_ref Node.
7009    pub fn r#is_alternate_for(
7010        &self,
7011        mut node_ref: fdomain_client::Event,
7012    ) -> fidl::client::QueryResponseFut<
7013        NodeIsAlternateForResult,
7014        fdomain_client::fidl::FDomainResourceDialect,
7015    > {
7016        NodeProxyInterface::r#is_alternate_for(self, node_ref)
7017    }
7018}
7019
7020impl NodeProxyInterface for NodeProxy {
7021    type SyncResponseFut =
7022        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7023    fn r#sync(&self) -> Self::SyncResponseFut {
7024        fn _decode(
7025            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7026        ) -> Result<(), fidl::Error> {
7027            let _response = fidl::client::decode_transaction_body::<
7028                fidl::encoding::EmptyPayload,
7029                fdomain_client::fidl::FDomainResourceDialect,
7030                0x4577e238ae26291,
7031            >(_buf?)?;
7032            Ok(_response)
7033        }
7034        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7035            (),
7036            0x4577e238ae26291,
7037            fidl::encoding::DynamicFlags::empty(),
7038            _decode,
7039        )
7040    }
7041
7042    fn r#close(&self) -> Result<(), fidl::Error> {
7043        self.client.send::<fidl::encoding::EmptyPayload>(
7044            (),
7045            0x5b1d7a4f5681fca7,
7046            fidl::encoding::DynamicFlags::empty(),
7047        )
7048    }
7049
7050    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7051        self.client.send::<NodeSetNameRequest>(
7052            (priority, name),
7053            0x77a41bb6217e2443,
7054            fidl::encoding::DynamicFlags::empty(),
7055        )
7056    }
7057
7058    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7059        self.client.send::<NodeSetDebugClientInfoRequest>(
7060            (name, id),
7061            0x7275759070eb5ee2,
7062            fidl::encoding::DynamicFlags::empty(),
7063        )
7064    }
7065
7066    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7067        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7068            (deadline,),
7069            0x46d38f4772638867,
7070            fidl::encoding::DynamicFlags::empty(),
7071        )
7072    }
7073
7074    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7075        self.client.send::<fidl::encoding::EmptyPayload>(
7076            (),
7077            0x6bfbe2cf1701d288,
7078            fidl::encoding::DynamicFlags::empty(),
7079        )
7080    }
7081
7082    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
7083        fdomain_client::Event,
7084        fdomain_client::fidl::FDomainResourceDialect,
7085    >;
7086    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7087        fn _decode(
7088            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7089        ) -> Result<fdomain_client::Event, fidl::Error> {
7090            let _response = fidl::client::decode_transaction_body::<
7091                NodeGetNodeRefResponse,
7092                fdomain_client::fidl::FDomainResourceDialect,
7093                0x467b7c75c35c3b84,
7094            >(_buf?)?;
7095            Ok(_response.node_ref)
7096        }
7097        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
7098            (),
7099            0x467b7c75c35c3b84,
7100            fidl::encoding::DynamicFlags::empty(),
7101            _decode,
7102        )
7103    }
7104
7105    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7106        NodeIsAlternateForResult,
7107        fdomain_client::fidl::FDomainResourceDialect,
7108    >;
7109    fn r#is_alternate_for(
7110        &self,
7111        mut node_ref: fdomain_client::Event,
7112    ) -> Self::IsAlternateForResponseFut {
7113        fn _decode(
7114            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7115        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7116            let _response = fidl::client::decode_transaction_body::<
7117                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7118                fdomain_client::fidl::FDomainResourceDialect,
7119                0x33a2a7aff2776c07,
7120            >(_buf?)?;
7121            Ok(_response.map(|x| x.is_alternate))
7122        }
7123        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7124            (node_ref,),
7125            0x33a2a7aff2776c07,
7126            fidl::encoding::DynamicFlags::empty(),
7127            _decode,
7128        )
7129    }
7130}
7131
7132pub struct NodeEventStream {
7133    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7134}
7135
7136impl std::marker::Unpin for NodeEventStream {}
7137
7138impl futures::stream::FusedStream for NodeEventStream {
7139    fn is_terminated(&self) -> bool {
7140        self.event_receiver.is_terminated()
7141    }
7142}
7143
7144impl futures::Stream for NodeEventStream {
7145    type Item = Result<NodeEvent, fidl::Error>;
7146
7147    fn poll_next(
7148        mut self: std::pin::Pin<&mut Self>,
7149        cx: &mut std::task::Context<'_>,
7150    ) -> std::task::Poll<Option<Self::Item>> {
7151        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7152            &mut self.event_receiver,
7153            cx
7154        )?) {
7155            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
7156            None => std::task::Poll::Ready(None),
7157        }
7158    }
7159}
7160
7161#[derive(Debug)]
7162pub enum NodeEvent {}
7163
7164impl NodeEvent {
7165    /// Decodes a message buffer as a [`NodeEvent`].
7166    fn decode(
7167        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7168    ) -> Result<NodeEvent, fidl::Error> {
7169        let (bytes, _handles) = buf.split_mut();
7170        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7171        debug_assert_eq!(tx_header.tx_id, 0);
7172        match tx_header.ordinal {
7173            _ => Err(fidl::Error::UnknownOrdinal {
7174                ordinal: tx_header.ordinal,
7175                protocol_name: <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7176            }),
7177        }
7178    }
7179}
7180
7181/// A Stream of incoming requests for fuchsia.sysmem/Node.
7182pub struct NodeRequestStream {
7183    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7184    is_terminated: bool,
7185}
7186
7187impl std::marker::Unpin for NodeRequestStream {}
7188
7189impl futures::stream::FusedStream for NodeRequestStream {
7190    fn is_terminated(&self) -> bool {
7191        self.is_terminated
7192    }
7193}
7194
7195impl fdomain_client::fidl::RequestStream for NodeRequestStream {
7196    type Protocol = NodeMarker;
7197    type ControlHandle = NodeControlHandle;
7198
7199    fn from_channel(channel: fdomain_client::Channel) -> Self {
7200        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7201    }
7202
7203    fn control_handle(&self) -> Self::ControlHandle {
7204        NodeControlHandle { inner: self.inner.clone() }
7205    }
7206
7207    fn into_inner(
7208        self,
7209    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7210    {
7211        (self.inner, self.is_terminated)
7212    }
7213
7214    fn from_inner(
7215        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7216        is_terminated: bool,
7217    ) -> Self {
7218        Self { inner, is_terminated }
7219    }
7220}
7221
7222impl futures::Stream for NodeRequestStream {
7223    type Item = Result<NodeRequest, fidl::Error>;
7224
7225    fn poll_next(
7226        mut self: std::pin::Pin<&mut Self>,
7227        cx: &mut std::task::Context<'_>,
7228    ) -> std::task::Poll<Option<Self::Item>> {
7229        let this = &mut *self;
7230        if this.inner.check_shutdown(cx) {
7231            this.is_terminated = true;
7232            return std::task::Poll::Ready(None);
7233        }
7234        if this.is_terminated {
7235            panic!("polled NodeRequestStream after completion");
7236        }
7237        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7238            |bytes, handles| {
7239                match this.inner.channel().read_etc(cx, bytes, handles) {
7240                    std::task::Poll::Ready(Ok(())) => {}
7241                    std::task::Poll::Pending => return std::task::Poll::Pending,
7242                    std::task::Poll::Ready(Err(None)) => {
7243                        this.is_terminated = true;
7244                        return std::task::Poll::Ready(None);
7245                    }
7246                    std::task::Poll::Ready(Err(Some(e))) => {
7247                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7248                            e.into(),
7249                        ))));
7250                    }
7251                }
7252
7253                // A message has been received from the channel
7254                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7255
7256                std::task::Poll::Ready(Some(match header.ordinal {
7257                    0x4577e238ae26291 => {
7258                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7259                        let mut req = fidl::new_empty!(
7260                            fidl::encoding::EmptyPayload,
7261                            fdomain_client::fidl::FDomainResourceDialect
7262                        );
7263                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7264                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7265                        Ok(NodeRequest::Sync {
7266                            responder: NodeSyncResponder {
7267                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7268                                tx_id: header.tx_id,
7269                            },
7270                        })
7271                    }
7272                    0x5b1d7a4f5681fca7 => {
7273                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7274                        let mut req = fidl::new_empty!(
7275                            fidl::encoding::EmptyPayload,
7276                            fdomain_client::fidl::FDomainResourceDialect
7277                        );
7278                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7279                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7280                        Ok(NodeRequest::Close { control_handle })
7281                    }
7282                    0x77a41bb6217e2443 => {
7283                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7284                        let mut req = fidl::new_empty!(
7285                            NodeSetNameRequest,
7286                            fdomain_client::fidl::FDomainResourceDialect
7287                        );
7288                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
7289                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7290                        Ok(NodeRequest::SetName {
7291                            priority: req.priority,
7292                            name: req.name,
7293
7294                            control_handle,
7295                        })
7296                    }
7297                    0x7275759070eb5ee2 => {
7298                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7299                        let mut req = fidl::new_empty!(
7300                            NodeSetDebugClientInfoRequest,
7301                            fdomain_client::fidl::FDomainResourceDialect
7302                        );
7303                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
7304                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7305                        Ok(NodeRequest::SetDebugClientInfo {
7306                            name: req.name,
7307                            id: req.id,
7308
7309                            control_handle,
7310                        })
7311                    }
7312                    0x46d38f4772638867 => {
7313                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7314                        let mut req = fidl::new_empty!(
7315                            NodeSetDebugTimeoutLogDeadlineRequest,
7316                            fdomain_client::fidl::FDomainResourceDialect
7317                        );
7318                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
7319                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7320                        Ok(NodeRequest::SetDebugTimeoutLogDeadline {
7321                            deadline: req.deadline,
7322
7323                            control_handle,
7324                        })
7325                    }
7326                    0x6bfbe2cf1701d288 => {
7327                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7328                        let mut req = fidl::new_empty!(
7329                            fidl::encoding::EmptyPayload,
7330                            fdomain_client::fidl::FDomainResourceDialect
7331                        );
7332                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7333                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7334                        Ok(NodeRequest::SetVerboseLogging { control_handle })
7335                    }
7336                    0x467b7c75c35c3b84 => {
7337                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7338                        let mut req = fidl::new_empty!(
7339                            fidl::encoding::EmptyPayload,
7340                            fdomain_client::fidl::FDomainResourceDialect
7341                        );
7342                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7343                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7344                        Ok(NodeRequest::GetNodeRef {
7345                            responder: NodeGetNodeRefResponder {
7346                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7347                                tx_id: header.tx_id,
7348                            },
7349                        })
7350                    }
7351                    0x33a2a7aff2776c07 => {
7352                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7353                        let mut req = fidl::new_empty!(
7354                            NodeIsAlternateForRequest,
7355                            fdomain_client::fidl::FDomainResourceDialect
7356                        );
7357                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
7358                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
7359                        Ok(NodeRequest::IsAlternateFor {
7360                            node_ref: req.node_ref,
7361
7362                            responder: NodeIsAlternateForResponder {
7363                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7364                                tx_id: header.tx_id,
7365                            },
7366                        })
7367                    }
7368                    _ => Err(fidl::Error::UnknownOrdinal {
7369                        ordinal: header.ordinal,
7370                        protocol_name:
7371                            <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7372                    }),
7373                }))
7374            },
7375        )
7376    }
7377}
7378
7379#[derive(Debug)]
7380pub enum NodeRequest {
7381    /// Ensure that previous messages, including Duplicate() messages on a
7382    /// token, collection, or group, have been received server side.
7383    ///
7384    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7385    /// valid sysmem token risks the Sync() hanging forever.  See
7386    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7387    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7388    /// Another way is to pass the token to BindSharedCollection(), which also
7389    /// validates the token as part of exchanging it for a BufferCollection
7390    /// channel, and BufferCollection Sync() can then be used.
7391    ///
7392    /// After a Sync(), it's then safe to send the client end of token_request
7393    /// to another participant knowing the server will recognize the token when
7394    /// it's sent into BindSharedCollection() by the other participant.
7395    ///
7396    /// Other options include waiting for each token.Duplicate() to complete
7397    /// individually (using separate call to token.Sync() after each), or
7398    /// calling Sync() on BufferCollection after the token has been turned in
7399    /// via BindSharedCollection().
7400    ///
7401    /// Another way to mitigate is to avoid calling Sync() on the token, and
7402    /// instead later deal with potential failure of BufferCollection.Sync() if
7403    /// the original token was invalid.  This option can be preferable from a
7404    /// performance point of view, but requires client code to delay sending
7405    /// tokens duplicated from this token until after client code has converted
7406    /// the duplicating token to a BufferCollection and received successful
7407    /// response from BufferCollection.Sync().
7408    ///
7409    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7410    /// When BufferCollection.Sync() isn't feasible, the caller must already
7411    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7412    /// hang forever.  See ValidateBufferCollectionToken() to check token
7413    /// validity first if the token isn't already known to be (is/was) valid.
7414    Sync { responder: NodeSyncResponder },
7415    /// On a BufferCollectionToken channel:
7416    ///
7417    /// Normally a participant will convert a BufferCollectionToken into a
7418    /// BufferCollection view, but a participant is also free to Close() the
7419    /// token (and then close the channel immediately or shortly later in
7420    /// response to server closing its end), which avoids causing logical buffer
7421    /// collection failure.  Normally an unexpected token channel close will
7422    /// cause logical buffer collection failure (the only exceptions being
7423    /// certain cases involving AttachToken() or SetDispensable()).
7424    ///
7425    /// On a BufferCollection channel:
7426    ///
7427    /// By default the server handles unexpected failure of a BufferCollection
7428    /// by failing the whole logical buffer collection.  Partly this is to
7429    /// expedite closing VMO handles to reclaim memory when any participant
7430    /// fails.  If a participant would like to cleanly close a BufferCollection
7431    /// view without causing logical buffer collection failure, the participant
7432    /// can send Close() before closing the client end of the BufferCollection
7433    /// channel.  If this is the last BufferCollection view, the logical buffer
7434    /// collection will still go away.  The Close() can occur before or after
7435    /// SetConstraints().  If before SetConstraints(), the buffer collection
7436    /// won't require constraints from this node in order to allocate.  If
7437    /// after SetConstraints(), the constraints are retained and aggregated
7438    /// along with any subsequent logical allocation(s), despite the lack of
7439    /// channel connection.
7440    ///
7441    /// On a BufferCollectionTokenGroup channel:
7442    ///
7443    /// By default, unexpected failure of a BufferCollectionTokenGroup will
7444    /// trigger failure of the logical BufferCollectionTokenGroup and will
7445    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
7446    /// channel without failing the logical group or propagating failure, send
7447    /// Close() before closing the channel client endpoint.
7448    ///
7449    /// If Close() occurs before AllChildrenPresent(), the logical buffer
7450    /// collection will still fail despite the Close() (because sysmem can't be
7451    /// sure whether all relevant children were created, so it's ambiguous
7452    /// whether all relevant constraints will be provided to sysmem).  If
7453    /// Close() occurs after AllChildrenPresent(), the children and all their
7454    /// constraints remain intact (just as they would if the
7455    /// BufferCollectionTokenGroup channel had remained open), and the close
7456    /// doesn't trigger or propagate failure.
7457    Close { control_handle: NodeControlHandle },
7458    /// Set a name for VMOs in this buffer collection. The name may be truncated
7459    /// shorter. The name only affects VMOs allocated after it's set - this call
7460    /// does not rename existing VMOs. If multiple clients set different names
7461    /// then the larger priority value will win.
7462    SetName { priority: u32, name: String, control_handle: NodeControlHandle },
7463    /// Set information about the current client that can be used by sysmem to
7464    /// help debug leaking memory and hangs waiting for constraints. |name| can
7465    /// be an arbitrary string, but the current process name (see
7466    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7467    /// arbitrary id, but the current process ID (see
7468    /// fsl::GetCurrentProcessKoid()) is a good default.
7469    ///
7470    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7471    /// indicate which client is closing their channel first, leading to
7472    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7473    /// over, but if happening earlier than expected, the
7474    /// client-channel-specific name can help diagnose where the failure is
7475    /// first coming from, from sysmem's point of view).
7476    ///
7477    /// By default (unless overriden by this message or using
7478    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7479    /// parent Node at the time the child Node is created.  While this can be
7480    /// better than nothing, it's often better for each participant to use
7481    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7482    /// info directly relevant to the current client.  Also, SetVerboseLogging()
7483    /// can be used to help disambiguate if a Node is suspected of having info
7484    /// that was copied from its parent.
7485    SetDebugClientInfo { name: String, id: u64, control_handle: NodeControlHandle },
7486    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7487    /// after creating a collection. Clients can call this method to change
7488    /// when the log is printed. If multiple client set the deadline, it's
7489    /// unspecified which deadline will take effect.
7490    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: NodeControlHandle },
7491    /// Verbose logging includes constraints set via SetConstraints() from each
7492    /// client along with info set via SetDebugClientInfo() and the structure of
7493    /// the tree of Node(s).
7494    ///
7495    /// Normally sysmem prints only a single line complaint when aggregation
7496    /// fails, with just the specific detailed reason that aggregation failed,
7497    /// with minimal context.  While this is often enough to diagnose a problem
7498    /// if only a small change was made and the system had been working before
7499    /// the small change, it's often not particularly helpful for getting a new
7500    /// buffer collection to work for the first time.  Especially with more
7501    /// complex trees of nodes, involving things like AttachToken(),
7502    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7503    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7504    /// looks like and why it's failing a logical allocation, or why a tree or
7505    /// sub-tree is failing sooner than expected.
7506    ///
7507    /// The intent of the extra logging is to be acceptable from a performance
7508    /// point of view, if only enabled on a low number of buffer collections.
7509    /// If we're not tracking down a bug, we shouldn't send this message.
7510    ///
7511    /// If too many participants leave verbose logging enabled, we may end up
7512    /// needing to require that system-wide sysmem verbose logging be permitted
7513    /// via some other setting, to avoid sysmem spamming the log too much due to
7514    /// this message.
7515    ///
7516    /// This may be a NOP for some nodes due to intentional policy associated
7517    /// with the node, if we don't trust a node enough to let it turn on verbose
7518    /// logging.
7519    SetVerboseLogging { control_handle: NodeControlHandle },
7520    /// This gets an event handle that can be used as a parameter to
7521    /// IsAlternateFor() called on any Node.  The client will not be granted the
7522    /// right to signal this event, as this handle should only be used as proof
7523    /// that the client obtained this handle from this Node.
7524    ///
7525    /// Because this is a get not a set, no Sync() is needed between the
7526    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7527    /// potentially being on different channels.
7528    ///
7529    /// See also IsAlternateFor().
7530    GetNodeRef { responder: NodeGetNodeRefResponder },
7531    /// This checks whether the calling node is in a subtree rooted at a
7532    /// different child token of a common parent BufferCollectionTokenGroup, in
7533    /// relation to the passed-in node_ref.
7534    ///
7535    /// This call is for assisting with admission control de-duplication, and
7536    /// with debugging.
7537    ///
7538    /// The node_ref must be obtained using GetNodeRef() of a
7539    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7540    ///
7541    /// The node_ref can be a duplicated handle; it's not necessary to call
7542    /// GetNodeRef() for every call to IsAlternateFor().
7543    ///
7544    /// If a calling token may not actually be a valid token at all due to
7545    /// a potentially hostile/untrusted provider of the token, call
7546    /// ValidateBufferCollectionToken() first instead of potentially getting
7547    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7548    /// token not being a real token (not really talking to sysmem).  Another
7549    /// option is to call BindSharedCollection with this token first which also
7550    /// validates the token along with converting it to a BufferCollection, then
7551    /// call BufferCollection IsAlternateFor().
7552    ///
7553    /// error values:
7554    ///
7555    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7556    /// buffer collection as the calling Node.  Before logical allocation and
7557    /// within the same logical allocation sub-tree, this essentially means that
7558    /// the node_ref was never part of this logical buffer collection, since
7559    /// before logical allocation all node_refs that come into existence remain
7560    /// in existence at least until logical allocation (including Node(s) that
7561    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7562    /// to be returned, this Node's channel needs to still be connected server
7563    /// side, which won't be the case if the whole logical allocation has
7564    /// failed.  After logical allocation or in a different logical allocation
7565    /// sub-tree there are additional potential reasons for this error.  For
7566    /// example a different logical allocation (separated from this Node(s)
7567    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7568    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7569    /// exist and may select a different child sub-tree than the sub-tree the
7570    /// node_ref is in causing deletion of the node_ref Node.  The only time
7571    /// sysmem keeps a Node around after that Node has no corresponding channel
7572    /// is when Close() is used and the Node's sub-tree has not yet failed.
7573    /// Another reason for this error is if the node_ref is an eventpair handle
7574    /// with sufficient rights, but isn't actually a real node_ref obtained from
7575    /// GetNodeRef().
7576    ///
7577    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7578    /// eventpair handle, or doesn't have the needed rights expected on a real
7579    /// node_ref.
7580    ///
7581    /// No other failing status codes are returned by this call.  However,
7582    /// sysmem may add additional codes in future, so the client should have
7583    /// sensible default handling for any failing status code.
7584    ///
7585    /// On success, is_alternate has the following meaning:
7586    ///   * true - The first parent node in common between the calling node and
7587    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7588    ///     the calling Node and the node_ref Node will _not_ have both their
7589    ///     constraints apply - rather sysmem will choose one or the other of
7590    ///     the constraints - never both.  This is because only one child of
7591    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7592    ///     with only that one child's sub-tree contributing to constraints
7593    ///     aggregation.
7594    ///   * false - The first parent node in common between the calling Node and
7595    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7596    ///     this means the first parent node in common is a
7597    ///     BufferCollectionToken or BufferCollection (regardless of not
7598    ///     Close()ed or Close()ed).  This means that the calling Node and the
7599    ///     node_ref Node _may_ have both their constraints apply during
7600    ///     constraints aggregation of the logical allocation, if both Node(s)
7601    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7602    ///     In this case, there is no BufferCollectionTokenGroup that will
7603    ///     directly prevent the two Node(s) from both being selected and their
7604    ///     constraints both aggregated, but even when false, one or both
7605    ///     Node(s) may still be eliminated from consideration if one or both
7606    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7607    ///     which selects a child sub-tree other than the sub-tree containing
7608    ///     the calling Node or node_ref Node.
7609    IsAlternateFor { node_ref: fdomain_client::Event, responder: NodeIsAlternateForResponder },
7610}
7611
7612impl NodeRequest {
7613    #[allow(irrefutable_let_patterns)]
7614    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
7615        if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
7616    }
7617
7618    #[allow(irrefutable_let_patterns)]
7619    pub fn into_close(self) -> Option<(NodeControlHandle)> {
7620        if let NodeRequest::Close { control_handle } = self { Some((control_handle)) } else { None }
7621    }
7622
7623    #[allow(irrefutable_let_patterns)]
7624    pub fn into_set_name(self) -> Option<(u32, String, NodeControlHandle)> {
7625        if let NodeRequest::SetName { priority, name, control_handle } = self {
7626            Some((priority, name, control_handle))
7627        } else {
7628            None
7629        }
7630    }
7631
7632    #[allow(irrefutable_let_patterns)]
7633    pub fn into_set_debug_client_info(self) -> Option<(String, u64, NodeControlHandle)> {
7634        if let NodeRequest::SetDebugClientInfo { name, id, control_handle } = self {
7635            Some((name, id, control_handle))
7636        } else {
7637            None
7638        }
7639    }
7640
7641    #[allow(irrefutable_let_patterns)]
7642    pub fn into_set_debug_timeout_log_deadline(self) -> Option<(i64, NodeControlHandle)> {
7643        if let NodeRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } = self {
7644            Some((deadline, control_handle))
7645        } else {
7646            None
7647        }
7648    }
7649
7650    #[allow(irrefutable_let_patterns)]
7651    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
7652        if let NodeRequest::SetVerboseLogging { control_handle } = self {
7653            Some((control_handle))
7654        } else {
7655            None
7656        }
7657    }
7658
7659    #[allow(irrefutable_let_patterns)]
7660    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
7661        if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
7662    }
7663
7664    #[allow(irrefutable_let_patterns)]
7665    pub fn into_is_alternate_for(
7666        self,
7667    ) -> Option<(fdomain_client::Event, NodeIsAlternateForResponder)> {
7668        if let NodeRequest::IsAlternateFor { node_ref, responder } = self {
7669            Some((node_ref, responder))
7670        } else {
7671            None
7672        }
7673    }
7674
7675    /// Name of the method defined in FIDL
7676    pub fn method_name(&self) -> &'static str {
7677        match *self {
7678            NodeRequest::Sync { .. } => "sync",
7679            NodeRequest::Close { .. } => "close",
7680            NodeRequest::SetName { .. } => "set_name",
7681            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
7682            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
7683            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
7684            NodeRequest::GetNodeRef { .. } => "get_node_ref",
7685            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
7686        }
7687    }
7688}
7689
7690#[derive(Debug, Clone)]
7691pub struct NodeControlHandle {
7692    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7693}
7694
7695impl NodeControlHandle {
7696    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7697        self.inner.shutdown_with_epitaph(status.into())
7698    }
7699}
7700
7701impl fdomain_client::fidl::ControlHandle for NodeControlHandle {
7702    fn shutdown(&self) {
7703        self.inner.shutdown()
7704    }
7705
7706    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7707        self.inner.shutdown_with_epitaph(status)
7708    }
7709
7710    fn is_closed(&self) -> bool {
7711        self.inner.channel().is_closed()
7712    }
7713    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
7714        self.inner.channel().on_closed()
7715    }
7716}
7717
7718impl NodeControlHandle {}
7719
7720#[must_use = "FIDL methods require a response to be sent"]
7721#[derive(Debug)]
7722pub struct NodeSyncResponder {
7723    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7724    tx_id: u32,
7725}
7726
7727/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7728/// if the responder is dropped without sending a response, so that the client
7729/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7730impl std::ops::Drop for NodeSyncResponder {
7731    fn drop(&mut self) {
7732        self.control_handle.shutdown();
7733        // Safety: drops once, never accessed again
7734        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7735    }
7736}
7737
7738impl fdomain_client::fidl::Responder for NodeSyncResponder {
7739    type ControlHandle = NodeControlHandle;
7740
7741    fn control_handle(&self) -> &NodeControlHandle {
7742        &self.control_handle
7743    }
7744
7745    fn drop_without_shutdown(mut self) {
7746        // Safety: drops once, never accessed again due to mem::forget
7747        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7748        // Prevent Drop from running (which would shut down the channel)
7749        std::mem::forget(self);
7750    }
7751}
7752
7753impl NodeSyncResponder {
7754    /// Sends a response to the FIDL transaction.
7755    ///
7756    /// Sets the channel to shutdown if an error occurs.
7757    pub fn send(self) -> Result<(), fidl::Error> {
7758        let _result = self.send_raw();
7759        if _result.is_err() {
7760            self.control_handle.shutdown();
7761        }
7762        self.drop_without_shutdown();
7763        _result
7764    }
7765
7766    /// Similar to "send" but does not shutdown the channel if an error occurs.
7767    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7768        let _result = self.send_raw();
7769        self.drop_without_shutdown();
7770        _result
7771    }
7772
7773    fn send_raw(&self) -> Result<(), fidl::Error> {
7774        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7775            (),
7776            self.tx_id,
7777            0x4577e238ae26291,
7778            fidl::encoding::DynamicFlags::empty(),
7779        )
7780    }
7781}
7782
7783#[must_use = "FIDL methods require a response to be sent"]
7784#[derive(Debug)]
7785pub struct NodeGetNodeRefResponder {
7786    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7787    tx_id: u32,
7788}
7789
7790/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7791/// if the responder is dropped without sending a response, so that the client
7792/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7793impl std::ops::Drop for NodeGetNodeRefResponder {
7794    fn drop(&mut self) {
7795        self.control_handle.shutdown();
7796        // Safety: drops once, never accessed again
7797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7798    }
7799}
7800
7801impl fdomain_client::fidl::Responder for NodeGetNodeRefResponder {
7802    type ControlHandle = NodeControlHandle;
7803
7804    fn control_handle(&self) -> &NodeControlHandle {
7805        &self.control_handle
7806    }
7807
7808    fn drop_without_shutdown(mut self) {
7809        // Safety: drops once, never accessed again due to mem::forget
7810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7811        // Prevent Drop from running (which would shut down the channel)
7812        std::mem::forget(self);
7813    }
7814}
7815
7816impl NodeGetNodeRefResponder {
7817    /// Sends a response to the FIDL transaction.
7818    ///
7819    /// Sets the channel to shutdown if an error occurs.
7820    pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
7821        let _result = self.send_raw(node_ref);
7822        if _result.is_err() {
7823            self.control_handle.shutdown();
7824        }
7825        self.drop_without_shutdown();
7826        _result
7827    }
7828
7829    /// Similar to "send" but does not shutdown the channel if an error occurs.
7830    pub fn send_no_shutdown_on_err(
7831        self,
7832        mut node_ref: fdomain_client::Event,
7833    ) -> Result<(), fidl::Error> {
7834        let _result = self.send_raw(node_ref);
7835        self.drop_without_shutdown();
7836        _result
7837    }
7838
7839    fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
7840        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
7841            (node_ref,),
7842            self.tx_id,
7843            0x467b7c75c35c3b84,
7844            fidl::encoding::DynamicFlags::empty(),
7845        )
7846    }
7847}
7848
7849#[must_use = "FIDL methods require a response to be sent"]
7850#[derive(Debug)]
7851pub struct NodeIsAlternateForResponder {
7852    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7853    tx_id: u32,
7854}
7855
7856/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7857/// if the responder is dropped without sending a response, so that the client
7858/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7859impl std::ops::Drop for NodeIsAlternateForResponder {
7860    fn drop(&mut self) {
7861        self.control_handle.shutdown();
7862        // Safety: drops once, never accessed again
7863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7864    }
7865}
7866
7867impl fdomain_client::fidl::Responder for NodeIsAlternateForResponder {
7868    type ControlHandle = NodeControlHandle;
7869
7870    fn control_handle(&self) -> &NodeControlHandle {
7871        &self.control_handle
7872    }
7873
7874    fn drop_without_shutdown(mut self) {
7875        // Safety: drops once, never accessed again due to mem::forget
7876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7877        // Prevent Drop from running (which would shut down the channel)
7878        std::mem::forget(self);
7879    }
7880}
7881
7882impl NodeIsAlternateForResponder {
7883    /// Sends a response to the FIDL transaction.
7884    ///
7885    /// Sets the channel to shutdown if an error occurs.
7886    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7887        let _result = self.send_raw(result);
7888        if _result.is_err() {
7889            self.control_handle.shutdown();
7890        }
7891        self.drop_without_shutdown();
7892        _result
7893    }
7894
7895    /// Similar to "send" but does not shutdown the channel if an error occurs.
7896    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7897        let _result = self.send_raw(result);
7898        self.drop_without_shutdown();
7899        _result
7900    }
7901
7902    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7903        self.control_handle
7904            .inner
7905            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
7906                result.map(|is_alternate| (is_alternate,)),
7907                self.tx_id,
7908                0x33a2a7aff2776c07,
7909                fidl::encoding::DynamicFlags::empty(),
7910            )
7911    }
7912}
7913
7914#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7915pub struct SecureMemMarker;
7916
7917impl fdomain_client::fidl::ProtocolMarker for SecureMemMarker {
7918    type Proxy = SecureMemProxy;
7919    type RequestStream = SecureMemRequestStream;
7920
7921    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
7922}
7923pub type SecureMemGetPhysicalSecureHeapsResult = Result<SecureHeapsAndRanges, i32>;
7924pub type SecureMemGetPhysicalSecureHeapPropertiesResult = Result<SecureHeapProperties, i32>;
7925pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), i32>;
7926pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), i32>;
7927pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), i32>;
7928pub type SecureMemZeroSubRangeResult = Result<(), i32>;
7929
7930pub trait SecureMemProxyInterface: Send + Sync {
7931    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
7932        + Send;
7933    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
7934    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
7935            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
7936        > + Send;
7937    fn r#get_physical_secure_heap_properties(
7938        &self,
7939        entire_heap: &SecureHeapAndRange,
7940    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
7941    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
7942        + Send;
7943    fn r#add_secure_heap_physical_range(
7944        &self,
7945        heap_range: &SecureHeapAndRange,
7946    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
7947    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
7948            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
7949        > + Send;
7950    fn r#delete_secure_heap_physical_range(
7951        &self,
7952        heap_range: &SecureHeapAndRange,
7953    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
7954    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
7955            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
7956        > + Send;
7957    fn r#modify_secure_heap_physical_range(
7958        &self,
7959        range_modification: &SecureHeapAndRangeModification,
7960    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
7961    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
7962        + Send;
7963    fn r#zero_sub_range(
7964        &self,
7965        is_covering_range_explicit: bool,
7966        heap_range: &SecureHeapAndRange,
7967    ) -> Self::ZeroSubRangeResponseFut;
7968}
7969
7970#[derive(Debug, Clone)]
7971pub struct SecureMemProxy {
7972    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
7973}
7974
7975impl fdomain_client::fidl::Proxy for SecureMemProxy {
7976    type Protocol = SecureMemMarker;
7977
7978    fn from_channel(inner: fdomain_client::Channel) -> Self {
7979        Self::new(inner)
7980    }
7981
7982    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
7983        self.client.into_channel().map_err(|client| Self { client })
7984    }
7985
7986    fn as_channel(&self) -> &fdomain_client::Channel {
7987        self.client.as_channel()
7988    }
7989}
7990
7991impl SecureMemProxy {
7992    /// Create a new Proxy for fuchsia.sysmem/SecureMem.
7993    pub fn new(channel: fdomain_client::Channel) -> Self {
7994        let protocol_name = <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
7995        Self { client: fidl::client::Client::new(channel, protocol_name) }
7996    }
7997
7998    /// Get a Stream of events from the remote end of the protocol.
7999    ///
8000    /// # Panics
8001    ///
8002    /// Panics if the event stream was already taken.
8003    pub fn take_event_stream(&self) -> SecureMemEventStream {
8004        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
8005    }
8006
8007    /// Gets the physical address and length of any secure heap whose physical
8008    /// range is configured via the TEE.
8009    ///
8010    /// Presently, these will be fixed physical addresses and lengths, with the
8011    /// location plumbed via the TEE.
8012    ///
8013    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
8014    /// when there isn't any special heap-specific per-VMO setup or teardown
8015    /// required.
8016    ///
8017    /// The physical range must be secured/protected by the TEE before the
8018    /// securemem driver responds to this request with success.
8019    ///
8020    /// Sysmem should only call this once.  Returning zero heaps is not a
8021    /// failure.
8022    ///
8023    /// Errors:
8024    ///  * ZX_ERR_BAD_STATE - called more than once.
8025    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
8026    ///    with TEE which doesn't generate zx_status_t errors).
8027    ///  * other errors are allowed; any other errors should be treated the same
8028    ///    as ZX_ERR_INTERNAL.
8029    pub fn r#get_physical_secure_heaps(
8030        &self,
8031    ) -> fidl::client::QueryResponseFut<
8032        SecureMemGetPhysicalSecureHeapsResult,
8033        fdomain_client::fidl::FDomainResourceDialect,
8034    > {
8035        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
8036    }
8037
8038    /// This request from sysmem to the securemem driver gets the properties of
8039    /// a protected/secure heap.
8040    ///
8041    /// This only handles heaps with a single contiguous physical extent.
8042    ///
8043    /// The heap's entire physical range is indicated in case this request needs
8044    /// some physical space to auto-detect how many ranges are REE-usable.  Any
8045    /// temporary HW protection ranges will be deleted before this request
8046    /// completes.
8047    pub fn r#get_physical_secure_heap_properties(
8048        &self,
8049        mut entire_heap: &SecureHeapAndRange,
8050    ) -> fidl::client::QueryResponseFut<
8051        SecureMemGetPhysicalSecureHeapPropertiesResult,
8052        fdomain_client::fidl::FDomainResourceDialect,
8053    > {
8054        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, entire_heap)
8055    }
8056
8057    /// This request from sysmem to the securemem driver conveys a physical
8058    /// range to add, for a heap whose physical range(s) are set up via
8059    /// sysmem.
8060    ///
8061    /// Only sysmem can call this because only sysmem is handed the client end
8062    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8063    /// securemem driver is the server end of this protocol.
8064    ///
8065    /// The securemem driver must configure all the covered offsets as protected
8066    /// before responding to this message with success.
8067    ///
8068    /// On failure, the securemem driver must ensure the protected range was not
8069    /// created.
8070    ///
8071    /// Sysmem must only call this up to once if dynamic_protection_ranges
8072    /// false.
8073    ///
8074    /// If dynamic_protection_ranges is true, sysmem can call this multiple
8075    /// times as long as the current number of ranges never exceeds
8076    /// max_protected_range_count.
8077    ///
8078    /// The caller must not attempt to add a range that matches an
8079    /// already-existing range.  Added ranges can overlap each other as long as
8080    /// no two ranges match exactly.
8081    ///
8082    /// Errors:
8083    ///   * ZX_ERR_BAD_STATE - called more than once when
8084    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
8085    ///     heap count to exceed max_protected_range_count.
8086    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8087    ///     to protected_range_granularity.
8088    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8089    ///     with TEE which doesn't generate zx_status_t errors).
8090    ///   * other errors are possible, such as from communication failures or
8091    ///     server propagation of zx_status_t failures.
8092    pub fn r#add_secure_heap_physical_range(
8093        &self,
8094        mut heap_range: &SecureHeapAndRange,
8095    ) -> fidl::client::QueryResponseFut<
8096        SecureMemAddSecureHeapPhysicalRangeResult,
8097        fdomain_client::fidl::FDomainResourceDialect,
8098    > {
8099        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, heap_range)
8100    }
8101
8102    /// This request from sysmem to the securemem driver conveys a physical
8103    /// range to delete, for a heap whose physical range(s) are set up via
8104    /// sysmem.
8105    ///
8106    /// Only sysmem can call this because only sysmem is handed the client end
8107    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8108    /// securemem driver is the server end of this protocol.
8109    ///
8110    /// The securemem driver must configure all the covered offsets as not
8111    /// protected before responding to this message with success.
8112    ///
8113    /// On failure, the securemem driver must ensure the protected range was not
8114    /// deleted.
8115    ///
8116    /// Sysmem must not call this if dynamic_protection_ranges false.
8117    ///
8118    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8119    /// on various ranges that exist at the time of the call.
8120    ///
8121    /// If any portion of the range being deleted is not also covered by another
8122    /// protected range, then any ongoing DMA to any part of the entire range
8123    /// may be interrupted / may fail, potentially in a way that's disruptive to
8124    /// the entire system (bus lockup or similar, depending on device details).
8125    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
8126    /// any portion of the range being deleted, unless the caller has other
8127    /// active ranges covering every block of the range being deleted.  Ongoing
8128    /// DMA to/from blocks outside the range being deleted is never impacted by
8129    /// the deletion.
8130    ///
8131    /// Errors:
8132    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8133    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8134    ///     to protected_range_granularity.
8135    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8136    ///     with TEE which doesn't generate zx_status_t errors).
8137    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
8138    ///   * other errors are possible, such as from communication failures or
8139    ///     server propagation of zx_status_t failures.
8140    pub fn r#delete_secure_heap_physical_range(
8141        &self,
8142        mut heap_range: &SecureHeapAndRange,
8143    ) -> fidl::client::QueryResponseFut<
8144        SecureMemDeleteSecureHeapPhysicalRangeResult,
8145        fdomain_client::fidl::FDomainResourceDialect,
8146    > {
8147        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, heap_range)
8148    }
8149
8150    /// This request from sysmem to the securemem driver conveys a physical
8151    /// range to modify and its new base and length, for a heap whose physical
8152    /// range(s) are set up via sysmem.
8153    ///
8154    /// Only sysmem can call this because only sysmem is handed the client end
8155    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8156    /// securemem driver is the server end of this protocol.
8157    ///
8158    /// The securemem driver must configure the range to cover only the new
8159    /// offsets before responding to this message with success.
8160    ///
8161    /// On failure, the securemem driver must ensure the range was not changed.
8162    ///
8163    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
8164    /// must not call this if !is_mod_protected_range_available.
8165    ///
8166    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8167    /// on various ranges that exist at the time of the call.
8168    ///
8169    /// The range must only be modified at one end or the other, but not both.
8170    /// If the range is getting shorter, and the un-covered blocks are not
8171    /// covered by other active ranges, any ongoing DMA to the entire range
8172    /// that's geting shorter may fail in a way that disrupts the entire system
8173    /// (bus lockup or similar), so the caller must ensure that no DMA is
8174    /// ongoing to any portion of a range that is getting shorter, unless the
8175    /// blocks being un-covered by the modification to this range are all
8176    /// covered by other active ranges, in which case no disruption to ongoing
8177    /// DMA will occur.
8178    ///
8179    /// If a range is modified to become <= zero length, the range is deleted.
8180    ///
8181    /// Errors:
8182    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8183    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
8184    ///     that doesn't conform to protected_range_granularity, or old_range
8185    ///     and new_range differ in both begin and end (disallowed).
8186    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8187    ///     with TEE which doesn't generate zx_status_t errors).
8188    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
8189    ///   * other errors are possible, such as from communication failures or
8190    ///     server propagation of zx_status_t failures.
8191    pub fn r#modify_secure_heap_physical_range(
8192        &self,
8193        mut range_modification: &SecureHeapAndRangeModification,
8194    ) -> fidl::client::QueryResponseFut<
8195        SecureMemModifySecureHeapPhysicalRangeResult,
8196        fdomain_client::fidl::FDomainResourceDialect,
8197    > {
8198        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, range_modification)
8199    }
8200
8201    /// Zero a sub-range of a currently-existing physical range added via
8202    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
8203    /// exactly one physical range, and must not overlap with any other
8204    /// physical range.
8205    ///
8206    /// is_covering_range_explicit - When true, the covering range must be one
8207    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
8208    ///     possibly modified since.  When false, the covering range must not
8209    ///     be one of the ranges explicitly created via
8210    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
8211    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
8212    ///     covering range is typically the entire physical range (or a range
8213    ///     which covers even more) of a heap configured by the TEE and whose
8214    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
8215    ///
8216    /// Ongoing DMA is not disrupted by this request.
8217    pub fn r#zero_sub_range(
8218        &self,
8219        mut is_covering_range_explicit: bool,
8220        mut heap_range: &SecureHeapAndRange,
8221    ) -> fidl::client::QueryResponseFut<
8222        SecureMemZeroSubRangeResult,
8223        fdomain_client::fidl::FDomainResourceDialect,
8224    > {
8225        SecureMemProxyInterface::r#zero_sub_range(self, is_covering_range_explicit, heap_range)
8226    }
8227}
8228
8229impl SecureMemProxyInterface for SecureMemProxy {
8230    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
8231        SecureMemGetPhysicalSecureHeapsResult,
8232        fdomain_client::fidl::FDomainResourceDialect,
8233    >;
8234    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
8235        fn _decode(
8236            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8237        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
8238            let _response = fidl::client::decode_transaction_body::<
8239                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
8240                fdomain_client::fidl::FDomainResourceDialect,
8241                0x782319d6ce7fa05,
8242            >(_buf?)?;
8243            Ok(_response.map(|x| x.heaps))
8244        }
8245        self.client.send_query_and_decode::<
8246            fidl::encoding::EmptyPayload,
8247            SecureMemGetPhysicalSecureHeapsResult,
8248        >(
8249            (),
8250            0x782319d6ce7fa05,
8251            fidl::encoding::DynamicFlags::empty(),
8252            _decode,
8253        )
8254    }
8255
8256    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
8257        SecureMemGetPhysicalSecureHeapPropertiesResult,
8258        fdomain_client::fidl::FDomainResourceDialect,
8259    >;
8260    fn r#get_physical_secure_heap_properties(
8261        &self,
8262        mut entire_heap: &SecureHeapAndRange,
8263    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
8264        fn _decode(
8265            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8266        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
8267            let _response = fidl::client::decode_transaction_body::<
8268                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
8269                fdomain_client::fidl::FDomainResourceDialect,
8270                0x26404e23f1271214,
8271            >(_buf?)?;
8272            Ok(_response.map(|x| x.properties))
8273        }
8274        self.client.send_query_and_decode::<
8275            SecureMemGetPhysicalSecureHeapPropertiesRequest,
8276            SecureMemGetPhysicalSecureHeapPropertiesResult,
8277        >(
8278            (entire_heap,),
8279            0x26404e23f1271214,
8280            fidl::encoding::DynamicFlags::empty(),
8281            _decode,
8282        )
8283    }
8284
8285    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8286        SecureMemAddSecureHeapPhysicalRangeResult,
8287        fdomain_client::fidl::FDomainResourceDialect,
8288    >;
8289    fn r#add_secure_heap_physical_range(
8290        &self,
8291        mut heap_range: &SecureHeapAndRange,
8292    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
8293        fn _decode(
8294            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8295        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
8296            let _response = fidl::client::decode_transaction_body::<
8297                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8298                fdomain_client::fidl::FDomainResourceDialect,
8299                0x1ca1abcee8a0b33e,
8300            >(_buf?)?;
8301            Ok(_response.map(|x| x))
8302        }
8303        self.client.send_query_and_decode::<
8304            SecureMemAddSecureHeapPhysicalRangeRequest,
8305            SecureMemAddSecureHeapPhysicalRangeResult,
8306        >(
8307            (heap_range,),
8308            0x1ca1abcee8a0b33e,
8309            fidl::encoding::DynamicFlags::empty(),
8310            _decode,
8311        )
8312    }
8313
8314    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8315        SecureMemDeleteSecureHeapPhysicalRangeResult,
8316        fdomain_client::fidl::FDomainResourceDialect,
8317    >;
8318    fn r#delete_secure_heap_physical_range(
8319        &self,
8320        mut heap_range: &SecureHeapAndRange,
8321    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
8322        fn _decode(
8323            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8324        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
8325            let _response = fidl::client::decode_transaction_body::<
8326                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8327                fdomain_client::fidl::FDomainResourceDialect,
8328                0x728a953e56df92ee,
8329            >(_buf?)?;
8330            Ok(_response.map(|x| x))
8331        }
8332        self.client.send_query_and_decode::<
8333            SecureMemDeleteSecureHeapPhysicalRangeRequest,
8334            SecureMemDeleteSecureHeapPhysicalRangeResult,
8335        >(
8336            (heap_range,),
8337            0x728a953e56df92ee,
8338            fidl::encoding::DynamicFlags::empty(),
8339            _decode,
8340        )
8341    }
8342
8343    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8344        SecureMemModifySecureHeapPhysicalRangeResult,
8345        fdomain_client::fidl::FDomainResourceDialect,
8346    >;
8347    fn r#modify_secure_heap_physical_range(
8348        &self,
8349        mut range_modification: &SecureHeapAndRangeModification,
8350    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
8351        fn _decode(
8352            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8353        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
8354            let _response = fidl::client::decode_transaction_body::<
8355                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8356                fdomain_client::fidl::FDomainResourceDialect,
8357                0x154fbfa3646a890d,
8358            >(_buf?)?;
8359            Ok(_response.map(|x| x))
8360        }
8361        self.client.send_query_and_decode::<
8362            SecureMemModifySecureHeapPhysicalRangeRequest,
8363            SecureMemModifySecureHeapPhysicalRangeResult,
8364        >(
8365            (range_modification,),
8366            0x154fbfa3646a890d,
8367            fidl::encoding::DynamicFlags::empty(),
8368            _decode,
8369        )
8370    }
8371
8372    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
8373        SecureMemZeroSubRangeResult,
8374        fdomain_client::fidl::FDomainResourceDialect,
8375    >;
8376    fn r#zero_sub_range(
8377        &self,
8378        mut is_covering_range_explicit: bool,
8379        mut heap_range: &SecureHeapAndRange,
8380    ) -> Self::ZeroSubRangeResponseFut {
8381        fn _decode(
8382            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8383        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
8384            let _response = fidl::client::decode_transaction_body::<
8385                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8386                fdomain_client::fidl::FDomainResourceDialect,
8387                0x7480f72bb5bc7e5b,
8388            >(_buf?)?;
8389            Ok(_response.map(|x| x))
8390        }
8391        self.client
8392            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
8393                (is_covering_range_explicit, heap_range),
8394                0x7480f72bb5bc7e5b,
8395                fidl::encoding::DynamicFlags::empty(),
8396                _decode,
8397            )
8398    }
8399}
8400
8401pub struct SecureMemEventStream {
8402    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
8403}
8404
8405impl std::marker::Unpin for SecureMemEventStream {}
8406
8407impl futures::stream::FusedStream for SecureMemEventStream {
8408    fn is_terminated(&self) -> bool {
8409        self.event_receiver.is_terminated()
8410    }
8411}
8412
8413impl futures::Stream for SecureMemEventStream {
8414    type Item = Result<SecureMemEvent, fidl::Error>;
8415
8416    fn poll_next(
8417        mut self: std::pin::Pin<&mut Self>,
8418        cx: &mut std::task::Context<'_>,
8419    ) -> std::task::Poll<Option<Self::Item>> {
8420        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8421            &mut self.event_receiver,
8422            cx
8423        )?) {
8424            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
8425            None => std::task::Poll::Ready(None),
8426        }
8427    }
8428}
8429
8430#[derive(Debug)]
8431pub enum SecureMemEvent {}
8432
8433impl SecureMemEvent {
8434    /// Decodes a message buffer as a [`SecureMemEvent`].
8435    fn decode(
8436        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8437    ) -> Result<SecureMemEvent, fidl::Error> {
8438        let (bytes, _handles) = buf.split_mut();
8439        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8440        debug_assert_eq!(tx_header.tx_id, 0);
8441        match tx_header.ordinal {
8442            _ => Err(fidl::Error::UnknownOrdinal {
8443                ordinal: tx_header.ordinal,
8444                protocol_name:
8445                    <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8446            }),
8447        }
8448    }
8449}
8450
8451/// A Stream of incoming requests for fuchsia.sysmem/SecureMem.
8452pub struct SecureMemRequestStream {
8453    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8454    is_terminated: bool,
8455}
8456
8457impl std::marker::Unpin for SecureMemRequestStream {}
8458
8459impl futures::stream::FusedStream for SecureMemRequestStream {
8460    fn is_terminated(&self) -> bool {
8461        self.is_terminated
8462    }
8463}
8464
8465impl fdomain_client::fidl::RequestStream for SecureMemRequestStream {
8466    type Protocol = SecureMemMarker;
8467    type ControlHandle = SecureMemControlHandle;
8468
8469    fn from_channel(channel: fdomain_client::Channel) -> Self {
8470        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8471    }
8472
8473    fn control_handle(&self) -> Self::ControlHandle {
8474        SecureMemControlHandle { inner: self.inner.clone() }
8475    }
8476
8477    fn into_inner(
8478        self,
8479    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
8480    {
8481        (self.inner, self.is_terminated)
8482    }
8483
8484    fn from_inner(
8485        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8486        is_terminated: bool,
8487    ) -> Self {
8488        Self { inner, is_terminated }
8489    }
8490}
8491
8492impl futures::Stream for SecureMemRequestStream {
8493    type Item = Result<SecureMemRequest, fidl::Error>;
8494
8495    fn poll_next(
8496        mut self: std::pin::Pin<&mut Self>,
8497        cx: &mut std::task::Context<'_>,
8498    ) -> std::task::Poll<Option<Self::Item>> {
8499        let this = &mut *self;
8500        if this.inner.check_shutdown(cx) {
8501            this.is_terminated = true;
8502            return std::task::Poll::Ready(None);
8503        }
8504        if this.is_terminated {
8505            panic!("polled SecureMemRequestStream after completion");
8506        }
8507        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
8508            |bytes, handles| {
8509                match this.inner.channel().read_etc(cx, bytes, handles) {
8510                    std::task::Poll::Ready(Ok(())) => {}
8511                    std::task::Poll::Pending => return std::task::Poll::Pending,
8512                    std::task::Poll::Ready(Err(None)) => {
8513                        this.is_terminated = true;
8514                        return std::task::Poll::Ready(None);
8515                    }
8516                    std::task::Poll::Ready(Err(Some(e))) => {
8517                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8518                            e.into(),
8519                        ))));
8520                    }
8521                }
8522
8523                // A message has been received from the channel
8524                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8525
8526                std::task::Poll::Ready(Some(match header.ordinal {
8527                    0x782319d6ce7fa05 => {
8528                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8529                        let mut req = fidl::new_empty!(
8530                            fidl::encoding::EmptyPayload,
8531                            fdomain_client::fidl::FDomainResourceDialect
8532                        );
8533                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8534                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8535                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
8536                            responder: SecureMemGetPhysicalSecureHeapsResponder {
8537                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8538                                tx_id: header.tx_id,
8539                            },
8540                        })
8541                    }
8542                    0x26404e23f1271214 => {
8543                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8544                        let mut req = fidl::new_empty!(
8545                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
8546                            fdomain_client::fidl::FDomainResourceDialect
8547                        );
8548                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
8549                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8550                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
8551                            entire_heap: req.entire_heap,
8552
8553                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
8554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8555                                tx_id: header.tx_id,
8556                            },
8557                        })
8558                    }
8559                    0x1ca1abcee8a0b33e => {
8560                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8561                        let mut req = fidl::new_empty!(
8562                            SecureMemAddSecureHeapPhysicalRangeRequest,
8563                            fdomain_client::fidl::FDomainResourceDialect
8564                        );
8565                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8566                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8567                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
8568                            heap_range: req.heap_range,
8569
8570                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
8571                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8572                                tx_id: header.tx_id,
8573                            },
8574                        })
8575                    }
8576                    0x728a953e56df92ee => {
8577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8578                        let mut req = fidl::new_empty!(
8579                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
8580                            fdomain_client::fidl::FDomainResourceDialect
8581                        );
8582                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8583                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8584                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
8585                            heap_range: req.heap_range,
8586
8587                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
8588                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8589                                tx_id: header.tx_id,
8590                            },
8591                        })
8592                    }
8593                    0x154fbfa3646a890d => {
8594                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8595                        let mut req = fidl::new_empty!(
8596                            SecureMemModifySecureHeapPhysicalRangeRequest,
8597                            fdomain_client::fidl::FDomainResourceDialect
8598                        );
8599                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8600                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8601                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
8602                            range_modification: req.range_modification,
8603
8604                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
8605                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8606                                tx_id: header.tx_id,
8607                            },
8608                        })
8609                    }
8610                    0x7480f72bb5bc7e5b => {
8611                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8612                        let mut req = fidl::new_empty!(
8613                            SecureMemZeroSubRangeRequest,
8614                            fdomain_client::fidl::FDomainResourceDialect
8615                        );
8616                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8617                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8618                        Ok(SecureMemRequest::ZeroSubRange {
8619                            is_covering_range_explicit: req.is_covering_range_explicit,
8620                            heap_range: req.heap_range,
8621
8622                            responder: SecureMemZeroSubRangeResponder {
8623                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8624                                tx_id: header.tx_id,
8625                            },
8626                        })
8627                    }
8628                    _ => Err(fidl::Error::UnknownOrdinal {
8629                        ordinal: header.ordinal,
8630                        protocol_name:
8631                            <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8632                    }),
8633                }))
8634            },
8635        )
8636    }
8637}
8638
8639/// SecureMem
8640///
8641/// The client is sysmem.  The server is securemem driver.
8642///
8643/// TEE - Trusted Execution Environment.
8644///
8645/// REE - Rich Execution Environment.
8646///
8647/// Enables sysmem to call the securemem driver to get any secure heaps
8648/// configured via the TEE (or via the securemem driver), and set any physical
8649/// secure heaps configured via sysmem.
8650///
8651/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
8652/// it starts quite early during boot and can successfully reserve contiguous
8653/// physical memory.  Presently, fixed-location secure heaps are configured via
8654/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
8655/// protocol intentionally doesn't care which heaps are dynamically-allocated
8656/// and which are fixed-location.
8657#[derive(Debug)]
8658pub enum SecureMemRequest {
8659    /// Gets the physical address and length of any secure heap whose physical
8660    /// range is configured via the TEE.
8661    ///
8662    /// Presently, these will be fixed physical addresses and lengths, with the
8663    /// location plumbed via the TEE.
8664    ///
8665    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
8666    /// when there isn't any special heap-specific per-VMO setup or teardown
8667    /// required.
8668    ///
8669    /// The physical range must be secured/protected by the TEE before the
8670    /// securemem driver responds to this request with success.
8671    ///
8672    /// Sysmem should only call this once.  Returning zero heaps is not a
8673    /// failure.
8674    ///
8675    /// Errors:
8676    ///  * ZX_ERR_BAD_STATE - called more than once.
8677    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
8678    ///    with TEE which doesn't generate zx_status_t errors).
8679    ///  * other errors are allowed; any other errors should be treated the same
8680    ///    as ZX_ERR_INTERNAL.
8681    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
8682    /// This request from sysmem to the securemem driver gets the properties of
8683    /// a protected/secure heap.
8684    ///
8685    /// This only handles heaps with a single contiguous physical extent.
8686    ///
8687    /// The heap's entire physical range is indicated in case this request needs
8688    /// some physical space to auto-detect how many ranges are REE-usable.  Any
8689    /// temporary HW protection ranges will be deleted before this request
8690    /// completes.
8691    GetPhysicalSecureHeapProperties {
8692        entire_heap: SecureHeapAndRange,
8693        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
8694    },
8695    /// This request from sysmem to the securemem driver conveys a physical
8696    /// range to add, for a heap whose physical range(s) are set up via
8697    /// sysmem.
8698    ///
8699    /// Only sysmem can call this because only sysmem is handed the client end
8700    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8701    /// securemem driver is the server end of this protocol.
8702    ///
8703    /// The securemem driver must configure all the covered offsets as protected
8704    /// before responding to this message with success.
8705    ///
8706    /// On failure, the securemem driver must ensure the protected range was not
8707    /// created.
8708    ///
8709    /// Sysmem must only call this up to once if dynamic_protection_ranges
8710    /// false.
8711    ///
8712    /// If dynamic_protection_ranges is true, sysmem can call this multiple
8713    /// times as long as the current number of ranges never exceeds
8714    /// max_protected_range_count.
8715    ///
8716    /// The caller must not attempt to add a range that matches an
8717    /// already-existing range.  Added ranges can overlap each other as long as
8718    /// no two ranges match exactly.
8719    ///
8720    /// Errors:
8721    ///   * ZX_ERR_BAD_STATE - called more than once when
8722    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
8723    ///     heap count to exceed max_protected_range_count.
8724    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8725    ///     to protected_range_granularity.
8726    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8727    ///     with TEE which doesn't generate zx_status_t errors).
8728    ///   * other errors are possible, such as from communication failures or
8729    ///     server propagation of zx_status_t failures.
8730    AddSecureHeapPhysicalRange {
8731        heap_range: SecureHeapAndRange,
8732        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
8733    },
8734    /// This request from sysmem to the securemem driver conveys a physical
8735    /// range to delete, for a heap whose physical range(s) are set up via
8736    /// sysmem.
8737    ///
8738    /// Only sysmem can call this because only sysmem is handed the client end
8739    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8740    /// securemem driver is the server end of this protocol.
8741    ///
8742    /// The securemem driver must configure all the covered offsets as not
8743    /// protected before responding to this message with success.
8744    ///
8745    /// On failure, the securemem driver must ensure the protected range was not
8746    /// deleted.
8747    ///
8748    /// Sysmem must not call this if dynamic_protection_ranges false.
8749    ///
8750    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8751    /// on various ranges that exist at the time of the call.
8752    ///
8753    /// If any portion of the range being deleted is not also covered by another
8754    /// protected range, then any ongoing DMA to any part of the entire range
8755    /// may be interrupted / may fail, potentially in a way that's disruptive to
8756    /// the entire system (bus lockup or similar, depending on device details).
8757    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
8758    /// any portion of the range being deleted, unless the caller has other
8759    /// active ranges covering every block of the range being deleted.  Ongoing
8760    /// DMA to/from blocks outside the range being deleted is never impacted by
8761    /// the deletion.
8762    ///
8763    /// Errors:
8764    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8765    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8766    ///     to protected_range_granularity.
8767    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8768    ///     with TEE which doesn't generate zx_status_t errors).
8769    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
8770    ///   * other errors are possible, such as from communication failures or
8771    ///     server propagation of zx_status_t failures.
8772    DeleteSecureHeapPhysicalRange {
8773        heap_range: SecureHeapAndRange,
8774        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
8775    },
8776    /// This request from sysmem to the securemem driver conveys a physical
8777    /// range to modify and its new base and length, for a heap whose physical
8778    /// range(s) are set up via sysmem.
8779    ///
8780    /// Only sysmem can call this because only sysmem is handed the client end
8781    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
8782    /// securemem driver is the server end of this protocol.
8783    ///
8784    /// The securemem driver must configure the range to cover only the new
8785    /// offsets before responding to this message with success.
8786    ///
8787    /// On failure, the securemem driver must ensure the range was not changed.
8788    ///
8789    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
8790    /// must not call this if !is_mod_protected_range_available.
8791    ///
8792    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8793    /// on various ranges that exist at the time of the call.
8794    ///
8795    /// The range must only be modified at one end or the other, but not both.
8796    /// If the range is getting shorter, and the un-covered blocks are not
8797    /// covered by other active ranges, any ongoing DMA to the entire range
8798    /// that's geting shorter may fail in a way that disrupts the entire system
8799    /// (bus lockup or similar), so the caller must ensure that no DMA is
8800    /// ongoing to any portion of a range that is getting shorter, unless the
8801    /// blocks being un-covered by the modification to this range are all
8802    /// covered by other active ranges, in which case no disruption to ongoing
8803    /// DMA will occur.
8804    ///
8805    /// If a range is modified to become <= zero length, the range is deleted.
8806    ///
8807    /// Errors:
8808    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8809    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
8810    ///     that doesn't conform to protected_range_granularity, or old_range
8811    ///     and new_range differ in both begin and end (disallowed).
8812    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
8813    ///     with TEE which doesn't generate zx_status_t errors).
8814    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
8815    ///   * other errors are possible, such as from communication failures or
8816    ///     server propagation of zx_status_t failures.
8817    ModifySecureHeapPhysicalRange {
8818        range_modification: SecureHeapAndRangeModification,
8819        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
8820    },
8821    /// Zero a sub-range of a currently-existing physical range added via
8822    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
8823    /// exactly one physical range, and must not overlap with any other
8824    /// physical range.
8825    ///
8826    /// is_covering_range_explicit - When true, the covering range must be one
8827    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
8828    ///     possibly modified since.  When false, the covering range must not
8829    ///     be one of the ranges explicitly created via
8830    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
8831    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
8832    ///     covering range is typically the entire physical range (or a range
8833    ///     which covers even more) of a heap configured by the TEE and whose
8834    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
8835    ///
8836    /// Ongoing DMA is not disrupted by this request.
8837    ZeroSubRange {
8838        is_covering_range_explicit: bool,
8839        heap_range: SecureHeapAndRange,
8840        responder: SecureMemZeroSubRangeResponder,
8841    },
8842}
8843
8844impl SecureMemRequest {
8845    #[allow(irrefutable_let_patterns)]
8846    pub fn into_get_physical_secure_heaps(
8847        self,
8848    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
8849        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
8850            Some((responder))
8851        } else {
8852            None
8853        }
8854    }
8855
8856    #[allow(irrefutable_let_patterns)]
8857    pub fn into_get_physical_secure_heap_properties(
8858        self,
8859    ) -> Option<(SecureHeapAndRange, SecureMemGetPhysicalSecureHeapPropertiesResponder)> {
8860        if let SecureMemRequest::GetPhysicalSecureHeapProperties { entire_heap, responder } = self {
8861            Some((entire_heap, responder))
8862        } else {
8863            None
8864        }
8865    }
8866
8867    #[allow(irrefutable_let_patterns)]
8868    pub fn into_add_secure_heap_physical_range(
8869        self,
8870    ) -> Option<(SecureHeapAndRange, SecureMemAddSecureHeapPhysicalRangeResponder)> {
8871        if let SecureMemRequest::AddSecureHeapPhysicalRange { heap_range, responder } = self {
8872            Some((heap_range, responder))
8873        } else {
8874            None
8875        }
8876    }
8877
8878    #[allow(irrefutable_let_patterns)]
8879    pub fn into_delete_secure_heap_physical_range(
8880        self,
8881    ) -> Option<(SecureHeapAndRange, SecureMemDeleteSecureHeapPhysicalRangeResponder)> {
8882        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { heap_range, responder } = self {
8883            Some((heap_range, responder))
8884        } else {
8885            None
8886        }
8887    }
8888
8889    #[allow(irrefutable_let_patterns)]
8890    pub fn into_modify_secure_heap_physical_range(
8891        self,
8892    ) -> Option<(SecureHeapAndRangeModification, SecureMemModifySecureHeapPhysicalRangeResponder)>
8893    {
8894        if let SecureMemRequest::ModifySecureHeapPhysicalRange { range_modification, responder } =
8895            self
8896        {
8897            Some((range_modification, responder))
8898        } else {
8899            None
8900        }
8901    }
8902
8903    #[allow(irrefutable_let_patterns)]
8904    pub fn into_zero_sub_range(
8905        self,
8906    ) -> Option<(bool, SecureHeapAndRange, SecureMemZeroSubRangeResponder)> {
8907        if let SecureMemRequest::ZeroSubRange {
8908            is_covering_range_explicit,
8909            heap_range,
8910            responder,
8911        } = self
8912        {
8913            Some((is_covering_range_explicit, heap_range, responder))
8914        } else {
8915            None
8916        }
8917    }
8918
8919    /// Name of the method defined in FIDL
8920    pub fn method_name(&self) -> &'static str {
8921        match *self {
8922            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
8923            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
8924                "get_physical_secure_heap_properties"
8925            }
8926            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
8927            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
8928                "delete_secure_heap_physical_range"
8929            }
8930            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
8931                "modify_secure_heap_physical_range"
8932            }
8933            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
8934        }
8935    }
8936}
8937
8938#[derive(Debug, Clone)]
8939pub struct SecureMemControlHandle {
8940    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8941}
8942
8943impl SecureMemControlHandle {
8944    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8945        self.inner.shutdown_with_epitaph(status.into())
8946    }
8947}
8948
8949impl fdomain_client::fidl::ControlHandle for SecureMemControlHandle {
8950    fn shutdown(&self) {
8951        self.inner.shutdown()
8952    }
8953
8954    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
8955        self.inner.shutdown_with_epitaph(status)
8956    }
8957
8958    fn is_closed(&self) -> bool {
8959        self.inner.channel().is_closed()
8960    }
8961    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
8962        self.inner.channel().on_closed()
8963    }
8964}
8965
8966impl SecureMemControlHandle {}
8967
8968#[must_use = "FIDL methods require a response to be sent"]
8969#[derive(Debug)]
8970pub struct SecureMemGetPhysicalSecureHeapsResponder {
8971    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
8972    tx_id: u32,
8973}
8974
8975/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
8976/// if the responder is dropped without sending a response, so that the client
8977/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8978impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
8979    fn drop(&mut self) {
8980        self.control_handle.shutdown();
8981        // Safety: drops once, never accessed again
8982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8983    }
8984}
8985
8986impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapsResponder {
8987    type ControlHandle = SecureMemControlHandle;
8988
8989    fn control_handle(&self) -> &SecureMemControlHandle {
8990        &self.control_handle
8991    }
8992
8993    fn drop_without_shutdown(mut self) {
8994        // Safety: drops once, never accessed again due to mem::forget
8995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8996        // Prevent Drop from running (which would shut down the channel)
8997        std::mem::forget(self);
8998    }
8999}
9000
9001impl SecureMemGetPhysicalSecureHeapsResponder {
9002    /// Sends a response to the FIDL transaction.
9003    ///
9004    /// Sets the channel to shutdown if an error occurs.
9005    pub fn send(self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
9006        let _result = self.send_raw(result);
9007        if _result.is_err() {
9008            self.control_handle.shutdown();
9009        }
9010        self.drop_without_shutdown();
9011        _result
9012    }
9013
9014    /// Similar to "send" but does not shutdown the channel if an error occurs.
9015    pub fn send_no_shutdown_on_err(
9016        self,
9017        mut result: Result<&SecureHeapsAndRanges, i32>,
9018    ) -> Result<(), fidl::Error> {
9019        let _result = self.send_raw(result);
9020        self.drop_without_shutdown();
9021        _result
9022    }
9023
9024    fn send_raw(&self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
9025        self.control_handle.inner.send::<fidl::encoding::ResultType<
9026            SecureMemGetPhysicalSecureHeapsResponse,
9027            i32,
9028        >>(
9029            result.map(|heaps| (heaps,)),
9030            self.tx_id,
9031            0x782319d6ce7fa05,
9032            fidl::encoding::DynamicFlags::empty(),
9033        )
9034    }
9035}
9036
9037#[must_use = "FIDL methods require a response to be sent"]
9038#[derive(Debug)]
9039pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
9040    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9041    tx_id: u32,
9042}
9043
9044/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9045/// if the responder is dropped without sending a response, so that the client
9046/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9047impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
9048    fn drop(&mut self) {
9049        self.control_handle.shutdown();
9050        // Safety: drops once, never accessed again
9051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9052    }
9053}
9054
9055impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
9056    type ControlHandle = SecureMemControlHandle;
9057
9058    fn control_handle(&self) -> &SecureMemControlHandle {
9059        &self.control_handle
9060    }
9061
9062    fn drop_without_shutdown(mut self) {
9063        // Safety: drops once, never accessed again due to mem::forget
9064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9065        // Prevent Drop from running (which would shut down the channel)
9066        std::mem::forget(self);
9067    }
9068}
9069
9070impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
9071    /// Sends a response to the FIDL transaction.
9072    ///
9073    /// Sets the channel to shutdown if an error occurs.
9074    pub fn send(self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
9075        let _result = self.send_raw(result);
9076        if _result.is_err() {
9077            self.control_handle.shutdown();
9078        }
9079        self.drop_without_shutdown();
9080        _result
9081    }
9082
9083    /// Similar to "send" but does not shutdown the channel if an error occurs.
9084    pub fn send_no_shutdown_on_err(
9085        self,
9086        mut result: Result<&SecureHeapProperties, i32>,
9087    ) -> Result<(), fidl::Error> {
9088        let _result = self.send_raw(result);
9089        self.drop_without_shutdown();
9090        _result
9091    }
9092
9093    fn send_raw(&self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
9094        self.control_handle.inner.send::<fidl::encoding::ResultType<
9095            SecureMemGetPhysicalSecureHeapPropertiesResponse,
9096            i32,
9097        >>(
9098            result.map(|properties| (properties,)),
9099            self.tx_id,
9100            0x26404e23f1271214,
9101            fidl::encoding::DynamicFlags::empty(),
9102        )
9103    }
9104}
9105
9106#[must_use = "FIDL methods require a response to be sent"]
9107#[derive(Debug)]
9108pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
9109    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9110    tx_id: u32,
9111}
9112
9113/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9114/// if the responder is dropped without sending a response, so that the client
9115/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9116impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
9117    fn drop(&mut self) {
9118        self.control_handle.shutdown();
9119        // Safety: drops once, never accessed again
9120        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9121    }
9122}
9123
9124impl fdomain_client::fidl::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
9125    type ControlHandle = SecureMemControlHandle;
9126
9127    fn control_handle(&self) -> &SecureMemControlHandle {
9128        &self.control_handle
9129    }
9130
9131    fn drop_without_shutdown(mut self) {
9132        // Safety: drops once, never accessed again due to mem::forget
9133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9134        // Prevent Drop from running (which would shut down the channel)
9135        std::mem::forget(self);
9136    }
9137}
9138
9139impl SecureMemAddSecureHeapPhysicalRangeResponder {
9140    /// Sends a response to the FIDL transaction.
9141    ///
9142    /// Sets the channel to shutdown if an error occurs.
9143    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9144        let _result = self.send_raw(result);
9145        if _result.is_err() {
9146            self.control_handle.shutdown();
9147        }
9148        self.drop_without_shutdown();
9149        _result
9150    }
9151
9152    /// Similar to "send" but does not shutdown the channel if an error occurs.
9153    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9154        let _result = self.send_raw(result);
9155        self.drop_without_shutdown();
9156        _result
9157    }
9158
9159    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9160        self.control_handle
9161            .inner
9162            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9163                result,
9164                self.tx_id,
9165                0x1ca1abcee8a0b33e,
9166                fidl::encoding::DynamicFlags::empty(),
9167            )
9168    }
9169}
9170
9171#[must_use = "FIDL methods require a response to be sent"]
9172#[derive(Debug)]
9173pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
9174    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9175    tx_id: u32,
9176}
9177
9178/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9179/// if the responder is dropped without sending a response, so that the client
9180/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9181impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
9182    fn drop(&mut self) {
9183        self.control_handle.shutdown();
9184        // Safety: drops once, never accessed again
9185        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9186    }
9187}
9188
9189impl fdomain_client::fidl::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
9190    type ControlHandle = SecureMemControlHandle;
9191
9192    fn control_handle(&self) -> &SecureMemControlHandle {
9193        &self.control_handle
9194    }
9195
9196    fn drop_without_shutdown(mut self) {
9197        // Safety: drops once, never accessed again due to mem::forget
9198        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9199        // Prevent Drop from running (which would shut down the channel)
9200        std::mem::forget(self);
9201    }
9202}
9203
9204impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
9205    /// Sends a response to the FIDL transaction.
9206    ///
9207    /// Sets the channel to shutdown if an error occurs.
9208    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9209        let _result = self.send_raw(result);
9210        if _result.is_err() {
9211            self.control_handle.shutdown();
9212        }
9213        self.drop_without_shutdown();
9214        _result
9215    }
9216
9217    /// Similar to "send" but does not shutdown the channel if an error occurs.
9218    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9219        let _result = self.send_raw(result);
9220        self.drop_without_shutdown();
9221        _result
9222    }
9223
9224    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9225        self.control_handle
9226            .inner
9227            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9228                result,
9229                self.tx_id,
9230                0x728a953e56df92ee,
9231                fidl::encoding::DynamicFlags::empty(),
9232            )
9233    }
9234}
9235
9236#[must_use = "FIDL methods require a response to be sent"]
9237#[derive(Debug)]
9238pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
9239    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9240    tx_id: u32,
9241}
9242
9243/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9244/// if the responder is dropped without sending a response, so that the client
9245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9246impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
9247    fn drop(&mut self) {
9248        self.control_handle.shutdown();
9249        // Safety: drops once, never accessed again
9250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9251    }
9252}
9253
9254impl fdomain_client::fidl::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
9255    type ControlHandle = SecureMemControlHandle;
9256
9257    fn control_handle(&self) -> &SecureMemControlHandle {
9258        &self.control_handle
9259    }
9260
9261    fn drop_without_shutdown(mut self) {
9262        // Safety: drops once, never accessed again due to mem::forget
9263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9264        // Prevent Drop from running (which would shut down the channel)
9265        std::mem::forget(self);
9266    }
9267}
9268
9269impl SecureMemModifySecureHeapPhysicalRangeResponder {
9270    /// Sends a response to the FIDL transaction.
9271    ///
9272    /// Sets the channel to shutdown if an error occurs.
9273    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9274        let _result = self.send_raw(result);
9275        if _result.is_err() {
9276            self.control_handle.shutdown();
9277        }
9278        self.drop_without_shutdown();
9279        _result
9280    }
9281
9282    /// Similar to "send" but does not shutdown the channel if an error occurs.
9283    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9284        let _result = self.send_raw(result);
9285        self.drop_without_shutdown();
9286        _result
9287    }
9288
9289    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9290        self.control_handle
9291            .inner
9292            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9293                result,
9294                self.tx_id,
9295                0x154fbfa3646a890d,
9296                fidl::encoding::DynamicFlags::empty(),
9297            )
9298    }
9299}
9300
9301#[must_use = "FIDL methods require a response to be sent"]
9302#[derive(Debug)]
9303pub struct SecureMemZeroSubRangeResponder {
9304    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9305    tx_id: u32,
9306}
9307
9308/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9309/// if the responder is dropped without sending a response, so that the client
9310/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9311impl std::ops::Drop for SecureMemZeroSubRangeResponder {
9312    fn drop(&mut self) {
9313        self.control_handle.shutdown();
9314        // Safety: drops once, never accessed again
9315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9316    }
9317}
9318
9319impl fdomain_client::fidl::Responder for SecureMemZeroSubRangeResponder {
9320    type ControlHandle = SecureMemControlHandle;
9321
9322    fn control_handle(&self) -> &SecureMemControlHandle {
9323        &self.control_handle
9324    }
9325
9326    fn drop_without_shutdown(mut self) {
9327        // Safety: drops once, never accessed again due to mem::forget
9328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9329        // Prevent Drop from running (which would shut down the channel)
9330        std::mem::forget(self);
9331    }
9332}
9333
9334impl SecureMemZeroSubRangeResponder {
9335    /// Sends a response to the FIDL transaction.
9336    ///
9337    /// Sets the channel to shutdown if an error occurs.
9338    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9339        let _result = self.send_raw(result);
9340        if _result.is_err() {
9341            self.control_handle.shutdown();
9342        }
9343        self.drop_without_shutdown();
9344        _result
9345    }
9346
9347    /// Similar to "send" but does not shutdown the channel if an error occurs.
9348    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9349        let _result = self.send_raw(result);
9350        self.drop_without_shutdown();
9351        _result
9352    }
9353
9354    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9355        self.control_handle
9356            .inner
9357            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9358                result,
9359                self.tx_id,
9360                0x7480f72bb5bc7e5b,
9361                fidl::encoding::DynamicFlags::empty(),
9362            )
9363    }
9364}
9365
9366mod internal {
9367    use super::*;
9368
9369    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
9370        type Borrowed<'a> = &'a mut Self;
9371        fn take_or_borrow<'a>(
9372            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9373        ) -> Self::Borrowed<'a> {
9374            value
9375        }
9376    }
9377
9378    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
9379        type Owned = Self;
9380
9381        #[inline(always)]
9382        fn inline_align(_context: fidl::encoding::Context) -> usize {
9383            4
9384        }
9385
9386        #[inline(always)]
9387        fn inline_size(_context: fidl::encoding::Context) -> usize {
9388            4
9389        }
9390    }
9391
9392    unsafe impl
9393        fidl::encoding::Encode<
9394            AllocatorAllocateNonSharedCollectionRequest,
9395            fdomain_client::fidl::FDomainResourceDialect,
9396        > for &mut AllocatorAllocateNonSharedCollectionRequest
9397    {
9398        #[inline]
9399        unsafe fn encode(
9400            self,
9401            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9402            offset: usize,
9403            _depth: fidl::encoding::Depth,
9404        ) -> fidl::Result<()> {
9405            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
9406            // Delegate to tuple encoding.
9407            fidl::encoding::Encode::<
9408                AllocatorAllocateNonSharedCollectionRequest,
9409                fdomain_client::fidl::FDomainResourceDialect,
9410            >::encode(
9411                (
9412                    <fidl::encoding::Endpoint<
9413                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9414                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9415                        &mut self.collection_request,
9416                    ),
9417                ),
9418                encoder,
9419                offset,
9420                _depth,
9421            )
9422        }
9423    }
9424    unsafe impl<
9425        T0: fidl::encoding::Encode<
9426                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9427                fdomain_client::fidl::FDomainResourceDialect,
9428            >,
9429    >
9430        fidl::encoding::Encode<
9431            AllocatorAllocateNonSharedCollectionRequest,
9432            fdomain_client::fidl::FDomainResourceDialect,
9433        > for (T0,)
9434    {
9435        #[inline]
9436        unsafe fn encode(
9437            self,
9438            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9439            offset: usize,
9440            depth: fidl::encoding::Depth,
9441        ) -> fidl::Result<()> {
9442            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
9443            // Zero out padding regions. There's no need to apply masks
9444            // because the unmasked parts will be overwritten by fields.
9445            // Write the fields.
9446            self.0.encode(encoder, offset + 0, depth)?;
9447            Ok(())
9448        }
9449    }
9450
9451    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9452        for AllocatorAllocateNonSharedCollectionRequest
9453    {
9454        #[inline(always)]
9455        fn new_empty() -> Self {
9456            Self {
9457                collection_request: fidl::new_empty!(
9458                    fidl::encoding::Endpoint<
9459                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9460                    >,
9461                    fdomain_client::fidl::FDomainResourceDialect
9462                ),
9463            }
9464        }
9465
9466        #[inline]
9467        unsafe fn decode(
9468            &mut self,
9469            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9470            offset: usize,
9471            _depth: fidl::encoding::Depth,
9472        ) -> fidl::Result<()> {
9473            decoder.debug_check_bounds::<Self>(offset);
9474            // Verify that padding bytes are zero.
9475            fidl::decode!(
9476                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9477                fdomain_client::fidl::FDomainResourceDialect,
9478                &mut self.collection_request,
9479                decoder,
9480                offset + 0,
9481                _depth
9482            )?;
9483            Ok(())
9484        }
9485    }
9486
9487    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
9488        type Borrowed<'a> = &'a mut Self;
9489        fn take_or_borrow<'a>(
9490            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9491        ) -> Self::Borrowed<'a> {
9492            value
9493        }
9494    }
9495
9496    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
9497        type Owned = Self;
9498
9499        #[inline(always)]
9500        fn inline_align(_context: fidl::encoding::Context) -> usize {
9501            4
9502        }
9503
9504        #[inline(always)]
9505        fn inline_size(_context: fidl::encoding::Context) -> usize {
9506            4
9507        }
9508    }
9509
9510    unsafe impl
9511        fidl::encoding::Encode<
9512            AllocatorAllocateSharedCollectionRequest,
9513            fdomain_client::fidl::FDomainResourceDialect,
9514        > for &mut AllocatorAllocateSharedCollectionRequest
9515    {
9516        #[inline]
9517        unsafe fn encode(
9518            self,
9519            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9520            offset: usize,
9521            _depth: fidl::encoding::Depth,
9522        ) -> fidl::Result<()> {
9523            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
9524            // Delegate to tuple encoding.
9525            fidl::encoding::Encode::<
9526                AllocatorAllocateSharedCollectionRequest,
9527                fdomain_client::fidl::FDomainResourceDialect,
9528            >::encode(
9529                (<fidl::encoding::Endpoint<
9530                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9531                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9532                    &mut self.token_request
9533                ),),
9534                encoder,
9535                offset,
9536                _depth,
9537            )
9538        }
9539    }
9540    unsafe impl<
9541        T0: fidl::encoding::Encode<
9542                fidl::encoding::Endpoint<
9543                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9544                >,
9545                fdomain_client::fidl::FDomainResourceDialect,
9546            >,
9547    >
9548        fidl::encoding::Encode<
9549            AllocatorAllocateSharedCollectionRequest,
9550            fdomain_client::fidl::FDomainResourceDialect,
9551        > for (T0,)
9552    {
9553        #[inline]
9554        unsafe fn encode(
9555            self,
9556            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9557            offset: usize,
9558            depth: fidl::encoding::Depth,
9559        ) -> fidl::Result<()> {
9560            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
9561            // Zero out padding regions. There's no need to apply masks
9562            // because the unmasked parts will be overwritten by fields.
9563            // Write the fields.
9564            self.0.encode(encoder, offset + 0, depth)?;
9565            Ok(())
9566        }
9567    }
9568
9569    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9570        for AllocatorAllocateSharedCollectionRequest
9571    {
9572        #[inline(always)]
9573        fn new_empty() -> Self {
9574            Self {
9575                token_request: fidl::new_empty!(
9576                    fidl::encoding::Endpoint<
9577                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9578                    >,
9579                    fdomain_client::fidl::FDomainResourceDialect
9580                ),
9581            }
9582        }
9583
9584        #[inline]
9585        unsafe fn decode(
9586            &mut self,
9587            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9588            offset: usize,
9589            _depth: fidl::encoding::Depth,
9590        ) -> fidl::Result<()> {
9591            decoder.debug_check_bounds::<Self>(offset);
9592            // Verify that padding bytes are zero.
9593            fidl::decode!(
9594                fidl::encoding::Endpoint<
9595                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9596                >,
9597                fdomain_client::fidl::FDomainResourceDialect,
9598                &mut self.token_request,
9599                decoder,
9600                offset + 0,
9601                _depth
9602            )?;
9603            Ok(())
9604        }
9605    }
9606
9607    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
9608        type Borrowed<'a> = &'a mut Self;
9609        fn take_or_borrow<'a>(
9610            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9611        ) -> Self::Borrowed<'a> {
9612            value
9613        }
9614    }
9615
9616    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
9617        type Owned = Self;
9618
9619        #[inline(always)]
9620        fn inline_align(_context: fidl::encoding::Context) -> usize {
9621            4
9622        }
9623
9624        #[inline(always)]
9625        fn inline_size(_context: fidl::encoding::Context) -> usize {
9626            8
9627        }
9628    }
9629
9630    unsafe impl
9631        fidl::encoding::Encode<
9632            AllocatorBindSharedCollectionRequest,
9633            fdomain_client::fidl::FDomainResourceDialect,
9634        > for &mut AllocatorBindSharedCollectionRequest
9635    {
9636        #[inline]
9637        unsafe fn encode(
9638            self,
9639            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9640            offset: usize,
9641            _depth: fidl::encoding::Depth,
9642        ) -> fidl::Result<()> {
9643            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
9644            // Delegate to tuple encoding.
9645            fidl::encoding::Encode::<
9646                AllocatorBindSharedCollectionRequest,
9647                fdomain_client::fidl::FDomainResourceDialect,
9648            >::encode(
9649                (
9650                    <fidl::encoding::Endpoint<
9651                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9652                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9653                        &mut self.token
9654                    ),
9655                    <fidl::encoding::Endpoint<
9656                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9657                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9658                        &mut self.buffer_collection_request,
9659                    ),
9660                ),
9661                encoder,
9662                offset,
9663                _depth,
9664            )
9665        }
9666    }
9667    unsafe impl<
9668        T0: fidl::encoding::Encode<
9669                fidl::encoding::Endpoint<
9670                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9671                >,
9672                fdomain_client::fidl::FDomainResourceDialect,
9673            >,
9674        T1: fidl::encoding::Encode<
9675                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9676                fdomain_client::fidl::FDomainResourceDialect,
9677            >,
9678    >
9679        fidl::encoding::Encode<
9680            AllocatorBindSharedCollectionRequest,
9681            fdomain_client::fidl::FDomainResourceDialect,
9682        > for (T0, T1)
9683    {
9684        #[inline]
9685        unsafe fn encode(
9686            self,
9687            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9688            offset: usize,
9689            depth: fidl::encoding::Depth,
9690        ) -> fidl::Result<()> {
9691            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
9692            // Zero out padding regions. There's no need to apply masks
9693            // because the unmasked parts will be overwritten by fields.
9694            // Write the fields.
9695            self.0.encode(encoder, offset + 0, depth)?;
9696            self.1.encode(encoder, offset + 4, depth)?;
9697            Ok(())
9698        }
9699    }
9700
9701    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9702        for AllocatorBindSharedCollectionRequest
9703    {
9704        #[inline(always)]
9705        fn new_empty() -> Self {
9706            Self {
9707                token: fidl::new_empty!(
9708                    fidl::encoding::Endpoint<
9709                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9710                    >,
9711                    fdomain_client::fidl::FDomainResourceDialect
9712                ),
9713                buffer_collection_request: fidl::new_empty!(
9714                    fidl::encoding::Endpoint<
9715                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9716                    >,
9717                    fdomain_client::fidl::FDomainResourceDialect
9718                ),
9719            }
9720        }
9721
9722        #[inline]
9723        unsafe fn decode(
9724            &mut self,
9725            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9726            offset: usize,
9727            _depth: fidl::encoding::Depth,
9728        ) -> fidl::Result<()> {
9729            decoder.debug_check_bounds::<Self>(offset);
9730            // Verify that padding bytes are zero.
9731            fidl::decode!(
9732                fidl::encoding::Endpoint<
9733                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9734                >,
9735                fdomain_client::fidl::FDomainResourceDialect,
9736                &mut self.token,
9737                decoder,
9738                offset + 0,
9739                _depth
9740            )?;
9741            fidl::decode!(
9742                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9743                fdomain_client::fidl::FDomainResourceDialect,
9744                &mut self.buffer_collection_request,
9745                decoder,
9746                offset + 4,
9747                _depth
9748            )?;
9749            Ok(())
9750        }
9751    }
9752
9753    impl fidl::encoding::ResourceTypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
9754        type Borrowed<'a> = &'a mut Self;
9755        fn take_or_borrow<'a>(
9756            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9757        ) -> Self::Borrowed<'a> {
9758            value
9759        }
9760    }
9761
9762    unsafe impl fidl::encoding::TypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
9763        type Owned = Self;
9764
9765        #[inline(always)]
9766        fn inline_align(_context: fidl::encoding::Context) -> usize {
9767            4
9768        }
9769
9770        #[inline(always)]
9771        fn inline_size(_context: fidl::encoding::Context) -> usize {
9772            4
9773        }
9774    }
9775
9776    unsafe impl
9777        fidl::encoding::Encode<
9778            AllocatorConnectToSysmem2AllocatorRequest,
9779            fdomain_client::fidl::FDomainResourceDialect,
9780        > for &mut AllocatorConnectToSysmem2AllocatorRequest
9781    {
9782        #[inline]
9783        unsafe fn encode(
9784            self,
9785            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9786            offset: usize,
9787            _depth: fidl::encoding::Depth,
9788        ) -> fidl::Result<()> {
9789            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
9790            // Delegate to tuple encoding.
9791            fidl::encoding::Encode::<
9792                AllocatorConnectToSysmem2AllocatorRequest,
9793                fdomain_client::fidl::FDomainResourceDialect,
9794            >::encode(
9795                (<fidl::encoding::Endpoint<
9796                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9797                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9798                    &mut self.allocator_request,
9799                ),),
9800                encoder,
9801                offset,
9802                _depth,
9803            )
9804        }
9805    }
9806    unsafe impl<
9807        T0: fidl::encoding::Encode<
9808                fidl::encoding::Endpoint<
9809                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9810                >,
9811                fdomain_client::fidl::FDomainResourceDialect,
9812            >,
9813    >
9814        fidl::encoding::Encode<
9815            AllocatorConnectToSysmem2AllocatorRequest,
9816            fdomain_client::fidl::FDomainResourceDialect,
9817        > for (T0,)
9818    {
9819        #[inline]
9820        unsafe fn encode(
9821            self,
9822            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9823            offset: usize,
9824            depth: fidl::encoding::Depth,
9825        ) -> fidl::Result<()> {
9826            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
9827            // Zero out padding regions. There's no need to apply masks
9828            // because the unmasked parts will be overwritten by fields.
9829            // Write the fields.
9830            self.0.encode(encoder, offset + 0, depth)?;
9831            Ok(())
9832        }
9833    }
9834
9835    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9836        for AllocatorConnectToSysmem2AllocatorRequest
9837    {
9838        #[inline(always)]
9839        fn new_empty() -> Self {
9840            Self {
9841                allocator_request: fidl::new_empty!(
9842                    fidl::encoding::Endpoint<
9843                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9844                    >,
9845                    fdomain_client::fidl::FDomainResourceDialect
9846                ),
9847            }
9848        }
9849
9850        #[inline]
9851        unsafe fn decode(
9852            &mut self,
9853            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9854            offset: usize,
9855            _depth: fidl::encoding::Depth,
9856        ) -> fidl::Result<()> {
9857            decoder.debug_check_bounds::<Self>(offset);
9858            // Verify that padding bytes are zero.
9859            fidl::decode!(
9860                fidl::encoding::Endpoint<
9861                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9862                >,
9863                fdomain_client::fidl::FDomainResourceDialect,
9864                &mut self.allocator_request,
9865                decoder,
9866                offset + 0,
9867                _depth
9868            )?;
9869            Ok(())
9870        }
9871    }
9872
9873    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
9874        type Borrowed<'a> = &'a mut Self;
9875        fn take_or_borrow<'a>(
9876            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9877        ) -> Self::Borrowed<'a> {
9878            value
9879        }
9880    }
9881
9882    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
9883        type Owned = Self;
9884
9885        #[inline(always)]
9886        fn inline_align(_context: fidl::encoding::Context) -> usize {
9887            4
9888        }
9889
9890        #[inline(always)]
9891        fn inline_size(_context: fidl::encoding::Context) -> usize {
9892            8
9893        }
9894    }
9895
9896    unsafe impl
9897        fidl::encoding::Encode<
9898            BufferCollectionAttachLifetimeTrackingRequest,
9899            fdomain_client::fidl::FDomainResourceDialect,
9900        > for &mut BufferCollectionAttachLifetimeTrackingRequest
9901    {
9902        #[inline]
9903        unsafe fn encode(
9904            self,
9905            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9906            offset: usize,
9907            _depth: fidl::encoding::Depth,
9908        ) -> fidl::Result<()> {
9909            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
9910            // Delegate to tuple encoding.
9911            fidl::encoding::Encode::<
9912                BufferCollectionAttachLifetimeTrackingRequest,
9913                fdomain_client::fidl::FDomainResourceDialect,
9914            >::encode(
9915                (
9916                    <fidl::encoding::HandleType<
9917                        fdomain_client::EventPair,
9918                        { fidl::ObjectType::EVENTPAIR.into_raw() },
9919                        2147483648,
9920                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9921                        &mut self.server_end
9922                    ),
9923                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffers_remaining),
9924                ),
9925                encoder,
9926                offset,
9927                _depth,
9928            )
9929        }
9930    }
9931    unsafe impl<
9932        T0: fidl::encoding::Encode<
9933                fidl::encoding::HandleType<
9934                    fdomain_client::EventPair,
9935                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9936                    2147483648,
9937                >,
9938                fdomain_client::fidl::FDomainResourceDialect,
9939            >,
9940        T1: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
9941    >
9942        fidl::encoding::Encode<
9943            BufferCollectionAttachLifetimeTrackingRequest,
9944            fdomain_client::fidl::FDomainResourceDialect,
9945        > for (T0, T1)
9946    {
9947        #[inline]
9948        unsafe fn encode(
9949            self,
9950            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9951            offset: usize,
9952            depth: fidl::encoding::Depth,
9953        ) -> fidl::Result<()> {
9954            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
9955            // Zero out padding regions. There's no need to apply masks
9956            // because the unmasked parts will be overwritten by fields.
9957            // Write the fields.
9958            self.0.encode(encoder, offset + 0, depth)?;
9959            self.1.encode(encoder, offset + 4, depth)?;
9960            Ok(())
9961        }
9962    }
9963
9964    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9965        for BufferCollectionAttachLifetimeTrackingRequest
9966    {
9967        #[inline(always)]
9968        fn new_empty() -> Self {
9969            Self {
9970                server_end: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
9971                buffers_remaining: fidl::new_empty!(
9972                    u32,
9973                    fdomain_client::fidl::FDomainResourceDialect
9974                ),
9975            }
9976        }
9977
9978        #[inline]
9979        unsafe fn decode(
9980            &mut self,
9981            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9982            offset: usize,
9983            _depth: fidl::encoding::Depth,
9984        ) -> fidl::Result<()> {
9985            decoder.debug_check_bounds::<Self>(offset);
9986            // Verify that padding bytes are zero.
9987            fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.server_end, decoder, offset + 0, _depth)?;
9988            fidl::decode!(
9989                u32,
9990                fdomain_client::fidl::FDomainResourceDialect,
9991                &mut self.buffers_remaining,
9992                decoder,
9993                offset + 4,
9994                _depth
9995            )?;
9996            Ok(())
9997        }
9998    }
9999
10000    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
10001        type Borrowed<'a> = &'a mut Self;
10002        fn take_or_borrow<'a>(
10003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10004        ) -> Self::Borrowed<'a> {
10005            value
10006        }
10007    }
10008
10009    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
10010        type Owned = Self;
10011
10012        #[inline(always)]
10013        fn inline_align(_context: fidl::encoding::Context) -> usize {
10014            4
10015        }
10016
10017        #[inline(always)]
10018        fn inline_size(_context: fidl::encoding::Context) -> usize {
10019            8
10020        }
10021    }
10022
10023    unsafe impl
10024        fidl::encoding::Encode<
10025            BufferCollectionAttachTokenRequest,
10026            fdomain_client::fidl::FDomainResourceDialect,
10027        > for &mut BufferCollectionAttachTokenRequest
10028    {
10029        #[inline]
10030        unsafe fn encode(
10031            self,
10032            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10033            offset: usize,
10034            _depth: fidl::encoding::Depth,
10035        ) -> fidl::Result<()> {
10036            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
10037            // Delegate to tuple encoding.
10038            fidl::encoding::Encode::<
10039                BufferCollectionAttachTokenRequest,
10040                fdomain_client::fidl::FDomainResourceDialect,
10041            >::encode(
10042                (
10043                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
10044                    <fidl::encoding::Endpoint<
10045                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10046                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10047                        &mut self.token_request,
10048                    ),
10049                ),
10050                encoder,
10051                offset,
10052                _depth,
10053            )
10054        }
10055    }
10056    unsafe impl<
10057        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10058        T1: fidl::encoding::Encode<
10059                fidl::encoding::Endpoint<
10060                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10061                >,
10062                fdomain_client::fidl::FDomainResourceDialect,
10063            >,
10064    >
10065        fidl::encoding::Encode<
10066            BufferCollectionAttachTokenRequest,
10067            fdomain_client::fidl::FDomainResourceDialect,
10068        > for (T0, T1)
10069    {
10070        #[inline]
10071        unsafe fn encode(
10072            self,
10073            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10074            offset: usize,
10075            depth: fidl::encoding::Depth,
10076        ) -> fidl::Result<()> {
10077            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
10078            // Zero out padding regions. There's no need to apply masks
10079            // because the unmasked parts will be overwritten by fields.
10080            // Write the fields.
10081            self.0.encode(encoder, offset + 0, depth)?;
10082            self.1.encode(encoder, offset + 4, depth)?;
10083            Ok(())
10084        }
10085    }
10086
10087    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10088        for BufferCollectionAttachTokenRequest
10089    {
10090        #[inline(always)]
10091        fn new_empty() -> Self {
10092            Self {
10093                rights_attenuation_mask: fidl::new_empty!(
10094                    u32,
10095                    fdomain_client::fidl::FDomainResourceDialect
10096                ),
10097                token_request: fidl::new_empty!(
10098                    fidl::encoding::Endpoint<
10099                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10100                    >,
10101                    fdomain_client::fidl::FDomainResourceDialect
10102                ),
10103            }
10104        }
10105
10106        #[inline]
10107        unsafe fn decode(
10108            &mut self,
10109            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10110            offset: usize,
10111            _depth: fidl::encoding::Depth,
10112        ) -> fidl::Result<()> {
10113            decoder.debug_check_bounds::<Self>(offset);
10114            // Verify that padding bytes are zero.
10115            fidl::decode!(
10116                u32,
10117                fdomain_client::fidl::FDomainResourceDialect,
10118                &mut self.rights_attenuation_mask,
10119                decoder,
10120                offset + 0,
10121                _depth
10122            )?;
10123            fidl::decode!(
10124                fidl::encoding::Endpoint<
10125                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10126                >,
10127                fdomain_client::fidl::FDomainResourceDialect,
10128                &mut self.token_request,
10129                decoder,
10130                offset + 4,
10131                _depth
10132            )?;
10133            Ok(())
10134        }
10135    }
10136
10137    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
10138        type Borrowed<'a> = &'a mut Self;
10139        fn take_or_borrow<'a>(
10140            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10141        ) -> Self::Borrowed<'a> {
10142            value
10143        }
10144    }
10145
10146    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
10147        type Owned = Self;
10148
10149        #[inline(always)]
10150        fn inline_align(_context: fidl::encoding::Context) -> usize {
10151            8
10152        }
10153
10154        #[inline(always)]
10155        fn inline_size(_context: fidl::encoding::Context) -> usize {
10156            352
10157        }
10158    }
10159
10160    unsafe impl
10161        fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
10162        for &mut BufferCollectionInfo
10163    {
10164        #[inline]
10165        unsafe fn encode(
10166            self,
10167            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10168            offset: usize,
10169            _depth: fidl::encoding::Depth,
10170        ) -> fidl::Result<()> {
10171            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
10172            // Delegate to tuple encoding.
10173            fidl::encoding::Encode::<
10174                BufferCollectionInfo,
10175                fdomain_client::fidl::FDomainResourceDialect,
10176            >::encode(
10177                (
10178                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
10179                    <BufferFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
10180                    <fidl::encoding::Array<
10181                        fidl::encoding::Optional<
10182                            fidl::encoding::HandleType<
10183                                fdomain_client::Vmo,
10184                                { fidl::ObjectType::VMO.into_raw() },
10185                                2147483648,
10186                            >,
10187                        >,
10188                        64,
10189                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10190                        &mut self.vmos
10191                    ),
10192                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_size),
10193                ),
10194                encoder,
10195                offset,
10196                _depth,
10197            )
10198        }
10199    }
10200    unsafe impl<
10201        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10202        T1: fidl::encoding::Encode<BufferFormat, fdomain_client::fidl::FDomainResourceDialect>,
10203        T2: fidl::encoding::Encode<
10204                fidl::encoding::Array<
10205                    fidl::encoding::Optional<
10206                        fidl::encoding::HandleType<
10207                            fdomain_client::Vmo,
10208                            { fidl::ObjectType::VMO.into_raw() },
10209                            2147483648,
10210                        >,
10211                    >,
10212                    64,
10213                >,
10214                fdomain_client::fidl::FDomainResourceDialect,
10215            >,
10216        T3: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
10217    > fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
10218        for (T0, T1, T2, T3)
10219    {
10220        #[inline]
10221        unsafe fn encode(
10222            self,
10223            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10224            offset: usize,
10225            depth: fidl::encoding::Depth,
10226        ) -> fidl::Result<()> {
10227            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
10228            // Zero out padding regions. There's no need to apply masks
10229            // because the unmasked parts will be overwritten by fields.
10230            unsafe {
10231                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10232                (ptr as *mut u64).write_unaligned(0);
10233            }
10234            // Write the fields.
10235            self.0.encode(encoder, offset + 0, depth)?;
10236            self.1.encode(encoder, offset + 8, depth)?;
10237            self.2.encode(encoder, offset + 88, depth)?;
10238            self.3.encode(encoder, offset + 344, depth)?;
10239            Ok(())
10240        }
10241    }
10242
10243    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10244        for BufferCollectionInfo
10245    {
10246        #[inline(always)]
10247        fn new_empty() -> Self {
10248            Self {
10249                buffer_count: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
10250                format: fidl::new_empty!(
10251                    BufferFormat,
10252                    fdomain_client::fidl::FDomainResourceDialect
10253                ),
10254                vmos: fidl::new_empty!(
10255                    fidl::encoding::Array<
10256                        fidl::encoding::Optional<
10257                            fidl::encoding::HandleType<
10258                                fdomain_client::Vmo,
10259                                { fidl::ObjectType::VMO.into_raw() },
10260                                2147483648,
10261                            >,
10262                        >,
10263                        64,
10264                    >,
10265                    fdomain_client::fidl::FDomainResourceDialect
10266                ),
10267                vmo_size: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
10268            }
10269        }
10270
10271        #[inline]
10272        unsafe fn decode(
10273            &mut self,
10274            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10275            offset: usize,
10276            _depth: fidl::encoding::Depth,
10277        ) -> fidl::Result<()> {
10278            decoder.debug_check_bounds::<Self>(offset);
10279            // Verify that padding bytes are zero.
10280            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10281            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10282            let mask = 0xffffffff00000000u64;
10283            let maskedval = padval & mask;
10284            if maskedval != 0 {
10285                return Err(fidl::Error::NonZeroPadding {
10286                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10287                });
10288            }
10289            fidl::decode!(
10290                u32,
10291                fdomain_client::fidl::FDomainResourceDialect,
10292                &mut self.buffer_count,
10293                decoder,
10294                offset + 0,
10295                _depth
10296            )?;
10297            fidl::decode!(
10298                BufferFormat,
10299                fdomain_client::fidl::FDomainResourceDialect,
10300                &mut self.format,
10301                decoder,
10302                offset + 8,
10303                _depth
10304            )?;
10305            fidl::decode!(
10306                fidl::encoding::Array<
10307                    fidl::encoding::Optional<
10308                        fidl::encoding::HandleType<
10309                            fdomain_client::Vmo,
10310                            { fidl::ObjectType::VMO.into_raw() },
10311                            2147483648,
10312                        >,
10313                    >,
10314                    64,
10315                >,
10316                fdomain_client::fidl::FDomainResourceDialect,
10317                &mut self.vmos,
10318                decoder,
10319                offset + 88,
10320                _depth
10321            )?;
10322            fidl::decode!(
10323                u64,
10324                fdomain_client::fidl::FDomainResourceDialect,
10325                &mut self.vmo_size,
10326                decoder,
10327                offset + 344,
10328                _depth
10329            )?;
10330            Ok(())
10331        }
10332    }
10333
10334    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo2 {
10335        type Borrowed<'a> = &'a mut Self;
10336        fn take_or_borrow<'a>(
10337            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10338        ) -> Self::Borrowed<'a> {
10339            value
10340        }
10341    }
10342
10343    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo2 {
10344        type Owned = Self;
10345
10346        #[inline(always)]
10347        fn inline_align(_context: fidl::encoding::Context) -> usize {
10348            8
10349        }
10350
10351        #[inline(always)]
10352        fn inline_size(_context: fidl::encoding::Context) -> usize {
10353            1296
10354        }
10355    }
10356
10357    unsafe impl
10358        fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>
10359        for &mut BufferCollectionInfo2
10360    {
10361        #[inline]
10362        unsafe fn encode(
10363            self,
10364            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10365            offset: usize,
10366            _depth: fidl::encoding::Depth,
10367        ) -> fidl::Result<()> {
10368            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
10369            // Delegate to tuple encoding.
10370            fidl::encoding::Encode::<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>::encode(
10371                (
10372                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
10373                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
10374                    <fidl::encoding::Array<VmoBuffer, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
10375                ),
10376                encoder, offset, _depth
10377            )
10378        }
10379    }
10380    unsafe impl<
10381        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10382        T1: fidl::encoding::Encode<SingleBufferSettings, fdomain_client::fidl::FDomainResourceDialect>,
10383        T2: fidl::encoding::Encode<
10384                fidl::encoding::Array<VmoBuffer, 64>,
10385                fdomain_client::fidl::FDomainResourceDialect,
10386            >,
10387    >
10388        fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>
10389        for (T0, T1, T2)
10390    {
10391        #[inline]
10392        unsafe fn encode(
10393            self,
10394            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10395            offset: usize,
10396            depth: fidl::encoding::Depth,
10397        ) -> fidl::Result<()> {
10398            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
10399            // Zero out padding regions. There's no need to apply masks
10400            // because the unmasked parts will be overwritten by fields.
10401            unsafe {
10402                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10403                (ptr as *mut u64).write_unaligned(0);
10404            }
10405            // Write the fields.
10406            self.0.encode(encoder, offset + 0, depth)?;
10407            self.1.encode(encoder, offset + 8, depth)?;
10408            self.2.encode(encoder, offset + 272, depth)?;
10409            Ok(())
10410        }
10411    }
10412
10413    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10414        for BufferCollectionInfo2
10415    {
10416        #[inline(always)]
10417        fn new_empty() -> Self {
10418            Self {
10419                buffer_count: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
10420                settings: fidl::new_empty!(
10421                    SingleBufferSettings,
10422                    fdomain_client::fidl::FDomainResourceDialect
10423                ),
10424                buffers: fidl::new_empty!(fidl::encoding::Array<VmoBuffer, 64>, fdomain_client::fidl::FDomainResourceDialect),
10425            }
10426        }
10427
10428        #[inline]
10429        unsafe fn decode(
10430            &mut self,
10431            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10432            offset: usize,
10433            _depth: fidl::encoding::Depth,
10434        ) -> fidl::Result<()> {
10435            decoder.debug_check_bounds::<Self>(offset);
10436            // Verify that padding bytes are zero.
10437            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10438            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10439            let mask = 0xffffffff00000000u64;
10440            let maskedval = padval & mask;
10441            if maskedval != 0 {
10442                return Err(fidl::Error::NonZeroPadding {
10443                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10444                });
10445            }
10446            fidl::decode!(
10447                u32,
10448                fdomain_client::fidl::FDomainResourceDialect,
10449                &mut self.buffer_count,
10450                decoder,
10451                offset + 0,
10452                _depth
10453            )?;
10454            fidl::decode!(
10455                SingleBufferSettings,
10456                fdomain_client::fidl::FDomainResourceDialect,
10457                &mut self.settings,
10458                decoder,
10459                offset + 8,
10460                _depth
10461            )?;
10462            fidl::decode!(fidl::encoding::Array<VmoBuffer, 64>, fdomain_client::fidl::FDomainResourceDialect, &mut self.buffers, decoder, offset + 272, _depth)?;
10463            Ok(())
10464        }
10465    }
10466
10467    impl fidl::encoding::ResourceTypeMarker
10468        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10469    {
10470        type Borrowed<'a> = &'a mut Self;
10471        fn take_or_borrow<'a>(
10472            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10473        ) -> Self::Borrowed<'a> {
10474            value
10475        }
10476    }
10477
10478    unsafe impl fidl::encoding::TypeMarker
10479        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10480    {
10481        type Owned = Self;
10482
10483        #[inline(always)]
10484        fn inline_align(_context: fidl::encoding::Context) -> usize {
10485            4
10486        }
10487
10488        #[inline(always)]
10489        fn inline_size(_context: fidl::encoding::Context) -> usize {
10490            4
10491        }
10492    }
10493
10494    unsafe impl
10495        fidl::encoding::Encode<
10496            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10497            fdomain_client::fidl::FDomainResourceDialect,
10498        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10499    {
10500        #[inline]
10501        unsafe fn encode(
10502            self,
10503            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10504            offset: usize,
10505            _depth: fidl::encoding::Depth,
10506        ) -> fidl::Result<()> {
10507            encoder
10508                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
10509                    offset,
10510                );
10511            // Delegate to tuple encoding.
10512            fidl::encoding::Encode::<
10513                BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10514                fdomain_client::fidl::FDomainResourceDialect,
10515            >::encode(
10516                (<fidl::encoding::Endpoint<
10517                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10518                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10519                    &mut self.group_request
10520                ),),
10521                encoder,
10522                offset,
10523                _depth,
10524            )
10525        }
10526    }
10527    unsafe impl<
10528        T0: fidl::encoding::Encode<
10529                fidl::encoding::Endpoint<
10530                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10531                >,
10532                fdomain_client::fidl::FDomainResourceDialect,
10533            >,
10534    >
10535        fidl::encoding::Encode<
10536            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10537            fdomain_client::fidl::FDomainResourceDialect,
10538        > for (T0,)
10539    {
10540        #[inline]
10541        unsafe fn encode(
10542            self,
10543            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10544            offset: usize,
10545            depth: fidl::encoding::Depth,
10546        ) -> fidl::Result<()> {
10547            encoder
10548                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
10549                    offset,
10550                );
10551            // Zero out padding regions. There's no need to apply masks
10552            // because the unmasked parts will be overwritten by fields.
10553            // Write the fields.
10554            self.0.encode(encoder, offset + 0, depth)?;
10555            Ok(())
10556        }
10557    }
10558
10559    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10560        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10561    {
10562        #[inline(always)]
10563        fn new_empty() -> Self {
10564            Self {
10565                group_request: fidl::new_empty!(
10566                    fidl::encoding::Endpoint<
10567                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10568                    >,
10569                    fdomain_client::fidl::FDomainResourceDialect
10570                ),
10571            }
10572        }
10573
10574        #[inline]
10575        unsafe fn decode(
10576            &mut self,
10577            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10578            offset: usize,
10579            _depth: fidl::encoding::Depth,
10580        ) -> fidl::Result<()> {
10581            decoder.debug_check_bounds::<Self>(offset);
10582            // Verify that padding bytes are zero.
10583            fidl::decode!(
10584                fidl::encoding::Endpoint<
10585                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10586                >,
10587                fdomain_client::fidl::FDomainResourceDialect,
10588                &mut self.group_request,
10589                decoder,
10590                offset + 0,
10591                _depth
10592            )?;
10593            Ok(())
10594        }
10595    }
10596
10597    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
10598        type Borrowed<'a> = &'a mut Self;
10599        fn take_or_borrow<'a>(
10600            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10601        ) -> Self::Borrowed<'a> {
10602            value
10603        }
10604    }
10605
10606    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
10607        type Owned = Self;
10608
10609        #[inline(always)]
10610        fn inline_align(_context: fidl::encoding::Context) -> usize {
10611            4
10612        }
10613
10614        #[inline(always)]
10615        fn inline_size(_context: fidl::encoding::Context) -> usize {
10616            8
10617        }
10618    }
10619
10620    unsafe impl
10621        fidl::encoding::Encode<
10622            BufferCollectionTokenDuplicateRequest,
10623            fdomain_client::fidl::FDomainResourceDialect,
10624        > for &mut BufferCollectionTokenDuplicateRequest
10625    {
10626        #[inline]
10627        unsafe fn encode(
10628            self,
10629            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10630            offset: usize,
10631            _depth: fidl::encoding::Depth,
10632        ) -> fidl::Result<()> {
10633            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
10634            // Delegate to tuple encoding.
10635            fidl::encoding::Encode::<
10636                BufferCollectionTokenDuplicateRequest,
10637                fdomain_client::fidl::FDomainResourceDialect,
10638            >::encode(
10639                (
10640                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
10641                    <fidl::encoding::Endpoint<
10642                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10643                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10644                        &mut self.token_request,
10645                    ),
10646                ),
10647                encoder,
10648                offset,
10649                _depth,
10650            )
10651        }
10652    }
10653    unsafe impl<
10654        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10655        T1: fidl::encoding::Encode<
10656                fidl::encoding::Endpoint<
10657                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10658                >,
10659                fdomain_client::fidl::FDomainResourceDialect,
10660            >,
10661    >
10662        fidl::encoding::Encode<
10663            BufferCollectionTokenDuplicateRequest,
10664            fdomain_client::fidl::FDomainResourceDialect,
10665        > for (T0, T1)
10666    {
10667        #[inline]
10668        unsafe fn encode(
10669            self,
10670            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10671            offset: usize,
10672            depth: fidl::encoding::Depth,
10673        ) -> fidl::Result<()> {
10674            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
10675            // Zero out padding regions. There's no need to apply masks
10676            // because the unmasked parts will be overwritten by fields.
10677            // Write the fields.
10678            self.0.encode(encoder, offset + 0, depth)?;
10679            self.1.encode(encoder, offset + 4, depth)?;
10680            Ok(())
10681        }
10682    }
10683
10684    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10685        for BufferCollectionTokenDuplicateRequest
10686    {
10687        #[inline(always)]
10688        fn new_empty() -> Self {
10689            Self {
10690                rights_attenuation_mask: fidl::new_empty!(
10691                    u32,
10692                    fdomain_client::fidl::FDomainResourceDialect
10693                ),
10694                token_request: fidl::new_empty!(
10695                    fidl::encoding::Endpoint<
10696                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10697                    >,
10698                    fdomain_client::fidl::FDomainResourceDialect
10699                ),
10700            }
10701        }
10702
10703        #[inline]
10704        unsafe fn decode(
10705            &mut self,
10706            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10707            offset: usize,
10708            _depth: fidl::encoding::Depth,
10709        ) -> fidl::Result<()> {
10710            decoder.debug_check_bounds::<Self>(offset);
10711            // Verify that padding bytes are zero.
10712            fidl::decode!(
10713                u32,
10714                fdomain_client::fidl::FDomainResourceDialect,
10715                &mut self.rights_attenuation_mask,
10716                decoder,
10717                offset + 0,
10718                _depth
10719            )?;
10720            fidl::decode!(
10721                fidl::encoding::Endpoint<
10722                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10723                >,
10724                fdomain_client::fidl::FDomainResourceDialect,
10725                &mut self.token_request,
10726                decoder,
10727                offset + 4,
10728                _depth
10729            )?;
10730            Ok(())
10731        }
10732    }
10733
10734    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
10735        type Borrowed<'a> = &'a mut Self;
10736        fn take_or_borrow<'a>(
10737            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10738        ) -> Self::Borrowed<'a> {
10739            value
10740        }
10741    }
10742
10743    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
10744        type Owned = Self;
10745
10746        #[inline(always)]
10747        fn inline_align(_context: fidl::encoding::Context) -> usize {
10748            8
10749        }
10750
10751        #[inline(always)]
10752        fn inline_size(_context: fidl::encoding::Context) -> usize {
10753            16
10754        }
10755    }
10756
10757    unsafe impl
10758        fidl::encoding::Encode<
10759            BufferCollectionTokenDuplicateSyncResponse,
10760            fdomain_client::fidl::FDomainResourceDialect,
10761        > for &mut BufferCollectionTokenDuplicateSyncResponse
10762    {
10763        #[inline]
10764        unsafe fn encode(
10765            self,
10766            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10767            offset: usize,
10768            _depth: fidl::encoding::Depth,
10769        ) -> fidl::Result<()> {
10770            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
10771            // Delegate to tuple encoding.
10772            fidl::encoding::Encode::<
10773                BufferCollectionTokenDuplicateSyncResponse,
10774                fdomain_client::fidl::FDomainResourceDialect,
10775            >::encode(
10776                (<fidl::encoding::Vector<
10777                    fidl::encoding::Endpoint<
10778                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10779                    >,
10780                    64,
10781                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10782                    &mut self.tokens
10783                ),),
10784                encoder,
10785                offset,
10786                _depth,
10787            )
10788        }
10789    }
10790    unsafe impl<
10791        T0: fidl::encoding::Encode<
10792                fidl::encoding::Vector<
10793                    fidl::encoding::Endpoint<
10794                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10795                    >,
10796                    64,
10797                >,
10798                fdomain_client::fidl::FDomainResourceDialect,
10799            >,
10800    >
10801        fidl::encoding::Encode<
10802            BufferCollectionTokenDuplicateSyncResponse,
10803            fdomain_client::fidl::FDomainResourceDialect,
10804        > for (T0,)
10805    {
10806        #[inline]
10807        unsafe fn encode(
10808            self,
10809            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10810            offset: usize,
10811            depth: fidl::encoding::Depth,
10812        ) -> fidl::Result<()> {
10813            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
10814            // Zero out padding regions. There's no need to apply masks
10815            // because the unmasked parts will be overwritten by fields.
10816            // Write the fields.
10817            self.0.encode(encoder, offset + 0, depth)?;
10818            Ok(())
10819        }
10820    }
10821
10822    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10823        for BufferCollectionTokenDuplicateSyncResponse
10824    {
10825        #[inline(always)]
10826        fn new_empty() -> Self {
10827            Self {
10828                tokens: fidl::new_empty!(
10829                    fidl::encoding::Vector<
10830                        fidl::encoding::Endpoint<
10831                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10832                        >,
10833                        64,
10834                    >,
10835                    fdomain_client::fidl::FDomainResourceDialect
10836                ),
10837            }
10838        }
10839
10840        #[inline]
10841        unsafe fn decode(
10842            &mut self,
10843            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10844            offset: usize,
10845            _depth: fidl::encoding::Depth,
10846        ) -> fidl::Result<()> {
10847            decoder.debug_check_bounds::<Self>(offset);
10848            // Verify that padding bytes are zero.
10849            fidl::decode!(
10850                fidl::encoding::Vector<
10851                    fidl::encoding::Endpoint<
10852                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10853                    >,
10854                    64,
10855                >,
10856                fdomain_client::fidl::FDomainResourceDialect,
10857                &mut self.tokens,
10858                decoder,
10859                offset + 0,
10860                _depth
10861            )?;
10862            Ok(())
10863        }
10864    }
10865
10866    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
10867        type Borrowed<'a> = &'a mut Self;
10868        fn take_or_borrow<'a>(
10869            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10870        ) -> Self::Borrowed<'a> {
10871            value
10872        }
10873    }
10874
10875    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
10876        type Owned = Self;
10877
10878        #[inline(always)]
10879        fn inline_align(_context: fidl::encoding::Context) -> usize {
10880            8
10881        }
10882
10883        #[inline(always)]
10884        fn inline_size(_context: fidl::encoding::Context) -> usize {
10885            16
10886        }
10887    }
10888
10889    unsafe impl
10890        fidl::encoding::Encode<
10891            BufferCollectionTokenGroupCreateChildrenSyncResponse,
10892            fdomain_client::fidl::FDomainResourceDialect,
10893        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
10894    {
10895        #[inline]
10896        unsafe fn encode(
10897            self,
10898            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10899            offset: usize,
10900            _depth: fidl::encoding::Depth,
10901        ) -> fidl::Result<()> {
10902            encoder
10903                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
10904            // Delegate to tuple encoding.
10905            fidl::encoding::Encode::<
10906                BufferCollectionTokenGroupCreateChildrenSyncResponse,
10907                fdomain_client::fidl::FDomainResourceDialect,
10908            >::encode(
10909                (<fidl::encoding::Vector<
10910                    fidl::encoding::Endpoint<
10911                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10912                    >,
10913                    64,
10914                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10915                    &mut self.tokens
10916                ),),
10917                encoder,
10918                offset,
10919                _depth,
10920            )
10921        }
10922    }
10923    unsafe impl<
10924        T0: fidl::encoding::Encode<
10925                fidl::encoding::Vector<
10926                    fidl::encoding::Endpoint<
10927                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10928                    >,
10929                    64,
10930                >,
10931                fdomain_client::fidl::FDomainResourceDialect,
10932            >,
10933    >
10934        fidl::encoding::Encode<
10935            BufferCollectionTokenGroupCreateChildrenSyncResponse,
10936            fdomain_client::fidl::FDomainResourceDialect,
10937        > for (T0,)
10938    {
10939        #[inline]
10940        unsafe fn encode(
10941            self,
10942            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10943            offset: usize,
10944            depth: fidl::encoding::Depth,
10945        ) -> fidl::Result<()> {
10946            encoder
10947                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
10948            // Zero out padding regions. There's no need to apply masks
10949            // because the unmasked parts will be overwritten by fields.
10950            // Write the fields.
10951            self.0.encode(encoder, offset + 0, depth)?;
10952            Ok(())
10953        }
10954    }
10955
10956    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10957        for BufferCollectionTokenGroupCreateChildrenSyncResponse
10958    {
10959        #[inline(always)]
10960        fn new_empty() -> Self {
10961            Self {
10962                tokens: fidl::new_empty!(
10963                    fidl::encoding::Vector<
10964                        fidl::encoding::Endpoint<
10965                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10966                        >,
10967                        64,
10968                    >,
10969                    fdomain_client::fidl::FDomainResourceDialect
10970                ),
10971            }
10972        }
10973
10974        #[inline]
10975        unsafe fn decode(
10976            &mut self,
10977            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10978            offset: usize,
10979            _depth: fidl::encoding::Depth,
10980        ) -> fidl::Result<()> {
10981            decoder.debug_check_bounds::<Self>(offset);
10982            // Verify that padding bytes are zero.
10983            fidl::decode!(
10984                fidl::encoding::Vector<
10985                    fidl::encoding::Endpoint<
10986                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10987                    >,
10988                    64,
10989                >,
10990                fdomain_client::fidl::FDomainResourceDialect,
10991                &mut self.tokens,
10992                decoder,
10993                offset + 0,
10994                _depth
10995            )?;
10996            Ok(())
10997        }
10998    }
10999
11000    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
11001        type Borrowed<'a> = &'a mut Self;
11002        fn take_or_borrow<'a>(
11003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11004        ) -> Self::Borrowed<'a> {
11005            value
11006        }
11007    }
11008
11009    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
11010        type Owned = Self;
11011
11012        #[inline(always)]
11013        fn inline_align(_context: fidl::encoding::Context) -> usize {
11014            8
11015        }
11016
11017        #[inline(always)]
11018        fn inline_size(_context: fidl::encoding::Context) -> usize {
11019            1304
11020        }
11021    }
11022
11023    unsafe impl
11024        fidl::encoding::Encode<
11025            BufferCollectionWaitForBuffersAllocatedResponse,
11026            fdomain_client::fidl::FDomainResourceDialect,
11027        > for &mut BufferCollectionWaitForBuffersAllocatedResponse
11028    {
11029        #[inline]
11030        unsafe fn encode(
11031            self,
11032            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11033            offset: usize,
11034            _depth: fidl::encoding::Depth,
11035        ) -> fidl::Result<()> {
11036            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
11037            // Delegate to tuple encoding.
11038            fidl::encoding::Encode::<
11039                BufferCollectionWaitForBuffersAllocatedResponse,
11040                fdomain_client::fidl::FDomainResourceDialect,
11041            >::encode(
11042                (
11043                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
11044                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11045                        &mut self.buffer_collection_info,
11046                    ),
11047                ),
11048                encoder,
11049                offset,
11050                _depth,
11051            )
11052        }
11053    }
11054    unsafe impl<
11055        T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
11056        T1: fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>,
11057    >
11058        fidl::encoding::Encode<
11059            BufferCollectionWaitForBuffersAllocatedResponse,
11060            fdomain_client::fidl::FDomainResourceDialect,
11061        > for (T0, T1)
11062    {
11063        #[inline]
11064        unsafe fn encode(
11065            self,
11066            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11067            offset: usize,
11068            depth: fidl::encoding::Depth,
11069        ) -> fidl::Result<()> {
11070            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
11071            // Zero out padding regions. There's no need to apply masks
11072            // because the unmasked parts will be overwritten by fields.
11073            unsafe {
11074                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
11075                (ptr as *mut u64).write_unaligned(0);
11076            }
11077            // Write the fields.
11078            self.0.encode(encoder, offset + 0, depth)?;
11079            self.1.encode(encoder, offset + 8, depth)?;
11080            Ok(())
11081        }
11082    }
11083
11084    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11085        for BufferCollectionWaitForBuffersAllocatedResponse
11086    {
11087        #[inline(always)]
11088        fn new_empty() -> Self {
11089            Self {
11090                status: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
11091                buffer_collection_info: fidl::new_empty!(
11092                    BufferCollectionInfo2,
11093                    fdomain_client::fidl::FDomainResourceDialect
11094                ),
11095            }
11096        }
11097
11098        #[inline]
11099        unsafe fn decode(
11100            &mut self,
11101            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11102            offset: usize,
11103            _depth: fidl::encoding::Depth,
11104        ) -> fidl::Result<()> {
11105            decoder.debug_check_bounds::<Self>(offset);
11106            // Verify that padding bytes are zero.
11107            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
11108            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11109            let mask = 0xffffffff00000000u64;
11110            let maskedval = padval & mask;
11111            if maskedval != 0 {
11112                return Err(fidl::Error::NonZeroPadding {
11113                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
11114                });
11115            }
11116            fidl::decode!(
11117                i32,
11118                fdomain_client::fidl::FDomainResourceDialect,
11119                &mut self.status,
11120                decoder,
11121                offset + 0,
11122                _depth
11123            )?;
11124            fidl::decode!(
11125                BufferCollectionInfo2,
11126                fdomain_client::fidl::FDomainResourceDialect,
11127                &mut self.buffer_collection_info,
11128                decoder,
11129                offset + 8,
11130                _depth
11131            )?;
11132            Ok(())
11133        }
11134    }
11135
11136    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
11137        type Borrowed<'a> = &'a mut Self;
11138        fn take_or_borrow<'a>(
11139            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11140        ) -> Self::Borrowed<'a> {
11141            value
11142        }
11143    }
11144
11145    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
11146        type Owned = Self;
11147
11148        #[inline(always)]
11149        fn inline_align(_context: fidl::encoding::Context) -> usize {
11150            4
11151        }
11152
11153        #[inline(always)]
11154        fn inline_size(_context: fidl::encoding::Context) -> usize {
11155            4
11156        }
11157    }
11158
11159    unsafe impl
11160        fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
11161        for &mut NodeGetNodeRefResponse
11162    {
11163        #[inline]
11164        unsafe fn encode(
11165            self,
11166            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11167            offset: usize,
11168            _depth: fidl::encoding::Depth,
11169        ) -> fidl::Result<()> {
11170            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
11171            // Delegate to tuple encoding.
11172            fidl::encoding::Encode::<
11173                NodeGetNodeRefResponse,
11174                fdomain_client::fidl::FDomainResourceDialect,
11175            >::encode(
11176                (<fidl::encoding::HandleType<
11177                    fdomain_client::Event,
11178                    { fidl::ObjectType::EVENT.into_raw() },
11179                    2147483648,
11180                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11181                    &mut self.node_ref
11182                ),),
11183                encoder,
11184                offset,
11185                _depth,
11186            )
11187        }
11188    }
11189    unsafe impl<
11190        T0: fidl::encoding::Encode<
11191                fidl::encoding::HandleType<
11192                    fdomain_client::Event,
11193                    { fidl::ObjectType::EVENT.into_raw() },
11194                    2147483648,
11195                >,
11196                fdomain_client::fidl::FDomainResourceDialect,
11197            >,
11198    >
11199        fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
11200        for (T0,)
11201    {
11202        #[inline]
11203        unsafe fn encode(
11204            self,
11205            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11206            offset: usize,
11207            depth: fidl::encoding::Depth,
11208        ) -> fidl::Result<()> {
11209            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
11210            // Zero out padding regions. There's no need to apply masks
11211            // because the unmasked parts will be overwritten by fields.
11212            // Write the fields.
11213            self.0.encode(encoder, offset + 0, depth)?;
11214            Ok(())
11215        }
11216    }
11217
11218    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11219        for NodeGetNodeRefResponse
11220    {
11221        #[inline(always)]
11222        fn new_empty() -> Self {
11223            Self {
11224                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
11225            }
11226        }
11227
11228        #[inline]
11229        unsafe fn decode(
11230            &mut self,
11231            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11232            offset: usize,
11233            _depth: fidl::encoding::Depth,
11234        ) -> fidl::Result<()> {
11235            decoder.debug_check_bounds::<Self>(offset);
11236            // Verify that padding bytes are zero.
11237            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
11238            Ok(())
11239        }
11240    }
11241
11242    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
11243        type Borrowed<'a> = &'a mut Self;
11244        fn take_or_borrow<'a>(
11245            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11246        ) -> Self::Borrowed<'a> {
11247            value
11248        }
11249    }
11250
11251    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
11252        type Owned = Self;
11253
11254        #[inline(always)]
11255        fn inline_align(_context: fidl::encoding::Context) -> usize {
11256            4
11257        }
11258
11259        #[inline(always)]
11260        fn inline_size(_context: fidl::encoding::Context) -> usize {
11261            4
11262        }
11263    }
11264
11265    unsafe impl
11266        fidl::encoding::Encode<
11267            NodeIsAlternateForRequest,
11268            fdomain_client::fidl::FDomainResourceDialect,
11269        > for &mut NodeIsAlternateForRequest
11270    {
11271        #[inline]
11272        unsafe fn encode(
11273            self,
11274            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11275            offset: usize,
11276            _depth: fidl::encoding::Depth,
11277        ) -> fidl::Result<()> {
11278            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
11279            // Delegate to tuple encoding.
11280            fidl::encoding::Encode::<
11281                NodeIsAlternateForRequest,
11282                fdomain_client::fidl::FDomainResourceDialect,
11283            >::encode(
11284                (<fidl::encoding::HandleType<
11285                    fdomain_client::Event,
11286                    { fidl::ObjectType::EVENT.into_raw() },
11287                    2147483648,
11288                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11289                    &mut self.node_ref
11290                ),),
11291                encoder,
11292                offset,
11293                _depth,
11294            )
11295        }
11296    }
11297    unsafe impl<
11298        T0: fidl::encoding::Encode<
11299                fidl::encoding::HandleType<
11300                    fdomain_client::Event,
11301                    { fidl::ObjectType::EVENT.into_raw() },
11302                    2147483648,
11303                >,
11304                fdomain_client::fidl::FDomainResourceDialect,
11305            >,
11306    >
11307        fidl::encoding::Encode<
11308            NodeIsAlternateForRequest,
11309            fdomain_client::fidl::FDomainResourceDialect,
11310        > for (T0,)
11311    {
11312        #[inline]
11313        unsafe fn encode(
11314            self,
11315            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11316            offset: usize,
11317            depth: fidl::encoding::Depth,
11318        ) -> fidl::Result<()> {
11319            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
11320            // Zero out padding regions. There's no need to apply masks
11321            // because the unmasked parts will be overwritten by fields.
11322            // Write the fields.
11323            self.0.encode(encoder, offset + 0, depth)?;
11324            Ok(())
11325        }
11326    }
11327
11328    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11329        for NodeIsAlternateForRequest
11330    {
11331        #[inline(always)]
11332        fn new_empty() -> Self {
11333            Self {
11334                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
11335            }
11336        }
11337
11338        #[inline]
11339        unsafe fn decode(
11340            &mut self,
11341            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11342            offset: usize,
11343            _depth: fidl::encoding::Depth,
11344        ) -> fidl::Result<()> {
11345            decoder.debug_check_bounds::<Self>(offset);
11346            // Verify that padding bytes are zero.
11347            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
11348            Ok(())
11349        }
11350    }
11351
11352    impl fidl::encoding::ResourceTypeMarker for SingleBufferInfo {
11353        type Borrowed<'a> = &'a mut Self;
11354        fn take_or_borrow<'a>(
11355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11356        ) -> Self::Borrowed<'a> {
11357            value
11358        }
11359    }
11360
11361    unsafe impl fidl::encoding::TypeMarker for SingleBufferInfo {
11362        type Owned = Self;
11363
11364        #[inline(always)]
11365        fn inline_align(_context: fidl::encoding::Context) -> usize {
11366            8
11367        }
11368
11369        #[inline(always)]
11370        fn inline_size(_context: fidl::encoding::Context) -> usize {
11371            280
11372        }
11373    }
11374
11375    unsafe impl
11376        fidl::encoding::Encode<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>
11377        for &mut SingleBufferInfo
11378    {
11379        #[inline]
11380        unsafe fn encode(
11381            self,
11382            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11383            offset: usize,
11384            _depth: fidl::encoding::Depth,
11385        ) -> fidl::Result<()> {
11386            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
11387            // Delegate to tuple encoding.
11388            fidl::encoding::Encode::<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>::encode(
11389                (
11390                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
11391                    <VmoBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
11392                ),
11393                encoder, offset, _depth
11394            )
11395        }
11396    }
11397    unsafe impl<
11398        T0: fidl::encoding::Encode<SingleBufferSettings, fdomain_client::fidl::FDomainResourceDialect>,
11399        T1: fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>,
11400    > fidl::encoding::Encode<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>
11401        for (T0, T1)
11402    {
11403        #[inline]
11404        unsafe fn encode(
11405            self,
11406            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11407            offset: usize,
11408            depth: fidl::encoding::Depth,
11409        ) -> fidl::Result<()> {
11410            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
11411            // Zero out padding regions. There's no need to apply masks
11412            // because the unmasked parts will be overwritten by fields.
11413            // Write the fields.
11414            self.0.encode(encoder, offset + 0, depth)?;
11415            self.1.encode(encoder, offset + 264, depth)?;
11416            Ok(())
11417        }
11418    }
11419
11420    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11421        for SingleBufferInfo
11422    {
11423        #[inline(always)]
11424        fn new_empty() -> Self {
11425            Self {
11426                settings: fidl::new_empty!(
11427                    SingleBufferSettings,
11428                    fdomain_client::fidl::FDomainResourceDialect
11429                ),
11430                buffer: fidl::new_empty!(VmoBuffer, fdomain_client::fidl::FDomainResourceDialect),
11431            }
11432        }
11433
11434        #[inline]
11435        unsafe fn decode(
11436            &mut self,
11437            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11438            offset: usize,
11439            _depth: fidl::encoding::Depth,
11440        ) -> fidl::Result<()> {
11441            decoder.debug_check_bounds::<Self>(offset);
11442            // Verify that padding bytes are zero.
11443            fidl::decode!(
11444                SingleBufferSettings,
11445                fdomain_client::fidl::FDomainResourceDialect,
11446                &mut self.settings,
11447                decoder,
11448                offset + 0,
11449                _depth
11450            )?;
11451            fidl::decode!(
11452                VmoBuffer,
11453                fdomain_client::fidl::FDomainResourceDialect,
11454                &mut self.buffer,
11455                decoder,
11456                offset + 264,
11457                _depth
11458            )?;
11459            Ok(())
11460        }
11461    }
11462
11463    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
11464        type Borrowed<'a> = &'a mut Self;
11465        fn take_or_borrow<'a>(
11466            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11467        ) -> Self::Borrowed<'a> {
11468            value
11469        }
11470    }
11471
11472    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
11473        type Owned = Self;
11474
11475        #[inline(always)]
11476        fn inline_align(_context: fidl::encoding::Context) -> usize {
11477            8
11478        }
11479
11480        #[inline(always)]
11481        fn inline_size(_context: fidl::encoding::Context) -> usize {
11482            16
11483        }
11484    }
11485
11486    unsafe impl fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>
11487        for &mut VmoBuffer
11488    {
11489        #[inline]
11490        unsafe fn encode(
11491            self,
11492            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11493            offset: usize,
11494            _depth: fidl::encoding::Depth,
11495        ) -> fidl::Result<()> {
11496            encoder.debug_check_bounds::<VmoBuffer>(offset);
11497            // Delegate to tuple encoding.
11498            fidl::encoding::Encode::<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>::encode(
11499                (
11500                    <fidl::encoding::Optional<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
11501                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_usable_start),
11502                ),
11503                encoder, offset, _depth
11504            )
11505        }
11506    }
11507    unsafe impl<
11508        T0: fidl::encoding::Encode<
11509                fidl::encoding::Optional<
11510                    fidl::encoding::HandleType<
11511                        fdomain_client::Vmo,
11512                        { fidl::ObjectType::VMO.into_raw() },
11513                        2147483648,
11514                    >,
11515                >,
11516                fdomain_client::fidl::FDomainResourceDialect,
11517            >,
11518        T1: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
11519    > fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect> for (T0, T1)
11520    {
11521        #[inline]
11522        unsafe fn encode(
11523            self,
11524            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11525            offset: usize,
11526            depth: fidl::encoding::Depth,
11527        ) -> fidl::Result<()> {
11528            encoder.debug_check_bounds::<VmoBuffer>(offset);
11529            // Zero out padding regions. There's no need to apply masks
11530            // because the unmasked parts will be overwritten by fields.
11531            unsafe {
11532                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
11533                (ptr as *mut u64).write_unaligned(0);
11534            }
11535            // Write the fields.
11536            self.0.encode(encoder, offset + 0, depth)?;
11537            self.1.encode(encoder, offset + 8, depth)?;
11538            Ok(())
11539        }
11540    }
11541
11542    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {
11543        #[inline(always)]
11544        fn new_empty() -> Self {
11545            Self {
11546                vmo: fidl::new_empty!(
11547                    fidl::encoding::Optional<
11548                        fidl::encoding::HandleType<
11549                            fdomain_client::Vmo,
11550                            { fidl::ObjectType::VMO.into_raw() },
11551                            2147483648,
11552                        >,
11553                    >,
11554                    fdomain_client::fidl::FDomainResourceDialect
11555                ),
11556                vmo_usable_start: fidl::new_empty!(
11557                    u64,
11558                    fdomain_client::fidl::FDomainResourceDialect
11559                ),
11560            }
11561        }
11562
11563        #[inline]
11564        unsafe fn decode(
11565            &mut self,
11566            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11567            offset: usize,
11568            _depth: fidl::encoding::Depth,
11569        ) -> fidl::Result<()> {
11570            decoder.debug_check_bounds::<Self>(offset);
11571            // Verify that padding bytes are zero.
11572            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
11573            let padval = unsafe { (ptr as *const u64).read_unaligned() };
11574            let mask = 0xffffffff00000000u64;
11575            let maskedval = padval & mask;
11576            if maskedval != 0 {
11577                return Err(fidl::Error::NonZeroPadding {
11578                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
11579                });
11580            }
11581            fidl::decode!(
11582                fidl::encoding::Optional<
11583                    fidl::encoding::HandleType<
11584                        fdomain_client::Vmo,
11585                        { fidl::ObjectType::VMO.into_raw() },
11586                        2147483648,
11587                    >,
11588                >,
11589                fdomain_client::fidl::FDomainResourceDialect,
11590                &mut self.vmo,
11591                decoder,
11592                offset + 0,
11593                _depth
11594            )?;
11595            fidl::decode!(
11596                u64,
11597                fdomain_client::fidl::FDomainResourceDialect,
11598                &mut self.vmo_usable_start,
11599                decoder,
11600                offset + 8,
11601                _depth
11602            )?;
11603            Ok(())
11604        }
11605    }
11606
11607    impl BufferCollectionTokenGroupCreateChildRequest {
11608        #[inline(always)]
11609        fn max_ordinal_present(&self) -> u64 {
11610            if let Some(_) = self.rights_attenuation_mask {
11611                return 2;
11612            }
11613            if let Some(_) = self.token_request {
11614                return 1;
11615            }
11616            0
11617        }
11618    }
11619
11620    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
11621        type Borrowed<'a> = &'a mut Self;
11622        fn take_or_borrow<'a>(
11623            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11624        ) -> Self::Borrowed<'a> {
11625            value
11626        }
11627    }
11628
11629    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
11630        type Owned = Self;
11631
11632        #[inline(always)]
11633        fn inline_align(_context: fidl::encoding::Context) -> usize {
11634            8
11635        }
11636
11637        #[inline(always)]
11638        fn inline_size(_context: fidl::encoding::Context) -> usize {
11639            16
11640        }
11641    }
11642
11643    unsafe impl
11644        fidl::encoding::Encode<
11645            BufferCollectionTokenGroupCreateChildRequest,
11646            fdomain_client::fidl::FDomainResourceDialect,
11647        > for &mut BufferCollectionTokenGroupCreateChildRequest
11648    {
11649        unsafe fn encode(
11650            self,
11651            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11652            offset: usize,
11653            mut depth: fidl::encoding::Depth,
11654        ) -> fidl::Result<()> {
11655            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
11656            // Vector header
11657            let max_ordinal: u64 = self.max_ordinal_present();
11658            encoder.write_num(max_ordinal, offset);
11659            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11660            // Calling encoder.out_of_line_offset(0) is not allowed.
11661            if max_ordinal == 0 {
11662                return Ok(());
11663            }
11664            depth.increment()?;
11665            let envelope_size = 8;
11666            let bytes_len = max_ordinal as usize * envelope_size;
11667            #[allow(unused_variables)]
11668            let offset = encoder.out_of_line_offset(bytes_len);
11669            let mut _prev_end_offset: usize = 0;
11670            if 1 > max_ordinal {
11671                return Ok(());
11672            }
11673
11674            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11675            // are envelope_size bytes.
11676            let cur_offset: usize = (1 - 1) * envelope_size;
11677
11678            // Zero reserved fields.
11679            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11680
11681            // Safety:
11682            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11683            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11684            //   envelope_size bytes, there is always sufficient room.
11685            fidl::encoding::encode_in_envelope_optional::<
11686                fidl::encoding::Endpoint<
11687                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11688                >,
11689                fdomain_client::fidl::FDomainResourceDialect,
11690            >(
11691                self.token_request.as_mut().map(
11692                    <fidl::encoding::Endpoint<
11693                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11694                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11695                ),
11696                encoder,
11697                offset + cur_offset,
11698                depth,
11699            )?;
11700
11701            _prev_end_offset = cur_offset + envelope_size;
11702            if 2 > max_ordinal {
11703                return Ok(());
11704            }
11705
11706            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11707            // are envelope_size bytes.
11708            let cur_offset: usize = (2 - 1) * envelope_size;
11709
11710            // Zero reserved fields.
11711            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11712
11713            // Safety:
11714            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11715            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11716            //   envelope_size bytes, there is always sufficient room.
11717            fidl::encoding::encode_in_envelope_optional::<
11718                u32,
11719                fdomain_client::fidl::FDomainResourceDialect,
11720            >(
11721                self.rights_attenuation_mask
11722                    .as_ref()
11723                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
11724                encoder,
11725                offset + cur_offset,
11726                depth,
11727            )?;
11728
11729            _prev_end_offset = cur_offset + envelope_size;
11730
11731            Ok(())
11732        }
11733    }
11734
11735    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11736        for BufferCollectionTokenGroupCreateChildRequest
11737    {
11738        #[inline(always)]
11739        fn new_empty() -> Self {
11740            Self::default()
11741        }
11742
11743        unsafe fn decode(
11744            &mut self,
11745            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11746            offset: usize,
11747            mut depth: fidl::encoding::Depth,
11748        ) -> fidl::Result<()> {
11749            decoder.debug_check_bounds::<Self>(offset);
11750            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11751                None => return Err(fidl::Error::NotNullable),
11752                Some(len) => len,
11753            };
11754            // Calling decoder.out_of_line_offset(0) is not allowed.
11755            if len == 0 {
11756                return Ok(());
11757            };
11758            depth.increment()?;
11759            let envelope_size = 8;
11760            let bytes_len = len * envelope_size;
11761            let offset = decoder.out_of_line_offset(bytes_len)?;
11762            // Decode the envelope for each type.
11763            let mut _next_ordinal_to_read = 0;
11764            let mut next_offset = offset;
11765            let end_offset = offset + bytes_len;
11766            _next_ordinal_to_read += 1;
11767            if next_offset >= end_offset {
11768                return Ok(());
11769            }
11770
11771            // Decode unknown envelopes for gaps in ordinals.
11772            while _next_ordinal_to_read < 1 {
11773                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11774                _next_ordinal_to_read += 1;
11775                next_offset += envelope_size;
11776            }
11777
11778            let next_out_of_line = decoder.next_out_of_line();
11779            let handles_before = decoder.remaining_handles();
11780            if let Some((inlined, num_bytes, num_handles)) =
11781                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11782            {
11783                let member_inline_size = <fidl::encoding::Endpoint<
11784                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11785                > as fidl::encoding::TypeMarker>::inline_size(
11786                    decoder.context
11787                );
11788                if inlined != (member_inline_size <= 4) {
11789                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11790                }
11791                let inner_offset;
11792                let mut inner_depth = depth.clone();
11793                if inlined {
11794                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11795                    inner_offset = next_offset;
11796                } else {
11797                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11798                    inner_depth.increment()?;
11799                }
11800                let val_ref = self.token_request.get_or_insert_with(|| {
11801                    fidl::new_empty!(
11802                        fidl::encoding::Endpoint<
11803                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11804                        >,
11805                        fdomain_client::fidl::FDomainResourceDialect
11806                    )
11807                });
11808                fidl::decode!(
11809                    fidl::encoding::Endpoint<
11810                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11811                    >,
11812                    fdomain_client::fidl::FDomainResourceDialect,
11813                    val_ref,
11814                    decoder,
11815                    inner_offset,
11816                    inner_depth
11817                )?;
11818                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11819                {
11820                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11821                }
11822                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11823                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11824                }
11825            }
11826
11827            next_offset += envelope_size;
11828            _next_ordinal_to_read += 1;
11829            if next_offset >= end_offset {
11830                return Ok(());
11831            }
11832
11833            // Decode unknown envelopes for gaps in ordinals.
11834            while _next_ordinal_to_read < 2 {
11835                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11836                _next_ordinal_to_read += 1;
11837                next_offset += envelope_size;
11838            }
11839
11840            let next_out_of_line = decoder.next_out_of_line();
11841            let handles_before = decoder.remaining_handles();
11842            if let Some((inlined, num_bytes, num_handles)) =
11843                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11844            {
11845                let member_inline_size =
11846                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11847                if inlined != (member_inline_size <= 4) {
11848                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11849                }
11850                let inner_offset;
11851                let mut inner_depth = depth.clone();
11852                if inlined {
11853                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11854                    inner_offset = next_offset;
11855                } else {
11856                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11857                    inner_depth.increment()?;
11858                }
11859                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
11860                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
11861                });
11862                fidl::decode!(
11863                    u32,
11864                    fdomain_client::fidl::FDomainResourceDialect,
11865                    val_ref,
11866                    decoder,
11867                    inner_offset,
11868                    inner_depth
11869                )?;
11870                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11871                {
11872                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11873                }
11874                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11875                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11876                }
11877            }
11878
11879            next_offset += envelope_size;
11880
11881            // Decode the remaining unknown envelopes.
11882            while next_offset < end_offset {
11883                _next_ordinal_to_read += 1;
11884                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11885                next_offset += envelope_size;
11886            }
11887
11888            Ok(())
11889        }
11890    }
11891}