fidl_fuchsia_sysmem/
fidl_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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_sysmem__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AllocatorAllocateNonSharedCollectionRequest {
16    pub collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for AllocatorAllocateNonSharedCollectionRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct AllocatorAllocateSharedCollectionRequest {
26    pub token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for AllocatorAllocateSharedCollectionRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AllocatorBindSharedCollectionRequest {
36    pub token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
37    pub buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for AllocatorBindSharedCollectionRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct AllocatorConnectToSysmem2AllocatorRequest {
47    pub allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
51    for AllocatorConnectToSysmem2AllocatorRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct BufferCollectionAttachLifetimeTrackingRequest {
57    pub server_end: fidl::EventPair,
58    pub buffers_remaining: u32,
59}
60
61impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
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: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
70}
71
72impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
73    for BufferCollectionAttachTokenRequest
74{
75}
76
77#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct BufferCollectionGetAuxBuffersResponse {
79    pub status: i32,
80    pub buffer_collection_info_aux_buffers: BufferCollectionInfo2,
81}
82
83impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
84    for BufferCollectionGetAuxBuffersResponse
85{
86}
87
88/// Deprecated. Use ['fuchsia.sysmem2.BufferCollectionInfo'].
89///
90/// This type is deprecated for new code but still used by some camera code.
91#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct BufferCollectionInfo {
93    /// The number of buffers in the collection.
94    pub buffer_count: u32,
95    /// Describes how the contents of buffers are represented.
96    /// All buffers within the collection have the same format.
97    pub format: BufferFormat,
98    /// VMO handles for each buffer in the collection.
99    /// The VMOs are only present when the buffers are backed by VMOs.
100    ///
101    /// If present, all the VMOs after `buffer_count` are invalid handles.
102    /// All buffer VMO handles have identical size and access rights.
103    /// The VMO access rights are determined based on the usages which the
104    /// client specified when allocating the buffer collection.  For example,
105    /// a client which expressed a read-only usage will receive VMOs without
106    /// write rights.
107    pub vmos: [Option<fidl::Vmo>; 64],
108    /// The size of each VMO provided.
109    /// This property is only present when the buffers are backed by VMOs.
110    pub vmo_size: u64,
111}
112
113impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BufferCollectionInfo {}
114
115/// Information about a buffer collection and its buffers.
116#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
117pub struct BufferCollectionInfo2 {
118    /// The total number of buffers.
119    pub buffer_count: u32,
120    /// These settings apply to all the buffers in the initial buffer allocation.
121    pub settings: SingleBufferSettings,
122    /// VMO handles (and vmo_usable_start offset) for each buffer in the
123    /// collection.
124    ///
125    /// If present, all the VMOs at or after index `buffer_count` are invalid
126    /// (0) handles.
127    ///
128    /// All buffer VMO handles have identical size and access rights.  The size
129    /// is in settings.buffer_settings.size_bytes.
130    ///
131    /// The VMO access rights are determined based on the usages which the
132    /// client specified when allocating the buffer collection.  For example,
133    /// a client which expressed a read-only usage will receive VMOs without
134    /// write rights.  In addition, the rights can be attenuated by the
135    /// parameter to BufferCollectionToken.Duplicate() calls.
136    pub buffers: [VmoBuffer; 64],
137}
138
139impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BufferCollectionInfo2 {}
140
141#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
142pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
143    pub group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
144}
145
146impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
147    for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
148{
149}
150
151#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152pub struct BufferCollectionTokenDuplicateRequest {
153    pub rights_attenuation_mask: u32,
154    pub token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
155}
156
157impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
158    for BufferCollectionTokenDuplicateRequest
159{
160}
161
162#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
163pub struct BufferCollectionTokenDuplicateSyncResponse {
164    pub tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
165}
166
167impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
168    for BufferCollectionTokenDuplicateSyncResponse
169{
170}
171
172#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
173pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
174    pub tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
175}
176
177impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
178    for BufferCollectionTokenGroupCreateChildrenSyncResponse
179{
180}
181
182#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
183pub struct BufferCollectionWaitForBuffersAllocatedResponse {
184    pub status: i32,
185    pub buffer_collection_info: BufferCollectionInfo2,
186}
187
188impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
189    for BufferCollectionWaitForBuffersAllocatedResponse
190{
191}
192
193#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
194pub struct NodeGetNodeRefResponse {
195    pub node_ref: fidl::Event,
196}
197
198impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeGetNodeRefResponse {}
199
200#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
201pub struct NodeIsAlternateForRequest {
202    pub node_ref: fidl::Event,
203}
204
205impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeIsAlternateForRequest {}
206
207/// There is no current replacement for this type, but if your use case needs
208/// incremental buffer allocation within a single collection, please reach out.
209#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
210pub struct SingleBufferInfo {
211    pub settings: SingleBufferSettings,
212    pub buffer: VmoBuffer,
213}
214
215impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SingleBufferInfo {}
216
217#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
218pub struct VmoBuffer {
219    /// The same VMO can be used by more than one CodecBuffer (only of the same
220    /// buffer_lifetime_ordinal), but each vmo handle must be a separate handle.
221    ///
222    /// The vmo field can be 0 if this is a VmoBuffer in BufferCollectionInfo_2
223    /// that's at or beyond BufferCollectionInfo_2.buffer_count.
224    pub vmo: Option<fidl::Vmo>,
225    /// Offset within the VMO of the first usable byte.  Must be < the VMO's
226    /// size in bytes, and leave sufficient room for
227    /// BufferMemorySettings.size_bytes before the end of the VMO.
228    pub vmo_usable_start: u64,
229}
230
231impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VmoBuffer {}
232
233#[derive(Debug, Default, PartialEq)]
234pub struct BufferCollectionTokenGroupCreateChildRequest {
235    /// Must be set.
236    pub token_request: Option<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
237    /// If not set, the default is ZX_RIGHT_SAME_RIGHTS.
238    pub rights_attenuation_mask: Option<u32>,
239    #[doc(hidden)]
240    pub __source_breaking: fidl::marker::SourceBreaking,
241}
242
243impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
244    for BufferCollectionTokenGroupCreateChildRequest
245{
246}
247
248#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
249pub struct AllocatorMarker;
250
251impl fidl::endpoints::ProtocolMarker for AllocatorMarker {
252    type Proxy = AllocatorProxy;
253    type RequestStream = AllocatorRequestStream;
254    #[cfg(target_os = "fuchsia")]
255    type SynchronousProxy = AllocatorSynchronousProxy;
256
257    const DEBUG_NAME: &'static str = "fuchsia.sysmem.Allocator";
258}
259impl fidl::endpoints::DiscoverableProtocolMarker for AllocatorMarker {}
260
261pub trait AllocatorProxyInterface: Send + Sync {
262    fn r#allocate_non_shared_collection(
263        &self,
264        collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
265    ) -> Result<(), fidl::Error>;
266    fn r#allocate_shared_collection(
267        &self,
268        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
269    ) -> Result<(), fidl::Error>;
270    fn r#bind_shared_collection(
271        &self,
272        token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
273        buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
274    ) -> Result<(), fidl::Error>;
275    type ValidateBufferCollectionTokenResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
276        + Send;
277    fn r#validate_buffer_collection_token(
278        &self,
279        token_server_koid: u64,
280    ) -> Self::ValidateBufferCollectionTokenResponseFut;
281    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
282    fn r#connect_to_sysmem2_allocator(
283        &self,
284        allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
285    ) -> Result<(), fidl::Error>;
286}
287#[derive(Debug)]
288#[cfg(target_os = "fuchsia")]
289pub struct AllocatorSynchronousProxy {
290    client: fidl::client::sync::Client,
291}
292
293#[cfg(target_os = "fuchsia")]
294impl fidl::endpoints::SynchronousProxy for AllocatorSynchronousProxy {
295    type Proxy = AllocatorProxy;
296    type Protocol = AllocatorMarker;
297
298    fn from_channel(inner: fidl::Channel) -> Self {
299        Self::new(inner)
300    }
301
302    fn into_channel(self) -> fidl::Channel {
303        self.client.into_channel()
304    }
305
306    fn as_channel(&self) -> &fidl::Channel {
307        self.client.as_channel()
308    }
309}
310
311#[cfg(target_os = "fuchsia")]
312impl AllocatorSynchronousProxy {
313    pub fn new(channel: fidl::Channel) -> Self {
314        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
315        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
316    }
317
318    pub fn into_channel(self) -> fidl::Channel {
319        self.client.into_channel()
320    }
321
322    /// Waits until an event arrives and returns it. It is safe for other
323    /// threads to make concurrent requests while waiting for an event.
324    pub fn wait_for_event(
325        &self,
326        deadline: zx::MonotonicInstant,
327    ) -> Result<AllocatorEvent, fidl::Error> {
328        AllocatorEvent::decode(self.client.wait_for_event(deadline)?)
329    }
330
331    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
332    /// who is also the only participant (from the point of view of sysmem).
333    ///
334    /// This call exists mainly for temp/testing purposes.  This call skips the
335    /// BufferCollectionToken stage, so there's no way to allow another
336    /// participant to specify its constraints.
337    ///
338    /// Real clients are encouraged to use AllocateSharedCollection() instead,
339    /// and to let relevant participants directly convey their own constraints to
340    /// sysmem.
341    ///
342    /// `collection_request` is the server end of the BufferCollection FIDL
343    /// channel.  The client can call SetConstraints() and then
344    /// WaitForBuffersAllocated() on the client end of this channel to specify
345    /// constraints and then determine success/failure and get the
346    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
347    /// keep the client end of this channel open while using the
348    /// BufferCollection, and should notice when this channel closes and stop
349    /// using the BufferCollection ASAP.
350    pub fn r#allocate_non_shared_collection(
351        &self,
352        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
353    ) -> Result<(), fidl::Error> {
354        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
355            (collection_request,),
356            0x20f79299bbb4d2c6,
357            fidl::encoding::DynamicFlags::empty(),
358        )
359    }
360
361    /// Creates a logical BufferCollectionToken which can be shared among
362    /// participants (using BufferCollectionToken.Duplicate()), and then
363    /// converted into a BufferCollection using BindSharedCollection().
364    ///
365    /// Success/failure to populate the BufferCollection with buffers is
366    /// determined via the BufferCollection interface.
367    pub fn r#allocate_shared_collection(
368        &self,
369        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
370    ) -> Result<(), fidl::Error> {
371        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
372            (token_request,),
373            0x7a757a57bfda0f71,
374            fidl::encoding::DynamicFlags::empty(),
375        )
376    }
377
378    /// Convert a BufferCollectionToken into a connection to the logical
379    /// BufferCollection.  The BufferCollection hasn't yet been populated with
380    /// buffers - the participant must first also send SetConstraints() via the
381    /// client end of buffer_collection.
382    ///
383    /// All BufferCollectionToken(s) duplicated from a logical
384    /// BufferCollectionToken created via AllocateSharedCollection() must be
385    /// turned in via BindSharedCollection() before the logical BufferCollection
386    /// will be populated with buffers.
387    ///
388    /// `token` the client endpoint of a channel whose server end was sent to
389    /// sysmem using AllocateSharedCollection or whose server end was sent to
390    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
391    /// "exchanged" for a channel to the logical BufferCollection.
392    ///
393    /// `buffer_collection_request` the server end of a BufferCollection
394    /// channel.  The sender retains the client end as usual.  The
395    /// BufferCollection channel is a single participant's connection to the
396    /// logical BufferCollection.  There typically will be other participants
397    /// with their own BufferCollection channel to the logical BufferCollection.
398    pub fn r#bind_shared_collection(
399        &self,
400        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
401        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
402    ) -> Result<(), fidl::Error> {
403        self.client.send::<AllocatorBindSharedCollectionRequest>(
404            (token, buffer_collection_request),
405            0x146eca7ec46ff4ee,
406            fidl::encoding::DynamicFlags::empty(),
407        )
408    }
409
410    /// Validate that a BufferCollectionToken is known to the sysmem server.
411    ///
412    /// This can be used in cases where BindSharedCollection() won't be called
413    /// until after BufferCollectionToken.Duplicate() +
414    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
415    /// whether an incoming token is valid (so far).
416    ///
417    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
418    /// sysmem risks the Sync() hanging forever.
419    ///
420    /// Given that an incoming token can become invalid at any time if any
421    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
422    /// authors of client code are encouraged to consider not calling
423    /// ValidateBufferCollectionToken() and instead dealing with async failure
424    /// of the BufferCollection.Sync() after all the
425    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
426    /// sending any duplicate tokens to other processes).
427    ///
428    /// Regardless of the result of this call, this call has no effect on the
429    /// token with the referenced koid.
430    ///
431    /// A true result from this call doesn't guarantee that the token remains
432    /// valid for any duration afterwards.
433    ///
434    /// Client code will zx_object_get_info() on the client's token handle,
435    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
436    /// which then gets passed to ValidateBufferCollectionToken().
437    ///
438    /// If ValidateBufferCollectionToken() returns true, the token was known at
439    /// the time the sysmem server processed the call, but may no longer be
440    /// valid/known by the time the client code receives the response.
441    ///
442    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
443    /// at the time the sysmem server processed the call, but the token may
444    /// become known by the time the client code receives the response.  However
445    /// client code is not required to mitigate the possibility that the token
446    /// may become known late, since the source of the token should have synced
447    /// the token to sysmem before sending the token to the client code.
448    ///
449    /// If calling ValidateBufferCollectionToken() fails in some way, there will
450    /// be a zx_status_t from the FIDL layer.
451    ///
452    /// `token_server_koid` the koid of the server end of a channel that might
453    /// be a BufferCollectionToken channel.  This can be obtained from
454    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
455    pub fn r#validate_buffer_collection_token(
456        &self,
457        mut token_server_koid: u64,
458        ___deadline: zx::MonotonicInstant,
459    ) -> Result<bool, fidl::Error> {
460        let _response = self.client.send_query::<
461            AllocatorValidateBufferCollectionTokenRequest,
462            AllocatorValidateBufferCollectionTokenResponse,
463        >(
464            (token_server_koid,),
465            0x575b279b0236faea,
466            fidl::encoding::DynamicFlags::empty(),
467            ___deadline,
468        )?;
469        Ok(_response.is_known)
470    }
471
472    /// Set information about the current client that can be used by sysmem to
473    /// help debug leaking memory and hangs waiting for constraints. |name| can
474    /// be an arbitrary string, but the current process name (see
475    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
476    /// arbitrary id, but the current process ID (see
477    /// fsl::GetCurrentProcessKoid()) is a good default.
478    ///
479    /// This information is propagated to all BufferCollections created using
480    /// BindSharedCollection() or AllocateNonSharedCollection() from this
481    /// allocator. It does not affect BufferCollectionTokens, since they are
482    /// often passed cross-process and should have their names managed manually.
483    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
484        self.client.send::<AllocatorSetDebugClientInfoRequest>(
485            (name, id),
486            0x419f0d5b30728b26,
487            fidl::encoding::DynamicFlags::empty(),
488        )
489    }
490
491    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
492    /// `Allocator`.
493    ///
494    /// This is mainly useful in situations where library code is handed a
495    /// sysmem(1) allocator, but the library code has been updated to use
496    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
497    /// `Allocator` instead, but client code isn't always in the same repo, so
498    /// this message allows the library to still accept the sysmem(1) Allocator
499    /// temporarily.
500    ///
501    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
502    /// `Allocator`.
503    pub fn r#connect_to_sysmem2_allocator(
504        &self,
505        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
506    ) -> Result<(), fidl::Error> {
507        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
508            (allocator_request,),
509            0x13db3e3abac2e24,
510            fidl::encoding::DynamicFlags::empty(),
511        )
512    }
513}
514
515#[cfg(target_os = "fuchsia")]
516impl From<AllocatorSynchronousProxy> for zx::Handle {
517    fn from(value: AllocatorSynchronousProxy) -> Self {
518        value.into_channel().into()
519    }
520}
521
522#[cfg(target_os = "fuchsia")]
523impl From<fidl::Channel> for AllocatorSynchronousProxy {
524    fn from(value: fidl::Channel) -> Self {
525        Self::new(value)
526    }
527}
528
529#[cfg(target_os = "fuchsia")]
530impl fidl::endpoints::FromClient for AllocatorSynchronousProxy {
531    type Protocol = AllocatorMarker;
532
533    fn from_client(value: fidl::endpoints::ClientEnd<AllocatorMarker>) -> Self {
534        Self::new(value.into_channel())
535    }
536}
537
538#[derive(Debug, Clone)]
539pub struct AllocatorProxy {
540    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
541}
542
543impl fidl::endpoints::Proxy for AllocatorProxy {
544    type Protocol = AllocatorMarker;
545
546    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
547        Self::new(inner)
548    }
549
550    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
551        self.client.into_channel().map_err(|client| Self { client })
552    }
553
554    fn as_channel(&self) -> &::fidl::AsyncChannel {
555        self.client.as_channel()
556    }
557}
558
559impl AllocatorProxy {
560    /// Create a new Proxy for fuchsia.sysmem/Allocator.
561    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
562        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
563        Self { client: fidl::client::Client::new(channel, protocol_name) }
564    }
565
566    /// Get a Stream of events from the remote end of the protocol.
567    ///
568    /// # Panics
569    ///
570    /// Panics if the event stream was already taken.
571    pub fn take_event_stream(&self) -> AllocatorEventStream {
572        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
573    }
574
575    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
576    /// who is also the only participant (from the point of view of sysmem).
577    ///
578    /// This call exists mainly for temp/testing purposes.  This call skips the
579    /// BufferCollectionToken stage, so there's no way to allow another
580    /// participant to specify its constraints.
581    ///
582    /// Real clients are encouraged to use AllocateSharedCollection() instead,
583    /// and to let relevant participants directly convey their own constraints to
584    /// sysmem.
585    ///
586    /// `collection_request` is the server end of the BufferCollection FIDL
587    /// channel.  The client can call SetConstraints() and then
588    /// WaitForBuffersAllocated() on the client end of this channel to specify
589    /// constraints and then determine success/failure and get the
590    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
591    /// keep the client end of this channel open while using the
592    /// BufferCollection, and should notice when this channel closes and stop
593    /// using the BufferCollection ASAP.
594    pub fn r#allocate_non_shared_collection(
595        &self,
596        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
597    ) -> Result<(), fidl::Error> {
598        AllocatorProxyInterface::r#allocate_non_shared_collection(self, collection_request)
599    }
600
601    /// Creates a logical BufferCollectionToken which can be shared among
602    /// participants (using BufferCollectionToken.Duplicate()), and then
603    /// converted into a BufferCollection using BindSharedCollection().
604    ///
605    /// Success/failure to populate the BufferCollection with buffers is
606    /// determined via the BufferCollection interface.
607    pub fn r#allocate_shared_collection(
608        &self,
609        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
610    ) -> Result<(), fidl::Error> {
611        AllocatorProxyInterface::r#allocate_shared_collection(self, token_request)
612    }
613
614    /// Convert a BufferCollectionToken into a connection to the logical
615    /// BufferCollection.  The BufferCollection hasn't yet been populated with
616    /// buffers - the participant must first also send SetConstraints() via the
617    /// client end of buffer_collection.
618    ///
619    /// All BufferCollectionToken(s) duplicated from a logical
620    /// BufferCollectionToken created via AllocateSharedCollection() must be
621    /// turned in via BindSharedCollection() before the logical BufferCollection
622    /// will be populated with buffers.
623    ///
624    /// `token` the client endpoint of a channel whose server end was sent to
625    /// sysmem using AllocateSharedCollection or whose server end was sent to
626    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
627    /// "exchanged" for a channel to the logical BufferCollection.
628    ///
629    /// `buffer_collection_request` the server end of a BufferCollection
630    /// channel.  The sender retains the client end as usual.  The
631    /// BufferCollection channel is a single participant's connection to the
632    /// logical BufferCollection.  There typically will be other participants
633    /// with their own BufferCollection channel to the logical BufferCollection.
634    pub fn r#bind_shared_collection(
635        &self,
636        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
637        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
638    ) -> Result<(), fidl::Error> {
639        AllocatorProxyInterface::r#bind_shared_collection(self, token, buffer_collection_request)
640    }
641
642    /// Validate that a BufferCollectionToken is known to the sysmem server.
643    ///
644    /// This can be used in cases where BindSharedCollection() won't be called
645    /// until after BufferCollectionToken.Duplicate() +
646    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
647    /// whether an incoming token is valid (so far).
648    ///
649    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
650    /// sysmem risks the Sync() hanging forever.
651    ///
652    /// Given that an incoming token can become invalid at any time if any
653    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
654    /// authors of client code are encouraged to consider not calling
655    /// ValidateBufferCollectionToken() and instead dealing with async failure
656    /// of the BufferCollection.Sync() after all the
657    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
658    /// sending any duplicate tokens to other processes).
659    ///
660    /// Regardless of the result of this call, this call has no effect on the
661    /// token with the referenced koid.
662    ///
663    /// A true result from this call doesn't guarantee that the token remains
664    /// valid for any duration afterwards.
665    ///
666    /// Client code will zx_object_get_info() on the client's token handle,
667    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
668    /// which then gets passed to ValidateBufferCollectionToken().
669    ///
670    /// If ValidateBufferCollectionToken() returns true, the token was known at
671    /// the time the sysmem server processed the call, but may no longer be
672    /// valid/known by the time the client code receives the response.
673    ///
674    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
675    /// at the time the sysmem server processed the call, but the token may
676    /// become known by the time the client code receives the response.  However
677    /// client code is not required to mitigate the possibility that the token
678    /// may become known late, since the source of the token should have synced
679    /// the token to sysmem before sending the token to the client code.
680    ///
681    /// If calling ValidateBufferCollectionToken() fails in some way, there will
682    /// be a zx_status_t from the FIDL layer.
683    ///
684    /// `token_server_koid` the koid of the server end of a channel that might
685    /// be a BufferCollectionToken channel.  This can be obtained from
686    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
687    pub fn r#validate_buffer_collection_token(
688        &self,
689        mut token_server_koid: u64,
690    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
691        AllocatorProxyInterface::r#validate_buffer_collection_token(self, token_server_koid)
692    }
693
694    /// Set information about the current client that can be used by sysmem to
695    /// help debug leaking memory and hangs waiting for constraints. |name| can
696    /// be an arbitrary string, but the current process name (see
697    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
698    /// arbitrary id, but the current process ID (see
699    /// fsl::GetCurrentProcessKoid()) is a good default.
700    ///
701    /// This information is propagated to all BufferCollections created using
702    /// BindSharedCollection() or AllocateNonSharedCollection() from this
703    /// allocator. It does not affect BufferCollectionTokens, since they are
704    /// often passed cross-process and should have their names managed manually.
705    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
706        AllocatorProxyInterface::r#set_debug_client_info(self, name, id)
707    }
708
709    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
710    /// `Allocator`.
711    ///
712    /// This is mainly useful in situations where library code is handed a
713    /// sysmem(1) allocator, but the library code has been updated to use
714    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
715    /// `Allocator` instead, but client code isn't always in the same repo, so
716    /// this message allows the library to still accept the sysmem(1) Allocator
717    /// temporarily.
718    ///
719    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
720    /// `Allocator`.
721    pub fn r#connect_to_sysmem2_allocator(
722        &self,
723        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
724    ) -> Result<(), fidl::Error> {
725        AllocatorProxyInterface::r#connect_to_sysmem2_allocator(self, allocator_request)
726    }
727}
728
729impl AllocatorProxyInterface for AllocatorProxy {
730    fn r#allocate_non_shared_collection(
731        &self,
732        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
733    ) -> Result<(), fidl::Error> {
734        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
735            (collection_request,),
736            0x20f79299bbb4d2c6,
737            fidl::encoding::DynamicFlags::empty(),
738        )
739    }
740
741    fn r#allocate_shared_collection(
742        &self,
743        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
744    ) -> Result<(), fidl::Error> {
745        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
746            (token_request,),
747            0x7a757a57bfda0f71,
748            fidl::encoding::DynamicFlags::empty(),
749        )
750    }
751
752    fn r#bind_shared_collection(
753        &self,
754        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
755        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
756    ) -> Result<(), fidl::Error> {
757        self.client.send::<AllocatorBindSharedCollectionRequest>(
758            (token, buffer_collection_request),
759            0x146eca7ec46ff4ee,
760            fidl::encoding::DynamicFlags::empty(),
761        )
762    }
763
764    type ValidateBufferCollectionTokenResponseFut =
765        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
766    fn r#validate_buffer_collection_token(
767        &self,
768        mut token_server_koid: u64,
769    ) -> Self::ValidateBufferCollectionTokenResponseFut {
770        fn _decode(
771            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
772        ) -> Result<bool, fidl::Error> {
773            let _response = fidl::client::decode_transaction_body::<
774                AllocatorValidateBufferCollectionTokenResponse,
775                fidl::encoding::DefaultFuchsiaResourceDialect,
776                0x575b279b0236faea,
777            >(_buf?)?;
778            Ok(_response.is_known)
779        }
780        self.client.send_query_and_decode::<AllocatorValidateBufferCollectionTokenRequest, bool>(
781            (token_server_koid,),
782            0x575b279b0236faea,
783            fidl::encoding::DynamicFlags::empty(),
784            _decode,
785        )
786    }
787
788    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
789        self.client.send::<AllocatorSetDebugClientInfoRequest>(
790            (name, id),
791            0x419f0d5b30728b26,
792            fidl::encoding::DynamicFlags::empty(),
793        )
794    }
795
796    fn r#connect_to_sysmem2_allocator(
797        &self,
798        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
799    ) -> Result<(), fidl::Error> {
800        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
801            (allocator_request,),
802            0x13db3e3abac2e24,
803            fidl::encoding::DynamicFlags::empty(),
804        )
805    }
806}
807
808pub struct AllocatorEventStream {
809    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
810}
811
812impl std::marker::Unpin for AllocatorEventStream {}
813
814impl futures::stream::FusedStream for AllocatorEventStream {
815    fn is_terminated(&self) -> bool {
816        self.event_receiver.is_terminated()
817    }
818}
819
820impl futures::Stream for AllocatorEventStream {
821    type Item = Result<AllocatorEvent, fidl::Error>;
822
823    fn poll_next(
824        mut self: std::pin::Pin<&mut Self>,
825        cx: &mut std::task::Context<'_>,
826    ) -> std::task::Poll<Option<Self::Item>> {
827        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
828            &mut self.event_receiver,
829            cx
830        )?) {
831            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
832            None => std::task::Poll::Ready(None),
833        }
834    }
835}
836
837#[derive(Debug)]
838pub enum AllocatorEvent {}
839
840impl AllocatorEvent {
841    /// Decodes a message buffer as a [`AllocatorEvent`].
842    fn decode(
843        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
844    ) -> Result<AllocatorEvent, fidl::Error> {
845        let (bytes, _handles) = buf.split_mut();
846        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
847        debug_assert_eq!(tx_header.tx_id, 0);
848        match tx_header.ordinal {
849            _ => Err(fidl::Error::UnknownOrdinal {
850                ordinal: tx_header.ordinal,
851                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
852            }),
853        }
854    }
855}
856
857/// A Stream of incoming requests for fuchsia.sysmem/Allocator.
858pub struct AllocatorRequestStream {
859    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
860    is_terminated: bool,
861}
862
863impl std::marker::Unpin for AllocatorRequestStream {}
864
865impl futures::stream::FusedStream for AllocatorRequestStream {
866    fn is_terminated(&self) -> bool {
867        self.is_terminated
868    }
869}
870
871impl fidl::endpoints::RequestStream for AllocatorRequestStream {
872    type Protocol = AllocatorMarker;
873    type ControlHandle = AllocatorControlHandle;
874
875    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
876        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
877    }
878
879    fn control_handle(&self) -> Self::ControlHandle {
880        AllocatorControlHandle { inner: self.inner.clone() }
881    }
882
883    fn into_inner(
884        self,
885    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
886    {
887        (self.inner, self.is_terminated)
888    }
889
890    fn from_inner(
891        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
892        is_terminated: bool,
893    ) -> Self {
894        Self { inner, is_terminated }
895    }
896}
897
898impl futures::Stream for AllocatorRequestStream {
899    type Item = Result<AllocatorRequest, fidl::Error>;
900
901    fn poll_next(
902        mut self: std::pin::Pin<&mut Self>,
903        cx: &mut std::task::Context<'_>,
904    ) -> std::task::Poll<Option<Self::Item>> {
905        let this = &mut *self;
906        if this.inner.check_shutdown(cx) {
907            this.is_terminated = true;
908            return std::task::Poll::Ready(None);
909        }
910        if this.is_terminated {
911            panic!("polled AllocatorRequestStream after completion");
912        }
913        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
914            |bytes, handles| {
915                match this.inner.channel().read_etc(cx, bytes, handles) {
916                    std::task::Poll::Ready(Ok(())) => {}
917                    std::task::Poll::Pending => return std::task::Poll::Pending,
918                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
919                        this.is_terminated = true;
920                        return std::task::Poll::Ready(None);
921                    }
922                    std::task::Poll::Ready(Err(e)) => {
923                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
924                            e.into(),
925                        ))))
926                    }
927                }
928
929                // A message has been received from the channel
930                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
931
932                std::task::Poll::Ready(Some(match header.ordinal {
933                    0x20f79299bbb4d2c6 => {
934                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
935                        let mut req = fidl::new_empty!(
936                            AllocatorAllocateNonSharedCollectionRequest,
937                            fidl::encoding::DefaultFuchsiaResourceDialect
938                        );
939                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
940                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
941                        Ok(AllocatorRequest::AllocateNonSharedCollection {
942                            collection_request: req.collection_request,
943
944                            control_handle,
945                        })
946                    }
947                    0x7a757a57bfda0f71 => {
948                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
949                        let mut req = fidl::new_empty!(
950                            AllocatorAllocateSharedCollectionRequest,
951                            fidl::encoding::DefaultFuchsiaResourceDialect
952                        );
953                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
954                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
955                        Ok(AllocatorRequest::AllocateSharedCollection {
956                            token_request: req.token_request,
957
958                            control_handle,
959                        })
960                    }
961                    0x146eca7ec46ff4ee => {
962                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
963                        let mut req = fidl::new_empty!(
964                            AllocatorBindSharedCollectionRequest,
965                            fidl::encoding::DefaultFuchsiaResourceDialect
966                        );
967                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
968                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
969                        Ok(AllocatorRequest::BindSharedCollection {
970                            token: req.token,
971                            buffer_collection_request: req.buffer_collection_request,
972
973                            control_handle,
974                        })
975                    }
976                    0x575b279b0236faea => {
977                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
978                        let mut req = fidl::new_empty!(
979                            AllocatorValidateBufferCollectionTokenRequest,
980                            fidl::encoding::DefaultFuchsiaResourceDialect
981                        );
982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
983                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
984                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
985                            token_server_koid: req.token_server_koid,
986
987                            responder: AllocatorValidateBufferCollectionTokenResponder {
988                                control_handle: std::mem::ManuallyDrop::new(control_handle),
989                                tx_id: header.tx_id,
990                            },
991                        })
992                    }
993                    0x419f0d5b30728b26 => {
994                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
995                        let mut req = fidl::new_empty!(
996                            AllocatorSetDebugClientInfoRequest,
997                            fidl::encoding::DefaultFuchsiaResourceDialect
998                        );
999                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1000                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1001                        Ok(AllocatorRequest::SetDebugClientInfo {
1002                            name: req.name,
1003                            id: req.id,
1004
1005                            control_handle,
1006                        })
1007                    }
1008                    0x13db3e3abac2e24 => {
1009                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1010                        let mut req = fidl::new_empty!(
1011                            AllocatorConnectToSysmem2AllocatorRequest,
1012                            fidl::encoding::DefaultFuchsiaResourceDialect
1013                        );
1014                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorConnectToSysmem2AllocatorRequest>(&header, _body_bytes, handles, &mut req)?;
1015                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1016                        Ok(AllocatorRequest::ConnectToSysmem2Allocator {
1017                            allocator_request: req.allocator_request,
1018
1019                            control_handle,
1020                        })
1021                    }
1022                    _ => Err(fidl::Error::UnknownOrdinal {
1023                        ordinal: header.ordinal,
1024                        protocol_name:
1025                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1026                    }),
1027                }))
1028            },
1029        )
1030    }
1031}
1032
1033/// Allocates system memory buffers.
1034#[derive(Debug)]
1035pub enum AllocatorRequest {
1036    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
1037    /// who is also the only participant (from the point of view of sysmem).
1038    ///
1039    /// This call exists mainly for temp/testing purposes.  This call skips the
1040    /// BufferCollectionToken stage, so there's no way to allow another
1041    /// participant to specify its constraints.
1042    ///
1043    /// Real clients are encouraged to use AllocateSharedCollection() instead,
1044    /// and to let relevant participants directly convey their own constraints to
1045    /// sysmem.
1046    ///
1047    /// `collection_request` is the server end of the BufferCollection FIDL
1048    /// channel.  The client can call SetConstraints() and then
1049    /// WaitForBuffersAllocated() on the client end of this channel to specify
1050    /// constraints and then determine success/failure and get the
1051    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
1052    /// keep the client end of this channel open while using the
1053    /// BufferCollection, and should notice when this channel closes and stop
1054    /// using the BufferCollection ASAP.
1055    AllocateNonSharedCollection {
1056        collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1057        control_handle: AllocatorControlHandle,
1058    },
1059    /// Creates a logical BufferCollectionToken which can be shared among
1060    /// participants (using BufferCollectionToken.Duplicate()), and then
1061    /// converted into a BufferCollection using BindSharedCollection().
1062    ///
1063    /// Success/failure to populate the BufferCollection with buffers is
1064    /// determined via the BufferCollection interface.
1065    AllocateSharedCollection {
1066        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1067        control_handle: AllocatorControlHandle,
1068    },
1069    /// Convert a BufferCollectionToken into a connection to the logical
1070    /// BufferCollection.  The BufferCollection hasn't yet been populated with
1071    /// buffers - the participant must first also send SetConstraints() via the
1072    /// client end of buffer_collection.
1073    ///
1074    /// All BufferCollectionToken(s) duplicated from a logical
1075    /// BufferCollectionToken created via AllocateSharedCollection() must be
1076    /// turned in via BindSharedCollection() before the logical BufferCollection
1077    /// will be populated with buffers.
1078    ///
1079    /// `token` the client endpoint of a channel whose server end was sent to
1080    /// sysmem using AllocateSharedCollection or whose server end was sent to
1081    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
1082    /// "exchanged" for a channel to the logical BufferCollection.
1083    ///
1084    /// `buffer_collection_request` the server end of a BufferCollection
1085    /// channel.  The sender retains the client end as usual.  The
1086    /// BufferCollection channel is a single participant's connection to the
1087    /// logical BufferCollection.  There typically will be other participants
1088    /// with their own BufferCollection channel to the logical BufferCollection.
1089    BindSharedCollection {
1090        token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1091        buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1092        control_handle: AllocatorControlHandle,
1093    },
1094    /// Validate that a BufferCollectionToken is known to the sysmem server.
1095    ///
1096    /// This can be used in cases where BindSharedCollection() won't be called
1097    /// until after BufferCollectionToken.Duplicate() +
1098    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
1099    /// whether an incoming token is valid (so far).
1100    ///
1101    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
1102    /// sysmem risks the Sync() hanging forever.
1103    ///
1104    /// Given that an incoming token can become invalid at any time if any
1105    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
1106    /// authors of client code are encouraged to consider not calling
1107    /// ValidateBufferCollectionToken() and instead dealing with async failure
1108    /// of the BufferCollection.Sync() after all the
1109    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
1110    /// sending any duplicate tokens to other processes).
1111    ///
1112    /// Regardless of the result of this call, this call has no effect on the
1113    /// token with the referenced koid.
1114    ///
1115    /// A true result from this call doesn't guarantee that the token remains
1116    /// valid for any duration afterwards.
1117    ///
1118    /// Client code will zx_object_get_info() on the client's token handle,
1119    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
1120    /// which then gets passed to ValidateBufferCollectionToken().
1121    ///
1122    /// If ValidateBufferCollectionToken() returns true, the token was known at
1123    /// the time the sysmem server processed the call, but may no longer be
1124    /// valid/known by the time the client code receives the response.
1125    ///
1126    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
1127    /// at the time the sysmem server processed the call, but the token may
1128    /// become known by the time the client code receives the response.  However
1129    /// client code is not required to mitigate the possibility that the token
1130    /// may become known late, since the source of the token should have synced
1131    /// the token to sysmem before sending the token to the client code.
1132    ///
1133    /// If calling ValidateBufferCollectionToken() fails in some way, there will
1134    /// be a zx_status_t from the FIDL layer.
1135    ///
1136    /// `token_server_koid` the koid of the server end of a channel that might
1137    /// be a BufferCollectionToken channel.  This can be obtained from
1138    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
1139    ValidateBufferCollectionToken {
1140        token_server_koid: u64,
1141        responder: AllocatorValidateBufferCollectionTokenResponder,
1142    },
1143    /// Set information about the current client that can be used by sysmem to
1144    /// help debug leaking memory and hangs waiting for constraints. |name| can
1145    /// be an arbitrary string, but the current process name (see
1146    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1147    /// arbitrary id, but the current process ID (see
1148    /// fsl::GetCurrentProcessKoid()) is a good default.
1149    ///
1150    /// This information is propagated to all BufferCollections created using
1151    /// BindSharedCollection() or AllocateNonSharedCollection() from this
1152    /// allocator. It does not affect BufferCollectionTokens, since they are
1153    /// often passed cross-process and should have their names managed manually.
1154    SetDebugClientInfo { name: String, id: u64, control_handle: AllocatorControlHandle },
1155    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
1156    /// `Allocator`.
1157    ///
1158    /// This is mainly useful in situations where library code is handed a
1159    /// sysmem(1) allocator, but the library code has been updated to use
1160    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
1161    /// `Allocator` instead, but client code isn't always in the same repo, so
1162    /// this message allows the library to still accept the sysmem(1) Allocator
1163    /// temporarily.
1164    ///
1165    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
1166    /// `Allocator`.
1167    ConnectToSysmem2Allocator {
1168        allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1169        control_handle: AllocatorControlHandle,
1170    },
1171}
1172
1173impl AllocatorRequest {
1174    #[allow(irrefutable_let_patterns)]
1175    pub fn into_allocate_non_shared_collection(
1176        self,
1177    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionMarker>, AllocatorControlHandle)> {
1178        if let AllocatorRequest::AllocateNonSharedCollection {
1179            collection_request,
1180            control_handle,
1181        } = self
1182        {
1183            Some((collection_request, control_handle))
1184        } else {
1185            None
1186        }
1187    }
1188
1189    #[allow(irrefutable_let_patterns)]
1190    pub fn into_allocate_shared_collection(
1191        self,
1192    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>, AllocatorControlHandle)>
1193    {
1194        if let AllocatorRequest::AllocateSharedCollection { token_request, control_handle } = self {
1195            Some((token_request, control_handle))
1196        } else {
1197            None
1198        }
1199    }
1200
1201    #[allow(irrefutable_let_patterns)]
1202    pub fn into_bind_shared_collection(
1203        self,
1204    ) -> Option<(
1205        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1206        fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1207        AllocatorControlHandle,
1208    )> {
1209        if let AllocatorRequest::BindSharedCollection {
1210            token,
1211            buffer_collection_request,
1212            control_handle,
1213        } = self
1214        {
1215            Some((token, buffer_collection_request, control_handle))
1216        } else {
1217            None
1218        }
1219    }
1220
1221    #[allow(irrefutable_let_patterns)]
1222    pub fn into_validate_buffer_collection_token(
1223        self,
1224    ) -> Option<(u64, AllocatorValidateBufferCollectionTokenResponder)> {
1225        if let AllocatorRequest::ValidateBufferCollectionToken { token_server_koid, responder } =
1226            self
1227        {
1228            Some((token_server_koid, responder))
1229        } else {
1230            None
1231        }
1232    }
1233
1234    #[allow(irrefutable_let_patterns)]
1235    pub fn into_set_debug_client_info(self) -> Option<(String, u64, AllocatorControlHandle)> {
1236        if let AllocatorRequest::SetDebugClientInfo { name, id, control_handle } = self {
1237            Some((name, id, control_handle))
1238        } else {
1239            None
1240        }
1241    }
1242
1243    #[allow(irrefutable_let_patterns)]
1244    pub fn into_connect_to_sysmem2_allocator(
1245        self,
1246    ) -> Option<(
1247        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1248        AllocatorControlHandle,
1249    )> {
1250        if let AllocatorRequest::ConnectToSysmem2Allocator { allocator_request, control_handle } =
1251            self
1252        {
1253            Some((allocator_request, control_handle))
1254        } else {
1255            None
1256        }
1257    }
1258
1259    /// Name of the method defined in FIDL
1260    pub fn method_name(&self) -> &'static str {
1261        match *self {
1262            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1263                "allocate_non_shared_collection"
1264            }
1265            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1266            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1267            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1268                "validate_buffer_collection_token"
1269            }
1270            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1271            AllocatorRequest::ConnectToSysmem2Allocator { .. } => "connect_to_sysmem2_allocator",
1272        }
1273    }
1274}
1275
1276#[derive(Debug, Clone)]
1277pub struct AllocatorControlHandle {
1278    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1279}
1280
1281impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
1282    fn shutdown(&self) {
1283        self.inner.shutdown()
1284    }
1285    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1286        self.inner.shutdown_with_epitaph(status)
1287    }
1288
1289    fn is_closed(&self) -> bool {
1290        self.inner.channel().is_closed()
1291    }
1292    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1293        self.inner.channel().on_closed()
1294    }
1295
1296    #[cfg(target_os = "fuchsia")]
1297    fn signal_peer(
1298        &self,
1299        clear_mask: zx::Signals,
1300        set_mask: zx::Signals,
1301    ) -> Result<(), zx_status::Status> {
1302        use fidl::Peered;
1303        self.inner.channel().signal_peer(clear_mask, set_mask)
1304    }
1305}
1306
1307impl AllocatorControlHandle {}
1308
1309#[must_use = "FIDL methods require a response to be sent"]
1310#[derive(Debug)]
1311pub struct AllocatorValidateBufferCollectionTokenResponder {
1312    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1313    tx_id: u32,
1314}
1315
1316/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1317/// if the responder is dropped without sending a response, so that the client
1318/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1319impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1320    fn drop(&mut self) {
1321        self.control_handle.shutdown();
1322        // Safety: drops once, never accessed again
1323        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1324    }
1325}
1326
1327impl fidl::endpoints::Responder for AllocatorValidateBufferCollectionTokenResponder {
1328    type ControlHandle = AllocatorControlHandle;
1329
1330    fn control_handle(&self) -> &AllocatorControlHandle {
1331        &self.control_handle
1332    }
1333
1334    fn drop_without_shutdown(mut self) {
1335        // Safety: drops once, never accessed again due to mem::forget
1336        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1337        // Prevent Drop from running (which would shut down the channel)
1338        std::mem::forget(self);
1339    }
1340}
1341
1342impl AllocatorValidateBufferCollectionTokenResponder {
1343    /// Sends a response to the FIDL transaction.
1344    ///
1345    /// Sets the channel to shutdown if an error occurs.
1346    pub fn send(self, mut is_known: bool) -> Result<(), fidl::Error> {
1347        let _result = self.send_raw(is_known);
1348        if _result.is_err() {
1349            self.control_handle.shutdown();
1350        }
1351        self.drop_without_shutdown();
1352        _result
1353    }
1354
1355    /// Similar to "send" but does not shutdown the channel if an error occurs.
1356    pub fn send_no_shutdown_on_err(self, mut is_known: bool) -> Result<(), fidl::Error> {
1357        let _result = self.send_raw(is_known);
1358        self.drop_without_shutdown();
1359        _result
1360    }
1361
1362    fn send_raw(&self, mut is_known: bool) -> Result<(), fidl::Error> {
1363        self.control_handle.inner.send::<AllocatorValidateBufferCollectionTokenResponse>(
1364            (is_known,),
1365            self.tx_id,
1366            0x575b279b0236faea,
1367            fidl::encoding::DynamicFlags::empty(),
1368        )
1369    }
1370}
1371
1372#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1373pub struct BufferCollectionMarker;
1374
1375impl fidl::endpoints::ProtocolMarker for BufferCollectionMarker {
1376    type Proxy = BufferCollectionProxy;
1377    type RequestStream = BufferCollectionRequestStream;
1378    #[cfg(target_os = "fuchsia")]
1379    type SynchronousProxy = BufferCollectionSynchronousProxy;
1380
1381    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1382}
1383
1384pub trait BufferCollectionProxyInterface: Send + Sync {
1385    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1386    fn r#sync(&self) -> Self::SyncResponseFut;
1387    fn r#close(&self) -> Result<(), fidl::Error>;
1388    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
1389    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
1390    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
1391    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1392    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
1393        + Send;
1394    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1395    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1396        + Send;
1397    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
1398    fn r#set_constraints(
1399        &self,
1400        has_constraints: bool,
1401        constraints: &BufferCollectionConstraints,
1402    ) -> Result<(), fidl::Error>;
1403    type WaitForBuffersAllocatedResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1404        + Send;
1405    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut;
1406    type CheckBuffersAllocatedResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1407        + Send;
1408    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut;
1409    fn r#set_constraints_aux_buffers(
1410        &self,
1411        constraints: &BufferCollectionConstraintsAuxBuffers,
1412    ) -> Result<(), fidl::Error>;
1413    type GetAuxBuffersResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1414        + Send;
1415    fn r#get_aux_buffers(&self) -> Self::GetAuxBuffersResponseFut;
1416    fn r#attach_token(
1417        &self,
1418        rights_attenuation_mask: u32,
1419        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1420    ) -> Result<(), fidl::Error>;
1421    fn r#attach_lifetime_tracking(
1422        &self,
1423        server_end: fidl::EventPair,
1424        buffers_remaining: u32,
1425    ) -> Result<(), fidl::Error>;
1426}
1427#[derive(Debug)]
1428#[cfg(target_os = "fuchsia")]
1429pub struct BufferCollectionSynchronousProxy {
1430    client: fidl::client::sync::Client,
1431}
1432
1433#[cfg(target_os = "fuchsia")]
1434impl fidl::endpoints::SynchronousProxy for BufferCollectionSynchronousProxy {
1435    type Proxy = BufferCollectionProxy;
1436    type Protocol = BufferCollectionMarker;
1437
1438    fn from_channel(inner: fidl::Channel) -> Self {
1439        Self::new(inner)
1440    }
1441
1442    fn into_channel(self) -> fidl::Channel {
1443        self.client.into_channel()
1444    }
1445
1446    fn as_channel(&self) -> &fidl::Channel {
1447        self.client.as_channel()
1448    }
1449}
1450
1451#[cfg(target_os = "fuchsia")]
1452impl BufferCollectionSynchronousProxy {
1453    pub fn new(channel: fidl::Channel) -> Self {
1454        let protocol_name = <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1455        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1456    }
1457
1458    pub fn into_channel(self) -> fidl::Channel {
1459        self.client.into_channel()
1460    }
1461
1462    /// Waits until an event arrives and returns it. It is safe for other
1463    /// threads to make concurrent requests while waiting for an event.
1464    pub fn wait_for_event(
1465        &self,
1466        deadline: zx::MonotonicInstant,
1467    ) -> Result<BufferCollectionEvent, fidl::Error> {
1468        BufferCollectionEvent::decode(self.client.wait_for_event(deadline)?)
1469    }
1470
1471    /// Ensure that previous messages, including Duplicate() messages on a
1472    /// token, collection, or group, have been received server side.
1473    ///
1474    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
1475    /// valid sysmem token risks the Sync() hanging forever.  See
1476    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
1477    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
1478    /// Another way is to pass the token to BindSharedCollection(), which also
1479    /// validates the token as part of exchanging it for a BufferCollection
1480    /// channel, and BufferCollection Sync() can then be used.
1481    ///
1482    /// After a Sync(), it's then safe to send the client end of token_request
1483    /// to another participant knowing the server will recognize the token when
1484    /// it's sent into BindSharedCollection() by the other participant.
1485    ///
1486    /// Other options include waiting for each token.Duplicate() to complete
1487    /// individually (using separate call to token.Sync() after each), or
1488    /// calling Sync() on BufferCollection after the token has been turned in
1489    /// via BindSharedCollection().
1490    ///
1491    /// Another way to mitigate is to avoid calling Sync() on the token, and
1492    /// instead later deal with potential failure of BufferCollection.Sync() if
1493    /// the original token was invalid.  This option can be preferable from a
1494    /// performance point of view, but requires client code to delay sending
1495    /// tokens duplicated from this token until after client code has converted
1496    /// the duplicating token to a BufferCollection and received successful
1497    /// response from BufferCollection.Sync().
1498    ///
1499    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
1500    /// When BufferCollection.Sync() isn't feasible, the caller must already
1501    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
1502    /// hang forever.  See ValidateBufferCollectionToken() to check token
1503    /// validity first if the token isn't already known to be (is/was) valid.
1504    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1505        let _response =
1506            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1507                (),
1508                0x4577e238ae26291,
1509                fidl::encoding::DynamicFlags::empty(),
1510                ___deadline,
1511            )?;
1512        Ok(_response)
1513    }
1514
1515    /// On a BufferCollectionToken channel:
1516    ///
1517    /// Normally a participant will convert a BufferCollectionToken into a
1518    /// BufferCollection view, but a participant is also free to Close() the
1519    /// token (and then close the channel immediately or shortly later in
1520    /// response to server closing its end), which avoids causing logical buffer
1521    /// collection failure.  Normally an unexpected token channel close will
1522    /// cause logical buffer collection failure (the only exceptions being
1523    /// certain cases involving AttachToken() or SetDispensable()).
1524    ///
1525    /// On a BufferCollection channel:
1526    ///
1527    /// By default the server handles unexpected failure of a BufferCollection
1528    /// by failing the whole logical buffer collection.  Partly this is to
1529    /// expedite closing VMO handles to reclaim memory when any participant
1530    /// fails.  If a participant would like to cleanly close a BufferCollection
1531    /// view without causing logical buffer collection failure, the participant
1532    /// can send Close() before closing the client end of the BufferCollection
1533    /// channel.  If this is the last BufferCollection view, the logical buffer
1534    /// collection will still go away.  The Close() can occur before or after
1535    /// SetConstraints().  If before SetConstraints(), the buffer collection
1536    /// won't require constraints from this node in order to allocate.  If
1537    /// after SetConstraints(), the constraints are retained and aggregated
1538    /// along with any subsequent logical allocation(s), despite the lack of
1539    /// channel connection.
1540    ///
1541    /// On a BufferCollectionTokenGroup channel:
1542    ///
1543    /// By default, unexpected failure of a BufferCollectionTokenGroup will
1544    /// trigger failure of the logical BufferCollectionTokenGroup and will
1545    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
1546    /// channel without failing the logical group or propagating failure, send
1547    /// Close() before closing the channel client endpoint.
1548    ///
1549    /// If Close() occurs before AllChildrenPresent(), the logical buffer
1550    /// collection will still fail despite the Close() (because sysmem can't be
1551    /// sure whether all relevant children were created, so it's ambiguous
1552    /// whether all relevant constraints will be provided to sysmem).  If
1553    /// Close() occurs after AllChildrenPresent(), the children and all their
1554    /// constraints remain intact (just as they would if the
1555    /// BufferCollectionTokenGroup channel had remained open), and the close
1556    /// doesn't trigger or propagate failure.
1557    pub fn r#close(&self) -> Result<(), fidl::Error> {
1558        self.client.send::<fidl::encoding::EmptyPayload>(
1559            (),
1560            0x5b1d7a4f5681fca7,
1561            fidl::encoding::DynamicFlags::empty(),
1562        )
1563    }
1564
1565    /// Set a name for VMOs in this buffer collection. The name may be truncated
1566    /// shorter. The name only affects VMOs allocated after it's set - this call
1567    /// does not rename existing VMOs. If multiple clients set different names
1568    /// then the larger priority value will win.
1569    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1570        self.client.send::<NodeSetNameRequest>(
1571            (priority, name),
1572            0x77a41bb6217e2443,
1573            fidl::encoding::DynamicFlags::empty(),
1574        )
1575    }
1576
1577    /// Set information about the current client that can be used by sysmem to
1578    /// help debug leaking memory and hangs waiting for constraints. |name| can
1579    /// be an arbitrary string, but the current process name (see
1580    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1581    /// arbitrary id, but the current process ID (see
1582    /// fsl::GetCurrentProcessKoid()) is a good default.
1583    ///
1584    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
1585    /// indicate which client is closing their channel first, leading to
1586    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
1587    /// over, but if happening earlier than expected, the
1588    /// client-channel-specific name can help diagnose where the failure is
1589    /// first coming from, from sysmem's point of view).
1590    ///
1591    /// By default (unless overriden by this message or using
1592    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
1593    /// parent Node at the time the child Node is created.  While this can be
1594    /// better than nothing, it's often better for each participant to use
1595    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
1596    /// info directly relevant to the current client.  Also, SetVerboseLogging()
1597    /// can be used to help disambiguate if a Node is suspected of having info
1598    /// that was copied from its parent.
1599    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1600        self.client.send::<NodeSetDebugClientInfoRequest>(
1601            (name, id),
1602            0x7275759070eb5ee2,
1603            fidl::encoding::DynamicFlags::empty(),
1604        )
1605    }
1606
1607    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
1608    /// after creating a collection. Clients can call this method to change
1609    /// when the log is printed. If multiple client set the deadline, it's
1610    /// unspecified which deadline will take effect.
1611    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1612        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
1613            (deadline,),
1614            0x46d38f4772638867,
1615            fidl::encoding::DynamicFlags::empty(),
1616        )
1617    }
1618
1619    /// Verbose logging includes constraints set via SetConstraints() from each
1620    /// client along with info set via SetDebugClientInfo() and the structure of
1621    /// the tree of Node(s).
1622    ///
1623    /// Normally sysmem prints only a single line complaint when aggregation
1624    /// fails, with just the specific detailed reason that aggregation failed,
1625    /// with minimal context.  While this is often enough to diagnose a problem
1626    /// if only a small change was made and the system had been working before
1627    /// the small change, it's often not particularly helpful for getting a new
1628    /// buffer collection to work for the first time.  Especially with more
1629    /// complex trees of nodes, involving things like AttachToken(),
1630    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
1631    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
1632    /// looks like and why it's failing a logical allocation, or why a tree or
1633    /// sub-tree is failing sooner than expected.
1634    ///
1635    /// The intent of the extra logging is to be acceptable from a performance
1636    /// point of view, if only enabled on a low number of buffer collections.
1637    /// If we're not tracking down a bug, we shouldn't send this message.
1638    ///
1639    /// If too many participants leave verbose logging enabled, we may end up
1640    /// needing to require that system-wide sysmem verbose logging be permitted
1641    /// via some other setting, to avoid sysmem spamming the log too much due to
1642    /// this message.
1643    ///
1644    /// This may be a NOP for some nodes due to intentional policy associated
1645    /// with the node, if we don't trust a node enough to let it turn on verbose
1646    /// logging.
1647    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1648        self.client.send::<fidl::encoding::EmptyPayload>(
1649            (),
1650            0x6bfbe2cf1701d288,
1651            fidl::encoding::DynamicFlags::empty(),
1652        )
1653    }
1654
1655    /// This gets an event handle that can be used as a parameter to
1656    /// IsAlternateFor() called on any Node.  The client will not be granted the
1657    /// right to signal this event, as this handle should only be used as proof
1658    /// that the client obtained this handle from this Node.
1659    ///
1660    /// Because this is a get not a set, no Sync() is needed between the
1661    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
1662    /// potentially being on different channels.
1663    ///
1664    /// See also IsAlternateFor().
1665    pub fn r#get_node_ref(
1666        &self,
1667        ___deadline: zx::MonotonicInstant,
1668    ) -> Result<fidl::Event, fidl::Error> {
1669        let _response =
1670            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
1671                (),
1672                0x467b7c75c35c3b84,
1673                fidl::encoding::DynamicFlags::empty(),
1674                ___deadline,
1675            )?;
1676        Ok(_response.node_ref)
1677    }
1678
1679    /// This checks whether the calling node is in a subtree rooted at a
1680    /// different child token of a common parent BufferCollectionTokenGroup, in
1681    /// relation to the passed-in node_ref.
1682    ///
1683    /// This call is for assisting with admission control de-duplication, and
1684    /// with debugging.
1685    ///
1686    /// The node_ref must be obtained using GetNodeRef() of a
1687    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
1688    ///
1689    /// The node_ref can be a duplicated handle; it's not necessary to call
1690    /// GetNodeRef() for every call to IsAlternateFor().
1691    ///
1692    /// If a calling token may not actually be a valid token at all due to
1693    /// a potentially hostile/untrusted provider of the token, call
1694    /// ValidateBufferCollectionToken() first instead of potentially getting
1695    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
1696    /// token not being a real token (not really talking to sysmem).  Another
1697    /// option is to call BindSharedCollection with this token first which also
1698    /// validates the token along with converting it to a BufferCollection, then
1699    /// call BufferCollection IsAlternateFor().
1700    ///
1701    /// error values:
1702    ///
1703    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
1704    /// buffer collection as the calling Node.  Before logical allocation and
1705    /// within the same logical allocation sub-tree, this essentially means that
1706    /// the node_ref was never part of this logical buffer collection, since
1707    /// before logical allocation all node_refs that come into existence remain
1708    /// in existence at least until logical allocation (including Node(s) that
1709    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
1710    /// to be returned, this Node's channel needs to still be connected server
1711    /// side, which won't be the case if the whole logical allocation has
1712    /// failed.  After logical allocation or in a different logical allocation
1713    /// sub-tree there are additional potential reasons for this error.  For
1714    /// example a different logical allocation (separated from this Node(s)
1715    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
1716    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
1717    /// exist and may select a different child sub-tree than the sub-tree the
1718    /// node_ref is in causing deletion of the node_ref Node.  The only time
1719    /// sysmem keeps a Node around after that Node has no corresponding channel
1720    /// is when Close() is used and the Node's sub-tree has not yet failed.
1721    /// Another reason for this error is if the node_ref is an eventpair handle
1722    /// with sufficient rights, but isn't actually a real node_ref obtained from
1723    /// GetNodeRef().
1724    ///
1725    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
1726    /// eventpair handle, or doesn't have the needed rights expected on a real
1727    /// node_ref.
1728    ///
1729    /// No other failing status codes are returned by this call.  However,
1730    /// sysmem may add additional codes in future, so the client should have
1731    /// sensible default handling for any failing status code.
1732    ///
1733    /// On success, is_alternate has the following meaning:
1734    ///   * true - The first parent node in common between the calling node and
1735    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
1736    ///     the calling Node and the node_ref Node will _not_ have both their
1737    ///     constraints apply - rather sysmem will choose one or the other of
1738    ///     the constraints - never both.  This is because only one child of
1739    ///     a BufferCollectionTokenGroup is selected during logical allocation,
1740    ///     with only that one child's sub-tree contributing to constraints
1741    ///     aggregation.
1742    ///   * false - The first parent node in common between the calling Node and
1743    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
1744    ///     this means the first parent node in common is a
1745    ///     BufferCollectionToken or BufferCollection (regardless of not
1746    ///     Close()ed or Close()ed).  This means that the calling Node and the
1747    ///     node_ref Node _may_ have both their constraints apply during
1748    ///     constraints aggregation of the logical allocation, if both Node(s)
1749    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
1750    ///     In this case, there is no BufferCollectionTokenGroup that will
1751    ///     directly prevent the two Node(s) from both being selected and their
1752    ///     constraints both aggregated, but even when false, one or both
1753    ///     Node(s) may still be eliminated from consideration if one or both
1754    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
1755    ///     which selects a child sub-tree other than the sub-tree containing
1756    ///     the calling Node or node_ref Node.
1757    pub fn r#is_alternate_for(
1758        &self,
1759        mut node_ref: fidl::Event,
1760        ___deadline: zx::MonotonicInstant,
1761    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
1762        let _response = self.client.send_query::<
1763            NodeIsAlternateForRequest,
1764            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
1765        >(
1766            (node_ref,),
1767            0x33a2a7aff2776c07,
1768            fidl::encoding::DynamicFlags::empty(),
1769            ___deadline,
1770        )?;
1771        Ok(_response.map(|x| x.is_alternate))
1772    }
1773
1774    /// Provide BufferCollectionConstraints to the logical BufferCollection.
1775    ///
1776    /// A participant may only call SetConstraints() once.
1777    ///
1778    /// Sometimes the initiator is a participant only in the sense of wanting to
1779    /// keep an eye on success/failure to populate with buffers, and zx.Status
1780    /// on failure.  In that case, `has_constraints` can be false, and
1781    /// `constraints` will be ignored.
1782    ///
1783    /// VMO handles will not be provided to the client that sends null
1784    /// constraints - that can be intentional for an initiator that doesn't need
1785    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
1786    /// adjusting which portion of a buffer is considered valid and similar, but
1787    /// the initiator can't hold a VMO handle open to prevent the logical
1788    /// BufferCollection from cleaning up if the logical BufferCollection needs
1789    /// to go away regardless of the initiator's degree of involvement for
1790    /// whatever reason.
1791    ///
1792    /// For population of buffers to be attempted, all holders of a
1793    /// BufferCollection client channel need to call SetConstraints() before
1794    /// sysmem will attempt to allocate buffers.
1795    ///
1796    /// `has_constraints` if false, the constraints are effectively null, and
1797    /// `constraints` are ignored.  The sender of null constraints won't get any
1798    /// VMO handles in BufferCollectionInfo, but can still find out how many
1799    /// buffers were allocated and can still refer to buffers by their
1800    /// buffer_index.
1801    ///
1802    /// `constraints` are constraints on the buffer collection.
1803    pub fn r#set_constraints(
1804        &self,
1805        mut has_constraints: bool,
1806        mut constraints: &BufferCollectionConstraints,
1807    ) -> Result<(), fidl::Error> {
1808        self.client.send::<BufferCollectionSetConstraintsRequest>(
1809            (has_constraints, constraints),
1810            0x4d9c3406c213227b,
1811            fidl::encoding::DynamicFlags::empty(),
1812        )
1813    }
1814
1815    /// This request completes when buffers have been allocated, responds with
1816    /// some failure detail if allocation has been attempted but failed.
1817    ///
1818    /// The following must occur before buffers will be allocated:
1819    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
1820    ///     must be turned in via BindSharedCollection().
1821    ///   * All BufferCollection(s) of the logical BufferCollection must have
1822    ///     had SetConstraints() sent to them.
1823    ///
1824    /// Returns `ZX_OK` if successful.
1825    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
1826    /// fulfilled due to resource exhaustion.
1827    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
1828    /// obtain the buffers it requested.
1829    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
1830    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
1831    /// satisfied, perhaps due to hardware limitations.
1832    ///
1833    /// `buffer_collection_info` has the VMO handles and other related info.
1834    pub fn r#wait_for_buffers_allocated(
1835        &self,
1836        ___deadline: zx::MonotonicInstant,
1837    ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1838        let _response = self.client.send_query::<
1839            fidl::encoding::EmptyPayload,
1840            BufferCollectionWaitForBuffersAllocatedResponse,
1841        >(
1842            (),
1843            0x714667ea2a29a3a2,
1844            fidl::encoding::DynamicFlags::empty(),
1845            ___deadline,
1846        )?;
1847        Ok((_response.status, _response.buffer_collection_info))
1848    }
1849
1850    /// This returns the same result code as WaitForBuffersAllocated if the
1851    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
1852    /// if WaitForBuffersAllocated would block.
1853    pub fn r#check_buffers_allocated(
1854        &self,
1855        ___deadline: zx::MonotonicInstant,
1856    ) -> Result<i32, fidl::Error> {
1857        let _response = self.client.send_query::<
1858            fidl::encoding::EmptyPayload,
1859            BufferCollectionCheckBuffersAllocatedResponse,
1860        >(
1861            (),
1862            0x245bb81f79189e9,
1863            fidl::encoding::DynamicFlags::empty(),
1864            ___deadline,
1865        )?;
1866        Ok(_response.status)
1867    }
1868
1869    pub fn r#set_constraints_aux_buffers(
1870        &self,
1871        mut constraints: &BufferCollectionConstraintsAuxBuffers,
1872    ) -> Result<(), fidl::Error> {
1873        self.client.send::<BufferCollectionSetConstraintsAuxBuffersRequest>(
1874            (constraints,),
1875            0x1ad80e63c090d817,
1876            fidl::encoding::DynamicFlags::empty(),
1877        )
1878    }
1879
1880    pub fn r#get_aux_buffers(
1881        &self,
1882        ___deadline: zx::MonotonicInstant,
1883    ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1884        let _response = self
1885            .client
1886            .send_query::<fidl::encoding::EmptyPayload, BufferCollectionGetAuxBuffersResponse>(
1887                (),
1888                0x6c6cac6000a29a55,
1889                fidl::encoding::DynamicFlags::empty(),
1890                ___deadline,
1891            )?;
1892        Ok((_response.status, _response.buffer_collection_info_aux_buffers))
1893    }
1894
1895    /// Create a new token, for trying to add a new participant to an existing
1896    /// collection, if the existing collection's buffer counts, constraints,
1897    /// and participants allow.
1898    ///
1899    /// This can be useful in replacing a failed participant, and/or in
1900    /// adding/re-adding a participant after buffers have already been
1901    /// allocated.
1902    ///
1903    /// Failure of an attached token / collection does not propagate to the
1904    /// parent of the attached token.  Failure does propagate from a normal
1905    /// child of a dispensable token to the dispensable token.  Failure
1906    /// of a child is blocked from reaching its parent if the child is attached,
1907    /// or if the child is dispensable and the failure occurred after logical
1908    /// allocation.
1909    ///
1910    /// An initiator may in some scenarios choose to initially use a dispensable
1911    /// token for a given instance of a participant, and then later if the first
1912    /// instance of that participant fails, a new second instance of that
1913    /// participant my be given a token created with AttachToken().
1914    ///
1915    /// From the point of view of the client end of the BufferCollectionToken
1916    /// channel, the token acts like any other token.  The client can
1917    /// Duplicate() the token as needed, and can send the token to a different
1918    /// process.  The token should be converted to a BufferCollection channel
1919    /// as normal by calling BindSharedCollection().  SetConstraints() should
1920    /// be called on that BufferCollection channel.
1921    ///
1922    /// A success result from WaitForBuffersAllocated() means the new
1923    /// participant's constraints were satisfiable using the already-existing
1924    /// buffer collection, the already-established BufferCollectionInfo
1925    /// including image format constraints, and the already-existing other
1926    /// participants and their buffer counts.  A failure result means the new
1927    /// participant's constraints cannot be satisfied using the existing
1928    /// buffer collection and its already-logically-allocated participants.
1929    /// Creating a new collection instead may allow all participant's
1930    /// constraints to be satisfied, assuming SetDispensable() is used in place
1931    /// of AttachToken(), or a normal token is used.
1932    ///
1933    /// A token created with AttachToken() performs constraints aggregation with
1934    /// all constraints currently in effect on the buffer collection, plus the
1935    /// attached token under consideration plus child tokens under the attached
1936    /// token which are not themselves an attached token or under such a token.
1937    ///
1938    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
1939    /// first-come first-served, but a child can't logically allocate before
1940    /// all its parents have sent SetConstraints().
1941    ///
1942    /// See also SetDispensable(), which in contrast to AttachToken(), has the
1943    /// created token + children participate in constraints aggregation along
1944    /// with its parent.
1945    ///
1946    /// The newly created token needs to be Sync()ed to sysmem before the new
1947    /// token can be passed to BindSharedCollection().  The Sync() of the new
1948    /// token can be accomplished with BufferCollection.Sync() on this
1949    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
1950    /// token also works.  A BufferCollectionToken.Sync() can be started after
1951    /// any BufferCollectionToken.Duplicate() messages have been sent via the
1952    /// newly created token, to also sync those additional tokens to sysmem
1953    /// using a single round-trip.
1954    ///
1955    /// These values for rights_attenuation_mask result in no attenuation (note
1956    /// that 0 is not on this list; 0 will output an ERROR to the system log
1957    /// to help diagnose the bug in client code):
1958    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
1959    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
1960    pub fn r#attach_token(
1961        &self,
1962        mut rights_attenuation_mask: u32,
1963        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1964    ) -> Result<(), fidl::Error> {
1965        self.client.send::<BufferCollectionAttachTokenRequest>(
1966            (rights_attenuation_mask, token_request),
1967            0x6f5adcca4ac7443e,
1968            fidl::encoding::DynamicFlags::empty(),
1969        )
1970    }
1971
1972    /// AttachLifetimeTracking:
1973    ///
1974    /// AttachLifetimeTracking() is intended to allow a client to wait until an
1975    /// old logical buffer collection is fully or mostly deallocated before
1976    /// attempting allocation of a new logical buffer collection.
1977    ///
1978    /// Attach an eventpair endpoint to the logical buffer collection, so that
1979    /// the server_end will be closed when the number of buffers allocated
1980    /// drops to 'buffers_remaining'.  The server_end won't close until after
1981    /// logical allocation has completed.
1982    ///
1983    /// If logical allocation fails, such as for an attached sub-tree (using
1984    /// AttachToken()), the server_end will close during that failure regardless
1985    /// of the number of buffers potenitally allocated in the overall logical
1986    /// buffer collection.
1987    ///
1988    /// The lifetime signalled by this event includes asynchronous cleanup of
1989    /// allocated buffers, and this asynchronous cleanup cannot occur until all
1990    /// holders of VMO handles to the buffers have closed those VMO handles.
1991    /// Therefore clients should take care not to become blocked forever waiting
1992    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
1993    /// participants using the logical buffer collection are less trusted or
1994    /// less reliable.
1995    ///
1996    /// The buffers_remaining parameter allows waiting for all but
1997    /// buffers_remaining buffers to be fully deallocated.  This can be useful
1998    /// in situations where a known number of buffers are intentionally not
1999    /// closed so that the data can continue to be used, such as for keeping the
2000    /// last available video picture displayed in the UI even if the video
2001    /// stream was using protected output buffers.  It's outside the scope of
2002    /// the BufferCollection interface (at least for now) to determine how many
2003    /// buffers may be held without closing, but it'll typically be in the range
2004    /// 0-2.
2005    ///
2006    /// This mechanism is meant to be compatible with other protocols providing
2007    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2008    /// same event can be sent to more than one AttachLifetimeTracking(), and
2009    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2010    /// over conditions are met (all holders of duplicates have closed their
2011    /// handle(s)).
2012    ///
2013    /// There is no way to cancel an attach.  Closing the client end of the
2014    /// eventpair doesn't subtract from the number of pending attach(es).
2015    ///
2016    /// Closing the client's end doesn't result in any action by the server.
2017    /// If the server listens to events from the client end at all, it is for
2018    /// debug logging only.
2019    ///
2020    /// The server intentionally doesn't "trust" any bits signalled by the
2021    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2022    /// which can't be triggered early, and is only triggered when all handles
2023    /// to server_end are closed.  No meaning is associated with any of the
2024    /// other signal bits, and clients should functionally ignore any other
2025    /// signal bits on either end of the eventpair or its peer.
2026    ///
2027    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2028    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2029    /// transfer without causing CodecFactory channel failure).
2030    pub fn r#attach_lifetime_tracking(
2031        &self,
2032        mut server_end: fidl::EventPair,
2033        mut buffers_remaining: u32,
2034    ) -> Result<(), fidl::Error> {
2035        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2036            (server_end, buffers_remaining),
2037            0x170d0f1d89d50989,
2038            fidl::encoding::DynamicFlags::empty(),
2039        )
2040    }
2041}
2042
2043#[cfg(target_os = "fuchsia")]
2044impl From<BufferCollectionSynchronousProxy> for zx::Handle {
2045    fn from(value: BufferCollectionSynchronousProxy) -> Self {
2046        value.into_channel().into()
2047    }
2048}
2049
2050#[cfg(target_os = "fuchsia")]
2051impl From<fidl::Channel> for BufferCollectionSynchronousProxy {
2052    fn from(value: fidl::Channel) -> Self {
2053        Self::new(value)
2054    }
2055}
2056
2057#[cfg(target_os = "fuchsia")]
2058impl fidl::endpoints::FromClient for BufferCollectionSynchronousProxy {
2059    type Protocol = BufferCollectionMarker;
2060
2061    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionMarker>) -> Self {
2062        Self::new(value.into_channel())
2063    }
2064}
2065
2066#[derive(Debug, Clone)]
2067pub struct BufferCollectionProxy {
2068    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2069}
2070
2071impl fidl::endpoints::Proxy for BufferCollectionProxy {
2072    type Protocol = BufferCollectionMarker;
2073
2074    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2075        Self::new(inner)
2076    }
2077
2078    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2079        self.client.into_channel().map_err(|client| Self { client })
2080    }
2081
2082    fn as_channel(&self) -> &::fidl::AsyncChannel {
2083        self.client.as_channel()
2084    }
2085}
2086
2087impl BufferCollectionProxy {
2088    /// Create a new Proxy for fuchsia.sysmem/BufferCollection.
2089    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2090        let protocol_name = <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2091        Self { client: fidl::client::Client::new(channel, protocol_name) }
2092    }
2093
2094    /// Get a Stream of events from the remote end of the protocol.
2095    ///
2096    /// # Panics
2097    ///
2098    /// Panics if the event stream was already taken.
2099    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
2100        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
2101    }
2102
2103    /// Ensure that previous messages, including Duplicate() messages on a
2104    /// token, collection, or group, have been received server side.
2105    ///
2106    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
2107    /// valid sysmem token risks the Sync() hanging forever.  See
2108    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
2109    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
2110    /// Another way is to pass the token to BindSharedCollection(), which also
2111    /// validates the token as part of exchanging it for a BufferCollection
2112    /// channel, and BufferCollection Sync() can then be used.
2113    ///
2114    /// After a Sync(), it's then safe to send the client end of token_request
2115    /// to another participant knowing the server will recognize the token when
2116    /// it's sent into BindSharedCollection() by the other participant.
2117    ///
2118    /// Other options include waiting for each token.Duplicate() to complete
2119    /// individually (using separate call to token.Sync() after each), or
2120    /// calling Sync() on BufferCollection after the token has been turned in
2121    /// via BindSharedCollection().
2122    ///
2123    /// Another way to mitigate is to avoid calling Sync() on the token, and
2124    /// instead later deal with potential failure of BufferCollection.Sync() if
2125    /// the original token was invalid.  This option can be preferable from a
2126    /// performance point of view, but requires client code to delay sending
2127    /// tokens duplicated from this token until after client code has converted
2128    /// the duplicating token to a BufferCollection and received successful
2129    /// response from BufferCollection.Sync().
2130    ///
2131    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
2132    /// When BufferCollection.Sync() isn't feasible, the caller must already
2133    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
2134    /// hang forever.  See ValidateBufferCollectionToken() to check token
2135    /// validity first if the token isn't already known to be (is/was) valid.
2136    pub fn r#sync(
2137        &self,
2138    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2139        BufferCollectionProxyInterface::r#sync(self)
2140    }
2141
2142    /// On a BufferCollectionToken channel:
2143    ///
2144    /// Normally a participant will convert a BufferCollectionToken into a
2145    /// BufferCollection view, but a participant is also free to Close() the
2146    /// token (and then close the channel immediately or shortly later in
2147    /// response to server closing its end), which avoids causing logical buffer
2148    /// collection failure.  Normally an unexpected token channel close will
2149    /// cause logical buffer collection failure (the only exceptions being
2150    /// certain cases involving AttachToken() or SetDispensable()).
2151    ///
2152    /// On a BufferCollection channel:
2153    ///
2154    /// By default the server handles unexpected failure of a BufferCollection
2155    /// by failing the whole logical buffer collection.  Partly this is to
2156    /// expedite closing VMO handles to reclaim memory when any participant
2157    /// fails.  If a participant would like to cleanly close a BufferCollection
2158    /// view without causing logical buffer collection failure, the participant
2159    /// can send Close() before closing the client end of the BufferCollection
2160    /// channel.  If this is the last BufferCollection view, the logical buffer
2161    /// collection will still go away.  The Close() can occur before or after
2162    /// SetConstraints().  If before SetConstraints(), the buffer collection
2163    /// won't require constraints from this node in order to allocate.  If
2164    /// after SetConstraints(), the constraints are retained and aggregated
2165    /// along with any subsequent logical allocation(s), despite the lack of
2166    /// channel connection.
2167    ///
2168    /// On a BufferCollectionTokenGroup channel:
2169    ///
2170    /// By default, unexpected failure of a BufferCollectionTokenGroup will
2171    /// trigger failure of the logical BufferCollectionTokenGroup and will
2172    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
2173    /// channel without failing the logical group or propagating failure, send
2174    /// Close() before closing the channel client endpoint.
2175    ///
2176    /// If Close() occurs before AllChildrenPresent(), the logical buffer
2177    /// collection will still fail despite the Close() (because sysmem can't be
2178    /// sure whether all relevant children were created, so it's ambiguous
2179    /// whether all relevant constraints will be provided to sysmem).  If
2180    /// Close() occurs after AllChildrenPresent(), the children and all their
2181    /// constraints remain intact (just as they would if the
2182    /// BufferCollectionTokenGroup channel had remained open), and the close
2183    /// doesn't trigger or propagate failure.
2184    pub fn r#close(&self) -> Result<(), fidl::Error> {
2185        BufferCollectionProxyInterface::r#close(self)
2186    }
2187
2188    /// Set a name for VMOs in this buffer collection. The name may be truncated
2189    /// shorter. The name only affects VMOs allocated after it's set - this call
2190    /// does not rename existing VMOs. If multiple clients set different names
2191    /// then the larger priority value will win.
2192    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2193        BufferCollectionProxyInterface::r#set_name(self, priority, name)
2194    }
2195
2196    /// Set information about the current client that can be used by sysmem to
2197    /// help debug leaking memory and hangs waiting for constraints. |name| can
2198    /// be an arbitrary string, but the current process name (see
2199    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
2200    /// arbitrary id, but the current process ID (see
2201    /// fsl::GetCurrentProcessKoid()) is a good default.
2202    ///
2203    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
2204    /// indicate which client is closing their channel first, leading to
2205    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
2206    /// over, but if happening earlier than expected, the
2207    /// client-channel-specific name can help diagnose where the failure is
2208    /// first coming from, from sysmem's point of view).
2209    ///
2210    /// By default (unless overriden by this message or using
2211    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
2212    /// parent Node at the time the child Node is created.  While this can be
2213    /// better than nothing, it's often better for each participant to use
2214    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
2215    /// info directly relevant to the current client.  Also, SetVerboseLogging()
2216    /// can be used to help disambiguate if a Node is suspected of having info
2217    /// that was copied from its parent.
2218    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2219        BufferCollectionProxyInterface::r#set_debug_client_info(self, name, id)
2220    }
2221
2222    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
2223    /// after creating a collection. Clients can call this method to change
2224    /// when the log is printed. If multiple client set the deadline, it's
2225    /// unspecified which deadline will take effect.
2226    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2227        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
2228    }
2229
2230    /// Verbose logging includes constraints set via SetConstraints() from each
2231    /// client along with info set via SetDebugClientInfo() and the structure of
2232    /// the tree of Node(s).
2233    ///
2234    /// Normally sysmem prints only a single line complaint when aggregation
2235    /// fails, with just the specific detailed reason that aggregation failed,
2236    /// with minimal context.  While this is often enough to diagnose a problem
2237    /// if only a small change was made and the system had been working before
2238    /// the small change, it's often not particularly helpful for getting a new
2239    /// buffer collection to work for the first time.  Especially with more
2240    /// complex trees of nodes, involving things like AttachToken(),
2241    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
2242    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
2243    /// looks like and why it's failing a logical allocation, or why a tree or
2244    /// sub-tree is failing sooner than expected.
2245    ///
2246    /// The intent of the extra logging is to be acceptable from a performance
2247    /// point of view, if only enabled on a low number of buffer collections.
2248    /// If we're not tracking down a bug, we shouldn't send this message.
2249    ///
2250    /// If too many participants leave verbose logging enabled, we may end up
2251    /// needing to require that system-wide sysmem verbose logging be permitted
2252    /// via some other setting, to avoid sysmem spamming the log too much due to
2253    /// this message.
2254    ///
2255    /// This may be a NOP for some nodes due to intentional policy associated
2256    /// with the node, if we don't trust a node enough to let it turn on verbose
2257    /// logging.
2258    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2259        BufferCollectionProxyInterface::r#set_verbose_logging(self)
2260    }
2261
2262    /// This gets an event handle that can be used as a parameter to
2263    /// IsAlternateFor() called on any Node.  The client will not be granted the
2264    /// right to signal this event, as this handle should only be used as proof
2265    /// that the client obtained this handle from this Node.
2266    ///
2267    /// Because this is a get not a set, no Sync() is needed between the
2268    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
2269    /// potentially being on different channels.
2270    ///
2271    /// See also IsAlternateFor().
2272    pub fn r#get_node_ref(
2273        &self,
2274    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
2275    {
2276        BufferCollectionProxyInterface::r#get_node_ref(self)
2277    }
2278
2279    /// This checks whether the calling node is in a subtree rooted at a
2280    /// different child token of a common parent BufferCollectionTokenGroup, in
2281    /// relation to the passed-in node_ref.
2282    ///
2283    /// This call is for assisting with admission control de-duplication, and
2284    /// with debugging.
2285    ///
2286    /// The node_ref must be obtained using GetNodeRef() of a
2287    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
2288    ///
2289    /// The node_ref can be a duplicated handle; it's not necessary to call
2290    /// GetNodeRef() for every call to IsAlternateFor().
2291    ///
2292    /// If a calling token may not actually be a valid token at all due to
2293    /// a potentially hostile/untrusted provider of the token, call
2294    /// ValidateBufferCollectionToken() first instead of potentially getting
2295    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
2296    /// token not being a real token (not really talking to sysmem).  Another
2297    /// option is to call BindSharedCollection with this token first which also
2298    /// validates the token along with converting it to a BufferCollection, then
2299    /// call BufferCollection IsAlternateFor().
2300    ///
2301    /// error values:
2302    ///
2303    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
2304    /// buffer collection as the calling Node.  Before logical allocation and
2305    /// within the same logical allocation sub-tree, this essentially means that
2306    /// the node_ref was never part of this logical buffer collection, since
2307    /// before logical allocation all node_refs that come into existence remain
2308    /// in existence at least until logical allocation (including Node(s) that
2309    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
2310    /// to be returned, this Node's channel needs to still be connected server
2311    /// side, which won't be the case if the whole logical allocation has
2312    /// failed.  After logical allocation or in a different logical allocation
2313    /// sub-tree there are additional potential reasons for this error.  For
2314    /// example a different logical allocation (separated from this Node(s)
2315    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
2316    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
2317    /// exist and may select a different child sub-tree than the sub-tree the
2318    /// node_ref is in causing deletion of the node_ref Node.  The only time
2319    /// sysmem keeps a Node around after that Node has no corresponding channel
2320    /// is when Close() is used and the Node's sub-tree has not yet failed.
2321    /// Another reason for this error is if the node_ref is an eventpair handle
2322    /// with sufficient rights, but isn't actually a real node_ref obtained from
2323    /// GetNodeRef().
2324    ///
2325    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
2326    /// eventpair handle, or doesn't have the needed rights expected on a real
2327    /// node_ref.
2328    ///
2329    /// No other failing status codes are returned by this call.  However,
2330    /// sysmem may add additional codes in future, so the client should have
2331    /// sensible default handling for any failing status code.
2332    ///
2333    /// On success, is_alternate has the following meaning:
2334    ///   * true - The first parent node in common between the calling node and
2335    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
2336    ///     the calling Node and the node_ref Node will _not_ have both their
2337    ///     constraints apply - rather sysmem will choose one or the other of
2338    ///     the constraints - never both.  This is because only one child of
2339    ///     a BufferCollectionTokenGroup is selected during logical allocation,
2340    ///     with only that one child's sub-tree contributing to constraints
2341    ///     aggregation.
2342    ///   * false - The first parent node in common between the calling Node and
2343    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
2344    ///     this means the first parent node in common is a
2345    ///     BufferCollectionToken or BufferCollection (regardless of not
2346    ///     Close()ed or Close()ed).  This means that the calling Node and the
2347    ///     node_ref Node _may_ have both their constraints apply during
2348    ///     constraints aggregation of the logical allocation, if both Node(s)
2349    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
2350    ///     In this case, there is no BufferCollectionTokenGroup that will
2351    ///     directly prevent the two Node(s) from both being selected and their
2352    ///     constraints both aggregated, but even when false, one or both
2353    ///     Node(s) may still be eliminated from consideration if one or both
2354    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
2355    ///     which selects a child sub-tree other than the sub-tree containing
2356    ///     the calling Node or node_ref Node.
2357    pub fn r#is_alternate_for(
2358        &self,
2359        mut node_ref: fidl::Event,
2360    ) -> fidl::client::QueryResponseFut<
2361        NodeIsAlternateForResult,
2362        fidl::encoding::DefaultFuchsiaResourceDialect,
2363    > {
2364        BufferCollectionProxyInterface::r#is_alternate_for(self, node_ref)
2365    }
2366
2367    /// Provide BufferCollectionConstraints to the logical BufferCollection.
2368    ///
2369    /// A participant may only call SetConstraints() once.
2370    ///
2371    /// Sometimes the initiator is a participant only in the sense of wanting to
2372    /// keep an eye on success/failure to populate with buffers, and zx.Status
2373    /// on failure.  In that case, `has_constraints` can be false, and
2374    /// `constraints` will be ignored.
2375    ///
2376    /// VMO handles will not be provided to the client that sends null
2377    /// constraints - that can be intentional for an initiator that doesn't need
2378    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
2379    /// adjusting which portion of a buffer is considered valid and similar, but
2380    /// the initiator can't hold a VMO handle open to prevent the logical
2381    /// BufferCollection from cleaning up if the logical BufferCollection needs
2382    /// to go away regardless of the initiator's degree of involvement for
2383    /// whatever reason.
2384    ///
2385    /// For population of buffers to be attempted, all holders of a
2386    /// BufferCollection client channel need to call SetConstraints() before
2387    /// sysmem will attempt to allocate buffers.
2388    ///
2389    /// `has_constraints` if false, the constraints are effectively null, and
2390    /// `constraints` are ignored.  The sender of null constraints won't get any
2391    /// VMO handles in BufferCollectionInfo, but can still find out how many
2392    /// buffers were allocated and can still refer to buffers by their
2393    /// buffer_index.
2394    ///
2395    /// `constraints` are constraints on the buffer collection.
2396    pub fn r#set_constraints(
2397        &self,
2398        mut has_constraints: bool,
2399        mut constraints: &BufferCollectionConstraints,
2400    ) -> Result<(), fidl::Error> {
2401        BufferCollectionProxyInterface::r#set_constraints(self, has_constraints, constraints)
2402    }
2403
2404    /// This request completes when buffers have been allocated, responds with
2405    /// some failure detail if allocation has been attempted but failed.
2406    ///
2407    /// The following must occur before buffers will be allocated:
2408    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
2409    ///     must be turned in via BindSharedCollection().
2410    ///   * All BufferCollection(s) of the logical BufferCollection must have
2411    ///     had SetConstraints() sent to them.
2412    ///
2413    /// Returns `ZX_OK` if successful.
2414    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
2415    /// fulfilled due to resource exhaustion.
2416    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
2417    /// obtain the buffers it requested.
2418    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
2419    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
2420    /// satisfied, perhaps due to hardware limitations.
2421    ///
2422    /// `buffer_collection_info` has the VMO handles and other related info.
2423    pub fn r#wait_for_buffers_allocated(
2424        &self,
2425    ) -> fidl::client::QueryResponseFut<
2426        (i32, BufferCollectionInfo2),
2427        fidl::encoding::DefaultFuchsiaResourceDialect,
2428    > {
2429        BufferCollectionProxyInterface::r#wait_for_buffers_allocated(self)
2430    }
2431
2432    /// This returns the same result code as WaitForBuffersAllocated if the
2433    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
2434    /// if WaitForBuffersAllocated would block.
2435    pub fn r#check_buffers_allocated(
2436        &self,
2437    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
2438        BufferCollectionProxyInterface::r#check_buffers_allocated(self)
2439    }
2440
2441    pub fn r#set_constraints_aux_buffers(
2442        &self,
2443        mut constraints: &BufferCollectionConstraintsAuxBuffers,
2444    ) -> Result<(), fidl::Error> {
2445        BufferCollectionProxyInterface::r#set_constraints_aux_buffers(self, constraints)
2446    }
2447
2448    pub fn r#get_aux_buffers(
2449        &self,
2450    ) -> fidl::client::QueryResponseFut<
2451        (i32, BufferCollectionInfo2),
2452        fidl::encoding::DefaultFuchsiaResourceDialect,
2453    > {
2454        BufferCollectionProxyInterface::r#get_aux_buffers(self)
2455    }
2456
2457    /// Create a new token, for trying to add a new participant to an existing
2458    /// collection, if the existing collection's buffer counts, constraints,
2459    /// and participants allow.
2460    ///
2461    /// This can be useful in replacing a failed participant, and/or in
2462    /// adding/re-adding a participant after buffers have already been
2463    /// allocated.
2464    ///
2465    /// Failure of an attached token / collection does not propagate to the
2466    /// parent of the attached token.  Failure does propagate from a normal
2467    /// child of a dispensable token to the dispensable token.  Failure
2468    /// of a child is blocked from reaching its parent if the child is attached,
2469    /// or if the child is dispensable and the failure occurred after logical
2470    /// allocation.
2471    ///
2472    /// An initiator may in some scenarios choose to initially use a dispensable
2473    /// token for a given instance of a participant, and then later if the first
2474    /// instance of that participant fails, a new second instance of that
2475    /// participant my be given a token created with AttachToken().
2476    ///
2477    /// From the point of view of the client end of the BufferCollectionToken
2478    /// channel, the token acts like any other token.  The client can
2479    /// Duplicate() the token as needed, and can send the token to a different
2480    /// process.  The token should be converted to a BufferCollection channel
2481    /// as normal by calling BindSharedCollection().  SetConstraints() should
2482    /// be called on that BufferCollection channel.
2483    ///
2484    /// A success result from WaitForBuffersAllocated() means the new
2485    /// participant's constraints were satisfiable using the already-existing
2486    /// buffer collection, the already-established BufferCollectionInfo
2487    /// including image format constraints, and the already-existing other
2488    /// participants and their buffer counts.  A failure result means the new
2489    /// participant's constraints cannot be satisfied using the existing
2490    /// buffer collection and its already-logically-allocated participants.
2491    /// Creating a new collection instead may allow all participant's
2492    /// constraints to be satisfied, assuming SetDispensable() is used in place
2493    /// of AttachToken(), or a normal token is used.
2494    ///
2495    /// A token created with AttachToken() performs constraints aggregation with
2496    /// all constraints currently in effect on the buffer collection, plus the
2497    /// attached token under consideration plus child tokens under the attached
2498    /// token which are not themselves an attached token or under such a token.
2499    ///
2500    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
2501    /// first-come first-served, but a child can't logically allocate before
2502    /// all its parents have sent SetConstraints().
2503    ///
2504    /// See also SetDispensable(), which in contrast to AttachToken(), has the
2505    /// created token + children participate in constraints aggregation along
2506    /// with its parent.
2507    ///
2508    /// The newly created token needs to be Sync()ed to sysmem before the new
2509    /// token can be passed to BindSharedCollection().  The Sync() of the new
2510    /// token can be accomplished with BufferCollection.Sync() on this
2511    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
2512    /// token also works.  A BufferCollectionToken.Sync() can be started after
2513    /// any BufferCollectionToken.Duplicate() messages have been sent via the
2514    /// newly created token, to also sync those additional tokens to sysmem
2515    /// using a single round-trip.
2516    ///
2517    /// These values for rights_attenuation_mask result in no attenuation (note
2518    /// that 0 is not on this list; 0 will output an ERROR to the system log
2519    /// to help diagnose the bug in client code):
2520    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
2521    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2522    pub fn r#attach_token(
2523        &self,
2524        mut rights_attenuation_mask: u32,
2525        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2526    ) -> Result<(), fidl::Error> {
2527        BufferCollectionProxyInterface::r#attach_token(self, rights_attenuation_mask, token_request)
2528    }
2529
2530    /// AttachLifetimeTracking:
2531    ///
2532    /// AttachLifetimeTracking() is intended to allow a client to wait until an
2533    /// old logical buffer collection is fully or mostly deallocated before
2534    /// attempting allocation of a new logical buffer collection.
2535    ///
2536    /// Attach an eventpair endpoint to the logical buffer collection, so that
2537    /// the server_end will be closed when the number of buffers allocated
2538    /// drops to 'buffers_remaining'.  The server_end won't close until after
2539    /// logical allocation has completed.
2540    ///
2541    /// If logical allocation fails, such as for an attached sub-tree (using
2542    /// AttachToken()), the server_end will close during that failure regardless
2543    /// of the number of buffers potenitally allocated in the overall logical
2544    /// buffer collection.
2545    ///
2546    /// The lifetime signalled by this event includes asynchronous cleanup of
2547    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2548    /// holders of VMO handles to the buffers have closed those VMO handles.
2549    /// Therefore clients should take care not to become blocked forever waiting
2550    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
2551    /// participants using the logical buffer collection are less trusted or
2552    /// less reliable.
2553    ///
2554    /// The buffers_remaining parameter allows waiting for all but
2555    /// buffers_remaining buffers to be fully deallocated.  This can be useful
2556    /// in situations where a known number of buffers are intentionally not
2557    /// closed so that the data can continue to be used, such as for keeping the
2558    /// last available video picture displayed in the UI even if the video
2559    /// stream was using protected output buffers.  It's outside the scope of
2560    /// the BufferCollection interface (at least for now) to determine how many
2561    /// buffers may be held without closing, but it'll typically be in the range
2562    /// 0-2.
2563    ///
2564    /// This mechanism is meant to be compatible with other protocols providing
2565    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2566    /// same event can be sent to more than one AttachLifetimeTracking(), and
2567    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2568    /// over conditions are met (all holders of duplicates have closed their
2569    /// handle(s)).
2570    ///
2571    /// There is no way to cancel an attach.  Closing the client end of the
2572    /// eventpair doesn't subtract from the number of pending attach(es).
2573    ///
2574    /// Closing the client's end doesn't result in any action by the server.
2575    /// If the server listens to events from the client end at all, it is for
2576    /// debug logging only.
2577    ///
2578    /// The server intentionally doesn't "trust" any bits signalled by the
2579    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2580    /// which can't be triggered early, and is only triggered when all handles
2581    /// to server_end are closed.  No meaning is associated with any of the
2582    /// other signal bits, and clients should functionally ignore any other
2583    /// signal bits on either end of the eventpair or its peer.
2584    ///
2585    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2586    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2587    /// transfer without causing CodecFactory channel failure).
2588    pub fn r#attach_lifetime_tracking(
2589        &self,
2590        mut server_end: fidl::EventPair,
2591        mut buffers_remaining: u32,
2592    ) -> Result<(), fidl::Error> {
2593        BufferCollectionProxyInterface::r#attach_lifetime_tracking(
2594            self,
2595            server_end,
2596            buffers_remaining,
2597        )
2598    }
2599}
2600
2601impl BufferCollectionProxyInterface for BufferCollectionProxy {
2602    type SyncResponseFut =
2603        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2604    fn r#sync(&self) -> Self::SyncResponseFut {
2605        fn _decode(
2606            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2607        ) -> Result<(), fidl::Error> {
2608            let _response = fidl::client::decode_transaction_body::<
2609                fidl::encoding::EmptyPayload,
2610                fidl::encoding::DefaultFuchsiaResourceDialect,
2611                0x4577e238ae26291,
2612            >(_buf?)?;
2613            Ok(_response)
2614        }
2615        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2616            (),
2617            0x4577e238ae26291,
2618            fidl::encoding::DynamicFlags::empty(),
2619            _decode,
2620        )
2621    }
2622
2623    fn r#close(&self) -> Result<(), fidl::Error> {
2624        self.client.send::<fidl::encoding::EmptyPayload>(
2625            (),
2626            0x5b1d7a4f5681fca7,
2627            fidl::encoding::DynamicFlags::empty(),
2628        )
2629    }
2630
2631    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2632        self.client.send::<NodeSetNameRequest>(
2633            (priority, name),
2634            0x77a41bb6217e2443,
2635            fidl::encoding::DynamicFlags::empty(),
2636        )
2637    }
2638
2639    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2640        self.client.send::<NodeSetDebugClientInfoRequest>(
2641            (name, id),
2642            0x7275759070eb5ee2,
2643            fidl::encoding::DynamicFlags::empty(),
2644        )
2645    }
2646
2647    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2648        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2649            (deadline,),
2650            0x46d38f4772638867,
2651            fidl::encoding::DynamicFlags::empty(),
2652        )
2653    }
2654
2655    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2656        self.client.send::<fidl::encoding::EmptyPayload>(
2657            (),
2658            0x6bfbe2cf1701d288,
2659            fidl::encoding::DynamicFlags::empty(),
2660        )
2661    }
2662
2663    type GetNodeRefResponseFut =
2664        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
2665    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2666        fn _decode(
2667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2668        ) -> Result<fidl::Event, fidl::Error> {
2669            let _response = fidl::client::decode_transaction_body::<
2670                NodeGetNodeRefResponse,
2671                fidl::encoding::DefaultFuchsiaResourceDialect,
2672                0x467b7c75c35c3b84,
2673            >(_buf?)?;
2674            Ok(_response.node_ref)
2675        }
2676        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
2677            (),
2678            0x467b7c75c35c3b84,
2679            fidl::encoding::DynamicFlags::empty(),
2680            _decode,
2681        )
2682    }
2683
2684    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2685        NodeIsAlternateForResult,
2686        fidl::encoding::DefaultFuchsiaResourceDialect,
2687    >;
2688    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
2689        fn _decode(
2690            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2691        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2692            let _response = fidl::client::decode_transaction_body::<
2693                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
2694                fidl::encoding::DefaultFuchsiaResourceDialect,
2695                0x33a2a7aff2776c07,
2696            >(_buf?)?;
2697            Ok(_response.map(|x| x.is_alternate))
2698        }
2699        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2700            (node_ref,),
2701            0x33a2a7aff2776c07,
2702            fidl::encoding::DynamicFlags::empty(),
2703            _decode,
2704        )
2705    }
2706
2707    fn r#set_constraints(
2708        &self,
2709        mut has_constraints: bool,
2710        mut constraints: &BufferCollectionConstraints,
2711    ) -> Result<(), fidl::Error> {
2712        self.client.send::<BufferCollectionSetConstraintsRequest>(
2713            (has_constraints, constraints),
2714            0x4d9c3406c213227b,
2715            fidl::encoding::DynamicFlags::empty(),
2716        )
2717    }
2718
2719    type WaitForBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2720        (i32, BufferCollectionInfo2),
2721        fidl::encoding::DefaultFuchsiaResourceDialect,
2722    >;
2723    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut {
2724        fn _decode(
2725            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2726        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
2727            let _response = fidl::client::decode_transaction_body::<
2728                BufferCollectionWaitForBuffersAllocatedResponse,
2729                fidl::encoding::DefaultFuchsiaResourceDialect,
2730                0x714667ea2a29a3a2,
2731            >(_buf?)?;
2732            Ok((_response.status, _response.buffer_collection_info))
2733        }
2734        self.client
2735            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
2736                (),
2737                0x714667ea2a29a3a2,
2738                fidl::encoding::DynamicFlags::empty(),
2739                _decode,
2740            )
2741    }
2742
2743    type CheckBuffersAllocatedResponseFut =
2744        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
2745    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut {
2746        fn _decode(
2747            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2748        ) -> Result<i32, fidl::Error> {
2749            let _response = fidl::client::decode_transaction_body::<
2750                BufferCollectionCheckBuffersAllocatedResponse,
2751                fidl::encoding::DefaultFuchsiaResourceDialect,
2752                0x245bb81f79189e9,
2753            >(_buf?)?;
2754            Ok(_response.status)
2755        }
2756        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
2757            (),
2758            0x245bb81f79189e9,
2759            fidl::encoding::DynamicFlags::empty(),
2760            _decode,
2761        )
2762    }
2763
2764    fn r#set_constraints_aux_buffers(
2765        &self,
2766        mut constraints: &BufferCollectionConstraintsAuxBuffers,
2767    ) -> Result<(), fidl::Error> {
2768        self.client.send::<BufferCollectionSetConstraintsAuxBuffersRequest>(
2769            (constraints,),
2770            0x1ad80e63c090d817,
2771            fidl::encoding::DynamicFlags::empty(),
2772        )
2773    }
2774
2775    type GetAuxBuffersResponseFut = fidl::client::QueryResponseFut<
2776        (i32, BufferCollectionInfo2),
2777        fidl::encoding::DefaultFuchsiaResourceDialect,
2778    >;
2779    fn r#get_aux_buffers(&self) -> Self::GetAuxBuffersResponseFut {
2780        fn _decode(
2781            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2782        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
2783            let _response = fidl::client::decode_transaction_body::<
2784                BufferCollectionGetAuxBuffersResponse,
2785                fidl::encoding::DefaultFuchsiaResourceDialect,
2786                0x6c6cac6000a29a55,
2787            >(_buf?)?;
2788            Ok((_response.status, _response.buffer_collection_info_aux_buffers))
2789        }
2790        self.client
2791            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
2792                (),
2793                0x6c6cac6000a29a55,
2794                fidl::encoding::DynamicFlags::empty(),
2795                _decode,
2796            )
2797    }
2798
2799    fn r#attach_token(
2800        &self,
2801        mut rights_attenuation_mask: u32,
2802        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2803    ) -> Result<(), fidl::Error> {
2804        self.client.send::<BufferCollectionAttachTokenRequest>(
2805            (rights_attenuation_mask, token_request),
2806            0x6f5adcca4ac7443e,
2807            fidl::encoding::DynamicFlags::empty(),
2808        )
2809    }
2810
2811    fn r#attach_lifetime_tracking(
2812        &self,
2813        mut server_end: fidl::EventPair,
2814        mut buffers_remaining: u32,
2815    ) -> Result<(), fidl::Error> {
2816        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2817            (server_end, buffers_remaining),
2818            0x170d0f1d89d50989,
2819            fidl::encoding::DynamicFlags::empty(),
2820        )
2821    }
2822}
2823
2824pub struct BufferCollectionEventStream {
2825    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2826}
2827
2828impl std::marker::Unpin for BufferCollectionEventStream {}
2829
2830impl futures::stream::FusedStream for BufferCollectionEventStream {
2831    fn is_terminated(&self) -> bool {
2832        self.event_receiver.is_terminated()
2833    }
2834}
2835
2836impl futures::Stream for BufferCollectionEventStream {
2837    type Item = Result<BufferCollectionEvent, fidl::Error>;
2838
2839    fn poll_next(
2840        mut self: std::pin::Pin<&mut Self>,
2841        cx: &mut std::task::Context<'_>,
2842    ) -> std::task::Poll<Option<Self::Item>> {
2843        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2844            &mut self.event_receiver,
2845            cx
2846        )?) {
2847            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2848            None => std::task::Poll::Ready(None),
2849        }
2850    }
2851}
2852
2853#[derive(Debug)]
2854pub enum BufferCollectionEvent {}
2855
2856impl BufferCollectionEvent {
2857    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2858    fn decode(
2859        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2860    ) -> Result<BufferCollectionEvent, fidl::Error> {
2861        let (bytes, _handles) = buf.split_mut();
2862        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2863        debug_assert_eq!(tx_header.tx_id, 0);
2864        match tx_header.ordinal {
2865            _ => Err(fidl::Error::UnknownOrdinal {
2866                ordinal: tx_header.ordinal,
2867                protocol_name:
2868                    <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2869            }),
2870        }
2871    }
2872}
2873
2874/// A Stream of incoming requests for fuchsia.sysmem/BufferCollection.
2875pub struct BufferCollectionRequestStream {
2876    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2877    is_terminated: bool,
2878}
2879
2880impl std::marker::Unpin for BufferCollectionRequestStream {}
2881
2882impl futures::stream::FusedStream for BufferCollectionRequestStream {
2883    fn is_terminated(&self) -> bool {
2884        self.is_terminated
2885    }
2886}
2887
2888impl fidl::endpoints::RequestStream for BufferCollectionRequestStream {
2889    type Protocol = BufferCollectionMarker;
2890    type ControlHandle = BufferCollectionControlHandle;
2891
2892    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2893        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2894    }
2895
2896    fn control_handle(&self) -> Self::ControlHandle {
2897        BufferCollectionControlHandle { inner: self.inner.clone() }
2898    }
2899
2900    fn into_inner(
2901        self,
2902    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2903    {
2904        (self.inner, self.is_terminated)
2905    }
2906
2907    fn from_inner(
2908        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2909        is_terminated: bool,
2910    ) -> Self {
2911        Self { inner, is_terminated }
2912    }
2913}
2914
2915impl futures::Stream for BufferCollectionRequestStream {
2916    type Item = Result<BufferCollectionRequest, fidl::Error>;
2917
2918    fn poll_next(
2919        mut self: std::pin::Pin<&mut Self>,
2920        cx: &mut std::task::Context<'_>,
2921    ) -> std::task::Poll<Option<Self::Item>> {
2922        let this = &mut *self;
2923        if this.inner.check_shutdown(cx) {
2924            this.is_terminated = true;
2925            return std::task::Poll::Ready(None);
2926        }
2927        if this.is_terminated {
2928            panic!("polled BufferCollectionRequestStream after completion");
2929        }
2930        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2931            |bytes, handles| {
2932                match this.inner.channel().read_etc(cx, bytes, handles) {
2933                    std::task::Poll::Ready(Ok(())) => {}
2934                    std::task::Poll::Pending => return std::task::Poll::Pending,
2935                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2936                        this.is_terminated = true;
2937                        return std::task::Poll::Ready(None);
2938                    }
2939                    std::task::Poll::Ready(Err(e)) => {
2940                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2941                            e.into(),
2942                        ))))
2943                    }
2944                }
2945
2946                // A message has been received from the channel
2947                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2948
2949                std::task::Poll::Ready(Some(match header.ordinal {
2950                    0x4577e238ae26291 => {
2951                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2952                        let mut req = fidl::new_empty!(
2953                            fidl::encoding::EmptyPayload,
2954                            fidl::encoding::DefaultFuchsiaResourceDialect
2955                        );
2956                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2957                        let control_handle =
2958                            BufferCollectionControlHandle { inner: this.inner.clone() };
2959                        Ok(BufferCollectionRequest::Sync {
2960                            responder: BufferCollectionSyncResponder {
2961                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2962                                tx_id: header.tx_id,
2963                            },
2964                        })
2965                    }
2966                    0x5b1d7a4f5681fca7 => {
2967                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2968                        let mut req = fidl::new_empty!(
2969                            fidl::encoding::EmptyPayload,
2970                            fidl::encoding::DefaultFuchsiaResourceDialect
2971                        );
2972                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2973                        let control_handle =
2974                            BufferCollectionControlHandle { inner: this.inner.clone() };
2975                        Ok(BufferCollectionRequest::Close { control_handle })
2976                    }
2977                    0x77a41bb6217e2443 => {
2978                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2979                        let mut req = fidl::new_empty!(
2980                            NodeSetNameRequest,
2981                            fidl::encoding::DefaultFuchsiaResourceDialect
2982                        );
2983                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2984                        let control_handle =
2985                            BufferCollectionControlHandle { inner: this.inner.clone() };
2986                        Ok(BufferCollectionRequest::SetName {
2987                            priority: req.priority,
2988                            name: req.name,
2989
2990                            control_handle,
2991                        })
2992                    }
2993                    0x7275759070eb5ee2 => {
2994                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2995                        let mut req = fidl::new_empty!(
2996                            NodeSetDebugClientInfoRequest,
2997                            fidl::encoding::DefaultFuchsiaResourceDialect
2998                        );
2999                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
3000                        let control_handle =
3001                            BufferCollectionControlHandle { inner: this.inner.clone() };
3002                        Ok(BufferCollectionRequest::SetDebugClientInfo {
3003                            name: req.name,
3004                            id: req.id,
3005
3006                            control_handle,
3007                        })
3008                    }
3009                    0x46d38f4772638867 => {
3010                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3011                        let mut req = fidl::new_empty!(
3012                            NodeSetDebugTimeoutLogDeadlineRequest,
3013                            fidl::encoding::DefaultFuchsiaResourceDialect
3014                        );
3015                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
3016                        let control_handle =
3017                            BufferCollectionControlHandle { inner: this.inner.clone() };
3018                        Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {
3019                            deadline: req.deadline,
3020
3021                            control_handle,
3022                        })
3023                    }
3024                    0x6bfbe2cf1701d288 => {
3025                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3026                        let mut req = fidl::new_empty!(
3027                            fidl::encoding::EmptyPayload,
3028                            fidl::encoding::DefaultFuchsiaResourceDialect
3029                        );
3030                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3031                        let control_handle =
3032                            BufferCollectionControlHandle { inner: this.inner.clone() };
3033                        Ok(BufferCollectionRequest::SetVerboseLogging { control_handle })
3034                    }
3035                    0x467b7c75c35c3b84 => {
3036                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3037                        let mut req = fidl::new_empty!(
3038                            fidl::encoding::EmptyPayload,
3039                            fidl::encoding::DefaultFuchsiaResourceDialect
3040                        );
3041                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3042                        let control_handle =
3043                            BufferCollectionControlHandle { inner: this.inner.clone() };
3044                        Ok(BufferCollectionRequest::GetNodeRef {
3045                            responder: BufferCollectionGetNodeRefResponder {
3046                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3047                                tx_id: header.tx_id,
3048                            },
3049                        })
3050                    }
3051                    0x33a2a7aff2776c07 => {
3052                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3053                        let mut req = fidl::new_empty!(
3054                            NodeIsAlternateForRequest,
3055                            fidl::encoding::DefaultFuchsiaResourceDialect
3056                        );
3057                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
3058                        let control_handle =
3059                            BufferCollectionControlHandle { inner: this.inner.clone() };
3060                        Ok(BufferCollectionRequest::IsAlternateFor {
3061                            node_ref: req.node_ref,
3062
3063                            responder: BufferCollectionIsAlternateForResponder {
3064                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3065                                tx_id: header.tx_id,
3066                            },
3067                        })
3068                    }
3069                    0x4d9c3406c213227b => {
3070                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3071                        let mut req = fidl::new_empty!(
3072                            BufferCollectionSetConstraintsRequest,
3073                            fidl::encoding::DefaultFuchsiaResourceDialect
3074                        );
3075                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
3076                        let control_handle =
3077                            BufferCollectionControlHandle { inner: this.inner.clone() };
3078                        Ok(BufferCollectionRequest::SetConstraints {
3079                            has_constraints: req.has_constraints,
3080                            constraints: req.constraints,
3081
3082                            control_handle,
3083                        })
3084                    }
3085                    0x714667ea2a29a3a2 => {
3086                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3087                        let mut req = fidl::new_empty!(
3088                            fidl::encoding::EmptyPayload,
3089                            fidl::encoding::DefaultFuchsiaResourceDialect
3090                        );
3091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3092                        let control_handle =
3093                            BufferCollectionControlHandle { inner: this.inner.clone() };
3094                        Ok(BufferCollectionRequest::WaitForBuffersAllocated {
3095                            responder: BufferCollectionWaitForBuffersAllocatedResponder {
3096                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3097                                tx_id: header.tx_id,
3098                            },
3099                        })
3100                    }
3101                    0x245bb81f79189e9 => {
3102                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3103                        let mut req = fidl::new_empty!(
3104                            fidl::encoding::EmptyPayload,
3105                            fidl::encoding::DefaultFuchsiaResourceDialect
3106                        );
3107                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3108                        let control_handle =
3109                            BufferCollectionControlHandle { inner: this.inner.clone() };
3110                        Ok(BufferCollectionRequest::CheckBuffersAllocated {
3111                            responder: BufferCollectionCheckBuffersAllocatedResponder {
3112                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3113                                tx_id: header.tx_id,
3114                            },
3115                        })
3116                    }
3117                    0x1ad80e63c090d817 => {
3118                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3119                        let mut req = fidl::new_empty!(
3120                            BufferCollectionSetConstraintsAuxBuffersRequest,
3121                            fidl::encoding::DefaultFuchsiaResourceDialect
3122                        );
3123                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionSetConstraintsAuxBuffersRequest>(&header, _body_bytes, handles, &mut req)?;
3124                        let control_handle =
3125                            BufferCollectionControlHandle { inner: this.inner.clone() };
3126                        Ok(BufferCollectionRequest::SetConstraintsAuxBuffers {
3127                            constraints: req.constraints,
3128
3129                            control_handle,
3130                        })
3131                    }
3132                    0x6c6cac6000a29a55 => {
3133                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3134                        let mut req = fidl::new_empty!(
3135                            fidl::encoding::EmptyPayload,
3136                            fidl::encoding::DefaultFuchsiaResourceDialect
3137                        );
3138                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3139                        let control_handle =
3140                            BufferCollectionControlHandle { inner: this.inner.clone() };
3141                        Ok(BufferCollectionRequest::GetAuxBuffers {
3142                            responder: BufferCollectionGetAuxBuffersResponder {
3143                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3144                                tx_id: header.tx_id,
3145                            },
3146                        })
3147                    }
3148                    0x6f5adcca4ac7443e => {
3149                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3150                        let mut req = fidl::new_empty!(
3151                            BufferCollectionAttachTokenRequest,
3152                            fidl::encoding::DefaultFuchsiaResourceDialect
3153                        );
3154                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
3155                        let control_handle =
3156                            BufferCollectionControlHandle { inner: this.inner.clone() };
3157                        Ok(BufferCollectionRequest::AttachToken {
3158                            rights_attenuation_mask: req.rights_attenuation_mask,
3159                            token_request: req.token_request,
3160
3161                            control_handle,
3162                        })
3163                    }
3164                    0x170d0f1d89d50989 => {
3165                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3166                        let mut req = fidl::new_empty!(
3167                            BufferCollectionAttachLifetimeTrackingRequest,
3168                            fidl::encoding::DefaultFuchsiaResourceDialect
3169                        );
3170                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3171                        let control_handle =
3172                            BufferCollectionControlHandle { inner: this.inner.clone() };
3173                        Ok(BufferCollectionRequest::AttachLifetimeTracking {
3174                            server_end: req.server_end,
3175                            buffers_remaining: req.buffers_remaining,
3176
3177                            control_handle,
3178                        })
3179                    }
3180                    _ => Err(fidl::Error::UnknownOrdinal {
3181                        ordinal: header.ordinal,
3182                        protocol_name:
3183                            <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3184                    }),
3185                }))
3186            },
3187        )
3188    }
3189}
3190
3191/// BufferCollection is a connection directly from a participant to sysmem re.
3192/// a logical BufferCollection; typically the logical BufferCollection is shared
3193/// with other participants.  In other words, an instance of the BufferCollection
3194/// interface is a view of a "logical buffer collection".
3195///
3196/// This connection exists to facilitate async indication of when the logical
3197/// BufferCollection has been populated with buffers.
3198///
3199/// Also, the channel's closure by the server is an indication to the client
3200/// that the client should close all VMO handles that were obtained from the
3201/// BufferCollection ASAP.
3202///
3203/// Also, this interface may in future allow specifying constraints in other
3204/// ways, and may allow for back-and-forth negotiation of constraints to some
3205/// degree.
3206///
3207/// This interface may in future allow for more than 64 VMO handles per
3208/// BufferCollection, but currently the limit is 64.
3209///
3210/// This interface may in future allow for allocating/deallocating single
3211/// buffers.
3212///
3213/// Some initiators may wait a short duration until all old logical
3214/// BufferCollection VMO handles have closed (or until the short duration times
3215/// out) before allocating a new BufferCollection, to help control physical
3216/// memory fragmentation and avoid overlap of buffer allocation lifetimes for
3217/// the old and new collections. Collections can be large enough that it's worth
3218/// avoiding allocation overlap (in time).
3219#[derive(Debug)]
3220pub enum BufferCollectionRequest {
3221    /// Ensure that previous messages, including Duplicate() messages on a
3222    /// token, collection, or group, have been received server side.
3223    ///
3224    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
3225    /// valid sysmem token risks the Sync() hanging forever.  See
3226    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
3227    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
3228    /// Another way is to pass the token to BindSharedCollection(), which also
3229    /// validates the token as part of exchanging it for a BufferCollection
3230    /// channel, and BufferCollection Sync() can then be used.
3231    ///
3232    /// After a Sync(), it's then safe to send the client end of token_request
3233    /// to another participant knowing the server will recognize the token when
3234    /// it's sent into BindSharedCollection() by the other participant.
3235    ///
3236    /// Other options include waiting for each token.Duplicate() to complete
3237    /// individually (using separate call to token.Sync() after each), or
3238    /// calling Sync() on BufferCollection after the token has been turned in
3239    /// via BindSharedCollection().
3240    ///
3241    /// Another way to mitigate is to avoid calling Sync() on the token, and
3242    /// instead later deal with potential failure of BufferCollection.Sync() if
3243    /// the original token was invalid.  This option can be preferable from a
3244    /// performance point of view, but requires client code to delay sending
3245    /// tokens duplicated from this token until after client code has converted
3246    /// the duplicating token to a BufferCollection and received successful
3247    /// response from BufferCollection.Sync().
3248    ///
3249    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
3250    /// When BufferCollection.Sync() isn't feasible, the caller must already
3251    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
3252    /// hang forever.  See ValidateBufferCollectionToken() to check token
3253    /// validity first if the token isn't already known to be (is/was) valid.
3254    Sync {
3255        responder: BufferCollectionSyncResponder,
3256    },
3257    /// On a BufferCollectionToken channel:
3258    ///
3259    /// Normally a participant will convert a BufferCollectionToken into a
3260    /// BufferCollection view, but a participant is also free to Close() the
3261    /// token (and then close the channel immediately or shortly later in
3262    /// response to server closing its end), which avoids causing logical buffer
3263    /// collection failure.  Normally an unexpected token channel close will
3264    /// cause logical buffer collection failure (the only exceptions being
3265    /// certain cases involving AttachToken() or SetDispensable()).
3266    ///
3267    /// On a BufferCollection channel:
3268    ///
3269    /// By default the server handles unexpected failure of a BufferCollection
3270    /// by failing the whole logical buffer collection.  Partly this is to
3271    /// expedite closing VMO handles to reclaim memory when any participant
3272    /// fails.  If a participant would like to cleanly close a BufferCollection
3273    /// view without causing logical buffer collection failure, the participant
3274    /// can send Close() before closing the client end of the BufferCollection
3275    /// channel.  If this is the last BufferCollection view, the logical buffer
3276    /// collection will still go away.  The Close() can occur before or after
3277    /// SetConstraints().  If before SetConstraints(), the buffer collection
3278    /// won't require constraints from this node in order to allocate.  If
3279    /// after SetConstraints(), the constraints are retained and aggregated
3280    /// along with any subsequent logical allocation(s), despite the lack of
3281    /// channel connection.
3282    ///
3283    /// On a BufferCollectionTokenGroup channel:
3284    ///
3285    /// By default, unexpected failure of a BufferCollectionTokenGroup will
3286    /// trigger failure of the logical BufferCollectionTokenGroup and will
3287    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
3288    /// channel without failing the logical group or propagating failure, send
3289    /// Close() before closing the channel client endpoint.
3290    ///
3291    /// If Close() occurs before AllChildrenPresent(), the logical buffer
3292    /// collection will still fail despite the Close() (because sysmem can't be
3293    /// sure whether all relevant children were created, so it's ambiguous
3294    /// whether all relevant constraints will be provided to sysmem).  If
3295    /// Close() occurs after AllChildrenPresent(), the children and all their
3296    /// constraints remain intact (just as they would if the
3297    /// BufferCollectionTokenGroup channel had remained open), and the close
3298    /// doesn't trigger or propagate failure.
3299    Close {
3300        control_handle: BufferCollectionControlHandle,
3301    },
3302    /// Set a name for VMOs in this buffer collection. The name may be truncated
3303    /// shorter. The name only affects VMOs allocated after it's set - this call
3304    /// does not rename existing VMOs. If multiple clients set different names
3305    /// then the larger priority value will win.
3306    SetName {
3307        priority: u32,
3308        name: String,
3309        control_handle: BufferCollectionControlHandle,
3310    },
3311    /// Set information about the current client that can be used by sysmem to
3312    /// help debug leaking memory and hangs waiting for constraints. |name| can
3313    /// be an arbitrary string, but the current process name (see
3314    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
3315    /// arbitrary id, but the current process ID (see
3316    /// fsl::GetCurrentProcessKoid()) is a good default.
3317    ///
3318    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
3319    /// indicate which client is closing their channel first, leading to
3320    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
3321    /// over, but if happening earlier than expected, the
3322    /// client-channel-specific name can help diagnose where the failure is
3323    /// first coming from, from sysmem's point of view).
3324    ///
3325    /// By default (unless overriden by this message or using
3326    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
3327    /// parent Node at the time the child Node is created.  While this can be
3328    /// better than nothing, it's often better for each participant to use
3329    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
3330    /// info directly relevant to the current client.  Also, SetVerboseLogging()
3331    /// can be used to help disambiguate if a Node is suspected of having info
3332    /// that was copied from its parent.
3333    SetDebugClientInfo {
3334        name: String,
3335        id: u64,
3336        control_handle: BufferCollectionControlHandle,
3337    },
3338    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
3339    /// after creating a collection. Clients can call this method to change
3340    /// when the log is printed. If multiple client set the deadline, it's
3341    /// unspecified which deadline will take effect.
3342    SetDebugTimeoutLogDeadline {
3343        deadline: i64,
3344        control_handle: BufferCollectionControlHandle,
3345    },
3346    /// Verbose logging includes constraints set via SetConstraints() from each
3347    /// client along with info set via SetDebugClientInfo() and the structure of
3348    /// the tree of Node(s).
3349    ///
3350    /// Normally sysmem prints only a single line complaint when aggregation
3351    /// fails, with just the specific detailed reason that aggregation failed,
3352    /// with minimal context.  While this is often enough to diagnose a problem
3353    /// if only a small change was made and the system had been working before
3354    /// the small change, it's often not particularly helpful for getting a new
3355    /// buffer collection to work for the first time.  Especially with more
3356    /// complex trees of nodes, involving things like AttachToken(),
3357    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
3358    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
3359    /// looks like and why it's failing a logical allocation, or why a tree or
3360    /// sub-tree is failing sooner than expected.
3361    ///
3362    /// The intent of the extra logging is to be acceptable from a performance
3363    /// point of view, if only enabled on a low number of buffer collections.
3364    /// If we're not tracking down a bug, we shouldn't send this message.
3365    ///
3366    /// If too many participants leave verbose logging enabled, we may end up
3367    /// needing to require that system-wide sysmem verbose logging be permitted
3368    /// via some other setting, to avoid sysmem spamming the log too much due to
3369    /// this message.
3370    ///
3371    /// This may be a NOP for some nodes due to intentional policy associated
3372    /// with the node, if we don't trust a node enough to let it turn on verbose
3373    /// logging.
3374    SetVerboseLogging {
3375        control_handle: BufferCollectionControlHandle,
3376    },
3377    /// This gets an event handle that can be used as a parameter to
3378    /// IsAlternateFor() called on any Node.  The client will not be granted the
3379    /// right to signal this event, as this handle should only be used as proof
3380    /// that the client obtained this handle from this Node.
3381    ///
3382    /// Because this is a get not a set, no Sync() is needed between the
3383    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
3384    /// potentially being on different channels.
3385    ///
3386    /// See also IsAlternateFor().
3387    GetNodeRef {
3388        responder: BufferCollectionGetNodeRefResponder,
3389    },
3390    /// This checks whether the calling node is in a subtree rooted at a
3391    /// different child token of a common parent BufferCollectionTokenGroup, in
3392    /// relation to the passed-in node_ref.
3393    ///
3394    /// This call is for assisting with admission control de-duplication, and
3395    /// with debugging.
3396    ///
3397    /// The node_ref must be obtained using GetNodeRef() of a
3398    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
3399    ///
3400    /// The node_ref can be a duplicated handle; it's not necessary to call
3401    /// GetNodeRef() for every call to IsAlternateFor().
3402    ///
3403    /// If a calling token may not actually be a valid token at all due to
3404    /// a potentially hostile/untrusted provider of the token, call
3405    /// ValidateBufferCollectionToken() first instead of potentially getting
3406    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
3407    /// token not being a real token (not really talking to sysmem).  Another
3408    /// option is to call BindSharedCollection with this token first which also
3409    /// validates the token along with converting it to a BufferCollection, then
3410    /// call BufferCollection IsAlternateFor().
3411    ///
3412    /// error values:
3413    ///
3414    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
3415    /// buffer collection as the calling Node.  Before logical allocation and
3416    /// within the same logical allocation sub-tree, this essentially means that
3417    /// the node_ref was never part of this logical buffer collection, since
3418    /// before logical allocation all node_refs that come into existence remain
3419    /// in existence at least until logical allocation (including Node(s) that
3420    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
3421    /// to be returned, this Node's channel needs to still be connected server
3422    /// side, which won't be the case if the whole logical allocation has
3423    /// failed.  After logical allocation or in a different logical allocation
3424    /// sub-tree there are additional potential reasons for this error.  For
3425    /// example a different logical allocation (separated from this Node(s)
3426    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
3427    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
3428    /// exist and may select a different child sub-tree than the sub-tree the
3429    /// node_ref is in causing deletion of the node_ref Node.  The only time
3430    /// sysmem keeps a Node around after that Node has no corresponding channel
3431    /// is when Close() is used and the Node's sub-tree has not yet failed.
3432    /// Another reason for this error is if the node_ref is an eventpair handle
3433    /// with sufficient rights, but isn't actually a real node_ref obtained from
3434    /// GetNodeRef().
3435    ///
3436    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
3437    /// eventpair handle, or doesn't have the needed rights expected on a real
3438    /// node_ref.
3439    ///
3440    /// No other failing status codes are returned by this call.  However,
3441    /// sysmem may add additional codes in future, so the client should have
3442    /// sensible default handling for any failing status code.
3443    ///
3444    /// On success, is_alternate has the following meaning:
3445    ///   * true - The first parent node in common between the calling node and
3446    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
3447    ///     the calling Node and the node_ref Node will _not_ have both their
3448    ///     constraints apply - rather sysmem will choose one or the other of
3449    ///     the constraints - never both.  This is because only one child of
3450    ///     a BufferCollectionTokenGroup is selected during logical allocation,
3451    ///     with only that one child's sub-tree contributing to constraints
3452    ///     aggregation.
3453    ///   * false - The first parent node in common between the calling Node and
3454    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
3455    ///     this means the first parent node in common is a
3456    ///     BufferCollectionToken or BufferCollection (regardless of not
3457    ///     Close()ed or Close()ed).  This means that the calling Node and the
3458    ///     node_ref Node _may_ have both their constraints apply during
3459    ///     constraints aggregation of the logical allocation, if both Node(s)
3460    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
3461    ///     In this case, there is no BufferCollectionTokenGroup that will
3462    ///     directly prevent the two Node(s) from both being selected and their
3463    ///     constraints both aggregated, but even when false, one or both
3464    ///     Node(s) may still be eliminated from consideration if one or both
3465    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
3466    ///     which selects a child sub-tree other than the sub-tree containing
3467    ///     the calling Node or node_ref Node.
3468    IsAlternateFor {
3469        node_ref: fidl::Event,
3470        responder: BufferCollectionIsAlternateForResponder,
3471    },
3472    /// Provide BufferCollectionConstraints to the logical BufferCollection.
3473    ///
3474    /// A participant may only call SetConstraints() once.
3475    ///
3476    /// Sometimes the initiator is a participant only in the sense of wanting to
3477    /// keep an eye on success/failure to populate with buffers, and zx.Status
3478    /// on failure.  In that case, `has_constraints` can be false, and
3479    /// `constraints` will be ignored.
3480    ///
3481    /// VMO handles will not be provided to the client that sends null
3482    /// constraints - that can be intentional for an initiator that doesn't need
3483    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
3484    /// adjusting which portion of a buffer is considered valid and similar, but
3485    /// the initiator can't hold a VMO handle open to prevent the logical
3486    /// BufferCollection from cleaning up if the logical BufferCollection needs
3487    /// to go away regardless of the initiator's degree of involvement for
3488    /// whatever reason.
3489    ///
3490    /// For population of buffers to be attempted, all holders of a
3491    /// BufferCollection client channel need to call SetConstraints() before
3492    /// sysmem will attempt to allocate buffers.
3493    ///
3494    /// `has_constraints` if false, the constraints are effectively null, and
3495    /// `constraints` are ignored.  The sender of null constraints won't get any
3496    /// VMO handles in BufferCollectionInfo, but can still find out how many
3497    /// buffers were allocated and can still refer to buffers by their
3498    /// buffer_index.
3499    ///
3500    /// `constraints` are constraints on the buffer collection.
3501    SetConstraints {
3502        has_constraints: bool,
3503        constraints: BufferCollectionConstraints,
3504        control_handle: BufferCollectionControlHandle,
3505    },
3506    /// This request completes when buffers have been allocated, responds with
3507    /// some failure detail if allocation has been attempted but failed.
3508    ///
3509    /// The following must occur before buffers will be allocated:
3510    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
3511    ///     must be turned in via BindSharedCollection().
3512    ///   * All BufferCollection(s) of the logical BufferCollection must have
3513    ///     had SetConstraints() sent to them.
3514    ///
3515    /// Returns `ZX_OK` if successful.
3516    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
3517    /// fulfilled due to resource exhaustion.
3518    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
3519    /// obtain the buffers it requested.
3520    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
3521    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
3522    /// satisfied, perhaps due to hardware limitations.
3523    ///
3524    /// `buffer_collection_info` has the VMO handles and other related info.
3525    WaitForBuffersAllocated {
3526        responder: BufferCollectionWaitForBuffersAllocatedResponder,
3527    },
3528    /// This returns the same result code as WaitForBuffersAllocated if the
3529    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
3530    /// if WaitForBuffersAllocated would block.
3531    CheckBuffersAllocated {
3532        responder: BufferCollectionCheckBuffersAllocatedResponder,
3533    },
3534    SetConstraintsAuxBuffers {
3535        constraints: BufferCollectionConstraintsAuxBuffers,
3536        control_handle: BufferCollectionControlHandle,
3537    },
3538    GetAuxBuffers {
3539        responder: BufferCollectionGetAuxBuffersResponder,
3540    },
3541    /// Create a new token, for trying to add a new participant to an existing
3542    /// collection, if the existing collection's buffer counts, constraints,
3543    /// and participants allow.
3544    ///
3545    /// This can be useful in replacing a failed participant, and/or in
3546    /// adding/re-adding a participant after buffers have already been
3547    /// allocated.
3548    ///
3549    /// Failure of an attached token / collection does not propagate to the
3550    /// parent of the attached token.  Failure does propagate from a normal
3551    /// child of a dispensable token to the dispensable token.  Failure
3552    /// of a child is blocked from reaching its parent if the child is attached,
3553    /// or if the child is dispensable and the failure occurred after logical
3554    /// allocation.
3555    ///
3556    /// An initiator may in some scenarios choose to initially use a dispensable
3557    /// token for a given instance of a participant, and then later if the first
3558    /// instance of that participant fails, a new second instance of that
3559    /// participant my be given a token created with AttachToken().
3560    ///
3561    /// From the point of view of the client end of the BufferCollectionToken
3562    /// channel, the token acts like any other token.  The client can
3563    /// Duplicate() the token as needed, and can send the token to a different
3564    /// process.  The token should be converted to a BufferCollection channel
3565    /// as normal by calling BindSharedCollection().  SetConstraints() should
3566    /// be called on that BufferCollection channel.
3567    ///
3568    /// A success result from WaitForBuffersAllocated() means the new
3569    /// participant's constraints were satisfiable using the already-existing
3570    /// buffer collection, the already-established BufferCollectionInfo
3571    /// including image format constraints, and the already-existing other
3572    /// participants and their buffer counts.  A failure result means the new
3573    /// participant's constraints cannot be satisfied using the existing
3574    /// buffer collection and its already-logically-allocated participants.
3575    /// Creating a new collection instead may allow all participant's
3576    /// constraints to be satisfied, assuming SetDispensable() is used in place
3577    /// of AttachToken(), or a normal token is used.
3578    ///
3579    /// A token created with AttachToken() performs constraints aggregation with
3580    /// all constraints currently in effect on the buffer collection, plus the
3581    /// attached token under consideration plus child tokens under the attached
3582    /// token which are not themselves an attached token or under such a token.
3583    ///
3584    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
3585    /// first-come first-served, but a child can't logically allocate before
3586    /// all its parents have sent SetConstraints().
3587    ///
3588    /// See also SetDispensable(), which in contrast to AttachToken(), has the
3589    /// created token + children participate in constraints aggregation along
3590    /// with its parent.
3591    ///
3592    /// The newly created token needs to be Sync()ed to sysmem before the new
3593    /// token can be passed to BindSharedCollection().  The Sync() of the new
3594    /// token can be accomplished with BufferCollection.Sync() on this
3595    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
3596    /// token also works.  A BufferCollectionToken.Sync() can be started after
3597    /// any BufferCollectionToken.Duplicate() messages have been sent via the
3598    /// newly created token, to also sync those additional tokens to sysmem
3599    /// using a single round-trip.
3600    ///
3601    /// These values for rights_attenuation_mask result in no attenuation (note
3602    /// that 0 is not on this list; 0 will output an ERROR to the system log
3603    /// to help diagnose the bug in client code):
3604    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
3605    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3606    AttachToken {
3607        rights_attenuation_mask: u32,
3608        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3609        control_handle: BufferCollectionControlHandle,
3610    },
3611    /// AttachLifetimeTracking:
3612    ///
3613    /// AttachLifetimeTracking() is intended to allow a client to wait until an
3614    /// old logical buffer collection is fully or mostly deallocated before
3615    /// attempting allocation of a new logical buffer collection.
3616    ///
3617    /// Attach an eventpair endpoint to the logical buffer collection, so that
3618    /// the server_end will be closed when the number of buffers allocated
3619    /// drops to 'buffers_remaining'.  The server_end won't close until after
3620    /// logical allocation has completed.
3621    ///
3622    /// If logical allocation fails, such as for an attached sub-tree (using
3623    /// AttachToken()), the server_end will close during that failure regardless
3624    /// of the number of buffers potenitally allocated in the overall logical
3625    /// buffer collection.
3626    ///
3627    /// The lifetime signalled by this event includes asynchronous cleanup of
3628    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3629    /// holders of VMO handles to the buffers have closed those VMO handles.
3630    /// Therefore clients should take care not to become blocked forever waiting
3631    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
3632    /// participants using the logical buffer collection are less trusted or
3633    /// less reliable.
3634    ///
3635    /// The buffers_remaining parameter allows waiting for all but
3636    /// buffers_remaining buffers to be fully deallocated.  This can be useful
3637    /// in situations where a known number of buffers are intentionally not
3638    /// closed so that the data can continue to be used, such as for keeping the
3639    /// last available video picture displayed in the UI even if the video
3640    /// stream was using protected output buffers.  It's outside the scope of
3641    /// the BufferCollection interface (at least for now) to determine how many
3642    /// buffers may be held without closing, but it'll typically be in the range
3643    /// 0-2.
3644    ///
3645    /// This mechanism is meant to be compatible with other protocols providing
3646    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
3647    /// same event can be sent to more than one AttachLifetimeTracking(), and
3648    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
3649    /// over conditions are met (all holders of duplicates have closed their
3650    /// handle(s)).
3651    ///
3652    /// There is no way to cancel an attach.  Closing the client end of the
3653    /// eventpair doesn't subtract from the number of pending attach(es).
3654    ///
3655    /// Closing the client's end doesn't result in any action by the server.
3656    /// If the server listens to events from the client end at all, it is for
3657    /// debug logging only.
3658    ///
3659    /// The server intentionally doesn't "trust" any bits signalled by the
3660    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
3661    /// which can't be triggered early, and is only triggered when all handles
3662    /// to server_end are closed.  No meaning is associated with any of the
3663    /// other signal bits, and clients should functionally ignore any other
3664    /// signal bits on either end of the eventpair or its peer.
3665    ///
3666    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
3667    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
3668    /// transfer without causing CodecFactory channel failure).
3669    AttachLifetimeTracking {
3670        server_end: fidl::EventPair,
3671        buffers_remaining: u32,
3672        control_handle: BufferCollectionControlHandle,
3673    },
3674}
3675
3676impl BufferCollectionRequest {
3677    #[allow(irrefutable_let_patterns)]
3678    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3679        if let BufferCollectionRequest::Sync { responder } = self {
3680            Some((responder))
3681        } else {
3682            None
3683        }
3684    }
3685
3686    #[allow(irrefutable_let_patterns)]
3687    pub fn into_close(self) -> Option<(BufferCollectionControlHandle)> {
3688        if let BufferCollectionRequest::Close { control_handle } = self {
3689            Some((control_handle))
3690        } else {
3691            None
3692        }
3693    }
3694
3695    #[allow(irrefutable_let_patterns)]
3696    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionControlHandle)> {
3697        if let BufferCollectionRequest::SetName { priority, name, control_handle } = self {
3698            Some((priority, name, control_handle))
3699        } else {
3700            None
3701        }
3702    }
3703
3704    #[allow(irrefutable_let_patterns)]
3705    pub fn into_set_debug_client_info(
3706        self,
3707    ) -> Option<(String, u64, BufferCollectionControlHandle)> {
3708        if let BufferCollectionRequest::SetDebugClientInfo { name, id, control_handle } = self {
3709            Some((name, id, control_handle))
3710        } else {
3711            None
3712        }
3713    }
3714
3715    #[allow(irrefutable_let_patterns)]
3716    pub fn into_set_debug_timeout_log_deadline(
3717        self,
3718    ) -> Option<(i64, BufferCollectionControlHandle)> {
3719        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } =
3720            self
3721        {
3722            Some((deadline, control_handle))
3723        } else {
3724            None
3725        }
3726    }
3727
3728    #[allow(irrefutable_let_patterns)]
3729    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3730        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3731            Some((control_handle))
3732        } else {
3733            None
3734        }
3735    }
3736
3737    #[allow(irrefutable_let_patterns)]
3738    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3739        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3740            Some((responder))
3741        } else {
3742            None
3743        }
3744    }
3745
3746    #[allow(irrefutable_let_patterns)]
3747    pub fn into_is_alternate_for(
3748        self,
3749    ) -> Option<(fidl::Event, BufferCollectionIsAlternateForResponder)> {
3750        if let BufferCollectionRequest::IsAlternateFor { node_ref, responder } = self {
3751            Some((node_ref, responder))
3752        } else {
3753            None
3754        }
3755    }
3756
3757    #[allow(irrefutable_let_patterns)]
3758    pub fn into_set_constraints(
3759        self,
3760    ) -> Option<(bool, BufferCollectionConstraints, BufferCollectionControlHandle)> {
3761        if let BufferCollectionRequest::SetConstraints {
3762            has_constraints,
3763            constraints,
3764            control_handle,
3765        } = self
3766        {
3767            Some((has_constraints, constraints, control_handle))
3768        } else {
3769            None
3770        }
3771    }
3772
3773    #[allow(irrefutable_let_patterns)]
3774    pub fn into_wait_for_buffers_allocated(
3775        self,
3776    ) -> Option<(BufferCollectionWaitForBuffersAllocatedResponder)> {
3777        if let BufferCollectionRequest::WaitForBuffersAllocated { responder } = self {
3778            Some((responder))
3779        } else {
3780            None
3781        }
3782    }
3783
3784    #[allow(irrefutable_let_patterns)]
3785    pub fn into_check_buffers_allocated(
3786        self,
3787    ) -> Option<(BufferCollectionCheckBuffersAllocatedResponder)> {
3788        if let BufferCollectionRequest::CheckBuffersAllocated { responder } = self {
3789            Some((responder))
3790        } else {
3791            None
3792        }
3793    }
3794
3795    #[allow(irrefutable_let_patterns)]
3796    pub fn into_set_constraints_aux_buffers(
3797        self,
3798    ) -> Option<(BufferCollectionConstraintsAuxBuffers, BufferCollectionControlHandle)> {
3799        if let BufferCollectionRequest::SetConstraintsAuxBuffers { constraints, control_handle } =
3800            self
3801        {
3802            Some((constraints, control_handle))
3803        } else {
3804            None
3805        }
3806    }
3807
3808    #[allow(irrefutable_let_patterns)]
3809    pub fn into_get_aux_buffers(self) -> Option<(BufferCollectionGetAuxBuffersResponder)> {
3810        if let BufferCollectionRequest::GetAuxBuffers { responder } = self {
3811            Some((responder))
3812        } else {
3813            None
3814        }
3815    }
3816
3817    #[allow(irrefutable_let_patterns)]
3818    pub fn into_attach_token(
3819        self,
3820    ) -> Option<(
3821        u32,
3822        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3823        BufferCollectionControlHandle,
3824    )> {
3825        if let BufferCollectionRequest::AttachToken {
3826            rights_attenuation_mask,
3827            token_request,
3828            control_handle,
3829        } = self
3830        {
3831            Some((rights_attenuation_mask, token_request, control_handle))
3832        } else {
3833            None
3834        }
3835    }
3836
3837    #[allow(irrefutable_let_patterns)]
3838    pub fn into_attach_lifetime_tracking(
3839        self,
3840    ) -> Option<(fidl::EventPair, u32, BufferCollectionControlHandle)> {
3841        if let BufferCollectionRequest::AttachLifetimeTracking {
3842            server_end,
3843            buffers_remaining,
3844            control_handle,
3845        } = self
3846        {
3847            Some((server_end, buffers_remaining, control_handle))
3848        } else {
3849            None
3850        }
3851    }
3852
3853    /// Name of the method defined in FIDL
3854    pub fn method_name(&self) -> &'static str {
3855        match *self {
3856            BufferCollectionRequest::Sync { .. } => "sync",
3857            BufferCollectionRequest::Close { .. } => "close",
3858            BufferCollectionRequest::SetName { .. } => "set_name",
3859            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
3860            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
3861                "set_debug_timeout_log_deadline"
3862            }
3863            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
3864            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
3865            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
3866            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
3867            BufferCollectionRequest::WaitForBuffersAllocated { .. } => "wait_for_buffers_allocated",
3868            BufferCollectionRequest::CheckBuffersAllocated { .. } => "check_buffers_allocated",
3869            BufferCollectionRequest::SetConstraintsAuxBuffers { .. } => {
3870                "set_constraints_aux_buffers"
3871            }
3872            BufferCollectionRequest::GetAuxBuffers { .. } => "get_aux_buffers",
3873            BufferCollectionRequest::AttachToken { .. } => "attach_token",
3874            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
3875        }
3876    }
3877}
3878
3879#[derive(Debug, Clone)]
3880pub struct BufferCollectionControlHandle {
3881    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3882}
3883
3884impl fidl::endpoints::ControlHandle for BufferCollectionControlHandle {
3885    fn shutdown(&self) {
3886        self.inner.shutdown()
3887    }
3888    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3889        self.inner.shutdown_with_epitaph(status)
3890    }
3891
3892    fn is_closed(&self) -> bool {
3893        self.inner.channel().is_closed()
3894    }
3895    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3896        self.inner.channel().on_closed()
3897    }
3898
3899    #[cfg(target_os = "fuchsia")]
3900    fn signal_peer(
3901        &self,
3902        clear_mask: zx::Signals,
3903        set_mask: zx::Signals,
3904    ) -> Result<(), zx_status::Status> {
3905        use fidl::Peered;
3906        self.inner.channel().signal_peer(clear_mask, set_mask)
3907    }
3908}
3909
3910impl BufferCollectionControlHandle {}
3911
3912#[must_use = "FIDL methods require a response to be sent"]
3913#[derive(Debug)]
3914pub struct BufferCollectionSyncResponder {
3915    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3916    tx_id: u32,
3917}
3918
3919/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3920/// if the responder is dropped without sending a response, so that the client
3921/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3922impl std::ops::Drop for BufferCollectionSyncResponder {
3923    fn drop(&mut self) {
3924        self.control_handle.shutdown();
3925        // Safety: drops once, never accessed again
3926        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3927    }
3928}
3929
3930impl fidl::endpoints::Responder for BufferCollectionSyncResponder {
3931    type ControlHandle = BufferCollectionControlHandle;
3932
3933    fn control_handle(&self) -> &BufferCollectionControlHandle {
3934        &self.control_handle
3935    }
3936
3937    fn drop_without_shutdown(mut self) {
3938        // Safety: drops once, never accessed again due to mem::forget
3939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3940        // Prevent Drop from running (which would shut down the channel)
3941        std::mem::forget(self);
3942    }
3943}
3944
3945impl BufferCollectionSyncResponder {
3946    /// Sends a response to the FIDL transaction.
3947    ///
3948    /// Sets the channel to shutdown if an error occurs.
3949    pub fn send(self) -> Result<(), fidl::Error> {
3950        let _result = self.send_raw();
3951        if _result.is_err() {
3952            self.control_handle.shutdown();
3953        }
3954        self.drop_without_shutdown();
3955        _result
3956    }
3957
3958    /// Similar to "send" but does not shutdown the channel if an error occurs.
3959    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3960        let _result = self.send_raw();
3961        self.drop_without_shutdown();
3962        _result
3963    }
3964
3965    fn send_raw(&self) -> Result<(), fidl::Error> {
3966        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3967            (),
3968            self.tx_id,
3969            0x4577e238ae26291,
3970            fidl::encoding::DynamicFlags::empty(),
3971        )
3972    }
3973}
3974
3975#[must_use = "FIDL methods require a response to be sent"]
3976#[derive(Debug)]
3977pub struct BufferCollectionGetNodeRefResponder {
3978    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3979    tx_id: u32,
3980}
3981
3982/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3983/// if the responder is dropped without sending a response, so that the client
3984/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3985impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
3986    fn drop(&mut self) {
3987        self.control_handle.shutdown();
3988        // Safety: drops once, never accessed again
3989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3990    }
3991}
3992
3993impl fidl::endpoints::Responder for BufferCollectionGetNodeRefResponder {
3994    type ControlHandle = BufferCollectionControlHandle;
3995
3996    fn control_handle(&self) -> &BufferCollectionControlHandle {
3997        &self.control_handle
3998    }
3999
4000    fn drop_without_shutdown(mut self) {
4001        // Safety: drops once, never accessed again due to mem::forget
4002        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4003        // Prevent Drop from running (which would shut down the channel)
4004        std::mem::forget(self);
4005    }
4006}
4007
4008impl BufferCollectionGetNodeRefResponder {
4009    /// Sends a response to the FIDL transaction.
4010    ///
4011    /// Sets the channel to shutdown if an error occurs.
4012    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
4013        let _result = self.send_raw(node_ref);
4014        if _result.is_err() {
4015            self.control_handle.shutdown();
4016        }
4017        self.drop_without_shutdown();
4018        _result
4019    }
4020
4021    /// Similar to "send" but does not shutdown the channel if an error occurs.
4022    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
4023        let _result = self.send_raw(node_ref);
4024        self.drop_without_shutdown();
4025        _result
4026    }
4027
4028    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
4029        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
4030            (node_ref,),
4031            self.tx_id,
4032            0x467b7c75c35c3b84,
4033            fidl::encoding::DynamicFlags::empty(),
4034        )
4035    }
4036}
4037
4038#[must_use = "FIDL methods require a response to be sent"]
4039#[derive(Debug)]
4040pub struct BufferCollectionIsAlternateForResponder {
4041    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4042    tx_id: u32,
4043}
4044
4045/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4046/// if the responder is dropped without sending a response, so that the client
4047/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4048impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
4049    fn drop(&mut self) {
4050        self.control_handle.shutdown();
4051        // Safety: drops once, never accessed again
4052        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4053    }
4054}
4055
4056impl fidl::endpoints::Responder for BufferCollectionIsAlternateForResponder {
4057    type ControlHandle = BufferCollectionControlHandle;
4058
4059    fn control_handle(&self) -> &BufferCollectionControlHandle {
4060        &self.control_handle
4061    }
4062
4063    fn drop_without_shutdown(mut self) {
4064        // Safety: drops once, never accessed again due to mem::forget
4065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4066        // Prevent Drop from running (which would shut down the channel)
4067        std::mem::forget(self);
4068    }
4069}
4070
4071impl BufferCollectionIsAlternateForResponder {
4072    /// Sends a response to the FIDL transaction.
4073    ///
4074    /// Sets the channel to shutdown if an error occurs.
4075    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4076        let _result = self.send_raw(result);
4077        if _result.is_err() {
4078            self.control_handle.shutdown();
4079        }
4080        self.drop_without_shutdown();
4081        _result
4082    }
4083
4084    /// Similar to "send" but does not shutdown the channel if an error occurs.
4085    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4086        let _result = self.send_raw(result);
4087        self.drop_without_shutdown();
4088        _result
4089    }
4090
4091    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4092        self.control_handle
4093            .inner
4094            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
4095                result.map(|is_alternate| (is_alternate,)),
4096                self.tx_id,
4097                0x33a2a7aff2776c07,
4098                fidl::encoding::DynamicFlags::empty(),
4099            )
4100    }
4101}
4102
4103#[must_use = "FIDL methods require a response to be sent"]
4104#[derive(Debug)]
4105pub struct BufferCollectionWaitForBuffersAllocatedResponder {
4106    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4107    tx_id: u32,
4108}
4109
4110/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4111/// if the responder is dropped without sending a response, so that the client
4112/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4113impl std::ops::Drop for BufferCollectionWaitForBuffersAllocatedResponder {
4114    fn drop(&mut self) {
4115        self.control_handle.shutdown();
4116        // Safety: drops once, never accessed again
4117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4118    }
4119}
4120
4121impl fidl::endpoints::Responder for BufferCollectionWaitForBuffersAllocatedResponder {
4122    type ControlHandle = BufferCollectionControlHandle;
4123
4124    fn control_handle(&self) -> &BufferCollectionControlHandle {
4125        &self.control_handle
4126    }
4127
4128    fn drop_without_shutdown(mut self) {
4129        // Safety: drops once, never accessed again due to mem::forget
4130        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4131        // Prevent Drop from running (which would shut down the channel)
4132        std::mem::forget(self);
4133    }
4134}
4135
4136impl BufferCollectionWaitForBuffersAllocatedResponder {
4137    /// Sends a response to the FIDL transaction.
4138    ///
4139    /// Sets the channel to shutdown if an error occurs.
4140    pub fn send(
4141        self,
4142        mut status: i32,
4143        mut buffer_collection_info: BufferCollectionInfo2,
4144    ) -> Result<(), fidl::Error> {
4145        let _result = self.send_raw(status, buffer_collection_info);
4146        if _result.is_err() {
4147            self.control_handle.shutdown();
4148        }
4149        self.drop_without_shutdown();
4150        _result
4151    }
4152
4153    /// Similar to "send" but does not shutdown the channel if an error occurs.
4154    pub fn send_no_shutdown_on_err(
4155        self,
4156        mut status: i32,
4157        mut buffer_collection_info: BufferCollectionInfo2,
4158    ) -> Result<(), fidl::Error> {
4159        let _result = self.send_raw(status, buffer_collection_info);
4160        self.drop_without_shutdown();
4161        _result
4162    }
4163
4164    fn send_raw(
4165        &self,
4166        mut status: i32,
4167        mut buffer_collection_info: BufferCollectionInfo2,
4168    ) -> Result<(), fidl::Error> {
4169        self.control_handle.inner.send::<BufferCollectionWaitForBuffersAllocatedResponse>(
4170            (status, &mut buffer_collection_info),
4171            self.tx_id,
4172            0x714667ea2a29a3a2,
4173            fidl::encoding::DynamicFlags::empty(),
4174        )
4175    }
4176}
4177
4178#[must_use = "FIDL methods require a response to be sent"]
4179#[derive(Debug)]
4180pub struct BufferCollectionCheckBuffersAllocatedResponder {
4181    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4182    tx_id: u32,
4183}
4184
4185/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4186/// if the responder is dropped without sending a response, so that the client
4187/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4188impl std::ops::Drop for BufferCollectionCheckBuffersAllocatedResponder {
4189    fn drop(&mut self) {
4190        self.control_handle.shutdown();
4191        // Safety: drops once, never accessed again
4192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4193    }
4194}
4195
4196impl fidl::endpoints::Responder for BufferCollectionCheckBuffersAllocatedResponder {
4197    type ControlHandle = BufferCollectionControlHandle;
4198
4199    fn control_handle(&self) -> &BufferCollectionControlHandle {
4200        &self.control_handle
4201    }
4202
4203    fn drop_without_shutdown(mut self) {
4204        // Safety: drops once, never accessed again due to mem::forget
4205        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4206        // Prevent Drop from running (which would shut down the channel)
4207        std::mem::forget(self);
4208    }
4209}
4210
4211impl BufferCollectionCheckBuffersAllocatedResponder {
4212    /// Sends a response to the FIDL transaction.
4213    ///
4214    /// Sets the channel to shutdown if an error occurs.
4215    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4216        let _result = self.send_raw(status);
4217        if _result.is_err() {
4218            self.control_handle.shutdown();
4219        }
4220        self.drop_without_shutdown();
4221        _result
4222    }
4223
4224    /// Similar to "send" but does not shutdown the channel if an error occurs.
4225    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4226        let _result = self.send_raw(status);
4227        self.drop_without_shutdown();
4228        _result
4229    }
4230
4231    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4232        self.control_handle.inner.send::<BufferCollectionCheckBuffersAllocatedResponse>(
4233            (status,),
4234            self.tx_id,
4235            0x245bb81f79189e9,
4236            fidl::encoding::DynamicFlags::empty(),
4237        )
4238    }
4239}
4240
4241#[must_use = "FIDL methods require a response to be sent"]
4242#[derive(Debug)]
4243pub struct BufferCollectionGetAuxBuffersResponder {
4244    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4245    tx_id: u32,
4246}
4247
4248/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4249/// if the responder is dropped without sending a response, so that the client
4250/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4251impl std::ops::Drop for BufferCollectionGetAuxBuffersResponder {
4252    fn drop(&mut self) {
4253        self.control_handle.shutdown();
4254        // Safety: drops once, never accessed again
4255        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4256    }
4257}
4258
4259impl fidl::endpoints::Responder for BufferCollectionGetAuxBuffersResponder {
4260    type ControlHandle = BufferCollectionControlHandle;
4261
4262    fn control_handle(&self) -> &BufferCollectionControlHandle {
4263        &self.control_handle
4264    }
4265
4266    fn drop_without_shutdown(mut self) {
4267        // Safety: drops once, never accessed again due to mem::forget
4268        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4269        // Prevent Drop from running (which would shut down the channel)
4270        std::mem::forget(self);
4271    }
4272}
4273
4274impl BufferCollectionGetAuxBuffersResponder {
4275    /// Sends a response to the FIDL transaction.
4276    ///
4277    /// Sets the channel to shutdown if an error occurs.
4278    pub fn send(
4279        self,
4280        mut status: i32,
4281        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4282    ) -> Result<(), fidl::Error> {
4283        let _result = self.send_raw(status, buffer_collection_info_aux_buffers);
4284        if _result.is_err() {
4285            self.control_handle.shutdown();
4286        }
4287        self.drop_without_shutdown();
4288        _result
4289    }
4290
4291    /// Similar to "send" but does not shutdown the channel if an error occurs.
4292    pub fn send_no_shutdown_on_err(
4293        self,
4294        mut status: i32,
4295        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4296    ) -> Result<(), fidl::Error> {
4297        let _result = self.send_raw(status, buffer_collection_info_aux_buffers);
4298        self.drop_without_shutdown();
4299        _result
4300    }
4301
4302    fn send_raw(
4303        &self,
4304        mut status: i32,
4305        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4306    ) -> Result<(), fidl::Error> {
4307        self.control_handle.inner.send::<BufferCollectionGetAuxBuffersResponse>(
4308            (status, &mut buffer_collection_info_aux_buffers),
4309            self.tx_id,
4310            0x6c6cac6000a29a55,
4311            fidl::encoding::DynamicFlags::empty(),
4312        )
4313    }
4314}
4315
4316#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4317pub struct BufferCollectionTokenMarker;
4318
4319impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenMarker {
4320    type Proxy = BufferCollectionTokenProxy;
4321    type RequestStream = BufferCollectionTokenRequestStream;
4322    #[cfg(target_os = "fuchsia")]
4323    type SynchronousProxy = BufferCollectionTokenSynchronousProxy;
4324
4325    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4326}
4327
4328pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4329    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4330    fn r#sync(&self) -> Self::SyncResponseFut;
4331    fn r#close(&self) -> Result<(), fidl::Error>;
4332    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
4333    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
4334    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
4335    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4336    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
4337        + Send;
4338    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4339    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4340        + Send;
4341    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
4342    type DuplicateSyncResponseFut: std::future::Future<
4343            Output = Result<
4344                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
4345                fidl::Error,
4346            >,
4347        > + Send;
4348    fn r#duplicate_sync(
4349        &self,
4350        rights_attenuation_masks: &[fidl::Rights],
4351    ) -> Self::DuplicateSyncResponseFut;
4352    fn r#duplicate(
4353        &self,
4354        rights_attenuation_mask: u32,
4355        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4356    ) -> Result<(), fidl::Error>;
4357    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4358    fn r#create_buffer_collection_token_group(
4359        &self,
4360        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4361    ) -> Result<(), fidl::Error>;
4362}
4363#[derive(Debug)]
4364#[cfg(target_os = "fuchsia")]
4365pub struct BufferCollectionTokenSynchronousProxy {
4366    client: fidl::client::sync::Client,
4367}
4368
4369#[cfg(target_os = "fuchsia")]
4370impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenSynchronousProxy {
4371    type Proxy = BufferCollectionTokenProxy;
4372    type Protocol = BufferCollectionTokenMarker;
4373
4374    fn from_channel(inner: fidl::Channel) -> Self {
4375        Self::new(inner)
4376    }
4377
4378    fn into_channel(self) -> fidl::Channel {
4379        self.client.into_channel()
4380    }
4381
4382    fn as_channel(&self) -> &fidl::Channel {
4383        self.client.as_channel()
4384    }
4385}
4386
4387#[cfg(target_os = "fuchsia")]
4388impl BufferCollectionTokenSynchronousProxy {
4389    pub fn new(channel: fidl::Channel) -> Self {
4390        let protocol_name =
4391            <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4392        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4393    }
4394
4395    pub fn into_channel(self) -> fidl::Channel {
4396        self.client.into_channel()
4397    }
4398
4399    /// Waits until an event arrives and returns it. It is safe for other
4400    /// threads to make concurrent requests while waiting for an event.
4401    pub fn wait_for_event(
4402        &self,
4403        deadline: zx::MonotonicInstant,
4404    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
4405        BufferCollectionTokenEvent::decode(self.client.wait_for_event(deadline)?)
4406    }
4407
4408    /// Ensure that previous messages, including Duplicate() messages on a
4409    /// token, collection, or group, have been received server side.
4410    ///
4411    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4412    /// valid sysmem token risks the Sync() hanging forever.  See
4413    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4414    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4415    /// Another way is to pass the token to BindSharedCollection(), which also
4416    /// validates the token as part of exchanging it for a BufferCollection
4417    /// channel, and BufferCollection Sync() can then be used.
4418    ///
4419    /// After a Sync(), it's then safe to send the client end of token_request
4420    /// to another participant knowing the server will recognize the token when
4421    /// it's sent into BindSharedCollection() by the other participant.
4422    ///
4423    /// Other options include waiting for each token.Duplicate() to complete
4424    /// individually (using separate call to token.Sync() after each), or
4425    /// calling Sync() on BufferCollection after the token has been turned in
4426    /// via BindSharedCollection().
4427    ///
4428    /// Another way to mitigate is to avoid calling Sync() on the token, and
4429    /// instead later deal with potential failure of BufferCollection.Sync() if
4430    /// the original token was invalid.  This option can be preferable from a
4431    /// performance point of view, but requires client code to delay sending
4432    /// tokens duplicated from this token until after client code has converted
4433    /// the duplicating token to a BufferCollection and received successful
4434    /// response from BufferCollection.Sync().
4435    ///
4436    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4437    /// When BufferCollection.Sync() isn't feasible, the caller must already
4438    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4439    /// hang forever.  See ValidateBufferCollectionToken() to check token
4440    /// validity first if the token isn't already known to be (is/was) valid.
4441    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4442        let _response =
4443            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
4444                (),
4445                0x4577e238ae26291,
4446                fidl::encoding::DynamicFlags::empty(),
4447                ___deadline,
4448            )?;
4449        Ok(_response)
4450    }
4451
4452    /// On a BufferCollectionToken channel:
4453    ///
4454    /// Normally a participant will convert a BufferCollectionToken into a
4455    /// BufferCollection view, but a participant is also free to Close() the
4456    /// token (and then close the channel immediately or shortly later in
4457    /// response to server closing its end), which avoids causing logical buffer
4458    /// collection failure.  Normally an unexpected token channel close will
4459    /// cause logical buffer collection failure (the only exceptions being
4460    /// certain cases involving AttachToken() or SetDispensable()).
4461    ///
4462    /// On a BufferCollection channel:
4463    ///
4464    /// By default the server handles unexpected failure of a BufferCollection
4465    /// by failing the whole logical buffer collection.  Partly this is to
4466    /// expedite closing VMO handles to reclaim memory when any participant
4467    /// fails.  If a participant would like to cleanly close a BufferCollection
4468    /// view without causing logical buffer collection failure, the participant
4469    /// can send Close() before closing the client end of the BufferCollection
4470    /// channel.  If this is the last BufferCollection view, the logical buffer
4471    /// collection will still go away.  The Close() can occur before or after
4472    /// SetConstraints().  If before SetConstraints(), the buffer collection
4473    /// won't require constraints from this node in order to allocate.  If
4474    /// after SetConstraints(), the constraints are retained and aggregated
4475    /// along with any subsequent logical allocation(s), despite the lack of
4476    /// channel connection.
4477    ///
4478    /// On a BufferCollectionTokenGroup channel:
4479    ///
4480    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4481    /// trigger failure of the logical BufferCollectionTokenGroup and will
4482    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4483    /// channel without failing the logical group or propagating failure, send
4484    /// Close() before closing the channel client endpoint.
4485    ///
4486    /// If Close() occurs before AllChildrenPresent(), the logical buffer
4487    /// collection will still fail despite the Close() (because sysmem can't be
4488    /// sure whether all relevant children were created, so it's ambiguous
4489    /// whether all relevant constraints will be provided to sysmem).  If
4490    /// Close() occurs after AllChildrenPresent(), the children and all their
4491    /// constraints remain intact (just as they would if the
4492    /// BufferCollectionTokenGroup channel had remained open), and the close
4493    /// doesn't trigger or propagate failure.
4494    pub fn r#close(&self) -> Result<(), fidl::Error> {
4495        self.client.send::<fidl::encoding::EmptyPayload>(
4496            (),
4497            0x5b1d7a4f5681fca7,
4498            fidl::encoding::DynamicFlags::empty(),
4499        )
4500    }
4501
4502    /// Set a name for VMOs in this buffer collection. The name may be truncated
4503    /// shorter. The name only affects VMOs allocated after it's set - this call
4504    /// does not rename existing VMOs. If multiple clients set different names
4505    /// then the larger priority value will win.
4506    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
4507        self.client.send::<NodeSetNameRequest>(
4508            (priority, name),
4509            0x77a41bb6217e2443,
4510            fidl::encoding::DynamicFlags::empty(),
4511        )
4512    }
4513
4514    /// Set information about the current client that can be used by sysmem to
4515    /// help debug leaking memory and hangs waiting for constraints. |name| can
4516    /// be an arbitrary string, but the current process name (see
4517    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4518    /// arbitrary id, but the current process ID (see
4519    /// fsl::GetCurrentProcessKoid()) is a good default.
4520    ///
4521    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4522    /// indicate which client is closing their channel first, leading to
4523    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4524    /// over, but if happening earlier than expected, the
4525    /// client-channel-specific name can help diagnose where the failure is
4526    /// first coming from, from sysmem's point of view).
4527    ///
4528    /// By default (unless overriden by this message or using
4529    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4530    /// parent Node at the time the child Node is created.  While this can be
4531    /// better than nothing, it's often better for each participant to use
4532    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4533    /// info directly relevant to the current client.  Also, SetVerboseLogging()
4534    /// can be used to help disambiguate if a Node is suspected of having info
4535    /// that was copied from its parent.
4536    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
4537        self.client.send::<NodeSetDebugClientInfoRequest>(
4538            (name, id),
4539            0x7275759070eb5ee2,
4540            fidl::encoding::DynamicFlags::empty(),
4541        )
4542    }
4543
4544    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4545    /// after creating a collection. Clients can call this method to change
4546    /// when the log is printed. If multiple client set the deadline, it's
4547    /// unspecified which deadline will take effect.
4548    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
4549        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
4550            (deadline,),
4551            0x46d38f4772638867,
4552            fidl::encoding::DynamicFlags::empty(),
4553        )
4554    }
4555
4556    /// Verbose logging includes constraints set via SetConstraints() from each
4557    /// client along with info set via SetDebugClientInfo() and the structure of
4558    /// the tree of Node(s).
4559    ///
4560    /// Normally sysmem prints only a single line complaint when aggregation
4561    /// fails, with just the specific detailed reason that aggregation failed,
4562    /// with minimal context.  While this is often enough to diagnose a problem
4563    /// if only a small change was made and the system had been working before
4564    /// the small change, it's often not particularly helpful for getting a new
4565    /// buffer collection to work for the first time.  Especially with more
4566    /// complex trees of nodes, involving things like AttachToken(),
4567    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4568    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4569    /// looks like and why it's failing a logical allocation, or why a tree or
4570    /// sub-tree is failing sooner than expected.
4571    ///
4572    /// The intent of the extra logging is to be acceptable from a performance
4573    /// point of view, if only enabled on a low number of buffer collections.
4574    /// If we're not tracking down a bug, we shouldn't send this message.
4575    ///
4576    /// If too many participants leave verbose logging enabled, we may end up
4577    /// needing to require that system-wide sysmem verbose logging be permitted
4578    /// via some other setting, to avoid sysmem spamming the log too much due to
4579    /// this message.
4580    ///
4581    /// This may be a NOP for some nodes due to intentional policy associated
4582    /// with the node, if we don't trust a node enough to let it turn on verbose
4583    /// logging.
4584    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4585        self.client.send::<fidl::encoding::EmptyPayload>(
4586            (),
4587            0x6bfbe2cf1701d288,
4588            fidl::encoding::DynamicFlags::empty(),
4589        )
4590    }
4591
4592    /// This gets an event handle that can be used as a parameter to
4593    /// IsAlternateFor() called on any Node.  The client will not be granted the
4594    /// right to signal this event, as this handle should only be used as proof
4595    /// that the client obtained this handle from this Node.
4596    ///
4597    /// Because this is a get not a set, no Sync() is needed between the
4598    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4599    /// potentially being on different channels.
4600    ///
4601    /// See also IsAlternateFor().
4602    pub fn r#get_node_ref(
4603        &self,
4604        ___deadline: zx::MonotonicInstant,
4605    ) -> Result<fidl::Event, fidl::Error> {
4606        let _response =
4607            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
4608                (),
4609                0x467b7c75c35c3b84,
4610                fidl::encoding::DynamicFlags::empty(),
4611                ___deadline,
4612            )?;
4613        Ok(_response.node_ref)
4614    }
4615
4616    /// This checks whether the calling node is in a subtree rooted at a
4617    /// different child token of a common parent BufferCollectionTokenGroup, in
4618    /// relation to the passed-in node_ref.
4619    ///
4620    /// This call is for assisting with admission control de-duplication, and
4621    /// with debugging.
4622    ///
4623    /// The node_ref must be obtained using GetNodeRef() of a
4624    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4625    ///
4626    /// The node_ref can be a duplicated handle; it's not necessary to call
4627    /// GetNodeRef() for every call to IsAlternateFor().
4628    ///
4629    /// If a calling token may not actually be a valid token at all due to
4630    /// a potentially hostile/untrusted provider of the token, call
4631    /// ValidateBufferCollectionToken() first instead of potentially getting
4632    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4633    /// token not being a real token (not really talking to sysmem).  Another
4634    /// option is to call BindSharedCollection with this token first which also
4635    /// validates the token along with converting it to a BufferCollection, then
4636    /// call BufferCollection IsAlternateFor().
4637    ///
4638    /// error values:
4639    ///
4640    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4641    /// buffer collection as the calling Node.  Before logical allocation and
4642    /// within the same logical allocation sub-tree, this essentially means that
4643    /// the node_ref was never part of this logical buffer collection, since
4644    /// before logical allocation all node_refs that come into existence remain
4645    /// in existence at least until logical allocation (including Node(s) that
4646    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4647    /// to be returned, this Node's channel needs to still be connected server
4648    /// side, which won't be the case if the whole logical allocation has
4649    /// failed.  After logical allocation or in a different logical allocation
4650    /// sub-tree there are additional potential reasons for this error.  For
4651    /// example a different logical allocation (separated from this Node(s)
4652    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4653    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4654    /// exist and may select a different child sub-tree than the sub-tree the
4655    /// node_ref is in causing deletion of the node_ref Node.  The only time
4656    /// sysmem keeps a Node around after that Node has no corresponding channel
4657    /// is when Close() is used and the Node's sub-tree has not yet failed.
4658    /// Another reason for this error is if the node_ref is an eventpair handle
4659    /// with sufficient rights, but isn't actually a real node_ref obtained from
4660    /// GetNodeRef().
4661    ///
4662    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4663    /// eventpair handle, or doesn't have the needed rights expected on a real
4664    /// node_ref.
4665    ///
4666    /// No other failing status codes are returned by this call.  However,
4667    /// sysmem may add additional codes in future, so the client should have
4668    /// sensible default handling for any failing status code.
4669    ///
4670    /// On success, is_alternate has the following meaning:
4671    ///   * true - The first parent node in common between the calling node and
4672    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
4673    ///     the calling Node and the node_ref Node will _not_ have both their
4674    ///     constraints apply - rather sysmem will choose one or the other of
4675    ///     the constraints - never both.  This is because only one child of
4676    ///     a BufferCollectionTokenGroup is selected during logical allocation,
4677    ///     with only that one child's sub-tree contributing to constraints
4678    ///     aggregation.
4679    ///   * false - The first parent node in common between the calling Node and
4680    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
4681    ///     this means the first parent node in common is a
4682    ///     BufferCollectionToken or BufferCollection (regardless of not
4683    ///     Close()ed or Close()ed).  This means that the calling Node and the
4684    ///     node_ref Node _may_ have both their constraints apply during
4685    ///     constraints aggregation of the logical allocation, if both Node(s)
4686    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
4687    ///     In this case, there is no BufferCollectionTokenGroup that will
4688    ///     directly prevent the two Node(s) from both being selected and their
4689    ///     constraints both aggregated, but even when false, one or both
4690    ///     Node(s) may still be eliminated from consideration if one or both
4691    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4692    ///     which selects a child sub-tree other than the sub-tree containing
4693    ///     the calling Node or node_ref Node.
4694    pub fn r#is_alternate_for(
4695        &self,
4696        mut node_ref: fidl::Event,
4697        ___deadline: zx::MonotonicInstant,
4698    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
4699        let _response = self.client.send_query::<
4700            NodeIsAlternateForRequest,
4701            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
4702        >(
4703            (node_ref,),
4704            0x33a2a7aff2776c07,
4705            fidl::encoding::DynamicFlags::empty(),
4706            ___deadline,
4707        )?;
4708        Ok(_response.map(|x| x.is_alternate))
4709    }
4710
4711    /// This method can be used to add more participants prior to creating a
4712    /// shared BufferCollection. A new token will be returned for each entry in
4713    /// the `rights_attenuation_masks` array. The return value is the client
4714    /// ends of each new participant token.
4715    ///
4716    /// If the calling token may not actually be a valid token at all due to
4717    /// a potentially hostile/untrusted provider of the token, consider using
4718    /// ValidateBufferCollectionToken() first instead of potentially getting
4719    /// stuck indefinitely if DuplicateSync() never responds due to the calling
4720    /// token not being a real token.
4721    ///
4722    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4723    /// after calling this method.
4724    ///
4725    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4726    /// BufferCollection to be successfully created.
4727    ///
4728    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4729    /// will be absent in the buffer VMO rights obtainable via the corresponding
4730    /// returned token. This allows an initiator or intermediary participant to
4731    /// attenuate the rights available to a participant. This does not allow a
4732    /// participant to gain rights that the participant doesn't already have.
4733    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4734    /// attenuation should be applied.
4735    pub fn r#duplicate_sync(
4736        &self,
4737        mut rights_attenuation_masks: &[fidl::Rights],
4738        ___deadline: zx::MonotonicInstant,
4739    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
4740        let _response = self.client.send_query::<
4741            BufferCollectionTokenDuplicateSyncRequest,
4742            BufferCollectionTokenDuplicateSyncResponse,
4743        >(
4744            (rights_attenuation_masks,),
4745            0x49ed7ab7cc19f18,
4746            fidl::encoding::DynamicFlags::empty(),
4747            ___deadline,
4748        )?;
4749        Ok(_response.tokens)
4750    }
4751
4752    /// This method can be used to add a participant prior to creating a shared
4753    /// BufferCollection. It should only be used instead of DuplicateSync in
4754    /// performance sensitive cases where it would be undesireable to wait for
4755    /// sysmem to respond as part of each duplicate.
4756    ///
4757    /// After sending one or more Duplicate() messages, and before sending the
4758    /// created tokens to other participants (or to other Allocator channels),
4759    /// the client should send a Sync() and wait for its response.  The Sync()
4760    /// call can be made on the token, or on the BufferCollection obtained by
4761    /// passing this token to BindSharedCollection().  Either will ensure that
4762    /// the server knows about the tokens created via Duplicate() before the
4763    /// other participant sends the token to the server via separate Allocator
4764    /// channel.
4765    ///
4766    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4767    /// BufferCollection to be successfully created.
4768    ///
4769    /// When a client calls BindSharedCollection() to turn in a
4770    /// BufferCollectionToken, the server will process all Duplicate() messages
4771    /// before closing down the BufferCollectionToken.  This allows the client
4772    /// to Duplicate() and immediately turn in the BufferCollectionToken using
4773    /// BindSharedCollection, then later transfer the client end of token_request
4774    /// to another participant - the server will notice the existence of the
4775    /// token_request before considering this BufferCollectionToken fully closed.
4776    ///
4777    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
4778    /// absent in the buffer VMO rights obtainable via the client end of
4779    /// token_request. This allows an initiator or intermediary participant to
4780    /// attenuate the rights available to a participant. This does not allow a
4781    /// participant to gain rights that the participant doesn't already have.
4782    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4783    /// attenuation should be applied.
4784    ///
4785    /// These values for rights_attenuation_mask result in no attenuation:
4786    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
4787    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
4788    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
4789    ///
4790    /// `token_request` is the server end of a BufferCollectionToken channel.
4791    /// The client end of this channel acts as another participant in creating the
4792    /// shared BufferCollection.
4793    pub fn r#duplicate(
4794        &self,
4795        mut rights_attenuation_mask: u32,
4796        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4797    ) -> Result<(), fidl::Error> {
4798        self.client.send::<BufferCollectionTokenDuplicateRequest>(
4799            (rights_attenuation_mask, token_request),
4800            0x2f9f81bdde4b7292,
4801            fidl::encoding::DynamicFlags::empty(),
4802        )
4803    }
4804
4805    /// A dispensable token can fail after buffers are logically allocated
4806    /// without causing failure of its parent (if any).
4807    ///
4808    /// The dispensable token participates in constraints aggregation along with
4809    /// its parent before logical buffer allocation.  If the dispensable token
4810    /// fails before buffers are logically allocated, the failure propagates to
4811    /// the dispensable token's parent.
4812    ///
4813    /// After buffers are logically allocated, failure of the dispensable token
4814    /// (or any child of the dispensable token) does not propagate to the
4815    /// dispensable token's parent.  Failure does propagate from a normal
4816    /// child of a dispensable token to the dispensable token.  Failure
4817    /// of a child is blocked from reaching its parent if the child is attached,
4818    /// or if the child is dispensable and the failure occurred after logical
4819    /// allocation.
4820    ///
4821    /// A dispensable token can be used in cases where a participant needs to
4822    /// provide constraints, but after buffers are allocated, the participant
4823    /// can fail without causing buffer collection failure from the parent's
4824    /// point of view.
4825    ///
4826    /// In contrast, AttachToken() can be used to create a token which does not
4827    /// participate in constraints aggregation with its parent, and whose
4828    /// failure at any time does not propagate to its parent, and whose delay
4829    /// providing constraints does not prevent the parent from completing its
4830    /// buffer allocation.
4831    ///
4832    /// An initiator may in some scenarios choose to initially use a dispensable
4833    /// token for a given instance of a participant, and then later if the first
4834    /// instance of that participant fails, a new second instance of that
4835    /// participant my be given a token created with AttachToken().
4836    ///
4837    /// If a client uses this message, the client should not rely on the
4838    /// client's own BufferCollectionToken or BufferCollection channel to close
4839    /// from the server end due to abrupt failure of any BufferCollectionToken
4840    /// or BufferCollection that the client has SetDispensable() and given out
4841    /// to another process.  For this reason, the client should take extra care
4842    /// to notice failure of that other process via other means.
4843    ///
4844    /// While it is possible (and potentially useful) to SetDispensable() on a
4845    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
4846    /// replace a failed dispensable token that was a direct child of a group
4847    /// with a new token using AttachToken() (since there's no AttachToken() on
4848    /// a group).  Instead, to enable AttachToken() replacement in this case,
4849    /// create an additional non-dispensable token (node) that's a direct child
4850    /// of the group and make the existing dispensable token a child of the
4851    /// additional token (node).  This way, the additional token (node) that is
4852    /// a direct child of the group has BufferCollection.AttachToken() which can
4853    /// be used to replace the failed dispensable token.
4854    ///
4855    /// SetDispensable() on an already-dispensable token is idempotent.
4856    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
4857        self.client.send::<fidl::encoding::EmptyPayload>(
4858            (),
4859            0x76e4ec34fc2cf5b3,
4860            fidl::encoding::DynamicFlags::empty(),
4861        )
4862    }
4863
4864    /// Most sysmem clients and many participants don't need to care about this
4865    /// message or about BufferCollectionTokenGroup(s) in general.
4866    ///
4867    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
4868    /// tokens.  The child tokens which are not selected during aggregation will
4869    /// fail (close), which a potential participant should notice when their
4870    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
4871    /// participant to clean up the speculative usage that didn't end up
4872    /// happening (similarly to a normal BufferCollection server end closing
4873    /// on failure of a logical buffer collection).
4874    ///
4875    /// See comments on protocol BufferCollectionTokenGroup.
4876    ///
4877    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
4878    /// applied to the whole group can be achieved with a token for this purpose
4879    /// as a direct parent of the group.
4880    ///
4881    /// group_request - the server end of a BufferCollectionTokenGroup channel
4882    /// to be served by sysmem.
4883    pub fn r#create_buffer_collection_token_group(
4884        &self,
4885        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4886    ) -> Result<(), fidl::Error> {
4887        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
4888            (group_request,),
4889            0x2f6243e05f22b9a7,
4890            fidl::encoding::DynamicFlags::empty(),
4891        )
4892    }
4893}
4894
4895#[cfg(target_os = "fuchsia")]
4896impl From<BufferCollectionTokenSynchronousProxy> for zx::Handle {
4897    fn from(value: BufferCollectionTokenSynchronousProxy) -> Self {
4898        value.into_channel().into()
4899    }
4900}
4901
4902#[cfg(target_os = "fuchsia")]
4903impl From<fidl::Channel> for BufferCollectionTokenSynchronousProxy {
4904    fn from(value: fidl::Channel) -> Self {
4905        Self::new(value)
4906    }
4907}
4908
4909#[cfg(target_os = "fuchsia")]
4910impl fidl::endpoints::FromClient for BufferCollectionTokenSynchronousProxy {
4911    type Protocol = BufferCollectionTokenMarker;
4912
4913    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>) -> Self {
4914        Self::new(value.into_channel())
4915    }
4916}
4917
4918#[derive(Debug, Clone)]
4919pub struct BufferCollectionTokenProxy {
4920    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4921}
4922
4923impl fidl::endpoints::Proxy for BufferCollectionTokenProxy {
4924    type Protocol = BufferCollectionTokenMarker;
4925
4926    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4927        Self::new(inner)
4928    }
4929
4930    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4931        self.client.into_channel().map_err(|client| Self { client })
4932    }
4933
4934    fn as_channel(&self) -> &::fidl::AsyncChannel {
4935        self.client.as_channel()
4936    }
4937}
4938
4939impl BufferCollectionTokenProxy {
4940    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionToken.
4941    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4942        let protocol_name =
4943            <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4944        Self { client: fidl::client::Client::new(channel, protocol_name) }
4945    }
4946
4947    /// Get a Stream of events from the remote end of the protocol.
4948    ///
4949    /// # Panics
4950    ///
4951    /// Panics if the event stream was already taken.
4952    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4953        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4954    }
4955
4956    /// Ensure that previous messages, including Duplicate() messages on a
4957    /// token, collection, or group, have been received server side.
4958    ///
4959    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4960    /// valid sysmem token risks the Sync() hanging forever.  See
4961    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4962    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4963    /// Another way is to pass the token to BindSharedCollection(), which also
4964    /// validates the token as part of exchanging it for a BufferCollection
4965    /// channel, and BufferCollection Sync() can then be used.
4966    ///
4967    /// After a Sync(), it's then safe to send the client end of token_request
4968    /// to another participant knowing the server will recognize the token when
4969    /// it's sent into BindSharedCollection() by the other participant.
4970    ///
4971    /// Other options include waiting for each token.Duplicate() to complete
4972    /// individually (using separate call to token.Sync() after each), or
4973    /// calling Sync() on BufferCollection after the token has been turned in
4974    /// via BindSharedCollection().
4975    ///
4976    /// Another way to mitigate is to avoid calling Sync() on the token, and
4977    /// instead later deal with potential failure of BufferCollection.Sync() if
4978    /// the original token was invalid.  This option can be preferable from a
4979    /// performance point of view, but requires client code to delay sending
4980    /// tokens duplicated from this token until after client code has converted
4981    /// the duplicating token to a BufferCollection and received successful
4982    /// response from BufferCollection.Sync().
4983    ///
4984    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4985    /// When BufferCollection.Sync() isn't feasible, the caller must already
4986    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4987    /// hang forever.  See ValidateBufferCollectionToken() to check token
4988    /// validity first if the token isn't already known to be (is/was) valid.
4989    pub fn r#sync(
4990        &self,
4991    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4992        BufferCollectionTokenProxyInterface::r#sync(self)
4993    }
4994
4995    /// On a BufferCollectionToken channel:
4996    ///
4997    /// Normally a participant will convert a BufferCollectionToken into a
4998    /// BufferCollection view, but a participant is also free to Close() the
4999    /// token (and then close the channel immediately or shortly later in
5000    /// response to server closing its end), which avoids causing logical buffer
5001    /// collection failure.  Normally an unexpected token channel close will
5002    /// cause logical buffer collection failure (the only exceptions being
5003    /// certain cases involving AttachToken() or SetDispensable()).
5004    ///
5005    /// On a BufferCollection channel:
5006    ///
5007    /// By default the server handles unexpected failure of a BufferCollection
5008    /// by failing the whole logical buffer collection.  Partly this is to
5009    /// expedite closing VMO handles to reclaim memory when any participant
5010    /// fails.  If a participant would like to cleanly close a BufferCollection
5011    /// view without causing logical buffer collection failure, the participant
5012    /// can send Close() before closing the client end of the BufferCollection
5013    /// channel.  If this is the last BufferCollection view, the logical buffer
5014    /// collection will still go away.  The Close() can occur before or after
5015    /// SetConstraints().  If before SetConstraints(), the buffer collection
5016    /// won't require constraints from this node in order to allocate.  If
5017    /// after SetConstraints(), the constraints are retained and aggregated
5018    /// along with any subsequent logical allocation(s), despite the lack of
5019    /// channel connection.
5020    ///
5021    /// On a BufferCollectionTokenGroup channel:
5022    ///
5023    /// By default, unexpected failure of a BufferCollectionTokenGroup will
5024    /// trigger failure of the logical BufferCollectionTokenGroup and will
5025    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
5026    /// channel without failing the logical group or propagating failure, send
5027    /// Close() before closing the channel client endpoint.
5028    ///
5029    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5030    /// collection will still fail despite the Close() (because sysmem can't be
5031    /// sure whether all relevant children were created, so it's ambiguous
5032    /// whether all relevant constraints will be provided to sysmem).  If
5033    /// Close() occurs after AllChildrenPresent(), the children and all their
5034    /// constraints remain intact (just as they would if the
5035    /// BufferCollectionTokenGroup channel had remained open), and the close
5036    /// doesn't trigger or propagate failure.
5037    pub fn r#close(&self) -> Result<(), fidl::Error> {
5038        BufferCollectionTokenProxyInterface::r#close(self)
5039    }
5040
5041    /// Set a name for VMOs in this buffer collection. The name may be truncated
5042    /// shorter. The name only affects VMOs allocated after it's set - this call
5043    /// does not rename existing VMOs. If multiple clients set different names
5044    /// then the larger priority value will win.
5045    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5046        BufferCollectionTokenProxyInterface::r#set_name(self, priority, name)
5047    }
5048
5049    /// Set information about the current client that can be used by sysmem to
5050    /// help debug leaking memory and hangs waiting for constraints. |name| can
5051    /// be an arbitrary string, but the current process name (see
5052    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5053    /// arbitrary id, but the current process ID (see
5054    /// fsl::GetCurrentProcessKoid()) is a good default.
5055    ///
5056    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5057    /// indicate which client is closing their channel first, leading to
5058    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5059    /// over, but if happening earlier than expected, the
5060    /// client-channel-specific name can help diagnose where the failure is
5061    /// first coming from, from sysmem's point of view).
5062    ///
5063    /// By default (unless overriden by this message or using
5064    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5065    /// parent Node at the time the child Node is created.  While this can be
5066    /// better than nothing, it's often better for each participant to use
5067    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5068    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5069    /// can be used to help disambiguate if a Node is suspected of having info
5070    /// that was copied from its parent.
5071    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5072        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, name, id)
5073    }
5074
5075    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5076    /// after creating a collection. Clients can call this method to change
5077    /// when the log is printed. If multiple client set the deadline, it's
5078    /// unspecified which deadline will take effect.
5079    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5080        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
5081    }
5082
5083    /// Verbose logging includes constraints set via SetConstraints() from each
5084    /// client along with info set via SetDebugClientInfo() and the structure of
5085    /// the tree of Node(s).
5086    ///
5087    /// Normally sysmem prints only a single line complaint when aggregation
5088    /// fails, with just the specific detailed reason that aggregation failed,
5089    /// with minimal context.  While this is often enough to diagnose a problem
5090    /// if only a small change was made and the system had been working before
5091    /// the small change, it's often not particularly helpful for getting a new
5092    /// buffer collection to work for the first time.  Especially with more
5093    /// complex trees of nodes, involving things like AttachToken(),
5094    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5095    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5096    /// looks like and why it's failing a logical allocation, or why a tree or
5097    /// sub-tree is failing sooner than expected.
5098    ///
5099    /// The intent of the extra logging is to be acceptable from a performance
5100    /// point of view, if only enabled on a low number of buffer collections.
5101    /// If we're not tracking down a bug, we shouldn't send this message.
5102    ///
5103    /// If too many participants leave verbose logging enabled, we may end up
5104    /// needing to require that system-wide sysmem verbose logging be permitted
5105    /// via some other setting, to avoid sysmem spamming the log too much due to
5106    /// this message.
5107    ///
5108    /// This may be a NOP for some nodes due to intentional policy associated
5109    /// with the node, if we don't trust a node enough to let it turn on verbose
5110    /// logging.
5111    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5112        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
5113    }
5114
5115    /// This gets an event handle that can be used as a parameter to
5116    /// IsAlternateFor() called on any Node.  The client will not be granted the
5117    /// right to signal this event, as this handle should only be used as proof
5118    /// that the client obtained this handle from this Node.
5119    ///
5120    /// Because this is a get not a set, no Sync() is needed between the
5121    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5122    /// potentially being on different channels.
5123    ///
5124    /// See also IsAlternateFor().
5125    pub fn r#get_node_ref(
5126        &self,
5127    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
5128    {
5129        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
5130    }
5131
5132    /// This checks whether the calling node is in a subtree rooted at a
5133    /// different child token of a common parent BufferCollectionTokenGroup, in
5134    /// relation to the passed-in node_ref.
5135    ///
5136    /// This call is for assisting with admission control de-duplication, and
5137    /// with debugging.
5138    ///
5139    /// The node_ref must be obtained using GetNodeRef() of a
5140    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
5141    ///
5142    /// The node_ref can be a duplicated handle; it's not necessary to call
5143    /// GetNodeRef() for every call to IsAlternateFor().
5144    ///
5145    /// If a calling token may not actually be a valid token at all due to
5146    /// a potentially hostile/untrusted provider of the token, call
5147    /// ValidateBufferCollectionToken() first instead of potentially getting
5148    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
5149    /// token not being a real token (not really talking to sysmem).  Another
5150    /// option is to call BindSharedCollection with this token first which also
5151    /// validates the token along with converting it to a BufferCollection, then
5152    /// call BufferCollection IsAlternateFor().
5153    ///
5154    /// error values:
5155    ///
5156    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
5157    /// buffer collection as the calling Node.  Before logical allocation and
5158    /// within the same logical allocation sub-tree, this essentially means that
5159    /// the node_ref was never part of this logical buffer collection, since
5160    /// before logical allocation all node_refs that come into existence remain
5161    /// in existence at least until logical allocation (including Node(s) that
5162    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
5163    /// to be returned, this Node's channel needs to still be connected server
5164    /// side, which won't be the case if the whole logical allocation has
5165    /// failed.  After logical allocation or in a different logical allocation
5166    /// sub-tree there are additional potential reasons for this error.  For
5167    /// example a different logical allocation (separated from this Node(s)
5168    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
5169    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
5170    /// exist and may select a different child sub-tree than the sub-tree the
5171    /// node_ref is in causing deletion of the node_ref Node.  The only time
5172    /// sysmem keeps a Node around after that Node has no corresponding channel
5173    /// is when Close() is used and the Node's sub-tree has not yet failed.
5174    /// Another reason for this error is if the node_ref is an eventpair handle
5175    /// with sufficient rights, but isn't actually a real node_ref obtained from
5176    /// GetNodeRef().
5177    ///
5178    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
5179    /// eventpair handle, or doesn't have the needed rights expected on a real
5180    /// node_ref.
5181    ///
5182    /// No other failing status codes are returned by this call.  However,
5183    /// sysmem may add additional codes in future, so the client should have
5184    /// sensible default handling for any failing status code.
5185    ///
5186    /// On success, is_alternate has the following meaning:
5187    ///   * true - The first parent node in common between the calling node and
5188    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
5189    ///     the calling Node and the node_ref Node will _not_ have both their
5190    ///     constraints apply - rather sysmem will choose one or the other of
5191    ///     the constraints - never both.  This is because only one child of
5192    ///     a BufferCollectionTokenGroup is selected during logical allocation,
5193    ///     with only that one child's sub-tree contributing to constraints
5194    ///     aggregation.
5195    ///   * false - The first parent node in common between the calling Node and
5196    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
5197    ///     this means the first parent node in common is a
5198    ///     BufferCollectionToken or BufferCollection (regardless of not
5199    ///     Close()ed or Close()ed).  This means that the calling Node and the
5200    ///     node_ref Node _may_ have both their constraints apply during
5201    ///     constraints aggregation of the logical allocation, if both Node(s)
5202    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
5203    ///     In this case, there is no BufferCollectionTokenGroup that will
5204    ///     directly prevent the two Node(s) from both being selected and their
5205    ///     constraints both aggregated, but even when false, one or both
5206    ///     Node(s) may still be eliminated from consideration if one or both
5207    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
5208    ///     which selects a child sub-tree other than the sub-tree containing
5209    ///     the calling Node or node_ref Node.
5210    pub fn r#is_alternate_for(
5211        &self,
5212        mut node_ref: fidl::Event,
5213    ) -> fidl::client::QueryResponseFut<
5214        NodeIsAlternateForResult,
5215        fidl::encoding::DefaultFuchsiaResourceDialect,
5216    > {
5217        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, node_ref)
5218    }
5219
5220    /// This method can be used to add more participants prior to creating a
5221    /// shared BufferCollection. A new token will be returned for each entry in
5222    /// the `rights_attenuation_masks` array. The return value is the client
5223    /// ends of each new participant token.
5224    ///
5225    /// If the calling token may not actually be a valid token at all due to
5226    /// a potentially hostile/untrusted provider of the token, consider using
5227    /// ValidateBufferCollectionToken() first instead of potentially getting
5228    /// stuck indefinitely if DuplicateSync() never responds due to the calling
5229    /// token not being a real token.
5230    ///
5231    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
5232    /// after calling this method.
5233    ///
5234    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5235    /// BufferCollection to be successfully created.
5236    ///
5237    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
5238    /// will be absent in the buffer VMO rights obtainable via the corresponding
5239    /// returned token. This allows an initiator or intermediary participant to
5240    /// attenuate the rights available to a participant. This does not allow a
5241    /// participant to gain rights that the participant doesn't already have.
5242    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5243    /// attenuation should be applied.
5244    pub fn r#duplicate_sync(
5245        &self,
5246        mut rights_attenuation_masks: &[fidl::Rights],
5247    ) -> fidl::client::QueryResponseFut<
5248        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5249        fidl::encoding::DefaultFuchsiaResourceDialect,
5250    > {
5251        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, rights_attenuation_masks)
5252    }
5253
5254    /// This method can be used to add a participant prior to creating a shared
5255    /// BufferCollection. It should only be used instead of DuplicateSync in
5256    /// performance sensitive cases where it would be undesireable to wait for
5257    /// sysmem to respond as part of each duplicate.
5258    ///
5259    /// After sending one or more Duplicate() messages, and before sending the
5260    /// created tokens to other participants (or to other Allocator channels),
5261    /// the client should send a Sync() and wait for its response.  The Sync()
5262    /// call can be made on the token, or on the BufferCollection obtained by
5263    /// passing this token to BindSharedCollection().  Either will ensure that
5264    /// the server knows about the tokens created via Duplicate() before the
5265    /// other participant sends the token to the server via separate Allocator
5266    /// channel.
5267    ///
5268    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5269    /// BufferCollection to be successfully created.
5270    ///
5271    /// When a client calls BindSharedCollection() to turn in a
5272    /// BufferCollectionToken, the server will process all Duplicate() messages
5273    /// before closing down the BufferCollectionToken.  This allows the client
5274    /// to Duplicate() and immediately turn in the BufferCollectionToken using
5275    /// BindSharedCollection, then later transfer the client end of token_request
5276    /// to another participant - the server will notice the existence of the
5277    /// token_request before considering this BufferCollectionToken fully closed.
5278    ///
5279    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
5280    /// absent in the buffer VMO rights obtainable via the client end of
5281    /// token_request. This allows an initiator or intermediary participant to
5282    /// attenuate the rights available to a participant. This does not allow a
5283    /// participant to gain rights that the participant doesn't already have.
5284    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5285    /// attenuation should be applied.
5286    ///
5287    /// These values for rights_attenuation_mask result in no attenuation:
5288    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
5289    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
5290    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
5291    ///
5292    /// `token_request` is the server end of a BufferCollectionToken channel.
5293    /// The client end of this channel acts as another participant in creating the
5294    /// shared BufferCollection.
5295    pub fn r#duplicate(
5296        &self,
5297        mut rights_attenuation_mask: u32,
5298        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5299    ) -> Result<(), fidl::Error> {
5300        BufferCollectionTokenProxyInterface::r#duplicate(
5301            self,
5302            rights_attenuation_mask,
5303            token_request,
5304        )
5305    }
5306
5307    /// A dispensable token can fail after buffers are logically allocated
5308    /// without causing failure of its parent (if any).
5309    ///
5310    /// The dispensable token participates in constraints aggregation along with
5311    /// its parent before logical buffer allocation.  If the dispensable token
5312    /// fails before buffers are logically allocated, the failure propagates to
5313    /// the dispensable token's parent.
5314    ///
5315    /// After buffers are logically allocated, failure of the dispensable token
5316    /// (or any child of the dispensable token) does not propagate to the
5317    /// dispensable token's parent.  Failure does propagate from a normal
5318    /// child of a dispensable token to the dispensable token.  Failure
5319    /// of a child is blocked from reaching its parent if the child is attached,
5320    /// or if the child is dispensable and the failure occurred after logical
5321    /// allocation.
5322    ///
5323    /// A dispensable token can be used in cases where a participant needs to
5324    /// provide constraints, but after buffers are allocated, the participant
5325    /// can fail without causing buffer collection failure from the parent's
5326    /// point of view.
5327    ///
5328    /// In contrast, AttachToken() can be used to create a token which does not
5329    /// participate in constraints aggregation with its parent, and whose
5330    /// failure at any time does not propagate to its parent, and whose delay
5331    /// providing constraints does not prevent the parent from completing its
5332    /// buffer allocation.
5333    ///
5334    /// An initiator may in some scenarios choose to initially use a dispensable
5335    /// token for a given instance of a participant, and then later if the first
5336    /// instance of that participant fails, a new second instance of that
5337    /// participant my be given a token created with AttachToken().
5338    ///
5339    /// If a client uses this message, the client should not rely on the
5340    /// client's own BufferCollectionToken or BufferCollection channel to close
5341    /// from the server end due to abrupt failure of any BufferCollectionToken
5342    /// or BufferCollection that the client has SetDispensable() and given out
5343    /// to another process.  For this reason, the client should take extra care
5344    /// to notice failure of that other process via other means.
5345    ///
5346    /// While it is possible (and potentially useful) to SetDispensable() on a
5347    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
5348    /// replace a failed dispensable token that was a direct child of a group
5349    /// with a new token using AttachToken() (since there's no AttachToken() on
5350    /// a group).  Instead, to enable AttachToken() replacement in this case,
5351    /// create an additional non-dispensable token (node) that's a direct child
5352    /// of the group and make the existing dispensable token a child of the
5353    /// additional token (node).  This way, the additional token (node) that is
5354    /// a direct child of the group has BufferCollection.AttachToken() which can
5355    /// be used to replace the failed dispensable token.
5356    ///
5357    /// SetDispensable() on an already-dispensable token is idempotent.
5358    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5359        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5360    }
5361
5362    /// Most sysmem clients and many participants don't need to care about this
5363    /// message or about BufferCollectionTokenGroup(s) in general.
5364    ///
5365    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
5366    /// tokens.  The child tokens which are not selected during aggregation will
5367    /// fail (close), which a potential participant should notice when their
5368    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
5369    /// participant to clean up the speculative usage that didn't end up
5370    /// happening (similarly to a normal BufferCollection server end closing
5371    /// on failure of a logical buffer collection).
5372    ///
5373    /// See comments on protocol BufferCollectionTokenGroup.
5374    ///
5375    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
5376    /// applied to the whole group can be achieved with a token for this purpose
5377    /// as a direct parent of the group.
5378    ///
5379    /// group_request - the server end of a BufferCollectionTokenGroup channel
5380    /// to be served by sysmem.
5381    pub fn r#create_buffer_collection_token_group(
5382        &self,
5383        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5384    ) -> Result<(), fidl::Error> {
5385        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(
5386            self,
5387            group_request,
5388        )
5389    }
5390}
5391
5392impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5393    type SyncResponseFut =
5394        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5395    fn r#sync(&self) -> Self::SyncResponseFut {
5396        fn _decode(
5397            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5398        ) -> Result<(), fidl::Error> {
5399            let _response = fidl::client::decode_transaction_body::<
5400                fidl::encoding::EmptyPayload,
5401                fidl::encoding::DefaultFuchsiaResourceDialect,
5402                0x4577e238ae26291,
5403            >(_buf?)?;
5404            Ok(_response)
5405        }
5406        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5407            (),
5408            0x4577e238ae26291,
5409            fidl::encoding::DynamicFlags::empty(),
5410            _decode,
5411        )
5412    }
5413
5414    fn r#close(&self) -> Result<(), fidl::Error> {
5415        self.client.send::<fidl::encoding::EmptyPayload>(
5416            (),
5417            0x5b1d7a4f5681fca7,
5418            fidl::encoding::DynamicFlags::empty(),
5419        )
5420    }
5421
5422    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5423        self.client.send::<NodeSetNameRequest>(
5424            (priority, name),
5425            0x77a41bb6217e2443,
5426            fidl::encoding::DynamicFlags::empty(),
5427        )
5428    }
5429
5430    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5431        self.client.send::<NodeSetDebugClientInfoRequest>(
5432            (name, id),
5433            0x7275759070eb5ee2,
5434            fidl::encoding::DynamicFlags::empty(),
5435        )
5436    }
5437
5438    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5439        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5440            (deadline,),
5441            0x46d38f4772638867,
5442            fidl::encoding::DynamicFlags::empty(),
5443        )
5444    }
5445
5446    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5447        self.client.send::<fidl::encoding::EmptyPayload>(
5448            (),
5449            0x6bfbe2cf1701d288,
5450            fidl::encoding::DynamicFlags::empty(),
5451        )
5452    }
5453
5454    type GetNodeRefResponseFut =
5455        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
5456    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5457        fn _decode(
5458            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5459        ) -> Result<fidl::Event, fidl::Error> {
5460            let _response = fidl::client::decode_transaction_body::<
5461                NodeGetNodeRefResponse,
5462                fidl::encoding::DefaultFuchsiaResourceDialect,
5463                0x467b7c75c35c3b84,
5464            >(_buf?)?;
5465            Ok(_response.node_ref)
5466        }
5467        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
5468            (),
5469            0x467b7c75c35c3b84,
5470            fidl::encoding::DynamicFlags::empty(),
5471            _decode,
5472        )
5473    }
5474
5475    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5476        NodeIsAlternateForResult,
5477        fidl::encoding::DefaultFuchsiaResourceDialect,
5478    >;
5479    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
5480        fn _decode(
5481            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5482        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5483            let _response = fidl::client::decode_transaction_body::<
5484                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
5485                fidl::encoding::DefaultFuchsiaResourceDialect,
5486                0x33a2a7aff2776c07,
5487            >(_buf?)?;
5488            Ok(_response.map(|x| x.is_alternate))
5489        }
5490        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5491            (node_ref,),
5492            0x33a2a7aff2776c07,
5493            fidl::encoding::DynamicFlags::empty(),
5494            _decode,
5495        )
5496    }
5497
5498    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5499        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5500        fidl::encoding::DefaultFuchsiaResourceDialect,
5501    >;
5502    fn r#duplicate_sync(
5503        &self,
5504        mut rights_attenuation_masks: &[fidl::Rights],
5505    ) -> Self::DuplicateSyncResponseFut {
5506        fn _decode(
5507            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5508        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
5509        {
5510            let _response = fidl::client::decode_transaction_body::<
5511                BufferCollectionTokenDuplicateSyncResponse,
5512                fidl::encoding::DefaultFuchsiaResourceDialect,
5513                0x49ed7ab7cc19f18,
5514            >(_buf?)?;
5515            Ok(_response.tokens)
5516        }
5517        self.client.send_query_and_decode::<
5518            BufferCollectionTokenDuplicateSyncRequest,
5519            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5520        >(
5521            (rights_attenuation_masks,),
5522            0x49ed7ab7cc19f18,
5523            fidl::encoding::DynamicFlags::empty(),
5524            _decode,
5525        )
5526    }
5527
5528    fn r#duplicate(
5529        &self,
5530        mut rights_attenuation_mask: u32,
5531        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5532    ) -> Result<(), fidl::Error> {
5533        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5534            (rights_attenuation_mask, token_request),
5535            0x2f9f81bdde4b7292,
5536            fidl::encoding::DynamicFlags::empty(),
5537        )
5538    }
5539
5540    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5541        self.client.send::<fidl::encoding::EmptyPayload>(
5542            (),
5543            0x76e4ec34fc2cf5b3,
5544            fidl::encoding::DynamicFlags::empty(),
5545        )
5546    }
5547
5548    fn r#create_buffer_collection_token_group(
5549        &self,
5550        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5551    ) -> Result<(), fidl::Error> {
5552        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5553            (group_request,),
5554            0x2f6243e05f22b9a7,
5555            fidl::encoding::DynamicFlags::empty(),
5556        )
5557    }
5558}
5559
5560pub struct BufferCollectionTokenEventStream {
5561    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5562}
5563
5564impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5565
5566impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5567    fn is_terminated(&self) -> bool {
5568        self.event_receiver.is_terminated()
5569    }
5570}
5571
5572impl futures::Stream for BufferCollectionTokenEventStream {
5573    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5574
5575    fn poll_next(
5576        mut self: std::pin::Pin<&mut Self>,
5577        cx: &mut std::task::Context<'_>,
5578    ) -> std::task::Poll<Option<Self::Item>> {
5579        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5580            &mut self.event_receiver,
5581            cx
5582        )?) {
5583            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5584            None => std::task::Poll::Ready(None),
5585        }
5586    }
5587}
5588
5589#[derive(Debug)]
5590pub enum BufferCollectionTokenEvent {}
5591
5592impl BufferCollectionTokenEvent {
5593    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5594    fn decode(
5595        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5596    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5597        let (bytes, _handles) = buf.split_mut();
5598        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5599        debug_assert_eq!(tx_header.tx_id, 0);
5600        match tx_header.ordinal {
5601            _ => Err(fidl::Error::UnknownOrdinal {
5602                ordinal: tx_header.ordinal,
5603                protocol_name:
5604                    <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5605            }),
5606        }
5607    }
5608}
5609
5610/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionToken.
5611pub struct BufferCollectionTokenRequestStream {
5612    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5613    is_terminated: bool,
5614}
5615
5616impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5617
5618impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5619    fn is_terminated(&self) -> bool {
5620        self.is_terminated
5621    }
5622}
5623
5624impl fidl::endpoints::RequestStream for BufferCollectionTokenRequestStream {
5625    type Protocol = BufferCollectionTokenMarker;
5626    type ControlHandle = BufferCollectionTokenControlHandle;
5627
5628    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5629        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5630    }
5631
5632    fn control_handle(&self) -> Self::ControlHandle {
5633        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5634    }
5635
5636    fn into_inner(
5637        self,
5638    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5639    {
5640        (self.inner, self.is_terminated)
5641    }
5642
5643    fn from_inner(
5644        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5645        is_terminated: bool,
5646    ) -> Self {
5647        Self { inner, is_terminated }
5648    }
5649}
5650
5651impl futures::Stream for BufferCollectionTokenRequestStream {
5652    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5653
5654    fn poll_next(
5655        mut self: std::pin::Pin<&mut Self>,
5656        cx: &mut std::task::Context<'_>,
5657    ) -> std::task::Poll<Option<Self::Item>> {
5658        let this = &mut *self;
5659        if this.inner.check_shutdown(cx) {
5660            this.is_terminated = true;
5661            return std::task::Poll::Ready(None);
5662        }
5663        if this.is_terminated {
5664            panic!("polled BufferCollectionTokenRequestStream after completion");
5665        }
5666        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5667            |bytes, handles| {
5668                match this.inner.channel().read_etc(cx, bytes, handles) {
5669                    std::task::Poll::Ready(Ok(())) => {}
5670                    std::task::Poll::Pending => return std::task::Poll::Pending,
5671                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5672                        this.is_terminated = true;
5673                        return std::task::Poll::Ready(None);
5674                    }
5675                    std::task::Poll::Ready(Err(e)) => {
5676                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5677                            e.into(),
5678                        ))))
5679                    }
5680                }
5681
5682                // A message has been received from the channel
5683                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5684
5685                std::task::Poll::Ready(Some(match header.ordinal {
5686                0x4577e238ae26291 => {
5687                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5688                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5689                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5690                    let control_handle = BufferCollectionTokenControlHandle {
5691                        inner: this.inner.clone(),
5692                    };
5693                    Ok(BufferCollectionTokenRequest::Sync {
5694                        responder: BufferCollectionTokenSyncResponder {
5695                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5696                            tx_id: header.tx_id,
5697                        },
5698                    })
5699                }
5700                0x5b1d7a4f5681fca7 => {
5701                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5702                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5703                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5704                    let control_handle = BufferCollectionTokenControlHandle {
5705                        inner: this.inner.clone(),
5706                    };
5707                    Ok(BufferCollectionTokenRequest::Close {
5708                        control_handle,
5709                    })
5710                }
5711                0x77a41bb6217e2443 => {
5712                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5713                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5714                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5715                    let control_handle = BufferCollectionTokenControlHandle {
5716                        inner: this.inner.clone(),
5717                    };
5718                    Ok(BufferCollectionTokenRequest::SetName {priority: req.priority,
5719name: req.name,
5720
5721                        control_handle,
5722                    })
5723                }
5724                0x7275759070eb5ee2 => {
5725                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5726                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5727                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5728                    let control_handle = BufferCollectionTokenControlHandle {
5729                        inner: this.inner.clone(),
5730                    };
5731                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {name: req.name,
5732id: req.id,
5733
5734                        control_handle,
5735                    })
5736                }
5737                0x46d38f4772638867 => {
5738                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5739                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5740                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5741                    let control_handle = BufferCollectionTokenControlHandle {
5742                        inner: this.inner.clone(),
5743                    };
5744                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
5745
5746                        control_handle,
5747                    })
5748                }
5749                0x6bfbe2cf1701d288 => {
5750                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5751                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5752                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5753                    let control_handle = BufferCollectionTokenControlHandle {
5754                        inner: this.inner.clone(),
5755                    };
5756                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5757                        control_handle,
5758                    })
5759                }
5760                0x467b7c75c35c3b84 => {
5761                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5762                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5763                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5764                    let control_handle = BufferCollectionTokenControlHandle {
5765                        inner: this.inner.clone(),
5766                    };
5767                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5768                        responder: BufferCollectionTokenGetNodeRefResponder {
5769                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5770                            tx_id: header.tx_id,
5771                        },
5772                    })
5773                }
5774                0x33a2a7aff2776c07 => {
5775                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5776                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5777                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5778                    let control_handle = BufferCollectionTokenControlHandle {
5779                        inner: this.inner.clone(),
5780                    };
5781                    Ok(BufferCollectionTokenRequest::IsAlternateFor {node_ref: req.node_ref,
5782
5783                        responder: BufferCollectionTokenIsAlternateForResponder {
5784                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5785                            tx_id: header.tx_id,
5786                        },
5787                    })
5788                }
5789                0x49ed7ab7cc19f18 => {
5790                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5791                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5792                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5793                    let control_handle = BufferCollectionTokenControlHandle {
5794                        inner: this.inner.clone(),
5795                    };
5796                    Ok(BufferCollectionTokenRequest::DuplicateSync {rights_attenuation_masks: req.rights_attenuation_masks,
5797
5798                        responder: BufferCollectionTokenDuplicateSyncResponder {
5799                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5800                            tx_id: header.tx_id,
5801                        },
5802                    })
5803                }
5804                0x2f9f81bdde4b7292 => {
5805                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5806                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5807                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5808                    let control_handle = BufferCollectionTokenControlHandle {
5809                        inner: this.inner.clone(),
5810                    };
5811                    Ok(BufferCollectionTokenRequest::Duplicate {rights_attenuation_mask: req.rights_attenuation_mask,
5812token_request: req.token_request,
5813
5814                        control_handle,
5815                    })
5816                }
5817                0x76e4ec34fc2cf5b3 => {
5818                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5819                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5820                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5821                    let control_handle = BufferCollectionTokenControlHandle {
5822                        inner: this.inner.clone(),
5823                    };
5824                    Ok(BufferCollectionTokenRequest::SetDispensable {
5825                        control_handle,
5826                    })
5827                }
5828                0x2f6243e05f22b9a7 => {
5829                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5830                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5831                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5832                    let control_handle = BufferCollectionTokenControlHandle {
5833                        inner: this.inner.clone(),
5834                    };
5835                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {group_request: req.group_request,
5836
5837                        control_handle,
5838                    })
5839                }
5840                _ => Err(fidl::Error::UnknownOrdinal {
5841                    ordinal: header.ordinal,
5842                    protocol_name: <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5843                }),
5844            }))
5845            },
5846        )
5847    }
5848}
5849
5850/// A BufferCollectionToken is not a BufferCollection, but rather a way to
5851/// identify a potential shared BufferCollection prior to the BufferCollection
5852/// being allocated.
5853///
5854/// We use a channel for the BufferCollectionToken instead of a single eventpair
5855/// (pair) because this way we can detect error conditions like a participant
5856/// dying mid-create.
5857///
5858/// The fuchsia.sysmem.BufferCollectionToken type is not yet deprecated due to
5859/// its use in some other protocols (for now), but all the internals of
5860/// fuchsia.sysmem.BufferCollectionToken are deprecated. Token channels serve
5861/// both fuchsia.sysmem.BufferCollectionToken and
5862/// fuchsia.sysmem2.BufferCollectionToken.
5863///
5864/// This protocol will be deprecated once other protocols have switched their
5865/// token fields to fuchsia.sysmem2.BufferCollectionToken.
5866#[derive(Debug)]
5867pub enum BufferCollectionTokenRequest {
5868    /// Ensure that previous messages, including Duplicate() messages on a
5869    /// token, collection, or group, have been received server side.
5870    ///
5871    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5872    /// valid sysmem token risks the Sync() hanging forever.  See
5873    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5874    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5875    /// Another way is to pass the token to BindSharedCollection(), which also
5876    /// validates the token as part of exchanging it for a BufferCollection
5877    /// channel, and BufferCollection Sync() can then be used.
5878    ///
5879    /// After a Sync(), it's then safe to send the client end of token_request
5880    /// to another participant knowing the server will recognize the token when
5881    /// it's sent into BindSharedCollection() by the other participant.
5882    ///
5883    /// Other options include waiting for each token.Duplicate() to complete
5884    /// individually (using separate call to token.Sync() after each), or
5885    /// calling Sync() on BufferCollection after the token has been turned in
5886    /// via BindSharedCollection().
5887    ///
5888    /// Another way to mitigate is to avoid calling Sync() on the token, and
5889    /// instead later deal with potential failure of BufferCollection.Sync() if
5890    /// the original token was invalid.  This option can be preferable from a
5891    /// performance point of view, but requires client code to delay sending
5892    /// tokens duplicated from this token until after client code has converted
5893    /// the duplicating token to a BufferCollection and received successful
5894    /// response from BufferCollection.Sync().
5895    ///
5896    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5897    /// When BufferCollection.Sync() isn't feasible, the caller must already
5898    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5899    /// hang forever.  See ValidateBufferCollectionToken() to check token
5900    /// validity first if the token isn't already known to be (is/was) valid.
5901    Sync { responder: BufferCollectionTokenSyncResponder },
5902    /// On a BufferCollectionToken channel:
5903    ///
5904    /// Normally a participant will convert a BufferCollectionToken into a
5905    /// BufferCollection view, but a participant is also free to Close() the
5906    /// token (and then close the channel immediately or shortly later in
5907    /// response to server closing its end), which avoids causing logical buffer
5908    /// collection failure.  Normally an unexpected token channel close will
5909    /// cause logical buffer collection failure (the only exceptions being
5910    /// certain cases involving AttachToken() or SetDispensable()).
5911    ///
5912    /// On a BufferCollection channel:
5913    ///
5914    /// By default the server handles unexpected failure of a BufferCollection
5915    /// by failing the whole logical buffer collection.  Partly this is to
5916    /// expedite closing VMO handles to reclaim memory when any participant
5917    /// fails.  If a participant would like to cleanly close a BufferCollection
5918    /// view without causing logical buffer collection failure, the participant
5919    /// can send Close() before closing the client end of the BufferCollection
5920    /// channel.  If this is the last BufferCollection view, the logical buffer
5921    /// collection will still go away.  The Close() can occur before or after
5922    /// SetConstraints().  If before SetConstraints(), the buffer collection
5923    /// won't require constraints from this node in order to allocate.  If
5924    /// after SetConstraints(), the constraints are retained and aggregated
5925    /// along with any subsequent logical allocation(s), despite the lack of
5926    /// channel connection.
5927    ///
5928    /// On a BufferCollectionTokenGroup channel:
5929    ///
5930    /// By default, unexpected failure of a BufferCollectionTokenGroup will
5931    /// trigger failure of the logical BufferCollectionTokenGroup and will
5932    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
5933    /// channel without failing the logical group or propagating failure, send
5934    /// Close() before closing the channel client endpoint.
5935    ///
5936    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5937    /// collection will still fail despite the Close() (because sysmem can't be
5938    /// sure whether all relevant children were created, so it's ambiguous
5939    /// whether all relevant constraints will be provided to sysmem).  If
5940    /// Close() occurs after AllChildrenPresent(), the children and all their
5941    /// constraints remain intact (just as they would if the
5942    /// BufferCollectionTokenGroup channel had remained open), and the close
5943    /// doesn't trigger or propagate failure.
5944    Close { control_handle: BufferCollectionTokenControlHandle },
5945    /// Set a name for VMOs in this buffer collection. The name may be truncated
5946    /// shorter. The name only affects VMOs allocated after it's set - this call
5947    /// does not rename existing VMOs. If multiple clients set different names
5948    /// then the larger priority value will win.
5949    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenControlHandle },
5950    /// Set information about the current client that can be used by sysmem to
5951    /// help debug leaking memory and hangs waiting for constraints. |name| can
5952    /// be an arbitrary string, but the current process name (see
5953    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5954    /// arbitrary id, but the current process ID (see
5955    /// fsl::GetCurrentProcessKoid()) is a good default.
5956    ///
5957    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5958    /// indicate which client is closing their channel first, leading to
5959    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5960    /// over, but if happening earlier than expected, the
5961    /// client-channel-specific name can help diagnose where the failure is
5962    /// first coming from, from sysmem's point of view).
5963    ///
5964    /// By default (unless overriden by this message or using
5965    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5966    /// parent Node at the time the child Node is created.  While this can be
5967    /// better than nothing, it's often better for each participant to use
5968    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5969    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5970    /// can be used to help disambiguate if a Node is suspected of having info
5971    /// that was copied from its parent.
5972    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionTokenControlHandle },
5973    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5974    /// after creating a collection. Clients can call this method to change
5975    /// when the log is printed. If multiple client set the deadline, it's
5976    /// unspecified which deadline will take effect.
5977    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionTokenControlHandle },
5978    /// Verbose logging includes constraints set via SetConstraints() from each
5979    /// client along with info set via SetDebugClientInfo() and the structure of
5980    /// the tree of Node(s).
5981    ///
5982    /// Normally sysmem prints only a single line complaint when aggregation
5983    /// fails, with just the specific detailed reason that aggregation failed,
5984    /// with minimal context.  While this is often enough to diagnose a problem
5985    /// if only a small change was made and the system had been working before
5986    /// the small change, it's often not particularly helpful for getting a new
5987    /// buffer collection to work for the first time.  Especially with more
5988    /// complex trees of nodes, involving things like AttachToken(),
5989    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5990    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5991    /// looks like and why it's failing a logical allocation, or why a tree or
5992    /// sub-tree is failing sooner than expected.
5993    ///
5994    /// The intent of the extra logging is to be acceptable from a performance
5995    /// point of view, if only enabled on a low number of buffer collections.
5996    /// If we're not tracking down a bug, we shouldn't send this message.
5997    ///
5998    /// If too many participants leave verbose logging enabled, we may end up
5999    /// needing to require that system-wide sysmem verbose logging be permitted
6000    /// via some other setting, to avoid sysmem spamming the log too much due to
6001    /// this message.
6002    ///
6003    /// This may be a NOP for some nodes due to intentional policy associated
6004    /// with the node, if we don't trust a node enough to let it turn on verbose
6005    /// logging.
6006    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
6007    /// This gets an event handle that can be used as a parameter to
6008    /// IsAlternateFor() called on any Node.  The client will not be granted the
6009    /// right to signal this event, as this handle should only be used as proof
6010    /// that the client obtained this handle from this Node.
6011    ///
6012    /// Because this is a get not a set, no Sync() is needed between the
6013    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6014    /// potentially being on different channels.
6015    ///
6016    /// See also IsAlternateFor().
6017    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
6018    /// This checks whether the calling node is in a subtree rooted at a
6019    /// different child token of a common parent BufferCollectionTokenGroup, in
6020    /// relation to the passed-in node_ref.
6021    ///
6022    /// This call is for assisting with admission control de-duplication, and
6023    /// with debugging.
6024    ///
6025    /// The node_ref must be obtained using GetNodeRef() of a
6026    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6027    ///
6028    /// The node_ref can be a duplicated handle; it's not necessary to call
6029    /// GetNodeRef() for every call to IsAlternateFor().
6030    ///
6031    /// If a calling token may not actually be a valid token at all due to
6032    /// a potentially hostile/untrusted provider of the token, call
6033    /// ValidateBufferCollectionToken() first instead of potentially getting
6034    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6035    /// token not being a real token (not really talking to sysmem).  Another
6036    /// option is to call BindSharedCollection with this token first which also
6037    /// validates the token along with converting it to a BufferCollection, then
6038    /// call BufferCollection IsAlternateFor().
6039    ///
6040    /// error values:
6041    ///
6042    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6043    /// buffer collection as the calling Node.  Before logical allocation and
6044    /// within the same logical allocation sub-tree, this essentially means that
6045    /// the node_ref was never part of this logical buffer collection, since
6046    /// before logical allocation all node_refs that come into existence remain
6047    /// in existence at least until logical allocation (including Node(s) that
6048    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6049    /// to be returned, this Node's channel needs to still be connected server
6050    /// side, which won't be the case if the whole logical allocation has
6051    /// failed.  After logical allocation or in a different logical allocation
6052    /// sub-tree there are additional potential reasons for this error.  For
6053    /// example a different logical allocation (separated from this Node(s)
6054    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6055    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6056    /// exist and may select a different child sub-tree than the sub-tree the
6057    /// node_ref is in causing deletion of the node_ref Node.  The only time
6058    /// sysmem keeps a Node around after that Node has no corresponding channel
6059    /// is when Close() is used and the Node's sub-tree has not yet failed.
6060    /// Another reason for this error is if the node_ref is an eventpair handle
6061    /// with sufficient rights, but isn't actually a real node_ref obtained from
6062    /// GetNodeRef().
6063    ///
6064    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6065    /// eventpair handle, or doesn't have the needed rights expected on a real
6066    /// node_ref.
6067    ///
6068    /// No other failing status codes are returned by this call.  However,
6069    /// sysmem may add additional codes in future, so the client should have
6070    /// sensible default handling for any failing status code.
6071    ///
6072    /// On success, is_alternate has the following meaning:
6073    ///   * true - The first parent node in common between the calling node and
6074    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
6075    ///     the calling Node and the node_ref Node will _not_ have both their
6076    ///     constraints apply - rather sysmem will choose one or the other of
6077    ///     the constraints - never both.  This is because only one child of
6078    ///     a BufferCollectionTokenGroup is selected during logical allocation,
6079    ///     with only that one child's sub-tree contributing to constraints
6080    ///     aggregation.
6081    ///   * false - The first parent node in common between the calling Node and
6082    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
6083    ///     this means the first parent node in common is a
6084    ///     BufferCollectionToken or BufferCollection (regardless of not
6085    ///     Close()ed or Close()ed).  This means that the calling Node and the
6086    ///     node_ref Node _may_ have both their constraints apply during
6087    ///     constraints aggregation of the logical allocation, if both Node(s)
6088    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
6089    ///     In this case, there is no BufferCollectionTokenGroup that will
6090    ///     directly prevent the two Node(s) from both being selected and their
6091    ///     constraints both aggregated, but even when false, one or both
6092    ///     Node(s) may still be eliminated from consideration if one or both
6093    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6094    ///     which selects a child sub-tree other than the sub-tree containing
6095    ///     the calling Node or node_ref Node.
6096    IsAlternateFor {
6097        node_ref: fidl::Event,
6098        responder: BufferCollectionTokenIsAlternateForResponder,
6099    },
6100    /// This method can be used to add more participants prior to creating a
6101    /// shared BufferCollection. A new token will be returned for each entry in
6102    /// the `rights_attenuation_masks` array. The return value is the client
6103    /// ends of each new participant token.
6104    ///
6105    /// If the calling token may not actually be a valid token at all due to
6106    /// a potentially hostile/untrusted provider of the token, consider using
6107    /// ValidateBufferCollectionToken() first instead of potentially getting
6108    /// stuck indefinitely if DuplicateSync() never responds due to the calling
6109    /// token not being a real token.
6110    ///
6111    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
6112    /// after calling this method.
6113    ///
6114    /// All tokens must be turned in via BindSharedCollection() or Close() for a
6115    /// BufferCollection to be successfully created.
6116    ///
6117    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
6118    /// will be absent in the buffer VMO rights obtainable via the corresponding
6119    /// returned token. This allows an initiator or intermediary participant to
6120    /// attenuate the rights available to a participant. This does not allow a
6121    /// participant to gain rights that the participant doesn't already have.
6122    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
6123    /// attenuation should be applied.
6124    DuplicateSync {
6125        rights_attenuation_masks: Vec<fidl::Rights>,
6126        responder: BufferCollectionTokenDuplicateSyncResponder,
6127    },
6128    /// This method can be used to add a participant prior to creating a shared
6129    /// BufferCollection. It should only be used instead of DuplicateSync in
6130    /// performance sensitive cases where it would be undesireable to wait for
6131    /// sysmem to respond as part of each duplicate.
6132    ///
6133    /// After sending one or more Duplicate() messages, and before sending the
6134    /// created tokens to other participants (or to other Allocator channels),
6135    /// the client should send a Sync() and wait for its response.  The Sync()
6136    /// call can be made on the token, or on the BufferCollection obtained by
6137    /// passing this token to BindSharedCollection().  Either will ensure that
6138    /// the server knows about the tokens created via Duplicate() before the
6139    /// other participant sends the token to the server via separate Allocator
6140    /// channel.
6141    ///
6142    /// All tokens must be turned in via BindSharedCollection() or Close() for a
6143    /// BufferCollection to be successfully created.
6144    ///
6145    /// When a client calls BindSharedCollection() to turn in a
6146    /// BufferCollectionToken, the server will process all Duplicate() messages
6147    /// before closing down the BufferCollectionToken.  This allows the client
6148    /// to Duplicate() and immediately turn in the BufferCollectionToken using
6149    /// BindSharedCollection, then later transfer the client end of token_request
6150    /// to another participant - the server will notice the existence of the
6151    /// token_request before considering this BufferCollectionToken fully closed.
6152    ///
6153    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
6154    /// absent in the buffer VMO rights obtainable via the client end of
6155    /// token_request. This allows an initiator or intermediary participant to
6156    /// attenuate the rights available to a participant. This does not allow a
6157    /// participant to gain rights that the participant doesn't already have.
6158    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
6159    /// attenuation should be applied.
6160    ///
6161    /// These values for rights_attenuation_mask result in no attenuation:
6162    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
6163    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
6164    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
6165    ///
6166    /// `token_request` is the server end of a BufferCollectionToken channel.
6167    /// The client end of this channel acts as another participant in creating the
6168    /// shared BufferCollection.
6169    Duplicate {
6170        rights_attenuation_mask: u32,
6171        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
6172        control_handle: BufferCollectionTokenControlHandle,
6173    },
6174    /// A dispensable token can fail after buffers are logically allocated
6175    /// without causing failure of its parent (if any).
6176    ///
6177    /// The dispensable token participates in constraints aggregation along with
6178    /// its parent before logical buffer allocation.  If the dispensable token
6179    /// fails before buffers are logically allocated, the failure propagates to
6180    /// the dispensable token's parent.
6181    ///
6182    /// After buffers are logically allocated, failure of the dispensable token
6183    /// (or any child of the dispensable token) does not propagate to the
6184    /// dispensable token's parent.  Failure does propagate from a normal
6185    /// child of a dispensable token to the dispensable token.  Failure
6186    /// of a child is blocked from reaching its parent if the child is attached,
6187    /// or if the child is dispensable and the failure occurred after logical
6188    /// allocation.
6189    ///
6190    /// A dispensable token can be used in cases where a participant needs to
6191    /// provide constraints, but after buffers are allocated, the participant
6192    /// can fail without causing buffer collection failure from the parent's
6193    /// point of view.
6194    ///
6195    /// In contrast, AttachToken() can be used to create a token which does not
6196    /// participate in constraints aggregation with its parent, and whose
6197    /// failure at any time does not propagate to its parent, and whose delay
6198    /// providing constraints does not prevent the parent from completing its
6199    /// buffer allocation.
6200    ///
6201    /// An initiator may in some scenarios choose to initially use a dispensable
6202    /// token for a given instance of a participant, and then later if the first
6203    /// instance of that participant fails, a new second instance of that
6204    /// participant my be given a token created with AttachToken().
6205    ///
6206    /// If a client uses this message, the client should not rely on the
6207    /// client's own BufferCollectionToken or BufferCollection channel to close
6208    /// from the server end due to abrupt failure of any BufferCollectionToken
6209    /// or BufferCollection that the client has SetDispensable() and given out
6210    /// to another process.  For this reason, the client should take extra care
6211    /// to notice failure of that other process via other means.
6212    ///
6213    /// While it is possible (and potentially useful) to SetDispensable() on a
6214    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
6215    /// replace a failed dispensable token that was a direct child of a group
6216    /// with a new token using AttachToken() (since there's no AttachToken() on
6217    /// a group).  Instead, to enable AttachToken() replacement in this case,
6218    /// create an additional non-dispensable token (node) that's a direct child
6219    /// of the group and make the existing dispensable token a child of the
6220    /// additional token (node).  This way, the additional token (node) that is
6221    /// a direct child of the group has BufferCollection.AttachToken() which can
6222    /// be used to replace the failed dispensable token.
6223    ///
6224    /// SetDispensable() on an already-dispensable token is idempotent.
6225    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
6226    /// Most sysmem clients and many participants don't need to care about this
6227    /// message or about BufferCollectionTokenGroup(s) in general.
6228    ///
6229    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
6230    /// tokens.  The child tokens which are not selected during aggregation will
6231    /// fail (close), which a potential participant should notice when their
6232    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
6233    /// participant to clean up the speculative usage that didn't end up
6234    /// happening (similarly to a normal BufferCollection server end closing
6235    /// on failure of a logical buffer collection).
6236    ///
6237    /// See comments on protocol BufferCollectionTokenGroup.
6238    ///
6239    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
6240    /// applied to the whole group can be achieved with a token for this purpose
6241    /// as a direct parent of the group.
6242    ///
6243    /// group_request - the server end of a BufferCollectionTokenGroup channel
6244    /// to be served by sysmem.
6245    CreateBufferCollectionTokenGroup {
6246        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6247        control_handle: BufferCollectionTokenControlHandle,
6248    },
6249}
6250
6251impl BufferCollectionTokenRequest {
6252    #[allow(irrefutable_let_patterns)]
6253    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6254        if let BufferCollectionTokenRequest::Sync { responder } = self {
6255            Some((responder))
6256        } else {
6257            None
6258        }
6259    }
6260
6261    #[allow(irrefutable_let_patterns)]
6262    pub fn into_close(self) -> Option<(BufferCollectionTokenControlHandle)> {
6263        if let BufferCollectionTokenRequest::Close { control_handle } = self {
6264            Some((control_handle))
6265        } else {
6266            None
6267        }
6268    }
6269
6270    #[allow(irrefutable_let_patterns)]
6271    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenControlHandle)> {
6272        if let BufferCollectionTokenRequest::SetName { priority, name, control_handle } = self {
6273            Some((priority, name, control_handle))
6274        } else {
6275            None
6276        }
6277    }
6278
6279    #[allow(irrefutable_let_patterns)]
6280    pub fn into_set_debug_client_info(
6281        self,
6282    ) -> Option<(String, u64, BufferCollectionTokenControlHandle)> {
6283        if let BufferCollectionTokenRequest::SetDebugClientInfo { name, id, control_handle } = self
6284        {
6285            Some((name, id, control_handle))
6286        } else {
6287            None
6288        }
6289    }
6290
6291    #[allow(irrefutable_let_patterns)]
6292    pub fn into_set_debug_timeout_log_deadline(
6293        self,
6294    ) -> Option<(i64, BufferCollectionTokenControlHandle)> {
6295        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6296            deadline,
6297            control_handle,
6298        } = self
6299        {
6300            Some((deadline, control_handle))
6301        } else {
6302            None
6303        }
6304    }
6305
6306    #[allow(irrefutable_let_patterns)]
6307    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6308        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6309            Some((control_handle))
6310        } else {
6311            None
6312        }
6313    }
6314
6315    #[allow(irrefutable_let_patterns)]
6316    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6317        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6318            Some((responder))
6319        } else {
6320            None
6321        }
6322    }
6323
6324    #[allow(irrefutable_let_patterns)]
6325    pub fn into_is_alternate_for(
6326        self,
6327    ) -> Option<(fidl::Event, BufferCollectionTokenIsAlternateForResponder)> {
6328        if let BufferCollectionTokenRequest::IsAlternateFor { node_ref, responder } = self {
6329            Some((node_ref, responder))
6330        } else {
6331            None
6332        }
6333    }
6334
6335    #[allow(irrefutable_let_patterns)]
6336    pub fn into_duplicate_sync(
6337        self,
6338    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenDuplicateSyncResponder)> {
6339        if let BufferCollectionTokenRequest::DuplicateSync { rights_attenuation_masks, responder } =
6340            self
6341        {
6342            Some((rights_attenuation_masks, responder))
6343        } else {
6344            None
6345        }
6346    }
6347
6348    #[allow(irrefutable_let_patterns)]
6349    pub fn into_duplicate(
6350        self,
6351    ) -> Option<(
6352        u32,
6353        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
6354        BufferCollectionTokenControlHandle,
6355    )> {
6356        if let BufferCollectionTokenRequest::Duplicate {
6357            rights_attenuation_mask,
6358            token_request,
6359            control_handle,
6360        } = self
6361        {
6362            Some((rights_attenuation_mask, token_request, control_handle))
6363        } else {
6364            None
6365        }
6366    }
6367
6368    #[allow(irrefutable_let_patterns)]
6369    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6370        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6371            Some((control_handle))
6372        } else {
6373            None
6374        }
6375    }
6376
6377    #[allow(irrefutable_let_patterns)]
6378    pub fn into_create_buffer_collection_token_group(
6379        self,
6380    ) -> Option<(
6381        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6382        BufferCollectionTokenControlHandle,
6383    )> {
6384        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6385            group_request,
6386            control_handle,
6387        } = self
6388        {
6389            Some((group_request, control_handle))
6390        } else {
6391            None
6392        }
6393    }
6394
6395    /// Name of the method defined in FIDL
6396    pub fn method_name(&self) -> &'static str {
6397        match *self {
6398            BufferCollectionTokenRequest::Sync { .. } => "sync",
6399            BufferCollectionTokenRequest::Close { .. } => "close",
6400            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6401            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6402            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6403                "set_debug_timeout_log_deadline"
6404            }
6405            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6406            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6407            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6408            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6409            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6410            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6411            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6412                "create_buffer_collection_token_group"
6413            }
6414        }
6415    }
6416}
6417
6418#[derive(Debug, Clone)]
6419pub struct BufferCollectionTokenControlHandle {
6420    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6421}
6422
6423impl fidl::endpoints::ControlHandle for BufferCollectionTokenControlHandle {
6424    fn shutdown(&self) {
6425        self.inner.shutdown()
6426    }
6427    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6428        self.inner.shutdown_with_epitaph(status)
6429    }
6430
6431    fn is_closed(&self) -> bool {
6432        self.inner.channel().is_closed()
6433    }
6434    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6435        self.inner.channel().on_closed()
6436    }
6437
6438    #[cfg(target_os = "fuchsia")]
6439    fn signal_peer(
6440        &self,
6441        clear_mask: zx::Signals,
6442        set_mask: zx::Signals,
6443    ) -> Result<(), zx_status::Status> {
6444        use fidl::Peered;
6445        self.inner.channel().signal_peer(clear_mask, set_mask)
6446    }
6447}
6448
6449impl BufferCollectionTokenControlHandle {}
6450
6451#[must_use = "FIDL methods require a response to be sent"]
6452#[derive(Debug)]
6453pub struct BufferCollectionTokenSyncResponder {
6454    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6455    tx_id: u32,
6456}
6457
6458/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6459/// if the responder is dropped without sending a response, so that the client
6460/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6461impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6462    fn drop(&mut self) {
6463        self.control_handle.shutdown();
6464        // Safety: drops once, never accessed again
6465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6466    }
6467}
6468
6469impl fidl::endpoints::Responder for BufferCollectionTokenSyncResponder {
6470    type ControlHandle = BufferCollectionTokenControlHandle;
6471
6472    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6473        &self.control_handle
6474    }
6475
6476    fn drop_without_shutdown(mut self) {
6477        // Safety: drops once, never accessed again due to mem::forget
6478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6479        // Prevent Drop from running (which would shut down the channel)
6480        std::mem::forget(self);
6481    }
6482}
6483
6484impl BufferCollectionTokenSyncResponder {
6485    /// Sends a response to the FIDL transaction.
6486    ///
6487    /// Sets the channel to shutdown if an error occurs.
6488    pub fn send(self) -> Result<(), fidl::Error> {
6489        let _result = self.send_raw();
6490        if _result.is_err() {
6491            self.control_handle.shutdown();
6492        }
6493        self.drop_without_shutdown();
6494        _result
6495    }
6496
6497    /// Similar to "send" but does not shutdown the channel if an error occurs.
6498    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6499        let _result = self.send_raw();
6500        self.drop_without_shutdown();
6501        _result
6502    }
6503
6504    fn send_raw(&self) -> Result<(), fidl::Error> {
6505        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6506            (),
6507            self.tx_id,
6508            0x4577e238ae26291,
6509            fidl::encoding::DynamicFlags::empty(),
6510        )
6511    }
6512}
6513
6514#[must_use = "FIDL methods require a response to be sent"]
6515#[derive(Debug)]
6516pub struct BufferCollectionTokenGetNodeRefResponder {
6517    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6518    tx_id: u32,
6519}
6520
6521/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6522/// if the responder is dropped without sending a response, so that the client
6523/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6524impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6525    fn drop(&mut self) {
6526        self.control_handle.shutdown();
6527        // Safety: drops once, never accessed again
6528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6529    }
6530}
6531
6532impl fidl::endpoints::Responder for BufferCollectionTokenGetNodeRefResponder {
6533    type ControlHandle = BufferCollectionTokenControlHandle;
6534
6535    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6536        &self.control_handle
6537    }
6538
6539    fn drop_without_shutdown(mut self) {
6540        // Safety: drops once, never accessed again due to mem::forget
6541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6542        // Prevent Drop from running (which would shut down the channel)
6543        std::mem::forget(self);
6544    }
6545}
6546
6547impl BufferCollectionTokenGetNodeRefResponder {
6548    /// Sends a response to the FIDL transaction.
6549    ///
6550    /// Sets the channel to shutdown if an error occurs.
6551    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6552        let _result = self.send_raw(node_ref);
6553        if _result.is_err() {
6554            self.control_handle.shutdown();
6555        }
6556        self.drop_without_shutdown();
6557        _result
6558    }
6559
6560    /// Similar to "send" but does not shutdown the channel if an error occurs.
6561    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6562        let _result = self.send_raw(node_ref);
6563        self.drop_without_shutdown();
6564        _result
6565    }
6566
6567    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6568        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
6569            (node_ref,),
6570            self.tx_id,
6571            0x467b7c75c35c3b84,
6572            fidl::encoding::DynamicFlags::empty(),
6573        )
6574    }
6575}
6576
6577#[must_use = "FIDL methods require a response to be sent"]
6578#[derive(Debug)]
6579pub struct BufferCollectionTokenIsAlternateForResponder {
6580    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6581    tx_id: u32,
6582}
6583
6584/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6585/// if the responder is dropped without sending a response, so that the client
6586/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6587impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
6588    fn drop(&mut self) {
6589        self.control_handle.shutdown();
6590        // Safety: drops once, never accessed again
6591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6592    }
6593}
6594
6595impl fidl::endpoints::Responder for BufferCollectionTokenIsAlternateForResponder {
6596    type ControlHandle = BufferCollectionTokenControlHandle;
6597
6598    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6599        &self.control_handle
6600    }
6601
6602    fn drop_without_shutdown(mut self) {
6603        // Safety: drops once, never accessed again due to mem::forget
6604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6605        // Prevent Drop from running (which would shut down the channel)
6606        std::mem::forget(self);
6607    }
6608}
6609
6610impl BufferCollectionTokenIsAlternateForResponder {
6611    /// Sends a response to the FIDL transaction.
6612    ///
6613    /// Sets the channel to shutdown if an error occurs.
6614    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6615        let _result = self.send_raw(result);
6616        if _result.is_err() {
6617            self.control_handle.shutdown();
6618        }
6619        self.drop_without_shutdown();
6620        _result
6621    }
6622
6623    /// Similar to "send" but does not shutdown the channel if an error occurs.
6624    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6625        let _result = self.send_raw(result);
6626        self.drop_without_shutdown();
6627        _result
6628    }
6629
6630    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6631        self.control_handle
6632            .inner
6633            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
6634                result.map(|is_alternate| (is_alternate,)),
6635                self.tx_id,
6636                0x33a2a7aff2776c07,
6637                fidl::encoding::DynamicFlags::empty(),
6638            )
6639    }
6640}
6641
6642#[must_use = "FIDL methods require a response to be sent"]
6643#[derive(Debug)]
6644pub struct BufferCollectionTokenDuplicateSyncResponder {
6645    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6646    tx_id: u32,
6647}
6648
6649/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6650/// if the responder is dropped without sending a response, so that the client
6651/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6652impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
6653    fn drop(&mut self) {
6654        self.control_handle.shutdown();
6655        // Safety: drops once, never accessed again
6656        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6657    }
6658}
6659
6660impl fidl::endpoints::Responder for BufferCollectionTokenDuplicateSyncResponder {
6661    type ControlHandle = BufferCollectionTokenControlHandle;
6662
6663    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6664        &self.control_handle
6665    }
6666
6667    fn drop_without_shutdown(mut self) {
6668        // Safety: drops once, never accessed again due to mem::forget
6669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6670        // Prevent Drop from running (which would shut down the channel)
6671        std::mem::forget(self);
6672    }
6673}
6674
6675impl BufferCollectionTokenDuplicateSyncResponder {
6676    /// Sends a response to the FIDL transaction.
6677    ///
6678    /// Sets the channel to shutdown if an error occurs.
6679    pub fn send(
6680        self,
6681        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6682    ) -> Result<(), fidl::Error> {
6683        let _result = self.send_raw(tokens);
6684        if _result.is_err() {
6685            self.control_handle.shutdown();
6686        }
6687        self.drop_without_shutdown();
6688        _result
6689    }
6690
6691    /// Similar to "send" but does not shutdown the channel if an error occurs.
6692    pub fn send_no_shutdown_on_err(
6693        self,
6694        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6695    ) -> Result<(), fidl::Error> {
6696        let _result = self.send_raw(tokens);
6697        self.drop_without_shutdown();
6698        _result
6699    }
6700
6701    fn send_raw(
6702        &self,
6703        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6704    ) -> Result<(), fidl::Error> {
6705        self.control_handle.inner.send::<BufferCollectionTokenDuplicateSyncResponse>(
6706            (tokens.as_mut(),),
6707            self.tx_id,
6708            0x49ed7ab7cc19f18,
6709            fidl::encoding::DynamicFlags::empty(),
6710        )
6711    }
6712}
6713
6714#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6715pub struct BufferCollectionTokenGroupMarker;
6716
6717impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenGroupMarker {
6718    type Proxy = BufferCollectionTokenGroupProxy;
6719    type RequestStream = BufferCollectionTokenGroupRequestStream;
6720    #[cfg(target_os = "fuchsia")]
6721    type SynchronousProxy = BufferCollectionTokenGroupSynchronousProxy;
6722
6723    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
6724}
6725
6726pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
6727    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6728    fn r#sync(&self) -> Self::SyncResponseFut;
6729    fn r#close(&self) -> Result<(), fidl::Error>;
6730    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
6731    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
6732    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
6733    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
6734    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
6735        + Send;
6736    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
6737    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
6738        + Send;
6739    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
6740    fn r#create_child(
6741        &self,
6742        payload: BufferCollectionTokenGroupCreateChildRequest,
6743    ) -> Result<(), fidl::Error>;
6744    type CreateChildrenSyncResponseFut: std::future::Future<
6745            Output = Result<
6746                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6747                fidl::Error,
6748            >,
6749        > + Send;
6750    fn r#create_children_sync(
6751        &self,
6752        rights_attenuation_masks: &[fidl::Rights],
6753    ) -> Self::CreateChildrenSyncResponseFut;
6754    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
6755}
6756#[derive(Debug)]
6757#[cfg(target_os = "fuchsia")]
6758pub struct BufferCollectionTokenGroupSynchronousProxy {
6759    client: fidl::client::sync::Client,
6760}
6761
6762#[cfg(target_os = "fuchsia")]
6763impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenGroupSynchronousProxy {
6764    type Proxy = BufferCollectionTokenGroupProxy;
6765    type Protocol = BufferCollectionTokenGroupMarker;
6766
6767    fn from_channel(inner: fidl::Channel) -> Self {
6768        Self::new(inner)
6769    }
6770
6771    fn into_channel(self) -> fidl::Channel {
6772        self.client.into_channel()
6773    }
6774
6775    fn as_channel(&self) -> &fidl::Channel {
6776        self.client.as_channel()
6777    }
6778}
6779
6780#[cfg(target_os = "fuchsia")]
6781impl BufferCollectionTokenGroupSynchronousProxy {
6782    pub fn new(channel: fidl::Channel) -> Self {
6783        let protocol_name =
6784            <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6785        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6786    }
6787
6788    pub fn into_channel(self) -> fidl::Channel {
6789        self.client.into_channel()
6790    }
6791
6792    /// Waits until an event arrives and returns it. It is safe for other
6793    /// threads to make concurrent requests while waiting for an event.
6794    pub fn wait_for_event(
6795        &self,
6796        deadline: zx::MonotonicInstant,
6797    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
6798        BufferCollectionTokenGroupEvent::decode(self.client.wait_for_event(deadline)?)
6799    }
6800
6801    /// Ensure that previous messages, including Duplicate() messages on a
6802    /// token, collection, or group, have been received server side.
6803    ///
6804    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
6805    /// valid sysmem token risks the Sync() hanging forever.  See
6806    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
6807    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
6808    /// Another way is to pass the token to BindSharedCollection(), which also
6809    /// validates the token as part of exchanging it for a BufferCollection
6810    /// channel, and BufferCollection Sync() can then be used.
6811    ///
6812    /// After a Sync(), it's then safe to send the client end of token_request
6813    /// to another participant knowing the server will recognize the token when
6814    /// it's sent into BindSharedCollection() by the other participant.
6815    ///
6816    /// Other options include waiting for each token.Duplicate() to complete
6817    /// individually (using separate call to token.Sync() after each), or
6818    /// calling Sync() on BufferCollection after the token has been turned in
6819    /// via BindSharedCollection().
6820    ///
6821    /// Another way to mitigate is to avoid calling Sync() on the token, and
6822    /// instead later deal with potential failure of BufferCollection.Sync() if
6823    /// the original token was invalid.  This option can be preferable from a
6824    /// performance point of view, but requires client code to delay sending
6825    /// tokens duplicated from this token until after client code has converted
6826    /// the duplicating token to a BufferCollection and received successful
6827    /// response from BufferCollection.Sync().
6828    ///
6829    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
6830    /// When BufferCollection.Sync() isn't feasible, the caller must already
6831    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
6832    /// hang forever.  See ValidateBufferCollectionToken() to check token
6833    /// validity first if the token isn't already known to be (is/was) valid.
6834    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
6835        let _response =
6836            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
6837                (),
6838                0x4577e238ae26291,
6839                fidl::encoding::DynamicFlags::empty(),
6840                ___deadline,
6841            )?;
6842        Ok(_response)
6843    }
6844
6845    /// On a BufferCollectionToken channel:
6846    ///
6847    /// Normally a participant will convert a BufferCollectionToken into a
6848    /// BufferCollection view, but a participant is also free to Close() the
6849    /// token (and then close the channel immediately or shortly later in
6850    /// response to server closing its end), which avoids causing logical buffer
6851    /// collection failure.  Normally an unexpected token channel close will
6852    /// cause logical buffer collection failure (the only exceptions being
6853    /// certain cases involving AttachToken() or SetDispensable()).
6854    ///
6855    /// On a BufferCollection channel:
6856    ///
6857    /// By default the server handles unexpected failure of a BufferCollection
6858    /// by failing the whole logical buffer collection.  Partly this is to
6859    /// expedite closing VMO handles to reclaim memory when any participant
6860    /// fails.  If a participant would like to cleanly close a BufferCollection
6861    /// view without causing logical buffer collection failure, the participant
6862    /// can send Close() before closing the client end of the BufferCollection
6863    /// channel.  If this is the last BufferCollection view, the logical buffer
6864    /// collection will still go away.  The Close() can occur before or after
6865    /// SetConstraints().  If before SetConstraints(), the buffer collection
6866    /// won't require constraints from this node in order to allocate.  If
6867    /// after SetConstraints(), the constraints are retained and aggregated
6868    /// along with any subsequent logical allocation(s), despite the lack of
6869    /// channel connection.
6870    ///
6871    /// On a BufferCollectionTokenGroup channel:
6872    ///
6873    /// By default, unexpected failure of a BufferCollectionTokenGroup will
6874    /// trigger failure of the logical BufferCollectionTokenGroup and will
6875    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
6876    /// channel without failing the logical group or propagating failure, send
6877    /// Close() before closing the channel client endpoint.
6878    ///
6879    /// If Close() occurs before AllChildrenPresent(), the logical buffer
6880    /// collection will still fail despite the Close() (because sysmem can't be
6881    /// sure whether all relevant children were created, so it's ambiguous
6882    /// whether all relevant constraints will be provided to sysmem).  If
6883    /// Close() occurs after AllChildrenPresent(), the children and all their
6884    /// constraints remain intact (just as they would if the
6885    /// BufferCollectionTokenGroup channel had remained open), and the close
6886    /// doesn't trigger or propagate failure.
6887    pub fn r#close(&self) -> Result<(), fidl::Error> {
6888        self.client.send::<fidl::encoding::EmptyPayload>(
6889            (),
6890            0x5b1d7a4f5681fca7,
6891            fidl::encoding::DynamicFlags::empty(),
6892        )
6893    }
6894
6895    /// Set a name for VMOs in this buffer collection. The name may be truncated
6896    /// shorter. The name only affects VMOs allocated after it's set - this call
6897    /// does not rename existing VMOs. If multiple clients set different names
6898    /// then the larger priority value will win.
6899    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
6900        self.client.send::<NodeSetNameRequest>(
6901            (priority, name),
6902            0x77a41bb6217e2443,
6903            fidl::encoding::DynamicFlags::empty(),
6904        )
6905    }
6906
6907    /// Set information about the current client that can be used by sysmem to
6908    /// help debug leaking memory and hangs waiting for constraints. |name| can
6909    /// be an arbitrary string, but the current process name (see
6910    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6911    /// arbitrary id, but the current process ID (see
6912    /// fsl::GetCurrentProcessKoid()) is a good default.
6913    ///
6914    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6915    /// indicate which client is closing their channel first, leading to
6916    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6917    /// over, but if happening earlier than expected, the
6918    /// client-channel-specific name can help diagnose where the failure is
6919    /// first coming from, from sysmem's point of view).
6920    ///
6921    /// By default (unless overriden by this message or using
6922    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6923    /// parent Node at the time the child Node is created.  While this can be
6924    /// better than nothing, it's often better for each participant to use
6925    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6926    /// info directly relevant to the current client.  Also, SetVerboseLogging()
6927    /// can be used to help disambiguate if a Node is suspected of having info
6928    /// that was copied from its parent.
6929    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
6930        self.client.send::<NodeSetDebugClientInfoRequest>(
6931            (name, id),
6932            0x7275759070eb5ee2,
6933            fidl::encoding::DynamicFlags::empty(),
6934        )
6935    }
6936
6937    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6938    /// after creating a collection. Clients can call this method to change
6939    /// when the log is printed. If multiple client set the deadline, it's
6940    /// unspecified which deadline will take effect.
6941    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
6942        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
6943            (deadline,),
6944            0x46d38f4772638867,
6945            fidl::encoding::DynamicFlags::empty(),
6946        )
6947    }
6948
6949    /// Verbose logging includes constraints set via SetConstraints() from each
6950    /// client along with info set via SetDebugClientInfo() and the structure of
6951    /// the tree of Node(s).
6952    ///
6953    /// Normally sysmem prints only a single line complaint when aggregation
6954    /// fails, with just the specific detailed reason that aggregation failed,
6955    /// with minimal context.  While this is often enough to diagnose a problem
6956    /// if only a small change was made and the system had been working before
6957    /// the small change, it's often not particularly helpful for getting a new
6958    /// buffer collection to work for the first time.  Especially with more
6959    /// complex trees of nodes, involving things like AttachToken(),
6960    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6961    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6962    /// looks like and why it's failing a logical allocation, or why a tree or
6963    /// sub-tree is failing sooner than expected.
6964    ///
6965    /// The intent of the extra logging is to be acceptable from a performance
6966    /// point of view, if only enabled on a low number of buffer collections.
6967    /// If we're not tracking down a bug, we shouldn't send this message.
6968    ///
6969    /// If too many participants leave verbose logging enabled, we may end up
6970    /// needing to require that system-wide sysmem verbose logging be permitted
6971    /// via some other setting, to avoid sysmem spamming the log too much due to
6972    /// this message.
6973    ///
6974    /// This may be a NOP for some nodes due to intentional policy associated
6975    /// with the node, if we don't trust a node enough to let it turn on verbose
6976    /// logging.
6977    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
6978        self.client.send::<fidl::encoding::EmptyPayload>(
6979            (),
6980            0x6bfbe2cf1701d288,
6981            fidl::encoding::DynamicFlags::empty(),
6982        )
6983    }
6984
6985    /// This gets an event handle that can be used as a parameter to
6986    /// IsAlternateFor() called on any Node.  The client will not be granted the
6987    /// right to signal this event, as this handle should only be used as proof
6988    /// that the client obtained this handle from this Node.
6989    ///
6990    /// Because this is a get not a set, no Sync() is needed between the
6991    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6992    /// potentially being on different channels.
6993    ///
6994    /// See also IsAlternateFor().
6995    pub fn r#get_node_ref(
6996        &self,
6997        ___deadline: zx::MonotonicInstant,
6998    ) -> Result<fidl::Event, fidl::Error> {
6999        let _response =
7000            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
7001                (),
7002                0x467b7c75c35c3b84,
7003                fidl::encoding::DynamicFlags::empty(),
7004                ___deadline,
7005            )?;
7006        Ok(_response.node_ref)
7007    }
7008
7009    /// This checks whether the calling node is in a subtree rooted at a
7010    /// different child token of a common parent BufferCollectionTokenGroup, in
7011    /// relation to the passed-in node_ref.
7012    ///
7013    /// This call is for assisting with admission control de-duplication, and
7014    /// with debugging.
7015    ///
7016    /// The node_ref must be obtained using GetNodeRef() of a
7017    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7018    ///
7019    /// The node_ref can be a duplicated handle; it's not necessary to call
7020    /// GetNodeRef() for every call to IsAlternateFor().
7021    ///
7022    /// If a calling token may not actually be a valid token at all due to
7023    /// a potentially hostile/untrusted provider of the token, call
7024    /// ValidateBufferCollectionToken() first instead of potentially getting
7025    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7026    /// token not being a real token (not really talking to sysmem).  Another
7027    /// option is to call BindSharedCollection with this token first which also
7028    /// validates the token along with converting it to a BufferCollection, then
7029    /// call BufferCollection IsAlternateFor().
7030    ///
7031    /// error values:
7032    ///
7033    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7034    /// buffer collection as the calling Node.  Before logical allocation and
7035    /// within the same logical allocation sub-tree, this essentially means that
7036    /// the node_ref was never part of this logical buffer collection, since
7037    /// before logical allocation all node_refs that come into existence remain
7038    /// in existence at least until logical allocation (including Node(s) that
7039    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7040    /// to be returned, this Node's channel needs to still be connected server
7041    /// side, which won't be the case if the whole logical allocation has
7042    /// failed.  After logical allocation or in a different logical allocation
7043    /// sub-tree there are additional potential reasons for this error.  For
7044    /// example a different logical allocation (separated from this Node(s)
7045    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7046    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7047    /// exist and may select a different child sub-tree than the sub-tree the
7048    /// node_ref is in causing deletion of the node_ref Node.  The only time
7049    /// sysmem keeps a Node around after that Node has no corresponding channel
7050    /// is when Close() is used and the Node's sub-tree has not yet failed.
7051    /// Another reason for this error is if the node_ref is an eventpair handle
7052    /// with sufficient rights, but isn't actually a real node_ref obtained from
7053    /// GetNodeRef().
7054    ///
7055    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7056    /// eventpair handle, or doesn't have the needed rights expected on a real
7057    /// node_ref.
7058    ///
7059    /// No other failing status codes are returned by this call.  However,
7060    /// sysmem may add additional codes in future, so the client should have
7061    /// sensible default handling for any failing status code.
7062    ///
7063    /// On success, is_alternate has the following meaning:
7064    ///   * true - The first parent node in common between the calling node and
7065    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7066    ///     the calling Node and the node_ref Node will _not_ have both their
7067    ///     constraints apply - rather sysmem will choose one or the other of
7068    ///     the constraints - never both.  This is because only one child of
7069    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7070    ///     with only that one child's sub-tree contributing to constraints
7071    ///     aggregation.
7072    ///   * false - The first parent node in common between the calling Node and
7073    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7074    ///     this means the first parent node in common is a
7075    ///     BufferCollectionToken or BufferCollection (regardless of not
7076    ///     Close()ed or Close()ed).  This means that the calling Node and the
7077    ///     node_ref Node _may_ have both their constraints apply during
7078    ///     constraints aggregation of the logical allocation, if both Node(s)
7079    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7080    ///     In this case, there is no BufferCollectionTokenGroup that will
7081    ///     directly prevent the two Node(s) from both being selected and their
7082    ///     constraints both aggregated, but even when false, one or both
7083    ///     Node(s) may still be eliminated from consideration if one or both
7084    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7085    ///     which selects a child sub-tree other than the sub-tree containing
7086    ///     the calling Node or node_ref Node.
7087    pub fn r#is_alternate_for(
7088        &self,
7089        mut node_ref: fidl::Event,
7090        ___deadline: zx::MonotonicInstant,
7091    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7092        let _response = self.client.send_query::<
7093            NodeIsAlternateForRequest,
7094            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7095        >(
7096            (node_ref,),
7097            0x33a2a7aff2776c07,
7098            fidl::encoding::DynamicFlags::empty(),
7099            ___deadline,
7100        )?;
7101        Ok(_response.map(|x| x.is_alternate))
7102    }
7103
7104    /// Create a child token.  Before passing the client end of this token to
7105    /// BindSharedCollection(), completion of Sync() after CreateChild() is
7106    /// required.  Or the client can use CreateChildrenSync() which essentially
7107    /// includes the Sync().
7108    ///
7109    /// token_request - the server end of the new token channel.
7110    ///
7111    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
7112    /// allows the holder to get the same rights to buffers as the parent token
7113    /// (of the group) had.
7114    pub fn r#create_child(
7115        &self,
7116        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7117    ) -> Result<(), fidl::Error> {
7118        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7119            &mut payload,
7120            0x2e74f8bcbf59ee59,
7121            fidl::encoding::DynamicFlags::empty(),
7122        )
7123    }
7124
7125    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7126    /// CreateChild(), no Sync() completion is required before passing the
7127    /// client end of a returned token to BindSharedCollection().
7128    ///
7129    /// The size of the rights_attentuation_mask determines the number of
7130    /// created child tokens.
7131    ///
7132    /// The lower-index child tokens are higher priority (attempted sooner) than
7133    /// higher-index child tokens.
7134    ///
7135    /// As per all child tokens, successful aggregation will choose exactly one
7136    /// child among all created children (across all children created across
7137    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
7138    ///
7139    /// The maximum permissible total number of children per group, and total
7140    /// number of nodes in an overall tree (from the root) are capped to limits
7141    /// which are not configurable via these protocols.
7142    pub fn r#create_children_sync(
7143        &self,
7144        mut rights_attenuation_masks: &[fidl::Rights],
7145        ___deadline: zx::MonotonicInstant,
7146    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
7147        let _response = self.client.send_query::<
7148            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7149            BufferCollectionTokenGroupCreateChildrenSyncResponse,
7150        >(
7151            (rights_attenuation_masks,),
7152            0x569dc3ca2a98f535,
7153            fidl::encoding::DynamicFlags::empty(),
7154            ___deadline,
7155        )?;
7156        Ok(_response.tokens)
7157    }
7158
7159    /// AllChildrenPresent()
7160    ///
7161    /// After creating all children, the client must call AllChildrenPresent()
7162    /// to inform sysmem that no more children will be created, so that sysmem
7163    /// can know when it's ok to start aggregating constraints.
7164    ///
7165    /// If Close() is to be sent, it should be sent _after_
7166    /// AllChildrenPresent(), else failure of the group and propagation of the
7167    /// failure to the group's parent will still be triggered.
7168    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7169        self.client.send::<fidl::encoding::EmptyPayload>(
7170            (),
7171            0x1d41715f6f044b50,
7172            fidl::encoding::DynamicFlags::empty(),
7173        )
7174    }
7175}
7176
7177#[cfg(target_os = "fuchsia")]
7178impl From<BufferCollectionTokenGroupSynchronousProxy> for zx::Handle {
7179    fn from(value: BufferCollectionTokenGroupSynchronousProxy) -> Self {
7180        value.into_channel().into()
7181    }
7182}
7183
7184#[cfg(target_os = "fuchsia")]
7185impl From<fidl::Channel> for BufferCollectionTokenGroupSynchronousProxy {
7186    fn from(value: fidl::Channel) -> Self {
7187        Self::new(value)
7188    }
7189}
7190
7191#[cfg(target_os = "fuchsia")]
7192impl fidl::endpoints::FromClient for BufferCollectionTokenGroupSynchronousProxy {
7193    type Protocol = BufferCollectionTokenGroupMarker;
7194
7195    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionTokenGroupMarker>) -> Self {
7196        Self::new(value.into_channel())
7197    }
7198}
7199
7200#[derive(Debug, Clone)]
7201pub struct BufferCollectionTokenGroupProxy {
7202    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7203}
7204
7205impl fidl::endpoints::Proxy for BufferCollectionTokenGroupProxy {
7206    type Protocol = BufferCollectionTokenGroupMarker;
7207
7208    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7209        Self::new(inner)
7210    }
7211
7212    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7213        self.client.into_channel().map_err(|client| Self { client })
7214    }
7215
7216    fn as_channel(&self) -> &::fidl::AsyncChannel {
7217        self.client.as_channel()
7218    }
7219}
7220
7221impl BufferCollectionTokenGroupProxy {
7222    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionTokenGroup.
7223    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7224        let protocol_name =
7225            <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7226        Self { client: fidl::client::Client::new(channel, protocol_name) }
7227    }
7228
7229    /// Get a Stream of events from the remote end of the protocol.
7230    ///
7231    /// # Panics
7232    ///
7233    /// Panics if the event stream was already taken.
7234    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7235        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7236    }
7237
7238    /// Ensure that previous messages, including Duplicate() messages on a
7239    /// token, collection, or group, have been received server side.
7240    ///
7241    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7242    /// valid sysmem token risks the Sync() hanging forever.  See
7243    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7244    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7245    /// Another way is to pass the token to BindSharedCollection(), which also
7246    /// validates the token as part of exchanging it for a BufferCollection
7247    /// channel, and BufferCollection Sync() can then be used.
7248    ///
7249    /// After a Sync(), it's then safe to send the client end of token_request
7250    /// to another participant knowing the server will recognize the token when
7251    /// it's sent into BindSharedCollection() by the other participant.
7252    ///
7253    /// Other options include waiting for each token.Duplicate() to complete
7254    /// individually (using separate call to token.Sync() after each), or
7255    /// calling Sync() on BufferCollection after the token has been turned in
7256    /// via BindSharedCollection().
7257    ///
7258    /// Another way to mitigate is to avoid calling Sync() on the token, and
7259    /// instead later deal with potential failure of BufferCollection.Sync() if
7260    /// the original token was invalid.  This option can be preferable from a
7261    /// performance point of view, but requires client code to delay sending
7262    /// tokens duplicated from this token until after client code has converted
7263    /// the duplicating token to a BufferCollection and received successful
7264    /// response from BufferCollection.Sync().
7265    ///
7266    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7267    /// When BufferCollection.Sync() isn't feasible, the caller must already
7268    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7269    /// hang forever.  See ValidateBufferCollectionToken() to check token
7270    /// validity first if the token isn't already known to be (is/was) valid.
7271    pub fn r#sync(
7272        &self,
7273    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7274        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7275    }
7276
7277    /// On a BufferCollectionToken channel:
7278    ///
7279    /// Normally a participant will convert a BufferCollectionToken into a
7280    /// BufferCollection view, but a participant is also free to Close() the
7281    /// token (and then close the channel immediately or shortly later in
7282    /// response to server closing its end), which avoids causing logical buffer
7283    /// collection failure.  Normally an unexpected token channel close will
7284    /// cause logical buffer collection failure (the only exceptions being
7285    /// certain cases involving AttachToken() or SetDispensable()).
7286    ///
7287    /// On a BufferCollection channel:
7288    ///
7289    /// By default the server handles unexpected failure of a BufferCollection
7290    /// by failing the whole logical buffer collection.  Partly this is to
7291    /// expedite closing VMO handles to reclaim memory when any participant
7292    /// fails.  If a participant would like to cleanly close a BufferCollection
7293    /// view without causing logical buffer collection failure, the participant
7294    /// can send Close() before closing the client end of the BufferCollection
7295    /// channel.  If this is the last BufferCollection view, the logical buffer
7296    /// collection will still go away.  The Close() can occur before or after
7297    /// SetConstraints().  If before SetConstraints(), the buffer collection
7298    /// won't require constraints from this node in order to allocate.  If
7299    /// after SetConstraints(), the constraints are retained and aggregated
7300    /// along with any subsequent logical allocation(s), despite the lack of
7301    /// channel connection.
7302    ///
7303    /// On a BufferCollectionTokenGroup channel:
7304    ///
7305    /// By default, unexpected failure of a BufferCollectionTokenGroup will
7306    /// trigger failure of the logical BufferCollectionTokenGroup and will
7307    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
7308    /// channel without failing the logical group or propagating failure, send
7309    /// Close() before closing the channel client endpoint.
7310    ///
7311    /// If Close() occurs before AllChildrenPresent(), the logical buffer
7312    /// collection will still fail despite the Close() (because sysmem can't be
7313    /// sure whether all relevant children were created, so it's ambiguous
7314    /// whether all relevant constraints will be provided to sysmem).  If
7315    /// Close() occurs after AllChildrenPresent(), the children and all their
7316    /// constraints remain intact (just as they would if the
7317    /// BufferCollectionTokenGroup channel had remained open), and the close
7318    /// doesn't trigger or propagate failure.
7319    pub fn r#close(&self) -> Result<(), fidl::Error> {
7320        BufferCollectionTokenGroupProxyInterface::r#close(self)
7321    }
7322
7323    /// Set a name for VMOs in this buffer collection. The name may be truncated
7324    /// shorter. The name only affects VMOs allocated after it's set - this call
7325    /// does not rename existing VMOs. If multiple clients set different names
7326    /// then the larger priority value will win.
7327    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7328        BufferCollectionTokenGroupProxyInterface::r#set_name(self, priority, name)
7329    }
7330
7331    /// Set information about the current client that can be used by sysmem to
7332    /// help debug leaking memory and hangs waiting for constraints. |name| can
7333    /// be an arbitrary string, but the current process name (see
7334    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7335    /// arbitrary id, but the current process ID (see
7336    /// fsl::GetCurrentProcessKoid()) is a good default.
7337    ///
7338    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7339    /// indicate which client is closing their channel first, leading to
7340    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7341    /// over, but if happening earlier than expected, the
7342    /// client-channel-specific name can help diagnose where the failure is
7343    /// first coming from, from sysmem's point of view).
7344    ///
7345    /// By default (unless overriden by this message or using
7346    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7347    /// parent Node at the time the child Node is created.  While this can be
7348    /// better than nothing, it's often better for each participant to use
7349    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7350    /// info directly relevant to the current client.  Also, SetVerboseLogging()
7351    /// can be used to help disambiguate if a Node is suspected of having info
7352    /// that was copied from its parent.
7353    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7354        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, name, id)
7355    }
7356
7357    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7358    /// after creating a collection. Clients can call this method to change
7359    /// when the log is printed. If multiple client set the deadline, it's
7360    /// unspecified which deadline will take effect.
7361    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7362        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
7363    }
7364
7365    /// Verbose logging includes constraints set via SetConstraints() from each
7366    /// client along with info set via SetDebugClientInfo() and the structure of
7367    /// the tree of Node(s).
7368    ///
7369    /// Normally sysmem prints only a single line complaint when aggregation
7370    /// fails, with just the specific detailed reason that aggregation failed,
7371    /// with minimal context.  While this is often enough to diagnose a problem
7372    /// if only a small change was made and the system had been working before
7373    /// the small change, it's often not particularly helpful for getting a new
7374    /// buffer collection to work for the first time.  Especially with more
7375    /// complex trees of nodes, involving things like AttachToken(),
7376    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7377    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7378    /// looks like and why it's failing a logical allocation, or why a tree or
7379    /// sub-tree is failing sooner than expected.
7380    ///
7381    /// The intent of the extra logging is to be acceptable from a performance
7382    /// point of view, if only enabled on a low number of buffer collections.
7383    /// If we're not tracking down a bug, we shouldn't send this message.
7384    ///
7385    /// If too many participants leave verbose logging enabled, we may end up
7386    /// needing to require that system-wide sysmem verbose logging be permitted
7387    /// via some other setting, to avoid sysmem spamming the log too much due to
7388    /// this message.
7389    ///
7390    /// This may be a NOP for some nodes due to intentional policy associated
7391    /// with the node, if we don't trust a node enough to let it turn on verbose
7392    /// logging.
7393    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7394        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7395    }
7396
7397    /// This gets an event handle that can be used as a parameter to
7398    /// IsAlternateFor() called on any Node.  The client will not be granted the
7399    /// right to signal this event, as this handle should only be used as proof
7400    /// that the client obtained this handle from this Node.
7401    ///
7402    /// Because this is a get not a set, no Sync() is needed between the
7403    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7404    /// potentially being on different channels.
7405    ///
7406    /// See also IsAlternateFor().
7407    pub fn r#get_node_ref(
7408        &self,
7409    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
7410    {
7411        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7412    }
7413
7414    /// This checks whether the calling node is in a subtree rooted at a
7415    /// different child token of a common parent BufferCollectionTokenGroup, in
7416    /// relation to the passed-in node_ref.
7417    ///
7418    /// This call is for assisting with admission control de-duplication, and
7419    /// with debugging.
7420    ///
7421    /// The node_ref must be obtained using GetNodeRef() of a
7422    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7423    ///
7424    /// The node_ref can be a duplicated handle; it's not necessary to call
7425    /// GetNodeRef() for every call to IsAlternateFor().
7426    ///
7427    /// If a calling token may not actually be a valid token at all due to
7428    /// a potentially hostile/untrusted provider of the token, call
7429    /// ValidateBufferCollectionToken() first instead of potentially getting
7430    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7431    /// token not being a real token (not really talking to sysmem).  Another
7432    /// option is to call BindSharedCollection with this token first which also
7433    /// validates the token along with converting it to a BufferCollection, then
7434    /// call BufferCollection IsAlternateFor().
7435    ///
7436    /// error values:
7437    ///
7438    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7439    /// buffer collection as the calling Node.  Before logical allocation and
7440    /// within the same logical allocation sub-tree, this essentially means that
7441    /// the node_ref was never part of this logical buffer collection, since
7442    /// before logical allocation all node_refs that come into existence remain
7443    /// in existence at least until logical allocation (including Node(s) that
7444    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7445    /// to be returned, this Node's channel needs to still be connected server
7446    /// side, which won't be the case if the whole logical allocation has
7447    /// failed.  After logical allocation or in a different logical allocation
7448    /// sub-tree there are additional potential reasons for this error.  For
7449    /// example a different logical allocation (separated from this Node(s)
7450    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7451    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7452    /// exist and may select a different child sub-tree than the sub-tree the
7453    /// node_ref is in causing deletion of the node_ref Node.  The only time
7454    /// sysmem keeps a Node around after that Node has no corresponding channel
7455    /// is when Close() is used and the Node's sub-tree has not yet failed.
7456    /// Another reason for this error is if the node_ref is an eventpair handle
7457    /// with sufficient rights, but isn't actually a real node_ref obtained from
7458    /// GetNodeRef().
7459    ///
7460    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7461    /// eventpair handle, or doesn't have the needed rights expected on a real
7462    /// node_ref.
7463    ///
7464    /// No other failing status codes are returned by this call.  However,
7465    /// sysmem may add additional codes in future, so the client should have
7466    /// sensible default handling for any failing status code.
7467    ///
7468    /// On success, is_alternate has the following meaning:
7469    ///   * true - The first parent node in common between the calling node and
7470    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7471    ///     the calling Node and the node_ref Node will _not_ have both their
7472    ///     constraints apply - rather sysmem will choose one or the other of
7473    ///     the constraints - never both.  This is because only one child of
7474    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7475    ///     with only that one child's sub-tree contributing to constraints
7476    ///     aggregation.
7477    ///   * false - The first parent node in common between the calling Node and
7478    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7479    ///     this means the first parent node in common is a
7480    ///     BufferCollectionToken or BufferCollection (regardless of not
7481    ///     Close()ed or Close()ed).  This means that the calling Node and the
7482    ///     node_ref Node _may_ have both their constraints apply during
7483    ///     constraints aggregation of the logical allocation, if both Node(s)
7484    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7485    ///     In this case, there is no BufferCollectionTokenGroup that will
7486    ///     directly prevent the two Node(s) from both being selected and their
7487    ///     constraints both aggregated, but even when false, one or both
7488    ///     Node(s) may still be eliminated from consideration if one or both
7489    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7490    ///     which selects a child sub-tree other than the sub-tree containing
7491    ///     the calling Node or node_ref Node.
7492    pub fn r#is_alternate_for(
7493        &self,
7494        mut node_ref: fidl::Event,
7495    ) -> fidl::client::QueryResponseFut<
7496        NodeIsAlternateForResult,
7497        fidl::encoding::DefaultFuchsiaResourceDialect,
7498    > {
7499        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, node_ref)
7500    }
7501
7502    /// Create a child token.  Before passing the client end of this token to
7503    /// BindSharedCollection(), completion of Sync() after CreateChild() is
7504    /// required.  Or the client can use CreateChildrenSync() which essentially
7505    /// includes the Sync().
7506    ///
7507    /// token_request - the server end of the new token channel.
7508    ///
7509    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
7510    /// allows the holder to get the same rights to buffers as the parent token
7511    /// (of the group) had.
7512    pub fn r#create_child(
7513        &self,
7514        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7515    ) -> Result<(), fidl::Error> {
7516        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7517    }
7518
7519    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7520    /// CreateChild(), no Sync() completion is required before passing the
7521    /// client end of a returned token to BindSharedCollection().
7522    ///
7523    /// The size of the rights_attentuation_mask determines the number of
7524    /// created child tokens.
7525    ///
7526    /// The lower-index child tokens are higher priority (attempted sooner) than
7527    /// higher-index child tokens.
7528    ///
7529    /// As per all child tokens, successful aggregation will choose exactly one
7530    /// child among all created children (across all children created across
7531    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
7532    ///
7533    /// The maximum permissible total number of children per group, and total
7534    /// number of nodes in an overall tree (from the root) are capped to limits
7535    /// which are not configurable via these protocols.
7536    pub fn r#create_children_sync(
7537        &self,
7538        mut rights_attenuation_masks: &[fidl::Rights],
7539    ) -> fidl::client::QueryResponseFut<
7540        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7541        fidl::encoding::DefaultFuchsiaResourceDialect,
7542    > {
7543        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(
7544            self,
7545            rights_attenuation_masks,
7546        )
7547    }
7548
7549    /// AllChildrenPresent()
7550    ///
7551    /// After creating all children, the client must call AllChildrenPresent()
7552    /// to inform sysmem that no more children will be created, so that sysmem
7553    /// can know when it's ok to start aggregating constraints.
7554    ///
7555    /// If Close() is to be sent, it should be sent _after_
7556    /// AllChildrenPresent(), else failure of the group and propagation of the
7557    /// failure to the group's parent will still be triggered.
7558    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7559        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7560    }
7561}
7562
7563impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7564    type SyncResponseFut =
7565        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7566    fn r#sync(&self) -> Self::SyncResponseFut {
7567        fn _decode(
7568            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7569        ) -> Result<(), fidl::Error> {
7570            let _response = fidl::client::decode_transaction_body::<
7571                fidl::encoding::EmptyPayload,
7572                fidl::encoding::DefaultFuchsiaResourceDialect,
7573                0x4577e238ae26291,
7574            >(_buf?)?;
7575            Ok(_response)
7576        }
7577        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7578            (),
7579            0x4577e238ae26291,
7580            fidl::encoding::DynamicFlags::empty(),
7581            _decode,
7582        )
7583    }
7584
7585    fn r#close(&self) -> Result<(), fidl::Error> {
7586        self.client.send::<fidl::encoding::EmptyPayload>(
7587            (),
7588            0x5b1d7a4f5681fca7,
7589            fidl::encoding::DynamicFlags::empty(),
7590        )
7591    }
7592
7593    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7594        self.client.send::<NodeSetNameRequest>(
7595            (priority, name),
7596            0x77a41bb6217e2443,
7597            fidl::encoding::DynamicFlags::empty(),
7598        )
7599    }
7600
7601    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7602        self.client.send::<NodeSetDebugClientInfoRequest>(
7603            (name, id),
7604            0x7275759070eb5ee2,
7605            fidl::encoding::DynamicFlags::empty(),
7606        )
7607    }
7608
7609    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7610        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7611            (deadline,),
7612            0x46d38f4772638867,
7613            fidl::encoding::DynamicFlags::empty(),
7614        )
7615    }
7616
7617    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7618        self.client.send::<fidl::encoding::EmptyPayload>(
7619            (),
7620            0x6bfbe2cf1701d288,
7621            fidl::encoding::DynamicFlags::empty(),
7622        )
7623    }
7624
7625    type GetNodeRefResponseFut =
7626        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
7627    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7628        fn _decode(
7629            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7630        ) -> Result<fidl::Event, fidl::Error> {
7631            let _response = fidl::client::decode_transaction_body::<
7632                NodeGetNodeRefResponse,
7633                fidl::encoding::DefaultFuchsiaResourceDialect,
7634                0x467b7c75c35c3b84,
7635            >(_buf?)?;
7636            Ok(_response.node_ref)
7637        }
7638        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
7639            (),
7640            0x467b7c75c35c3b84,
7641            fidl::encoding::DynamicFlags::empty(),
7642            _decode,
7643        )
7644    }
7645
7646    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7647        NodeIsAlternateForResult,
7648        fidl::encoding::DefaultFuchsiaResourceDialect,
7649    >;
7650    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
7651        fn _decode(
7652            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7653        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7654            let _response = fidl::client::decode_transaction_body::<
7655                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7656                fidl::encoding::DefaultFuchsiaResourceDialect,
7657                0x33a2a7aff2776c07,
7658            >(_buf?)?;
7659            Ok(_response.map(|x| x.is_alternate))
7660        }
7661        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7662            (node_ref,),
7663            0x33a2a7aff2776c07,
7664            fidl::encoding::DynamicFlags::empty(),
7665            _decode,
7666        )
7667    }
7668
7669    fn r#create_child(
7670        &self,
7671        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7672    ) -> Result<(), fidl::Error> {
7673        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7674            &mut payload,
7675            0x2e74f8bcbf59ee59,
7676            fidl::encoding::DynamicFlags::empty(),
7677        )
7678    }
7679
7680    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
7681        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7682        fidl::encoding::DefaultFuchsiaResourceDialect,
7683    >;
7684    fn r#create_children_sync(
7685        &self,
7686        mut rights_attenuation_masks: &[fidl::Rights],
7687    ) -> Self::CreateChildrenSyncResponseFut {
7688        fn _decode(
7689            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7690        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
7691        {
7692            let _response = fidl::client::decode_transaction_body::<
7693                BufferCollectionTokenGroupCreateChildrenSyncResponse,
7694                fidl::encoding::DefaultFuchsiaResourceDialect,
7695                0x569dc3ca2a98f535,
7696            >(_buf?)?;
7697            Ok(_response.tokens)
7698        }
7699        self.client.send_query_and_decode::<
7700            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7701            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7702        >(
7703            (rights_attenuation_masks,),
7704            0x569dc3ca2a98f535,
7705            fidl::encoding::DynamicFlags::empty(),
7706            _decode,
7707        )
7708    }
7709
7710    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7711        self.client.send::<fidl::encoding::EmptyPayload>(
7712            (),
7713            0x1d41715f6f044b50,
7714            fidl::encoding::DynamicFlags::empty(),
7715        )
7716    }
7717}
7718
7719pub struct BufferCollectionTokenGroupEventStream {
7720    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7721}
7722
7723impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
7724
7725impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
7726    fn is_terminated(&self) -> bool {
7727        self.event_receiver.is_terminated()
7728    }
7729}
7730
7731impl futures::Stream for BufferCollectionTokenGroupEventStream {
7732    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
7733
7734    fn poll_next(
7735        mut self: std::pin::Pin<&mut Self>,
7736        cx: &mut std::task::Context<'_>,
7737    ) -> std::task::Poll<Option<Self::Item>> {
7738        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7739            &mut self.event_receiver,
7740            cx
7741        )?) {
7742            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
7743            None => std::task::Poll::Ready(None),
7744        }
7745    }
7746}
7747
7748#[derive(Debug)]
7749pub enum BufferCollectionTokenGroupEvent {}
7750
7751impl BufferCollectionTokenGroupEvent {
7752    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
7753    fn decode(
7754        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7755    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
7756        let (bytes, _handles) = buf.split_mut();
7757        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7758        debug_assert_eq!(tx_header.tx_id, 0);
7759        match tx_header.ordinal {
7760            _ => Err(fidl::Error::UnknownOrdinal {
7761                ordinal: tx_header.ordinal,
7762                protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7763            })
7764        }
7765    }
7766}
7767
7768/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionTokenGroup.
7769pub struct BufferCollectionTokenGroupRequestStream {
7770    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7771    is_terminated: bool,
7772}
7773
7774impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
7775
7776impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
7777    fn is_terminated(&self) -> bool {
7778        self.is_terminated
7779    }
7780}
7781
7782impl fidl::endpoints::RequestStream for BufferCollectionTokenGroupRequestStream {
7783    type Protocol = BufferCollectionTokenGroupMarker;
7784    type ControlHandle = BufferCollectionTokenGroupControlHandle;
7785
7786    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7787        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7788    }
7789
7790    fn control_handle(&self) -> Self::ControlHandle {
7791        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
7792    }
7793
7794    fn into_inner(
7795        self,
7796    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7797    {
7798        (self.inner, self.is_terminated)
7799    }
7800
7801    fn from_inner(
7802        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7803        is_terminated: bool,
7804    ) -> Self {
7805        Self { inner, is_terminated }
7806    }
7807}
7808
7809impl futures::Stream for BufferCollectionTokenGroupRequestStream {
7810    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
7811
7812    fn poll_next(
7813        mut self: std::pin::Pin<&mut Self>,
7814        cx: &mut std::task::Context<'_>,
7815    ) -> std::task::Poll<Option<Self::Item>> {
7816        let this = &mut *self;
7817        if this.inner.check_shutdown(cx) {
7818            this.is_terminated = true;
7819            return std::task::Poll::Ready(None);
7820        }
7821        if this.is_terminated {
7822            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
7823        }
7824        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7825            |bytes, handles| {
7826                match this.inner.channel().read_etc(cx, bytes, handles) {
7827                    std::task::Poll::Ready(Ok(())) => {}
7828                    std::task::Poll::Pending => return std::task::Poll::Pending,
7829                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7830                        this.is_terminated = true;
7831                        return std::task::Poll::Ready(None);
7832                    }
7833                    std::task::Poll::Ready(Err(e)) => {
7834                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7835                            e.into(),
7836                        ))))
7837                    }
7838                }
7839
7840                // A message has been received from the channel
7841                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7842
7843                std::task::Poll::Ready(Some(match header.ordinal {
7844                0x4577e238ae26291 => {
7845                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7846                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7847                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7848                    let control_handle = BufferCollectionTokenGroupControlHandle {
7849                        inner: this.inner.clone(),
7850                    };
7851                    Ok(BufferCollectionTokenGroupRequest::Sync {
7852                        responder: BufferCollectionTokenGroupSyncResponder {
7853                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7854                            tx_id: header.tx_id,
7855                        },
7856                    })
7857                }
7858                0x5b1d7a4f5681fca7 => {
7859                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7860                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7861                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7862                    let control_handle = BufferCollectionTokenGroupControlHandle {
7863                        inner: this.inner.clone(),
7864                    };
7865                    Ok(BufferCollectionTokenGroupRequest::Close {
7866                        control_handle,
7867                    })
7868                }
7869                0x77a41bb6217e2443 => {
7870                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7871                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7872                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
7873                    let control_handle = BufferCollectionTokenGroupControlHandle {
7874                        inner: this.inner.clone(),
7875                    };
7876                    Ok(BufferCollectionTokenGroupRequest::SetName {priority: req.priority,
7877name: req.name,
7878
7879                        control_handle,
7880                    })
7881                }
7882                0x7275759070eb5ee2 => {
7883                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7884                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7885                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
7886                    let control_handle = BufferCollectionTokenGroupControlHandle {
7887                        inner: this.inner.clone(),
7888                    };
7889                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {name: req.name,
7890id: req.id,
7891
7892                        control_handle,
7893                    })
7894                }
7895                0x46d38f4772638867 => {
7896                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7897                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7898                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
7899                    let control_handle = BufferCollectionTokenGroupControlHandle {
7900                        inner: this.inner.clone(),
7901                    };
7902                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
7903
7904                        control_handle,
7905                    })
7906                }
7907                0x6bfbe2cf1701d288 => {
7908                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7909                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7910                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7911                    let control_handle = BufferCollectionTokenGroupControlHandle {
7912                        inner: this.inner.clone(),
7913                    };
7914                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
7915                        control_handle,
7916                    })
7917                }
7918                0x467b7c75c35c3b84 => {
7919                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7920                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7921                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7922                    let control_handle = BufferCollectionTokenGroupControlHandle {
7923                        inner: this.inner.clone(),
7924                    };
7925                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
7926                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
7927                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7928                            tx_id: header.tx_id,
7929                        },
7930                    })
7931                }
7932                0x33a2a7aff2776c07 => {
7933                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7934                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7935                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
7936                    let control_handle = BufferCollectionTokenGroupControlHandle {
7937                        inner: this.inner.clone(),
7938                    };
7939                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {node_ref: req.node_ref,
7940
7941                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
7942                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7943                            tx_id: header.tx_id,
7944                        },
7945                    })
7946                }
7947                0x2e74f8bcbf59ee59 => {
7948                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7949                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7950                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
7951                    let control_handle = BufferCollectionTokenGroupControlHandle {
7952                        inner: this.inner.clone(),
7953                    };
7954                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
7955                        control_handle,
7956                    })
7957                }
7958                0x569dc3ca2a98f535 => {
7959                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7960                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7961                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
7962                    let control_handle = BufferCollectionTokenGroupControlHandle {
7963                        inner: this.inner.clone(),
7964                    };
7965                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {rights_attenuation_masks: req.rights_attenuation_masks,
7966
7967                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
7968                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7969                            tx_id: header.tx_id,
7970                        },
7971                    })
7972                }
7973                0x1d41715f6f044b50 => {
7974                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7975                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7976                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7977                    let control_handle = BufferCollectionTokenGroupControlHandle {
7978                        inner: this.inner.clone(),
7979                    };
7980                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
7981                        control_handle,
7982                    })
7983                }
7984                _ => Err(fidl::Error::UnknownOrdinal {
7985                    ordinal: header.ordinal,
7986                    protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7987                }),
7988            }))
7989            },
7990        )
7991    }
7992}
7993
7994/// The sysmem implementation is guaranteed to be consistent with a logical /
7995/// conceptual model as follows:
7996///
7997/// As usual, a logical allocation considers either the root and all nodes with
7998/// connectivity to the root that don't transit an AttachToken(), or a sub-tree
7999/// rooted at an AttachToken() token and all nodes with connectivity to that
8000/// subtree that don't transit another AttachToken().  This is called the
8001/// logical allocation pruned sub-tree, or pruned sub-tree for short.
8002///
8003/// During constraints aggregation, each BufferCollectionTokenGroup will select
8004/// a single child token among its children.  The rest of the children will
8005/// appear to fail the logical allocation, while the selected child may succeed.
8006///
8007/// When more than one BufferCollectionTokenGroup exists in the overall logical
8008/// allocation pruned sub-tree, the relative priority between two groups is
8009/// equivalent to their ordering in a DFS pre-order iteration of the tree, with
8010/// parents higher priority than children, and left children higher priority
8011/// than right children.
8012///
8013/// When a particular child of a group is selected (whether provisionally during
8014/// a constraints aggregation attempt, or as a final selection), the
8015/// non-selection of other children of the group can potentially "hide" other
8016/// groups under those non-selected children.
8017///
8018/// Within a logical allocation, aggregation is attempted first by provisionally
8019/// selecting the child 0 of the highest-priority group, and child 0 of the next
8020/// highest-priority group that isn't hidden by the provisional selections so
8021/// far, etc.
8022///
8023/// If that aggregation attempt fails, aggregation will be attempted with the
8024/// ordinal 0 child of all the same groups except the lowest priority non-hidden
8025/// group which will provisionally select its ordinal 1 child (and then child 2
8026/// and so on).  If a new lowest-priority group is un-hidden as provisional
8027/// selections are updated, that newly un-hidden lowest-priority group has all
8028/// its children considered in order, before changing the provisional selection
8029/// in the former lowest-priority group.  In terms of result, this is equivalent
8030/// to systematic enumeration of all possible combinations of choices in a
8031/// counting-like order updating the lowest-priority group the most often and
8032/// the highest-priority group the least often.  Rather than actually attempting
8033/// aggregation with all the combinations, we can skip over combinations which
8034/// are redundant/equivalent due to hiding without any change to the result.
8035///
8036/// Attempted aggregations of enumerated non-equivalent combinations of choices
8037/// continue in this manner until either (a) all aggregation attempts fail in
8038/// which case the overall logical allocation fails, or (b) until an attempted
8039/// aggregation succeeds, in which case buffer allocation (if needed) is
8040/// attempted once.  If buffer allocation based on the first successful
8041/// aggregation fails, the overall logical allocation fails (there is no buffer
8042/// allocation retry / re-attempt).  If buffer allocation succeeds (or is not
8043/// needed), the logical allocation succeeds.
8044///
8045/// If this prioritization scheme cannot reasonably work for your usage of
8046/// sysmem, please contact sysmem folks to discuss potentially adding a way to
8047/// achieve what you need.
8048///
8049/// Please avoid creating a large number of BufferCollectionTokenGroup(s) per
8050/// logical allocation, especially with large number of children overall, and
8051/// especially in cases where aggregation may reasonably be expected to often
8052/// fail using ordinal 0 children and possibly with later children as well.  We
8053/// anticipate mitigating potentially high time complexity of evaluating too
8054/// many child combinations/selections across too many groups by simply failing
8055/// logical allocation beyond a certain (fairly high, but not huge) max number
8056/// of considered group child combinations/selections.  More advanced (and more
8057/// complicated) mitigation is not anticipated to be practically necessary or
8058/// worth the added complexity.  Please contact sysmem folks if the max limit
8059/// is getting hit or if you anticipate it getting hit, to discuss potential
8060/// options.
8061///
8062/// Prefer to use multiple ImageFormatConstraints in a single
8063/// BufferCollectionConstraints when feasible (when a participant just needs to
8064/// express the ability to work with more than a single PixelFormat, with
8065/// sysmem choosing which PixelFormat to use among those supported by all
8066/// participants).
8067///
8068/// Similar to BufferCollectionToken and BufferCollection, closure of the
8069/// BufferCollectionTokenGroup channel without sending Close() first will cause
8070/// logical buffer collection failure (or sub-tree failure if using
8071/// SetDispensable() or AttachToken() and the BufferCollectionTokenGroup is part
8072/// of a sub-tree under such a node that doesn't propagate failure to its
8073/// parent).
8074#[derive(Debug)]
8075pub enum BufferCollectionTokenGroupRequest {
8076    /// Ensure that previous messages, including Duplicate() messages on a
8077    /// token, collection, or group, have been received server side.
8078    ///
8079    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
8080    /// valid sysmem token risks the Sync() hanging forever.  See
8081    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
8082    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
8083    /// Another way is to pass the token to BindSharedCollection(), which also
8084    /// validates the token as part of exchanging it for a BufferCollection
8085    /// channel, and BufferCollection Sync() can then be used.
8086    ///
8087    /// After a Sync(), it's then safe to send the client end of token_request
8088    /// to another participant knowing the server will recognize the token when
8089    /// it's sent into BindSharedCollection() by the other participant.
8090    ///
8091    /// Other options include waiting for each token.Duplicate() to complete
8092    /// individually (using separate call to token.Sync() after each), or
8093    /// calling Sync() on BufferCollection after the token has been turned in
8094    /// via BindSharedCollection().
8095    ///
8096    /// Another way to mitigate is to avoid calling Sync() on the token, and
8097    /// instead later deal with potential failure of BufferCollection.Sync() if
8098    /// the original token was invalid.  This option can be preferable from a
8099    /// performance point of view, but requires client code to delay sending
8100    /// tokens duplicated from this token until after client code has converted
8101    /// the duplicating token to a BufferCollection and received successful
8102    /// response from BufferCollection.Sync().
8103    ///
8104    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
8105    /// When BufferCollection.Sync() isn't feasible, the caller must already
8106    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
8107    /// hang forever.  See ValidateBufferCollectionToken() to check token
8108    /// validity first if the token isn't already known to be (is/was) valid.
8109    Sync { responder: BufferCollectionTokenGroupSyncResponder },
8110    /// On a BufferCollectionToken channel:
8111    ///
8112    /// Normally a participant will convert a BufferCollectionToken into a
8113    /// BufferCollection view, but a participant is also free to Close() the
8114    /// token (and then close the channel immediately or shortly later in
8115    /// response to server closing its end), which avoids causing logical buffer
8116    /// collection failure.  Normally an unexpected token channel close will
8117    /// cause logical buffer collection failure (the only exceptions being
8118    /// certain cases involving AttachToken() or SetDispensable()).
8119    ///
8120    /// On a BufferCollection channel:
8121    ///
8122    /// By default the server handles unexpected failure of a BufferCollection
8123    /// by failing the whole logical buffer collection.  Partly this is to
8124    /// expedite closing VMO handles to reclaim memory when any participant
8125    /// fails.  If a participant would like to cleanly close a BufferCollection
8126    /// view without causing logical buffer collection failure, the participant
8127    /// can send Close() before closing the client end of the BufferCollection
8128    /// channel.  If this is the last BufferCollection view, the logical buffer
8129    /// collection will still go away.  The Close() can occur before or after
8130    /// SetConstraints().  If before SetConstraints(), the buffer collection
8131    /// won't require constraints from this node in order to allocate.  If
8132    /// after SetConstraints(), the constraints are retained and aggregated
8133    /// along with any subsequent logical allocation(s), despite the lack of
8134    /// channel connection.
8135    ///
8136    /// On a BufferCollectionTokenGroup channel:
8137    ///
8138    /// By default, unexpected failure of a BufferCollectionTokenGroup will
8139    /// trigger failure of the logical BufferCollectionTokenGroup and will
8140    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
8141    /// channel without failing the logical group or propagating failure, send
8142    /// Close() before closing the channel client endpoint.
8143    ///
8144    /// If Close() occurs before AllChildrenPresent(), the logical buffer
8145    /// collection will still fail despite the Close() (because sysmem can't be
8146    /// sure whether all relevant children were created, so it's ambiguous
8147    /// whether all relevant constraints will be provided to sysmem).  If
8148    /// Close() occurs after AllChildrenPresent(), the children and all their
8149    /// constraints remain intact (just as they would if the
8150    /// BufferCollectionTokenGroup channel had remained open), and the close
8151    /// doesn't trigger or propagate failure.
8152    Close { control_handle: BufferCollectionTokenGroupControlHandle },
8153    /// Set a name for VMOs in this buffer collection. The name may be truncated
8154    /// shorter. The name only affects VMOs allocated after it's set - this call
8155    /// does not rename existing VMOs. If multiple clients set different names
8156    /// then the larger priority value will win.
8157    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenGroupControlHandle },
8158    /// Set information about the current client that can be used by sysmem to
8159    /// help debug leaking memory and hangs waiting for constraints. |name| can
8160    /// be an arbitrary string, but the current process name (see
8161    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
8162    /// arbitrary id, but the current process ID (see
8163    /// fsl::GetCurrentProcessKoid()) is a good default.
8164    ///
8165    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
8166    /// indicate which client is closing their channel first, leading to
8167    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
8168    /// over, but if happening earlier than expected, the
8169    /// client-channel-specific name can help diagnose where the failure is
8170    /// first coming from, from sysmem's point of view).
8171    ///
8172    /// By default (unless overriden by this message or using
8173    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
8174    /// parent Node at the time the child Node is created.  While this can be
8175    /// better than nothing, it's often better for each participant to use
8176    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
8177    /// info directly relevant to the current client.  Also, SetVerboseLogging()
8178    /// can be used to help disambiguate if a Node is suspected of having info
8179    /// that was copied from its parent.
8180    SetDebugClientInfo {
8181        name: String,
8182        id: u64,
8183        control_handle: BufferCollectionTokenGroupControlHandle,
8184    },
8185    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
8186    /// after creating a collection. Clients can call this method to change
8187    /// when the log is printed. If multiple client set the deadline, it's
8188    /// unspecified which deadline will take effect.
8189    SetDebugTimeoutLogDeadline {
8190        deadline: i64,
8191        control_handle: BufferCollectionTokenGroupControlHandle,
8192    },
8193    /// Verbose logging includes constraints set via SetConstraints() from each
8194    /// client along with info set via SetDebugClientInfo() and the structure of
8195    /// the tree of Node(s).
8196    ///
8197    /// Normally sysmem prints only a single line complaint when aggregation
8198    /// fails, with just the specific detailed reason that aggregation failed,
8199    /// with minimal context.  While this is often enough to diagnose a problem
8200    /// if only a small change was made and the system had been working before
8201    /// the small change, it's often not particularly helpful for getting a new
8202    /// buffer collection to work for the first time.  Especially with more
8203    /// complex trees of nodes, involving things like AttachToken(),
8204    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
8205    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
8206    /// looks like and why it's failing a logical allocation, or why a tree or
8207    /// sub-tree is failing sooner than expected.
8208    ///
8209    /// The intent of the extra logging is to be acceptable from a performance
8210    /// point of view, if only enabled on a low number of buffer collections.
8211    /// If we're not tracking down a bug, we shouldn't send this message.
8212    ///
8213    /// If too many participants leave verbose logging enabled, we may end up
8214    /// needing to require that system-wide sysmem verbose logging be permitted
8215    /// via some other setting, to avoid sysmem spamming the log too much due to
8216    /// this message.
8217    ///
8218    /// This may be a NOP for some nodes due to intentional policy associated
8219    /// with the node, if we don't trust a node enough to let it turn on verbose
8220    /// logging.
8221    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
8222    /// This gets an event handle that can be used as a parameter to
8223    /// IsAlternateFor() called on any Node.  The client will not be granted the
8224    /// right to signal this event, as this handle should only be used as proof
8225    /// that the client obtained this handle from this Node.
8226    ///
8227    /// Because this is a get not a set, no Sync() is needed between the
8228    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
8229    /// potentially being on different channels.
8230    ///
8231    /// See also IsAlternateFor().
8232    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8233    /// This checks whether the calling node is in a subtree rooted at a
8234    /// different child token of a common parent BufferCollectionTokenGroup, in
8235    /// relation to the passed-in node_ref.
8236    ///
8237    /// This call is for assisting with admission control de-duplication, and
8238    /// with debugging.
8239    ///
8240    /// The node_ref must be obtained using GetNodeRef() of a
8241    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
8242    ///
8243    /// The node_ref can be a duplicated handle; it's not necessary to call
8244    /// GetNodeRef() for every call to IsAlternateFor().
8245    ///
8246    /// If a calling token may not actually be a valid token at all due to
8247    /// a potentially hostile/untrusted provider of the token, call
8248    /// ValidateBufferCollectionToken() first instead of potentially getting
8249    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
8250    /// token not being a real token (not really talking to sysmem).  Another
8251    /// option is to call BindSharedCollection with this token first which also
8252    /// validates the token along with converting it to a BufferCollection, then
8253    /// call BufferCollection IsAlternateFor().
8254    ///
8255    /// error values:
8256    ///
8257    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
8258    /// buffer collection as the calling Node.  Before logical allocation and
8259    /// within the same logical allocation sub-tree, this essentially means that
8260    /// the node_ref was never part of this logical buffer collection, since
8261    /// before logical allocation all node_refs that come into existence remain
8262    /// in existence at least until logical allocation (including Node(s) that
8263    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
8264    /// to be returned, this Node's channel needs to still be connected server
8265    /// side, which won't be the case if the whole logical allocation has
8266    /// failed.  After logical allocation or in a different logical allocation
8267    /// sub-tree there are additional potential reasons for this error.  For
8268    /// example a different logical allocation (separated from this Node(s)
8269    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
8270    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
8271    /// exist and may select a different child sub-tree than the sub-tree the
8272    /// node_ref is in causing deletion of the node_ref Node.  The only time
8273    /// sysmem keeps a Node around after that Node has no corresponding channel
8274    /// is when Close() is used and the Node's sub-tree has not yet failed.
8275    /// Another reason for this error is if the node_ref is an eventpair handle
8276    /// with sufficient rights, but isn't actually a real node_ref obtained from
8277    /// GetNodeRef().
8278    ///
8279    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
8280    /// eventpair handle, or doesn't have the needed rights expected on a real
8281    /// node_ref.
8282    ///
8283    /// No other failing status codes are returned by this call.  However,
8284    /// sysmem may add additional codes in future, so the client should have
8285    /// sensible default handling for any failing status code.
8286    ///
8287    /// On success, is_alternate has the following meaning:
8288    ///   * true - The first parent node in common between the calling node and
8289    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
8290    ///     the calling Node and the node_ref Node will _not_ have both their
8291    ///     constraints apply - rather sysmem will choose one or the other of
8292    ///     the constraints - never both.  This is because only one child of
8293    ///     a BufferCollectionTokenGroup is selected during logical allocation,
8294    ///     with only that one child's sub-tree contributing to constraints
8295    ///     aggregation.
8296    ///   * false - The first parent node in common between the calling Node and
8297    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
8298    ///     this means the first parent node in common is a
8299    ///     BufferCollectionToken or BufferCollection (regardless of not
8300    ///     Close()ed or Close()ed).  This means that the calling Node and the
8301    ///     node_ref Node _may_ have both their constraints apply during
8302    ///     constraints aggregation of the logical allocation, if both Node(s)
8303    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
8304    ///     In this case, there is no BufferCollectionTokenGroup that will
8305    ///     directly prevent the two Node(s) from both being selected and their
8306    ///     constraints both aggregated, but even when false, one or both
8307    ///     Node(s) may still be eliminated from consideration if one or both
8308    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
8309    ///     which selects a child sub-tree other than the sub-tree containing
8310    ///     the calling Node or node_ref Node.
8311    IsAlternateFor {
8312        node_ref: fidl::Event,
8313        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8314    },
8315    /// Create a child token.  Before passing the client end of this token to
8316    /// BindSharedCollection(), completion of Sync() after CreateChild() is
8317    /// required.  Or the client can use CreateChildrenSync() which essentially
8318    /// includes the Sync().
8319    ///
8320    /// token_request - the server end of the new token channel.
8321    ///
8322    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
8323    /// allows the holder to get the same rights to buffers as the parent token
8324    /// (of the group) had.
8325    CreateChild {
8326        payload: BufferCollectionTokenGroupCreateChildRequest,
8327        control_handle: BufferCollectionTokenGroupControlHandle,
8328    },
8329    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8330    /// CreateChild(), no Sync() completion is required before passing the
8331    /// client end of a returned token to BindSharedCollection().
8332    ///
8333    /// The size of the rights_attentuation_mask determines the number of
8334    /// created child tokens.
8335    ///
8336    /// The lower-index child tokens are higher priority (attempted sooner) than
8337    /// higher-index child tokens.
8338    ///
8339    /// As per all child tokens, successful aggregation will choose exactly one
8340    /// child among all created children (across all children created across
8341    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
8342    ///
8343    /// The maximum permissible total number of children per group, and total
8344    /// number of nodes in an overall tree (from the root) are capped to limits
8345    /// which are not configurable via these protocols.
8346    CreateChildrenSync {
8347        rights_attenuation_masks: Vec<fidl::Rights>,
8348        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
8349    },
8350    /// AllChildrenPresent()
8351    ///
8352    /// After creating all children, the client must call AllChildrenPresent()
8353    /// to inform sysmem that no more children will be created, so that sysmem
8354    /// can know when it's ok to start aggregating constraints.
8355    ///
8356    /// If Close() is to be sent, it should be sent _after_
8357    /// AllChildrenPresent(), else failure of the group and propagation of the
8358    /// failure to the group's parent will still be triggered.
8359    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
8360}
8361
8362impl BufferCollectionTokenGroupRequest {
8363    #[allow(irrefutable_let_patterns)]
8364    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
8365        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
8366            Some((responder))
8367        } else {
8368            None
8369        }
8370    }
8371
8372    #[allow(irrefutable_let_patterns)]
8373    pub fn into_close(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8374        if let BufferCollectionTokenGroupRequest::Close { control_handle } = self {
8375            Some((control_handle))
8376        } else {
8377            None
8378        }
8379    }
8380
8381    #[allow(irrefutable_let_patterns)]
8382    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenGroupControlHandle)> {
8383        if let BufferCollectionTokenGroupRequest::SetName { priority, name, control_handle } = self
8384        {
8385            Some((priority, name, control_handle))
8386        } else {
8387            None
8388        }
8389    }
8390
8391    #[allow(irrefutable_let_patterns)]
8392    pub fn into_set_debug_client_info(
8393        self,
8394    ) -> Option<(String, u64, BufferCollectionTokenGroupControlHandle)> {
8395        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { name, id, control_handle } =
8396            self
8397        {
8398            Some((name, id, control_handle))
8399        } else {
8400            None
8401        }
8402    }
8403
8404    #[allow(irrefutable_let_patterns)]
8405    pub fn into_set_debug_timeout_log_deadline(
8406        self,
8407    ) -> Option<(i64, BufferCollectionTokenGroupControlHandle)> {
8408        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
8409            deadline,
8410            control_handle,
8411        } = self
8412        {
8413            Some((deadline, control_handle))
8414        } else {
8415            None
8416        }
8417    }
8418
8419    #[allow(irrefutable_let_patterns)]
8420    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8421        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
8422            Some((control_handle))
8423        } else {
8424            None
8425        }
8426    }
8427
8428    #[allow(irrefutable_let_patterns)]
8429    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
8430        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
8431            Some((responder))
8432        } else {
8433            None
8434        }
8435    }
8436
8437    #[allow(irrefutable_let_patterns)]
8438    pub fn into_is_alternate_for(
8439        self,
8440    ) -> Option<(fidl::Event, BufferCollectionTokenGroupIsAlternateForResponder)> {
8441        if let BufferCollectionTokenGroupRequest::IsAlternateFor { node_ref, responder } = self {
8442            Some((node_ref, responder))
8443        } else {
8444            None
8445        }
8446    }
8447
8448    #[allow(irrefutable_let_patterns)]
8449    pub fn into_create_child(
8450        self,
8451    ) -> Option<(
8452        BufferCollectionTokenGroupCreateChildRequest,
8453        BufferCollectionTokenGroupControlHandle,
8454    )> {
8455        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
8456            Some((payload, control_handle))
8457        } else {
8458            None
8459        }
8460    }
8461
8462    #[allow(irrefutable_let_patterns)]
8463    pub fn into_create_children_sync(
8464        self,
8465    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenGroupCreateChildrenSyncResponder)> {
8466        if let BufferCollectionTokenGroupRequest::CreateChildrenSync {
8467            rights_attenuation_masks,
8468            responder,
8469        } = self
8470        {
8471            Some((rights_attenuation_masks, responder))
8472        } else {
8473            None
8474        }
8475    }
8476
8477    #[allow(irrefutable_let_patterns)]
8478    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8479        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
8480            Some((control_handle))
8481        } else {
8482            None
8483        }
8484    }
8485
8486    /// Name of the method defined in FIDL
8487    pub fn method_name(&self) -> &'static str {
8488        match *self {
8489            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
8490            BufferCollectionTokenGroupRequest::Close { .. } => "close",
8491            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
8492            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
8493            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
8494                "set_debug_timeout_log_deadline"
8495            }
8496            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
8497            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
8498            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
8499            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
8500            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
8501            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
8502        }
8503    }
8504}
8505
8506#[derive(Debug, Clone)]
8507pub struct BufferCollectionTokenGroupControlHandle {
8508    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8509}
8510
8511impl fidl::endpoints::ControlHandle for BufferCollectionTokenGroupControlHandle {
8512    fn shutdown(&self) {
8513        self.inner.shutdown()
8514    }
8515    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8516        self.inner.shutdown_with_epitaph(status)
8517    }
8518
8519    fn is_closed(&self) -> bool {
8520        self.inner.channel().is_closed()
8521    }
8522    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8523        self.inner.channel().on_closed()
8524    }
8525
8526    #[cfg(target_os = "fuchsia")]
8527    fn signal_peer(
8528        &self,
8529        clear_mask: zx::Signals,
8530        set_mask: zx::Signals,
8531    ) -> Result<(), zx_status::Status> {
8532        use fidl::Peered;
8533        self.inner.channel().signal_peer(clear_mask, set_mask)
8534    }
8535}
8536
8537impl BufferCollectionTokenGroupControlHandle {}
8538
8539#[must_use = "FIDL methods require a response to be sent"]
8540#[derive(Debug)]
8541pub struct BufferCollectionTokenGroupSyncResponder {
8542    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8543    tx_id: u32,
8544}
8545
8546/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8547/// if the responder is dropped without sending a response, so that the client
8548/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8549impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
8550    fn drop(&mut self) {
8551        self.control_handle.shutdown();
8552        // Safety: drops once, never accessed again
8553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8554    }
8555}
8556
8557impl fidl::endpoints::Responder for BufferCollectionTokenGroupSyncResponder {
8558    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8559
8560    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8561        &self.control_handle
8562    }
8563
8564    fn drop_without_shutdown(mut self) {
8565        // Safety: drops once, never accessed again due to mem::forget
8566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8567        // Prevent Drop from running (which would shut down the channel)
8568        std::mem::forget(self);
8569    }
8570}
8571
8572impl BufferCollectionTokenGroupSyncResponder {
8573    /// Sends a response to the FIDL transaction.
8574    ///
8575    /// Sets the channel to shutdown if an error occurs.
8576    pub fn send(self) -> Result<(), fidl::Error> {
8577        let _result = self.send_raw();
8578        if _result.is_err() {
8579            self.control_handle.shutdown();
8580        }
8581        self.drop_without_shutdown();
8582        _result
8583    }
8584
8585    /// Similar to "send" but does not shutdown the channel if an error occurs.
8586    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8587        let _result = self.send_raw();
8588        self.drop_without_shutdown();
8589        _result
8590    }
8591
8592    fn send_raw(&self) -> Result<(), fidl::Error> {
8593        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8594            (),
8595            self.tx_id,
8596            0x4577e238ae26291,
8597            fidl::encoding::DynamicFlags::empty(),
8598        )
8599    }
8600}
8601
8602#[must_use = "FIDL methods require a response to be sent"]
8603#[derive(Debug)]
8604pub struct BufferCollectionTokenGroupGetNodeRefResponder {
8605    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8606    tx_id: u32,
8607}
8608
8609/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8610/// if the responder is dropped without sending a response, so that the client
8611/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8612impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
8613    fn drop(&mut self) {
8614        self.control_handle.shutdown();
8615        // Safety: drops once, never accessed again
8616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8617    }
8618}
8619
8620impl fidl::endpoints::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
8621    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8622
8623    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8624        &self.control_handle
8625    }
8626
8627    fn drop_without_shutdown(mut self) {
8628        // Safety: drops once, never accessed again due to mem::forget
8629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8630        // Prevent Drop from running (which would shut down the channel)
8631        std::mem::forget(self);
8632    }
8633}
8634
8635impl BufferCollectionTokenGroupGetNodeRefResponder {
8636    /// Sends a response to the FIDL transaction.
8637    ///
8638    /// Sets the channel to shutdown if an error occurs.
8639    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8640        let _result = self.send_raw(node_ref);
8641        if _result.is_err() {
8642            self.control_handle.shutdown();
8643        }
8644        self.drop_without_shutdown();
8645        _result
8646    }
8647
8648    /// Similar to "send" but does not shutdown the channel if an error occurs.
8649    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8650        let _result = self.send_raw(node_ref);
8651        self.drop_without_shutdown();
8652        _result
8653    }
8654
8655    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8656        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
8657            (node_ref,),
8658            self.tx_id,
8659            0x467b7c75c35c3b84,
8660            fidl::encoding::DynamicFlags::empty(),
8661        )
8662    }
8663}
8664
8665#[must_use = "FIDL methods require a response to be sent"]
8666#[derive(Debug)]
8667pub struct BufferCollectionTokenGroupIsAlternateForResponder {
8668    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8669    tx_id: u32,
8670}
8671
8672/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8673/// if the responder is dropped without sending a response, so that the client
8674/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8675impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
8676    fn drop(&mut self) {
8677        self.control_handle.shutdown();
8678        // Safety: drops once, never accessed again
8679        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8680    }
8681}
8682
8683impl fidl::endpoints::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
8684    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8685
8686    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8687        &self.control_handle
8688    }
8689
8690    fn drop_without_shutdown(mut self) {
8691        // Safety: drops once, never accessed again due to mem::forget
8692        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8693        // Prevent Drop from running (which would shut down the channel)
8694        std::mem::forget(self);
8695    }
8696}
8697
8698impl BufferCollectionTokenGroupIsAlternateForResponder {
8699    /// Sends a response to the FIDL transaction.
8700    ///
8701    /// Sets the channel to shutdown if an error occurs.
8702    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8703        let _result = self.send_raw(result);
8704        if _result.is_err() {
8705            self.control_handle.shutdown();
8706        }
8707        self.drop_without_shutdown();
8708        _result
8709    }
8710
8711    /// Similar to "send" but does not shutdown the channel if an error occurs.
8712    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8713        let _result = self.send_raw(result);
8714        self.drop_without_shutdown();
8715        _result
8716    }
8717
8718    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8719        self.control_handle
8720            .inner
8721            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
8722                result.map(|is_alternate| (is_alternate,)),
8723                self.tx_id,
8724                0x33a2a7aff2776c07,
8725                fidl::encoding::DynamicFlags::empty(),
8726            )
8727    }
8728}
8729
8730#[must_use = "FIDL methods require a response to be sent"]
8731#[derive(Debug)]
8732pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
8733    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8734    tx_id: u32,
8735}
8736
8737/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8738/// if the responder is dropped without sending a response, so that the client
8739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8740impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8741    fn drop(&mut self) {
8742        self.control_handle.shutdown();
8743        // Safety: drops once, never accessed again
8744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8745    }
8746}
8747
8748impl fidl::endpoints::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8749    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8750
8751    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8752        &self.control_handle
8753    }
8754
8755    fn drop_without_shutdown(mut self) {
8756        // Safety: drops once, never accessed again due to mem::forget
8757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8758        // Prevent Drop from running (which would shut down the channel)
8759        std::mem::forget(self);
8760    }
8761}
8762
8763impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
8764    /// Sends a response to the FIDL transaction.
8765    ///
8766    /// Sets the channel to shutdown if an error occurs.
8767    pub fn send(
8768        self,
8769        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8770    ) -> Result<(), fidl::Error> {
8771        let _result = self.send_raw(tokens);
8772        if _result.is_err() {
8773            self.control_handle.shutdown();
8774        }
8775        self.drop_without_shutdown();
8776        _result
8777    }
8778
8779    /// Similar to "send" but does not shutdown the channel if an error occurs.
8780    pub fn send_no_shutdown_on_err(
8781        self,
8782        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8783    ) -> Result<(), fidl::Error> {
8784        let _result = self.send_raw(tokens);
8785        self.drop_without_shutdown();
8786        _result
8787    }
8788
8789    fn send_raw(
8790        &self,
8791        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8792    ) -> Result<(), fidl::Error> {
8793        self.control_handle.inner.send::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(
8794            (tokens.as_mut(),),
8795            self.tx_id,
8796            0x569dc3ca2a98f535,
8797            fidl::encoding::DynamicFlags::empty(),
8798        )
8799    }
8800}
8801
8802#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8803pub struct NodeMarker;
8804
8805impl fidl::endpoints::ProtocolMarker for NodeMarker {
8806    type Proxy = NodeProxy;
8807    type RequestStream = NodeRequestStream;
8808    #[cfg(target_os = "fuchsia")]
8809    type SynchronousProxy = NodeSynchronousProxy;
8810
8811    const DEBUG_NAME: &'static str = "(anonymous) Node";
8812}
8813pub type NodeIsAlternateForResult = Result<bool, i32>;
8814
8815pub trait NodeProxyInterface: Send + Sync {
8816    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8817    fn r#sync(&self) -> Self::SyncResponseFut;
8818    fn r#close(&self) -> Result<(), fidl::Error>;
8819    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
8820    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
8821    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
8822    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
8823    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
8824        + Send;
8825    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
8826    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
8827        + Send;
8828    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
8829}
8830#[derive(Debug)]
8831#[cfg(target_os = "fuchsia")]
8832pub struct NodeSynchronousProxy {
8833    client: fidl::client::sync::Client,
8834}
8835
8836#[cfg(target_os = "fuchsia")]
8837impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
8838    type Proxy = NodeProxy;
8839    type Protocol = NodeMarker;
8840
8841    fn from_channel(inner: fidl::Channel) -> Self {
8842        Self::new(inner)
8843    }
8844
8845    fn into_channel(self) -> fidl::Channel {
8846        self.client.into_channel()
8847    }
8848
8849    fn as_channel(&self) -> &fidl::Channel {
8850        self.client.as_channel()
8851    }
8852}
8853
8854#[cfg(target_os = "fuchsia")]
8855impl NodeSynchronousProxy {
8856    pub fn new(channel: fidl::Channel) -> Self {
8857        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8858        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8859    }
8860
8861    pub fn into_channel(self) -> fidl::Channel {
8862        self.client.into_channel()
8863    }
8864
8865    /// Waits until an event arrives and returns it. It is safe for other
8866    /// threads to make concurrent requests while waiting for an event.
8867    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
8868        NodeEvent::decode(self.client.wait_for_event(deadline)?)
8869    }
8870
8871    /// Ensure that previous messages, including Duplicate() messages on a
8872    /// token, collection, or group, have been received server side.
8873    ///
8874    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
8875    /// valid sysmem token risks the Sync() hanging forever.  See
8876    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
8877    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
8878    /// Another way is to pass the token to BindSharedCollection(), which also
8879    /// validates the token as part of exchanging it for a BufferCollection
8880    /// channel, and BufferCollection Sync() can then be used.
8881    ///
8882    /// After a Sync(), it's then safe to send the client end of token_request
8883    /// to another participant knowing the server will recognize the token when
8884    /// it's sent into BindSharedCollection() by the other participant.
8885    ///
8886    /// Other options include waiting for each token.Duplicate() to complete
8887    /// individually (using separate call to token.Sync() after each), or
8888    /// calling Sync() on BufferCollection after the token has been turned in
8889    /// via BindSharedCollection().
8890    ///
8891    /// Another way to mitigate is to avoid calling Sync() on the token, and
8892    /// instead later deal with potential failure of BufferCollection.Sync() if
8893    /// the original token was invalid.  This option can be preferable from a
8894    /// performance point of view, but requires client code to delay sending
8895    /// tokens duplicated from this token until after client code has converted
8896    /// the duplicating token to a BufferCollection and received successful
8897    /// response from BufferCollection.Sync().
8898    ///
8899    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
8900    /// When BufferCollection.Sync() isn't feasible, the caller must already
8901    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
8902    /// hang forever.  See ValidateBufferCollectionToken() to check token
8903    /// validity first if the token isn't already known to be (is/was) valid.
8904    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8905        let _response =
8906            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8907                (),
8908                0x4577e238ae26291,
8909                fidl::encoding::DynamicFlags::empty(),
8910                ___deadline,
8911            )?;
8912        Ok(_response)
8913    }
8914
8915    /// On a BufferCollectionToken channel:
8916    ///
8917    /// Normally a participant will convert a BufferCollectionToken into a
8918    /// BufferCollection view, but a participant is also free to Close() the
8919    /// token (and then close the channel immediately or shortly later in
8920    /// response to server closing its end), which avoids causing logical buffer
8921    /// collection failure.  Normally an unexpected token channel close will
8922    /// cause logical buffer collection failure (the only exceptions being
8923    /// certain cases involving AttachToken() or SetDispensable()).
8924    ///
8925    /// On a BufferCollection channel:
8926    ///
8927    /// By default the server handles unexpected failure of a BufferCollection
8928    /// by failing the whole logical buffer collection.  Partly this is to
8929    /// expedite closing VMO handles to reclaim memory when any participant
8930    /// fails.  If a participant would like to cleanly close a BufferCollection
8931    /// view without causing logical buffer collection failure, the participant
8932    /// can send Close() before closing the client end of the BufferCollection
8933    /// channel.  If this is the last BufferCollection view, the logical buffer
8934    /// collection will still go away.  The Close() can occur before or after
8935    /// SetConstraints().  If before SetConstraints(), the buffer collection
8936    /// won't require constraints from this node in order to allocate.  If
8937    /// after SetConstraints(), the constraints are retained and aggregated
8938    /// along with any subsequent logical allocation(s), despite the lack of
8939    /// channel connection.
8940    ///
8941    /// On a BufferCollectionTokenGroup channel:
8942    ///
8943    /// By default, unexpected failure of a BufferCollectionTokenGroup will
8944    /// trigger failure of the logical BufferCollectionTokenGroup and will
8945    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
8946    /// channel without failing the logical group or propagating failure, send
8947    /// Close() before closing the channel client endpoint.
8948    ///
8949    /// If Close() occurs before AllChildrenPresent(), the logical buffer
8950    /// collection will still fail despite the Close() (because sysmem can't be
8951    /// sure whether all relevant children were created, so it's ambiguous
8952    /// whether all relevant constraints will be provided to sysmem).  If
8953    /// Close() occurs after AllChildrenPresent(), the children and all their
8954    /// constraints remain intact (just as they would if the
8955    /// BufferCollectionTokenGroup channel had remained open), and the close
8956    /// doesn't trigger or propagate failure.
8957    pub fn r#close(&self) -> Result<(), fidl::Error> {
8958        self.client.send::<fidl::encoding::EmptyPayload>(
8959            (),
8960            0x5b1d7a4f5681fca7,
8961            fidl::encoding::DynamicFlags::empty(),
8962        )
8963    }
8964
8965    /// Set a name for VMOs in this buffer collection. The name may be truncated
8966    /// shorter. The name only affects VMOs allocated after it's set - this call
8967    /// does not rename existing VMOs. If multiple clients set different names
8968    /// then the larger priority value will win.
8969    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
8970        self.client.send::<NodeSetNameRequest>(
8971            (priority, name),
8972            0x77a41bb6217e2443,
8973            fidl::encoding::DynamicFlags::empty(),
8974        )
8975    }
8976
8977    /// Set information about the current client that can be used by sysmem to
8978    /// help debug leaking memory and hangs waiting for constraints. |name| can
8979    /// be an arbitrary string, but the current process name (see
8980    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
8981    /// arbitrary id, but the current process ID (see
8982    /// fsl::GetCurrentProcessKoid()) is a good default.
8983    ///
8984    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
8985    /// indicate which client is closing their channel first, leading to
8986    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
8987    /// over, but if happening earlier than expected, the
8988    /// client-channel-specific name can help diagnose where the failure is
8989    /// first coming from, from sysmem's point of view).
8990    ///
8991    /// By default (unless overriden by this message or using
8992    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
8993    /// parent Node at the time the child Node is created.  While this can be
8994    /// better than nothing, it's often better for each participant to use
8995    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
8996    /// info directly relevant to the current client.  Also, SetVerboseLogging()
8997    /// can be used to help disambiguate if a Node is suspected of having info
8998    /// that was copied from its parent.
8999    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9000        self.client.send::<NodeSetDebugClientInfoRequest>(
9001            (name, id),
9002            0x7275759070eb5ee2,
9003            fidl::encoding::DynamicFlags::empty(),
9004        )
9005    }
9006
9007    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9008    /// after creating a collection. Clients can call this method to change
9009    /// when the log is printed. If multiple client set the deadline, it's
9010    /// unspecified which deadline will take effect.
9011    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9012        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
9013            (deadline,),
9014            0x46d38f4772638867,
9015            fidl::encoding::DynamicFlags::empty(),
9016        )
9017    }
9018
9019    /// Verbose logging includes constraints set via SetConstraints() from each
9020    /// client along with info set via SetDebugClientInfo() and the structure of
9021    /// the tree of Node(s).
9022    ///
9023    /// Normally sysmem prints only a single line complaint when aggregation
9024    /// fails, with just the specific detailed reason that aggregation failed,
9025    /// with minimal context.  While this is often enough to diagnose a problem
9026    /// if only a small change was made and the system had been working before
9027    /// the small change, it's often not particularly helpful for getting a new
9028    /// buffer collection to work for the first time.  Especially with more
9029    /// complex trees of nodes, involving things like AttachToken(),
9030    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9031    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9032    /// looks like and why it's failing a logical allocation, or why a tree or
9033    /// sub-tree is failing sooner than expected.
9034    ///
9035    /// The intent of the extra logging is to be acceptable from a performance
9036    /// point of view, if only enabled on a low number of buffer collections.
9037    /// If we're not tracking down a bug, we shouldn't send this message.
9038    ///
9039    /// If too many participants leave verbose logging enabled, we may end up
9040    /// needing to require that system-wide sysmem verbose logging be permitted
9041    /// via some other setting, to avoid sysmem spamming the log too much due to
9042    /// this message.
9043    ///
9044    /// This may be a NOP for some nodes due to intentional policy associated
9045    /// with the node, if we don't trust a node enough to let it turn on verbose
9046    /// logging.
9047    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9048        self.client.send::<fidl::encoding::EmptyPayload>(
9049            (),
9050            0x6bfbe2cf1701d288,
9051            fidl::encoding::DynamicFlags::empty(),
9052        )
9053    }
9054
9055    /// This gets an event handle that can be used as a parameter to
9056    /// IsAlternateFor() called on any Node.  The client will not be granted the
9057    /// right to signal this event, as this handle should only be used as proof
9058    /// that the client obtained this handle from this Node.
9059    ///
9060    /// Because this is a get not a set, no Sync() is needed between the
9061    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9062    /// potentially being on different channels.
9063    ///
9064    /// See also IsAlternateFor().
9065    pub fn r#get_node_ref(
9066        &self,
9067        ___deadline: zx::MonotonicInstant,
9068    ) -> Result<fidl::Event, fidl::Error> {
9069        let _response =
9070            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
9071                (),
9072                0x467b7c75c35c3b84,
9073                fidl::encoding::DynamicFlags::empty(),
9074                ___deadline,
9075            )?;
9076        Ok(_response.node_ref)
9077    }
9078
9079    /// This checks whether the calling node is in a subtree rooted at a
9080    /// different child token of a common parent BufferCollectionTokenGroup, in
9081    /// relation to the passed-in node_ref.
9082    ///
9083    /// This call is for assisting with admission control de-duplication, and
9084    /// with debugging.
9085    ///
9086    /// The node_ref must be obtained using GetNodeRef() of a
9087    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9088    ///
9089    /// The node_ref can be a duplicated handle; it's not necessary to call
9090    /// GetNodeRef() for every call to IsAlternateFor().
9091    ///
9092    /// If a calling token may not actually be a valid token at all due to
9093    /// a potentially hostile/untrusted provider of the token, call
9094    /// ValidateBufferCollectionToken() first instead of potentially getting
9095    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9096    /// token not being a real token (not really talking to sysmem).  Another
9097    /// option is to call BindSharedCollection with this token first which also
9098    /// validates the token along with converting it to a BufferCollection, then
9099    /// call BufferCollection IsAlternateFor().
9100    ///
9101    /// error values:
9102    ///
9103    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9104    /// buffer collection as the calling Node.  Before logical allocation and
9105    /// within the same logical allocation sub-tree, this essentially means that
9106    /// the node_ref was never part of this logical buffer collection, since
9107    /// before logical allocation all node_refs that come into existence remain
9108    /// in existence at least until logical allocation (including Node(s) that
9109    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9110    /// to be returned, this Node's channel needs to still be connected server
9111    /// side, which won't be the case if the whole logical allocation has
9112    /// failed.  After logical allocation or in a different logical allocation
9113    /// sub-tree there are additional potential reasons for this error.  For
9114    /// example a different logical allocation (separated from this Node(s)
9115    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9116    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9117    /// exist and may select a different child sub-tree than the sub-tree the
9118    /// node_ref is in causing deletion of the node_ref Node.  The only time
9119    /// sysmem keeps a Node around after that Node has no corresponding channel
9120    /// is when Close() is used and the Node's sub-tree has not yet failed.
9121    /// Another reason for this error is if the node_ref is an eventpair handle
9122    /// with sufficient rights, but isn't actually a real node_ref obtained from
9123    /// GetNodeRef().
9124    ///
9125    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9126    /// eventpair handle, or doesn't have the needed rights expected on a real
9127    /// node_ref.
9128    ///
9129    /// No other failing status codes are returned by this call.  However,
9130    /// sysmem may add additional codes in future, so the client should have
9131    /// sensible default handling for any failing status code.
9132    ///
9133    /// On success, is_alternate has the following meaning:
9134    ///   * true - The first parent node in common between the calling node and
9135    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9136    ///     the calling Node and the node_ref Node will _not_ have both their
9137    ///     constraints apply - rather sysmem will choose one or the other of
9138    ///     the constraints - never both.  This is because only one child of
9139    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9140    ///     with only that one child's sub-tree contributing to constraints
9141    ///     aggregation.
9142    ///   * false - The first parent node in common between the calling Node and
9143    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9144    ///     this means the first parent node in common is a
9145    ///     BufferCollectionToken or BufferCollection (regardless of not
9146    ///     Close()ed or Close()ed).  This means that the calling Node and the
9147    ///     node_ref Node _may_ have both their constraints apply during
9148    ///     constraints aggregation of the logical allocation, if both Node(s)
9149    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9150    ///     In this case, there is no BufferCollectionTokenGroup that will
9151    ///     directly prevent the two Node(s) from both being selected and their
9152    ///     constraints both aggregated, but even when false, one or both
9153    ///     Node(s) may still be eliminated from consideration if one or both
9154    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9155    ///     which selects a child sub-tree other than the sub-tree containing
9156    ///     the calling Node or node_ref Node.
9157    pub fn r#is_alternate_for(
9158        &self,
9159        mut node_ref: fidl::Event,
9160        ___deadline: zx::MonotonicInstant,
9161    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
9162        let _response = self.client.send_query::<
9163            NodeIsAlternateForRequest,
9164            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
9165        >(
9166            (node_ref,),
9167            0x33a2a7aff2776c07,
9168            fidl::encoding::DynamicFlags::empty(),
9169            ___deadline,
9170        )?;
9171        Ok(_response.map(|x| x.is_alternate))
9172    }
9173}
9174
9175#[cfg(target_os = "fuchsia")]
9176impl From<NodeSynchronousProxy> for zx::Handle {
9177    fn from(value: NodeSynchronousProxy) -> Self {
9178        value.into_channel().into()
9179    }
9180}
9181
9182#[cfg(target_os = "fuchsia")]
9183impl From<fidl::Channel> for NodeSynchronousProxy {
9184    fn from(value: fidl::Channel) -> Self {
9185        Self::new(value)
9186    }
9187}
9188
9189#[cfg(target_os = "fuchsia")]
9190impl fidl::endpoints::FromClient for NodeSynchronousProxy {
9191    type Protocol = NodeMarker;
9192
9193    fn from_client(value: fidl::endpoints::ClientEnd<NodeMarker>) -> Self {
9194        Self::new(value.into_channel())
9195    }
9196}
9197
9198#[derive(Debug, Clone)]
9199pub struct NodeProxy {
9200    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9201}
9202
9203impl fidl::endpoints::Proxy for NodeProxy {
9204    type Protocol = NodeMarker;
9205
9206    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9207        Self::new(inner)
9208    }
9209
9210    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9211        self.client.into_channel().map_err(|client| Self { client })
9212    }
9213
9214    fn as_channel(&self) -> &::fidl::AsyncChannel {
9215        self.client.as_channel()
9216    }
9217}
9218
9219impl NodeProxy {
9220    /// Create a new Proxy for fuchsia.sysmem/Node.
9221    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9222        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9223        Self { client: fidl::client::Client::new(channel, protocol_name) }
9224    }
9225
9226    /// Get a Stream of events from the remote end of the protocol.
9227    ///
9228    /// # Panics
9229    ///
9230    /// Panics if the event stream was already taken.
9231    pub fn take_event_stream(&self) -> NodeEventStream {
9232        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9233    }
9234
9235    /// Ensure that previous messages, including Duplicate() messages on a
9236    /// token, collection, or group, have been received server side.
9237    ///
9238    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9239    /// valid sysmem token risks the Sync() hanging forever.  See
9240    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9241    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9242    /// Another way is to pass the token to BindSharedCollection(), which also
9243    /// validates the token as part of exchanging it for a BufferCollection
9244    /// channel, and BufferCollection Sync() can then be used.
9245    ///
9246    /// After a Sync(), it's then safe to send the client end of token_request
9247    /// to another participant knowing the server will recognize the token when
9248    /// it's sent into BindSharedCollection() by the other participant.
9249    ///
9250    /// Other options include waiting for each token.Duplicate() to complete
9251    /// individually (using separate call to token.Sync() after each), or
9252    /// calling Sync() on BufferCollection after the token has been turned in
9253    /// via BindSharedCollection().
9254    ///
9255    /// Another way to mitigate is to avoid calling Sync() on the token, and
9256    /// instead later deal with potential failure of BufferCollection.Sync() if
9257    /// the original token was invalid.  This option can be preferable from a
9258    /// performance point of view, but requires client code to delay sending
9259    /// tokens duplicated from this token until after client code has converted
9260    /// the duplicating token to a BufferCollection and received successful
9261    /// response from BufferCollection.Sync().
9262    ///
9263    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9264    /// When BufferCollection.Sync() isn't feasible, the caller must already
9265    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9266    /// hang forever.  See ValidateBufferCollectionToken() to check token
9267    /// validity first if the token isn't already known to be (is/was) valid.
9268    pub fn r#sync(
9269        &self,
9270    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9271        NodeProxyInterface::r#sync(self)
9272    }
9273
9274    /// On a BufferCollectionToken channel:
9275    ///
9276    /// Normally a participant will convert a BufferCollectionToken into a
9277    /// BufferCollection view, but a participant is also free to Close() the
9278    /// token (and then close the channel immediately or shortly later in
9279    /// response to server closing its end), which avoids causing logical buffer
9280    /// collection failure.  Normally an unexpected token channel close will
9281    /// cause logical buffer collection failure (the only exceptions being
9282    /// certain cases involving AttachToken() or SetDispensable()).
9283    ///
9284    /// On a BufferCollection channel:
9285    ///
9286    /// By default the server handles unexpected failure of a BufferCollection
9287    /// by failing the whole logical buffer collection.  Partly this is to
9288    /// expedite closing VMO handles to reclaim memory when any participant
9289    /// fails.  If a participant would like to cleanly close a BufferCollection
9290    /// view without causing logical buffer collection failure, the participant
9291    /// can send Close() before closing the client end of the BufferCollection
9292    /// channel.  If this is the last BufferCollection view, the logical buffer
9293    /// collection will still go away.  The Close() can occur before or after
9294    /// SetConstraints().  If before SetConstraints(), the buffer collection
9295    /// won't require constraints from this node in order to allocate.  If
9296    /// after SetConstraints(), the constraints are retained and aggregated
9297    /// along with any subsequent logical allocation(s), despite the lack of
9298    /// channel connection.
9299    ///
9300    /// On a BufferCollectionTokenGroup channel:
9301    ///
9302    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9303    /// trigger failure of the logical BufferCollectionTokenGroup and will
9304    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9305    /// channel without failing the logical group or propagating failure, send
9306    /// Close() before closing the channel client endpoint.
9307    ///
9308    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9309    /// collection will still fail despite the Close() (because sysmem can't be
9310    /// sure whether all relevant children were created, so it's ambiguous
9311    /// whether all relevant constraints will be provided to sysmem).  If
9312    /// Close() occurs after AllChildrenPresent(), the children and all their
9313    /// constraints remain intact (just as they would if the
9314    /// BufferCollectionTokenGroup channel had remained open), and the close
9315    /// doesn't trigger or propagate failure.
9316    pub fn r#close(&self) -> Result<(), fidl::Error> {
9317        NodeProxyInterface::r#close(self)
9318    }
9319
9320    /// Set a name for VMOs in this buffer collection. The name may be truncated
9321    /// shorter. The name only affects VMOs allocated after it's set - this call
9322    /// does not rename existing VMOs. If multiple clients set different names
9323    /// then the larger priority value will win.
9324    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9325        NodeProxyInterface::r#set_name(self, priority, name)
9326    }
9327
9328    /// Set information about the current client that can be used by sysmem to
9329    /// help debug leaking memory and hangs waiting for constraints. |name| can
9330    /// be an arbitrary string, but the current process name (see
9331    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9332    /// arbitrary id, but the current process ID (see
9333    /// fsl::GetCurrentProcessKoid()) is a good default.
9334    ///
9335    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9336    /// indicate which client is closing their channel first, leading to
9337    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9338    /// over, but if happening earlier than expected, the
9339    /// client-channel-specific name can help diagnose where the failure is
9340    /// first coming from, from sysmem's point of view).
9341    ///
9342    /// By default (unless overriden by this message or using
9343    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9344    /// parent Node at the time the child Node is created.  While this can be
9345    /// better than nothing, it's often better for each participant to use
9346    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9347    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9348    /// can be used to help disambiguate if a Node is suspected of having info
9349    /// that was copied from its parent.
9350    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9351        NodeProxyInterface::r#set_debug_client_info(self, name, id)
9352    }
9353
9354    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9355    /// after creating a collection. Clients can call this method to change
9356    /// when the log is printed. If multiple client set the deadline, it's
9357    /// unspecified which deadline will take effect.
9358    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9359        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
9360    }
9361
9362    /// Verbose logging includes constraints set via SetConstraints() from each
9363    /// client along with info set via SetDebugClientInfo() and the structure of
9364    /// the tree of Node(s).
9365    ///
9366    /// Normally sysmem prints only a single line complaint when aggregation
9367    /// fails, with just the specific detailed reason that aggregation failed,
9368    /// with minimal context.  While this is often enough to diagnose a problem
9369    /// if only a small change was made and the system had been working before
9370    /// the small change, it's often not particularly helpful for getting a new
9371    /// buffer collection to work for the first time.  Especially with more
9372    /// complex trees of nodes, involving things like AttachToken(),
9373    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9374    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9375    /// looks like and why it's failing a logical allocation, or why a tree or
9376    /// sub-tree is failing sooner than expected.
9377    ///
9378    /// The intent of the extra logging is to be acceptable from a performance
9379    /// point of view, if only enabled on a low number of buffer collections.
9380    /// If we're not tracking down a bug, we shouldn't send this message.
9381    ///
9382    /// If too many participants leave verbose logging enabled, we may end up
9383    /// needing to require that system-wide sysmem verbose logging be permitted
9384    /// via some other setting, to avoid sysmem spamming the log too much due to
9385    /// this message.
9386    ///
9387    /// This may be a NOP for some nodes due to intentional policy associated
9388    /// with the node, if we don't trust a node enough to let it turn on verbose
9389    /// logging.
9390    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9391        NodeProxyInterface::r#set_verbose_logging(self)
9392    }
9393
9394    /// This gets an event handle that can be used as a parameter to
9395    /// IsAlternateFor() called on any Node.  The client will not be granted the
9396    /// right to signal this event, as this handle should only be used as proof
9397    /// that the client obtained this handle from this Node.
9398    ///
9399    /// Because this is a get not a set, no Sync() is needed between the
9400    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9401    /// potentially being on different channels.
9402    ///
9403    /// See also IsAlternateFor().
9404    pub fn r#get_node_ref(
9405        &self,
9406    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
9407    {
9408        NodeProxyInterface::r#get_node_ref(self)
9409    }
9410
9411    /// This checks whether the calling node is in a subtree rooted at a
9412    /// different child token of a common parent BufferCollectionTokenGroup, in
9413    /// relation to the passed-in node_ref.
9414    ///
9415    /// This call is for assisting with admission control de-duplication, and
9416    /// with debugging.
9417    ///
9418    /// The node_ref must be obtained using GetNodeRef() of a
9419    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9420    ///
9421    /// The node_ref can be a duplicated handle; it's not necessary to call
9422    /// GetNodeRef() for every call to IsAlternateFor().
9423    ///
9424    /// If a calling token may not actually be a valid token at all due to
9425    /// a potentially hostile/untrusted provider of the token, call
9426    /// ValidateBufferCollectionToken() first instead of potentially getting
9427    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9428    /// token not being a real token (not really talking to sysmem).  Another
9429    /// option is to call BindSharedCollection with this token first which also
9430    /// validates the token along with converting it to a BufferCollection, then
9431    /// call BufferCollection IsAlternateFor().
9432    ///
9433    /// error values:
9434    ///
9435    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9436    /// buffer collection as the calling Node.  Before logical allocation and
9437    /// within the same logical allocation sub-tree, this essentially means that
9438    /// the node_ref was never part of this logical buffer collection, since
9439    /// before logical allocation all node_refs that come into existence remain
9440    /// in existence at least until logical allocation (including Node(s) that
9441    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9442    /// to be returned, this Node's channel needs to still be connected server
9443    /// side, which won't be the case if the whole logical allocation has
9444    /// failed.  After logical allocation or in a different logical allocation
9445    /// sub-tree there are additional potential reasons for this error.  For
9446    /// example a different logical allocation (separated from this Node(s)
9447    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9448    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9449    /// exist and may select a different child sub-tree than the sub-tree the
9450    /// node_ref is in causing deletion of the node_ref Node.  The only time
9451    /// sysmem keeps a Node around after that Node has no corresponding channel
9452    /// is when Close() is used and the Node's sub-tree has not yet failed.
9453    /// Another reason for this error is if the node_ref is an eventpair handle
9454    /// with sufficient rights, but isn't actually a real node_ref obtained from
9455    /// GetNodeRef().
9456    ///
9457    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9458    /// eventpair handle, or doesn't have the needed rights expected on a real
9459    /// node_ref.
9460    ///
9461    /// No other failing status codes are returned by this call.  However,
9462    /// sysmem may add additional codes in future, so the client should have
9463    /// sensible default handling for any failing status code.
9464    ///
9465    /// On success, is_alternate has the following meaning:
9466    ///   * true - The first parent node in common between the calling node and
9467    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9468    ///     the calling Node and the node_ref Node will _not_ have both their
9469    ///     constraints apply - rather sysmem will choose one or the other of
9470    ///     the constraints - never both.  This is because only one child of
9471    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9472    ///     with only that one child's sub-tree contributing to constraints
9473    ///     aggregation.
9474    ///   * false - The first parent node in common between the calling Node and
9475    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9476    ///     this means the first parent node in common is a
9477    ///     BufferCollectionToken or BufferCollection (regardless of not
9478    ///     Close()ed or Close()ed).  This means that the calling Node and the
9479    ///     node_ref Node _may_ have both their constraints apply during
9480    ///     constraints aggregation of the logical allocation, if both Node(s)
9481    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9482    ///     In this case, there is no BufferCollectionTokenGroup that will
9483    ///     directly prevent the two Node(s) from both being selected and their
9484    ///     constraints both aggregated, but even when false, one or both
9485    ///     Node(s) may still be eliminated from consideration if one or both
9486    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9487    ///     which selects a child sub-tree other than the sub-tree containing
9488    ///     the calling Node or node_ref Node.
9489    pub fn r#is_alternate_for(
9490        &self,
9491        mut node_ref: fidl::Event,
9492    ) -> fidl::client::QueryResponseFut<
9493        NodeIsAlternateForResult,
9494        fidl::encoding::DefaultFuchsiaResourceDialect,
9495    > {
9496        NodeProxyInterface::r#is_alternate_for(self, node_ref)
9497    }
9498}
9499
9500impl NodeProxyInterface for NodeProxy {
9501    type SyncResponseFut =
9502        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9503    fn r#sync(&self) -> Self::SyncResponseFut {
9504        fn _decode(
9505            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9506        ) -> Result<(), fidl::Error> {
9507            let _response = fidl::client::decode_transaction_body::<
9508                fidl::encoding::EmptyPayload,
9509                fidl::encoding::DefaultFuchsiaResourceDialect,
9510                0x4577e238ae26291,
9511            >(_buf?)?;
9512            Ok(_response)
9513        }
9514        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9515            (),
9516            0x4577e238ae26291,
9517            fidl::encoding::DynamicFlags::empty(),
9518            _decode,
9519        )
9520    }
9521
9522    fn r#close(&self) -> Result<(), fidl::Error> {
9523        self.client.send::<fidl::encoding::EmptyPayload>(
9524            (),
9525            0x5b1d7a4f5681fca7,
9526            fidl::encoding::DynamicFlags::empty(),
9527        )
9528    }
9529
9530    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9531        self.client.send::<NodeSetNameRequest>(
9532            (priority, name),
9533            0x77a41bb6217e2443,
9534            fidl::encoding::DynamicFlags::empty(),
9535        )
9536    }
9537
9538    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9539        self.client.send::<NodeSetDebugClientInfoRequest>(
9540            (name, id),
9541            0x7275759070eb5ee2,
9542            fidl::encoding::DynamicFlags::empty(),
9543        )
9544    }
9545
9546    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9547        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
9548            (deadline,),
9549            0x46d38f4772638867,
9550            fidl::encoding::DynamicFlags::empty(),
9551        )
9552    }
9553
9554    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9555        self.client.send::<fidl::encoding::EmptyPayload>(
9556            (),
9557            0x6bfbe2cf1701d288,
9558            fidl::encoding::DynamicFlags::empty(),
9559        )
9560    }
9561
9562    type GetNodeRefResponseFut =
9563        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
9564    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
9565        fn _decode(
9566            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9567        ) -> Result<fidl::Event, fidl::Error> {
9568            let _response = fidl::client::decode_transaction_body::<
9569                NodeGetNodeRefResponse,
9570                fidl::encoding::DefaultFuchsiaResourceDialect,
9571                0x467b7c75c35c3b84,
9572            >(_buf?)?;
9573            Ok(_response.node_ref)
9574        }
9575        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
9576            (),
9577            0x467b7c75c35c3b84,
9578            fidl::encoding::DynamicFlags::empty(),
9579            _decode,
9580        )
9581    }
9582
9583    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
9584        NodeIsAlternateForResult,
9585        fidl::encoding::DefaultFuchsiaResourceDialect,
9586    >;
9587    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
9588        fn _decode(
9589            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9590        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
9591            let _response = fidl::client::decode_transaction_body::<
9592                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
9593                fidl::encoding::DefaultFuchsiaResourceDialect,
9594                0x33a2a7aff2776c07,
9595            >(_buf?)?;
9596            Ok(_response.map(|x| x.is_alternate))
9597        }
9598        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
9599            (node_ref,),
9600            0x33a2a7aff2776c07,
9601            fidl::encoding::DynamicFlags::empty(),
9602            _decode,
9603        )
9604    }
9605}
9606
9607pub struct NodeEventStream {
9608    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9609}
9610
9611impl std::marker::Unpin for NodeEventStream {}
9612
9613impl futures::stream::FusedStream for NodeEventStream {
9614    fn is_terminated(&self) -> bool {
9615        self.event_receiver.is_terminated()
9616    }
9617}
9618
9619impl futures::Stream for NodeEventStream {
9620    type Item = Result<NodeEvent, fidl::Error>;
9621
9622    fn poll_next(
9623        mut self: std::pin::Pin<&mut Self>,
9624        cx: &mut std::task::Context<'_>,
9625    ) -> std::task::Poll<Option<Self::Item>> {
9626        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9627            &mut self.event_receiver,
9628            cx
9629        )?) {
9630            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
9631            None => std::task::Poll::Ready(None),
9632        }
9633    }
9634}
9635
9636#[derive(Debug)]
9637pub enum NodeEvent {}
9638
9639impl NodeEvent {
9640    /// Decodes a message buffer as a [`NodeEvent`].
9641    fn decode(
9642        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9643    ) -> Result<NodeEvent, fidl::Error> {
9644        let (bytes, _handles) = buf.split_mut();
9645        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9646        debug_assert_eq!(tx_header.tx_id, 0);
9647        match tx_header.ordinal {
9648            _ => Err(fidl::Error::UnknownOrdinal {
9649                ordinal: tx_header.ordinal,
9650                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9651            }),
9652        }
9653    }
9654}
9655
9656/// A Stream of incoming requests for fuchsia.sysmem/Node.
9657pub struct NodeRequestStream {
9658    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9659    is_terminated: bool,
9660}
9661
9662impl std::marker::Unpin for NodeRequestStream {}
9663
9664impl futures::stream::FusedStream for NodeRequestStream {
9665    fn is_terminated(&self) -> bool {
9666        self.is_terminated
9667    }
9668}
9669
9670impl fidl::endpoints::RequestStream for NodeRequestStream {
9671    type Protocol = NodeMarker;
9672    type ControlHandle = NodeControlHandle;
9673
9674    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9675        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9676    }
9677
9678    fn control_handle(&self) -> Self::ControlHandle {
9679        NodeControlHandle { inner: self.inner.clone() }
9680    }
9681
9682    fn into_inner(
9683        self,
9684    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9685    {
9686        (self.inner, self.is_terminated)
9687    }
9688
9689    fn from_inner(
9690        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9691        is_terminated: bool,
9692    ) -> Self {
9693        Self { inner, is_terminated }
9694    }
9695}
9696
9697impl futures::Stream for NodeRequestStream {
9698    type Item = Result<NodeRequest, fidl::Error>;
9699
9700    fn poll_next(
9701        mut self: std::pin::Pin<&mut Self>,
9702        cx: &mut std::task::Context<'_>,
9703    ) -> std::task::Poll<Option<Self::Item>> {
9704        let this = &mut *self;
9705        if this.inner.check_shutdown(cx) {
9706            this.is_terminated = true;
9707            return std::task::Poll::Ready(None);
9708        }
9709        if this.is_terminated {
9710            panic!("polled NodeRequestStream after completion");
9711        }
9712        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9713            |bytes, handles| {
9714                match this.inner.channel().read_etc(cx, bytes, handles) {
9715                    std::task::Poll::Ready(Ok(())) => {}
9716                    std::task::Poll::Pending => return std::task::Poll::Pending,
9717                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9718                        this.is_terminated = true;
9719                        return std::task::Poll::Ready(None);
9720                    }
9721                    std::task::Poll::Ready(Err(e)) => {
9722                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9723                            e.into(),
9724                        ))))
9725                    }
9726                }
9727
9728                // A message has been received from the channel
9729                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9730
9731                std::task::Poll::Ready(Some(match header.ordinal {
9732                    0x4577e238ae26291 => {
9733                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9734                        let mut req = fidl::new_empty!(
9735                            fidl::encoding::EmptyPayload,
9736                            fidl::encoding::DefaultFuchsiaResourceDialect
9737                        );
9738                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9739                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9740                        Ok(NodeRequest::Sync {
9741                            responder: NodeSyncResponder {
9742                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9743                                tx_id: header.tx_id,
9744                            },
9745                        })
9746                    }
9747                    0x5b1d7a4f5681fca7 => {
9748                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9749                        let mut req = fidl::new_empty!(
9750                            fidl::encoding::EmptyPayload,
9751                            fidl::encoding::DefaultFuchsiaResourceDialect
9752                        );
9753                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9754                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9755                        Ok(NodeRequest::Close { control_handle })
9756                    }
9757                    0x77a41bb6217e2443 => {
9758                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9759                        let mut req = fidl::new_empty!(
9760                            NodeSetNameRequest,
9761                            fidl::encoding::DefaultFuchsiaResourceDialect
9762                        );
9763                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
9764                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9765                        Ok(NodeRequest::SetName {
9766                            priority: req.priority,
9767                            name: req.name,
9768
9769                            control_handle,
9770                        })
9771                    }
9772                    0x7275759070eb5ee2 => {
9773                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9774                        let mut req = fidl::new_empty!(
9775                            NodeSetDebugClientInfoRequest,
9776                            fidl::encoding::DefaultFuchsiaResourceDialect
9777                        );
9778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
9779                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9780                        Ok(NodeRequest::SetDebugClientInfo {
9781                            name: req.name,
9782                            id: req.id,
9783
9784                            control_handle,
9785                        })
9786                    }
9787                    0x46d38f4772638867 => {
9788                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9789                        let mut req = fidl::new_empty!(
9790                            NodeSetDebugTimeoutLogDeadlineRequest,
9791                            fidl::encoding::DefaultFuchsiaResourceDialect
9792                        );
9793                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
9794                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9795                        Ok(NodeRequest::SetDebugTimeoutLogDeadline {
9796                            deadline: req.deadline,
9797
9798                            control_handle,
9799                        })
9800                    }
9801                    0x6bfbe2cf1701d288 => {
9802                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9803                        let mut req = fidl::new_empty!(
9804                            fidl::encoding::EmptyPayload,
9805                            fidl::encoding::DefaultFuchsiaResourceDialect
9806                        );
9807                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9808                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9809                        Ok(NodeRequest::SetVerboseLogging { control_handle })
9810                    }
9811                    0x467b7c75c35c3b84 => {
9812                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9813                        let mut req = fidl::new_empty!(
9814                            fidl::encoding::EmptyPayload,
9815                            fidl::encoding::DefaultFuchsiaResourceDialect
9816                        );
9817                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9818                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9819                        Ok(NodeRequest::GetNodeRef {
9820                            responder: NodeGetNodeRefResponder {
9821                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9822                                tx_id: header.tx_id,
9823                            },
9824                        })
9825                    }
9826                    0x33a2a7aff2776c07 => {
9827                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9828                        let mut req = fidl::new_empty!(
9829                            NodeIsAlternateForRequest,
9830                            fidl::encoding::DefaultFuchsiaResourceDialect
9831                        );
9832                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
9833                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9834                        Ok(NodeRequest::IsAlternateFor {
9835                            node_ref: req.node_ref,
9836
9837                            responder: NodeIsAlternateForResponder {
9838                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9839                                tx_id: header.tx_id,
9840                            },
9841                        })
9842                    }
9843                    _ => Err(fidl::Error::UnknownOrdinal {
9844                        ordinal: header.ordinal,
9845                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9846                    }),
9847                }))
9848            },
9849        )
9850    }
9851}
9852
9853#[derive(Debug)]
9854pub enum NodeRequest {
9855    /// Ensure that previous messages, including Duplicate() messages on a
9856    /// token, collection, or group, have been received server side.
9857    ///
9858    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9859    /// valid sysmem token risks the Sync() hanging forever.  See
9860    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9861    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9862    /// Another way is to pass the token to BindSharedCollection(), which also
9863    /// validates the token as part of exchanging it for a BufferCollection
9864    /// channel, and BufferCollection Sync() can then be used.
9865    ///
9866    /// After a Sync(), it's then safe to send the client end of token_request
9867    /// to another participant knowing the server will recognize the token when
9868    /// it's sent into BindSharedCollection() by the other participant.
9869    ///
9870    /// Other options include waiting for each token.Duplicate() to complete
9871    /// individually (using separate call to token.Sync() after each), or
9872    /// calling Sync() on BufferCollection after the token has been turned in
9873    /// via BindSharedCollection().
9874    ///
9875    /// Another way to mitigate is to avoid calling Sync() on the token, and
9876    /// instead later deal with potential failure of BufferCollection.Sync() if
9877    /// the original token was invalid.  This option can be preferable from a
9878    /// performance point of view, but requires client code to delay sending
9879    /// tokens duplicated from this token until after client code has converted
9880    /// the duplicating token to a BufferCollection and received successful
9881    /// response from BufferCollection.Sync().
9882    ///
9883    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9884    /// When BufferCollection.Sync() isn't feasible, the caller must already
9885    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9886    /// hang forever.  See ValidateBufferCollectionToken() to check token
9887    /// validity first if the token isn't already known to be (is/was) valid.
9888    Sync { responder: NodeSyncResponder },
9889    /// On a BufferCollectionToken channel:
9890    ///
9891    /// Normally a participant will convert a BufferCollectionToken into a
9892    /// BufferCollection view, but a participant is also free to Close() the
9893    /// token (and then close the channel immediately or shortly later in
9894    /// response to server closing its end), which avoids causing logical buffer
9895    /// collection failure.  Normally an unexpected token channel close will
9896    /// cause logical buffer collection failure (the only exceptions being
9897    /// certain cases involving AttachToken() or SetDispensable()).
9898    ///
9899    /// On a BufferCollection channel:
9900    ///
9901    /// By default the server handles unexpected failure of a BufferCollection
9902    /// by failing the whole logical buffer collection.  Partly this is to
9903    /// expedite closing VMO handles to reclaim memory when any participant
9904    /// fails.  If a participant would like to cleanly close a BufferCollection
9905    /// view without causing logical buffer collection failure, the participant
9906    /// can send Close() before closing the client end of the BufferCollection
9907    /// channel.  If this is the last BufferCollection view, the logical buffer
9908    /// collection will still go away.  The Close() can occur before or after
9909    /// SetConstraints().  If before SetConstraints(), the buffer collection
9910    /// won't require constraints from this node in order to allocate.  If
9911    /// after SetConstraints(), the constraints are retained and aggregated
9912    /// along with any subsequent logical allocation(s), despite the lack of
9913    /// channel connection.
9914    ///
9915    /// On a BufferCollectionTokenGroup channel:
9916    ///
9917    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9918    /// trigger failure of the logical BufferCollectionTokenGroup and will
9919    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9920    /// channel without failing the logical group or propagating failure, send
9921    /// Close() before closing the channel client endpoint.
9922    ///
9923    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9924    /// collection will still fail despite the Close() (because sysmem can't be
9925    /// sure whether all relevant children were created, so it's ambiguous
9926    /// whether all relevant constraints will be provided to sysmem).  If
9927    /// Close() occurs after AllChildrenPresent(), the children and all their
9928    /// constraints remain intact (just as they would if the
9929    /// BufferCollectionTokenGroup channel had remained open), and the close
9930    /// doesn't trigger or propagate failure.
9931    Close { control_handle: NodeControlHandle },
9932    /// Set a name for VMOs in this buffer collection. The name may be truncated
9933    /// shorter. The name only affects VMOs allocated after it's set - this call
9934    /// does not rename existing VMOs. If multiple clients set different names
9935    /// then the larger priority value will win.
9936    SetName { priority: u32, name: String, control_handle: NodeControlHandle },
9937    /// Set information about the current client that can be used by sysmem to
9938    /// help debug leaking memory and hangs waiting for constraints. |name| can
9939    /// be an arbitrary string, but the current process name (see
9940    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9941    /// arbitrary id, but the current process ID (see
9942    /// fsl::GetCurrentProcessKoid()) is a good default.
9943    ///
9944    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9945    /// indicate which client is closing their channel first, leading to
9946    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9947    /// over, but if happening earlier than expected, the
9948    /// client-channel-specific name can help diagnose where the failure is
9949    /// first coming from, from sysmem's point of view).
9950    ///
9951    /// By default (unless overriden by this message or using
9952    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9953    /// parent Node at the time the child Node is created.  While this can be
9954    /// better than nothing, it's often better for each participant to use
9955    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9956    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9957    /// can be used to help disambiguate if a Node is suspected of having info
9958    /// that was copied from its parent.
9959    SetDebugClientInfo { name: String, id: u64, control_handle: NodeControlHandle },
9960    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9961    /// after creating a collection. Clients can call this method to change
9962    /// when the log is printed. If multiple client set the deadline, it's
9963    /// unspecified which deadline will take effect.
9964    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: NodeControlHandle },
9965    /// Verbose logging includes constraints set via SetConstraints() from each
9966    /// client along with info set via SetDebugClientInfo() and the structure of
9967    /// the tree of Node(s).
9968    ///
9969    /// Normally sysmem prints only a single line complaint when aggregation
9970    /// fails, with just the specific detailed reason that aggregation failed,
9971    /// with minimal context.  While this is often enough to diagnose a problem
9972    /// if only a small change was made and the system had been working before
9973    /// the small change, it's often not particularly helpful for getting a new
9974    /// buffer collection to work for the first time.  Especially with more
9975    /// complex trees of nodes, involving things like AttachToken(),
9976    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9977    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9978    /// looks like and why it's failing a logical allocation, or why a tree or
9979    /// sub-tree is failing sooner than expected.
9980    ///
9981    /// The intent of the extra logging is to be acceptable from a performance
9982    /// point of view, if only enabled on a low number of buffer collections.
9983    /// If we're not tracking down a bug, we shouldn't send this message.
9984    ///
9985    /// If too many participants leave verbose logging enabled, we may end up
9986    /// needing to require that system-wide sysmem verbose logging be permitted
9987    /// via some other setting, to avoid sysmem spamming the log too much due to
9988    /// this message.
9989    ///
9990    /// This may be a NOP for some nodes due to intentional policy associated
9991    /// with the node, if we don't trust a node enough to let it turn on verbose
9992    /// logging.
9993    SetVerboseLogging { control_handle: NodeControlHandle },
9994    /// This gets an event handle that can be used as a parameter to
9995    /// IsAlternateFor() called on any Node.  The client will not be granted the
9996    /// right to signal this event, as this handle should only be used as proof
9997    /// that the client obtained this handle from this Node.
9998    ///
9999    /// Because this is a get not a set, no Sync() is needed between the
10000    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
10001    /// potentially being on different channels.
10002    ///
10003    /// See also IsAlternateFor().
10004    GetNodeRef { responder: NodeGetNodeRefResponder },
10005    /// This checks whether the calling node is in a subtree rooted at a
10006    /// different child token of a common parent BufferCollectionTokenGroup, in
10007    /// relation to the passed-in node_ref.
10008    ///
10009    /// This call is for assisting with admission control de-duplication, and
10010    /// with debugging.
10011    ///
10012    /// The node_ref must be obtained using GetNodeRef() of a
10013    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
10014    ///
10015    /// The node_ref can be a duplicated handle; it's not necessary to call
10016    /// GetNodeRef() for every call to IsAlternateFor().
10017    ///
10018    /// If a calling token may not actually be a valid token at all due to
10019    /// a potentially hostile/untrusted provider of the token, call
10020    /// ValidateBufferCollectionToken() first instead of potentially getting
10021    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
10022    /// token not being a real token (not really talking to sysmem).  Another
10023    /// option is to call BindSharedCollection with this token first which also
10024    /// validates the token along with converting it to a BufferCollection, then
10025    /// call BufferCollection IsAlternateFor().
10026    ///
10027    /// error values:
10028    ///
10029    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
10030    /// buffer collection as the calling Node.  Before logical allocation and
10031    /// within the same logical allocation sub-tree, this essentially means that
10032    /// the node_ref was never part of this logical buffer collection, since
10033    /// before logical allocation all node_refs that come into existence remain
10034    /// in existence at least until logical allocation (including Node(s) that
10035    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
10036    /// to be returned, this Node's channel needs to still be connected server
10037    /// side, which won't be the case if the whole logical allocation has
10038    /// failed.  After logical allocation or in a different logical allocation
10039    /// sub-tree there are additional potential reasons for this error.  For
10040    /// example a different logical allocation (separated from this Node(s)
10041    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
10042    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
10043    /// exist and may select a different child sub-tree than the sub-tree the
10044    /// node_ref is in causing deletion of the node_ref Node.  The only time
10045    /// sysmem keeps a Node around after that Node has no corresponding channel
10046    /// is when Close() is used and the Node's sub-tree has not yet failed.
10047    /// Another reason for this error is if the node_ref is an eventpair handle
10048    /// with sufficient rights, but isn't actually a real node_ref obtained from
10049    /// GetNodeRef().
10050    ///
10051    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
10052    /// eventpair handle, or doesn't have the needed rights expected on a real
10053    /// node_ref.
10054    ///
10055    /// No other failing status codes are returned by this call.  However,
10056    /// sysmem may add additional codes in future, so the client should have
10057    /// sensible default handling for any failing status code.
10058    ///
10059    /// On success, is_alternate has the following meaning:
10060    ///   * true - The first parent node in common between the calling node and
10061    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
10062    ///     the calling Node and the node_ref Node will _not_ have both their
10063    ///     constraints apply - rather sysmem will choose one or the other of
10064    ///     the constraints - never both.  This is because only one child of
10065    ///     a BufferCollectionTokenGroup is selected during logical allocation,
10066    ///     with only that one child's sub-tree contributing to constraints
10067    ///     aggregation.
10068    ///   * false - The first parent node in common between the calling Node and
10069    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
10070    ///     this means the first parent node in common is a
10071    ///     BufferCollectionToken or BufferCollection (regardless of not
10072    ///     Close()ed or Close()ed).  This means that the calling Node and the
10073    ///     node_ref Node _may_ have both their constraints apply during
10074    ///     constraints aggregation of the logical allocation, if both Node(s)
10075    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
10076    ///     In this case, there is no BufferCollectionTokenGroup that will
10077    ///     directly prevent the two Node(s) from both being selected and their
10078    ///     constraints both aggregated, but even when false, one or both
10079    ///     Node(s) may still be eliminated from consideration if one or both
10080    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
10081    ///     which selects a child sub-tree other than the sub-tree containing
10082    ///     the calling Node or node_ref Node.
10083    IsAlternateFor { node_ref: fidl::Event, responder: NodeIsAlternateForResponder },
10084}
10085
10086impl NodeRequest {
10087    #[allow(irrefutable_let_patterns)]
10088    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
10089        if let NodeRequest::Sync { responder } = self {
10090            Some((responder))
10091        } else {
10092            None
10093        }
10094    }
10095
10096    #[allow(irrefutable_let_patterns)]
10097    pub fn into_close(self) -> Option<(NodeControlHandle)> {
10098        if let NodeRequest::Close { control_handle } = self {
10099            Some((control_handle))
10100        } else {
10101            None
10102        }
10103    }
10104
10105    #[allow(irrefutable_let_patterns)]
10106    pub fn into_set_name(self) -> Option<(u32, String, NodeControlHandle)> {
10107        if let NodeRequest::SetName { priority, name, control_handle } = self {
10108            Some((priority, name, control_handle))
10109        } else {
10110            None
10111        }
10112    }
10113
10114    #[allow(irrefutable_let_patterns)]
10115    pub fn into_set_debug_client_info(self) -> Option<(String, u64, NodeControlHandle)> {
10116        if let NodeRequest::SetDebugClientInfo { name, id, control_handle } = self {
10117            Some((name, id, control_handle))
10118        } else {
10119            None
10120        }
10121    }
10122
10123    #[allow(irrefutable_let_patterns)]
10124    pub fn into_set_debug_timeout_log_deadline(self) -> Option<(i64, NodeControlHandle)> {
10125        if let NodeRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } = self {
10126            Some((deadline, control_handle))
10127        } else {
10128            None
10129        }
10130    }
10131
10132    #[allow(irrefutable_let_patterns)]
10133    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
10134        if let NodeRequest::SetVerboseLogging { control_handle } = self {
10135            Some((control_handle))
10136        } else {
10137            None
10138        }
10139    }
10140
10141    #[allow(irrefutable_let_patterns)]
10142    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
10143        if let NodeRequest::GetNodeRef { responder } = self {
10144            Some((responder))
10145        } else {
10146            None
10147        }
10148    }
10149
10150    #[allow(irrefutable_let_patterns)]
10151    pub fn into_is_alternate_for(self) -> Option<(fidl::Event, NodeIsAlternateForResponder)> {
10152        if let NodeRequest::IsAlternateFor { node_ref, responder } = self {
10153            Some((node_ref, responder))
10154        } else {
10155            None
10156        }
10157    }
10158
10159    /// Name of the method defined in FIDL
10160    pub fn method_name(&self) -> &'static str {
10161        match *self {
10162            NodeRequest::Sync { .. } => "sync",
10163            NodeRequest::Close { .. } => "close",
10164            NodeRequest::SetName { .. } => "set_name",
10165            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
10166            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
10167            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
10168            NodeRequest::GetNodeRef { .. } => "get_node_ref",
10169            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
10170        }
10171    }
10172}
10173
10174#[derive(Debug, Clone)]
10175pub struct NodeControlHandle {
10176    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10177}
10178
10179impl fidl::endpoints::ControlHandle for NodeControlHandle {
10180    fn shutdown(&self) {
10181        self.inner.shutdown()
10182    }
10183    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10184        self.inner.shutdown_with_epitaph(status)
10185    }
10186
10187    fn is_closed(&self) -> bool {
10188        self.inner.channel().is_closed()
10189    }
10190    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10191        self.inner.channel().on_closed()
10192    }
10193
10194    #[cfg(target_os = "fuchsia")]
10195    fn signal_peer(
10196        &self,
10197        clear_mask: zx::Signals,
10198        set_mask: zx::Signals,
10199    ) -> Result<(), zx_status::Status> {
10200        use fidl::Peered;
10201        self.inner.channel().signal_peer(clear_mask, set_mask)
10202    }
10203}
10204
10205impl NodeControlHandle {}
10206
10207#[must_use = "FIDL methods require a response to be sent"]
10208#[derive(Debug)]
10209pub struct NodeSyncResponder {
10210    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10211    tx_id: u32,
10212}
10213
10214/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10215/// if the responder is dropped without sending a response, so that the client
10216/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10217impl std::ops::Drop for NodeSyncResponder {
10218    fn drop(&mut self) {
10219        self.control_handle.shutdown();
10220        // Safety: drops once, never accessed again
10221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10222    }
10223}
10224
10225impl fidl::endpoints::Responder for NodeSyncResponder {
10226    type ControlHandle = NodeControlHandle;
10227
10228    fn control_handle(&self) -> &NodeControlHandle {
10229        &self.control_handle
10230    }
10231
10232    fn drop_without_shutdown(mut self) {
10233        // Safety: drops once, never accessed again due to mem::forget
10234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10235        // Prevent Drop from running (which would shut down the channel)
10236        std::mem::forget(self);
10237    }
10238}
10239
10240impl NodeSyncResponder {
10241    /// Sends a response to the FIDL transaction.
10242    ///
10243    /// Sets the channel to shutdown if an error occurs.
10244    pub fn send(self) -> Result<(), fidl::Error> {
10245        let _result = self.send_raw();
10246        if _result.is_err() {
10247            self.control_handle.shutdown();
10248        }
10249        self.drop_without_shutdown();
10250        _result
10251    }
10252
10253    /// Similar to "send" but does not shutdown the channel if an error occurs.
10254    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10255        let _result = self.send_raw();
10256        self.drop_without_shutdown();
10257        _result
10258    }
10259
10260    fn send_raw(&self) -> Result<(), fidl::Error> {
10261        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10262            (),
10263            self.tx_id,
10264            0x4577e238ae26291,
10265            fidl::encoding::DynamicFlags::empty(),
10266        )
10267    }
10268}
10269
10270#[must_use = "FIDL methods require a response to be sent"]
10271#[derive(Debug)]
10272pub struct NodeGetNodeRefResponder {
10273    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10274    tx_id: u32,
10275}
10276
10277/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10278/// if the responder is dropped without sending a response, so that the client
10279/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10280impl std::ops::Drop for NodeGetNodeRefResponder {
10281    fn drop(&mut self) {
10282        self.control_handle.shutdown();
10283        // Safety: drops once, never accessed again
10284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10285    }
10286}
10287
10288impl fidl::endpoints::Responder for NodeGetNodeRefResponder {
10289    type ControlHandle = NodeControlHandle;
10290
10291    fn control_handle(&self) -> &NodeControlHandle {
10292        &self.control_handle
10293    }
10294
10295    fn drop_without_shutdown(mut self) {
10296        // Safety: drops once, never accessed again due to mem::forget
10297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10298        // Prevent Drop from running (which would shut down the channel)
10299        std::mem::forget(self);
10300    }
10301}
10302
10303impl NodeGetNodeRefResponder {
10304    /// Sends a response to the FIDL transaction.
10305    ///
10306    /// Sets the channel to shutdown if an error occurs.
10307    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10308        let _result = self.send_raw(node_ref);
10309        if _result.is_err() {
10310            self.control_handle.shutdown();
10311        }
10312        self.drop_without_shutdown();
10313        _result
10314    }
10315
10316    /// Similar to "send" but does not shutdown the channel if an error occurs.
10317    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10318        let _result = self.send_raw(node_ref);
10319        self.drop_without_shutdown();
10320        _result
10321    }
10322
10323    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10324        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
10325            (node_ref,),
10326            self.tx_id,
10327            0x467b7c75c35c3b84,
10328            fidl::encoding::DynamicFlags::empty(),
10329        )
10330    }
10331}
10332
10333#[must_use = "FIDL methods require a response to be sent"]
10334#[derive(Debug)]
10335pub struct NodeIsAlternateForResponder {
10336    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10337    tx_id: u32,
10338}
10339
10340/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10341/// if the responder is dropped without sending a response, so that the client
10342/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10343impl std::ops::Drop for NodeIsAlternateForResponder {
10344    fn drop(&mut self) {
10345        self.control_handle.shutdown();
10346        // Safety: drops once, never accessed again
10347        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10348    }
10349}
10350
10351impl fidl::endpoints::Responder for NodeIsAlternateForResponder {
10352    type ControlHandle = NodeControlHandle;
10353
10354    fn control_handle(&self) -> &NodeControlHandle {
10355        &self.control_handle
10356    }
10357
10358    fn drop_without_shutdown(mut self) {
10359        // Safety: drops once, never accessed again due to mem::forget
10360        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10361        // Prevent Drop from running (which would shut down the channel)
10362        std::mem::forget(self);
10363    }
10364}
10365
10366impl NodeIsAlternateForResponder {
10367    /// Sends a response to the FIDL transaction.
10368    ///
10369    /// Sets the channel to shutdown if an error occurs.
10370    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10371        let _result = self.send_raw(result);
10372        if _result.is_err() {
10373            self.control_handle.shutdown();
10374        }
10375        self.drop_without_shutdown();
10376        _result
10377    }
10378
10379    /// Similar to "send" but does not shutdown the channel if an error occurs.
10380    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10381        let _result = self.send_raw(result);
10382        self.drop_without_shutdown();
10383        _result
10384    }
10385
10386    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10387        self.control_handle
10388            .inner
10389            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
10390                result.map(|is_alternate| (is_alternate,)),
10391                self.tx_id,
10392                0x33a2a7aff2776c07,
10393                fidl::encoding::DynamicFlags::empty(),
10394            )
10395    }
10396}
10397
10398#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10399pub struct SecureMemMarker;
10400
10401impl fidl::endpoints::ProtocolMarker for SecureMemMarker {
10402    type Proxy = SecureMemProxy;
10403    type RequestStream = SecureMemRequestStream;
10404    #[cfg(target_os = "fuchsia")]
10405    type SynchronousProxy = SecureMemSynchronousProxy;
10406
10407    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
10408}
10409pub type SecureMemGetPhysicalSecureHeapsResult = Result<SecureHeapsAndRanges, i32>;
10410pub type SecureMemGetPhysicalSecureHeapPropertiesResult = Result<SecureHeapProperties, i32>;
10411pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), i32>;
10412pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), i32>;
10413pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), i32>;
10414pub type SecureMemZeroSubRangeResult = Result<(), i32>;
10415
10416pub trait SecureMemProxyInterface: Send + Sync {
10417    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
10418        + Send;
10419    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
10420    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
10421            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
10422        > + Send;
10423    fn r#get_physical_secure_heap_properties(
10424        &self,
10425        entire_heap: &SecureHeapAndRange,
10426    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
10427    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
10428        + Send;
10429    fn r#add_secure_heap_physical_range(
10430        &self,
10431        heap_range: &SecureHeapAndRange,
10432    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
10433    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
10434            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
10435        > + Send;
10436    fn r#delete_secure_heap_physical_range(
10437        &self,
10438        heap_range: &SecureHeapAndRange,
10439    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
10440    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
10441            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
10442        > + Send;
10443    fn r#modify_secure_heap_physical_range(
10444        &self,
10445        range_modification: &SecureHeapAndRangeModification,
10446    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
10447    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
10448        + Send;
10449    fn r#zero_sub_range(
10450        &self,
10451        is_covering_range_explicit: bool,
10452        heap_range: &SecureHeapAndRange,
10453    ) -> Self::ZeroSubRangeResponseFut;
10454}
10455#[derive(Debug)]
10456#[cfg(target_os = "fuchsia")]
10457pub struct SecureMemSynchronousProxy {
10458    client: fidl::client::sync::Client,
10459}
10460
10461#[cfg(target_os = "fuchsia")]
10462impl fidl::endpoints::SynchronousProxy for SecureMemSynchronousProxy {
10463    type Proxy = SecureMemProxy;
10464    type Protocol = SecureMemMarker;
10465
10466    fn from_channel(inner: fidl::Channel) -> Self {
10467        Self::new(inner)
10468    }
10469
10470    fn into_channel(self) -> fidl::Channel {
10471        self.client.into_channel()
10472    }
10473
10474    fn as_channel(&self) -> &fidl::Channel {
10475        self.client.as_channel()
10476    }
10477}
10478
10479#[cfg(target_os = "fuchsia")]
10480impl SecureMemSynchronousProxy {
10481    pub fn new(channel: fidl::Channel) -> Self {
10482        let protocol_name = <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10483        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10484    }
10485
10486    pub fn into_channel(self) -> fidl::Channel {
10487        self.client.into_channel()
10488    }
10489
10490    /// Waits until an event arrives and returns it. It is safe for other
10491    /// threads to make concurrent requests while waiting for an event.
10492    pub fn wait_for_event(
10493        &self,
10494        deadline: zx::MonotonicInstant,
10495    ) -> Result<SecureMemEvent, fidl::Error> {
10496        SecureMemEvent::decode(self.client.wait_for_event(deadline)?)
10497    }
10498
10499    /// Gets the physical address and length of any secure heap whose physical
10500    /// range is configured via the TEE.
10501    ///
10502    /// Presently, these will be fixed physical addresses and lengths, with the
10503    /// location plumbed via the TEE.
10504    ///
10505    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10506    /// when there isn't any special heap-specific per-VMO setup or teardown
10507    /// required.
10508    ///
10509    /// The physical range must be secured/protected by the TEE before the
10510    /// securemem driver responds to this request with success.
10511    ///
10512    /// Sysmem should only call this once.  Returning zero heaps is not a
10513    /// failure.
10514    ///
10515    /// Errors:
10516    ///  * ZX_ERR_BAD_STATE - called more than once.
10517    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10518    ///    with TEE which doesn't generate zx_status_t errors).
10519    ///  * other errors are allowed; any other errors should be treated the same
10520    ///    as ZX_ERR_INTERNAL.
10521    pub fn r#get_physical_secure_heaps(
10522        &self,
10523        ___deadline: zx::MonotonicInstant,
10524    ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
10525        let _response = self.client.send_query::<
10526            fidl::encoding::EmptyPayload,
10527            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
10528        >(
10529            (),
10530            0x782319d6ce7fa05,
10531            fidl::encoding::DynamicFlags::empty(),
10532            ___deadline,
10533        )?;
10534        Ok(_response.map(|x| x.heaps))
10535    }
10536
10537    /// This request from sysmem to the securemem driver gets the properties of
10538    /// a protected/secure heap.
10539    ///
10540    /// This only handles heaps with a single contiguous physical extent.
10541    ///
10542    /// The heap's entire physical range is indicated in case this request needs
10543    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10544    /// temporary HW protection ranges will be deleted before this request
10545    /// completes.
10546    pub fn r#get_physical_secure_heap_properties(
10547        &self,
10548        mut entire_heap: &SecureHeapAndRange,
10549        ___deadline: zx::MonotonicInstant,
10550    ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
10551        let _response = self.client.send_query::<
10552            SecureMemGetPhysicalSecureHeapPropertiesRequest,
10553            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
10554        >(
10555            (entire_heap,),
10556            0x26404e23f1271214,
10557            fidl::encoding::DynamicFlags::empty(),
10558            ___deadline,
10559        )?;
10560        Ok(_response.map(|x| x.properties))
10561    }
10562
10563    /// This request from sysmem to the securemem driver conveys a physical
10564    /// range to add, for a heap whose physical range(s) are set up via
10565    /// sysmem.
10566    ///
10567    /// Only sysmem can call this because only sysmem is handed the client end
10568    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10569    /// securemem driver is the server end of this protocol.
10570    ///
10571    /// The securemem driver must configure all the covered offsets as protected
10572    /// before responding to this message with success.
10573    ///
10574    /// On failure, the securemem driver must ensure the protected range was not
10575    /// created.
10576    ///
10577    /// Sysmem must only call this up to once if dynamic_protection_ranges
10578    /// false.
10579    ///
10580    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10581    /// times as long as the current number of ranges never exceeds
10582    /// max_protected_range_count.
10583    ///
10584    /// The caller must not attempt to add a range that matches an
10585    /// already-existing range.  Added ranges can overlap each other as long as
10586    /// no two ranges match exactly.
10587    ///
10588    /// Errors:
10589    ///   * ZX_ERR_BAD_STATE - called more than once when
10590    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10591    ///     heap count to exceed max_protected_range_count.
10592    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10593    ///     to protected_range_granularity.
10594    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10595    ///     with TEE which doesn't generate zx_status_t errors).
10596    ///   * other errors are possible, such as from communication failures or
10597    ///     server propagation of zx_status_t failures.
10598    pub fn r#add_secure_heap_physical_range(
10599        &self,
10600        mut heap_range: &SecureHeapAndRange,
10601        ___deadline: zx::MonotonicInstant,
10602    ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
10603        let _response = self.client.send_query::<
10604            SecureMemAddSecureHeapPhysicalRangeRequest,
10605            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10606        >(
10607            (heap_range,),
10608            0x1ca1abcee8a0b33e,
10609            fidl::encoding::DynamicFlags::empty(),
10610            ___deadline,
10611        )?;
10612        Ok(_response.map(|x| x))
10613    }
10614
10615    /// This request from sysmem to the securemem driver conveys a physical
10616    /// range to delete, for a heap whose physical range(s) are set up via
10617    /// sysmem.
10618    ///
10619    /// Only sysmem can call this because only sysmem is handed the client end
10620    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10621    /// securemem driver is the server end of this protocol.
10622    ///
10623    /// The securemem driver must configure all the covered offsets as not
10624    /// protected before responding to this message with success.
10625    ///
10626    /// On failure, the securemem driver must ensure the protected range was not
10627    /// deleted.
10628    ///
10629    /// Sysmem must not call this if dynamic_protection_ranges false.
10630    ///
10631    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10632    /// on various ranges that exist at the time of the call.
10633    ///
10634    /// If any portion of the range being deleted is not also covered by another
10635    /// protected range, then any ongoing DMA to any part of the entire range
10636    /// may be interrupted / may fail, potentially in a way that's disruptive to
10637    /// the entire system (bus lockup or similar, depending on device details).
10638    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10639    /// any portion of the range being deleted, unless the caller has other
10640    /// active ranges covering every block of the range being deleted.  Ongoing
10641    /// DMA to/from blocks outside the range being deleted is never impacted by
10642    /// the deletion.
10643    ///
10644    /// Errors:
10645    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10646    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10647    ///     to protected_range_granularity.
10648    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10649    ///     with TEE which doesn't generate zx_status_t errors).
10650    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10651    ///   * other errors are possible, such as from communication failures or
10652    ///     server propagation of zx_status_t failures.
10653    pub fn r#delete_secure_heap_physical_range(
10654        &self,
10655        mut heap_range: &SecureHeapAndRange,
10656        ___deadline: zx::MonotonicInstant,
10657    ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
10658        let _response = self.client.send_query::<
10659            SecureMemDeleteSecureHeapPhysicalRangeRequest,
10660            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10661        >(
10662            (heap_range,),
10663            0x728a953e56df92ee,
10664            fidl::encoding::DynamicFlags::empty(),
10665            ___deadline,
10666        )?;
10667        Ok(_response.map(|x| x))
10668    }
10669
10670    /// This request from sysmem to the securemem driver conveys a physical
10671    /// range to modify and its new base and length, for a heap whose physical
10672    /// range(s) are set up via sysmem.
10673    ///
10674    /// Only sysmem can call this because only sysmem is handed the client end
10675    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10676    /// securemem driver is the server end of this protocol.
10677    ///
10678    /// The securemem driver must configure the range to cover only the new
10679    /// offsets before responding to this message with success.
10680    ///
10681    /// On failure, the securemem driver must ensure the range was not changed.
10682    ///
10683    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10684    /// must not call this if !is_mod_protected_range_available.
10685    ///
10686    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10687    /// on various ranges that exist at the time of the call.
10688    ///
10689    /// The range must only be modified at one end or the other, but not both.
10690    /// If the range is getting shorter, and the un-covered blocks are not
10691    /// covered by other active ranges, any ongoing DMA to the entire range
10692    /// that's geting shorter may fail in a way that disrupts the entire system
10693    /// (bus lockup or similar), so the caller must ensure that no DMA is
10694    /// ongoing to any portion of a range that is getting shorter, unless the
10695    /// blocks being un-covered by the modification to this range are all
10696    /// covered by other active ranges, in which case no disruption to ongoing
10697    /// DMA will occur.
10698    ///
10699    /// If a range is modified to become <= zero length, the range is deleted.
10700    ///
10701    /// Errors:
10702    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10703    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
10704    ///     that doesn't conform to protected_range_granularity, or old_range
10705    ///     and new_range differ in both begin and end (disallowed).
10706    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10707    ///     with TEE which doesn't generate zx_status_t errors).
10708    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10709    ///   * other errors are possible, such as from communication failures or
10710    ///     server propagation of zx_status_t failures.
10711    pub fn r#modify_secure_heap_physical_range(
10712        &self,
10713        mut range_modification: &SecureHeapAndRangeModification,
10714        ___deadline: zx::MonotonicInstant,
10715    ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
10716        let _response = self.client.send_query::<
10717            SecureMemModifySecureHeapPhysicalRangeRequest,
10718            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10719        >(
10720            (range_modification,),
10721            0x154fbfa3646a890d,
10722            fidl::encoding::DynamicFlags::empty(),
10723            ___deadline,
10724        )?;
10725        Ok(_response.map(|x| x))
10726    }
10727
10728    /// Zero a sub-range of a currently-existing physical range added via
10729    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
10730    /// exactly one physical range, and must not overlap with any other
10731    /// physical range.
10732    ///
10733    /// is_covering_range_explicit - When true, the covering range must be one
10734    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
10735    ///     possibly modified since.  When false, the covering range must not
10736    ///     be one of the ranges explicitly created via
10737    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
10738    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
10739    ///     covering range is typically the entire physical range (or a range
10740    ///     which covers even more) of a heap configured by the TEE and whose
10741    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
10742    ///
10743    /// Ongoing DMA is not disrupted by this request.
10744    pub fn r#zero_sub_range(
10745        &self,
10746        mut is_covering_range_explicit: bool,
10747        mut heap_range: &SecureHeapAndRange,
10748        ___deadline: zx::MonotonicInstant,
10749    ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
10750        let _response = self.client.send_query::<
10751            SecureMemZeroSubRangeRequest,
10752            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10753        >(
10754            (is_covering_range_explicit, heap_range,),
10755            0x7480f72bb5bc7e5b,
10756            fidl::encoding::DynamicFlags::empty(),
10757            ___deadline,
10758        )?;
10759        Ok(_response.map(|x| x))
10760    }
10761}
10762
10763#[cfg(target_os = "fuchsia")]
10764impl From<SecureMemSynchronousProxy> for zx::Handle {
10765    fn from(value: SecureMemSynchronousProxy) -> Self {
10766        value.into_channel().into()
10767    }
10768}
10769
10770#[cfg(target_os = "fuchsia")]
10771impl From<fidl::Channel> for SecureMemSynchronousProxy {
10772    fn from(value: fidl::Channel) -> Self {
10773        Self::new(value)
10774    }
10775}
10776
10777#[cfg(target_os = "fuchsia")]
10778impl fidl::endpoints::FromClient for SecureMemSynchronousProxy {
10779    type Protocol = SecureMemMarker;
10780
10781    fn from_client(value: fidl::endpoints::ClientEnd<SecureMemMarker>) -> Self {
10782        Self::new(value.into_channel())
10783    }
10784}
10785
10786#[derive(Debug, Clone)]
10787pub struct SecureMemProxy {
10788    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10789}
10790
10791impl fidl::endpoints::Proxy for SecureMemProxy {
10792    type Protocol = SecureMemMarker;
10793
10794    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10795        Self::new(inner)
10796    }
10797
10798    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10799        self.client.into_channel().map_err(|client| Self { client })
10800    }
10801
10802    fn as_channel(&self) -> &::fidl::AsyncChannel {
10803        self.client.as_channel()
10804    }
10805}
10806
10807impl SecureMemProxy {
10808    /// Create a new Proxy for fuchsia.sysmem/SecureMem.
10809    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10810        let protocol_name = <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10811        Self { client: fidl::client::Client::new(channel, protocol_name) }
10812    }
10813
10814    /// Get a Stream of events from the remote end of the protocol.
10815    ///
10816    /// # Panics
10817    ///
10818    /// Panics if the event stream was already taken.
10819    pub fn take_event_stream(&self) -> SecureMemEventStream {
10820        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
10821    }
10822
10823    /// Gets the physical address and length of any secure heap whose physical
10824    /// range is configured via the TEE.
10825    ///
10826    /// Presently, these will be fixed physical addresses and lengths, with the
10827    /// location plumbed via the TEE.
10828    ///
10829    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10830    /// when there isn't any special heap-specific per-VMO setup or teardown
10831    /// required.
10832    ///
10833    /// The physical range must be secured/protected by the TEE before the
10834    /// securemem driver responds to this request with success.
10835    ///
10836    /// Sysmem should only call this once.  Returning zero heaps is not a
10837    /// failure.
10838    ///
10839    /// Errors:
10840    ///  * ZX_ERR_BAD_STATE - called more than once.
10841    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10842    ///    with TEE which doesn't generate zx_status_t errors).
10843    ///  * other errors are allowed; any other errors should be treated the same
10844    ///    as ZX_ERR_INTERNAL.
10845    pub fn r#get_physical_secure_heaps(
10846        &self,
10847    ) -> fidl::client::QueryResponseFut<
10848        SecureMemGetPhysicalSecureHeapsResult,
10849        fidl::encoding::DefaultFuchsiaResourceDialect,
10850    > {
10851        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
10852    }
10853
10854    /// This request from sysmem to the securemem driver gets the properties of
10855    /// a protected/secure heap.
10856    ///
10857    /// This only handles heaps with a single contiguous physical extent.
10858    ///
10859    /// The heap's entire physical range is indicated in case this request needs
10860    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10861    /// temporary HW protection ranges will be deleted before this request
10862    /// completes.
10863    pub fn r#get_physical_secure_heap_properties(
10864        &self,
10865        mut entire_heap: &SecureHeapAndRange,
10866    ) -> fidl::client::QueryResponseFut<
10867        SecureMemGetPhysicalSecureHeapPropertiesResult,
10868        fidl::encoding::DefaultFuchsiaResourceDialect,
10869    > {
10870        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, entire_heap)
10871    }
10872
10873    /// This request from sysmem to the securemem driver conveys a physical
10874    /// range to add, for a heap whose physical range(s) are set up via
10875    /// sysmem.
10876    ///
10877    /// Only sysmem can call this because only sysmem is handed the client end
10878    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10879    /// securemem driver is the server end of this protocol.
10880    ///
10881    /// The securemem driver must configure all the covered offsets as protected
10882    /// before responding to this message with success.
10883    ///
10884    /// On failure, the securemem driver must ensure the protected range was not
10885    /// created.
10886    ///
10887    /// Sysmem must only call this up to once if dynamic_protection_ranges
10888    /// false.
10889    ///
10890    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10891    /// times as long as the current number of ranges never exceeds
10892    /// max_protected_range_count.
10893    ///
10894    /// The caller must not attempt to add a range that matches an
10895    /// already-existing range.  Added ranges can overlap each other as long as
10896    /// no two ranges match exactly.
10897    ///
10898    /// Errors:
10899    ///   * ZX_ERR_BAD_STATE - called more than once when
10900    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10901    ///     heap count to exceed max_protected_range_count.
10902    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10903    ///     to protected_range_granularity.
10904    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10905    ///     with TEE which doesn't generate zx_status_t errors).
10906    ///   * other errors are possible, such as from communication failures or
10907    ///     server propagation of zx_status_t failures.
10908    pub fn r#add_secure_heap_physical_range(
10909        &self,
10910        mut heap_range: &SecureHeapAndRange,
10911    ) -> fidl::client::QueryResponseFut<
10912        SecureMemAddSecureHeapPhysicalRangeResult,
10913        fidl::encoding::DefaultFuchsiaResourceDialect,
10914    > {
10915        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, heap_range)
10916    }
10917
10918    /// This request from sysmem to the securemem driver conveys a physical
10919    /// range to delete, for a heap whose physical range(s) are set up via
10920    /// sysmem.
10921    ///
10922    /// Only sysmem can call this because only sysmem is handed the client end
10923    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10924    /// securemem driver is the server end of this protocol.
10925    ///
10926    /// The securemem driver must configure all the covered offsets as not
10927    /// protected before responding to this message with success.
10928    ///
10929    /// On failure, the securemem driver must ensure the protected range was not
10930    /// deleted.
10931    ///
10932    /// Sysmem must not call this if dynamic_protection_ranges false.
10933    ///
10934    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10935    /// on various ranges that exist at the time of the call.
10936    ///
10937    /// If any portion of the range being deleted is not also covered by another
10938    /// protected range, then any ongoing DMA to any part of the entire range
10939    /// may be interrupted / may fail, potentially in a way that's disruptive to
10940    /// the entire system (bus lockup or similar, depending on device details).
10941    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10942    /// any portion of the range being deleted, unless the caller has other
10943    /// active ranges covering every block of the range being deleted.  Ongoing
10944    /// DMA to/from blocks outside the range being deleted is never impacted by
10945    /// the deletion.
10946    ///
10947    /// Errors:
10948    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10949    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10950    ///     to protected_range_granularity.
10951    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10952    ///     with TEE which doesn't generate zx_status_t errors).
10953    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10954    ///   * other errors are possible, such as from communication failures or
10955    ///     server propagation of zx_status_t failures.
10956    pub fn r#delete_secure_heap_physical_range(
10957        &self,
10958        mut heap_range: &SecureHeapAndRange,
10959    ) -> fidl::client::QueryResponseFut<
10960        SecureMemDeleteSecureHeapPhysicalRangeResult,
10961        fidl::encoding::DefaultFuchsiaResourceDialect,
10962    > {
10963        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, heap_range)
10964    }
10965
10966    /// This request from sysmem to the securemem driver conveys a physical
10967    /// range to modify and its new base and length, for a heap whose physical
10968    /// range(s) are set up via sysmem.
10969    ///
10970    /// Only sysmem can call this because only sysmem is handed the client end
10971    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10972    /// securemem driver is the server end of this protocol.
10973    ///
10974    /// The securemem driver must configure the range to cover only the new
10975    /// offsets before responding to this message with success.
10976    ///
10977    /// On failure, the securemem driver must ensure the range was not changed.
10978    ///
10979    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10980    /// must not call this if !is_mod_protected_range_available.
10981    ///
10982    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10983    /// on various ranges that exist at the time of the call.
10984    ///
10985    /// The range must only be modified at one end or the other, but not both.
10986    /// If the range is getting shorter, and the un-covered blocks are not
10987    /// covered by other active ranges, any ongoing DMA to the entire range
10988    /// that's geting shorter may fail in a way that disrupts the entire system
10989    /// (bus lockup or similar), so the caller must ensure that no DMA is
10990    /// ongoing to any portion of a range that is getting shorter, unless the
10991    /// blocks being un-covered by the modification to this range are all
10992    /// covered by other active ranges, in which case no disruption to ongoing
10993    /// DMA will occur.
10994    ///
10995    /// If a range is modified to become <= zero length, the range is deleted.
10996    ///
10997    /// Errors:
10998    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10999    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
11000    ///     that doesn't conform to protected_range_granularity, or old_range
11001    ///     and new_range differ in both begin and end (disallowed).
11002    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11003    ///     with TEE which doesn't generate zx_status_t errors).
11004    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11005    ///   * other errors are possible, such as from communication failures or
11006    ///     server propagation of zx_status_t failures.
11007    pub fn r#modify_secure_heap_physical_range(
11008        &self,
11009        mut range_modification: &SecureHeapAndRangeModification,
11010    ) -> fidl::client::QueryResponseFut<
11011        SecureMemModifySecureHeapPhysicalRangeResult,
11012        fidl::encoding::DefaultFuchsiaResourceDialect,
11013    > {
11014        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, range_modification)
11015    }
11016
11017    /// Zero a sub-range of a currently-existing physical range added via
11018    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11019    /// exactly one physical range, and must not overlap with any other
11020    /// physical range.
11021    ///
11022    /// is_covering_range_explicit - When true, the covering range must be one
11023    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11024    ///     possibly modified since.  When false, the covering range must not
11025    ///     be one of the ranges explicitly created via
11026    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11027    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11028    ///     covering range is typically the entire physical range (or a range
11029    ///     which covers even more) of a heap configured by the TEE and whose
11030    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11031    ///
11032    /// Ongoing DMA is not disrupted by this request.
11033    pub fn r#zero_sub_range(
11034        &self,
11035        mut is_covering_range_explicit: bool,
11036        mut heap_range: &SecureHeapAndRange,
11037    ) -> fidl::client::QueryResponseFut<
11038        SecureMemZeroSubRangeResult,
11039        fidl::encoding::DefaultFuchsiaResourceDialect,
11040    > {
11041        SecureMemProxyInterface::r#zero_sub_range(self, is_covering_range_explicit, heap_range)
11042    }
11043}
11044
11045impl SecureMemProxyInterface for SecureMemProxy {
11046    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11047        SecureMemGetPhysicalSecureHeapsResult,
11048        fidl::encoding::DefaultFuchsiaResourceDialect,
11049    >;
11050    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
11051        fn _decode(
11052            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11053        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
11054            let _response = fidl::client::decode_transaction_body::<
11055                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
11056                fidl::encoding::DefaultFuchsiaResourceDialect,
11057                0x782319d6ce7fa05,
11058            >(_buf?)?;
11059            Ok(_response.map(|x| x.heaps))
11060        }
11061        self.client.send_query_and_decode::<
11062            fidl::encoding::EmptyPayload,
11063            SecureMemGetPhysicalSecureHeapsResult,
11064        >(
11065            (),
11066            0x782319d6ce7fa05,
11067            fidl::encoding::DynamicFlags::empty(),
11068            _decode,
11069        )
11070    }
11071
11072    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
11073        SecureMemGetPhysicalSecureHeapPropertiesResult,
11074        fidl::encoding::DefaultFuchsiaResourceDialect,
11075    >;
11076    fn r#get_physical_secure_heap_properties(
11077        &self,
11078        mut entire_heap: &SecureHeapAndRange,
11079    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
11080        fn _decode(
11081            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11082        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
11083            let _response = fidl::client::decode_transaction_body::<
11084                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
11085                fidl::encoding::DefaultFuchsiaResourceDialect,
11086                0x26404e23f1271214,
11087            >(_buf?)?;
11088            Ok(_response.map(|x| x.properties))
11089        }
11090        self.client.send_query_and_decode::<
11091            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11092            SecureMemGetPhysicalSecureHeapPropertiesResult,
11093        >(
11094            (entire_heap,),
11095            0x26404e23f1271214,
11096            fidl::encoding::DynamicFlags::empty(),
11097            _decode,
11098        )
11099    }
11100
11101    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11102        SecureMemAddSecureHeapPhysicalRangeResult,
11103        fidl::encoding::DefaultFuchsiaResourceDialect,
11104    >;
11105    fn r#add_secure_heap_physical_range(
11106        &self,
11107        mut heap_range: &SecureHeapAndRange,
11108    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
11109        fn _decode(
11110            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11111        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
11112            let _response = fidl::client::decode_transaction_body::<
11113                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11114                fidl::encoding::DefaultFuchsiaResourceDialect,
11115                0x1ca1abcee8a0b33e,
11116            >(_buf?)?;
11117            Ok(_response.map(|x| x))
11118        }
11119        self.client.send_query_and_decode::<
11120            SecureMemAddSecureHeapPhysicalRangeRequest,
11121            SecureMemAddSecureHeapPhysicalRangeResult,
11122        >(
11123            (heap_range,),
11124            0x1ca1abcee8a0b33e,
11125            fidl::encoding::DynamicFlags::empty(),
11126            _decode,
11127        )
11128    }
11129
11130    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11131        SecureMemDeleteSecureHeapPhysicalRangeResult,
11132        fidl::encoding::DefaultFuchsiaResourceDialect,
11133    >;
11134    fn r#delete_secure_heap_physical_range(
11135        &self,
11136        mut heap_range: &SecureHeapAndRange,
11137    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
11138        fn _decode(
11139            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11140        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
11141            let _response = fidl::client::decode_transaction_body::<
11142                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11143                fidl::encoding::DefaultFuchsiaResourceDialect,
11144                0x728a953e56df92ee,
11145            >(_buf?)?;
11146            Ok(_response.map(|x| x))
11147        }
11148        self.client.send_query_and_decode::<
11149            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11150            SecureMemDeleteSecureHeapPhysicalRangeResult,
11151        >(
11152            (heap_range,),
11153            0x728a953e56df92ee,
11154            fidl::encoding::DynamicFlags::empty(),
11155            _decode,
11156        )
11157    }
11158
11159    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11160        SecureMemModifySecureHeapPhysicalRangeResult,
11161        fidl::encoding::DefaultFuchsiaResourceDialect,
11162    >;
11163    fn r#modify_secure_heap_physical_range(
11164        &self,
11165        mut range_modification: &SecureHeapAndRangeModification,
11166    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
11167        fn _decode(
11168            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11169        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
11170            let _response = fidl::client::decode_transaction_body::<
11171                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11172                fidl::encoding::DefaultFuchsiaResourceDialect,
11173                0x154fbfa3646a890d,
11174            >(_buf?)?;
11175            Ok(_response.map(|x| x))
11176        }
11177        self.client.send_query_and_decode::<
11178            SecureMemModifySecureHeapPhysicalRangeRequest,
11179            SecureMemModifySecureHeapPhysicalRangeResult,
11180        >(
11181            (range_modification,),
11182            0x154fbfa3646a890d,
11183            fidl::encoding::DynamicFlags::empty(),
11184            _decode,
11185        )
11186    }
11187
11188    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
11189        SecureMemZeroSubRangeResult,
11190        fidl::encoding::DefaultFuchsiaResourceDialect,
11191    >;
11192    fn r#zero_sub_range(
11193        &self,
11194        mut is_covering_range_explicit: bool,
11195        mut heap_range: &SecureHeapAndRange,
11196    ) -> Self::ZeroSubRangeResponseFut {
11197        fn _decode(
11198            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11199        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
11200            let _response = fidl::client::decode_transaction_body::<
11201                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11202                fidl::encoding::DefaultFuchsiaResourceDialect,
11203                0x7480f72bb5bc7e5b,
11204            >(_buf?)?;
11205            Ok(_response.map(|x| x))
11206        }
11207        self.client
11208            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
11209                (is_covering_range_explicit, heap_range),
11210                0x7480f72bb5bc7e5b,
11211                fidl::encoding::DynamicFlags::empty(),
11212                _decode,
11213            )
11214    }
11215}
11216
11217pub struct SecureMemEventStream {
11218    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11219}
11220
11221impl std::marker::Unpin for SecureMemEventStream {}
11222
11223impl futures::stream::FusedStream for SecureMemEventStream {
11224    fn is_terminated(&self) -> bool {
11225        self.event_receiver.is_terminated()
11226    }
11227}
11228
11229impl futures::Stream for SecureMemEventStream {
11230    type Item = Result<SecureMemEvent, fidl::Error>;
11231
11232    fn poll_next(
11233        mut self: std::pin::Pin<&mut Self>,
11234        cx: &mut std::task::Context<'_>,
11235    ) -> std::task::Poll<Option<Self::Item>> {
11236        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11237            &mut self.event_receiver,
11238            cx
11239        )?) {
11240            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
11241            None => std::task::Poll::Ready(None),
11242        }
11243    }
11244}
11245
11246#[derive(Debug)]
11247pub enum SecureMemEvent {}
11248
11249impl SecureMemEvent {
11250    /// Decodes a message buffer as a [`SecureMemEvent`].
11251    fn decode(
11252        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11253    ) -> Result<SecureMemEvent, fidl::Error> {
11254        let (bytes, _handles) = buf.split_mut();
11255        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11256        debug_assert_eq!(tx_header.tx_id, 0);
11257        match tx_header.ordinal {
11258            _ => Err(fidl::Error::UnknownOrdinal {
11259                ordinal: tx_header.ordinal,
11260                protocol_name: <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11261            }),
11262        }
11263    }
11264}
11265
11266/// A Stream of incoming requests for fuchsia.sysmem/SecureMem.
11267pub struct SecureMemRequestStream {
11268    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11269    is_terminated: bool,
11270}
11271
11272impl std::marker::Unpin for SecureMemRequestStream {}
11273
11274impl futures::stream::FusedStream for SecureMemRequestStream {
11275    fn is_terminated(&self) -> bool {
11276        self.is_terminated
11277    }
11278}
11279
11280impl fidl::endpoints::RequestStream for SecureMemRequestStream {
11281    type Protocol = SecureMemMarker;
11282    type ControlHandle = SecureMemControlHandle;
11283
11284    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11285        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11286    }
11287
11288    fn control_handle(&self) -> Self::ControlHandle {
11289        SecureMemControlHandle { inner: self.inner.clone() }
11290    }
11291
11292    fn into_inner(
11293        self,
11294    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11295    {
11296        (self.inner, self.is_terminated)
11297    }
11298
11299    fn from_inner(
11300        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11301        is_terminated: bool,
11302    ) -> Self {
11303        Self { inner, is_terminated }
11304    }
11305}
11306
11307impl futures::Stream for SecureMemRequestStream {
11308    type Item = Result<SecureMemRequest, fidl::Error>;
11309
11310    fn poll_next(
11311        mut self: std::pin::Pin<&mut Self>,
11312        cx: &mut std::task::Context<'_>,
11313    ) -> std::task::Poll<Option<Self::Item>> {
11314        let this = &mut *self;
11315        if this.inner.check_shutdown(cx) {
11316            this.is_terminated = true;
11317            return std::task::Poll::Ready(None);
11318        }
11319        if this.is_terminated {
11320            panic!("polled SecureMemRequestStream after completion");
11321        }
11322        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11323            |bytes, handles| {
11324                match this.inner.channel().read_etc(cx, bytes, handles) {
11325                    std::task::Poll::Ready(Ok(())) => {}
11326                    std::task::Poll::Pending => return std::task::Poll::Pending,
11327                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11328                        this.is_terminated = true;
11329                        return std::task::Poll::Ready(None);
11330                    }
11331                    std::task::Poll::Ready(Err(e)) => {
11332                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11333                            e.into(),
11334                        ))))
11335                    }
11336                }
11337
11338                // A message has been received from the channel
11339                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11340
11341                std::task::Poll::Ready(Some(match header.ordinal {
11342                    0x782319d6ce7fa05 => {
11343                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11344                        let mut req = fidl::new_empty!(
11345                            fidl::encoding::EmptyPayload,
11346                            fidl::encoding::DefaultFuchsiaResourceDialect
11347                        );
11348                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11349                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11350                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
11351                            responder: SecureMemGetPhysicalSecureHeapsResponder {
11352                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11353                                tx_id: header.tx_id,
11354                            },
11355                        })
11356                    }
11357                    0x26404e23f1271214 => {
11358                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11359                        let mut req = fidl::new_empty!(
11360                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11361                            fidl::encoding::DefaultFuchsiaResourceDialect
11362                        );
11363                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
11364                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11365                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
11366                            entire_heap: req.entire_heap,
11367
11368                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
11369                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11370                                tx_id: header.tx_id,
11371                            },
11372                        })
11373                    }
11374                    0x1ca1abcee8a0b33e => {
11375                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11376                        let mut req = fidl::new_empty!(
11377                            SecureMemAddSecureHeapPhysicalRangeRequest,
11378                            fidl::encoding::DefaultFuchsiaResourceDialect
11379                        );
11380                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11381                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11382                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
11383                            heap_range: req.heap_range,
11384
11385                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
11386                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11387                                tx_id: header.tx_id,
11388                            },
11389                        })
11390                    }
11391                    0x728a953e56df92ee => {
11392                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11393                        let mut req = fidl::new_empty!(
11394                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11395                            fidl::encoding::DefaultFuchsiaResourceDialect
11396                        );
11397                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11398                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11399                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
11400                            heap_range: req.heap_range,
11401
11402                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
11403                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11404                                tx_id: header.tx_id,
11405                            },
11406                        })
11407                    }
11408                    0x154fbfa3646a890d => {
11409                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11410                        let mut req = fidl::new_empty!(
11411                            SecureMemModifySecureHeapPhysicalRangeRequest,
11412                            fidl::encoding::DefaultFuchsiaResourceDialect
11413                        );
11414                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11415                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11416                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
11417                            range_modification: req.range_modification,
11418
11419                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
11420                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11421                                tx_id: header.tx_id,
11422                            },
11423                        })
11424                    }
11425                    0x7480f72bb5bc7e5b => {
11426                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11427                        let mut req = fidl::new_empty!(
11428                            SecureMemZeroSubRangeRequest,
11429                            fidl::encoding::DefaultFuchsiaResourceDialect
11430                        );
11431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11432                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11433                        Ok(SecureMemRequest::ZeroSubRange {
11434                            is_covering_range_explicit: req.is_covering_range_explicit,
11435                            heap_range: req.heap_range,
11436
11437                            responder: SecureMemZeroSubRangeResponder {
11438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11439                                tx_id: header.tx_id,
11440                            },
11441                        })
11442                    }
11443                    _ => Err(fidl::Error::UnknownOrdinal {
11444                        ordinal: header.ordinal,
11445                        protocol_name:
11446                            <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11447                    }),
11448                }))
11449            },
11450        )
11451    }
11452}
11453
11454/// SecureMem
11455///
11456/// The client is sysmem.  The server is securemem driver.
11457///
11458/// TEE - Trusted Execution Environment.
11459///
11460/// REE - Rich Execution Environment.
11461///
11462/// Enables sysmem to call the securemem driver to get any secure heaps
11463/// configured via the TEE (or via the securemem driver), and set any physical
11464/// secure heaps configured via sysmem.
11465///
11466/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
11467/// it starts quite early during boot and can successfully reserve contiguous
11468/// physical memory.  Presently, fixed-location secure heaps are configured via
11469/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
11470/// protocol intentionally doesn't care which heaps are dynamically-allocated
11471/// and which are fixed-location.
11472#[derive(Debug)]
11473pub enum SecureMemRequest {
11474    /// Gets the physical address and length of any secure heap whose physical
11475    /// range is configured via the TEE.
11476    ///
11477    /// Presently, these will be fixed physical addresses and lengths, with the
11478    /// location plumbed via the TEE.
11479    ///
11480    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11481    /// when there isn't any special heap-specific per-VMO setup or teardown
11482    /// required.
11483    ///
11484    /// The physical range must be secured/protected by the TEE before the
11485    /// securemem driver responds to this request with success.
11486    ///
11487    /// Sysmem should only call this once.  Returning zero heaps is not a
11488    /// failure.
11489    ///
11490    /// Errors:
11491    ///  * ZX_ERR_BAD_STATE - called more than once.
11492    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
11493    ///    with TEE which doesn't generate zx_status_t errors).
11494    ///  * other errors are allowed; any other errors should be treated the same
11495    ///    as ZX_ERR_INTERNAL.
11496    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
11497    /// This request from sysmem to the securemem driver gets the properties of
11498    /// a protected/secure heap.
11499    ///
11500    /// This only handles heaps with a single contiguous physical extent.
11501    ///
11502    /// The heap's entire physical range is indicated in case this request needs
11503    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11504    /// temporary HW protection ranges will be deleted before this request
11505    /// completes.
11506    GetPhysicalSecureHeapProperties {
11507        entire_heap: SecureHeapAndRange,
11508        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
11509    },
11510    /// This request from sysmem to the securemem driver conveys a physical
11511    /// range to add, for a heap whose physical range(s) are set up via
11512    /// sysmem.
11513    ///
11514    /// Only sysmem can call this because only sysmem is handed the client end
11515    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11516    /// securemem driver is the server end of this protocol.
11517    ///
11518    /// The securemem driver must configure all the covered offsets as protected
11519    /// before responding to this message with success.
11520    ///
11521    /// On failure, the securemem driver must ensure the protected range was not
11522    /// created.
11523    ///
11524    /// Sysmem must only call this up to once if dynamic_protection_ranges
11525    /// false.
11526    ///
11527    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11528    /// times as long as the current number of ranges never exceeds
11529    /// max_protected_range_count.
11530    ///
11531    /// The caller must not attempt to add a range that matches an
11532    /// already-existing range.  Added ranges can overlap each other as long as
11533    /// no two ranges match exactly.
11534    ///
11535    /// Errors:
11536    ///   * ZX_ERR_BAD_STATE - called more than once when
11537    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11538    ///     heap count to exceed max_protected_range_count.
11539    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11540    ///     to protected_range_granularity.
11541    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11542    ///     with TEE which doesn't generate zx_status_t errors).
11543    ///   * other errors are possible, such as from communication failures or
11544    ///     server propagation of zx_status_t failures.
11545    AddSecureHeapPhysicalRange {
11546        heap_range: SecureHeapAndRange,
11547        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
11548    },
11549    /// This request from sysmem to the securemem driver conveys a physical
11550    /// range to delete, for a heap whose physical range(s) are set up via
11551    /// sysmem.
11552    ///
11553    /// Only sysmem can call this because only sysmem is handed the client end
11554    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11555    /// securemem driver is the server end of this protocol.
11556    ///
11557    /// The securemem driver must configure all the covered offsets as not
11558    /// protected before responding to this message with success.
11559    ///
11560    /// On failure, the securemem driver must ensure the protected range was not
11561    /// deleted.
11562    ///
11563    /// Sysmem must not call this if dynamic_protection_ranges false.
11564    ///
11565    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11566    /// on various ranges that exist at the time of the call.
11567    ///
11568    /// If any portion of the range being deleted is not also covered by another
11569    /// protected range, then any ongoing DMA to any part of the entire range
11570    /// may be interrupted / may fail, potentially in a way that's disruptive to
11571    /// the entire system (bus lockup or similar, depending on device details).
11572    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11573    /// any portion of the range being deleted, unless the caller has other
11574    /// active ranges covering every block of the range being deleted.  Ongoing
11575    /// DMA to/from blocks outside the range being deleted is never impacted by
11576    /// the deletion.
11577    ///
11578    /// Errors:
11579    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11580    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11581    ///     to protected_range_granularity.
11582    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11583    ///     with TEE which doesn't generate zx_status_t errors).
11584    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11585    ///   * other errors are possible, such as from communication failures or
11586    ///     server propagation of zx_status_t failures.
11587    DeleteSecureHeapPhysicalRange {
11588        heap_range: SecureHeapAndRange,
11589        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
11590    },
11591    /// This request from sysmem to the securemem driver conveys a physical
11592    /// range to modify and its new base and length, for a heap whose physical
11593    /// range(s) are set up via sysmem.
11594    ///
11595    /// Only sysmem can call this because only sysmem is handed the client end
11596    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11597    /// securemem driver is the server end of this protocol.
11598    ///
11599    /// The securemem driver must configure the range to cover only the new
11600    /// offsets before responding to this message with success.
11601    ///
11602    /// On failure, the securemem driver must ensure the range was not changed.
11603    ///
11604    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11605    /// must not call this if !is_mod_protected_range_available.
11606    ///
11607    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11608    /// on various ranges that exist at the time of the call.
11609    ///
11610    /// The range must only be modified at one end or the other, but not both.
11611    /// If the range is getting shorter, and the un-covered blocks are not
11612    /// covered by other active ranges, any ongoing DMA to the entire range
11613    /// that's geting shorter may fail in a way that disrupts the entire system
11614    /// (bus lockup or similar), so the caller must ensure that no DMA is
11615    /// ongoing to any portion of a range that is getting shorter, unless the
11616    /// blocks being un-covered by the modification to this range are all
11617    /// covered by other active ranges, in which case no disruption to ongoing
11618    /// DMA will occur.
11619    ///
11620    /// If a range is modified to become <= zero length, the range is deleted.
11621    ///
11622    /// Errors:
11623    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11624    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
11625    ///     that doesn't conform to protected_range_granularity, or old_range
11626    ///     and new_range differ in both begin and end (disallowed).
11627    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11628    ///     with TEE which doesn't generate zx_status_t errors).
11629    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11630    ///   * other errors are possible, such as from communication failures or
11631    ///     server propagation of zx_status_t failures.
11632    ModifySecureHeapPhysicalRange {
11633        range_modification: SecureHeapAndRangeModification,
11634        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
11635    },
11636    /// Zero a sub-range of a currently-existing physical range added via
11637    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11638    /// exactly one physical range, and must not overlap with any other
11639    /// physical range.
11640    ///
11641    /// is_covering_range_explicit - When true, the covering range must be one
11642    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11643    ///     possibly modified since.  When false, the covering range must not
11644    ///     be one of the ranges explicitly created via
11645    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11646    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11647    ///     covering range is typically the entire physical range (or a range
11648    ///     which covers even more) of a heap configured by the TEE and whose
11649    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11650    ///
11651    /// Ongoing DMA is not disrupted by this request.
11652    ZeroSubRange {
11653        is_covering_range_explicit: bool,
11654        heap_range: SecureHeapAndRange,
11655        responder: SecureMemZeroSubRangeResponder,
11656    },
11657}
11658
11659impl SecureMemRequest {
11660    #[allow(irrefutable_let_patterns)]
11661    pub fn into_get_physical_secure_heaps(
11662        self,
11663    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
11664        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
11665            Some((responder))
11666        } else {
11667            None
11668        }
11669    }
11670
11671    #[allow(irrefutable_let_patterns)]
11672    pub fn into_get_physical_secure_heap_properties(
11673        self,
11674    ) -> Option<(SecureHeapAndRange, SecureMemGetPhysicalSecureHeapPropertiesResponder)> {
11675        if let SecureMemRequest::GetPhysicalSecureHeapProperties { entire_heap, responder } = self {
11676            Some((entire_heap, responder))
11677        } else {
11678            None
11679        }
11680    }
11681
11682    #[allow(irrefutable_let_patterns)]
11683    pub fn into_add_secure_heap_physical_range(
11684        self,
11685    ) -> Option<(SecureHeapAndRange, SecureMemAddSecureHeapPhysicalRangeResponder)> {
11686        if let SecureMemRequest::AddSecureHeapPhysicalRange { heap_range, responder } = self {
11687            Some((heap_range, responder))
11688        } else {
11689            None
11690        }
11691    }
11692
11693    #[allow(irrefutable_let_patterns)]
11694    pub fn into_delete_secure_heap_physical_range(
11695        self,
11696    ) -> Option<(SecureHeapAndRange, SecureMemDeleteSecureHeapPhysicalRangeResponder)> {
11697        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { heap_range, responder } = self {
11698            Some((heap_range, responder))
11699        } else {
11700            None
11701        }
11702    }
11703
11704    #[allow(irrefutable_let_patterns)]
11705    pub fn into_modify_secure_heap_physical_range(
11706        self,
11707    ) -> Option<(SecureHeapAndRangeModification, SecureMemModifySecureHeapPhysicalRangeResponder)>
11708    {
11709        if let SecureMemRequest::ModifySecureHeapPhysicalRange { range_modification, responder } =
11710            self
11711        {
11712            Some((range_modification, responder))
11713        } else {
11714            None
11715        }
11716    }
11717
11718    #[allow(irrefutable_let_patterns)]
11719    pub fn into_zero_sub_range(
11720        self,
11721    ) -> Option<(bool, SecureHeapAndRange, SecureMemZeroSubRangeResponder)> {
11722        if let SecureMemRequest::ZeroSubRange {
11723            is_covering_range_explicit,
11724            heap_range,
11725            responder,
11726        } = self
11727        {
11728            Some((is_covering_range_explicit, heap_range, responder))
11729        } else {
11730            None
11731        }
11732    }
11733
11734    /// Name of the method defined in FIDL
11735    pub fn method_name(&self) -> &'static str {
11736        match *self {
11737            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
11738            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
11739                "get_physical_secure_heap_properties"
11740            }
11741            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
11742            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
11743                "delete_secure_heap_physical_range"
11744            }
11745            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
11746                "modify_secure_heap_physical_range"
11747            }
11748            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
11749        }
11750    }
11751}
11752
11753#[derive(Debug, Clone)]
11754pub struct SecureMemControlHandle {
11755    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11756}
11757
11758impl fidl::endpoints::ControlHandle for SecureMemControlHandle {
11759    fn shutdown(&self) {
11760        self.inner.shutdown()
11761    }
11762    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11763        self.inner.shutdown_with_epitaph(status)
11764    }
11765
11766    fn is_closed(&self) -> bool {
11767        self.inner.channel().is_closed()
11768    }
11769    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11770        self.inner.channel().on_closed()
11771    }
11772
11773    #[cfg(target_os = "fuchsia")]
11774    fn signal_peer(
11775        &self,
11776        clear_mask: zx::Signals,
11777        set_mask: zx::Signals,
11778    ) -> Result<(), zx_status::Status> {
11779        use fidl::Peered;
11780        self.inner.channel().signal_peer(clear_mask, set_mask)
11781    }
11782}
11783
11784impl SecureMemControlHandle {}
11785
11786#[must_use = "FIDL methods require a response to be sent"]
11787#[derive(Debug)]
11788pub struct SecureMemGetPhysicalSecureHeapsResponder {
11789    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11790    tx_id: u32,
11791}
11792
11793/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11794/// if the responder is dropped without sending a response, so that the client
11795/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11796impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
11797    fn drop(&mut self) {
11798        self.control_handle.shutdown();
11799        // Safety: drops once, never accessed again
11800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11801    }
11802}
11803
11804impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapsResponder {
11805    type ControlHandle = SecureMemControlHandle;
11806
11807    fn control_handle(&self) -> &SecureMemControlHandle {
11808        &self.control_handle
11809    }
11810
11811    fn drop_without_shutdown(mut self) {
11812        // Safety: drops once, never accessed again due to mem::forget
11813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11814        // Prevent Drop from running (which would shut down the channel)
11815        std::mem::forget(self);
11816    }
11817}
11818
11819impl SecureMemGetPhysicalSecureHeapsResponder {
11820    /// Sends a response to the FIDL transaction.
11821    ///
11822    /// Sets the channel to shutdown if an error occurs.
11823    pub fn send(self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11824        let _result = self.send_raw(result);
11825        if _result.is_err() {
11826            self.control_handle.shutdown();
11827        }
11828        self.drop_without_shutdown();
11829        _result
11830    }
11831
11832    /// Similar to "send" but does not shutdown the channel if an error occurs.
11833    pub fn send_no_shutdown_on_err(
11834        self,
11835        mut result: Result<&SecureHeapsAndRanges, i32>,
11836    ) -> Result<(), fidl::Error> {
11837        let _result = self.send_raw(result);
11838        self.drop_without_shutdown();
11839        _result
11840    }
11841
11842    fn send_raw(&self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11843        self.control_handle.inner.send::<fidl::encoding::ResultType<
11844            SecureMemGetPhysicalSecureHeapsResponse,
11845            i32,
11846        >>(
11847            result.map(|heaps| (heaps,)),
11848            self.tx_id,
11849            0x782319d6ce7fa05,
11850            fidl::encoding::DynamicFlags::empty(),
11851        )
11852    }
11853}
11854
11855#[must_use = "FIDL methods require a response to be sent"]
11856#[derive(Debug)]
11857pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
11858    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11859    tx_id: u32,
11860}
11861
11862/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11863/// if the responder is dropped without sending a response, so that the client
11864/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11865impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11866    fn drop(&mut self) {
11867        self.control_handle.shutdown();
11868        // Safety: drops once, never accessed again
11869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11870    }
11871}
11872
11873impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11874    type ControlHandle = SecureMemControlHandle;
11875
11876    fn control_handle(&self) -> &SecureMemControlHandle {
11877        &self.control_handle
11878    }
11879
11880    fn drop_without_shutdown(mut self) {
11881        // Safety: drops once, never accessed again due to mem::forget
11882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11883        // Prevent Drop from running (which would shut down the channel)
11884        std::mem::forget(self);
11885    }
11886}
11887
11888impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
11889    /// Sends a response to the FIDL transaction.
11890    ///
11891    /// Sets the channel to shutdown if an error occurs.
11892    pub fn send(self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11893        let _result = self.send_raw(result);
11894        if _result.is_err() {
11895            self.control_handle.shutdown();
11896        }
11897        self.drop_without_shutdown();
11898        _result
11899    }
11900
11901    /// Similar to "send" but does not shutdown the channel if an error occurs.
11902    pub fn send_no_shutdown_on_err(
11903        self,
11904        mut result: Result<&SecureHeapProperties, i32>,
11905    ) -> Result<(), fidl::Error> {
11906        let _result = self.send_raw(result);
11907        self.drop_without_shutdown();
11908        _result
11909    }
11910
11911    fn send_raw(&self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11912        self.control_handle.inner.send::<fidl::encoding::ResultType<
11913            SecureMemGetPhysicalSecureHeapPropertiesResponse,
11914            i32,
11915        >>(
11916            result.map(|properties| (properties,)),
11917            self.tx_id,
11918            0x26404e23f1271214,
11919            fidl::encoding::DynamicFlags::empty(),
11920        )
11921    }
11922}
11923
11924#[must_use = "FIDL methods require a response to be sent"]
11925#[derive(Debug)]
11926pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
11927    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11928    tx_id: u32,
11929}
11930
11931/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11932/// if the responder is dropped without sending a response, so that the client
11933/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11934impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
11935    fn drop(&mut self) {
11936        self.control_handle.shutdown();
11937        // Safety: drops once, never accessed again
11938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11939    }
11940}
11941
11942impl fidl::endpoints::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
11943    type ControlHandle = SecureMemControlHandle;
11944
11945    fn control_handle(&self) -> &SecureMemControlHandle {
11946        &self.control_handle
11947    }
11948
11949    fn drop_without_shutdown(mut self) {
11950        // Safety: drops once, never accessed again due to mem::forget
11951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11952        // Prevent Drop from running (which would shut down the channel)
11953        std::mem::forget(self);
11954    }
11955}
11956
11957impl SecureMemAddSecureHeapPhysicalRangeResponder {
11958    /// Sends a response to the FIDL transaction.
11959    ///
11960    /// Sets the channel to shutdown if an error occurs.
11961    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11962        let _result = self.send_raw(result);
11963        if _result.is_err() {
11964            self.control_handle.shutdown();
11965        }
11966        self.drop_without_shutdown();
11967        _result
11968    }
11969
11970    /// Similar to "send" but does not shutdown the channel if an error occurs.
11971    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11972        let _result = self.send_raw(result);
11973        self.drop_without_shutdown();
11974        _result
11975    }
11976
11977    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11978        self.control_handle
11979            .inner
11980            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11981                result,
11982                self.tx_id,
11983                0x1ca1abcee8a0b33e,
11984                fidl::encoding::DynamicFlags::empty(),
11985            )
11986    }
11987}
11988
11989#[must_use = "FIDL methods require a response to be sent"]
11990#[derive(Debug)]
11991pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
11992    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11993    tx_id: u32,
11994}
11995
11996/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11997/// if the responder is dropped without sending a response, so that the client
11998/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11999impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
12000    fn drop(&mut self) {
12001        self.control_handle.shutdown();
12002        // Safety: drops once, never accessed again
12003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12004    }
12005}
12006
12007impl fidl::endpoints::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
12008    type ControlHandle = SecureMemControlHandle;
12009
12010    fn control_handle(&self) -> &SecureMemControlHandle {
12011        &self.control_handle
12012    }
12013
12014    fn drop_without_shutdown(mut self) {
12015        // Safety: drops once, never accessed again due to mem::forget
12016        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12017        // Prevent Drop from running (which would shut down the channel)
12018        std::mem::forget(self);
12019    }
12020}
12021
12022impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
12023    /// Sends a response to the FIDL transaction.
12024    ///
12025    /// Sets the channel to shutdown if an error occurs.
12026    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12027        let _result = self.send_raw(result);
12028        if _result.is_err() {
12029            self.control_handle.shutdown();
12030        }
12031        self.drop_without_shutdown();
12032        _result
12033    }
12034
12035    /// Similar to "send" but does not shutdown the channel if an error occurs.
12036    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12037        let _result = self.send_raw(result);
12038        self.drop_without_shutdown();
12039        _result
12040    }
12041
12042    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12043        self.control_handle
12044            .inner
12045            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
12046                result,
12047                self.tx_id,
12048                0x728a953e56df92ee,
12049                fidl::encoding::DynamicFlags::empty(),
12050            )
12051    }
12052}
12053
12054#[must_use = "FIDL methods require a response to be sent"]
12055#[derive(Debug)]
12056pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
12057    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12058    tx_id: u32,
12059}
12060
12061/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12062/// if the responder is dropped without sending a response, so that the client
12063/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12064impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
12065    fn drop(&mut self) {
12066        self.control_handle.shutdown();
12067        // Safety: drops once, never accessed again
12068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12069    }
12070}
12071
12072impl fidl::endpoints::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
12073    type ControlHandle = SecureMemControlHandle;
12074
12075    fn control_handle(&self) -> &SecureMemControlHandle {
12076        &self.control_handle
12077    }
12078
12079    fn drop_without_shutdown(mut self) {
12080        // Safety: drops once, never accessed again due to mem::forget
12081        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12082        // Prevent Drop from running (which would shut down the channel)
12083        std::mem::forget(self);
12084    }
12085}
12086
12087impl SecureMemModifySecureHeapPhysicalRangeResponder {
12088    /// Sends a response to the FIDL transaction.
12089    ///
12090    /// Sets the channel to shutdown if an error occurs.
12091    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12092        let _result = self.send_raw(result);
12093        if _result.is_err() {
12094            self.control_handle.shutdown();
12095        }
12096        self.drop_without_shutdown();
12097        _result
12098    }
12099
12100    /// Similar to "send" but does not shutdown the channel if an error occurs.
12101    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12102        let _result = self.send_raw(result);
12103        self.drop_without_shutdown();
12104        _result
12105    }
12106
12107    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12108        self.control_handle
12109            .inner
12110            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
12111                result,
12112                self.tx_id,
12113                0x154fbfa3646a890d,
12114                fidl::encoding::DynamicFlags::empty(),
12115            )
12116    }
12117}
12118
12119#[must_use = "FIDL methods require a response to be sent"]
12120#[derive(Debug)]
12121pub struct SecureMemZeroSubRangeResponder {
12122    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12123    tx_id: u32,
12124}
12125
12126/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12127/// if the responder is dropped without sending a response, so that the client
12128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12129impl std::ops::Drop for SecureMemZeroSubRangeResponder {
12130    fn drop(&mut self) {
12131        self.control_handle.shutdown();
12132        // Safety: drops once, never accessed again
12133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12134    }
12135}
12136
12137impl fidl::endpoints::Responder for SecureMemZeroSubRangeResponder {
12138    type ControlHandle = SecureMemControlHandle;
12139
12140    fn control_handle(&self) -> &SecureMemControlHandle {
12141        &self.control_handle
12142    }
12143
12144    fn drop_without_shutdown(mut self) {
12145        // Safety: drops once, never accessed again due to mem::forget
12146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12147        // Prevent Drop from running (which would shut down the channel)
12148        std::mem::forget(self);
12149    }
12150}
12151
12152impl SecureMemZeroSubRangeResponder {
12153    /// Sends a response to the FIDL transaction.
12154    ///
12155    /// Sets the channel to shutdown if an error occurs.
12156    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12157        let _result = self.send_raw(result);
12158        if _result.is_err() {
12159            self.control_handle.shutdown();
12160        }
12161        self.drop_without_shutdown();
12162        _result
12163    }
12164
12165    /// Similar to "send" but does not shutdown the channel if an error occurs.
12166    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12167        let _result = self.send_raw(result);
12168        self.drop_without_shutdown();
12169        _result
12170    }
12171
12172    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12173        self.control_handle
12174            .inner
12175            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
12176                result,
12177                self.tx_id,
12178                0x7480f72bb5bc7e5b,
12179                fidl::encoding::DynamicFlags::empty(),
12180            )
12181    }
12182}
12183
12184mod internal {
12185    use super::*;
12186
12187    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
12188        type Borrowed<'a> = &'a mut Self;
12189        fn take_or_borrow<'a>(
12190            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12191        ) -> Self::Borrowed<'a> {
12192            value
12193        }
12194    }
12195
12196    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
12197        type Owned = Self;
12198
12199        #[inline(always)]
12200        fn inline_align(_context: fidl::encoding::Context) -> usize {
12201            4
12202        }
12203
12204        #[inline(always)]
12205        fn inline_size(_context: fidl::encoding::Context) -> usize {
12206            4
12207        }
12208    }
12209
12210    unsafe impl
12211        fidl::encoding::Encode<
12212            AllocatorAllocateNonSharedCollectionRequest,
12213            fidl::encoding::DefaultFuchsiaResourceDialect,
12214        > for &mut AllocatorAllocateNonSharedCollectionRequest
12215    {
12216        #[inline]
12217        unsafe fn encode(
12218            self,
12219            encoder: &mut fidl::encoding::Encoder<
12220                '_,
12221                fidl::encoding::DefaultFuchsiaResourceDialect,
12222            >,
12223            offset: usize,
12224            _depth: fidl::encoding::Depth,
12225        ) -> fidl::Result<()> {
12226            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
12227            // Delegate to tuple encoding.
12228            fidl::encoding::Encode::<AllocatorAllocateNonSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12229                (
12230                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.collection_request),
12231                ),
12232                encoder, offset, _depth
12233            )
12234        }
12235    }
12236    unsafe impl<
12237            T0: fidl::encoding::Encode<
12238                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12239                fidl::encoding::DefaultFuchsiaResourceDialect,
12240            >,
12241        >
12242        fidl::encoding::Encode<
12243            AllocatorAllocateNonSharedCollectionRequest,
12244            fidl::encoding::DefaultFuchsiaResourceDialect,
12245        > for (T0,)
12246    {
12247        #[inline]
12248        unsafe fn encode(
12249            self,
12250            encoder: &mut fidl::encoding::Encoder<
12251                '_,
12252                fidl::encoding::DefaultFuchsiaResourceDialect,
12253            >,
12254            offset: usize,
12255            depth: fidl::encoding::Depth,
12256        ) -> fidl::Result<()> {
12257            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
12258            // Zero out padding regions. There's no need to apply masks
12259            // because the unmasked parts will be overwritten by fields.
12260            // Write the fields.
12261            self.0.encode(encoder, offset + 0, depth)?;
12262            Ok(())
12263        }
12264    }
12265
12266    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12267        for AllocatorAllocateNonSharedCollectionRequest
12268    {
12269        #[inline(always)]
12270        fn new_empty() -> Self {
12271            Self {
12272                collection_request: fidl::new_empty!(
12273                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12274                    fidl::encoding::DefaultFuchsiaResourceDialect
12275                ),
12276            }
12277        }
12278
12279        #[inline]
12280        unsafe fn decode(
12281            &mut self,
12282            decoder: &mut fidl::encoding::Decoder<
12283                '_,
12284                fidl::encoding::DefaultFuchsiaResourceDialect,
12285            >,
12286            offset: usize,
12287            _depth: fidl::encoding::Depth,
12288        ) -> fidl::Result<()> {
12289            decoder.debug_check_bounds::<Self>(offset);
12290            // Verify that padding bytes are zero.
12291            fidl::decode!(
12292                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12293                fidl::encoding::DefaultFuchsiaResourceDialect,
12294                &mut self.collection_request,
12295                decoder,
12296                offset + 0,
12297                _depth
12298            )?;
12299            Ok(())
12300        }
12301    }
12302
12303    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
12304        type Borrowed<'a> = &'a mut Self;
12305        fn take_or_borrow<'a>(
12306            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12307        ) -> Self::Borrowed<'a> {
12308            value
12309        }
12310    }
12311
12312    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
12313        type Owned = Self;
12314
12315        #[inline(always)]
12316        fn inline_align(_context: fidl::encoding::Context) -> usize {
12317            4
12318        }
12319
12320        #[inline(always)]
12321        fn inline_size(_context: fidl::encoding::Context) -> usize {
12322            4
12323        }
12324    }
12325
12326    unsafe impl
12327        fidl::encoding::Encode<
12328            AllocatorAllocateSharedCollectionRequest,
12329            fidl::encoding::DefaultFuchsiaResourceDialect,
12330        > for &mut AllocatorAllocateSharedCollectionRequest
12331    {
12332        #[inline]
12333        unsafe fn encode(
12334            self,
12335            encoder: &mut fidl::encoding::Encoder<
12336                '_,
12337                fidl::encoding::DefaultFuchsiaResourceDialect,
12338            >,
12339            offset: usize,
12340            _depth: fidl::encoding::Depth,
12341        ) -> fidl::Result<()> {
12342            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12343            // Delegate to tuple encoding.
12344            fidl::encoding::Encode::<
12345                AllocatorAllocateSharedCollectionRequest,
12346                fidl::encoding::DefaultFuchsiaResourceDialect,
12347            >::encode(
12348                (
12349                    <fidl::encoding::Endpoint<
12350                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12351                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12352                        &mut self.token_request,
12353                    ),
12354                ),
12355                encoder,
12356                offset,
12357                _depth,
12358            )
12359        }
12360    }
12361    unsafe impl<
12362            T0: fidl::encoding::Encode<
12363                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12364                fidl::encoding::DefaultFuchsiaResourceDialect,
12365            >,
12366        >
12367        fidl::encoding::Encode<
12368            AllocatorAllocateSharedCollectionRequest,
12369            fidl::encoding::DefaultFuchsiaResourceDialect,
12370        > for (T0,)
12371    {
12372        #[inline]
12373        unsafe fn encode(
12374            self,
12375            encoder: &mut fidl::encoding::Encoder<
12376                '_,
12377                fidl::encoding::DefaultFuchsiaResourceDialect,
12378            >,
12379            offset: usize,
12380            depth: fidl::encoding::Depth,
12381        ) -> fidl::Result<()> {
12382            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12383            // Zero out padding regions. There's no need to apply masks
12384            // because the unmasked parts will be overwritten by fields.
12385            // Write the fields.
12386            self.0.encode(encoder, offset + 0, depth)?;
12387            Ok(())
12388        }
12389    }
12390
12391    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12392        for AllocatorAllocateSharedCollectionRequest
12393    {
12394        #[inline(always)]
12395        fn new_empty() -> Self {
12396            Self {
12397                token_request: fidl::new_empty!(
12398                    fidl::encoding::Endpoint<
12399                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12400                    >,
12401                    fidl::encoding::DefaultFuchsiaResourceDialect
12402                ),
12403            }
12404        }
12405
12406        #[inline]
12407        unsafe fn decode(
12408            &mut self,
12409            decoder: &mut fidl::encoding::Decoder<
12410                '_,
12411                fidl::encoding::DefaultFuchsiaResourceDialect,
12412            >,
12413            offset: usize,
12414            _depth: fidl::encoding::Depth,
12415        ) -> fidl::Result<()> {
12416            decoder.debug_check_bounds::<Self>(offset);
12417            // Verify that padding bytes are zero.
12418            fidl::decode!(
12419                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12420                fidl::encoding::DefaultFuchsiaResourceDialect,
12421                &mut self.token_request,
12422                decoder,
12423                offset + 0,
12424                _depth
12425            )?;
12426            Ok(())
12427        }
12428    }
12429
12430    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
12431        type Borrowed<'a> = &'a mut Self;
12432        fn take_or_borrow<'a>(
12433            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12434        ) -> Self::Borrowed<'a> {
12435            value
12436        }
12437    }
12438
12439    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
12440        type Owned = Self;
12441
12442        #[inline(always)]
12443        fn inline_align(_context: fidl::encoding::Context) -> usize {
12444            4
12445        }
12446
12447        #[inline(always)]
12448        fn inline_size(_context: fidl::encoding::Context) -> usize {
12449            8
12450        }
12451    }
12452
12453    unsafe impl
12454        fidl::encoding::Encode<
12455            AllocatorBindSharedCollectionRequest,
12456            fidl::encoding::DefaultFuchsiaResourceDialect,
12457        > for &mut AllocatorBindSharedCollectionRequest
12458    {
12459        #[inline]
12460        unsafe fn encode(
12461            self,
12462            encoder: &mut fidl::encoding::Encoder<
12463                '_,
12464                fidl::encoding::DefaultFuchsiaResourceDialect,
12465            >,
12466            offset: usize,
12467            _depth: fidl::encoding::Depth,
12468        ) -> fidl::Result<()> {
12469            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12470            // Delegate to tuple encoding.
12471            fidl::encoding::Encode::<AllocatorBindSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12472                (
12473                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
12474                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer_collection_request),
12475                ),
12476                encoder, offset, _depth
12477            )
12478        }
12479    }
12480    unsafe impl<
12481            T0: fidl::encoding::Encode<
12482                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12483                fidl::encoding::DefaultFuchsiaResourceDialect,
12484            >,
12485            T1: fidl::encoding::Encode<
12486                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12487                fidl::encoding::DefaultFuchsiaResourceDialect,
12488            >,
12489        >
12490        fidl::encoding::Encode<
12491            AllocatorBindSharedCollectionRequest,
12492            fidl::encoding::DefaultFuchsiaResourceDialect,
12493        > for (T0, T1)
12494    {
12495        #[inline]
12496        unsafe fn encode(
12497            self,
12498            encoder: &mut fidl::encoding::Encoder<
12499                '_,
12500                fidl::encoding::DefaultFuchsiaResourceDialect,
12501            >,
12502            offset: usize,
12503            depth: fidl::encoding::Depth,
12504        ) -> fidl::Result<()> {
12505            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12506            // Zero out padding regions. There's no need to apply masks
12507            // because the unmasked parts will be overwritten by fields.
12508            // Write the fields.
12509            self.0.encode(encoder, offset + 0, depth)?;
12510            self.1.encode(encoder, offset + 4, depth)?;
12511            Ok(())
12512        }
12513    }
12514
12515    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12516        for AllocatorBindSharedCollectionRequest
12517    {
12518        #[inline(always)]
12519        fn new_empty() -> Self {
12520            Self {
12521                token: fidl::new_empty!(
12522                    fidl::encoding::Endpoint<
12523                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
12524                    >,
12525                    fidl::encoding::DefaultFuchsiaResourceDialect
12526                ),
12527                buffer_collection_request: fidl::new_empty!(
12528                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12529                    fidl::encoding::DefaultFuchsiaResourceDialect
12530                ),
12531            }
12532        }
12533
12534        #[inline]
12535        unsafe fn decode(
12536            &mut self,
12537            decoder: &mut fidl::encoding::Decoder<
12538                '_,
12539                fidl::encoding::DefaultFuchsiaResourceDialect,
12540            >,
12541            offset: usize,
12542            _depth: fidl::encoding::Depth,
12543        ) -> fidl::Result<()> {
12544            decoder.debug_check_bounds::<Self>(offset);
12545            // Verify that padding bytes are zero.
12546            fidl::decode!(
12547                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12548                fidl::encoding::DefaultFuchsiaResourceDialect,
12549                &mut self.token,
12550                decoder,
12551                offset + 0,
12552                _depth
12553            )?;
12554            fidl::decode!(
12555                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12556                fidl::encoding::DefaultFuchsiaResourceDialect,
12557                &mut self.buffer_collection_request,
12558                decoder,
12559                offset + 4,
12560                _depth
12561            )?;
12562            Ok(())
12563        }
12564    }
12565
12566    impl fidl::encoding::ResourceTypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12567        type Borrowed<'a> = &'a mut Self;
12568        fn take_or_borrow<'a>(
12569            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12570        ) -> Self::Borrowed<'a> {
12571            value
12572        }
12573    }
12574
12575    unsafe impl fidl::encoding::TypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12576        type Owned = Self;
12577
12578        #[inline(always)]
12579        fn inline_align(_context: fidl::encoding::Context) -> usize {
12580            4
12581        }
12582
12583        #[inline(always)]
12584        fn inline_size(_context: fidl::encoding::Context) -> usize {
12585            4
12586        }
12587    }
12588
12589    unsafe impl
12590        fidl::encoding::Encode<
12591            AllocatorConnectToSysmem2AllocatorRequest,
12592            fidl::encoding::DefaultFuchsiaResourceDialect,
12593        > for &mut AllocatorConnectToSysmem2AllocatorRequest
12594    {
12595        #[inline]
12596        unsafe fn encode(
12597            self,
12598            encoder: &mut fidl::encoding::Encoder<
12599                '_,
12600                fidl::encoding::DefaultFuchsiaResourceDialect,
12601            >,
12602            offset: usize,
12603            _depth: fidl::encoding::Depth,
12604        ) -> fidl::Result<()> {
12605            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12606            // Delegate to tuple encoding.
12607            fidl::encoding::Encode::<
12608                AllocatorConnectToSysmem2AllocatorRequest,
12609                fidl::encoding::DefaultFuchsiaResourceDialect,
12610            >::encode(
12611                (<fidl::encoding::Endpoint<
12612                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12613                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12614                    &mut self.allocator_request,
12615                ),),
12616                encoder,
12617                offset,
12618                _depth,
12619            )
12620        }
12621    }
12622    unsafe impl<
12623            T0: fidl::encoding::Encode<
12624                fidl::encoding::Endpoint<
12625                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12626                >,
12627                fidl::encoding::DefaultFuchsiaResourceDialect,
12628            >,
12629        >
12630        fidl::encoding::Encode<
12631            AllocatorConnectToSysmem2AllocatorRequest,
12632            fidl::encoding::DefaultFuchsiaResourceDialect,
12633        > for (T0,)
12634    {
12635        #[inline]
12636        unsafe fn encode(
12637            self,
12638            encoder: &mut fidl::encoding::Encoder<
12639                '_,
12640                fidl::encoding::DefaultFuchsiaResourceDialect,
12641            >,
12642            offset: usize,
12643            depth: fidl::encoding::Depth,
12644        ) -> fidl::Result<()> {
12645            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12646            // Zero out padding regions. There's no need to apply masks
12647            // because the unmasked parts will be overwritten by fields.
12648            // Write the fields.
12649            self.0.encode(encoder, offset + 0, depth)?;
12650            Ok(())
12651        }
12652    }
12653
12654    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12655        for AllocatorConnectToSysmem2AllocatorRequest
12656    {
12657        #[inline(always)]
12658        fn new_empty() -> Self {
12659            Self {
12660                allocator_request: fidl::new_empty!(
12661                    fidl::encoding::Endpoint<
12662                        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12663                    >,
12664                    fidl::encoding::DefaultFuchsiaResourceDialect
12665                ),
12666            }
12667        }
12668
12669        #[inline]
12670        unsafe fn decode(
12671            &mut self,
12672            decoder: &mut fidl::encoding::Decoder<
12673                '_,
12674                fidl::encoding::DefaultFuchsiaResourceDialect,
12675            >,
12676            offset: usize,
12677            _depth: fidl::encoding::Depth,
12678        ) -> fidl::Result<()> {
12679            decoder.debug_check_bounds::<Self>(offset);
12680            // Verify that padding bytes are zero.
12681            fidl::decode!(
12682                fidl::encoding::Endpoint<
12683                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12684                >,
12685                fidl::encoding::DefaultFuchsiaResourceDialect,
12686                &mut self.allocator_request,
12687                decoder,
12688                offset + 0,
12689                _depth
12690            )?;
12691            Ok(())
12692        }
12693    }
12694
12695    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12696        type Borrowed<'a> = &'a mut Self;
12697        fn take_or_borrow<'a>(
12698            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12699        ) -> Self::Borrowed<'a> {
12700            value
12701        }
12702    }
12703
12704    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12705        type Owned = Self;
12706
12707        #[inline(always)]
12708        fn inline_align(_context: fidl::encoding::Context) -> usize {
12709            4
12710        }
12711
12712        #[inline(always)]
12713        fn inline_size(_context: fidl::encoding::Context) -> usize {
12714            8
12715        }
12716    }
12717
12718    unsafe impl
12719        fidl::encoding::Encode<
12720            BufferCollectionAttachLifetimeTrackingRequest,
12721            fidl::encoding::DefaultFuchsiaResourceDialect,
12722        > for &mut BufferCollectionAttachLifetimeTrackingRequest
12723    {
12724        #[inline]
12725        unsafe fn encode(
12726            self,
12727            encoder: &mut fidl::encoding::Encoder<
12728                '_,
12729                fidl::encoding::DefaultFuchsiaResourceDialect,
12730            >,
12731            offset: usize,
12732            _depth: fidl::encoding::Depth,
12733        ) -> fidl::Result<()> {
12734            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12735            // Delegate to tuple encoding.
12736            fidl::encoding::Encode::<
12737                BufferCollectionAttachLifetimeTrackingRequest,
12738                fidl::encoding::DefaultFuchsiaResourceDialect,
12739            >::encode(
12740                (
12741                    <fidl::encoding::HandleType<
12742                        fidl::EventPair,
12743                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12744                        2147483648,
12745                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12746                        &mut self.server_end
12747                    ),
12748                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffers_remaining),
12749                ),
12750                encoder,
12751                offset,
12752                _depth,
12753            )
12754        }
12755    }
12756    unsafe impl<
12757            T0: fidl::encoding::Encode<
12758                fidl::encoding::HandleType<
12759                    fidl::EventPair,
12760                    { fidl::ObjectType::EVENTPAIR.into_raw() },
12761                    2147483648,
12762                >,
12763                fidl::encoding::DefaultFuchsiaResourceDialect,
12764            >,
12765            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12766        >
12767        fidl::encoding::Encode<
12768            BufferCollectionAttachLifetimeTrackingRequest,
12769            fidl::encoding::DefaultFuchsiaResourceDialect,
12770        > for (T0, T1)
12771    {
12772        #[inline]
12773        unsafe fn encode(
12774            self,
12775            encoder: &mut fidl::encoding::Encoder<
12776                '_,
12777                fidl::encoding::DefaultFuchsiaResourceDialect,
12778            >,
12779            offset: usize,
12780            depth: fidl::encoding::Depth,
12781        ) -> fidl::Result<()> {
12782            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12783            // Zero out padding regions. There's no need to apply masks
12784            // because the unmasked parts will be overwritten by fields.
12785            // Write the fields.
12786            self.0.encode(encoder, offset + 0, depth)?;
12787            self.1.encode(encoder, offset + 4, depth)?;
12788            Ok(())
12789        }
12790    }
12791
12792    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12793        for BufferCollectionAttachLifetimeTrackingRequest
12794    {
12795        #[inline(always)]
12796        fn new_empty() -> Self {
12797            Self {
12798                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12799                buffers_remaining: fidl::new_empty!(
12800                    u32,
12801                    fidl::encoding::DefaultFuchsiaResourceDialect
12802                ),
12803            }
12804        }
12805
12806        #[inline]
12807        unsafe fn decode(
12808            &mut self,
12809            decoder: &mut fidl::encoding::Decoder<
12810                '_,
12811                fidl::encoding::DefaultFuchsiaResourceDialect,
12812            >,
12813            offset: usize,
12814            _depth: fidl::encoding::Depth,
12815        ) -> fidl::Result<()> {
12816            decoder.debug_check_bounds::<Self>(offset);
12817            // Verify that padding bytes are zero.
12818            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 0, _depth)?;
12819            fidl::decode!(
12820                u32,
12821                fidl::encoding::DefaultFuchsiaResourceDialect,
12822                &mut self.buffers_remaining,
12823                decoder,
12824                offset + 4,
12825                _depth
12826            )?;
12827            Ok(())
12828        }
12829    }
12830
12831    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
12832        type Borrowed<'a> = &'a mut Self;
12833        fn take_or_borrow<'a>(
12834            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12835        ) -> Self::Borrowed<'a> {
12836            value
12837        }
12838    }
12839
12840    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
12841        type Owned = Self;
12842
12843        #[inline(always)]
12844        fn inline_align(_context: fidl::encoding::Context) -> usize {
12845            4
12846        }
12847
12848        #[inline(always)]
12849        fn inline_size(_context: fidl::encoding::Context) -> usize {
12850            8
12851        }
12852    }
12853
12854    unsafe impl
12855        fidl::encoding::Encode<
12856            BufferCollectionAttachTokenRequest,
12857            fidl::encoding::DefaultFuchsiaResourceDialect,
12858        > for &mut BufferCollectionAttachTokenRequest
12859    {
12860        #[inline]
12861        unsafe fn encode(
12862            self,
12863            encoder: &mut fidl::encoding::Encoder<
12864                '_,
12865                fidl::encoding::DefaultFuchsiaResourceDialect,
12866            >,
12867            offset: usize,
12868            _depth: fidl::encoding::Depth,
12869        ) -> fidl::Result<()> {
12870            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12871            // Delegate to tuple encoding.
12872            fidl::encoding::Encode::<
12873                BufferCollectionAttachTokenRequest,
12874                fidl::encoding::DefaultFuchsiaResourceDialect,
12875            >::encode(
12876                (
12877                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
12878                    <fidl::encoding::Endpoint<
12879                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12880                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12881                        &mut self.token_request,
12882                    ),
12883                ),
12884                encoder,
12885                offset,
12886                _depth,
12887            )
12888        }
12889    }
12890    unsafe impl<
12891            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12892            T1: fidl::encoding::Encode<
12893                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12894                fidl::encoding::DefaultFuchsiaResourceDialect,
12895            >,
12896        >
12897        fidl::encoding::Encode<
12898            BufferCollectionAttachTokenRequest,
12899            fidl::encoding::DefaultFuchsiaResourceDialect,
12900        > for (T0, T1)
12901    {
12902        #[inline]
12903        unsafe fn encode(
12904            self,
12905            encoder: &mut fidl::encoding::Encoder<
12906                '_,
12907                fidl::encoding::DefaultFuchsiaResourceDialect,
12908            >,
12909            offset: usize,
12910            depth: fidl::encoding::Depth,
12911        ) -> fidl::Result<()> {
12912            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12913            // Zero out padding regions. There's no need to apply masks
12914            // because the unmasked parts will be overwritten by fields.
12915            // Write the fields.
12916            self.0.encode(encoder, offset + 0, depth)?;
12917            self.1.encode(encoder, offset + 4, depth)?;
12918            Ok(())
12919        }
12920    }
12921
12922    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12923        for BufferCollectionAttachTokenRequest
12924    {
12925        #[inline(always)]
12926        fn new_empty() -> Self {
12927            Self {
12928                rights_attenuation_mask: fidl::new_empty!(
12929                    u32,
12930                    fidl::encoding::DefaultFuchsiaResourceDialect
12931                ),
12932                token_request: fidl::new_empty!(
12933                    fidl::encoding::Endpoint<
12934                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12935                    >,
12936                    fidl::encoding::DefaultFuchsiaResourceDialect
12937                ),
12938            }
12939        }
12940
12941        #[inline]
12942        unsafe fn decode(
12943            &mut self,
12944            decoder: &mut fidl::encoding::Decoder<
12945                '_,
12946                fidl::encoding::DefaultFuchsiaResourceDialect,
12947            >,
12948            offset: usize,
12949            _depth: fidl::encoding::Depth,
12950        ) -> fidl::Result<()> {
12951            decoder.debug_check_bounds::<Self>(offset);
12952            // Verify that padding bytes are zero.
12953            fidl::decode!(
12954                u32,
12955                fidl::encoding::DefaultFuchsiaResourceDialect,
12956                &mut self.rights_attenuation_mask,
12957                decoder,
12958                offset + 0,
12959                _depth
12960            )?;
12961            fidl::decode!(
12962                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12963                fidl::encoding::DefaultFuchsiaResourceDialect,
12964                &mut self.token_request,
12965                decoder,
12966                offset + 4,
12967                _depth
12968            )?;
12969            Ok(())
12970        }
12971    }
12972
12973    impl fidl::encoding::ResourceTypeMarker for BufferCollectionGetAuxBuffersResponse {
12974        type Borrowed<'a> = &'a mut Self;
12975        fn take_or_borrow<'a>(
12976            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12977        ) -> Self::Borrowed<'a> {
12978            value
12979        }
12980    }
12981
12982    unsafe impl fidl::encoding::TypeMarker for BufferCollectionGetAuxBuffersResponse {
12983        type Owned = Self;
12984
12985        #[inline(always)]
12986        fn inline_align(_context: fidl::encoding::Context) -> usize {
12987            8
12988        }
12989
12990        #[inline(always)]
12991        fn inline_size(_context: fidl::encoding::Context) -> usize {
12992            1304
12993        }
12994    }
12995
12996    unsafe impl
12997        fidl::encoding::Encode<
12998            BufferCollectionGetAuxBuffersResponse,
12999            fidl::encoding::DefaultFuchsiaResourceDialect,
13000        > for &mut BufferCollectionGetAuxBuffersResponse
13001    {
13002        #[inline]
13003        unsafe fn encode(
13004            self,
13005            encoder: &mut fidl::encoding::Encoder<
13006                '_,
13007                fidl::encoding::DefaultFuchsiaResourceDialect,
13008            >,
13009            offset: usize,
13010            _depth: fidl::encoding::Depth,
13011        ) -> fidl::Result<()> {
13012            encoder.debug_check_bounds::<BufferCollectionGetAuxBuffersResponse>(offset);
13013            // Delegate to tuple encoding.
13014            fidl::encoding::Encode::<
13015                BufferCollectionGetAuxBuffersResponse,
13016                fidl::encoding::DefaultFuchsiaResourceDialect,
13017            >::encode(
13018                (
13019                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
13020                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13021                        &mut self.buffer_collection_info_aux_buffers,
13022                    ),
13023                ),
13024                encoder,
13025                offset,
13026                _depth,
13027            )
13028        }
13029    }
13030    unsafe impl<
13031            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13032            T1: fidl::encoding::Encode<
13033                BufferCollectionInfo2,
13034                fidl::encoding::DefaultFuchsiaResourceDialect,
13035            >,
13036        >
13037        fidl::encoding::Encode<
13038            BufferCollectionGetAuxBuffersResponse,
13039            fidl::encoding::DefaultFuchsiaResourceDialect,
13040        > for (T0, T1)
13041    {
13042        #[inline]
13043        unsafe fn encode(
13044            self,
13045            encoder: &mut fidl::encoding::Encoder<
13046                '_,
13047                fidl::encoding::DefaultFuchsiaResourceDialect,
13048            >,
13049            offset: usize,
13050            depth: fidl::encoding::Depth,
13051        ) -> fidl::Result<()> {
13052            encoder.debug_check_bounds::<BufferCollectionGetAuxBuffersResponse>(offset);
13053            // Zero out padding regions. There's no need to apply masks
13054            // because the unmasked parts will be overwritten by fields.
13055            unsafe {
13056                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13057                (ptr as *mut u64).write_unaligned(0);
13058            }
13059            // Write the fields.
13060            self.0.encode(encoder, offset + 0, depth)?;
13061            self.1.encode(encoder, offset + 8, depth)?;
13062            Ok(())
13063        }
13064    }
13065
13066    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13067        for BufferCollectionGetAuxBuffersResponse
13068    {
13069        #[inline(always)]
13070        fn new_empty() -> Self {
13071            Self {
13072                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
13073                buffer_collection_info_aux_buffers: fidl::new_empty!(
13074                    BufferCollectionInfo2,
13075                    fidl::encoding::DefaultFuchsiaResourceDialect
13076                ),
13077            }
13078        }
13079
13080        #[inline]
13081        unsafe fn decode(
13082            &mut self,
13083            decoder: &mut fidl::encoding::Decoder<
13084                '_,
13085                fidl::encoding::DefaultFuchsiaResourceDialect,
13086            >,
13087            offset: usize,
13088            _depth: fidl::encoding::Depth,
13089        ) -> fidl::Result<()> {
13090            decoder.debug_check_bounds::<Self>(offset);
13091            // Verify that padding bytes are zero.
13092            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13093            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13094            let mask = 0xffffffff00000000u64;
13095            let maskedval = padval & mask;
13096            if maskedval != 0 {
13097                return Err(fidl::Error::NonZeroPadding {
13098                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13099                });
13100            }
13101            fidl::decode!(
13102                i32,
13103                fidl::encoding::DefaultFuchsiaResourceDialect,
13104                &mut self.status,
13105                decoder,
13106                offset + 0,
13107                _depth
13108            )?;
13109            fidl::decode!(
13110                BufferCollectionInfo2,
13111                fidl::encoding::DefaultFuchsiaResourceDialect,
13112                &mut self.buffer_collection_info_aux_buffers,
13113                decoder,
13114                offset + 8,
13115                _depth
13116            )?;
13117            Ok(())
13118        }
13119    }
13120
13121    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
13122        type Borrowed<'a> = &'a mut Self;
13123        fn take_or_borrow<'a>(
13124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13125        ) -> Self::Borrowed<'a> {
13126            value
13127        }
13128    }
13129
13130    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
13131        type Owned = Self;
13132
13133        #[inline(always)]
13134        fn inline_align(_context: fidl::encoding::Context) -> usize {
13135            8
13136        }
13137
13138        #[inline(always)]
13139        fn inline_size(_context: fidl::encoding::Context) -> usize {
13140            352
13141        }
13142    }
13143
13144    unsafe impl
13145        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
13146        for &mut BufferCollectionInfo
13147    {
13148        #[inline]
13149        unsafe fn encode(
13150            self,
13151            encoder: &mut fidl::encoding::Encoder<
13152                '_,
13153                fidl::encoding::DefaultFuchsiaResourceDialect,
13154            >,
13155            offset: usize,
13156            _depth: fidl::encoding::Depth,
13157        ) -> fidl::Result<()> {
13158            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
13159            // Delegate to tuple encoding.
13160            fidl::encoding::Encode::<
13161                BufferCollectionInfo,
13162                fidl::encoding::DefaultFuchsiaResourceDialect,
13163            >::encode(
13164                (
13165                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
13166                    <BufferFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
13167                    <fidl::encoding::Array<
13168                        fidl::encoding::Optional<
13169                            fidl::encoding::HandleType<
13170                                fidl::Vmo,
13171                                { fidl::ObjectType::VMO.into_raw() },
13172                                2147483648,
13173                            >,
13174                        >,
13175                        64,
13176                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13177                        &mut self.vmos
13178                    ),
13179                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_size),
13180                ),
13181                encoder,
13182                offset,
13183                _depth,
13184            )
13185        }
13186    }
13187    unsafe impl<
13188            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13189            T1: fidl::encoding::Encode<BufferFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
13190            T2: fidl::encoding::Encode<
13191                fidl::encoding::Array<
13192                    fidl::encoding::Optional<
13193                        fidl::encoding::HandleType<
13194                            fidl::Vmo,
13195                            { fidl::ObjectType::VMO.into_raw() },
13196                            2147483648,
13197                        >,
13198                    >,
13199                    64,
13200                >,
13201                fidl::encoding::DefaultFuchsiaResourceDialect,
13202            >,
13203            T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13204        >
13205        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
13206        for (T0, T1, T2, T3)
13207    {
13208        #[inline]
13209        unsafe fn encode(
13210            self,
13211            encoder: &mut fidl::encoding::Encoder<
13212                '_,
13213                fidl::encoding::DefaultFuchsiaResourceDialect,
13214            >,
13215            offset: usize,
13216            depth: fidl::encoding::Depth,
13217        ) -> fidl::Result<()> {
13218            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
13219            // Zero out padding regions. There's no need to apply masks
13220            // because the unmasked parts will be overwritten by fields.
13221            unsafe {
13222                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13223                (ptr as *mut u64).write_unaligned(0);
13224            }
13225            // Write the fields.
13226            self.0.encode(encoder, offset + 0, depth)?;
13227            self.1.encode(encoder, offset + 8, depth)?;
13228            self.2.encode(encoder, offset + 88, depth)?;
13229            self.3.encode(encoder, offset + 344, depth)?;
13230            Ok(())
13231        }
13232    }
13233
13234    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13235        for BufferCollectionInfo
13236    {
13237        #[inline(always)]
13238        fn new_empty() -> Self {
13239            Self {
13240                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13241                format: fidl::new_empty!(
13242                    BufferFormat,
13243                    fidl::encoding::DefaultFuchsiaResourceDialect
13244                ),
13245                vmos: fidl::new_empty!(
13246                    fidl::encoding::Array<
13247                        fidl::encoding::Optional<
13248                            fidl::encoding::HandleType<
13249                                fidl::Vmo,
13250                                { fidl::ObjectType::VMO.into_raw() },
13251                                2147483648,
13252                            >,
13253                        >,
13254                        64,
13255                    >,
13256                    fidl::encoding::DefaultFuchsiaResourceDialect
13257                ),
13258                vmo_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13259            }
13260        }
13261
13262        #[inline]
13263        unsafe fn decode(
13264            &mut self,
13265            decoder: &mut fidl::encoding::Decoder<
13266                '_,
13267                fidl::encoding::DefaultFuchsiaResourceDialect,
13268            >,
13269            offset: usize,
13270            _depth: fidl::encoding::Depth,
13271        ) -> fidl::Result<()> {
13272            decoder.debug_check_bounds::<Self>(offset);
13273            // Verify that padding bytes are zero.
13274            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13275            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13276            let mask = 0xffffffff00000000u64;
13277            let maskedval = padval & mask;
13278            if maskedval != 0 {
13279                return Err(fidl::Error::NonZeroPadding {
13280                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13281                });
13282            }
13283            fidl::decode!(
13284                u32,
13285                fidl::encoding::DefaultFuchsiaResourceDialect,
13286                &mut self.buffer_count,
13287                decoder,
13288                offset + 0,
13289                _depth
13290            )?;
13291            fidl::decode!(
13292                BufferFormat,
13293                fidl::encoding::DefaultFuchsiaResourceDialect,
13294                &mut self.format,
13295                decoder,
13296                offset + 8,
13297                _depth
13298            )?;
13299            fidl::decode!(
13300                fidl::encoding::Array<
13301                    fidl::encoding::Optional<
13302                        fidl::encoding::HandleType<
13303                            fidl::Vmo,
13304                            { fidl::ObjectType::VMO.into_raw() },
13305                            2147483648,
13306                        >,
13307                    >,
13308                    64,
13309                >,
13310                fidl::encoding::DefaultFuchsiaResourceDialect,
13311                &mut self.vmos,
13312                decoder,
13313                offset + 88,
13314                _depth
13315            )?;
13316            fidl::decode!(
13317                u64,
13318                fidl::encoding::DefaultFuchsiaResourceDialect,
13319                &mut self.vmo_size,
13320                decoder,
13321                offset + 344,
13322                _depth
13323            )?;
13324            Ok(())
13325        }
13326    }
13327
13328    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo2 {
13329        type Borrowed<'a> = &'a mut Self;
13330        fn take_or_borrow<'a>(
13331            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13332        ) -> Self::Borrowed<'a> {
13333            value
13334        }
13335    }
13336
13337    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo2 {
13338        type Owned = Self;
13339
13340        #[inline(always)]
13341        fn inline_align(_context: fidl::encoding::Context) -> usize {
13342            8
13343        }
13344
13345        #[inline(always)]
13346        fn inline_size(_context: fidl::encoding::Context) -> usize {
13347            1296
13348        }
13349    }
13350
13351    unsafe impl
13352        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
13353        for &mut BufferCollectionInfo2
13354    {
13355        #[inline]
13356        unsafe fn encode(
13357            self,
13358            encoder: &mut fidl::encoding::Encoder<
13359                '_,
13360                fidl::encoding::DefaultFuchsiaResourceDialect,
13361            >,
13362            offset: usize,
13363            _depth: fidl::encoding::Depth,
13364        ) -> fidl::Result<()> {
13365            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
13366            // Delegate to tuple encoding.
13367            fidl::encoding::Encode::<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13368                (
13369                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
13370                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
13371                    <fidl::encoding::Array<VmoBuffer, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
13372                ),
13373                encoder, offset, _depth
13374            )
13375        }
13376    }
13377    unsafe impl<
13378            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13379            T1: fidl::encoding::Encode<
13380                SingleBufferSettings,
13381                fidl::encoding::DefaultFuchsiaResourceDialect,
13382            >,
13383            T2: fidl::encoding::Encode<
13384                fidl::encoding::Array<VmoBuffer, 64>,
13385                fidl::encoding::DefaultFuchsiaResourceDialect,
13386            >,
13387        >
13388        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
13389        for (T0, T1, T2)
13390    {
13391        #[inline]
13392        unsafe fn encode(
13393            self,
13394            encoder: &mut fidl::encoding::Encoder<
13395                '_,
13396                fidl::encoding::DefaultFuchsiaResourceDialect,
13397            >,
13398            offset: usize,
13399            depth: fidl::encoding::Depth,
13400        ) -> fidl::Result<()> {
13401            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
13402            // Zero out padding regions. There's no need to apply masks
13403            // because the unmasked parts will be overwritten by fields.
13404            unsafe {
13405                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13406                (ptr as *mut u64).write_unaligned(0);
13407            }
13408            // Write the fields.
13409            self.0.encode(encoder, offset + 0, depth)?;
13410            self.1.encode(encoder, offset + 8, depth)?;
13411            self.2.encode(encoder, offset + 272, depth)?;
13412            Ok(())
13413        }
13414    }
13415
13416    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13417        for BufferCollectionInfo2
13418    {
13419        #[inline(always)]
13420        fn new_empty() -> Self {
13421            Self {
13422                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13423                settings: fidl::new_empty!(
13424                    SingleBufferSettings,
13425                    fidl::encoding::DefaultFuchsiaResourceDialect
13426                ),
13427                buffers: fidl::new_empty!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
13428            }
13429        }
13430
13431        #[inline]
13432        unsafe fn decode(
13433            &mut self,
13434            decoder: &mut fidl::encoding::Decoder<
13435                '_,
13436                fidl::encoding::DefaultFuchsiaResourceDialect,
13437            >,
13438            offset: usize,
13439            _depth: fidl::encoding::Depth,
13440        ) -> fidl::Result<()> {
13441            decoder.debug_check_bounds::<Self>(offset);
13442            // Verify that padding bytes are zero.
13443            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13444            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13445            let mask = 0xffffffff00000000u64;
13446            let maskedval = padval & mask;
13447            if maskedval != 0 {
13448                return Err(fidl::Error::NonZeroPadding {
13449                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13450                });
13451            }
13452            fidl::decode!(
13453                u32,
13454                fidl::encoding::DefaultFuchsiaResourceDialect,
13455                &mut self.buffer_count,
13456                decoder,
13457                offset + 0,
13458                _depth
13459            )?;
13460            fidl::decode!(
13461                SingleBufferSettings,
13462                fidl::encoding::DefaultFuchsiaResourceDialect,
13463                &mut self.settings,
13464                decoder,
13465                offset + 8,
13466                _depth
13467            )?;
13468            fidl::decode!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffers, decoder, offset + 272, _depth)?;
13469            Ok(())
13470        }
13471    }
13472
13473    impl fidl::encoding::ResourceTypeMarker
13474        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13475    {
13476        type Borrowed<'a> = &'a mut Self;
13477        fn take_or_borrow<'a>(
13478            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13479        ) -> Self::Borrowed<'a> {
13480            value
13481        }
13482    }
13483
13484    unsafe impl fidl::encoding::TypeMarker
13485        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13486    {
13487        type Owned = Self;
13488
13489        #[inline(always)]
13490        fn inline_align(_context: fidl::encoding::Context) -> usize {
13491            4
13492        }
13493
13494        #[inline(always)]
13495        fn inline_size(_context: fidl::encoding::Context) -> usize {
13496            4
13497        }
13498    }
13499
13500    unsafe impl
13501        fidl::encoding::Encode<
13502            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13503            fidl::encoding::DefaultFuchsiaResourceDialect,
13504        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13505    {
13506        #[inline]
13507        unsafe fn encode(
13508            self,
13509            encoder: &mut fidl::encoding::Encoder<
13510                '_,
13511                fidl::encoding::DefaultFuchsiaResourceDialect,
13512            >,
13513            offset: usize,
13514            _depth: fidl::encoding::Depth,
13515        ) -> fidl::Result<()> {
13516            encoder
13517                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13518                    offset,
13519                );
13520            // Delegate to tuple encoding.
13521            fidl::encoding::Encode::<
13522                BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13523                fidl::encoding::DefaultFuchsiaResourceDialect,
13524            >::encode(
13525                (<fidl::encoding::Endpoint<
13526                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13527                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13528                    &mut self.group_request
13529                ),),
13530                encoder,
13531                offset,
13532                _depth,
13533            )
13534        }
13535    }
13536    unsafe impl<
13537            T0: fidl::encoding::Encode<
13538                fidl::encoding::Endpoint<
13539                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13540                >,
13541                fidl::encoding::DefaultFuchsiaResourceDialect,
13542            >,
13543        >
13544        fidl::encoding::Encode<
13545            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13546            fidl::encoding::DefaultFuchsiaResourceDialect,
13547        > for (T0,)
13548    {
13549        #[inline]
13550        unsafe fn encode(
13551            self,
13552            encoder: &mut fidl::encoding::Encoder<
13553                '_,
13554                fidl::encoding::DefaultFuchsiaResourceDialect,
13555            >,
13556            offset: usize,
13557            depth: fidl::encoding::Depth,
13558        ) -> fidl::Result<()> {
13559            encoder
13560                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13561                    offset,
13562                );
13563            // Zero out padding regions. There's no need to apply masks
13564            // because the unmasked parts will be overwritten by fields.
13565            // Write the fields.
13566            self.0.encode(encoder, offset + 0, depth)?;
13567            Ok(())
13568        }
13569    }
13570
13571    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13572        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13573    {
13574        #[inline(always)]
13575        fn new_empty() -> Self {
13576            Self {
13577                group_request: fidl::new_empty!(
13578                    fidl::encoding::Endpoint<
13579                        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13580                    >,
13581                    fidl::encoding::DefaultFuchsiaResourceDialect
13582                ),
13583            }
13584        }
13585
13586        #[inline]
13587        unsafe fn decode(
13588            &mut self,
13589            decoder: &mut fidl::encoding::Decoder<
13590                '_,
13591                fidl::encoding::DefaultFuchsiaResourceDialect,
13592            >,
13593            offset: usize,
13594            _depth: fidl::encoding::Depth,
13595        ) -> fidl::Result<()> {
13596            decoder.debug_check_bounds::<Self>(offset);
13597            // Verify that padding bytes are zero.
13598            fidl::decode!(
13599                fidl::encoding::Endpoint<
13600                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13601                >,
13602                fidl::encoding::DefaultFuchsiaResourceDialect,
13603                &mut self.group_request,
13604                decoder,
13605                offset + 0,
13606                _depth
13607            )?;
13608            Ok(())
13609        }
13610    }
13611
13612    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
13613        type Borrowed<'a> = &'a mut Self;
13614        fn take_or_borrow<'a>(
13615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13616        ) -> Self::Borrowed<'a> {
13617            value
13618        }
13619    }
13620
13621    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
13622        type Owned = Self;
13623
13624        #[inline(always)]
13625        fn inline_align(_context: fidl::encoding::Context) -> usize {
13626            4
13627        }
13628
13629        #[inline(always)]
13630        fn inline_size(_context: fidl::encoding::Context) -> usize {
13631            8
13632        }
13633    }
13634
13635    unsafe impl
13636        fidl::encoding::Encode<
13637            BufferCollectionTokenDuplicateRequest,
13638            fidl::encoding::DefaultFuchsiaResourceDialect,
13639        > for &mut BufferCollectionTokenDuplicateRequest
13640    {
13641        #[inline]
13642        unsafe fn encode(
13643            self,
13644            encoder: &mut fidl::encoding::Encoder<
13645                '_,
13646                fidl::encoding::DefaultFuchsiaResourceDialect,
13647            >,
13648            offset: usize,
13649            _depth: fidl::encoding::Depth,
13650        ) -> fidl::Result<()> {
13651            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13652            // Delegate to tuple encoding.
13653            fidl::encoding::Encode::<
13654                BufferCollectionTokenDuplicateRequest,
13655                fidl::encoding::DefaultFuchsiaResourceDialect,
13656            >::encode(
13657                (
13658                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
13659                    <fidl::encoding::Endpoint<
13660                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13661                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13662                        &mut self.token_request,
13663                    ),
13664                ),
13665                encoder,
13666                offset,
13667                _depth,
13668            )
13669        }
13670    }
13671    unsafe impl<
13672            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13673            T1: fidl::encoding::Encode<
13674                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13675                fidl::encoding::DefaultFuchsiaResourceDialect,
13676            >,
13677        >
13678        fidl::encoding::Encode<
13679            BufferCollectionTokenDuplicateRequest,
13680            fidl::encoding::DefaultFuchsiaResourceDialect,
13681        > for (T0, T1)
13682    {
13683        #[inline]
13684        unsafe fn encode(
13685            self,
13686            encoder: &mut fidl::encoding::Encoder<
13687                '_,
13688                fidl::encoding::DefaultFuchsiaResourceDialect,
13689            >,
13690            offset: usize,
13691            depth: fidl::encoding::Depth,
13692        ) -> fidl::Result<()> {
13693            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13694            // Zero out padding regions. There's no need to apply masks
13695            // because the unmasked parts will be overwritten by fields.
13696            // Write the fields.
13697            self.0.encode(encoder, offset + 0, depth)?;
13698            self.1.encode(encoder, offset + 4, depth)?;
13699            Ok(())
13700        }
13701    }
13702
13703    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13704        for BufferCollectionTokenDuplicateRequest
13705    {
13706        #[inline(always)]
13707        fn new_empty() -> Self {
13708            Self {
13709                rights_attenuation_mask: fidl::new_empty!(
13710                    u32,
13711                    fidl::encoding::DefaultFuchsiaResourceDialect
13712                ),
13713                token_request: fidl::new_empty!(
13714                    fidl::encoding::Endpoint<
13715                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13716                    >,
13717                    fidl::encoding::DefaultFuchsiaResourceDialect
13718                ),
13719            }
13720        }
13721
13722        #[inline]
13723        unsafe fn decode(
13724            &mut self,
13725            decoder: &mut fidl::encoding::Decoder<
13726                '_,
13727                fidl::encoding::DefaultFuchsiaResourceDialect,
13728            >,
13729            offset: usize,
13730            _depth: fidl::encoding::Depth,
13731        ) -> fidl::Result<()> {
13732            decoder.debug_check_bounds::<Self>(offset);
13733            // Verify that padding bytes are zero.
13734            fidl::decode!(
13735                u32,
13736                fidl::encoding::DefaultFuchsiaResourceDialect,
13737                &mut self.rights_attenuation_mask,
13738                decoder,
13739                offset + 0,
13740                _depth
13741            )?;
13742            fidl::decode!(
13743                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13744                fidl::encoding::DefaultFuchsiaResourceDialect,
13745                &mut self.token_request,
13746                decoder,
13747                offset + 4,
13748                _depth
13749            )?;
13750            Ok(())
13751        }
13752    }
13753
13754    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13755        type Borrowed<'a> = &'a mut Self;
13756        fn take_or_borrow<'a>(
13757            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13758        ) -> Self::Borrowed<'a> {
13759            value
13760        }
13761    }
13762
13763    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13764        type Owned = Self;
13765
13766        #[inline(always)]
13767        fn inline_align(_context: fidl::encoding::Context) -> usize {
13768            8
13769        }
13770
13771        #[inline(always)]
13772        fn inline_size(_context: fidl::encoding::Context) -> usize {
13773            16
13774        }
13775    }
13776
13777    unsafe impl
13778        fidl::encoding::Encode<
13779            BufferCollectionTokenDuplicateSyncResponse,
13780            fidl::encoding::DefaultFuchsiaResourceDialect,
13781        > for &mut BufferCollectionTokenDuplicateSyncResponse
13782    {
13783        #[inline]
13784        unsafe fn encode(
13785            self,
13786            encoder: &mut fidl::encoding::Encoder<
13787                '_,
13788                fidl::encoding::DefaultFuchsiaResourceDialect,
13789            >,
13790            offset: usize,
13791            _depth: fidl::encoding::Depth,
13792        ) -> fidl::Result<()> {
13793            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13794            // Delegate to tuple encoding.
13795            fidl::encoding::Encode::<
13796                BufferCollectionTokenDuplicateSyncResponse,
13797                fidl::encoding::DefaultFuchsiaResourceDialect,
13798            >::encode(
13799                (<fidl::encoding::Vector<
13800                    fidl::encoding::Endpoint<
13801                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13802                    >,
13803                    64,
13804                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13805                    &mut self.tokens
13806                ),),
13807                encoder,
13808                offset,
13809                _depth,
13810            )
13811        }
13812    }
13813    unsafe impl<
13814            T0: fidl::encoding::Encode<
13815                fidl::encoding::Vector<
13816                    fidl::encoding::Endpoint<
13817                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13818                    >,
13819                    64,
13820                >,
13821                fidl::encoding::DefaultFuchsiaResourceDialect,
13822            >,
13823        >
13824        fidl::encoding::Encode<
13825            BufferCollectionTokenDuplicateSyncResponse,
13826            fidl::encoding::DefaultFuchsiaResourceDialect,
13827        > for (T0,)
13828    {
13829        #[inline]
13830        unsafe fn encode(
13831            self,
13832            encoder: &mut fidl::encoding::Encoder<
13833                '_,
13834                fidl::encoding::DefaultFuchsiaResourceDialect,
13835            >,
13836            offset: usize,
13837            depth: fidl::encoding::Depth,
13838        ) -> fidl::Result<()> {
13839            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13840            // Zero out padding regions. There's no need to apply masks
13841            // because the unmasked parts will be overwritten by fields.
13842            // Write the fields.
13843            self.0.encode(encoder, offset + 0, depth)?;
13844            Ok(())
13845        }
13846    }
13847
13848    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13849        for BufferCollectionTokenDuplicateSyncResponse
13850    {
13851        #[inline(always)]
13852        fn new_empty() -> Self {
13853            Self {
13854                tokens: fidl::new_empty!(
13855                    fidl::encoding::Vector<
13856                        fidl::encoding::Endpoint<
13857                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13858                        >,
13859                        64,
13860                    >,
13861                    fidl::encoding::DefaultFuchsiaResourceDialect
13862                ),
13863            }
13864        }
13865
13866        #[inline]
13867        unsafe fn decode(
13868            &mut self,
13869            decoder: &mut fidl::encoding::Decoder<
13870                '_,
13871                fidl::encoding::DefaultFuchsiaResourceDialect,
13872            >,
13873            offset: usize,
13874            _depth: fidl::encoding::Depth,
13875        ) -> fidl::Result<()> {
13876            decoder.debug_check_bounds::<Self>(offset);
13877            // Verify that padding bytes are zero.
13878            fidl::decode!(
13879                fidl::encoding::Vector<
13880                    fidl::encoding::Endpoint<
13881                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13882                    >,
13883                    64,
13884                >,
13885                fidl::encoding::DefaultFuchsiaResourceDialect,
13886                &mut self.tokens,
13887                decoder,
13888                offset + 0,
13889                _depth
13890            )?;
13891            Ok(())
13892        }
13893    }
13894
13895    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13896        type Borrowed<'a> = &'a mut Self;
13897        fn take_or_borrow<'a>(
13898            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13899        ) -> Self::Borrowed<'a> {
13900            value
13901        }
13902    }
13903
13904    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13905        type Owned = Self;
13906
13907        #[inline(always)]
13908        fn inline_align(_context: fidl::encoding::Context) -> usize {
13909            8
13910        }
13911
13912        #[inline(always)]
13913        fn inline_size(_context: fidl::encoding::Context) -> usize {
13914            16
13915        }
13916    }
13917
13918    unsafe impl
13919        fidl::encoding::Encode<
13920            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13921            fidl::encoding::DefaultFuchsiaResourceDialect,
13922        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
13923    {
13924        #[inline]
13925        unsafe fn encode(
13926            self,
13927            encoder: &mut fidl::encoding::Encoder<
13928                '_,
13929                fidl::encoding::DefaultFuchsiaResourceDialect,
13930            >,
13931            offset: usize,
13932            _depth: fidl::encoding::Depth,
13933        ) -> fidl::Result<()> {
13934            encoder
13935                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13936            // Delegate to tuple encoding.
13937            fidl::encoding::Encode::<
13938                BufferCollectionTokenGroupCreateChildrenSyncResponse,
13939                fidl::encoding::DefaultFuchsiaResourceDialect,
13940            >::encode(
13941                (<fidl::encoding::Vector<
13942                    fidl::encoding::Endpoint<
13943                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13944                    >,
13945                    64,
13946                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13947                    &mut self.tokens
13948                ),),
13949                encoder,
13950                offset,
13951                _depth,
13952            )
13953        }
13954    }
13955    unsafe impl<
13956            T0: fidl::encoding::Encode<
13957                fidl::encoding::Vector<
13958                    fidl::encoding::Endpoint<
13959                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13960                    >,
13961                    64,
13962                >,
13963                fidl::encoding::DefaultFuchsiaResourceDialect,
13964            >,
13965        >
13966        fidl::encoding::Encode<
13967            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13968            fidl::encoding::DefaultFuchsiaResourceDialect,
13969        > for (T0,)
13970    {
13971        #[inline]
13972        unsafe fn encode(
13973            self,
13974            encoder: &mut fidl::encoding::Encoder<
13975                '_,
13976                fidl::encoding::DefaultFuchsiaResourceDialect,
13977            >,
13978            offset: usize,
13979            depth: fidl::encoding::Depth,
13980        ) -> fidl::Result<()> {
13981            encoder
13982                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13983            // Zero out padding regions. There's no need to apply masks
13984            // because the unmasked parts will be overwritten by fields.
13985            // Write the fields.
13986            self.0.encode(encoder, offset + 0, depth)?;
13987            Ok(())
13988        }
13989    }
13990
13991    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13992        for BufferCollectionTokenGroupCreateChildrenSyncResponse
13993    {
13994        #[inline(always)]
13995        fn new_empty() -> Self {
13996            Self {
13997                tokens: fidl::new_empty!(
13998                    fidl::encoding::Vector<
13999                        fidl::encoding::Endpoint<
14000                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
14001                        >,
14002                        64,
14003                    >,
14004                    fidl::encoding::DefaultFuchsiaResourceDialect
14005                ),
14006            }
14007        }
14008
14009        #[inline]
14010        unsafe fn decode(
14011            &mut self,
14012            decoder: &mut fidl::encoding::Decoder<
14013                '_,
14014                fidl::encoding::DefaultFuchsiaResourceDialect,
14015            >,
14016            offset: usize,
14017            _depth: fidl::encoding::Depth,
14018        ) -> fidl::Result<()> {
14019            decoder.debug_check_bounds::<Self>(offset);
14020            // Verify that padding bytes are zero.
14021            fidl::decode!(
14022                fidl::encoding::Vector<
14023                    fidl::encoding::Endpoint<
14024                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
14025                    >,
14026                    64,
14027                >,
14028                fidl::encoding::DefaultFuchsiaResourceDialect,
14029                &mut self.tokens,
14030                decoder,
14031                offset + 0,
14032                _depth
14033            )?;
14034            Ok(())
14035        }
14036    }
14037
14038    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
14039        type Borrowed<'a> = &'a mut Self;
14040        fn take_or_borrow<'a>(
14041            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14042        ) -> Self::Borrowed<'a> {
14043            value
14044        }
14045    }
14046
14047    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
14048        type Owned = Self;
14049
14050        #[inline(always)]
14051        fn inline_align(_context: fidl::encoding::Context) -> usize {
14052            8
14053        }
14054
14055        #[inline(always)]
14056        fn inline_size(_context: fidl::encoding::Context) -> usize {
14057            1304
14058        }
14059    }
14060
14061    unsafe impl
14062        fidl::encoding::Encode<
14063            BufferCollectionWaitForBuffersAllocatedResponse,
14064            fidl::encoding::DefaultFuchsiaResourceDialect,
14065        > for &mut BufferCollectionWaitForBuffersAllocatedResponse
14066    {
14067        #[inline]
14068        unsafe fn encode(
14069            self,
14070            encoder: &mut fidl::encoding::Encoder<
14071                '_,
14072                fidl::encoding::DefaultFuchsiaResourceDialect,
14073            >,
14074            offset: usize,
14075            _depth: fidl::encoding::Depth,
14076        ) -> fidl::Result<()> {
14077            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
14078            // Delegate to tuple encoding.
14079            fidl::encoding::Encode::<
14080                BufferCollectionWaitForBuffersAllocatedResponse,
14081                fidl::encoding::DefaultFuchsiaResourceDialect,
14082            >::encode(
14083                (
14084                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
14085                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14086                        &mut self.buffer_collection_info,
14087                    ),
14088                ),
14089                encoder,
14090                offset,
14091                _depth,
14092            )
14093        }
14094    }
14095    unsafe impl<
14096            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
14097            T1: fidl::encoding::Encode<
14098                BufferCollectionInfo2,
14099                fidl::encoding::DefaultFuchsiaResourceDialect,
14100            >,
14101        >
14102        fidl::encoding::Encode<
14103            BufferCollectionWaitForBuffersAllocatedResponse,
14104            fidl::encoding::DefaultFuchsiaResourceDialect,
14105        > for (T0, T1)
14106    {
14107        #[inline]
14108        unsafe fn encode(
14109            self,
14110            encoder: &mut fidl::encoding::Encoder<
14111                '_,
14112                fidl::encoding::DefaultFuchsiaResourceDialect,
14113            >,
14114            offset: usize,
14115            depth: fidl::encoding::Depth,
14116        ) -> fidl::Result<()> {
14117            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
14118            // Zero out padding regions. There's no need to apply masks
14119            // because the unmasked parts will be overwritten by fields.
14120            unsafe {
14121                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14122                (ptr as *mut u64).write_unaligned(0);
14123            }
14124            // Write the fields.
14125            self.0.encode(encoder, offset + 0, depth)?;
14126            self.1.encode(encoder, offset + 8, depth)?;
14127            Ok(())
14128        }
14129    }
14130
14131    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14132        for BufferCollectionWaitForBuffersAllocatedResponse
14133    {
14134        #[inline(always)]
14135        fn new_empty() -> Self {
14136            Self {
14137                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
14138                buffer_collection_info: fidl::new_empty!(
14139                    BufferCollectionInfo2,
14140                    fidl::encoding::DefaultFuchsiaResourceDialect
14141                ),
14142            }
14143        }
14144
14145        #[inline]
14146        unsafe fn decode(
14147            &mut self,
14148            decoder: &mut fidl::encoding::Decoder<
14149                '_,
14150                fidl::encoding::DefaultFuchsiaResourceDialect,
14151            >,
14152            offset: usize,
14153            _depth: fidl::encoding::Depth,
14154        ) -> fidl::Result<()> {
14155            decoder.debug_check_bounds::<Self>(offset);
14156            // Verify that padding bytes are zero.
14157            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14158            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14159            let mask = 0xffffffff00000000u64;
14160            let maskedval = padval & mask;
14161            if maskedval != 0 {
14162                return Err(fidl::Error::NonZeroPadding {
14163                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14164                });
14165            }
14166            fidl::decode!(
14167                i32,
14168                fidl::encoding::DefaultFuchsiaResourceDialect,
14169                &mut self.status,
14170                decoder,
14171                offset + 0,
14172                _depth
14173            )?;
14174            fidl::decode!(
14175                BufferCollectionInfo2,
14176                fidl::encoding::DefaultFuchsiaResourceDialect,
14177                &mut self.buffer_collection_info,
14178                decoder,
14179                offset + 8,
14180                _depth
14181            )?;
14182            Ok(())
14183        }
14184    }
14185
14186    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
14187        type Borrowed<'a> = &'a mut Self;
14188        fn take_or_borrow<'a>(
14189            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14190        ) -> Self::Borrowed<'a> {
14191            value
14192        }
14193    }
14194
14195    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
14196        type Owned = Self;
14197
14198        #[inline(always)]
14199        fn inline_align(_context: fidl::encoding::Context) -> usize {
14200            4
14201        }
14202
14203        #[inline(always)]
14204        fn inline_size(_context: fidl::encoding::Context) -> usize {
14205            4
14206        }
14207    }
14208
14209    unsafe impl
14210        fidl::encoding::Encode<
14211            NodeGetNodeRefResponse,
14212            fidl::encoding::DefaultFuchsiaResourceDialect,
14213        > for &mut NodeGetNodeRefResponse
14214    {
14215        #[inline]
14216        unsafe fn encode(
14217            self,
14218            encoder: &mut fidl::encoding::Encoder<
14219                '_,
14220                fidl::encoding::DefaultFuchsiaResourceDialect,
14221            >,
14222            offset: usize,
14223            _depth: fidl::encoding::Depth,
14224        ) -> fidl::Result<()> {
14225            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
14226            // Delegate to tuple encoding.
14227            fidl::encoding::Encode::<
14228                NodeGetNodeRefResponse,
14229                fidl::encoding::DefaultFuchsiaResourceDialect,
14230            >::encode(
14231                (<fidl::encoding::HandleType<
14232                    fidl::Event,
14233                    { fidl::ObjectType::EVENT.into_raw() },
14234                    2147483648,
14235                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14236                    &mut self.node_ref
14237                ),),
14238                encoder,
14239                offset,
14240                _depth,
14241            )
14242        }
14243    }
14244    unsafe impl<
14245            T0: fidl::encoding::Encode<
14246                fidl::encoding::HandleType<
14247                    fidl::Event,
14248                    { fidl::ObjectType::EVENT.into_raw() },
14249                    2147483648,
14250                >,
14251                fidl::encoding::DefaultFuchsiaResourceDialect,
14252            >,
14253        >
14254        fidl::encoding::Encode<
14255            NodeGetNodeRefResponse,
14256            fidl::encoding::DefaultFuchsiaResourceDialect,
14257        > for (T0,)
14258    {
14259        #[inline]
14260        unsafe fn encode(
14261            self,
14262            encoder: &mut fidl::encoding::Encoder<
14263                '_,
14264                fidl::encoding::DefaultFuchsiaResourceDialect,
14265            >,
14266            offset: usize,
14267            depth: fidl::encoding::Depth,
14268        ) -> fidl::Result<()> {
14269            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
14270            // Zero out padding regions. There's no need to apply masks
14271            // because the unmasked parts will be overwritten by fields.
14272            // Write the fields.
14273            self.0.encode(encoder, offset + 0, depth)?;
14274            Ok(())
14275        }
14276    }
14277
14278    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14279        for NodeGetNodeRefResponse
14280    {
14281        #[inline(always)]
14282        fn new_empty() -> Self {
14283            Self {
14284                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14285            }
14286        }
14287
14288        #[inline]
14289        unsafe fn decode(
14290            &mut self,
14291            decoder: &mut fidl::encoding::Decoder<
14292                '_,
14293                fidl::encoding::DefaultFuchsiaResourceDialect,
14294            >,
14295            offset: usize,
14296            _depth: fidl::encoding::Depth,
14297        ) -> fidl::Result<()> {
14298            decoder.debug_check_bounds::<Self>(offset);
14299            // Verify that padding bytes are zero.
14300            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
14301            Ok(())
14302        }
14303    }
14304
14305    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
14306        type Borrowed<'a> = &'a mut Self;
14307        fn take_or_borrow<'a>(
14308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14309        ) -> Self::Borrowed<'a> {
14310            value
14311        }
14312    }
14313
14314    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
14315        type Owned = Self;
14316
14317        #[inline(always)]
14318        fn inline_align(_context: fidl::encoding::Context) -> usize {
14319            4
14320        }
14321
14322        #[inline(always)]
14323        fn inline_size(_context: fidl::encoding::Context) -> usize {
14324            4
14325        }
14326    }
14327
14328    unsafe impl
14329        fidl::encoding::Encode<
14330            NodeIsAlternateForRequest,
14331            fidl::encoding::DefaultFuchsiaResourceDialect,
14332        > for &mut NodeIsAlternateForRequest
14333    {
14334        #[inline]
14335        unsafe fn encode(
14336            self,
14337            encoder: &mut fidl::encoding::Encoder<
14338                '_,
14339                fidl::encoding::DefaultFuchsiaResourceDialect,
14340            >,
14341            offset: usize,
14342            _depth: fidl::encoding::Depth,
14343        ) -> fidl::Result<()> {
14344            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
14345            // Delegate to tuple encoding.
14346            fidl::encoding::Encode::<
14347                NodeIsAlternateForRequest,
14348                fidl::encoding::DefaultFuchsiaResourceDialect,
14349            >::encode(
14350                (<fidl::encoding::HandleType<
14351                    fidl::Event,
14352                    { fidl::ObjectType::EVENT.into_raw() },
14353                    2147483648,
14354                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14355                    &mut self.node_ref
14356                ),),
14357                encoder,
14358                offset,
14359                _depth,
14360            )
14361        }
14362    }
14363    unsafe impl<
14364            T0: fidl::encoding::Encode<
14365                fidl::encoding::HandleType<
14366                    fidl::Event,
14367                    { fidl::ObjectType::EVENT.into_raw() },
14368                    2147483648,
14369                >,
14370                fidl::encoding::DefaultFuchsiaResourceDialect,
14371            >,
14372        >
14373        fidl::encoding::Encode<
14374            NodeIsAlternateForRequest,
14375            fidl::encoding::DefaultFuchsiaResourceDialect,
14376        > for (T0,)
14377    {
14378        #[inline]
14379        unsafe fn encode(
14380            self,
14381            encoder: &mut fidl::encoding::Encoder<
14382                '_,
14383                fidl::encoding::DefaultFuchsiaResourceDialect,
14384            >,
14385            offset: usize,
14386            depth: fidl::encoding::Depth,
14387        ) -> fidl::Result<()> {
14388            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
14389            // Zero out padding regions. There's no need to apply masks
14390            // because the unmasked parts will be overwritten by fields.
14391            // Write the fields.
14392            self.0.encode(encoder, offset + 0, depth)?;
14393            Ok(())
14394        }
14395    }
14396
14397    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14398        for NodeIsAlternateForRequest
14399    {
14400        #[inline(always)]
14401        fn new_empty() -> Self {
14402            Self {
14403                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14404            }
14405        }
14406
14407        #[inline]
14408        unsafe fn decode(
14409            &mut self,
14410            decoder: &mut fidl::encoding::Decoder<
14411                '_,
14412                fidl::encoding::DefaultFuchsiaResourceDialect,
14413            >,
14414            offset: usize,
14415            _depth: fidl::encoding::Depth,
14416        ) -> fidl::Result<()> {
14417            decoder.debug_check_bounds::<Self>(offset);
14418            // Verify that padding bytes are zero.
14419            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
14420            Ok(())
14421        }
14422    }
14423
14424    impl fidl::encoding::ResourceTypeMarker for SingleBufferInfo {
14425        type Borrowed<'a> = &'a mut Self;
14426        fn take_or_borrow<'a>(
14427            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14428        ) -> Self::Borrowed<'a> {
14429            value
14430        }
14431    }
14432
14433    unsafe impl fidl::encoding::TypeMarker for SingleBufferInfo {
14434        type Owned = Self;
14435
14436        #[inline(always)]
14437        fn inline_align(_context: fidl::encoding::Context) -> usize {
14438            8
14439        }
14440
14441        #[inline(always)]
14442        fn inline_size(_context: fidl::encoding::Context) -> usize {
14443            280
14444        }
14445    }
14446
14447    unsafe impl
14448        fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14449        for &mut SingleBufferInfo
14450    {
14451        #[inline]
14452        unsafe fn encode(
14453            self,
14454            encoder: &mut fidl::encoding::Encoder<
14455                '_,
14456                fidl::encoding::DefaultFuchsiaResourceDialect,
14457            >,
14458            offset: usize,
14459            _depth: fidl::encoding::Depth,
14460        ) -> fidl::Result<()> {
14461            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14462            // Delegate to tuple encoding.
14463            fidl::encoding::Encode::<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14464                (
14465                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
14466                    <VmoBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
14467                ),
14468                encoder, offset, _depth
14469            )
14470        }
14471    }
14472    unsafe impl<
14473            T0: fidl::encoding::Encode<
14474                SingleBufferSettings,
14475                fidl::encoding::DefaultFuchsiaResourceDialect,
14476            >,
14477            T1: fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>,
14478        >
14479        fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14480        for (T0, T1)
14481    {
14482        #[inline]
14483        unsafe fn encode(
14484            self,
14485            encoder: &mut fidl::encoding::Encoder<
14486                '_,
14487                fidl::encoding::DefaultFuchsiaResourceDialect,
14488            >,
14489            offset: usize,
14490            depth: fidl::encoding::Depth,
14491        ) -> fidl::Result<()> {
14492            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14493            // Zero out padding regions. There's no need to apply masks
14494            // because the unmasked parts will be overwritten by fields.
14495            // Write the fields.
14496            self.0.encode(encoder, offset + 0, depth)?;
14497            self.1.encode(encoder, offset + 264, depth)?;
14498            Ok(())
14499        }
14500    }
14501
14502    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14503        for SingleBufferInfo
14504    {
14505        #[inline(always)]
14506        fn new_empty() -> Self {
14507            Self {
14508                settings: fidl::new_empty!(
14509                    SingleBufferSettings,
14510                    fidl::encoding::DefaultFuchsiaResourceDialect
14511                ),
14512                buffer: fidl::new_empty!(VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect),
14513            }
14514        }
14515
14516        #[inline]
14517        unsafe fn decode(
14518            &mut self,
14519            decoder: &mut fidl::encoding::Decoder<
14520                '_,
14521                fidl::encoding::DefaultFuchsiaResourceDialect,
14522            >,
14523            offset: usize,
14524            _depth: fidl::encoding::Depth,
14525        ) -> fidl::Result<()> {
14526            decoder.debug_check_bounds::<Self>(offset);
14527            // Verify that padding bytes are zero.
14528            fidl::decode!(
14529                SingleBufferSettings,
14530                fidl::encoding::DefaultFuchsiaResourceDialect,
14531                &mut self.settings,
14532                decoder,
14533                offset + 0,
14534                _depth
14535            )?;
14536            fidl::decode!(
14537                VmoBuffer,
14538                fidl::encoding::DefaultFuchsiaResourceDialect,
14539                &mut self.buffer,
14540                decoder,
14541                offset + 264,
14542                _depth
14543            )?;
14544            Ok(())
14545        }
14546    }
14547
14548    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
14549        type Borrowed<'a> = &'a mut Self;
14550        fn take_or_borrow<'a>(
14551            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14552        ) -> Self::Borrowed<'a> {
14553            value
14554        }
14555    }
14556
14557    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
14558        type Owned = Self;
14559
14560        #[inline(always)]
14561        fn inline_align(_context: fidl::encoding::Context) -> usize {
14562            8
14563        }
14564
14565        #[inline(always)]
14566        fn inline_size(_context: fidl::encoding::Context) -> usize {
14567            16
14568        }
14569    }
14570
14571    unsafe impl fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14572        for &mut VmoBuffer
14573    {
14574        #[inline]
14575        unsafe fn encode(
14576            self,
14577            encoder: &mut fidl::encoding::Encoder<
14578                '_,
14579                fidl::encoding::DefaultFuchsiaResourceDialect,
14580            >,
14581            offset: usize,
14582            _depth: fidl::encoding::Depth,
14583        ) -> fidl::Result<()> {
14584            encoder.debug_check_bounds::<VmoBuffer>(offset);
14585            // Delegate to tuple encoding.
14586            fidl::encoding::Encode::<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14587                (
14588                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
14589                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_usable_start),
14590                ),
14591                encoder, offset, _depth
14592            )
14593        }
14594    }
14595    unsafe impl<
14596            T0: fidl::encoding::Encode<
14597                fidl::encoding::Optional<
14598                    fidl::encoding::HandleType<
14599                        fidl::Vmo,
14600                        { fidl::ObjectType::VMO.into_raw() },
14601                        2147483648,
14602                    >,
14603                >,
14604                fidl::encoding::DefaultFuchsiaResourceDialect,
14605            >,
14606            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
14607        > fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14608        for (T0, T1)
14609    {
14610        #[inline]
14611        unsafe fn encode(
14612            self,
14613            encoder: &mut fidl::encoding::Encoder<
14614                '_,
14615                fidl::encoding::DefaultFuchsiaResourceDialect,
14616            >,
14617            offset: usize,
14618            depth: fidl::encoding::Depth,
14619        ) -> fidl::Result<()> {
14620            encoder.debug_check_bounds::<VmoBuffer>(offset);
14621            // Zero out padding regions. There's no need to apply masks
14622            // because the unmasked parts will be overwritten by fields.
14623            unsafe {
14624                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14625                (ptr as *mut u64).write_unaligned(0);
14626            }
14627            // Write the fields.
14628            self.0.encode(encoder, offset + 0, depth)?;
14629            self.1.encode(encoder, offset + 8, depth)?;
14630            Ok(())
14631        }
14632    }
14633
14634    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoBuffer {
14635        #[inline(always)]
14636        fn new_empty() -> Self {
14637            Self {
14638                vmo: fidl::new_empty!(
14639                    fidl::encoding::Optional<
14640                        fidl::encoding::HandleType<
14641                            fidl::Vmo,
14642                            { fidl::ObjectType::VMO.into_raw() },
14643                            2147483648,
14644                        >,
14645                    >,
14646                    fidl::encoding::DefaultFuchsiaResourceDialect
14647                ),
14648                vmo_usable_start: fidl::new_empty!(
14649                    u64,
14650                    fidl::encoding::DefaultFuchsiaResourceDialect
14651                ),
14652            }
14653        }
14654
14655        #[inline]
14656        unsafe fn decode(
14657            &mut self,
14658            decoder: &mut fidl::encoding::Decoder<
14659                '_,
14660                fidl::encoding::DefaultFuchsiaResourceDialect,
14661            >,
14662            offset: usize,
14663            _depth: fidl::encoding::Depth,
14664        ) -> fidl::Result<()> {
14665            decoder.debug_check_bounds::<Self>(offset);
14666            // Verify that padding bytes are zero.
14667            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14668            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14669            let mask = 0xffffffff00000000u64;
14670            let maskedval = padval & mask;
14671            if maskedval != 0 {
14672                return Err(fidl::Error::NonZeroPadding {
14673                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14674                });
14675            }
14676            fidl::decode!(
14677                fidl::encoding::Optional<
14678                    fidl::encoding::HandleType<
14679                        fidl::Vmo,
14680                        { fidl::ObjectType::VMO.into_raw() },
14681                        2147483648,
14682                    >,
14683                >,
14684                fidl::encoding::DefaultFuchsiaResourceDialect,
14685                &mut self.vmo,
14686                decoder,
14687                offset + 0,
14688                _depth
14689            )?;
14690            fidl::decode!(
14691                u64,
14692                fidl::encoding::DefaultFuchsiaResourceDialect,
14693                &mut self.vmo_usable_start,
14694                decoder,
14695                offset + 8,
14696                _depth
14697            )?;
14698            Ok(())
14699        }
14700    }
14701
14702    impl BufferCollectionTokenGroupCreateChildRequest {
14703        #[inline(always)]
14704        fn max_ordinal_present(&self) -> u64 {
14705            if let Some(_) = self.rights_attenuation_mask {
14706                return 2;
14707            }
14708            if let Some(_) = self.token_request {
14709                return 1;
14710            }
14711            0
14712        }
14713    }
14714
14715    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14716        type Borrowed<'a> = &'a mut Self;
14717        fn take_or_borrow<'a>(
14718            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14719        ) -> Self::Borrowed<'a> {
14720            value
14721        }
14722    }
14723
14724    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14725        type Owned = Self;
14726
14727        #[inline(always)]
14728        fn inline_align(_context: fidl::encoding::Context) -> usize {
14729            8
14730        }
14731
14732        #[inline(always)]
14733        fn inline_size(_context: fidl::encoding::Context) -> usize {
14734            16
14735        }
14736    }
14737
14738    unsafe impl
14739        fidl::encoding::Encode<
14740            BufferCollectionTokenGroupCreateChildRequest,
14741            fidl::encoding::DefaultFuchsiaResourceDialect,
14742        > for &mut BufferCollectionTokenGroupCreateChildRequest
14743    {
14744        unsafe fn encode(
14745            self,
14746            encoder: &mut fidl::encoding::Encoder<
14747                '_,
14748                fidl::encoding::DefaultFuchsiaResourceDialect,
14749            >,
14750            offset: usize,
14751            mut depth: fidl::encoding::Depth,
14752        ) -> fidl::Result<()> {
14753            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
14754            // Vector header
14755            let max_ordinal: u64 = self.max_ordinal_present();
14756            encoder.write_num(max_ordinal, offset);
14757            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14758            // Calling encoder.out_of_line_offset(0) is not allowed.
14759            if max_ordinal == 0 {
14760                return Ok(());
14761            }
14762            depth.increment()?;
14763            let envelope_size = 8;
14764            let bytes_len = max_ordinal as usize * envelope_size;
14765            #[allow(unused_variables)]
14766            let offset = encoder.out_of_line_offset(bytes_len);
14767            let mut _prev_end_offset: usize = 0;
14768            if 1 > max_ordinal {
14769                return Ok(());
14770            }
14771
14772            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14773            // are envelope_size bytes.
14774            let cur_offset: usize = (1 - 1) * envelope_size;
14775
14776            // Zero reserved fields.
14777            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14778
14779            // Safety:
14780            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14781            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14782            //   envelope_size bytes, there is always sufficient room.
14783            fidl::encoding::encode_in_envelope_optional::<
14784                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
14785                fidl::encoding::DefaultFuchsiaResourceDialect,
14786            >(
14787                self.token_request.as_mut().map(
14788                    <fidl::encoding::Endpoint<
14789                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14790                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14791                ),
14792                encoder,
14793                offset + cur_offset,
14794                depth,
14795            )?;
14796
14797            _prev_end_offset = cur_offset + envelope_size;
14798            if 2 > max_ordinal {
14799                return Ok(());
14800            }
14801
14802            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14803            // are envelope_size bytes.
14804            let cur_offset: usize = (2 - 1) * envelope_size;
14805
14806            // Zero reserved fields.
14807            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14808
14809            // Safety:
14810            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14811            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14812            //   envelope_size bytes, there is always sufficient room.
14813            fidl::encoding::encode_in_envelope_optional::<
14814                u32,
14815                fidl::encoding::DefaultFuchsiaResourceDialect,
14816            >(
14817                self.rights_attenuation_mask
14818                    .as_ref()
14819                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
14820                encoder,
14821                offset + cur_offset,
14822                depth,
14823            )?;
14824
14825            _prev_end_offset = cur_offset + envelope_size;
14826
14827            Ok(())
14828        }
14829    }
14830
14831    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14832        for BufferCollectionTokenGroupCreateChildRequest
14833    {
14834        #[inline(always)]
14835        fn new_empty() -> Self {
14836            Self::default()
14837        }
14838
14839        unsafe fn decode(
14840            &mut self,
14841            decoder: &mut fidl::encoding::Decoder<
14842                '_,
14843                fidl::encoding::DefaultFuchsiaResourceDialect,
14844            >,
14845            offset: usize,
14846            mut depth: fidl::encoding::Depth,
14847        ) -> fidl::Result<()> {
14848            decoder.debug_check_bounds::<Self>(offset);
14849            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14850                None => return Err(fidl::Error::NotNullable),
14851                Some(len) => len,
14852            };
14853            // Calling decoder.out_of_line_offset(0) is not allowed.
14854            if len == 0 {
14855                return Ok(());
14856            };
14857            depth.increment()?;
14858            let envelope_size = 8;
14859            let bytes_len = len * envelope_size;
14860            let offset = decoder.out_of_line_offset(bytes_len)?;
14861            // Decode the envelope for each type.
14862            let mut _next_ordinal_to_read = 0;
14863            let mut next_offset = offset;
14864            let end_offset = offset + bytes_len;
14865            _next_ordinal_to_read += 1;
14866            if next_offset >= end_offset {
14867                return Ok(());
14868            }
14869
14870            // Decode unknown envelopes for gaps in ordinals.
14871            while _next_ordinal_to_read < 1 {
14872                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14873                _next_ordinal_to_read += 1;
14874                next_offset += envelope_size;
14875            }
14876
14877            let next_out_of_line = decoder.next_out_of_line();
14878            let handles_before = decoder.remaining_handles();
14879            if let Some((inlined, num_bytes, num_handles)) =
14880                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14881            {
14882                let member_inline_size = <fidl::encoding::Endpoint<
14883                    fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14884                > as fidl::encoding::TypeMarker>::inline_size(
14885                    decoder.context
14886                );
14887                if inlined != (member_inline_size <= 4) {
14888                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14889                }
14890                let inner_offset;
14891                let mut inner_depth = depth.clone();
14892                if inlined {
14893                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14894                    inner_offset = next_offset;
14895                } else {
14896                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14897                    inner_depth.increment()?;
14898                }
14899                let val_ref = self.token_request.get_or_insert_with(|| {
14900                    fidl::new_empty!(
14901                        fidl::encoding::Endpoint<
14902                            fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14903                        >,
14904                        fidl::encoding::DefaultFuchsiaResourceDialect
14905                    )
14906                });
14907                fidl::decode!(
14908                    fidl::encoding::Endpoint<
14909                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14910                    >,
14911                    fidl::encoding::DefaultFuchsiaResourceDialect,
14912                    val_ref,
14913                    decoder,
14914                    inner_offset,
14915                    inner_depth
14916                )?;
14917                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14918                {
14919                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14920                }
14921                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14922                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14923                }
14924            }
14925
14926            next_offset += envelope_size;
14927            _next_ordinal_to_read += 1;
14928            if next_offset >= end_offset {
14929                return Ok(());
14930            }
14931
14932            // Decode unknown envelopes for gaps in ordinals.
14933            while _next_ordinal_to_read < 2 {
14934                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14935                _next_ordinal_to_read += 1;
14936                next_offset += envelope_size;
14937            }
14938
14939            let next_out_of_line = decoder.next_out_of_line();
14940            let handles_before = decoder.remaining_handles();
14941            if let Some((inlined, num_bytes, num_handles)) =
14942                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14943            {
14944                let member_inline_size =
14945                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14946                if inlined != (member_inline_size <= 4) {
14947                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14948                }
14949                let inner_offset;
14950                let mut inner_depth = depth.clone();
14951                if inlined {
14952                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14953                    inner_offset = next_offset;
14954                } else {
14955                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14956                    inner_depth.increment()?;
14957                }
14958                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
14959                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
14960                });
14961                fidl::decode!(
14962                    u32,
14963                    fidl::encoding::DefaultFuchsiaResourceDialect,
14964                    val_ref,
14965                    decoder,
14966                    inner_offset,
14967                    inner_depth
14968                )?;
14969                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14970                {
14971                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14972                }
14973                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14974                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14975                }
14976            }
14977
14978            next_offset += envelope_size;
14979
14980            // Decode the remaining unknown envelopes.
14981            while next_offset < end_offset {
14982                _next_ordinal_to_read += 1;
14983                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14984                next_offset += envelope_size;
14985            }
14986
14987            Ok(())
14988        }
14989    }
14990}