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#[derive(Debug, Clone)]
530pub struct AllocatorProxy {
531    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
532}
533
534impl fidl::endpoints::Proxy for AllocatorProxy {
535    type Protocol = AllocatorMarker;
536
537    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
538        Self::new(inner)
539    }
540
541    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
542        self.client.into_channel().map_err(|client| Self { client })
543    }
544
545    fn as_channel(&self) -> &::fidl::AsyncChannel {
546        self.client.as_channel()
547    }
548}
549
550impl AllocatorProxy {
551    /// Create a new Proxy for fuchsia.sysmem/Allocator.
552    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
553        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
554        Self { client: fidl::client::Client::new(channel, protocol_name) }
555    }
556
557    /// Get a Stream of events from the remote end of the protocol.
558    ///
559    /// # Panics
560    ///
561    /// Panics if the event stream was already taken.
562    pub fn take_event_stream(&self) -> AllocatorEventStream {
563        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
564    }
565
566    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
567    /// who is also the only participant (from the point of view of sysmem).
568    ///
569    /// This call exists mainly for temp/testing purposes.  This call skips the
570    /// BufferCollectionToken stage, so there's no way to allow another
571    /// participant to specify its constraints.
572    ///
573    /// Real clients are encouraged to use AllocateSharedCollection() instead,
574    /// and to let relevant participants directly convey their own constraints to
575    /// sysmem.
576    ///
577    /// `collection_request` is the server end of the BufferCollection FIDL
578    /// channel.  The client can call SetConstraints() and then
579    /// WaitForBuffersAllocated() on the client end of this channel to specify
580    /// constraints and then determine success/failure and get the
581    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
582    /// keep the client end of this channel open while using the
583    /// BufferCollection, and should notice when this channel closes and stop
584    /// using the BufferCollection ASAP.
585    pub fn r#allocate_non_shared_collection(
586        &self,
587        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
588    ) -> Result<(), fidl::Error> {
589        AllocatorProxyInterface::r#allocate_non_shared_collection(self, collection_request)
590    }
591
592    /// Creates a logical BufferCollectionToken which can be shared among
593    /// participants (using BufferCollectionToken.Duplicate()), and then
594    /// converted into a BufferCollection using BindSharedCollection().
595    ///
596    /// Success/failure to populate the BufferCollection with buffers is
597    /// determined via the BufferCollection interface.
598    pub fn r#allocate_shared_collection(
599        &self,
600        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
601    ) -> Result<(), fidl::Error> {
602        AllocatorProxyInterface::r#allocate_shared_collection(self, token_request)
603    }
604
605    /// Convert a BufferCollectionToken into a connection to the logical
606    /// BufferCollection.  The BufferCollection hasn't yet been populated with
607    /// buffers - the participant must first also send SetConstraints() via the
608    /// client end of buffer_collection.
609    ///
610    /// All BufferCollectionToken(s) duplicated from a logical
611    /// BufferCollectionToken created via AllocateSharedCollection() must be
612    /// turned in via BindSharedCollection() before the logical BufferCollection
613    /// will be populated with buffers.
614    ///
615    /// `token` the client endpoint of a channel whose server end was sent to
616    /// sysmem using AllocateSharedCollection or whose server end was sent to
617    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
618    /// "exchanged" for a channel to the logical BufferCollection.
619    ///
620    /// `buffer_collection_request` the server end of a BufferCollection
621    /// channel.  The sender retains the client end as usual.  The
622    /// BufferCollection channel is a single participant's connection to the
623    /// logical BufferCollection.  There typically will be other participants
624    /// with their own BufferCollection channel to the logical BufferCollection.
625    pub fn r#bind_shared_collection(
626        &self,
627        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
628        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
629    ) -> Result<(), fidl::Error> {
630        AllocatorProxyInterface::r#bind_shared_collection(self, token, buffer_collection_request)
631    }
632
633    /// Validate that a BufferCollectionToken is known to the sysmem server.
634    ///
635    /// This can be used in cases where BindSharedCollection() won't be called
636    /// until after BufferCollectionToken.Duplicate() +
637    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
638    /// whether an incoming token is valid (so far).
639    ///
640    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
641    /// sysmem risks the Sync() hanging forever.
642    ///
643    /// Given that an incoming token can become invalid at any time if any
644    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
645    /// authors of client code are encouraged to consider not calling
646    /// ValidateBufferCollectionToken() and instead dealing with async failure
647    /// of the BufferCollection.Sync() after all the
648    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
649    /// sending any duplicate tokens to other processes).
650    ///
651    /// Regardless of the result of this call, this call has no effect on the
652    /// token with the referenced koid.
653    ///
654    /// A true result from this call doesn't guarantee that the token remains
655    /// valid for any duration afterwards.
656    ///
657    /// Client code will zx_object_get_info() on the client's token handle,
658    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
659    /// which then gets passed to ValidateBufferCollectionToken().
660    ///
661    /// If ValidateBufferCollectionToken() returns true, the token was known at
662    /// the time the sysmem server processed the call, but may no longer be
663    /// valid/known by the time the client code receives the response.
664    ///
665    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
666    /// at the time the sysmem server processed the call, but the token may
667    /// become known by the time the client code receives the response.  However
668    /// client code is not required to mitigate the possibility that the token
669    /// may become known late, since the source of the token should have synced
670    /// the token to sysmem before sending the token to the client code.
671    ///
672    /// If calling ValidateBufferCollectionToken() fails in some way, there will
673    /// be a zx_status_t from the FIDL layer.
674    ///
675    /// `token_server_koid` the koid of the server end of a channel that might
676    /// be a BufferCollectionToken channel.  This can be obtained from
677    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
678    pub fn r#validate_buffer_collection_token(
679        &self,
680        mut token_server_koid: u64,
681    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
682        AllocatorProxyInterface::r#validate_buffer_collection_token(self, token_server_koid)
683    }
684
685    /// Set information about the current client that can be used by sysmem to
686    /// help debug leaking memory and hangs waiting for constraints. |name| can
687    /// be an arbitrary string, but the current process name (see
688    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
689    /// arbitrary id, but the current process ID (see
690    /// fsl::GetCurrentProcessKoid()) is a good default.
691    ///
692    /// This information is propagated to all BufferCollections created using
693    /// BindSharedCollection() or AllocateNonSharedCollection() from this
694    /// allocator. It does not affect BufferCollectionTokens, since they are
695    /// often passed cross-process and should have their names managed manually.
696    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
697        AllocatorProxyInterface::r#set_debug_client_info(self, name, id)
698    }
699
700    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
701    /// `Allocator`.
702    ///
703    /// This is mainly useful in situations where library code is handed a
704    /// sysmem(1) allocator, but the library code has been updated to use
705    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
706    /// `Allocator` instead, but client code isn't always in the same repo, so
707    /// this message allows the library to still accept the sysmem(1) Allocator
708    /// temporarily.
709    ///
710    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
711    /// `Allocator`.
712    pub fn r#connect_to_sysmem2_allocator(
713        &self,
714        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
715    ) -> Result<(), fidl::Error> {
716        AllocatorProxyInterface::r#connect_to_sysmem2_allocator(self, allocator_request)
717    }
718}
719
720impl AllocatorProxyInterface for AllocatorProxy {
721    fn r#allocate_non_shared_collection(
722        &self,
723        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
724    ) -> Result<(), fidl::Error> {
725        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
726            (collection_request,),
727            0x20f79299bbb4d2c6,
728            fidl::encoding::DynamicFlags::empty(),
729        )
730    }
731
732    fn r#allocate_shared_collection(
733        &self,
734        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
735    ) -> Result<(), fidl::Error> {
736        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
737            (token_request,),
738            0x7a757a57bfda0f71,
739            fidl::encoding::DynamicFlags::empty(),
740        )
741    }
742
743    fn r#bind_shared_collection(
744        &self,
745        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
746        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
747    ) -> Result<(), fidl::Error> {
748        self.client.send::<AllocatorBindSharedCollectionRequest>(
749            (token, buffer_collection_request),
750            0x146eca7ec46ff4ee,
751            fidl::encoding::DynamicFlags::empty(),
752        )
753    }
754
755    type ValidateBufferCollectionTokenResponseFut =
756        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
757    fn r#validate_buffer_collection_token(
758        &self,
759        mut token_server_koid: u64,
760    ) -> Self::ValidateBufferCollectionTokenResponseFut {
761        fn _decode(
762            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
763        ) -> Result<bool, fidl::Error> {
764            let _response = fidl::client::decode_transaction_body::<
765                AllocatorValidateBufferCollectionTokenResponse,
766                fidl::encoding::DefaultFuchsiaResourceDialect,
767                0x575b279b0236faea,
768            >(_buf?)?;
769            Ok(_response.is_known)
770        }
771        self.client.send_query_and_decode::<AllocatorValidateBufferCollectionTokenRequest, bool>(
772            (token_server_koid,),
773            0x575b279b0236faea,
774            fidl::encoding::DynamicFlags::empty(),
775            _decode,
776        )
777    }
778
779    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
780        self.client.send::<AllocatorSetDebugClientInfoRequest>(
781            (name, id),
782            0x419f0d5b30728b26,
783            fidl::encoding::DynamicFlags::empty(),
784        )
785    }
786
787    fn r#connect_to_sysmem2_allocator(
788        &self,
789        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
790    ) -> Result<(), fidl::Error> {
791        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
792            (allocator_request,),
793            0x13db3e3abac2e24,
794            fidl::encoding::DynamicFlags::empty(),
795        )
796    }
797}
798
799pub struct AllocatorEventStream {
800    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
801}
802
803impl std::marker::Unpin for AllocatorEventStream {}
804
805impl futures::stream::FusedStream for AllocatorEventStream {
806    fn is_terminated(&self) -> bool {
807        self.event_receiver.is_terminated()
808    }
809}
810
811impl futures::Stream for AllocatorEventStream {
812    type Item = Result<AllocatorEvent, fidl::Error>;
813
814    fn poll_next(
815        mut self: std::pin::Pin<&mut Self>,
816        cx: &mut std::task::Context<'_>,
817    ) -> std::task::Poll<Option<Self::Item>> {
818        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
819            &mut self.event_receiver,
820            cx
821        )?) {
822            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
823            None => std::task::Poll::Ready(None),
824        }
825    }
826}
827
828#[derive(Debug)]
829pub enum AllocatorEvent {}
830
831impl AllocatorEvent {
832    /// Decodes a message buffer as a [`AllocatorEvent`].
833    fn decode(
834        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
835    ) -> Result<AllocatorEvent, fidl::Error> {
836        let (bytes, _handles) = buf.split_mut();
837        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
838        debug_assert_eq!(tx_header.tx_id, 0);
839        match tx_header.ordinal {
840            _ => Err(fidl::Error::UnknownOrdinal {
841                ordinal: tx_header.ordinal,
842                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
843            }),
844        }
845    }
846}
847
848/// A Stream of incoming requests for fuchsia.sysmem/Allocator.
849pub struct AllocatorRequestStream {
850    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
851    is_terminated: bool,
852}
853
854impl std::marker::Unpin for AllocatorRequestStream {}
855
856impl futures::stream::FusedStream for AllocatorRequestStream {
857    fn is_terminated(&self) -> bool {
858        self.is_terminated
859    }
860}
861
862impl fidl::endpoints::RequestStream for AllocatorRequestStream {
863    type Protocol = AllocatorMarker;
864    type ControlHandle = AllocatorControlHandle;
865
866    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
867        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
868    }
869
870    fn control_handle(&self) -> Self::ControlHandle {
871        AllocatorControlHandle { inner: self.inner.clone() }
872    }
873
874    fn into_inner(
875        self,
876    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
877    {
878        (self.inner, self.is_terminated)
879    }
880
881    fn from_inner(
882        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
883        is_terminated: bool,
884    ) -> Self {
885        Self { inner, is_terminated }
886    }
887}
888
889impl futures::Stream for AllocatorRequestStream {
890    type Item = Result<AllocatorRequest, fidl::Error>;
891
892    fn poll_next(
893        mut self: std::pin::Pin<&mut Self>,
894        cx: &mut std::task::Context<'_>,
895    ) -> std::task::Poll<Option<Self::Item>> {
896        let this = &mut *self;
897        if this.inner.check_shutdown(cx) {
898            this.is_terminated = true;
899            return std::task::Poll::Ready(None);
900        }
901        if this.is_terminated {
902            panic!("polled AllocatorRequestStream after completion");
903        }
904        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
905            |bytes, handles| {
906                match this.inner.channel().read_etc(cx, bytes, handles) {
907                    std::task::Poll::Ready(Ok(())) => {}
908                    std::task::Poll::Pending => return std::task::Poll::Pending,
909                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
910                        this.is_terminated = true;
911                        return std::task::Poll::Ready(None);
912                    }
913                    std::task::Poll::Ready(Err(e)) => {
914                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
915                            e.into(),
916                        ))))
917                    }
918                }
919
920                // A message has been received from the channel
921                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
922
923                std::task::Poll::Ready(Some(match header.ordinal {
924                    0x20f79299bbb4d2c6 => {
925                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
926                        let mut req = fidl::new_empty!(
927                            AllocatorAllocateNonSharedCollectionRequest,
928                            fidl::encoding::DefaultFuchsiaResourceDialect
929                        );
930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
931                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
932                        Ok(AllocatorRequest::AllocateNonSharedCollection {
933                            collection_request: req.collection_request,
934
935                            control_handle,
936                        })
937                    }
938                    0x7a757a57bfda0f71 => {
939                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
940                        let mut req = fidl::new_empty!(
941                            AllocatorAllocateSharedCollectionRequest,
942                            fidl::encoding::DefaultFuchsiaResourceDialect
943                        );
944                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
945                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
946                        Ok(AllocatorRequest::AllocateSharedCollection {
947                            token_request: req.token_request,
948
949                            control_handle,
950                        })
951                    }
952                    0x146eca7ec46ff4ee => {
953                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
954                        let mut req = fidl::new_empty!(
955                            AllocatorBindSharedCollectionRequest,
956                            fidl::encoding::DefaultFuchsiaResourceDialect
957                        );
958                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
959                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
960                        Ok(AllocatorRequest::BindSharedCollection {
961                            token: req.token,
962                            buffer_collection_request: req.buffer_collection_request,
963
964                            control_handle,
965                        })
966                    }
967                    0x575b279b0236faea => {
968                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
969                        let mut req = fidl::new_empty!(
970                            AllocatorValidateBufferCollectionTokenRequest,
971                            fidl::encoding::DefaultFuchsiaResourceDialect
972                        );
973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
974                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
975                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
976                            token_server_koid: req.token_server_koid,
977
978                            responder: AllocatorValidateBufferCollectionTokenResponder {
979                                control_handle: std::mem::ManuallyDrop::new(control_handle),
980                                tx_id: header.tx_id,
981                            },
982                        })
983                    }
984                    0x419f0d5b30728b26 => {
985                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
986                        let mut req = fidl::new_empty!(
987                            AllocatorSetDebugClientInfoRequest,
988                            fidl::encoding::DefaultFuchsiaResourceDialect
989                        );
990                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
991                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
992                        Ok(AllocatorRequest::SetDebugClientInfo {
993                            name: req.name,
994                            id: req.id,
995
996                            control_handle,
997                        })
998                    }
999                    0x13db3e3abac2e24 => {
1000                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1001                        let mut req = fidl::new_empty!(
1002                            AllocatorConnectToSysmem2AllocatorRequest,
1003                            fidl::encoding::DefaultFuchsiaResourceDialect
1004                        );
1005                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorConnectToSysmem2AllocatorRequest>(&header, _body_bytes, handles, &mut req)?;
1006                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1007                        Ok(AllocatorRequest::ConnectToSysmem2Allocator {
1008                            allocator_request: req.allocator_request,
1009
1010                            control_handle,
1011                        })
1012                    }
1013                    _ => Err(fidl::Error::UnknownOrdinal {
1014                        ordinal: header.ordinal,
1015                        protocol_name:
1016                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1017                    }),
1018                }))
1019            },
1020        )
1021    }
1022}
1023
1024/// Allocates system memory buffers.
1025#[derive(Debug)]
1026pub enum AllocatorRequest {
1027    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
1028    /// who is also the only participant (from the point of view of sysmem).
1029    ///
1030    /// This call exists mainly for temp/testing purposes.  This call skips the
1031    /// BufferCollectionToken stage, so there's no way to allow another
1032    /// participant to specify its constraints.
1033    ///
1034    /// Real clients are encouraged to use AllocateSharedCollection() instead,
1035    /// and to let relevant participants directly convey their own constraints to
1036    /// sysmem.
1037    ///
1038    /// `collection_request` is the server end of the BufferCollection FIDL
1039    /// channel.  The client can call SetConstraints() and then
1040    /// WaitForBuffersAllocated() on the client end of this channel to specify
1041    /// constraints and then determine success/failure and get the
1042    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
1043    /// keep the client end of this channel open while using the
1044    /// BufferCollection, and should notice when this channel closes and stop
1045    /// using the BufferCollection ASAP.
1046    AllocateNonSharedCollection {
1047        collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1048        control_handle: AllocatorControlHandle,
1049    },
1050    /// Creates a logical BufferCollectionToken which can be shared among
1051    /// participants (using BufferCollectionToken.Duplicate()), and then
1052    /// converted into a BufferCollection using BindSharedCollection().
1053    ///
1054    /// Success/failure to populate the BufferCollection with buffers is
1055    /// determined via the BufferCollection interface.
1056    AllocateSharedCollection {
1057        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1058        control_handle: AllocatorControlHandle,
1059    },
1060    /// Convert a BufferCollectionToken into a connection to the logical
1061    /// BufferCollection.  The BufferCollection hasn't yet been populated with
1062    /// buffers - the participant must first also send SetConstraints() via the
1063    /// client end of buffer_collection.
1064    ///
1065    /// All BufferCollectionToken(s) duplicated from a logical
1066    /// BufferCollectionToken created via AllocateSharedCollection() must be
1067    /// turned in via BindSharedCollection() before the logical BufferCollection
1068    /// will be populated with buffers.
1069    ///
1070    /// `token` the client endpoint of a channel whose server end was sent to
1071    /// sysmem using AllocateSharedCollection or whose server end was sent to
1072    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
1073    /// "exchanged" for a channel to the logical BufferCollection.
1074    ///
1075    /// `buffer_collection_request` the server end of a BufferCollection
1076    /// channel.  The sender retains the client end as usual.  The
1077    /// BufferCollection channel is a single participant's connection to the
1078    /// logical BufferCollection.  There typically will be other participants
1079    /// with their own BufferCollection channel to the logical BufferCollection.
1080    BindSharedCollection {
1081        token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1082        buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1083        control_handle: AllocatorControlHandle,
1084    },
1085    /// Validate that a BufferCollectionToken is known to the sysmem server.
1086    ///
1087    /// This can be used in cases where BindSharedCollection() won't be called
1088    /// until after BufferCollectionToken.Duplicate() +
1089    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
1090    /// whether an incoming token is valid (so far).
1091    ///
1092    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
1093    /// sysmem risks the Sync() hanging forever.
1094    ///
1095    /// Given that an incoming token can become invalid at any time if any
1096    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
1097    /// authors of client code are encouraged to consider not calling
1098    /// ValidateBufferCollectionToken() and instead dealing with async failure
1099    /// of the BufferCollection.Sync() after all the
1100    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
1101    /// sending any duplicate tokens to other processes).
1102    ///
1103    /// Regardless of the result of this call, this call has no effect on the
1104    /// token with the referenced koid.
1105    ///
1106    /// A true result from this call doesn't guarantee that the token remains
1107    /// valid for any duration afterwards.
1108    ///
1109    /// Client code will zx_object_get_info() on the client's token handle,
1110    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
1111    /// which then gets passed to ValidateBufferCollectionToken().
1112    ///
1113    /// If ValidateBufferCollectionToken() returns true, the token was known at
1114    /// the time the sysmem server processed the call, but may no longer be
1115    /// valid/known by the time the client code receives the response.
1116    ///
1117    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
1118    /// at the time the sysmem server processed the call, but the token may
1119    /// become known by the time the client code receives the response.  However
1120    /// client code is not required to mitigate the possibility that the token
1121    /// may become known late, since the source of the token should have synced
1122    /// the token to sysmem before sending the token to the client code.
1123    ///
1124    /// If calling ValidateBufferCollectionToken() fails in some way, there will
1125    /// be a zx_status_t from the FIDL layer.
1126    ///
1127    /// `token_server_koid` the koid of the server end of a channel that might
1128    /// be a BufferCollectionToken channel.  This can be obtained from
1129    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
1130    ValidateBufferCollectionToken {
1131        token_server_koid: u64,
1132        responder: AllocatorValidateBufferCollectionTokenResponder,
1133    },
1134    /// Set information about the current client that can be used by sysmem to
1135    /// help debug leaking memory and hangs waiting for constraints. |name| can
1136    /// be an arbitrary string, but the current process name (see
1137    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1138    /// arbitrary id, but the current process ID (see
1139    /// fsl::GetCurrentProcessKoid()) is a good default.
1140    ///
1141    /// This information is propagated to all BufferCollections created using
1142    /// BindSharedCollection() or AllocateNonSharedCollection() from this
1143    /// allocator. It does not affect BufferCollectionTokens, since they are
1144    /// often passed cross-process and should have their names managed manually.
1145    SetDebugClientInfo { name: String, id: u64, control_handle: AllocatorControlHandle },
1146    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
1147    /// `Allocator`.
1148    ///
1149    /// This is mainly useful in situations where library code is handed a
1150    /// sysmem(1) allocator, but the library code has been updated to use
1151    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
1152    /// `Allocator` instead, but client code isn't always in the same repo, so
1153    /// this message allows the library to still accept the sysmem(1) Allocator
1154    /// temporarily.
1155    ///
1156    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
1157    /// `Allocator`.
1158    ConnectToSysmem2Allocator {
1159        allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1160        control_handle: AllocatorControlHandle,
1161    },
1162}
1163
1164impl AllocatorRequest {
1165    #[allow(irrefutable_let_patterns)]
1166    pub fn into_allocate_non_shared_collection(
1167        self,
1168    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionMarker>, AllocatorControlHandle)> {
1169        if let AllocatorRequest::AllocateNonSharedCollection {
1170            collection_request,
1171            control_handle,
1172        } = self
1173        {
1174            Some((collection_request, control_handle))
1175        } else {
1176            None
1177        }
1178    }
1179
1180    #[allow(irrefutable_let_patterns)]
1181    pub fn into_allocate_shared_collection(
1182        self,
1183    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>, AllocatorControlHandle)>
1184    {
1185        if let AllocatorRequest::AllocateSharedCollection { token_request, control_handle } = self {
1186            Some((token_request, control_handle))
1187        } else {
1188            None
1189        }
1190    }
1191
1192    #[allow(irrefutable_let_patterns)]
1193    pub fn into_bind_shared_collection(
1194        self,
1195    ) -> Option<(
1196        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1197        fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1198        AllocatorControlHandle,
1199    )> {
1200        if let AllocatorRequest::BindSharedCollection {
1201            token,
1202            buffer_collection_request,
1203            control_handle,
1204        } = self
1205        {
1206            Some((token, buffer_collection_request, control_handle))
1207        } else {
1208            None
1209        }
1210    }
1211
1212    #[allow(irrefutable_let_patterns)]
1213    pub fn into_validate_buffer_collection_token(
1214        self,
1215    ) -> Option<(u64, AllocatorValidateBufferCollectionTokenResponder)> {
1216        if let AllocatorRequest::ValidateBufferCollectionToken { token_server_koid, responder } =
1217            self
1218        {
1219            Some((token_server_koid, responder))
1220        } else {
1221            None
1222        }
1223    }
1224
1225    #[allow(irrefutable_let_patterns)]
1226    pub fn into_set_debug_client_info(self) -> Option<(String, u64, AllocatorControlHandle)> {
1227        if let AllocatorRequest::SetDebugClientInfo { name, id, control_handle } = self {
1228            Some((name, id, control_handle))
1229        } else {
1230            None
1231        }
1232    }
1233
1234    #[allow(irrefutable_let_patterns)]
1235    pub fn into_connect_to_sysmem2_allocator(
1236        self,
1237    ) -> Option<(
1238        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1239        AllocatorControlHandle,
1240    )> {
1241        if let AllocatorRequest::ConnectToSysmem2Allocator { allocator_request, control_handle } =
1242            self
1243        {
1244            Some((allocator_request, control_handle))
1245        } else {
1246            None
1247        }
1248    }
1249
1250    /// Name of the method defined in FIDL
1251    pub fn method_name(&self) -> &'static str {
1252        match *self {
1253            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1254                "allocate_non_shared_collection"
1255            }
1256            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1257            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1258            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1259                "validate_buffer_collection_token"
1260            }
1261            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1262            AllocatorRequest::ConnectToSysmem2Allocator { .. } => "connect_to_sysmem2_allocator",
1263        }
1264    }
1265}
1266
1267#[derive(Debug, Clone)]
1268pub struct AllocatorControlHandle {
1269    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1270}
1271
1272impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
1273    fn shutdown(&self) {
1274        self.inner.shutdown()
1275    }
1276    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1277        self.inner.shutdown_with_epitaph(status)
1278    }
1279
1280    fn is_closed(&self) -> bool {
1281        self.inner.channel().is_closed()
1282    }
1283    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1284        self.inner.channel().on_closed()
1285    }
1286
1287    #[cfg(target_os = "fuchsia")]
1288    fn signal_peer(
1289        &self,
1290        clear_mask: zx::Signals,
1291        set_mask: zx::Signals,
1292    ) -> Result<(), zx_status::Status> {
1293        use fidl::Peered;
1294        self.inner.channel().signal_peer(clear_mask, set_mask)
1295    }
1296}
1297
1298impl AllocatorControlHandle {}
1299
1300#[must_use = "FIDL methods require a response to be sent"]
1301#[derive(Debug)]
1302pub struct AllocatorValidateBufferCollectionTokenResponder {
1303    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1304    tx_id: u32,
1305}
1306
1307/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1308/// if the responder is dropped without sending a response, so that the client
1309/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1310impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1311    fn drop(&mut self) {
1312        self.control_handle.shutdown();
1313        // Safety: drops once, never accessed again
1314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1315    }
1316}
1317
1318impl fidl::endpoints::Responder for AllocatorValidateBufferCollectionTokenResponder {
1319    type ControlHandle = AllocatorControlHandle;
1320
1321    fn control_handle(&self) -> &AllocatorControlHandle {
1322        &self.control_handle
1323    }
1324
1325    fn drop_without_shutdown(mut self) {
1326        // Safety: drops once, never accessed again due to mem::forget
1327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1328        // Prevent Drop from running (which would shut down the channel)
1329        std::mem::forget(self);
1330    }
1331}
1332
1333impl AllocatorValidateBufferCollectionTokenResponder {
1334    /// Sends a response to the FIDL transaction.
1335    ///
1336    /// Sets the channel to shutdown if an error occurs.
1337    pub fn send(self, mut is_known: bool) -> Result<(), fidl::Error> {
1338        let _result = self.send_raw(is_known);
1339        if _result.is_err() {
1340            self.control_handle.shutdown();
1341        }
1342        self.drop_without_shutdown();
1343        _result
1344    }
1345
1346    /// Similar to "send" but does not shutdown the channel if an error occurs.
1347    pub fn send_no_shutdown_on_err(self, mut is_known: bool) -> Result<(), fidl::Error> {
1348        let _result = self.send_raw(is_known);
1349        self.drop_without_shutdown();
1350        _result
1351    }
1352
1353    fn send_raw(&self, mut is_known: bool) -> Result<(), fidl::Error> {
1354        self.control_handle.inner.send::<AllocatorValidateBufferCollectionTokenResponse>(
1355            (is_known,),
1356            self.tx_id,
1357            0x575b279b0236faea,
1358            fidl::encoding::DynamicFlags::empty(),
1359        )
1360    }
1361}
1362
1363#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1364pub struct BufferCollectionMarker;
1365
1366impl fidl::endpoints::ProtocolMarker for BufferCollectionMarker {
1367    type Proxy = BufferCollectionProxy;
1368    type RequestStream = BufferCollectionRequestStream;
1369    #[cfg(target_os = "fuchsia")]
1370    type SynchronousProxy = BufferCollectionSynchronousProxy;
1371
1372    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1373}
1374
1375pub trait BufferCollectionProxyInterface: Send + Sync {
1376    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1377    fn r#sync(&self) -> Self::SyncResponseFut;
1378    fn r#close(&self) -> Result<(), fidl::Error>;
1379    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
1380    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
1381    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
1382    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1383    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
1384        + Send;
1385    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1386    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1387        + Send;
1388    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
1389    fn r#set_constraints(
1390        &self,
1391        has_constraints: bool,
1392        constraints: &BufferCollectionConstraints,
1393    ) -> Result<(), fidl::Error>;
1394    type WaitForBuffersAllocatedResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1395        + Send;
1396    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut;
1397    type CheckBuffersAllocatedResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1398        + Send;
1399    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut;
1400    fn r#set_constraints_aux_buffers(
1401        &self,
1402        constraints: &BufferCollectionConstraintsAuxBuffers,
1403    ) -> Result<(), fidl::Error>;
1404    type GetAuxBuffersResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1405        + Send;
1406    fn r#get_aux_buffers(&self) -> Self::GetAuxBuffersResponseFut;
1407    fn r#attach_token(
1408        &self,
1409        rights_attenuation_mask: u32,
1410        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1411    ) -> Result<(), fidl::Error>;
1412    fn r#attach_lifetime_tracking(
1413        &self,
1414        server_end: fidl::EventPair,
1415        buffers_remaining: u32,
1416    ) -> Result<(), fidl::Error>;
1417}
1418#[derive(Debug)]
1419#[cfg(target_os = "fuchsia")]
1420pub struct BufferCollectionSynchronousProxy {
1421    client: fidl::client::sync::Client,
1422}
1423
1424#[cfg(target_os = "fuchsia")]
1425impl fidl::endpoints::SynchronousProxy for BufferCollectionSynchronousProxy {
1426    type Proxy = BufferCollectionProxy;
1427    type Protocol = BufferCollectionMarker;
1428
1429    fn from_channel(inner: fidl::Channel) -> Self {
1430        Self::new(inner)
1431    }
1432
1433    fn into_channel(self) -> fidl::Channel {
1434        self.client.into_channel()
1435    }
1436
1437    fn as_channel(&self) -> &fidl::Channel {
1438        self.client.as_channel()
1439    }
1440}
1441
1442#[cfg(target_os = "fuchsia")]
1443impl BufferCollectionSynchronousProxy {
1444    pub fn new(channel: fidl::Channel) -> Self {
1445        let protocol_name = <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1446        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1447    }
1448
1449    pub fn into_channel(self) -> fidl::Channel {
1450        self.client.into_channel()
1451    }
1452
1453    /// Waits until an event arrives and returns it. It is safe for other
1454    /// threads to make concurrent requests while waiting for an event.
1455    pub fn wait_for_event(
1456        &self,
1457        deadline: zx::MonotonicInstant,
1458    ) -> Result<BufferCollectionEvent, fidl::Error> {
1459        BufferCollectionEvent::decode(self.client.wait_for_event(deadline)?)
1460    }
1461
1462    /// Ensure that previous messages, including Duplicate() messages on a
1463    /// token, collection, or group, have been received server side.
1464    ///
1465    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
1466    /// valid sysmem token risks the Sync() hanging forever.  See
1467    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
1468    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
1469    /// Another way is to pass the token to BindSharedCollection(), which also
1470    /// validates the token as part of exchanging it for a BufferCollection
1471    /// channel, and BufferCollection Sync() can then be used.
1472    ///
1473    /// After a Sync(), it's then safe to send the client end of token_request
1474    /// to another participant knowing the server will recognize the token when
1475    /// it's sent into BindSharedCollection() by the other participant.
1476    ///
1477    /// Other options include waiting for each token.Duplicate() to complete
1478    /// individually (using separate call to token.Sync() after each), or
1479    /// calling Sync() on BufferCollection after the token has been turned in
1480    /// via BindSharedCollection().
1481    ///
1482    /// Another way to mitigate is to avoid calling Sync() on the token, and
1483    /// instead later deal with potential failure of BufferCollection.Sync() if
1484    /// the original token was invalid.  This option can be preferable from a
1485    /// performance point of view, but requires client code to delay sending
1486    /// tokens duplicated from this token until after client code has converted
1487    /// the duplicating token to a BufferCollection and received successful
1488    /// response from BufferCollection.Sync().
1489    ///
1490    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
1491    /// When BufferCollection.Sync() isn't feasible, the caller must already
1492    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
1493    /// hang forever.  See ValidateBufferCollectionToken() to check token
1494    /// validity first if the token isn't already known to be (is/was) valid.
1495    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1496        let _response =
1497            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1498                (),
1499                0x4577e238ae26291,
1500                fidl::encoding::DynamicFlags::empty(),
1501                ___deadline,
1502            )?;
1503        Ok(_response)
1504    }
1505
1506    /// On a BufferCollectionToken channel:
1507    ///
1508    /// Normally a participant will convert a BufferCollectionToken into a
1509    /// BufferCollection view, but a participant is also free to Close() the
1510    /// token (and then close the channel immediately or shortly later in
1511    /// response to server closing its end), which avoids causing logical buffer
1512    /// collection failure.  Normally an unexpected token channel close will
1513    /// cause logical buffer collection failure (the only exceptions being
1514    /// certain cases involving AttachToken() or SetDispensable()).
1515    ///
1516    /// On a BufferCollection channel:
1517    ///
1518    /// By default the server handles unexpected failure of a BufferCollection
1519    /// by failing the whole logical buffer collection.  Partly this is to
1520    /// expedite closing VMO handles to reclaim memory when any participant
1521    /// fails.  If a participant would like to cleanly close a BufferCollection
1522    /// view without causing logical buffer collection failure, the participant
1523    /// can send Close() before closing the client end of the BufferCollection
1524    /// channel.  If this is the last BufferCollection view, the logical buffer
1525    /// collection will still go away.  The Close() can occur before or after
1526    /// SetConstraints().  If before SetConstraints(), the buffer collection
1527    /// won't require constraints from this node in order to allocate.  If
1528    /// after SetConstraints(), the constraints are retained and aggregated
1529    /// along with any subsequent logical allocation(s), despite the lack of
1530    /// channel connection.
1531    ///
1532    /// On a BufferCollectionTokenGroup channel:
1533    ///
1534    /// By default, unexpected failure of a BufferCollectionTokenGroup will
1535    /// trigger failure of the logical BufferCollectionTokenGroup and will
1536    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
1537    /// channel without failing the logical group or propagating failure, send
1538    /// Close() before closing the channel client endpoint.
1539    ///
1540    /// If Close() occurs before AllChildrenPresent(), the logical buffer
1541    /// collection will still fail despite the Close() (because sysmem can't be
1542    /// sure whether all relevant children were created, so it's ambiguous
1543    /// whether all relevant constraints will be provided to sysmem).  If
1544    /// Close() occurs after AllChildrenPresent(), the children and all their
1545    /// constraints remain intact (just as they would if the
1546    /// BufferCollectionTokenGroup channel had remained open), and the close
1547    /// doesn't trigger or propagate failure.
1548    pub fn r#close(&self) -> Result<(), fidl::Error> {
1549        self.client.send::<fidl::encoding::EmptyPayload>(
1550            (),
1551            0x5b1d7a4f5681fca7,
1552            fidl::encoding::DynamicFlags::empty(),
1553        )
1554    }
1555
1556    /// Set a name for VMOs in this buffer collection. The name may be truncated
1557    /// shorter. The name only affects VMOs allocated after it's set - this call
1558    /// does not rename existing VMOs. If multiple clients set different names
1559    /// then the larger priority value will win.
1560    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1561        self.client.send::<NodeSetNameRequest>(
1562            (priority, name),
1563            0x77a41bb6217e2443,
1564            fidl::encoding::DynamicFlags::empty(),
1565        )
1566    }
1567
1568    /// Set information about the current client that can be used by sysmem to
1569    /// help debug leaking memory and hangs waiting for constraints. |name| can
1570    /// be an arbitrary string, but the current process name (see
1571    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1572    /// arbitrary id, but the current process ID (see
1573    /// fsl::GetCurrentProcessKoid()) is a good default.
1574    ///
1575    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
1576    /// indicate which client is closing their channel first, leading to
1577    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
1578    /// over, but if happening earlier than expected, the
1579    /// client-channel-specific name can help diagnose where the failure is
1580    /// first coming from, from sysmem's point of view).
1581    ///
1582    /// By default (unless overriden by this message or using
1583    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
1584    /// parent Node at the time the child Node is created.  While this can be
1585    /// better than nothing, it's often better for each participant to use
1586    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
1587    /// info directly relevant to the current client.  Also, SetVerboseLogging()
1588    /// can be used to help disambiguate if a Node is suspected of having info
1589    /// that was copied from its parent.
1590    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1591        self.client.send::<NodeSetDebugClientInfoRequest>(
1592            (name, id),
1593            0x7275759070eb5ee2,
1594            fidl::encoding::DynamicFlags::empty(),
1595        )
1596    }
1597
1598    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
1599    /// after creating a collection. Clients can call this method to change
1600    /// when the log is printed. If multiple client set the deadline, it's
1601    /// unspecified which deadline will take effect.
1602    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1603        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
1604            (deadline,),
1605            0x46d38f4772638867,
1606            fidl::encoding::DynamicFlags::empty(),
1607        )
1608    }
1609
1610    /// Verbose logging includes constraints set via SetConstraints() from each
1611    /// client along with info set via SetDebugClientInfo() and the structure of
1612    /// the tree of Node(s).
1613    ///
1614    /// Normally sysmem prints only a single line complaint when aggregation
1615    /// fails, with just the specific detailed reason that aggregation failed,
1616    /// with minimal context.  While this is often enough to diagnose a problem
1617    /// if only a small change was made and the system had been working before
1618    /// the small change, it's often not particularly helpful for getting a new
1619    /// buffer collection to work for the first time.  Especially with more
1620    /// complex trees of nodes, involving things like AttachToken(),
1621    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
1622    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
1623    /// looks like and why it's failing a logical allocation, or why a tree or
1624    /// sub-tree is failing sooner than expected.
1625    ///
1626    /// The intent of the extra logging is to be acceptable from a performance
1627    /// point of view, if only enabled on a low number of buffer collections.
1628    /// If we're not tracking down a bug, we shouldn't send this message.
1629    ///
1630    /// If too many participants leave verbose logging enabled, we may end up
1631    /// needing to require that system-wide sysmem verbose logging be permitted
1632    /// via some other setting, to avoid sysmem spamming the log too much due to
1633    /// this message.
1634    ///
1635    /// This may be a NOP for some nodes due to intentional policy associated
1636    /// with the node, if we don't trust a node enough to let it turn on verbose
1637    /// logging.
1638    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1639        self.client.send::<fidl::encoding::EmptyPayload>(
1640            (),
1641            0x6bfbe2cf1701d288,
1642            fidl::encoding::DynamicFlags::empty(),
1643        )
1644    }
1645
1646    /// This gets an event handle that can be used as a parameter to
1647    /// IsAlternateFor() called on any Node.  The client will not be granted the
1648    /// right to signal this event, as this handle should only be used as proof
1649    /// that the client obtained this handle from this Node.
1650    ///
1651    /// Because this is a get not a set, no Sync() is needed between the
1652    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
1653    /// potentially being on different channels.
1654    ///
1655    /// See also IsAlternateFor().
1656    pub fn r#get_node_ref(
1657        &self,
1658        ___deadline: zx::MonotonicInstant,
1659    ) -> Result<fidl::Event, fidl::Error> {
1660        let _response =
1661            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
1662                (),
1663                0x467b7c75c35c3b84,
1664                fidl::encoding::DynamicFlags::empty(),
1665                ___deadline,
1666            )?;
1667        Ok(_response.node_ref)
1668    }
1669
1670    /// This checks whether the calling node is in a subtree rooted at a
1671    /// different child token of a common parent BufferCollectionTokenGroup, in
1672    /// relation to the passed-in node_ref.
1673    ///
1674    /// This call is for assisting with admission control de-duplication, and
1675    /// with debugging.
1676    ///
1677    /// The node_ref must be obtained using GetNodeRef() of a
1678    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
1679    ///
1680    /// The node_ref can be a duplicated handle; it's not necessary to call
1681    /// GetNodeRef() for every call to IsAlternateFor().
1682    ///
1683    /// If a calling token may not actually be a valid token at all due to
1684    /// a potentially hostile/untrusted provider of the token, call
1685    /// ValidateBufferCollectionToken() first instead of potentially getting
1686    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
1687    /// token not being a real token (not really talking to sysmem).  Another
1688    /// option is to call BindSharedCollection with this token first which also
1689    /// validates the token along with converting it to a BufferCollection, then
1690    /// call BufferCollection IsAlternateFor().
1691    ///
1692    /// error values:
1693    ///
1694    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
1695    /// buffer collection as the calling Node.  Before logical allocation and
1696    /// within the same logical allocation sub-tree, this essentially means that
1697    /// the node_ref was never part of this logical buffer collection, since
1698    /// before logical allocation all node_refs that come into existence remain
1699    /// in existence at least until logical allocation (including Node(s) that
1700    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
1701    /// to be returned, this Node's channel needs to still be connected server
1702    /// side, which won't be the case if the whole logical allocation has
1703    /// failed.  After logical allocation or in a different logical allocation
1704    /// sub-tree there are additional potential reasons for this error.  For
1705    /// example a different logical allocation (separated from this Node(s)
1706    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
1707    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
1708    /// exist and may select a different child sub-tree than the sub-tree the
1709    /// node_ref is in causing deletion of the node_ref Node.  The only time
1710    /// sysmem keeps a Node around after that Node has no corresponding channel
1711    /// is when Close() is used and the Node's sub-tree has not yet failed.
1712    /// Another reason for this error is if the node_ref is an eventpair handle
1713    /// with sufficient rights, but isn't actually a real node_ref obtained from
1714    /// GetNodeRef().
1715    ///
1716    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
1717    /// eventpair handle, or doesn't have the needed rights expected on a real
1718    /// node_ref.
1719    ///
1720    /// No other failing status codes are returned by this call.  However,
1721    /// sysmem may add additional codes in future, so the client should have
1722    /// sensible default handling for any failing status code.
1723    ///
1724    /// On success, is_alternate has the following meaning:
1725    ///   * true - The first parent node in common between the calling node and
1726    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
1727    ///     the calling Node and the node_ref Node will _not_ have both their
1728    ///     constraints apply - rather sysmem will choose one or the other of
1729    ///     the constraints - never both.  This is because only one child of
1730    ///     a BufferCollectionTokenGroup is selected during logical allocation,
1731    ///     with only that one child's sub-tree contributing to constraints
1732    ///     aggregation.
1733    ///   * false - The first parent node in common between the calling Node and
1734    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
1735    ///     this means the first parent node in common is a
1736    ///     BufferCollectionToken or BufferCollection (regardless of not
1737    ///     Close()ed or Close()ed).  This means that the calling Node and the
1738    ///     node_ref Node _may_ have both their constraints apply during
1739    ///     constraints aggregation of the logical allocation, if both Node(s)
1740    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
1741    ///     In this case, there is no BufferCollectionTokenGroup that will
1742    ///     directly prevent the two Node(s) from both being selected and their
1743    ///     constraints both aggregated, but even when false, one or both
1744    ///     Node(s) may still be eliminated from consideration if one or both
1745    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
1746    ///     which selects a child sub-tree other than the sub-tree containing
1747    ///     the calling Node or node_ref Node.
1748    pub fn r#is_alternate_for(
1749        &self,
1750        mut node_ref: fidl::Event,
1751        ___deadline: zx::MonotonicInstant,
1752    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
1753        let _response = self.client.send_query::<
1754            NodeIsAlternateForRequest,
1755            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
1756        >(
1757            (node_ref,),
1758            0x33a2a7aff2776c07,
1759            fidl::encoding::DynamicFlags::empty(),
1760            ___deadline,
1761        )?;
1762        Ok(_response.map(|x| x.is_alternate))
1763    }
1764
1765    /// Provide BufferCollectionConstraints to the logical BufferCollection.
1766    ///
1767    /// A participant may only call SetConstraints() once.
1768    ///
1769    /// Sometimes the initiator is a participant only in the sense of wanting to
1770    /// keep an eye on success/failure to populate with buffers, and zx.Status
1771    /// on failure.  In that case, `has_constraints` can be false, and
1772    /// `constraints` will be ignored.
1773    ///
1774    /// VMO handles will not be provided to the client that sends null
1775    /// constraints - that can be intentional for an initiator that doesn't need
1776    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
1777    /// adjusting which portion of a buffer is considered valid and similar, but
1778    /// the initiator can't hold a VMO handle open to prevent the logical
1779    /// BufferCollection from cleaning up if the logical BufferCollection needs
1780    /// to go away regardless of the initiator's degree of involvement for
1781    /// whatever reason.
1782    ///
1783    /// For population of buffers to be attempted, all holders of a
1784    /// BufferCollection client channel need to call SetConstraints() before
1785    /// sysmem will attempt to allocate buffers.
1786    ///
1787    /// `has_constraints` if false, the constraints are effectively null, and
1788    /// `constraints` are ignored.  The sender of null constraints won't get any
1789    /// VMO handles in BufferCollectionInfo, but can still find out how many
1790    /// buffers were allocated and can still refer to buffers by their
1791    /// buffer_index.
1792    ///
1793    /// `constraints` are constraints on the buffer collection.
1794    pub fn r#set_constraints(
1795        &self,
1796        mut has_constraints: bool,
1797        mut constraints: &BufferCollectionConstraints,
1798    ) -> Result<(), fidl::Error> {
1799        self.client.send::<BufferCollectionSetConstraintsRequest>(
1800            (has_constraints, constraints),
1801            0x4d9c3406c213227b,
1802            fidl::encoding::DynamicFlags::empty(),
1803        )
1804    }
1805
1806    /// This request completes when buffers have been allocated, responds with
1807    /// some failure detail if allocation has been attempted but failed.
1808    ///
1809    /// The following must occur before buffers will be allocated:
1810    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
1811    ///     must be turned in via BindSharedCollection().
1812    ///   * All BufferCollection(s) of the logical BufferCollection must have
1813    ///     had SetConstraints() sent to them.
1814    ///
1815    /// Returns `ZX_OK` if successful.
1816    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
1817    /// fulfilled due to resource exhaustion.
1818    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
1819    /// obtain the buffers it requested.
1820    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
1821    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
1822    /// satisfied, perhaps due to hardware limitations.
1823    ///
1824    /// `buffer_collection_info` has the VMO handles and other related info.
1825    pub fn r#wait_for_buffers_allocated(
1826        &self,
1827        ___deadline: zx::MonotonicInstant,
1828    ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1829        let _response = self.client.send_query::<
1830            fidl::encoding::EmptyPayload,
1831            BufferCollectionWaitForBuffersAllocatedResponse,
1832        >(
1833            (),
1834            0x714667ea2a29a3a2,
1835            fidl::encoding::DynamicFlags::empty(),
1836            ___deadline,
1837        )?;
1838        Ok((_response.status, _response.buffer_collection_info))
1839    }
1840
1841    /// This returns the same result code as WaitForBuffersAllocated if the
1842    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
1843    /// if WaitForBuffersAllocated would block.
1844    pub fn r#check_buffers_allocated(
1845        &self,
1846        ___deadline: zx::MonotonicInstant,
1847    ) -> Result<i32, fidl::Error> {
1848        let _response = self.client.send_query::<
1849            fidl::encoding::EmptyPayload,
1850            BufferCollectionCheckBuffersAllocatedResponse,
1851        >(
1852            (),
1853            0x245bb81f79189e9,
1854            fidl::encoding::DynamicFlags::empty(),
1855            ___deadline,
1856        )?;
1857        Ok(_response.status)
1858    }
1859
1860    pub fn r#set_constraints_aux_buffers(
1861        &self,
1862        mut constraints: &BufferCollectionConstraintsAuxBuffers,
1863    ) -> Result<(), fidl::Error> {
1864        self.client.send::<BufferCollectionSetConstraintsAuxBuffersRequest>(
1865            (constraints,),
1866            0x1ad80e63c090d817,
1867            fidl::encoding::DynamicFlags::empty(),
1868        )
1869    }
1870
1871    pub fn r#get_aux_buffers(
1872        &self,
1873        ___deadline: zx::MonotonicInstant,
1874    ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1875        let _response = self
1876            .client
1877            .send_query::<fidl::encoding::EmptyPayload, BufferCollectionGetAuxBuffersResponse>(
1878                (),
1879                0x6c6cac6000a29a55,
1880                fidl::encoding::DynamicFlags::empty(),
1881                ___deadline,
1882            )?;
1883        Ok((_response.status, _response.buffer_collection_info_aux_buffers))
1884    }
1885
1886    /// Create a new token, for trying to add a new participant to an existing
1887    /// collection, if the existing collection's buffer counts, constraints,
1888    /// and participants allow.
1889    ///
1890    /// This can be useful in replacing a failed participant, and/or in
1891    /// adding/re-adding a participant after buffers have already been
1892    /// allocated.
1893    ///
1894    /// Failure of an attached token / collection does not propagate to the
1895    /// parent of the attached token.  Failure does propagate from a normal
1896    /// child of a dispensable token to the dispensable token.  Failure
1897    /// of a child is blocked from reaching its parent if the child is attached,
1898    /// or if the child is dispensable and the failure occurred after logical
1899    /// allocation.
1900    ///
1901    /// An initiator may in some scenarios choose to initially use a dispensable
1902    /// token for a given instance of a participant, and then later if the first
1903    /// instance of that participant fails, a new second instance of that
1904    /// participant my be given a token created with AttachToken().
1905    ///
1906    /// From the point of view of the client end of the BufferCollectionToken
1907    /// channel, the token acts like any other token.  The client can
1908    /// Duplicate() the token as needed, and can send the token to a different
1909    /// process.  The token should be converted to a BufferCollection channel
1910    /// as normal by calling BindSharedCollection().  SetConstraints() should
1911    /// be called on that BufferCollection channel.
1912    ///
1913    /// A success result from WaitForBuffersAllocated() means the new
1914    /// participant's constraints were satisfiable using the already-existing
1915    /// buffer collection, the already-established BufferCollectionInfo
1916    /// including image format constraints, and the already-existing other
1917    /// participants and their buffer counts.  A failure result means the new
1918    /// participant's constraints cannot be satisfied using the existing
1919    /// buffer collection and its already-logically-allocated participants.
1920    /// Creating a new collection instead may allow all participant's
1921    /// constraints to be satisfied, assuming SetDispensable() is used in place
1922    /// of AttachToken(), or a normal token is used.
1923    ///
1924    /// A token created with AttachToken() performs constraints aggregation with
1925    /// all constraints currently in effect on the buffer collection, plus the
1926    /// attached token under consideration plus child tokens under the attached
1927    /// token which are not themselves an attached token or under such a token.
1928    ///
1929    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
1930    /// first-come first-served, but a child can't logically allocate before
1931    /// all its parents have sent SetConstraints().
1932    ///
1933    /// See also SetDispensable(), which in contrast to AttachToken(), has the
1934    /// created token + children participate in constraints aggregation along
1935    /// with its parent.
1936    ///
1937    /// The newly created token needs to be Sync()ed to sysmem before the new
1938    /// token can be passed to BindSharedCollection().  The Sync() of the new
1939    /// token can be accomplished with BufferCollection.Sync() on this
1940    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
1941    /// token also works.  A BufferCollectionToken.Sync() can be started after
1942    /// any BufferCollectionToken.Duplicate() messages have been sent via the
1943    /// newly created token, to also sync those additional tokens to sysmem
1944    /// using a single round-trip.
1945    ///
1946    /// These values for rights_attenuation_mask result in no attenuation (note
1947    /// that 0 is not on this list; 0 will output an ERROR to the system log
1948    /// to help diagnose the bug in client code):
1949    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
1950    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
1951    pub fn r#attach_token(
1952        &self,
1953        mut rights_attenuation_mask: u32,
1954        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1955    ) -> Result<(), fidl::Error> {
1956        self.client.send::<BufferCollectionAttachTokenRequest>(
1957            (rights_attenuation_mask, token_request),
1958            0x6f5adcca4ac7443e,
1959            fidl::encoding::DynamicFlags::empty(),
1960        )
1961    }
1962
1963    /// AttachLifetimeTracking:
1964    ///
1965    /// AttachLifetimeTracking() is intended to allow a client to wait until an
1966    /// old logical buffer collection is fully or mostly deallocated before
1967    /// attempting allocation of a new logical buffer collection.
1968    ///
1969    /// Attach an eventpair endpoint to the logical buffer collection, so that
1970    /// the server_end will be closed when the number of buffers allocated
1971    /// drops to 'buffers_remaining'.  The server_end won't close until after
1972    /// logical allocation has completed.
1973    ///
1974    /// If logical allocation fails, such as for an attached sub-tree (using
1975    /// AttachToken()), the server_end will close during that failure regardless
1976    /// of the number of buffers potenitally allocated in the overall logical
1977    /// buffer collection.
1978    ///
1979    /// The lifetime signalled by this event includes asynchronous cleanup of
1980    /// allocated buffers, and this asynchronous cleanup cannot occur until all
1981    /// holders of VMO handles to the buffers have closed those VMO handles.
1982    /// Therefore clients should take care not to become blocked forever waiting
1983    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
1984    /// participants using the logical buffer collection are less trusted or
1985    /// less reliable.
1986    ///
1987    /// The buffers_remaining parameter allows waiting for all but
1988    /// buffers_remaining buffers to be fully deallocated.  This can be useful
1989    /// in situations where a known number of buffers are intentionally not
1990    /// closed so that the data can continue to be used, such as for keeping the
1991    /// last available video picture displayed in the UI even if the video
1992    /// stream was using protected output buffers.  It's outside the scope of
1993    /// the BufferCollection interface (at least for now) to determine how many
1994    /// buffers may be held without closing, but it'll typically be in the range
1995    /// 0-2.
1996    ///
1997    /// This mechanism is meant to be compatible with other protocols providing
1998    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
1999    /// same event can be sent to more than one AttachLifetimeTracking(), and
2000    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2001    /// over conditions are met (all holders of duplicates have closed their
2002    /// handle(s)).
2003    ///
2004    /// There is no way to cancel an attach.  Closing the client end of the
2005    /// eventpair doesn't subtract from the number of pending attach(es).
2006    ///
2007    /// Closing the client's end doesn't result in any action by the server.
2008    /// If the server listens to events from the client end at all, it is for
2009    /// debug logging only.
2010    ///
2011    /// The server intentionally doesn't "trust" any bits signalled by the
2012    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2013    /// which can't be triggered early, and is only triggered when all handles
2014    /// to server_end are closed.  No meaning is associated with any of the
2015    /// other signal bits, and clients should functionally ignore any other
2016    /// signal bits on either end of the eventpair or its peer.
2017    ///
2018    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2019    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2020    /// transfer without causing CodecFactory channel failure).
2021    pub fn r#attach_lifetime_tracking(
2022        &self,
2023        mut server_end: fidl::EventPair,
2024        mut buffers_remaining: u32,
2025    ) -> Result<(), fidl::Error> {
2026        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2027            (server_end, buffers_remaining),
2028            0x170d0f1d89d50989,
2029            fidl::encoding::DynamicFlags::empty(),
2030        )
2031    }
2032}
2033
2034#[cfg(target_os = "fuchsia")]
2035impl From<BufferCollectionSynchronousProxy> for zx::Handle {
2036    fn from(value: BufferCollectionSynchronousProxy) -> Self {
2037        value.into_channel().into()
2038    }
2039}
2040
2041#[cfg(target_os = "fuchsia")]
2042impl From<fidl::Channel> for BufferCollectionSynchronousProxy {
2043    fn from(value: fidl::Channel) -> Self {
2044        Self::new(value)
2045    }
2046}
2047
2048#[derive(Debug, Clone)]
2049pub struct BufferCollectionProxy {
2050    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2051}
2052
2053impl fidl::endpoints::Proxy for BufferCollectionProxy {
2054    type Protocol = BufferCollectionMarker;
2055
2056    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2057        Self::new(inner)
2058    }
2059
2060    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2061        self.client.into_channel().map_err(|client| Self { client })
2062    }
2063
2064    fn as_channel(&self) -> &::fidl::AsyncChannel {
2065        self.client.as_channel()
2066    }
2067}
2068
2069impl BufferCollectionProxy {
2070    /// Create a new Proxy for fuchsia.sysmem/BufferCollection.
2071    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2072        let protocol_name = <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2073        Self { client: fidl::client::Client::new(channel, protocol_name) }
2074    }
2075
2076    /// Get a Stream of events from the remote end of the protocol.
2077    ///
2078    /// # Panics
2079    ///
2080    /// Panics if the event stream was already taken.
2081    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
2082        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
2083    }
2084
2085    /// Ensure that previous messages, including Duplicate() messages on a
2086    /// token, collection, or group, have been received server side.
2087    ///
2088    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
2089    /// valid sysmem token risks the Sync() hanging forever.  See
2090    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
2091    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
2092    /// Another way is to pass the token to BindSharedCollection(), which also
2093    /// validates the token as part of exchanging it for a BufferCollection
2094    /// channel, and BufferCollection Sync() can then be used.
2095    ///
2096    /// After a Sync(), it's then safe to send the client end of token_request
2097    /// to another participant knowing the server will recognize the token when
2098    /// it's sent into BindSharedCollection() by the other participant.
2099    ///
2100    /// Other options include waiting for each token.Duplicate() to complete
2101    /// individually (using separate call to token.Sync() after each), or
2102    /// calling Sync() on BufferCollection after the token has been turned in
2103    /// via BindSharedCollection().
2104    ///
2105    /// Another way to mitigate is to avoid calling Sync() on the token, and
2106    /// instead later deal with potential failure of BufferCollection.Sync() if
2107    /// the original token was invalid.  This option can be preferable from a
2108    /// performance point of view, but requires client code to delay sending
2109    /// tokens duplicated from this token until after client code has converted
2110    /// the duplicating token to a BufferCollection and received successful
2111    /// response from BufferCollection.Sync().
2112    ///
2113    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
2114    /// When BufferCollection.Sync() isn't feasible, the caller must already
2115    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
2116    /// hang forever.  See ValidateBufferCollectionToken() to check token
2117    /// validity first if the token isn't already known to be (is/was) valid.
2118    pub fn r#sync(
2119        &self,
2120    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2121        BufferCollectionProxyInterface::r#sync(self)
2122    }
2123
2124    /// On a BufferCollectionToken channel:
2125    ///
2126    /// Normally a participant will convert a BufferCollectionToken into a
2127    /// BufferCollection view, but a participant is also free to Close() the
2128    /// token (and then close the channel immediately or shortly later in
2129    /// response to server closing its end), which avoids causing logical buffer
2130    /// collection failure.  Normally an unexpected token channel close will
2131    /// cause logical buffer collection failure (the only exceptions being
2132    /// certain cases involving AttachToken() or SetDispensable()).
2133    ///
2134    /// On a BufferCollection channel:
2135    ///
2136    /// By default the server handles unexpected failure of a BufferCollection
2137    /// by failing the whole logical buffer collection.  Partly this is to
2138    /// expedite closing VMO handles to reclaim memory when any participant
2139    /// fails.  If a participant would like to cleanly close a BufferCollection
2140    /// view without causing logical buffer collection failure, the participant
2141    /// can send Close() before closing the client end of the BufferCollection
2142    /// channel.  If this is the last BufferCollection view, the logical buffer
2143    /// collection will still go away.  The Close() can occur before or after
2144    /// SetConstraints().  If before SetConstraints(), the buffer collection
2145    /// won't require constraints from this node in order to allocate.  If
2146    /// after SetConstraints(), the constraints are retained and aggregated
2147    /// along with any subsequent logical allocation(s), despite the lack of
2148    /// channel connection.
2149    ///
2150    /// On a BufferCollectionTokenGroup channel:
2151    ///
2152    /// By default, unexpected failure of a BufferCollectionTokenGroup will
2153    /// trigger failure of the logical BufferCollectionTokenGroup and will
2154    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
2155    /// channel without failing the logical group or propagating failure, send
2156    /// Close() before closing the channel client endpoint.
2157    ///
2158    /// If Close() occurs before AllChildrenPresent(), the logical buffer
2159    /// collection will still fail despite the Close() (because sysmem can't be
2160    /// sure whether all relevant children were created, so it's ambiguous
2161    /// whether all relevant constraints will be provided to sysmem).  If
2162    /// Close() occurs after AllChildrenPresent(), the children and all their
2163    /// constraints remain intact (just as they would if the
2164    /// BufferCollectionTokenGroup channel had remained open), and the close
2165    /// doesn't trigger or propagate failure.
2166    pub fn r#close(&self) -> Result<(), fidl::Error> {
2167        BufferCollectionProxyInterface::r#close(self)
2168    }
2169
2170    /// Set a name for VMOs in this buffer collection. The name may be truncated
2171    /// shorter. The name only affects VMOs allocated after it's set - this call
2172    /// does not rename existing VMOs. If multiple clients set different names
2173    /// then the larger priority value will win.
2174    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2175        BufferCollectionProxyInterface::r#set_name(self, priority, name)
2176    }
2177
2178    /// Set information about the current client that can be used by sysmem to
2179    /// help debug leaking memory and hangs waiting for constraints. |name| can
2180    /// be an arbitrary string, but the current process name (see
2181    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
2182    /// arbitrary id, but the current process ID (see
2183    /// fsl::GetCurrentProcessKoid()) is a good default.
2184    ///
2185    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
2186    /// indicate which client is closing their channel first, leading to
2187    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
2188    /// over, but if happening earlier than expected, the
2189    /// client-channel-specific name can help diagnose where the failure is
2190    /// first coming from, from sysmem's point of view).
2191    ///
2192    /// By default (unless overriden by this message or using
2193    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
2194    /// parent Node at the time the child Node is created.  While this can be
2195    /// better than nothing, it's often better for each participant to use
2196    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
2197    /// info directly relevant to the current client.  Also, SetVerboseLogging()
2198    /// can be used to help disambiguate if a Node is suspected of having info
2199    /// that was copied from its parent.
2200    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2201        BufferCollectionProxyInterface::r#set_debug_client_info(self, name, id)
2202    }
2203
2204    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
2205    /// after creating a collection. Clients can call this method to change
2206    /// when the log is printed. If multiple client set the deadline, it's
2207    /// unspecified which deadline will take effect.
2208    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2209        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
2210    }
2211
2212    /// Verbose logging includes constraints set via SetConstraints() from each
2213    /// client along with info set via SetDebugClientInfo() and the structure of
2214    /// the tree of Node(s).
2215    ///
2216    /// Normally sysmem prints only a single line complaint when aggregation
2217    /// fails, with just the specific detailed reason that aggregation failed,
2218    /// with minimal context.  While this is often enough to diagnose a problem
2219    /// if only a small change was made and the system had been working before
2220    /// the small change, it's often not particularly helpful for getting a new
2221    /// buffer collection to work for the first time.  Especially with more
2222    /// complex trees of nodes, involving things like AttachToken(),
2223    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
2224    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
2225    /// looks like and why it's failing a logical allocation, or why a tree or
2226    /// sub-tree is failing sooner than expected.
2227    ///
2228    /// The intent of the extra logging is to be acceptable from a performance
2229    /// point of view, if only enabled on a low number of buffer collections.
2230    /// If we're not tracking down a bug, we shouldn't send this message.
2231    ///
2232    /// If too many participants leave verbose logging enabled, we may end up
2233    /// needing to require that system-wide sysmem verbose logging be permitted
2234    /// via some other setting, to avoid sysmem spamming the log too much due to
2235    /// this message.
2236    ///
2237    /// This may be a NOP for some nodes due to intentional policy associated
2238    /// with the node, if we don't trust a node enough to let it turn on verbose
2239    /// logging.
2240    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2241        BufferCollectionProxyInterface::r#set_verbose_logging(self)
2242    }
2243
2244    /// This gets an event handle that can be used as a parameter to
2245    /// IsAlternateFor() called on any Node.  The client will not be granted the
2246    /// right to signal this event, as this handle should only be used as proof
2247    /// that the client obtained this handle from this Node.
2248    ///
2249    /// Because this is a get not a set, no Sync() is needed between the
2250    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
2251    /// potentially being on different channels.
2252    ///
2253    /// See also IsAlternateFor().
2254    pub fn r#get_node_ref(
2255        &self,
2256    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
2257    {
2258        BufferCollectionProxyInterface::r#get_node_ref(self)
2259    }
2260
2261    /// This checks whether the calling node is in a subtree rooted at a
2262    /// different child token of a common parent BufferCollectionTokenGroup, in
2263    /// relation to the passed-in node_ref.
2264    ///
2265    /// This call is for assisting with admission control de-duplication, and
2266    /// with debugging.
2267    ///
2268    /// The node_ref must be obtained using GetNodeRef() of a
2269    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
2270    ///
2271    /// The node_ref can be a duplicated handle; it's not necessary to call
2272    /// GetNodeRef() for every call to IsAlternateFor().
2273    ///
2274    /// If a calling token may not actually be a valid token at all due to
2275    /// a potentially hostile/untrusted provider of the token, call
2276    /// ValidateBufferCollectionToken() first instead of potentially getting
2277    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
2278    /// token not being a real token (not really talking to sysmem).  Another
2279    /// option is to call BindSharedCollection with this token first which also
2280    /// validates the token along with converting it to a BufferCollection, then
2281    /// call BufferCollection IsAlternateFor().
2282    ///
2283    /// error values:
2284    ///
2285    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
2286    /// buffer collection as the calling Node.  Before logical allocation and
2287    /// within the same logical allocation sub-tree, this essentially means that
2288    /// the node_ref was never part of this logical buffer collection, since
2289    /// before logical allocation all node_refs that come into existence remain
2290    /// in existence at least until logical allocation (including Node(s) that
2291    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
2292    /// to be returned, this Node's channel needs to still be connected server
2293    /// side, which won't be the case if the whole logical allocation has
2294    /// failed.  After logical allocation or in a different logical allocation
2295    /// sub-tree there are additional potential reasons for this error.  For
2296    /// example a different logical allocation (separated from this Node(s)
2297    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
2298    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
2299    /// exist and may select a different child sub-tree than the sub-tree the
2300    /// node_ref is in causing deletion of the node_ref Node.  The only time
2301    /// sysmem keeps a Node around after that Node has no corresponding channel
2302    /// is when Close() is used and the Node's sub-tree has not yet failed.
2303    /// Another reason for this error is if the node_ref is an eventpair handle
2304    /// with sufficient rights, but isn't actually a real node_ref obtained from
2305    /// GetNodeRef().
2306    ///
2307    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
2308    /// eventpair handle, or doesn't have the needed rights expected on a real
2309    /// node_ref.
2310    ///
2311    /// No other failing status codes are returned by this call.  However,
2312    /// sysmem may add additional codes in future, so the client should have
2313    /// sensible default handling for any failing status code.
2314    ///
2315    /// On success, is_alternate has the following meaning:
2316    ///   * true - The first parent node in common between the calling node and
2317    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
2318    ///     the calling Node and the node_ref Node will _not_ have both their
2319    ///     constraints apply - rather sysmem will choose one or the other of
2320    ///     the constraints - never both.  This is because only one child of
2321    ///     a BufferCollectionTokenGroup is selected during logical allocation,
2322    ///     with only that one child's sub-tree contributing to constraints
2323    ///     aggregation.
2324    ///   * false - The first parent node in common between the calling Node and
2325    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
2326    ///     this means the first parent node in common is a
2327    ///     BufferCollectionToken or BufferCollection (regardless of not
2328    ///     Close()ed or Close()ed).  This means that the calling Node and the
2329    ///     node_ref Node _may_ have both their constraints apply during
2330    ///     constraints aggregation of the logical allocation, if both Node(s)
2331    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
2332    ///     In this case, there is no BufferCollectionTokenGroup that will
2333    ///     directly prevent the two Node(s) from both being selected and their
2334    ///     constraints both aggregated, but even when false, one or both
2335    ///     Node(s) may still be eliminated from consideration if one or both
2336    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
2337    ///     which selects a child sub-tree other than the sub-tree containing
2338    ///     the calling Node or node_ref Node.
2339    pub fn r#is_alternate_for(
2340        &self,
2341        mut node_ref: fidl::Event,
2342    ) -> fidl::client::QueryResponseFut<
2343        NodeIsAlternateForResult,
2344        fidl::encoding::DefaultFuchsiaResourceDialect,
2345    > {
2346        BufferCollectionProxyInterface::r#is_alternate_for(self, node_ref)
2347    }
2348
2349    /// Provide BufferCollectionConstraints to the logical BufferCollection.
2350    ///
2351    /// A participant may only call SetConstraints() once.
2352    ///
2353    /// Sometimes the initiator is a participant only in the sense of wanting to
2354    /// keep an eye on success/failure to populate with buffers, and zx.Status
2355    /// on failure.  In that case, `has_constraints` can be false, and
2356    /// `constraints` will be ignored.
2357    ///
2358    /// VMO handles will not be provided to the client that sends null
2359    /// constraints - that can be intentional for an initiator that doesn't need
2360    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
2361    /// adjusting which portion of a buffer is considered valid and similar, but
2362    /// the initiator can't hold a VMO handle open to prevent the logical
2363    /// BufferCollection from cleaning up if the logical BufferCollection needs
2364    /// to go away regardless of the initiator's degree of involvement for
2365    /// whatever reason.
2366    ///
2367    /// For population of buffers to be attempted, all holders of a
2368    /// BufferCollection client channel need to call SetConstraints() before
2369    /// sysmem will attempt to allocate buffers.
2370    ///
2371    /// `has_constraints` if false, the constraints are effectively null, and
2372    /// `constraints` are ignored.  The sender of null constraints won't get any
2373    /// VMO handles in BufferCollectionInfo, but can still find out how many
2374    /// buffers were allocated and can still refer to buffers by their
2375    /// buffer_index.
2376    ///
2377    /// `constraints` are constraints on the buffer collection.
2378    pub fn r#set_constraints(
2379        &self,
2380        mut has_constraints: bool,
2381        mut constraints: &BufferCollectionConstraints,
2382    ) -> Result<(), fidl::Error> {
2383        BufferCollectionProxyInterface::r#set_constraints(self, has_constraints, constraints)
2384    }
2385
2386    /// This request completes when buffers have been allocated, responds with
2387    /// some failure detail if allocation has been attempted but failed.
2388    ///
2389    /// The following must occur before buffers will be allocated:
2390    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
2391    ///     must be turned in via BindSharedCollection().
2392    ///   * All BufferCollection(s) of the logical BufferCollection must have
2393    ///     had SetConstraints() sent to them.
2394    ///
2395    /// Returns `ZX_OK` if successful.
2396    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
2397    /// fulfilled due to resource exhaustion.
2398    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
2399    /// obtain the buffers it requested.
2400    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
2401    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
2402    /// satisfied, perhaps due to hardware limitations.
2403    ///
2404    /// `buffer_collection_info` has the VMO handles and other related info.
2405    pub fn r#wait_for_buffers_allocated(
2406        &self,
2407    ) -> fidl::client::QueryResponseFut<
2408        (i32, BufferCollectionInfo2),
2409        fidl::encoding::DefaultFuchsiaResourceDialect,
2410    > {
2411        BufferCollectionProxyInterface::r#wait_for_buffers_allocated(self)
2412    }
2413
2414    /// This returns the same result code as WaitForBuffersAllocated if the
2415    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
2416    /// if WaitForBuffersAllocated would block.
2417    pub fn r#check_buffers_allocated(
2418        &self,
2419    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
2420        BufferCollectionProxyInterface::r#check_buffers_allocated(self)
2421    }
2422
2423    pub fn r#set_constraints_aux_buffers(
2424        &self,
2425        mut constraints: &BufferCollectionConstraintsAuxBuffers,
2426    ) -> Result<(), fidl::Error> {
2427        BufferCollectionProxyInterface::r#set_constraints_aux_buffers(self, constraints)
2428    }
2429
2430    pub fn r#get_aux_buffers(
2431        &self,
2432    ) -> fidl::client::QueryResponseFut<
2433        (i32, BufferCollectionInfo2),
2434        fidl::encoding::DefaultFuchsiaResourceDialect,
2435    > {
2436        BufferCollectionProxyInterface::r#get_aux_buffers(self)
2437    }
2438
2439    /// Create a new token, for trying to add a new participant to an existing
2440    /// collection, if the existing collection's buffer counts, constraints,
2441    /// and participants allow.
2442    ///
2443    /// This can be useful in replacing a failed participant, and/or in
2444    /// adding/re-adding a participant after buffers have already been
2445    /// allocated.
2446    ///
2447    /// Failure of an attached token / collection does not propagate to the
2448    /// parent of the attached token.  Failure does propagate from a normal
2449    /// child of a dispensable token to the dispensable token.  Failure
2450    /// of a child is blocked from reaching its parent if the child is attached,
2451    /// or if the child is dispensable and the failure occurred after logical
2452    /// allocation.
2453    ///
2454    /// An initiator may in some scenarios choose to initially use a dispensable
2455    /// token for a given instance of a participant, and then later if the first
2456    /// instance of that participant fails, a new second instance of that
2457    /// participant my be given a token created with AttachToken().
2458    ///
2459    /// From the point of view of the client end of the BufferCollectionToken
2460    /// channel, the token acts like any other token.  The client can
2461    /// Duplicate() the token as needed, and can send the token to a different
2462    /// process.  The token should be converted to a BufferCollection channel
2463    /// as normal by calling BindSharedCollection().  SetConstraints() should
2464    /// be called on that BufferCollection channel.
2465    ///
2466    /// A success result from WaitForBuffersAllocated() means the new
2467    /// participant's constraints were satisfiable using the already-existing
2468    /// buffer collection, the already-established BufferCollectionInfo
2469    /// including image format constraints, and the already-existing other
2470    /// participants and their buffer counts.  A failure result means the new
2471    /// participant's constraints cannot be satisfied using the existing
2472    /// buffer collection and its already-logically-allocated participants.
2473    /// Creating a new collection instead may allow all participant's
2474    /// constraints to be satisfied, assuming SetDispensable() is used in place
2475    /// of AttachToken(), or a normal token is used.
2476    ///
2477    /// A token created with AttachToken() performs constraints aggregation with
2478    /// all constraints currently in effect on the buffer collection, plus the
2479    /// attached token under consideration plus child tokens under the attached
2480    /// token which are not themselves an attached token or under such a token.
2481    ///
2482    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
2483    /// first-come first-served, but a child can't logically allocate before
2484    /// all its parents have sent SetConstraints().
2485    ///
2486    /// See also SetDispensable(), which in contrast to AttachToken(), has the
2487    /// created token + children participate in constraints aggregation along
2488    /// with its parent.
2489    ///
2490    /// The newly created token needs to be Sync()ed to sysmem before the new
2491    /// token can be passed to BindSharedCollection().  The Sync() of the new
2492    /// token can be accomplished with BufferCollection.Sync() on this
2493    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
2494    /// token also works.  A BufferCollectionToken.Sync() can be started after
2495    /// any BufferCollectionToken.Duplicate() messages have been sent via the
2496    /// newly created token, to also sync those additional tokens to sysmem
2497    /// using a single round-trip.
2498    ///
2499    /// These values for rights_attenuation_mask result in no attenuation (note
2500    /// that 0 is not on this list; 0 will output an ERROR to the system log
2501    /// to help diagnose the bug in client code):
2502    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
2503    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2504    pub fn r#attach_token(
2505        &self,
2506        mut rights_attenuation_mask: u32,
2507        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2508    ) -> Result<(), fidl::Error> {
2509        BufferCollectionProxyInterface::r#attach_token(self, rights_attenuation_mask, token_request)
2510    }
2511
2512    /// AttachLifetimeTracking:
2513    ///
2514    /// AttachLifetimeTracking() is intended to allow a client to wait until an
2515    /// old logical buffer collection is fully or mostly deallocated before
2516    /// attempting allocation of a new logical buffer collection.
2517    ///
2518    /// Attach an eventpair endpoint to the logical buffer collection, so that
2519    /// the server_end will be closed when the number of buffers allocated
2520    /// drops to 'buffers_remaining'.  The server_end won't close until after
2521    /// logical allocation has completed.
2522    ///
2523    /// If logical allocation fails, such as for an attached sub-tree (using
2524    /// AttachToken()), the server_end will close during that failure regardless
2525    /// of the number of buffers potenitally allocated in the overall logical
2526    /// buffer collection.
2527    ///
2528    /// The lifetime signalled by this event includes asynchronous cleanup of
2529    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2530    /// holders of VMO handles to the buffers have closed those VMO handles.
2531    /// Therefore clients should take care not to become blocked forever waiting
2532    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
2533    /// participants using the logical buffer collection are less trusted or
2534    /// less reliable.
2535    ///
2536    /// The buffers_remaining parameter allows waiting for all but
2537    /// buffers_remaining buffers to be fully deallocated.  This can be useful
2538    /// in situations where a known number of buffers are intentionally not
2539    /// closed so that the data can continue to be used, such as for keeping the
2540    /// last available video picture displayed in the UI even if the video
2541    /// stream was using protected output buffers.  It's outside the scope of
2542    /// the BufferCollection interface (at least for now) to determine how many
2543    /// buffers may be held without closing, but it'll typically be in the range
2544    /// 0-2.
2545    ///
2546    /// This mechanism is meant to be compatible with other protocols providing
2547    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2548    /// same event can be sent to more than one AttachLifetimeTracking(), and
2549    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2550    /// over conditions are met (all holders of duplicates have closed their
2551    /// handle(s)).
2552    ///
2553    /// There is no way to cancel an attach.  Closing the client end of the
2554    /// eventpair doesn't subtract from the number of pending attach(es).
2555    ///
2556    /// Closing the client's end doesn't result in any action by the server.
2557    /// If the server listens to events from the client end at all, it is for
2558    /// debug logging only.
2559    ///
2560    /// The server intentionally doesn't "trust" any bits signalled by the
2561    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2562    /// which can't be triggered early, and is only triggered when all handles
2563    /// to server_end are closed.  No meaning is associated with any of the
2564    /// other signal bits, and clients should functionally ignore any other
2565    /// signal bits on either end of the eventpair or its peer.
2566    ///
2567    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2568    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2569    /// transfer without causing CodecFactory channel failure).
2570    pub fn r#attach_lifetime_tracking(
2571        &self,
2572        mut server_end: fidl::EventPair,
2573        mut buffers_remaining: u32,
2574    ) -> Result<(), fidl::Error> {
2575        BufferCollectionProxyInterface::r#attach_lifetime_tracking(
2576            self,
2577            server_end,
2578            buffers_remaining,
2579        )
2580    }
2581}
2582
2583impl BufferCollectionProxyInterface for BufferCollectionProxy {
2584    type SyncResponseFut =
2585        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2586    fn r#sync(&self) -> Self::SyncResponseFut {
2587        fn _decode(
2588            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2589        ) -> Result<(), fidl::Error> {
2590            let _response = fidl::client::decode_transaction_body::<
2591                fidl::encoding::EmptyPayload,
2592                fidl::encoding::DefaultFuchsiaResourceDialect,
2593                0x4577e238ae26291,
2594            >(_buf?)?;
2595            Ok(_response)
2596        }
2597        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2598            (),
2599            0x4577e238ae26291,
2600            fidl::encoding::DynamicFlags::empty(),
2601            _decode,
2602        )
2603    }
2604
2605    fn r#close(&self) -> Result<(), fidl::Error> {
2606        self.client.send::<fidl::encoding::EmptyPayload>(
2607            (),
2608            0x5b1d7a4f5681fca7,
2609            fidl::encoding::DynamicFlags::empty(),
2610        )
2611    }
2612
2613    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2614        self.client.send::<NodeSetNameRequest>(
2615            (priority, name),
2616            0x77a41bb6217e2443,
2617            fidl::encoding::DynamicFlags::empty(),
2618        )
2619    }
2620
2621    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2622        self.client.send::<NodeSetDebugClientInfoRequest>(
2623            (name, id),
2624            0x7275759070eb5ee2,
2625            fidl::encoding::DynamicFlags::empty(),
2626        )
2627    }
2628
2629    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2630        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2631            (deadline,),
2632            0x46d38f4772638867,
2633            fidl::encoding::DynamicFlags::empty(),
2634        )
2635    }
2636
2637    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2638        self.client.send::<fidl::encoding::EmptyPayload>(
2639            (),
2640            0x6bfbe2cf1701d288,
2641            fidl::encoding::DynamicFlags::empty(),
2642        )
2643    }
2644
2645    type GetNodeRefResponseFut =
2646        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
2647    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2648        fn _decode(
2649            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2650        ) -> Result<fidl::Event, fidl::Error> {
2651            let _response = fidl::client::decode_transaction_body::<
2652                NodeGetNodeRefResponse,
2653                fidl::encoding::DefaultFuchsiaResourceDialect,
2654                0x467b7c75c35c3b84,
2655            >(_buf?)?;
2656            Ok(_response.node_ref)
2657        }
2658        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
2659            (),
2660            0x467b7c75c35c3b84,
2661            fidl::encoding::DynamicFlags::empty(),
2662            _decode,
2663        )
2664    }
2665
2666    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2667        NodeIsAlternateForResult,
2668        fidl::encoding::DefaultFuchsiaResourceDialect,
2669    >;
2670    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
2671        fn _decode(
2672            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2673        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2674            let _response = fidl::client::decode_transaction_body::<
2675                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
2676                fidl::encoding::DefaultFuchsiaResourceDialect,
2677                0x33a2a7aff2776c07,
2678            >(_buf?)?;
2679            Ok(_response.map(|x| x.is_alternate))
2680        }
2681        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2682            (node_ref,),
2683            0x33a2a7aff2776c07,
2684            fidl::encoding::DynamicFlags::empty(),
2685            _decode,
2686        )
2687    }
2688
2689    fn r#set_constraints(
2690        &self,
2691        mut has_constraints: bool,
2692        mut constraints: &BufferCollectionConstraints,
2693    ) -> Result<(), fidl::Error> {
2694        self.client.send::<BufferCollectionSetConstraintsRequest>(
2695            (has_constraints, constraints),
2696            0x4d9c3406c213227b,
2697            fidl::encoding::DynamicFlags::empty(),
2698        )
2699    }
2700
2701    type WaitForBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2702        (i32, BufferCollectionInfo2),
2703        fidl::encoding::DefaultFuchsiaResourceDialect,
2704    >;
2705    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut {
2706        fn _decode(
2707            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2708        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
2709            let _response = fidl::client::decode_transaction_body::<
2710                BufferCollectionWaitForBuffersAllocatedResponse,
2711                fidl::encoding::DefaultFuchsiaResourceDialect,
2712                0x714667ea2a29a3a2,
2713            >(_buf?)?;
2714            Ok((_response.status, _response.buffer_collection_info))
2715        }
2716        self.client
2717            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
2718                (),
2719                0x714667ea2a29a3a2,
2720                fidl::encoding::DynamicFlags::empty(),
2721                _decode,
2722            )
2723    }
2724
2725    type CheckBuffersAllocatedResponseFut =
2726        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
2727    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut {
2728        fn _decode(
2729            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2730        ) -> Result<i32, fidl::Error> {
2731            let _response = fidl::client::decode_transaction_body::<
2732                BufferCollectionCheckBuffersAllocatedResponse,
2733                fidl::encoding::DefaultFuchsiaResourceDialect,
2734                0x245bb81f79189e9,
2735            >(_buf?)?;
2736            Ok(_response.status)
2737        }
2738        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
2739            (),
2740            0x245bb81f79189e9,
2741            fidl::encoding::DynamicFlags::empty(),
2742            _decode,
2743        )
2744    }
2745
2746    fn r#set_constraints_aux_buffers(
2747        &self,
2748        mut constraints: &BufferCollectionConstraintsAuxBuffers,
2749    ) -> Result<(), fidl::Error> {
2750        self.client.send::<BufferCollectionSetConstraintsAuxBuffersRequest>(
2751            (constraints,),
2752            0x1ad80e63c090d817,
2753            fidl::encoding::DynamicFlags::empty(),
2754        )
2755    }
2756
2757    type GetAuxBuffersResponseFut = fidl::client::QueryResponseFut<
2758        (i32, BufferCollectionInfo2),
2759        fidl::encoding::DefaultFuchsiaResourceDialect,
2760    >;
2761    fn r#get_aux_buffers(&self) -> Self::GetAuxBuffersResponseFut {
2762        fn _decode(
2763            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2764        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
2765            let _response = fidl::client::decode_transaction_body::<
2766                BufferCollectionGetAuxBuffersResponse,
2767                fidl::encoding::DefaultFuchsiaResourceDialect,
2768                0x6c6cac6000a29a55,
2769            >(_buf?)?;
2770            Ok((_response.status, _response.buffer_collection_info_aux_buffers))
2771        }
2772        self.client
2773            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
2774                (),
2775                0x6c6cac6000a29a55,
2776                fidl::encoding::DynamicFlags::empty(),
2777                _decode,
2778            )
2779    }
2780
2781    fn r#attach_token(
2782        &self,
2783        mut rights_attenuation_mask: u32,
2784        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2785    ) -> Result<(), fidl::Error> {
2786        self.client.send::<BufferCollectionAttachTokenRequest>(
2787            (rights_attenuation_mask, token_request),
2788            0x6f5adcca4ac7443e,
2789            fidl::encoding::DynamicFlags::empty(),
2790        )
2791    }
2792
2793    fn r#attach_lifetime_tracking(
2794        &self,
2795        mut server_end: fidl::EventPair,
2796        mut buffers_remaining: u32,
2797    ) -> Result<(), fidl::Error> {
2798        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2799            (server_end, buffers_remaining),
2800            0x170d0f1d89d50989,
2801            fidl::encoding::DynamicFlags::empty(),
2802        )
2803    }
2804}
2805
2806pub struct BufferCollectionEventStream {
2807    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2808}
2809
2810impl std::marker::Unpin for BufferCollectionEventStream {}
2811
2812impl futures::stream::FusedStream for BufferCollectionEventStream {
2813    fn is_terminated(&self) -> bool {
2814        self.event_receiver.is_terminated()
2815    }
2816}
2817
2818impl futures::Stream for BufferCollectionEventStream {
2819    type Item = Result<BufferCollectionEvent, fidl::Error>;
2820
2821    fn poll_next(
2822        mut self: std::pin::Pin<&mut Self>,
2823        cx: &mut std::task::Context<'_>,
2824    ) -> std::task::Poll<Option<Self::Item>> {
2825        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2826            &mut self.event_receiver,
2827            cx
2828        )?) {
2829            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2830            None => std::task::Poll::Ready(None),
2831        }
2832    }
2833}
2834
2835#[derive(Debug)]
2836pub enum BufferCollectionEvent {}
2837
2838impl BufferCollectionEvent {
2839    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2840    fn decode(
2841        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2842    ) -> Result<BufferCollectionEvent, fidl::Error> {
2843        let (bytes, _handles) = buf.split_mut();
2844        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2845        debug_assert_eq!(tx_header.tx_id, 0);
2846        match tx_header.ordinal {
2847            _ => Err(fidl::Error::UnknownOrdinal {
2848                ordinal: tx_header.ordinal,
2849                protocol_name:
2850                    <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2851            }),
2852        }
2853    }
2854}
2855
2856/// A Stream of incoming requests for fuchsia.sysmem/BufferCollection.
2857pub struct BufferCollectionRequestStream {
2858    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2859    is_terminated: bool,
2860}
2861
2862impl std::marker::Unpin for BufferCollectionRequestStream {}
2863
2864impl futures::stream::FusedStream for BufferCollectionRequestStream {
2865    fn is_terminated(&self) -> bool {
2866        self.is_terminated
2867    }
2868}
2869
2870impl fidl::endpoints::RequestStream for BufferCollectionRequestStream {
2871    type Protocol = BufferCollectionMarker;
2872    type ControlHandle = BufferCollectionControlHandle;
2873
2874    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2875        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2876    }
2877
2878    fn control_handle(&self) -> Self::ControlHandle {
2879        BufferCollectionControlHandle { inner: self.inner.clone() }
2880    }
2881
2882    fn into_inner(
2883        self,
2884    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2885    {
2886        (self.inner, self.is_terminated)
2887    }
2888
2889    fn from_inner(
2890        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2891        is_terminated: bool,
2892    ) -> Self {
2893        Self { inner, is_terminated }
2894    }
2895}
2896
2897impl futures::Stream for BufferCollectionRequestStream {
2898    type Item = Result<BufferCollectionRequest, fidl::Error>;
2899
2900    fn poll_next(
2901        mut self: std::pin::Pin<&mut Self>,
2902        cx: &mut std::task::Context<'_>,
2903    ) -> std::task::Poll<Option<Self::Item>> {
2904        let this = &mut *self;
2905        if this.inner.check_shutdown(cx) {
2906            this.is_terminated = true;
2907            return std::task::Poll::Ready(None);
2908        }
2909        if this.is_terminated {
2910            panic!("polled BufferCollectionRequestStream after completion");
2911        }
2912        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2913            |bytes, handles| {
2914                match this.inner.channel().read_etc(cx, bytes, handles) {
2915                    std::task::Poll::Ready(Ok(())) => {}
2916                    std::task::Poll::Pending => return std::task::Poll::Pending,
2917                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2918                        this.is_terminated = true;
2919                        return std::task::Poll::Ready(None);
2920                    }
2921                    std::task::Poll::Ready(Err(e)) => {
2922                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2923                            e.into(),
2924                        ))))
2925                    }
2926                }
2927
2928                // A message has been received from the channel
2929                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2930
2931                std::task::Poll::Ready(Some(match header.ordinal {
2932                    0x4577e238ae26291 => {
2933                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2934                        let mut req = fidl::new_empty!(
2935                            fidl::encoding::EmptyPayload,
2936                            fidl::encoding::DefaultFuchsiaResourceDialect
2937                        );
2938                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2939                        let control_handle =
2940                            BufferCollectionControlHandle { inner: this.inner.clone() };
2941                        Ok(BufferCollectionRequest::Sync {
2942                            responder: BufferCollectionSyncResponder {
2943                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2944                                tx_id: header.tx_id,
2945                            },
2946                        })
2947                    }
2948                    0x5b1d7a4f5681fca7 => {
2949                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2950                        let mut req = fidl::new_empty!(
2951                            fidl::encoding::EmptyPayload,
2952                            fidl::encoding::DefaultFuchsiaResourceDialect
2953                        );
2954                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2955                        let control_handle =
2956                            BufferCollectionControlHandle { inner: this.inner.clone() };
2957                        Ok(BufferCollectionRequest::Close { control_handle })
2958                    }
2959                    0x77a41bb6217e2443 => {
2960                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2961                        let mut req = fidl::new_empty!(
2962                            NodeSetNameRequest,
2963                            fidl::encoding::DefaultFuchsiaResourceDialect
2964                        );
2965                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2966                        let control_handle =
2967                            BufferCollectionControlHandle { inner: this.inner.clone() };
2968                        Ok(BufferCollectionRequest::SetName {
2969                            priority: req.priority,
2970                            name: req.name,
2971
2972                            control_handle,
2973                        })
2974                    }
2975                    0x7275759070eb5ee2 => {
2976                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2977                        let mut req = fidl::new_empty!(
2978                            NodeSetDebugClientInfoRequest,
2979                            fidl::encoding::DefaultFuchsiaResourceDialect
2980                        );
2981                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
2982                        let control_handle =
2983                            BufferCollectionControlHandle { inner: this.inner.clone() };
2984                        Ok(BufferCollectionRequest::SetDebugClientInfo {
2985                            name: req.name,
2986                            id: req.id,
2987
2988                            control_handle,
2989                        })
2990                    }
2991                    0x46d38f4772638867 => {
2992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2993                        let mut req = fidl::new_empty!(
2994                            NodeSetDebugTimeoutLogDeadlineRequest,
2995                            fidl::encoding::DefaultFuchsiaResourceDialect
2996                        );
2997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2998                        let control_handle =
2999                            BufferCollectionControlHandle { inner: this.inner.clone() };
3000                        Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {
3001                            deadline: req.deadline,
3002
3003                            control_handle,
3004                        })
3005                    }
3006                    0x6bfbe2cf1701d288 => {
3007                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3008                        let mut req = fidl::new_empty!(
3009                            fidl::encoding::EmptyPayload,
3010                            fidl::encoding::DefaultFuchsiaResourceDialect
3011                        );
3012                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3013                        let control_handle =
3014                            BufferCollectionControlHandle { inner: this.inner.clone() };
3015                        Ok(BufferCollectionRequest::SetVerboseLogging { control_handle })
3016                    }
3017                    0x467b7c75c35c3b84 => {
3018                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3019                        let mut req = fidl::new_empty!(
3020                            fidl::encoding::EmptyPayload,
3021                            fidl::encoding::DefaultFuchsiaResourceDialect
3022                        );
3023                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3024                        let control_handle =
3025                            BufferCollectionControlHandle { inner: this.inner.clone() };
3026                        Ok(BufferCollectionRequest::GetNodeRef {
3027                            responder: BufferCollectionGetNodeRefResponder {
3028                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3029                                tx_id: header.tx_id,
3030                            },
3031                        })
3032                    }
3033                    0x33a2a7aff2776c07 => {
3034                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3035                        let mut req = fidl::new_empty!(
3036                            NodeIsAlternateForRequest,
3037                            fidl::encoding::DefaultFuchsiaResourceDialect
3038                        );
3039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
3040                        let control_handle =
3041                            BufferCollectionControlHandle { inner: this.inner.clone() };
3042                        Ok(BufferCollectionRequest::IsAlternateFor {
3043                            node_ref: req.node_ref,
3044
3045                            responder: BufferCollectionIsAlternateForResponder {
3046                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3047                                tx_id: header.tx_id,
3048                            },
3049                        })
3050                    }
3051                    0x4d9c3406c213227b => {
3052                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3053                        let mut req = fidl::new_empty!(
3054                            BufferCollectionSetConstraintsRequest,
3055                            fidl::encoding::DefaultFuchsiaResourceDialect
3056                        );
3057                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
3058                        let control_handle =
3059                            BufferCollectionControlHandle { inner: this.inner.clone() };
3060                        Ok(BufferCollectionRequest::SetConstraints {
3061                            has_constraints: req.has_constraints,
3062                            constraints: req.constraints,
3063
3064                            control_handle,
3065                        })
3066                    }
3067                    0x714667ea2a29a3a2 => {
3068                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3069                        let mut req = fidl::new_empty!(
3070                            fidl::encoding::EmptyPayload,
3071                            fidl::encoding::DefaultFuchsiaResourceDialect
3072                        );
3073                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3074                        let control_handle =
3075                            BufferCollectionControlHandle { inner: this.inner.clone() };
3076                        Ok(BufferCollectionRequest::WaitForBuffersAllocated {
3077                            responder: BufferCollectionWaitForBuffersAllocatedResponder {
3078                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3079                                tx_id: header.tx_id,
3080                            },
3081                        })
3082                    }
3083                    0x245bb81f79189e9 => {
3084                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3085                        let mut req = fidl::new_empty!(
3086                            fidl::encoding::EmptyPayload,
3087                            fidl::encoding::DefaultFuchsiaResourceDialect
3088                        );
3089                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3090                        let control_handle =
3091                            BufferCollectionControlHandle { inner: this.inner.clone() };
3092                        Ok(BufferCollectionRequest::CheckBuffersAllocated {
3093                            responder: BufferCollectionCheckBuffersAllocatedResponder {
3094                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3095                                tx_id: header.tx_id,
3096                            },
3097                        })
3098                    }
3099                    0x1ad80e63c090d817 => {
3100                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3101                        let mut req = fidl::new_empty!(
3102                            BufferCollectionSetConstraintsAuxBuffersRequest,
3103                            fidl::encoding::DefaultFuchsiaResourceDialect
3104                        );
3105                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionSetConstraintsAuxBuffersRequest>(&header, _body_bytes, handles, &mut req)?;
3106                        let control_handle =
3107                            BufferCollectionControlHandle { inner: this.inner.clone() };
3108                        Ok(BufferCollectionRequest::SetConstraintsAuxBuffers {
3109                            constraints: req.constraints,
3110
3111                            control_handle,
3112                        })
3113                    }
3114                    0x6c6cac6000a29a55 => {
3115                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3116                        let mut req = fidl::new_empty!(
3117                            fidl::encoding::EmptyPayload,
3118                            fidl::encoding::DefaultFuchsiaResourceDialect
3119                        );
3120                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3121                        let control_handle =
3122                            BufferCollectionControlHandle { inner: this.inner.clone() };
3123                        Ok(BufferCollectionRequest::GetAuxBuffers {
3124                            responder: BufferCollectionGetAuxBuffersResponder {
3125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3126                                tx_id: header.tx_id,
3127                            },
3128                        })
3129                    }
3130                    0x6f5adcca4ac7443e => {
3131                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3132                        let mut req = fidl::new_empty!(
3133                            BufferCollectionAttachTokenRequest,
3134                            fidl::encoding::DefaultFuchsiaResourceDialect
3135                        );
3136                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
3137                        let control_handle =
3138                            BufferCollectionControlHandle { inner: this.inner.clone() };
3139                        Ok(BufferCollectionRequest::AttachToken {
3140                            rights_attenuation_mask: req.rights_attenuation_mask,
3141                            token_request: req.token_request,
3142
3143                            control_handle,
3144                        })
3145                    }
3146                    0x170d0f1d89d50989 => {
3147                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3148                        let mut req = fidl::new_empty!(
3149                            BufferCollectionAttachLifetimeTrackingRequest,
3150                            fidl::encoding::DefaultFuchsiaResourceDialect
3151                        );
3152                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3153                        let control_handle =
3154                            BufferCollectionControlHandle { inner: this.inner.clone() };
3155                        Ok(BufferCollectionRequest::AttachLifetimeTracking {
3156                            server_end: req.server_end,
3157                            buffers_remaining: req.buffers_remaining,
3158
3159                            control_handle,
3160                        })
3161                    }
3162                    _ => Err(fidl::Error::UnknownOrdinal {
3163                        ordinal: header.ordinal,
3164                        protocol_name:
3165                            <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3166                    }),
3167                }))
3168            },
3169        )
3170    }
3171}
3172
3173/// BufferCollection is a connection directly from a participant to sysmem re.
3174/// a logical BufferCollection; typically the logical BufferCollection is shared
3175/// with other participants.  In other words, an instance of the BufferCollection
3176/// interface is a view of a "logical buffer collection".
3177///
3178/// This connection exists to facilitate async indication of when the logical
3179/// BufferCollection has been populated with buffers.
3180///
3181/// Also, the channel's closure by the server is an indication to the client
3182/// that the client should close all VMO handles that were obtained from the
3183/// BufferCollection ASAP.
3184///
3185/// Also, this interface may in future allow specifying constraints in other
3186/// ways, and may allow for back-and-forth negotiation of constraints to some
3187/// degree.
3188///
3189/// This interface may in future allow for more than 64 VMO handles per
3190/// BufferCollection, but currently the limit is 64.
3191///
3192/// This interface may in future allow for allocating/deallocating single
3193/// buffers.
3194///
3195/// Some initiators may wait a short duration until all old logical
3196/// BufferCollection VMO handles have closed (or until the short duration times
3197/// out) before allocating a new BufferCollection, to help control physical
3198/// memory fragmentation and avoid overlap of buffer allocation lifetimes for
3199/// the old and new collections. Collections can be large enough that it's worth
3200/// avoiding allocation overlap (in time).
3201#[derive(Debug)]
3202pub enum BufferCollectionRequest {
3203    /// Ensure that previous messages, including Duplicate() messages on a
3204    /// token, collection, or group, have been received server side.
3205    ///
3206    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
3207    /// valid sysmem token risks the Sync() hanging forever.  See
3208    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
3209    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
3210    /// Another way is to pass the token to BindSharedCollection(), which also
3211    /// validates the token as part of exchanging it for a BufferCollection
3212    /// channel, and BufferCollection Sync() can then be used.
3213    ///
3214    /// After a Sync(), it's then safe to send the client end of token_request
3215    /// to another participant knowing the server will recognize the token when
3216    /// it's sent into BindSharedCollection() by the other participant.
3217    ///
3218    /// Other options include waiting for each token.Duplicate() to complete
3219    /// individually (using separate call to token.Sync() after each), or
3220    /// calling Sync() on BufferCollection after the token has been turned in
3221    /// via BindSharedCollection().
3222    ///
3223    /// Another way to mitigate is to avoid calling Sync() on the token, and
3224    /// instead later deal with potential failure of BufferCollection.Sync() if
3225    /// the original token was invalid.  This option can be preferable from a
3226    /// performance point of view, but requires client code to delay sending
3227    /// tokens duplicated from this token until after client code has converted
3228    /// the duplicating token to a BufferCollection and received successful
3229    /// response from BufferCollection.Sync().
3230    ///
3231    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
3232    /// When BufferCollection.Sync() isn't feasible, the caller must already
3233    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
3234    /// hang forever.  See ValidateBufferCollectionToken() to check token
3235    /// validity first if the token isn't already known to be (is/was) valid.
3236    Sync {
3237        responder: BufferCollectionSyncResponder,
3238    },
3239    /// On a BufferCollectionToken channel:
3240    ///
3241    /// Normally a participant will convert a BufferCollectionToken into a
3242    /// BufferCollection view, but a participant is also free to Close() the
3243    /// token (and then close the channel immediately or shortly later in
3244    /// response to server closing its end), which avoids causing logical buffer
3245    /// collection failure.  Normally an unexpected token channel close will
3246    /// cause logical buffer collection failure (the only exceptions being
3247    /// certain cases involving AttachToken() or SetDispensable()).
3248    ///
3249    /// On a BufferCollection channel:
3250    ///
3251    /// By default the server handles unexpected failure of a BufferCollection
3252    /// by failing the whole logical buffer collection.  Partly this is to
3253    /// expedite closing VMO handles to reclaim memory when any participant
3254    /// fails.  If a participant would like to cleanly close a BufferCollection
3255    /// view without causing logical buffer collection failure, the participant
3256    /// can send Close() before closing the client end of the BufferCollection
3257    /// channel.  If this is the last BufferCollection view, the logical buffer
3258    /// collection will still go away.  The Close() can occur before or after
3259    /// SetConstraints().  If before SetConstraints(), the buffer collection
3260    /// won't require constraints from this node in order to allocate.  If
3261    /// after SetConstraints(), the constraints are retained and aggregated
3262    /// along with any subsequent logical allocation(s), despite the lack of
3263    /// channel connection.
3264    ///
3265    /// On a BufferCollectionTokenGroup channel:
3266    ///
3267    /// By default, unexpected failure of a BufferCollectionTokenGroup will
3268    /// trigger failure of the logical BufferCollectionTokenGroup and will
3269    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
3270    /// channel without failing the logical group or propagating failure, send
3271    /// Close() before closing the channel client endpoint.
3272    ///
3273    /// If Close() occurs before AllChildrenPresent(), the logical buffer
3274    /// collection will still fail despite the Close() (because sysmem can't be
3275    /// sure whether all relevant children were created, so it's ambiguous
3276    /// whether all relevant constraints will be provided to sysmem).  If
3277    /// Close() occurs after AllChildrenPresent(), the children and all their
3278    /// constraints remain intact (just as they would if the
3279    /// BufferCollectionTokenGroup channel had remained open), and the close
3280    /// doesn't trigger or propagate failure.
3281    Close {
3282        control_handle: BufferCollectionControlHandle,
3283    },
3284    /// Set a name for VMOs in this buffer collection. The name may be truncated
3285    /// shorter. The name only affects VMOs allocated after it's set - this call
3286    /// does not rename existing VMOs. If multiple clients set different names
3287    /// then the larger priority value will win.
3288    SetName {
3289        priority: u32,
3290        name: String,
3291        control_handle: BufferCollectionControlHandle,
3292    },
3293    /// Set information about the current client that can be used by sysmem to
3294    /// help debug leaking memory and hangs waiting for constraints. |name| can
3295    /// be an arbitrary string, but the current process name (see
3296    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
3297    /// arbitrary id, but the current process ID (see
3298    /// fsl::GetCurrentProcessKoid()) is a good default.
3299    ///
3300    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
3301    /// indicate which client is closing their channel first, leading to
3302    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
3303    /// over, but if happening earlier than expected, the
3304    /// client-channel-specific name can help diagnose where the failure is
3305    /// first coming from, from sysmem's point of view).
3306    ///
3307    /// By default (unless overriden by this message or using
3308    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
3309    /// parent Node at the time the child Node is created.  While this can be
3310    /// better than nothing, it's often better for each participant to use
3311    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
3312    /// info directly relevant to the current client.  Also, SetVerboseLogging()
3313    /// can be used to help disambiguate if a Node is suspected of having info
3314    /// that was copied from its parent.
3315    SetDebugClientInfo {
3316        name: String,
3317        id: u64,
3318        control_handle: BufferCollectionControlHandle,
3319    },
3320    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
3321    /// after creating a collection. Clients can call this method to change
3322    /// when the log is printed. If multiple client set the deadline, it's
3323    /// unspecified which deadline will take effect.
3324    SetDebugTimeoutLogDeadline {
3325        deadline: i64,
3326        control_handle: BufferCollectionControlHandle,
3327    },
3328    /// Verbose logging includes constraints set via SetConstraints() from each
3329    /// client along with info set via SetDebugClientInfo() and the structure of
3330    /// the tree of Node(s).
3331    ///
3332    /// Normally sysmem prints only a single line complaint when aggregation
3333    /// fails, with just the specific detailed reason that aggregation failed,
3334    /// with minimal context.  While this is often enough to diagnose a problem
3335    /// if only a small change was made and the system had been working before
3336    /// the small change, it's often not particularly helpful for getting a new
3337    /// buffer collection to work for the first time.  Especially with more
3338    /// complex trees of nodes, involving things like AttachToken(),
3339    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
3340    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
3341    /// looks like and why it's failing a logical allocation, or why a tree or
3342    /// sub-tree is failing sooner than expected.
3343    ///
3344    /// The intent of the extra logging is to be acceptable from a performance
3345    /// point of view, if only enabled on a low number of buffer collections.
3346    /// If we're not tracking down a bug, we shouldn't send this message.
3347    ///
3348    /// If too many participants leave verbose logging enabled, we may end up
3349    /// needing to require that system-wide sysmem verbose logging be permitted
3350    /// via some other setting, to avoid sysmem spamming the log too much due to
3351    /// this message.
3352    ///
3353    /// This may be a NOP for some nodes due to intentional policy associated
3354    /// with the node, if we don't trust a node enough to let it turn on verbose
3355    /// logging.
3356    SetVerboseLogging {
3357        control_handle: BufferCollectionControlHandle,
3358    },
3359    /// This gets an event handle that can be used as a parameter to
3360    /// IsAlternateFor() called on any Node.  The client will not be granted the
3361    /// right to signal this event, as this handle should only be used as proof
3362    /// that the client obtained this handle from this Node.
3363    ///
3364    /// Because this is a get not a set, no Sync() is needed between the
3365    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
3366    /// potentially being on different channels.
3367    ///
3368    /// See also IsAlternateFor().
3369    GetNodeRef {
3370        responder: BufferCollectionGetNodeRefResponder,
3371    },
3372    /// This checks whether the calling node is in a subtree rooted at a
3373    /// different child token of a common parent BufferCollectionTokenGroup, in
3374    /// relation to the passed-in node_ref.
3375    ///
3376    /// This call is for assisting with admission control de-duplication, and
3377    /// with debugging.
3378    ///
3379    /// The node_ref must be obtained using GetNodeRef() of a
3380    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
3381    ///
3382    /// The node_ref can be a duplicated handle; it's not necessary to call
3383    /// GetNodeRef() for every call to IsAlternateFor().
3384    ///
3385    /// If a calling token may not actually be a valid token at all due to
3386    /// a potentially hostile/untrusted provider of the token, call
3387    /// ValidateBufferCollectionToken() first instead of potentially getting
3388    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
3389    /// token not being a real token (not really talking to sysmem).  Another
3390    /// option is to call BindSharedCollection with this token first which also
3391    /// validates the token along with converting it to a BufferCollection, then
3392    /// call BufferCollection IsAlternateFor().
3393    ///
3394    /// error values:
3395    ///
3396    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
3397    /// buffer collection as the calling Node.  Before logical allocation and
3398    /// within the same logical allocation sub-tree, this essentially means that
3399    /// the node_ref was never part of this logical buffer collection, since
3400    /// before logical allocation all node_refs that come into existence remain
3401    /// in existence at least until logical allocation (including Node(s) that
3402    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
3403    /// to be returned, this Node's channel needs to still be connected server
3404    /// side, which won't be the case if the whole logical allocation has
3405    /// failed.  After logical allocation or in a different logical allocation
3406    /// sub-tree there are additional potential reasons for this error.  For
3407    /// example a different logical allocation (separated from this Node(s)
3408    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
3409    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
3410    /// exist and may select a different child sub-tree than the sub-tree the
3411    /// node_ref is in causing deletion of the node_ref Node.  The only time
3412    /// sysmem keeps a Node around after that Node has no corresponding channel
3413    /// is when Close() is used and the Node's sub-tree has not yet failed.
3414    /// Another reason for this error is if the node_ref is an eventpair handle
3415    /// with sufficient rights, but isn't actually a real node_ref obtained from
3416    /// GetNodeRef().
3417    ///
3418    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
3419    /// eventpair handle, or doesn't have the needed rights expected on a real
3420    /// node_ref.
3421    ///
3422    /// No other failing status codes are returned by this call.  However,
3423    /// sysmem may add additional codes in future, so the client should have
3424    /// sensible default handling for any failing status code.
3425    ///
3426    /// On success, is_alternate has the following meaning:
3427    ///   * true - The first parent node in common between the calling node and
3428    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
3429    ///     the calling Node and the node_ref Node will _not_ have both their
3430    ///     constraints apply - rather sysmem will choose one or the other of
3431    ///     the constraints - never both.  This is because only one child of
3432    ///     a BufferCollectionTokenGroup is selected during logical allocation,
3433    ///     with only that one child's sub-tree contributing to constraints
3434    ///     aggregation.
3435    ///   * false - The first parent node in common between the calling Node and
3436    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
3437    ///     this means the first parent node in common is a
3438    ///     BufferCollectionToken or BufferCollection (regardless of not
3439    ///     Close()ed or Close()ed).  This means that the calling Node and the
3440    ///     node_ref Node _may_ have both their constraints apply during
3441    ///     constraints aggregation of the logical allocation, if both Node(s)
3442    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
3443    ///     In this case, there is no BufferCollectionTokenGroup that will
3444    ///     directly prevent the two Node(s) from both being selected and their
3445    ///     constraints both aggregated, but even when false, one or both
3446    ///     Node(s) may still be eliminated from consideration if one or both
3447    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
3448    ///     which selects a child sub-tree other than the sub-tree containing
3449    ///     the calling Node or node_ref Node.
3450    IsAlternateFor {
3451        node_ref: fidl::Event,
3452        responder: BufferCollectionIsAlternateForResponder,
3453    },
3454    /// Provide BufferCollectionConstraints to the logical BufferCollection.
3455    ///
3456    /// A participant may only call SetConstraints() once.
3457    ///
3458    /// Sometimes the initiator is a participant only in the sense of wanting to
3459    /// keep an eye on success/failure to populate with buffers, and zx.Status
3460    /// on failure.  In that case, `has_constraints` can be false, and
3461    /// `constraints` will be ignored.
3462    ///
3463    /// VMO handles will not be provided to the client that sends null
3464    /// constraints - that can be intentional for an initiator that doesn't need
3465    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
3466    /// adjusting which portion of a buffer is considered valid and similar, but
3467    /// the initiator can't hold a VMO handle open to prevent the logical
3468    /// BufferCollection from cleaning up if the logical BufferCollection needs
3469    /// to go away regardless of the initiator's degree of involvement for
3470    /// whatever reason.
3471    ///
3472    /// For population of buffers to be attempted, all holders of a
3473    /// BufferCollection client channel need to call SetConstraints() before
3474    /// sysmem will attempt to allocate buffers.
3475    ///
3476    /// `has_constraints` if false, the constraints are effectively null, and
3477    /// `constraints` are ignored.  The sender of null constraints won't get any
3478    /// VMO handles in BufferCollectionInfo, but can still find out how many
3479    /// buffers were allocated and can still refer to buffers by their
3480    /// buffer_index.
3481    ///
3482    /// `constraints` are constraints on the buffer collection.
3483    SetConstraints {
3484        has_constraints: bool,
3485        constraints: BufferCollectionConstraints,
3486        control_handle: BufferCollectionControlHandle,
3487    },
3488    /// This request completes when buffers have been allocated, responds with
3489    /// some failure detail if allocation has been attempted but failed.
3490    ///
3491    /// The following must occur before buffers will be allocated:
3492    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
3493    ///     must be turned in via BindSharedCollection().
3494    ///   * All BufferCollection(s) of the logical BufferCollection must have
3495    ///     had SetConstraints() sent to them.
3496    ///
3497    /// Returns `ZX_OK` if successful.
3498    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
3499    /// fulfilled due to resource exhaustion.
3500    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
3501    /// obtain the buffers it requested.
3502    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
3503    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
3504    /// satisfied, perhaps due to hardware limitations.
3505    ///
3506    /// `buffer_collection_info` has the VMO handles and other related info.
3507    WaitForBuffersAllocated {
3508        responder: BufferCollectionWaitForBuffersAllocatedResponder,
3509    },
3510    /// This returns the same result code as WaitForBuffersAllocated if the
3511    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
3512    /// if WaitForBuffersAllocated would block.
3513    CheckBuffersAllocated {
3514        responder: BufferCollectionCheckBuffersAllocatedResponder,
3515    },
3516    SetConstraintsAuxBuffers {
3517        constraints: BufferCollectionConstraintsAuxBuffers,
3518        control_handle: BufferCollectionControlHandle,
3519    },
3520    GetAuxBuffers {
3521        responder: BufferCollectionGetAuxBuffersResponder,
3522    },
3523    /// Create a new token, for trying to add a new participant to an existing
3524    /// collection, if the existing collection's buffer counts, constraints,
3525    /// and participants allow.
3526    ///
3527    /// This can be useful in replacing a failed participant, and/or in
3528    /// adding/re-adding a participant after buffers have already been
3529    /// allocated.
3530    ///
3531    /// Failure of an attached token / collection does not propagate to the
3532    /// parent of the attached token.  Failure does propagate from a normal
3533    /// child of a dispensable token to the dispensable token.  Failure
3534    /// of a child is blocked from reaching its parent if the child is attached,
3535    /// or if the child is dispensable and the failure occurred after logical
3536    /// allocation.
3537    ///
3538    /// An initiator may in some scenarios choose to initially use a dispensable
3539    /// token for a given instance of a participant, and then later if the first
3540    /// instance of that participant fails, a new second instance of that
3541    /// participant my be given a token created with AttachToken().
3542    ///
3543    /// From the point of view of the client end of the BufferCollectionToken
3544    /// channel, the token acts like any other token.  The client can
3545    /// Duplicate() the token as needed, and can send the token to a different
3546    /// process.  The token should be converted to a BufferCollection channel
3547    /// as normal by calling BindSharedCollection().  SetConstraints() should
3548    /// be called on that BufferCollection channel.
3549    ///
3550    /// A success result from WaitForBuffersAllocated() means the new
3551    /// participant's constraints were satisfiable using the already-existing
3552    /// buffer collection, the already-established BufferCollectionInfo
3553    /// including image format constraints, and the already-existing other
3554    /// participants and their buffer counts.  A failure result means the new
3555    /// participant's constraints cannot be satisfied using the existing
3556    /// buffer collection and its already-logically-allocated participants.
3557    /// Creating a new collection instead may allow all participant's
3558    /// constraints to be satisfied, assuming SetDispensable() is used in place
3559    /// of AttachToken(), or a normal token is used.
3560    ///
3561    /// A token created with AttachToken() performs constraints aggregation with
3562    /// all constraints currently in effect on the buffer collection, plus the
3563    /// attached token under consideration plus child tokens under the attached
3564    /// token which are not themselves an attached token or under such a token.
3565    ///
3566    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
3567    /// first-come first-served, but a child can't logically allocate before
3568    /// all its parents have sent SetConstraints().
3569    ///
3570    /// See also SetDispensable(), which in contrast to AttachToken(), has the
3571    /// created token + children participate in constraints aggregation along
3572    /// with its parent.
3573    ///
3574    /// The newly created token needs to be Sync()ed to sysmem before the new
3575    /// token can be passed to BindSharedCollection().  The Sync() of the new
3576    /// token can be accomplished with BufferCollection.Sync() on this
3577    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
3578    /// token also works.  A BufferCollectionToken.Sync() can be started after
3579    /// any BufferCollectionToken.Duplicate() messages have been sent via the
3580    /// newly created token, to also sync those additional tokens to sysmem
3581    /// using a single round-trip.
3582    ///
3583    /// These values for rights_attenuation_mask result in no attenuation (note
3584    /// that 0 is not on this list; 0 will output an ERROR to the system log
3585    /// to help diagnose the bug in client code):
3586    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
3587    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3588    AttachToken {
3589        rights_attenuation_mask: u32,
3590        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3591        control_handle: BufferCollectionControlHandle,
3592    },
3593    /// AttachLifetimeTracking:
3594    ///
3595    /// AttachLifetimeTracking() is intended to allow a client to wait until an
3596    /// old logical buffer collection is fully or mostly deallocated before
3597    /// attempting allocation of a new logical buffer collection.
3598    ///
3599    /// Attach an eventpair endpoint to the logical buffer collection, so that
3600    /// the server_end will be closed when the number of buffers allocated
3601    /// drops to 'buffers_remaining'.  The server_end won't close until after
3602    /// logical allocation has completed.
3603    ///
3604    /// If logical allocation fails, such as for an attached sub-tree (using
3605    /// AttachToken()), the server_end will close during that failure regardless
3606    /// of the number of buffers potenitally allocated in the overall logical
3607    /// buffer collection.
3608    ///
3609    /// The lifetime signalled by this event includes asynchronous cleanup of
3610    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3611    /// holders of VMO handles to the buffers have closed those VMO handles.
3612    /// Therefore clients should take care not to become blocked forever waiting
3613    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
3614    /// participants using the logical buffer collection are less trusted or
3615    /// less reliable.
3616    ///
3617    /// The buffers_remaining parameter allows waiting for all but
3618    /// buffers_remaining buffers to be fully deallocated.  This can be useful
3619    /// in situations where a known number of buffers are intentionally not
3620    /// closed so that the data can continue to be used, such as for keeping the
3621    /// last available video picture displayed in the UI even if the video
3622    /// stream was using protected output buffers.  It's outside the scope of
3623    /// the BufferCollection interface (at least for now) to determine how many
3624    /// buffers may be held without closing, but it'll typically be in the range
3625    /// 0-2.
3626    ///
3627    /// This mechanism is meant to be compatible with other protocols providing
3628    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
3629    /// same event can be sent to more than one AttachLifetimeTracking(), and
3630    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
3631    /// over conditions are met (all holders of duplicates have closed their
3632    /// handle(s)).
3633    ///
3634    /// There is no way to cancel an attach.  Closing the client end of the
3635    /// eventpair doesn't subtract from the number of pending attach(es).
3636    ///
3637    /// Closing the client's end doesn't result in any action by the server.
3638    /// If the server listens to events from the client end at all, it is for
3639    /// debug logging only.
3640    ///
3641    /// The server intentionally doesn't "trust" any bits signalled by the
3642    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
3643    /// which can't be triggered early, and is only triggered when all handles
3644    /// to server_end are closed.  No meaning is associated with any of the
3645    /// other signal bits, and clients should functionally ignore any other
3646    /// signal bits on either end of the eventpair or its peer.
3647    ///
3648    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
3649    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
3650    /// transfer without causing CodecFactory channel failure).
3651    AttachLifetimeTracking {
3652        server_end: fidl::EventPair,
3653        buffers_remaining: u32,
3654        control_handle: BufferCollectionControlHandle,
3655    },
3656}
3657
3658impl BufferCollectionRequest {
3659    #[allow(irrefutable_let_patterns)]
3660    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3661        if let BufferCollectionRequest::Sync { responder } = self {
3662            Some((responder))
3663        } else {
3664            None
3665        }
3666    }
3667
3668    #[allow(irrefutable_let_patterns)]
3669    pub fn into_close(self) -> Option<(BufferCollectionControlHandle)> {
3670        if let BufferCollectionRequest::Close { control_handle } = self {
3671            Some((control_handle))
3672        } else {
3673            None
3674        }
3675    }
3676
3677    #[allow(irrefutable_let_patterns)]
3678    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionControlHandle)> {
3679        if let BufferCollectionRequest::SetName { priority, name, control_handle } = self {
3680            Some((priority, name, control_handle))
3681        } else {
3682            None
3683        }
3684    }
3685
3686    #[allow(irrefutable_let_patterns)]
3687    pub fn into_set_debug_client_info(
3688        self,
3689    ) -> Option<(String, u64, BufferCollectionControlHandle)> {
3690        if let BufferCollectionRequest::SetDebugClientInfo { name, id, control_handle } = self {
3691            Some((name, id, control_handle))
3692        } else {
3693            None
3694        }
3695    }
3696
3697    #[allow(irrefutable_let_patterns)]
3698    pub fn into_set_debug_timeout_log_deadline(
3699        self,
3700    ) -> Option<(i64, BufferCollectionControlHandle)> {
3701        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } =
3702            self
3703        {
3704            Some((deadline, control_handle))
3705        } else {
3706            None
3707        }
3708    }
3709
3710    #[allow(irrefutable_let_patterns)]
3711    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3712        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3713            Some((control_handle))
3714        } else {
3715            None
3716        }
3717    }
3718
3719    #[allow(irrefutable_let_patterns)]
3720    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3721        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3722            Some((responder))
3723        } else {
3724            None
3725        }
3726    }
3727
3728    #[allow(irrefutable_let_patterns)]
3729    pub fn into_is_alternate_for(
3730        self,
3731    ) -> Option<(fidl::Event, BufferCollectionIsAlternateForResponder)> {
3732        if let BufferCollectionRequest::IsAlternateFor { node_ref, responder } = self {
3733            Some((node_ref, responder))
3734        } else {
3735            None
3736        }
3737    }
3738
3739    #[allow(irrefutable_let_patterns)]
3740    pub fn into_set_constraints(
3741        self,
3742    ) -> Option<(bool, BufferCollectionConstraints, BufferCollectionControlHandle)> {
3743        if let BufferCollectionRequest::SetConstraints {
3744            has_constraints,
3745            constraints,
3746            control_handle,
3747        } = self
3748        {
3749            Some((has_constraints, constraints, control_handle))
3750        } else {
3751            None
3752        }
3753    }
3754
3755    #[allow(irrefutable_let_patterns)]
3756    pub fn into_wait_for_buffers_allocated(
3757        self,
3758    ) -> Option<(BufferCollectionWaitForBuffersAllocatedResponder)> {
3759        if let BufferCollectionRequest::WaitForBuffersAllocated { responder } = self {
3760            Some((responder))
3761        } else {
3762            None
3763        }
3764    }
3765
3766    #[allow(irrefutable_let_patterns)]
3767    pub fn into_check_buffers_allocated(
3768        self,
3769    ) -> Option<(BufferCollectionCheckBuffersAllocatedResponder)> {
3770        if let BufferCollectionRequest::CheckBuffersAllocated { responder } = self {
3771            Some((responder))
3772        } else {
3773            None
3774        }
3775    }
3776
3777    #[allow(irrefutable_let_patterns)]
3778    pub fn into_set_constraints_aux_buffers(
3779        self,
3780    ) -> Option<(BufferCollectionConstraintsAuxBuffers, BufferCollectionControlHandle)> {
3781        if let BufferCollectionRequest::SetConstraintsAuxBuffers { constraints, control_handle } =
3782            self
3783        {
3784            Some((constraints, control_handle))
3785        } else {
3786            None
3787        }
3788    }
3789
3790    #[allow(irrefutable_let_patterns)]
3791    pub fn into_get_aux_buffers(self) -> Option<(BufferCollectionGetAuxBuffersResponder)> {
3792        if let BufferCollectionRequest::GetAuxBuffers { responder } = self {
3793            Some((responder))
3794        } else {
3795            None
3796        }
3797    }
3798
3799    #[allow(irrefutable_let_patterns)]
3800    pub fn into_attach_token(
3801        self,
3802    ) -> Option<(
3803        u32,
3804        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3805        BufferCollectionControlHandle,
3806    )> {
3807        if let BufferCollectionRequest::AttachToken {
3808            rights_attenuation_mask,
3809            token_request,
3810            control_handle,
3811        } = self
3812        {
3813            Some((rights_attenuation_mask, token_request, control_handle))
3814        } else {
3815            None
3816        }
3817    }
3818
3819    #[allow(irrefutable_let_patterns)]
3820    pub fn into_attach_lifetime_tracking(
3821        self,
3822    ) -> Option<(fidl::EventPair, u32, BufferCollectionControlHandle)> {
3823        if let BufferCollectionRequest::AttachLifetimeTracking {
3824            server_end,
3825            buffers_remaining,
3826            control_handle,
3827        } = self
3828        {
3829            Some((server_end, buffers_remaining, control_handle))
3830        } else {
3831            None
3832        }
3833    }
3834
3835    /// Name of the method defined in FIDL
3836    pub fn method_name(&self) -> &'static str {
3837        match *self {
3838            BufferCollectionRequest::Sync { .. } => "sync",
3839            BufferCollectionRequest::Close { .. } => "close",
3840            BufferCollectionRequest::SetName { .. } => "set_name",
3841            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
3842            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
3843                "set_debug_timeout_log_deadline"
3844            }
3845            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
3846            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
3847            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
3848            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
3849            BufferCollectionRequest::WaitForBuffersAllocated { .. } => "wait_for_buffers_allocated",
3850            BufferCollectionRequest::CheckBuffersAllocated { .. } => "check_buffers_allocated",
3851            BufferCollectionRequest::SetConstraintsAuxBuffers { .. } => {
3852                "set_constraints_aux_buffers"
3853            }
3854            BufferCollectionRequest::GetAuxBuffers { .. } => "get_aux_buffers",
3855            BufferCollectionRequest::AttachToken { .. } => "attach_token",
3856            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
3857        }
3858    }
3859}
3860
3861#[derive(Debug, Clone)]
3862pub struct BufferCollectionControlHandle {
3863    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3864}
3865
3866impl fidl::endpoints::ControlHandle for BufferCollectionControlHandle {
3867    fn shutdown(&self) {
3868        self.inner.shutdown()
3869    }
3870    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3871        self.inner.shutdown_with_epitaph(status)
3872    }
3873
3874    fn is_closed(&self) -> bool {
3875        self.inner.channel().is_closed()
3876    }
3877    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3878        self.inner.channel().on_closed()
3879    }
3880
3881    #[cfg(target_os = "fuchsia")]
3882    fn signal_peer(
3883        &self,
3884        clear_mask: zx::Signals,
3885        set_mask: zx::Signals,
3886    ) -> Result<(), zx_status::Status> {
3887        use fidl::Peered;
3888        self.inner.channel().signal_peer(clear_mask, set_mask)
3889    }
3890}
3891
3892impl BufferCollectionControlHandle {}
3893
3894#[must_use = "FIDL methods require a response to be sent"]
3895#[derive(Debug)]
3896pub struct BufferCollectionSyncResponder {
3897    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3898    tx_id: u32,
3899}
3900
3901/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3902/// if the responder is dropped without sending a response, so that the client
3903/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3904impl std::ops::Drop for BufferCollectionSyncResponder {
3905    fn drop(&mut self) {
3906        self.control_handle.shutdown();
3907        // Safety: drops once, never accessed again
3908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3909    }
3910}
3911
3912impl fidl::endpoints::Responder for BufferCollectionSyncResponder {
3913    type ControlHandle = BufferCollectionControlHandle;
3914
3915    fn control_handle(&self) -> &BufferCollectionControlHandle {
3916        &self.control_handle
3917    }
3918
3919    fn drop_without_shutdown(mut self) {
3920        // Safety: drops once, never accessed again due to mem::forget
3921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3922        // Prevent Drop from running (which would shut down the channel)
3923        std::mem::forget(self);
3924    }
3925}
3926
3927impl BufferCollectionSyncResponder {
3928    /// Sends a response to the FIDL transaction.
3929    ///
3930    /// Sets the channel to shutdown if an error occurs.
3931    pub fn send(self) -> Result<(), fidl::Error> {
3932        let _result = self.send_raw();
3933        if _result.is_err() {
3934            self.control_handle.shutdown();
3935        }
3936        self.drop_without_shutdown();
3937        _result
3938    }
3939
3940    /// Similar to "send" but does not shutdown the channel if an error occurs.
3941    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3942        let _result = self.send_raw();
3943        self.drop_without_shutdown();
3944        _result
3945    }
3946
3947    fn send_raw(&self) -> Result<(), fidl::Error> {
3948        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3949            (),
3950            self.tx_id,
3951            0x4577e238ae26291,
3952            fidl::encoding::DynamicFlags::empty(),
3953        )
3954    }
3955}
3956
3957#[must_use = "FIDL methods require a response to be sent"]
3958#[derive(Debug)]
3959pub struct BufferCollectionGetNodeRefResponder {
3960    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3961    tx_id: u32,
3962}
3963
3964/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3965/// if the responder is dropped without sending a response, so that the client
3966/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3967impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
3968    fn drop(&mut self) {
3969        self.control_handle.shutdown();
3970        // Safety: drops once, never accessed again
3971        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3972    }
3973}
3974
3975impl fidl::endpoints::Responder for BufferCollectionGetNodeRefResponder {
3976    type ControlHandle = BufferCollectionControlHandle;
3977
3978    fn control_handle(&self) -> &BufferCollectionControlHandle {
3979        &self.control_handle
3980    }
3981
3982    fn drop_without_shutdown(mut self) {
3983        // Safety: drops once, never accessed again due to mem::forget
3984        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3985        // Prevent Drop from running (which would shut down the channel)
3986        std::mem::forget(self);
3987    }
3988}
3989
3990impl BufferCollectionGetNodeRefResponder {
3991    /// Sends a response to the FIDL transaction.
3992    ///
3993    /// Sets the channel to shutdown if an error occurs.
3994    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
3995        let _result = self.send_raw(node_ref);
3996        if _result.is_err() {
3997            self.control_handle.shutdown();
3998        }
3999        self.drop_without_shutdown();
4000        _result
4001    }
4002
4003    /// Similar to "send" but does not shutdown the channel if an error occurs.
4004    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
4005        let _result = self.send_raw(node_ref);
4006        self.drop_without_shutdown();
4007        _result
4008    }
4009
4010    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
4011        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
4012            (node_ref,),
4013            self.tx_id,
4014            0x467b7c75c35c3b84,
4015            fidl::encoding::DynamicFlags::empty(),
4016        )
4017    }
4018}
4019
4020#[must_use = "FIDL methods require a response to be sent"]
4021#[derive(Debug)]
4022pub struct BufferCollectionIsAlternateForResponder {
4023    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4024    tx_id: u32,
4025}
4026
4027/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4028/// if the responder is dropped without sending a response, so that the client
4029/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4030impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
4031    fn drop(&mut self) {
4032        self.control_handle.shutdown();
4033        // Safety: drops once, never accessed again
4034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4035    }
4036}
4037
4038impl fidl::endpoints::Responder for BufferCollectionIsAlternateForResponder {
4039    type ControlHandle = BufferCollectionControlHandle;
4040
4041    fn control_handle(&self) -> &BufferCollectionControlHandle {
4042        &self.control_handle
4043    }
4044
4045    fn drop_without_shutdown(mut self) {
4046        // Safety: drops once, never accessed again due to mem::forget
4047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4048        // Prevent Drop from running (which would shut down the channel)
4049        std::mem::forget(self);
4050    }
4051}
4052
4053impl BufferCollectionIsAlternateForResponder {
4054    /// Sends a response to the FIDL transaction.
4055    ///
4056    /// Sets the channel to shutdown if an error occurs.
4057    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4058        let _result = self.send_raw(result);
4059        if _result.is_err() {
4060            self.control_handle.shutdown();
4061        }
4062        self.drop_without_shutdown();
4063        _result
4064    }
4065
4066    /// Similar to "send" but does not shutdown the channel if an error occurs.
4067    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4068        let _result = self.send_raw(result);
4069        self.drop_without_shutdown();
4070        _result
4071    }
4072
4073    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4074        self.control_handle
4075            .inner
4076            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
4077                result.map(|is_alternate| (is_alternate,)),
4078                self.tx_id,
4079                0x33a2a7aff2776c07,
4080                fidl::encoding::DynamicFlags::empty(),
4081            )
4082    }
4083}
4084
4085#[must_use = "FIDL methods require a response to be sent"]
4086#[derive(Debug)]
4087pub struct BufferCollectionWaitForBuffersAllocatedResponder {
4088    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4089    tx_id: u32,
4090}
4091
4092/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4093/// if the responder is dropped without sending a response, so that the client
4094/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4095impl std::ops::Drop for BufferCollectionWaitForBuffersAllocatedResponder {
4096    fn drop(&mut self) {
4097        self.control_handle.shutdown();
4098        // Safety: drops once, never accessed again
4099        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4100    }
4101}
4102
4103impl fidl::endpoints::Responder for BufferCollectionWaitForBuffersAllocatedResponder {
4104    type ControlHandle = BufferCollectionControlHandle;
4105
4106    fn control_handle(&self) -> &BufferCollectionControlHandle {
4107        &self.control_handle
4108    }
4109
4110    fn drop_without_shutdown(mut self) {
4111        // Safety: drops once, never accessed again due to mem::forget
4112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4113        // Prevent Drop from running (which would shut down the channel)
4114        std::mem::forget(self);
4115    }
4116}
4117
4118impl BufferCollectionWaitForBuffersAllocatedResponder {
4119    /// Sends a response to the FIDL transaction.
4120    ///
4121    /// Sets the channel to shutdown if an error occurs.
4122    pub fn send(
4123        self,
4124        mut status: i32,
4125        mut buffer_collection_info: BufferCollectionInfo2,
4126    ) -> Result<(), fidl::Error> {
4127        let _result = self.send_raw(status, buffer_collection_info);
4128        if _result.is_err() {
4129            self.control_handle.shutdown();
4130        }
4131        self.drop_without_shutdown();
4132        _result
4133    }
4134
4135    /// Similar to "send" but does not shutdown the channel if an error occurs.
4136    pub fn send_no_shutdown_on_err(
4137        self,
4138        mut status: i32,
4139        mut buffer_collection_info: BufferCollectionInfo2,
4140    ) -> Result<(), fidl::Error> {
4141        let _result = self.send_raw(status, buffer_collection_info);
4142        self.drop_without_shutdown();
4143        _result
4144    }
4145
4146    fn send_raw(
4147        &self,
4148        mut status: i32,
4149        mut buffer_collection_info: BufferCollectionInfo2,
4150    ) -> Result<(), fidl::Error> {
4151        self.control_handle.inner.send::<BufferCollectionWaitForBuffersAllocatedResponse>(
4152            (status, &mut buffer_collection_info),
4153            self.tx_id,
4154            0x714667ea2a29a3a2,
4155            fidl::encoding::DynamicFlags::empty(),
4156        )
4157    }
4158}
4159
4160#[must_use = "FIDL methods require a response to be sent"]
4161#[derive(Debug)]
4162pub struct BufferCollectionCheckBuffersAllocatedResponder {
4163    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4164    tx_id: u32,
4165}
4166
4167/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4168/// if the responder is dropped without sending a response, so that the client
4169/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4170impl std::ops::Drop for BufferCollectionCheckBuffersAllocatedResponder {
4171    fn drop(&mut self) {
4172        self.control_handle.shutdown();
4173        // Safety: drops once, never accessed again
4174        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4175    }
4176}
4177
4178impl fidl::endpoints::Responder for BufferCollectionCheckBuffersAllocatedResponder {
4179    type ControlHandle = BufferCollectionControlHandle;
4180
4181    fn control_handle(&self) -> &BufferCollectionControlHandle {
4182        &self.control_handle
4183    }
4184
4185    fn drop_without_shutdown(mut self) {
4186        // Safety: drops once, never accessed again due to mem::forget
4187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4188        // Prevent Drop from running (which would shut down the channel)
4189        std::mem::forget(self);
4190    }
4191}
4192
4193impl BufferCollectionCheckBuffersAllocatedResponder {
4194    /// Sends a response to the FIDL transaction.
4195    ///
4196    /// Sets the channel to shutdown if an error occurs.
4197    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4198        let _result = self.send_raw(status);
4199        if _result.is_err() {
4200            self.control_handle.shutdown();
4201        }
4202        self.drop_without_shutdown();
4203        _result
4204    }
4205
4206    /// Similar to "send" but does not shutdown the channel if an error occurs.
4207    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4208        let _result = self.send_raw(status);
4209        self.drop_without_shutdown();
4210        _result
4211    }
4212
4213    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4214        self.control_handle.inner.send::<BufferCollectionCheckBuffersAllocatedResponse>(
4215            (status,),
4216            self.tx_id,
4217            0x245bb81f79189e9,
4218            fidl::encoding::DynamicFlags::empty(),
4219        )
4220    }
4221}
4222
4223#[must_use = "FIDL methods require a response to be sent"]
4224#[derive(Debug)]
4225pub struct BufferCollectionGetAuxBuffersResponder {
4226    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4227    tx_id: u32,
4228}
4229
4230/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4231/// if the responder is dropped without sending a response, so that the client
4232/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4233impl std::ops::Drop for BufferCollectionGetAuxBuffersResponder {
4234    fn drop(&mut self) {
4235        self.control_handle.shutdown();
4236        // Safety: drops once, never accessed again
4237        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4238    }
4239}
4240
4241impl fidl::endpoints::Responder for BufferCollectionGetAuxBuffersResponder {
4242    type ControlHandle = BufferCollectionControlHandle;
4243
4244    fn control_handle(&self) -> &BufferCollectionControlHandle {
4245        &self.control_handle
4246    }
4247
4248    fn drop_without_shutdown(mut self) {
4249        // Safety: drops once, never accessed again due to mem::forget
4250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4251        // Prevent Drop from running (which would shut down the channel)
4252        std::mem::forget(self);
4253    }
4254}
4255
4256impl BufferCollectionGetAuxBuffersResponder {
4257    /// Sends a response to the FIDL transaction.
4258    ///
4259    /// Sets the channel to shutdown if an error occurs.
4260    pub fn send(
4261        self,
4262        mut status: i32,
4263        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4264    ) -> Result<(), fidl::Error> {
4265        let _result = self.send_raw(status, buffer_collection_info_aux_buffers);
4266        if _result.is_err() {
4267            self.control_handle.shutdown();
4268        }
4269        self.drop_without_shutdown();
4270        _result
4271    }
4272
4273    /// Similar to "send" but does not shutdown the channel if an error occurs.
4274    pub fn send_no_shutdown_on_err(
4275        self,
4276        mut status: i32,
4277        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4278    ) -> Result<(), fidl::Error> {
4279        let _result = self.send_raw(status, buffer_collection_info_aux_buffers);
4280        self.drop_without_shutdown();
4281        _result
4282    }
4283
4284    fn send_raw(
4285        &self,
4286        mut status: i32,
4287        mut buffer_collection_info_aux_buffers: BufferCollectionInfo2,
4288    ) -> Result<(), fidl::Error> {
4289        self.control_handle.inner.send::<BufferCollectionGetAuxBuffersResponse>(
4290            (status, &mut buffer_collection_info_aux_buffers),
4291            self.tx_id,
4292            0x6c6cac6000a29a55,
4293            fidl::encoding::DynamicFlags::empty(),
4294        )
4295    }
4296}
4297
4298#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4299pub struct BufferCollectionTokenMarker;
4300
4301impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenMarker {
4302    type Proxy = BufferCollectionTokenProxy;
4303    type RequestStream = BufferCollectionTokenRequestStream;
4304    #[cfg(target_os = "fuchsia")]
4305    type SynchronousProxy = BufferCollectionTokenSynchronousProxy;
4306
4307    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4308}
4309
4310pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4311    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4312    fn r#sync(&self) -> Self::SyncResponseFut;
4313    fn r#close(&self) -> Result<(), fidl::Error>;
4314    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
4315    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
4316    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
4317    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4318    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
4319        + Send;
4320    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4321    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4322        + Send;
4323    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
4324    type DuplicateSyncResponseFut: std::future::Future<
4325            Output = Result<
4326                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
4327                fidl::Error,
4328            >,
4329        > + Send;
4330    fn r#duplicate_sync(
4331        &self,
4332        rights_attenuation_masks: &[fidl::Rights],
4333    ) -> Self::DuplicateSyncResponseFut;
4334    fn r#duplicate(
4335        &self,
4336        rights_attenuation_mask: u32,
4337        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4338    ) -> Result<(), fidl::Error>;
4339    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4340    fn r#create_buffer_collection_token_group(
4341        &self,
4342        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4343    ) -> Result<(), fidl::Error>;
4344}
4345#[derive(Debug)]
4346#[cfg(target_os = "fuchsia")]
4347pub struct BufferCollectionTokenSynchronousProxy {
4348    client: fidl::client::sync::Client,
4349}
4350
4351#[cfg(target_os = "fuchsia")]
4352impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenSynchronousProxy {
4353    type Proxy = BufferCollectionTokenProxy;
4354    type Protocol = BufferCollectionTokenMarker;
4355
4356    fn from_channel(inner: fidl::Channel) -> Self {
4357        Self::new(inner)
4358    }
4359
4360    fn into_channel(self) -> fidl::Channel {
4361        self.client.into_channel()
4362    }
4363
4364    fn as_channel(&self) -> &fidl::Channel {
4365        self.client.as_channel()
4366    }
4367}
4368
4369#[cfg(target_os = "fuchsia")]
4370impl BufferCollectionTokenSynchronousProxy {
4371    pub fn new(channel: fidl::Channel) -> Self {
4372        let protocol_name =
4373            <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4374        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4375    }
4376
4377    pub fn into_channel(self) -> fidl::Channel {
4378        self.client.into_channel()
4379    }
4380
4381    /// Waits until an event arrives and returns it. It is safe for other
4382    /// threads to make concurrent requests while waiting for an event.
4383    pub fn wait_for_event(
4384        &self,
4385        deadline: zx::MonotonicInstant,
4386    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
4387        BufferCollectionTokenEvent::decode(self.client.wait_for_event(deadline)?)
4388    }
4389
4390    /// Ensure that previous messages, including Duplicate() messages on a
4391    /// token, collection, or group, have been received server side.
4392    ///
4393    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4394    /// valid sysmem token risks the Sync() hanging forever.  See
4395    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4396    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4397    /// Another way is to pass the token to BindSharedCollection(), which also
4398    /// validates the token as part of exchanging it for a BufferCollection
4399    /// channel, and BufferCollection Sync() can then be used.
4400    ///
4401    /// After a Sync(), it's then safe to send the client end of token_request
4402    /// to another participant knowing the server will recognize the token when
4403    /// it's sent into BindSharedCollection() by the other participant.
4404    ///
4405    /// Other options include waiting for each token.Duplicate() to complete
4406    /// individually (using separate call to token.Sync() after each), or
4407    /// calling Sync() on BufferCollection after the token has been turned in
4408    /// via BindSharedCollection().
4409    ///
4410    /// Another way to mitigate is to avoid calling Sync() on the token, and
4411    /// instead later deal with potential failure of BufferCollection.Sync() if
4412    /// the original token was invalid.  This option can be preferable from a
4413    /// performance point of view, but requires client code to delay sending
4414    /// tokens duplicated from this token until after client code has converted
4415    /// the duplicating token to a BufferCollection and received successful
4416    /// response from BufferCollection.Sync().
4417    ///
4418    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4419    /// When BufferCollection.Sync() isn't feasible, the caller must already
4420    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4421    /// hang forever.  See ValidateBufferCollectionToken() to check token
4422    /// validity first if the token isn't already known to be (is/was) valid.
4423    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4424        let _response =
4425            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
4426                (),
4427                0x4577e238ae26291,
4428                fidl::encoding::DynamicFlags::empty(),
4429                ___deadline,
4430            )?;
4431        Ok(_response)
4432    }
4433
4434    /// On a BufferCollectionToken channel:
4435    ///
4436    /// Normally a participant will convert a BufferCollectionToken into a
4437    /// BufferCollection view, but a participant is also free to Close() the
4438    /// token (and then close the channel immediately or shortly later in
4439    /// response to server closing its end), which avoids causing logical buffer
4440    /// collection failure.  Normally an unexpected token channel close will
4441    /// cause logical buffer collection failure (the only exceptions being
4442    /// certain cases involving AttachToken() or SetDispensable()).
4443    ///
4444    /// On a BufferCollection channel:
4445    ///
4446    /// By default the server handles unexpected failure of a BufferCollection
4447    /// by failing the whole logical buffer collection.  Partly this is to
4448    /// expedite closing VMO handles to reclaim memory when any participant
4449    /// fails.  If a participant would like to cleanly close a BufferCollection
4450    /// view without causing logical buffer collection failure, the participant
4451    /// can send Close() before closing the client end of the BufferCollection
4452    /// channel.  If this is the last BufferCollection view, the logical buffer
4453    /// collection will still go away.  The Close() can occur before or after
4454    /// SetConstraints().  If before SetConstraints(), the buffer collection
4455    /// won't require constraints from this node in order to allocate.  If
4456    /// after SetConstraints(), the constraints are retained and aggregated
4457    /// along with any subsequent logical allocation(s), despite the lack of
4458    /// channel connection.
4459    ///
4460    /// On a BufferCollectionTokenGroup channel:
4461    ///
4462    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4463    /// trigger failure of the logical BufferCollectionTokenGroup and will
4464    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4465    /// channel without failing the logical group or propagating failure, send
4466    /// Close() before closing the channel client endpoint.
4467    ///
4468    /// If Close() occurs before AllChildrenPresent(), the logical buffer
4469    /// collection will still fail despite the Close() (because sysmem can't be
4470    /// sure whether all relevant children were created, so it's ambiguous
4471    /// whether all relevant constraints will be provided to sysmem).  If
4472    /// Close() occurs after AllChildrenPresent(), the children and all their
4473    /// constraints remain intact (just as they would if the
4474    /// BufferCollectionTokenGroup channel had remained open), and the close
4475    /// doesn't trigger or propagate failure.
4476    pub fn r#close(&self) -> Result<(), fidl::Error> {
4477        self.client.send::<fidl::encoding::EmptyPayload>(
4478            (),
4479            0x5b1d7a4f5681fca7,
4480            fidl::encoding::DynamicFlags::empty(),
4481        )
4482    }
4483
4484    /// Set a name for VMOs in this buffer collection. The name may be truncated
4485    /// shorter. The name only affects VMOs allocated after it's set - this call
4486    /// does not rename existing VMOs. If multiple clients set different names
4487    /// then the larger priority value will win.
4488    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
4489        self.client.send::<NodeSetNameRequest>(
4490            (priority, name),
4491            0x77a41bb6217e2443,
4492            fidl::encoding::DynamicFlags::empty(),
4493        )
4494    }
4495
4496    /// Set information about the current client that can be used by sysmem to
4497    /// help debug leaking memory and hangs waiting for constraints. |name| can
4498    /// be an arbitrary string, but the current process name (see
4499    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4500    /// arbitrary id, but the current process ID (see
4501    /// fsl::GetCurrentProcessKoid()) is a good default.
4502    ///
4503    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4504    /// indicate which client is closing their channel first, leading to
4505    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4506    /// over, but if happening earlier than expected, the
4507    /// client-channel-specific name can help diagnose where the failure is
4508    /// first coming from, from sysmem's point of view).
4509    ///
4510    /// By default (unless overriden by this message or using
4511    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4512    /// parent Node at the time the child Node is created.  While this can be
4513    /// better than nothing, it's often better for each participant to use
4514    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4515    /// info directly relevant to the current client.  Also, SetVerboseLogging()
4516    /// can be used to help disambiguate if a Node is suspected of having info
4517    /// that was copied from its parent.
4518    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
4519        self.client.send::<NodeSetDebugClientInfoRequest>(
4520            (name, id),
4521            0x7275759070eb5ee2,
4522            fidl::encoding::DynamicFlags::empty(),
4523        )
4524    }
4525
4526    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4527    /// after creating a collection. Clients can call this method to change
4528    /// when the log is printed. If multiple client set the deadline, it's
4529    /// unspecified which deadline will take effect.
4530    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
4531        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
4532            (deadline,),
4533            0x46d38f4772638867,
4534            fidl::encoding::DynamicFlags::empty(),
4535        )
4536    }
4537
4538    /// Verbose logging includes constraints set via SetConstraints() from each
4539    /// client along with info set via SetDebugClientInfo() and the structure of
4540    /// the tree of Node(s).
4541    ///
4542    /// Normally sysmem prints only a single line complaint when aggregation
4543    /// fails, with just the specific detailed reason that aggregation failed,
4544    /// with minimal context.  While this is often enough to diagnose a problem
4545    /// if only a small change was made and the system had been working before
4546    /// the small change, it's often not particularly helpful for getting a new
4547    /// buffer collection to work for the first time.  Especially with more
4548    /// complex trees of nodes, involving things like AttachToken(),
4549    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4550    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4551    /// looks like and why it's failing a logical allocation, or why a tree or
4552    /// sub-tree is failing sooner than expected.
4553    ///
4554    /// The intent of the extra logging is to be acceptable from a performance
4555    /// point of view, if only enabled on a low number of buffer collections.
4556    /// If we're not tracking down a bug, we shouldn't send this message.
4557    ///
4558    /// If too many participants leave verbose logging enabled, we may end up
4559    /// needing to require that system-wide sysmem verbose logging be permitted
4560    /// via some other setting, to avoid sysmem spamming the log too much due to
4561    /// this message.
4562    ///
4563    /// This may be a NOP for some nodes due to intentional policy associated
4564    /// with the node, if we don't trust a node enough to let it turn on verbose
4565    /// logging.
4566    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4567        self.client.send::<fidl::encoding::EmptyPayload>(
4568            (),
4569            0x6bfbe2cf1701d288,
4570            fidl::encoding::DynamicFlags::empty(),
4571        )
4572    }
4573
4574    /// This gets an event handle that can be used as a parameter to
4575    /// IsAlternateFor() called on any Node.  The client will not be granted the
4576    /// right to signal this event, as this handle should only be used as proof
4577    /// that the client obtained this handle from this Node.
4578    ///
4579    /// Because this is a get not a set, no Sync() is needed between the
4580    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4581    /// potentially being on different channels.
4582    ///
4583    /// See also IsAlternateFor().
4584    pub fn r#get_node_ref(
4585        &self,
4586        ___deadline: zx::MonotonicInstant,
4587    ) -> Result<fidl::Event, fidl::Error> {
4588        let _response =
4589            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
4590                (),
4591                0x467b7c75c35c3b84,
4592                fidl::encoding::DynamicFlags::empty(),
4593                ___deadline,
4594            )?;
4595        Ok(_response.node_ref)
4596    }
4597
4598    /// This checks whether the calling node is in a subtree rooted at a
4599    /// different child token of a common parent BufferCollectionTokenGroup, in
4600    /// relation to the passed-in node_ref.
4601    ///
4602    /// This call is for assisting with admission control de-duplication, and
4603    /// with debugging.
4604    ///
4605    /// The node_ref must be obtained using GetNodeRef() of a
4606    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4607    ///
4608    /// The node_ref can be a duplicated handle; it's not necessary to call
4609    /// GetNodeRef() for every call to IsAlternateFor().
4610    ///
4611    /// If a calling token may not actually be a valid token at all due to
4612    /// a potentially hostile/untrusted provider of the token, call
4613    /// ValidateBufferCollectionToken() first instead of potentially getting
4614    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4615    /// token not being a real token (not really talking to sysmem).  Another
4616    /// option is to call BindSharedCollection with this token first which also
4617    /// validates the token along with converting it to a BufferCollection, then
4618    /// call BufferCollection IsAlternateFor().
4619    ///
4620    /// error values:
4621    ///
4622    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4623    /// buffer collection as the calling Node.  Before logical allocation and
4624    /// within the same logical allocation sub-tree, this essentially means that
4625    /// the node_ref was never part of this logical buffer collection, since
4626    /// before logical allocation all node_refs that come into existence remain
4627    /// in existence at least until logical allocation (including Node(s) that
4628    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4629    /// to be returned, this Node's channel needs to still be connected server
4630    /// side, which won't be the case if the whole logical allocation has
4631    /// failed.  After logical allocation or in a different logical allocation
4632    /// sub-tree there are additional potential reasons for this error.  For
4633    /// example a different logical allocation (separated from this Node(s)
4634    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4635    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4636    /// exist and may select a different child sub-tree than the sub-tree the
4637    /// node_ref is in causing deletion of the node_ref Node.  The only time
4638    /// sysmem keeps a Node around after that Node has no corresponding channel
4639    /// is when Close() is used and the Node's sub-tree has not yet failed.
4640    /// Another reason for this error is if the node_ref is an eventpair handle
4641    /// with sufficient rights, but isn't actually a real node_ref obtained from
4642    /// GetNodeRef().
4643    ///
4644    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4645    /// eventpair handle, or doesn't have the needed rights expected on a real
4646    /// node_ref.
4647    ///
4648    /// No other failing status codes are returned by this call.  However,
4649    /// sysmem may add additional codes in future, so the client should have
4650    /// sensible default handling for any failing status code.
4651    ///
4652    /// On success, is_alternate has the following meaning:
4653    ///   * true - The first parent node in common between the calling node and
4654    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
4655    ///     the calling Node and the node_ref Node will _not_ have both their
4656    ///     constraints apply - rather sysmem will choose one or the other of
4657    ///     the constraints - never both.  This is because only one child of
4658    ///     a BufferCollectionTokenGroup is selected during logical allocation,
4659    ///     with only that one child's sub-tree contributing to constraints
4660    ///     aggregation.
4661    ///   * false - The first parent node in common between the calling Node and
4662    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
4663    ///     this means the first parent node in common is a
4664    ///     BufferCollectionToken or BufferCollection (regardless of not
4665    ///     Close()ed or Close()ed).  This means that the calling Node and the
4666    ///     node_ref Node _may_ have both their constraints apply during
4667    ///     constraints aggregation of the logical allocation, if both Node(s)
4668    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
4669    ///     In this case, there is no BufferCollectionTokenGroup that will
4670    ///     directly prevent the two Node(s) from both being selected and their
4671    ///     constraints both aggregated, but even when false, one or both
4672    ///     Node(s) may still be eliminated from consideration if one or both
4673    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4674    ///     which selects a child sub-tree other than the sub-tree containing
4675    ///     the calling Node or node_ref Node.
4676    pub fn r#is_alternate_for(
4677        &self,
4678        mut node_ref: fidl::Event,
4679        ___deadline: zx::MonotonicInstant,
4680    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
4681        let _response = self.client.send_query::<
4682            NodeIsAlternateForRequest,
4683            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
4684        >(
4685            (node_ref,),
4686            0x33a2a7aff2776c07,
4687            fidl::encoding::DynamicFlags::empty(),
4688            ___deadline,
4689        )?;
4690        Ok(_response.map(|x| x.is_alternate))
4691    }
4692
4693    /// This method can be used to add more participants prior to creating a
4694    /// shared BufferCollection. A new token will be returned for each entry in
4695    /// the `rights_attenuation_masks` array. The return value is the client
4696    /// ends of each new participant token.
4697    ///
4698    /// If the calling token may not actually be a valid token at all due to
4699    /// a potentially hostile/untrusted provider of the token, consider using
4700    /// ValidateBufferCollectionToken() first instead of potentially getting
4701    /// stuck indefinitely if DuplicateSync() never responds due to the calling
4702    /// token not being a real token.
4703    ///
4704    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4705    /// after calling this method.
4706    ///
4707    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4708    /// BufferCollection to be successfully created.
4709    ///
4710    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4711    /// will be absent in the buffer VMO rights obtainable via the corresponding
4712    /// returned token. This allows an initiator or intermediary participant to
4713    /// attenuate the rights available to a participant. This does not allow a
4714    /// participant to gain rights that the participant doesn't already have.
4715    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4716    /// attenuation should be applied.
4717    pub fn r#duplicate_sync(
4718        &self,
4719        mut rights_attenuation_masks: &[fidl::Rights],
4720        ___deadline: zx::MonotonicInstant,
4721    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
4722        let _response = self.client.send_query::<
4723            BufferCollectionTokenDuplicateSyncRequest,
4724            BufferCollectionTokenDuplicateSyncResponse,
4725        >(
4726            (rights_attenuation_masks,),
4727            0x49ed7ab7cc19f18,
4728            fidl::encoding::DynamicFlags::empty(),
4729            ___deadline,
4730        )?;
4731        Ok(_response.tokens)
4732    }
4733
4734    /// This method can be used to add a participant prior to creating a shared
4735    /// BufferCollection. It should only be used instead of DuplicateSync in
4736    /// performance sensitive cases where it would be undesireable to wait for
4737    /// sysmem to respond as part of each duplicate.
4738    ///
4739    /// After sending one or more Duplicate() messages, and before sending the
4740    /// created tokens to other participants (or to other Allocator channels),
4741    /// the client should send a Sync() and wait for its response.  The Sync()
4742    /// call can be made on the token, or on the BufferCollection obtained by
4743    /// passing this token to BindSharedCollection().  Either will ensure that
4744    /// the server knows about the tokens created via Duplicate() before the
4745    /// other participant sends the token to the server via separate Allocator
4746    /// channel.
4747    ///
4748    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4749    /// BufferCollection to be successfully created.
4750    ///
4751    /// When a client calls BindSharedCollection() to turn in a
4752    /// BufferCollectionToken, the server will process all Duplicate() messages
4753    /// before closing down the BufferCollectionToken.  This allows the client
4754    /// to Duplicate() and immediately turn in the BufferCollectionToken using
4755    /// BindSharedCollection, then later transfer the client end of token_request
4756    /// to another participant - the server will notice the existence of the
4757    /// token_request before considering this BufferCollectionToken fully closed.
4758    ///
4759    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
4760    /// absent in the buffer VMO rights obtainable via the client end of
4761    /// token_request. This allows an initiator or intermediary participant to
4762    /// attenuate the rights available to a participant. This does not allow a
4763    /// participant to gain rights that the participant doesn't already have.
4764    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4765    /// attenuation should be applied.
4766    ///
4767    /// These values for rights_attenuation_mask result in no attenuation:
4768    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
4769    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
4770    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
4771    ///
4772    /// `token_request` is the server end of a BufferCollectionToken channel.
4773    /// The client end of this channel acts as another participant in creating the
4774    /// shared BufferCollection.
4775    pub fn r#duplicate(
4776        &self,
4777        mut rights_attenuation_mask: u32,
4778        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4779    ) -> Result<(), fidl::Error> {
4780        self.client.send::<BufferCollectionTokenDuplicateRequest>(
4781            (rights_attenuation_mask, token_request),
4782            0x2f9f81bdde4b7292,
4783            fidl::encoding::DynamicFlags::empty(),
4784        )
4785    }
4786
4787    /// A dispensable token can fail after buffers are logically allocated
4788    /// without causing failure of its parent (if any).
4789    ///
4790    /// The dispensable token participates in constraints aggregation along with
4791    /// its parent before logical buffer allocation.  If the dispensable token
4792    /// fails before buffers are logically allocated, the failure propagates to
4793    /// the dispensable token's parent.
4794    ///
4795    /// After buffers are logically allocated, failure of the dispensable token
4796    /// (or any child of the dispensable token) does not propagate to the
4797    /// dispensable token's parent.  Failure does propagate from a normal
4798    /// child of a dispensable token to the dispensable token.  Failure
4799    /// of a child is blocked from reaching its parent if the child is attached,
4800    /// or if the child is dispensable and the failure occurred after logical
4801    /// allocation.
4802    ///
4803    /// A dispensable token can be used in cases where a participant needs to
4804    /// provide constraints, but after buffers are allocated, the participant
4805    /// can fail without causing buffer collection failure from the parent's
4806    /// point of view.
4807    ///
4808    /// In contrast, AttachToken() can be used to create a token which does not
4809    /// participate in constraints aggregation with its parent, and whose
4810    /// failure at any time does not propagate to its parent, and whose delay
4811    /// providing constraints does not prevent the parent from completing its
4812    /// buffer allocation.
4813    ///
4814    /// An initiator may in some scenarios choose to initially use a dispensable
4815    /// token for a given instance of a participant, and then later if the first
4816    /// instance of that participant fails, a new second instance of that
4817    /// participant my be given a token created with AttachToken().
4818    ///
4819    /// If a client uses this message, the client should not rely on the
4820    /// client's own BufferCollectionToken or BufferCollection channel to close
4821    /// from the server end due to abrupt failure of any BufferCollectionToken
4822    /// or BufferCollection that the client has SetDispensable() and given out
4823    /// to another process.  For this reason, the client should take extra care
4824    /// to notice failure of that other process via other means.
4825    ///
4826    /// While it is possible (and potentially useful) to SetDispensable() on a
4827    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
4828    /// replace a failed dispensable token that was a direct child of a group
4829    /// with a new token using AttachToken() (since there's no AttachToken() on
4830    /// a group).  Instead, to enable AttachToken() replacement in this case,
4831    /// create an additional non-dispensable token (node) that's a direct child
4832    /// of the group and make the existing dispensable token a child of the
4833    /// additional token (node).  This way, the additional token (node) that is
4834    /// a direct child of the group has BufferCollection.AttachToken() which can
4835    /// be used to replace the failed dispensable token.
4836    ///
4837    /// SetDispensable() on an already-dispensable token is idempotent.
4838    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
4839        self.client.send::<fidl::encoding::EmptyPayload>(
4840            (),
4841            0x76e4ec34fc2cf5b3,
4842            fidl::encoding::DynamicFlags::empty(),
4843        )
4844    }
4845
4846    /// Most sysmem clients and many participants don't need to care about this
4847    /// message or about BufferCollectionTokenGroup(s) in general.
4848    ///
4849    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
4850    /// tokens.  The child tokens which are not selected during aggregation will
4851    /// fail (close), which a potential participant should notice when their
4852    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
4853    /// participant to clean up the speculative usage that didn't end up
4854    /// happening (similarly to a normal BufferCollection server end closing
4855    /// on failure of a logical buffer collection).
4856    ///
4857    /// See comments on protocol BufferCollectionTokenGroup.
4858    ///
4859    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
4860    /// applied to the whole group can be achieved with a token for this purpose
4861    /// as a direct parent of the group.
4862    ///
4863    /// group_request - the server end of a BufferCollectionTokenGroup channel
4864    /// to be served by sysmem.
4865    pub fn r#create_buffer_collection_token_group(
4866        &self,
4867        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4868    ) -> Result<(), fidl::Error> {
4869        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
4870            (group_request,),
4871            0x2f6243e05f22b9a7,
4872            fidl::encoding::DynamicFlags::empty(),
4873        )
4874    }
4875}
4876
4877#[cfg(target_os = "fuchsia")]
4878impl From<BufferCollectionTokenSynchronousProxy> for zx::Handle {
4879    fn from(value: BufferCollectionTokenSynchronousProxy) -> Self {
4880        value.into_channel().into()
4881    }
4882}
4883
4884#[cfg(target_os = "fuchsia")]
4885impl From<fidl::Channel> for BufferCollectionTokenSynchronousProxy {
4886    fn from(value: fidl::Channel) -> Self {
4887        Self::new(value)
4888    }
4889}
4890
4891#[derive(Debug, Clone)]
4892pub struct BufferCollectionTokenProxy {
4893    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4894}
4895
4896impl fidl::endpoints::Proxy for BufferCollectionTokenProxy {
4897    type Protocol = BufferCollectionTokenMarker;
4898
4899    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4900        Self::new(inner)
4901    }
4902
4903    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4904        self.client.into_channel().map_err(|client| Self { client })
4905    }
4906
4907    fn as_channel(&self) -> &::fidl::AsyncChannel {
4908        self.client.as_channel()
4909    }
4910}
4911
4912impl BufferCollectionTokenProxy {
4913    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionToken.
4914    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4915        let protocol_name =
4916            <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4917        Self { client: fidl::client::Client::new(channel, protocol_name) }
4918    }
4919
4920    /// Get a Stream of events from the remote end of the protocol.
4921    ///
4922    /// # Panics
4923    ///
4924    /// Panics if the event stream was already taken.
4925    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4926        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4927    }
4928
4929    /// Ensure that previous messages, including Duplicate() messages on a
4930    /// token, collection, or group, have been received server side.
4931    ///
4932    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4933    /// valid sysmem token risks the Sync() hanging forever.  See
4934    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4935    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4936    /// Another way is to pass the token to BindSharedCollection(), which also
4937    /// validates the token as part of exchanging it for a BufferCollection
4938    /// channel, and BufferCollection Sync() can then be used.
4939    ///
4940    /// After a Sync(), it's then safe to send the client end of token_request
4941    /// to another participant knowing the server will recognize the token when
4942    /// it's sent into BindSharedCollection() by the other participant.
4943    ///
4944    /// Other options include waiting for each token.Duplicate() to complete
4945    /// individually (using separate call to token.Sync() after each), or
4946    /// calling Sync() on BufferCollection after the token has been turned in
4947    /// via BindSharedCollection().
4948    ///
4949    /// Another way to mitigate is to avoid calling Sync() on the token, and
4950    /// instead later deal with potential failure of BufferCollection.Sync() if
4951    /// the original token was invalid.  This option can be preferable from a
4952    /// performance point of view, but requires client code to delay sending
4953    /// tokens duplicated from this token until after client code has converted
4954    /// the duplicating token to a BufferCollection and received successful
4955    /// response from BufferCollection.Sync().
4956    ///
4957    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4958    /// When BufferCollection.Sync() isn't feasible, the caller must already
4959    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4960    /// hang forever.  See ValidateBufferCollectionToken() to check token
4961    /// validity first if the token isn't already known to be (is/was) valid.
4962    pub fn r#sync(
4963        &self,
4964    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4965        BufferCollectionTokenProxyInterface::r#sync(self)
4966    }
4967
4968    /// On a BufferCollectionToken channel:
4969    ///
4970    /// Normally a participant will convert a BufferCollectionToken into a
4971    /// BufferCollection view, but a participant is also free to Close() the
4972    /// token (and then close the channel immediately or shortly later in
4973    /// response to server closing its end), which avoids causing logical buffer
4974    /// collection failure.  Normally an unexpected token channel close will
4975    /// cause logical buffer collection failure (the only exceptions being
4976    /// certain cases involving AttachToken() or SetDispensable()).
4977    ///
4978    /// On a BufferCollection channel:
4979    ///
4980    /// By default the server handles unexpected failure of a BufferCollection
4981    /// by failing the whole logical buffer collection.  Partly this is to
4982    /// expedite closing VMO handles to reclaim memory when any participant
4983    /// fails.  If a participant would like to cleanly close a BufferCollection
4984    /// view without causing logical buffer collection failure, the participant
4985    /// can send Close() before closing the client end of the BufferCollection
4986    /// channel.  If this is the last BufferCollection view, the logical buffer
4987    /// collection will still go away.  The Close() can occur before or after
4988    /// SetConstraints().  If before SetConstraints(), the buffer collection
4989    /// won't require constraints from this node in order to allocate.  If
4990    /// after SetConstraints(), the constraints are retained and aggregated
4991    /// along with any subsequent logical allocation(s), despite the lack of
4992    /// channel connection.
4993    ///
4994    /// On a BufferCollectionTokenGroup channel:
4995    ///
4996    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4997    /// trigger failure of the logical BufferCollectionTokenGroup and will
4998    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4999    /// channel without failing the logical group or propagating failure, send
5000    /// Close() before closing the channel client endpoint.
5001    ///
5002    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5003    /// collection will still fail despite the Close() (because sysmem can't be
5004    /// sure whether all relevant children were created, so it's ambiguous
5005    /// whether all relevant constraints will be provided to sysmem).  If
5006    /// Close() occurs after AllChildrenPresent(), the children and all their
5007    /// constraints remain intact (just as they would if the
5008    /// BufferCollectionTokenGroup channel had remained open), and the close
5009    /// doesn't trigger or propagate failure.
5010    pub fn r#close(&self) -> Result<(), fidl::Error> {
5011        BufferCollectionTokenProxyInterface::r#close(self)
5012    }
5013
5014    /// Set a name for VMOs in this buffer collection. The name may be truncated
5015    /// shorter. The name only affects VMOs allocated after it's set - this call
5016    /// does not rename existing VMOs. If multiple clients set different names
5017    /// then the larger priority value will win.
5018    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5019        BufferCollectionTokenProxyInterface::r#set_name(self, priority, name)
5020    }
5021
5022    /// Set information about the current client that can be used by sysmem to
5023    /// help debug leaking memory and hangs waiting for constraints. |name| can
5024    /// be an arbitrary string, but the current process name (see
5025    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5026    /// arbitrary id, but the current process ID (see
5027    /// fsl::GetCurrentProcessKoid()) is a good default.
5028    ///
5029    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5030    /// indicate which client is closing their channel first, leading to
5031    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5032    /// over, but if happening earlier than expected, the
5033    /// client-channel-specific name can help diagnose where the failure is
5034    /// first coming from, from sysmem's point of view).
5035    ///
5036    /// By default (unless overriden by this message or using
5037    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5038    /// parent Node at the time the child Node is created.  While this can be
5039    /// better than nothing, it's often better for each participant to use
5040    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5041    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5042    /// can be used to help disambiguate if a Node is suspected of having info
5043    /// that was copied from its parent.
5044    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5045        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, name, id)
5046    }
5047
5048    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5049    /// after creating a collection. Clients can call this method to change
5050    /// when the log is printed. If multiple client set the deadline, it's
5051    /// unspecified which deadline will take effect.
5052    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5053        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
5054    }
5055
5056    /// Verbose logging includes constraints set via SetConstraints() from each
5057    /// client along with info set via SetDebugClientInfo() and the structure of
5058    /// the tree of Node(s).
5059    ///
5060    /// Normally sysmem prints only a single line complaint when aggregation
5061    /// fails, with just the specific detailed reason that aggregation failed,
5062    /// with minimal context.  While this is often enough to diagnose a problem
5063    /// if only a small change was made and the system had been working before
5064    /// the small change, it's often not particularly helpful for getting a new
5065    /// buffer collection to work for the first time.  Especially with more
5066    /// complex trees of nodes, involving things like AttachToken(),
5067    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5068    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5069    /// looks like and why it's failing a logical allocation, or why a tree or
5070    /// sub-tree is failing sooner than expected.
5071    ///
5072    /// The intent of the extra logging is to be acceptable from a performance
5073    /// point of view, if only enabled on a low number of buffer collections.
5074    /// If we're not tracking down a bug, we shouldn't send this message.
5075    ///
5076    /// If too many participants leave verbose logging enabled, we may end up
5077    /// needing to require that system-wide sysmem verbose logging be permitted
5078    /// via some other setting, to avoid sysmem spamming the log too much due to
5079    /// this message.
5080    ///
5081    /// This may be a NOP for some nodes due to intentional policy associated
5082    /// with the node, if we don't trust a node enough to let it turn on verbose
5083    /// logging.
5084    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5085        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
5086    }
5087
5088    /// This gets an event handle that can be used as a parameter to
5089    /// IsAlternateFor() called on any Node.  The client will not be granted the
5090    /// right to signal this event, as this handle should only be used as proof
5091    /// that the client obtained this handle from this Node.
5092    ///
5093    /// Because this is a get not a set, no Sync() is needed between the
5094    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5095    /// potentially being on different channels.
5096    ///
5097    /// See also IsAlternateFor().
5098    pub fn r#get_node_ref(
5099        &self,
5100    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
5101    {
5102        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
5103    }
5104
5105    /// This checks whether the calling node is in a subtree rooted at a
5106    /// different child token of a common parent BufferCollectionTokenGroup, in
5107    /// relation to the passed-in node_ref.
5108    ///
5109    /// This call is for assisting with admission control de-duplication, and
5110    /// with debugging.
5111    ///
5112    /// The node_ref must be obtained using GetNodeRef() of a
5113    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
5114    ///
5115    /// The node_ref can be a duplicated handle; it's not necessary to call
5116    /// GetNodeRef() for every call to IsAlternateFor().
5117    ///
5118    /// If a calling token may not actually be a valid token at all due to
5119    /// a potentially hostile/untrusted provider of the token, call
5120    /// ValidateBufferCollectionToken() first instead of potentially getting
5121    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
5122    /// token not being a real token (not really talking to sysmem).  Another
5123    /// option is to call BindSharedCollection with this token first which also
5124    /// validates the token along with converting it to a BufferCollection, then
5125    /// call BufferCollection IsAlternateFor().
5126    ///
5127    /// error values:
5128    ///
5129    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
5130    /// buffer collection as the calling Node.  Before logical allocation and
5131    /// within the same logical allocation sub-tree, this essentially means that
5132    /// the node_ref was never part of this logical buffer collection, since
5133    /// before logical allocation all node_refs that come into existence remain
5134    /// in existence at least until logical allocation (including Node(s) that
5135    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
5136    /// to be returned, this Node's channel needs to still be connected server
5137    /// side, which won't be the case if the whole logical allocation has
5138    /// failed.  After logical allocation or in a different logical allocation
5139    /// sub-tree there are additional potential reasons for this error.  For
5140    /// example a different logical allocation (separated from this Node(s)
5141    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
5142    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
5143    /// exist and may select a different child sub-tree than the sub-tree the
5144    /// node_ref is in causing deletion of the node_ref Node.  The only time
5145    /// sysmem keeps a Node around after that Node has no corresponding channel
5146    /// is when Close() is used and the Node's sub-tree has not yet failed.
5147    /// Another reason for this error is if the node_ref is an eventpair handle
5148    /// with sufficient rights, but isn't actually a real node_ref obtained from
5149    /// GetNodeRef().
5150    ///
5151    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
5152    /// eventpair handle, or doesn't have the needed rights expected on a real
5153    /// node_ref.
5154    ///
5155    /// No other failing status codes are returned by this call.  However,
5156    /// sysmem may add additional codes in future, so the client should have
5157    /// sensible default handling for any failing status code.
5158    ///
5159    /// On success, is_alternate has the following meaning:
5160    ///   * true - The first parent node in common between the calling node and
5161    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
5162    ///     the calling Node and the node_ref Node will _not_ have both their
5163    ///     constraints apply - rather sysmem will choose one or the other of
5164    ///     the constraints - never both.  This is because only one child of
5165    ///     a BufferCollectionTokenGroup is selected during logical allocation,
5166    ///     with only that one child's sub-tree contributing to constraints
5167    ///     aggregation.
5168    ///   * false - The first parent node in common between the calling Node and
5169    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
5170    ///     this means the first parent node in common is a
5171    ///     BufferCollectionToken or BufferCollection (regardless of not
5172    ///     Close()ed or Close()ed).  This means that the calling Node and the
5173    ///     node_ref Node _may_ have both their constraints apply during
5174    ///     constraints aggregation of the logical allocation, if both Node(s)
5175    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
5176    ///     In this case, there is no BufferCollectionTokenGroup that will
5177    ///     directly prevent the two Node(s) from both being selected and their
5178    ///     constraints both aggregated, but even when false, one or both
5179    ///     Node(s) may still be eliminated from consideration if one or both
5180    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
5181    ///     which selects a child sub-tree other than the sub-tree containing
5182    ///     the calling Node or node_ref Node.
5183    pub fn r#is_alternate_for(
5184        &self,
5185        mut node_ref: fidl::Event,
5186    ) -> fidl::client::QueryResponseFut<
5187        NodeIsAlternateForResult,
5188        fidl::encoding::DefaultFuchsiaResourceDialect,
5189    > {
5190        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, node_ref)
5191    }
5192
5193    /// This method can be used to add more participants prior to creating a
5194    /// shared BufferCollection. A new token will be returned for each entry in
5195    /// the `rights_attenuation_masks` array. The return value is the client
5196    /// ends of each new participant token.
5197    ///
5198    /// If the calling token may not actually be a valid token at all due to
5199    /// a potentially hostile/untrusted provider of the token, consider using
5200    /// ValidateBufferCollectionToken() first instead of potentially getting
5201    /// stuck indefinitely if DuplicateSync() never responds due to the calling
5202    /// token not being a real token.
5203    ///
5204    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
5205    /// after calling this method.
5206    ///
5207    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5208    /// BufferCollection to be successfully created.
5209    ///
5210    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
5211    /// will be absent in the buffer VMO rights obtainable via the corresponding
5212    /// returned token. This allows an initiator or intermediary participant to
5213    /// attenuate the rights available to a participant. This does not allow a
5214    /// participant to gain rights that the participant doesn't already have.
5215    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5216    /// attenuation should be applied.
5217    pub fn r#duplicate_sync(
5218        &self,
5219        mut rights_attenuation_masks: &[fidl::Rights],
5220    ) -> fidl::client::QueryResponseFut<
5221        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5222        fidl::encoding::DefaultFuchsiaResourceDialect,
5223    > {
5224        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, rights_attenuation_masks)
5225    }
5226
5227    /// This method can be used to add a participant prior to creating a shared
5228    /// BufferCollection. It should only be used instead of DuplicateSync in
5229    /// performance sensitive cases where it would be undesireable to wait for
5230    /// sysmem to respond as part of each duplicate.
5231    ///
5232    /// After sending one or more Duplicate() messages, and before sending the
5233    /// created tokens to other participants (or to other Allocator channels),
5234    /// the client should send a Sync() and wait for its response.  The Sync()
5235    /// call can be made on the token, or on the BufferCollection obtained by
5236    /// passing this token to BindSharedCollection().  Either will ensure that
5237    /// the server knows about the tokens created via Duplicate() before the
5238    /// other participant sends the token to the server via separate Allocator
5239    /// channel.
5240    ///
5241    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5242    /// BufferCollection to be successfully created.
5243    ///
5244    /// When a client calls BindSharedCollection() to turn in a
5245    /// BufferCollectionToken, the server will process all Duplicate() messages
5246    /// before closing down the BufferCollectionToken.  This allows the client
5247    /// to Duplicate() and immediately turn in the BufferCollectionToken using
5248    /// BindSharedCollection, then later transfer the client end of token_request
5249    /// to another participant - the server will notice the existence of the
5250    /// token_request before considering this BufferCollectionToken fully closed.
5251    ///
5252    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
5253    /// absent in the buffer VMO rights obtainable via the client end of
5254    /// token_request. This allows an initiator or intermediary participant to
5255    /// attenuate the rights available to a participant. This does not allow a
5256    /// participant to gain rights that the participant doesn't already have.
5257    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5258    /// attenuation should be applied.
5259    ///
5260    /// These values for rights_attenuation_mask result in no attenuation:
5261    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
5262    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
5263    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
5264    ///
5265    /// `token_request` is the server end of a BufferCollectionToken channel.
5266    /// The client end of this channel acts as another participant in creating the
5267    /// shared BufferCollection.
5268    pub fn r#duplicate(
5269        &self,
5270        mut rights_attenuation_mask: u32,
5271        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5272    ) -> Result<(), fidl::Error> {
5273        BufferCollectionTokenProxyInterface::r#duplicate(
5274            self,
5275            rights_attenuation_mask,
5276            token_request,
5277        )
5278    }
5279
5280    /// A dispensable token can fail after buffers are logically allocated
5281    /// without causing failure of its parent (if any).
5282    ///
5283    /// The dispensable token participates in constraints aggregation along with
5284    /// its parent before logical buffer allocation.  If the dispensable token
5285    /// fails before buffers are logically allocated, the failure propagates to
5286    /// the dispensable token's parent.
5287    ///
5288    /// After buffers are logically allocated, failure of the dispensable token
5289    /// (or any child of the dispensable token) does not propagate to the
5290    /// dispensable token's parent.  Failure does propagate from a normal
5291    /// child of a dispensable token to the dispensable token.  Failure
5292    /// of a child is blocked from reaching its parent if the child is attached,
5293    /// or if the child is dispensable and the failure occurred after logical
5294    /// allocation.
5295    ///
5296    /// A dispensable token can be used in cases where a participant needs to
5297    /// provide constraints, but after buffers are allocated, the participant
5298    /// can fail without causing buffer collection failure from the parent's
5299    /// point of view.
5300    ///
5301    /// In contrast, AttachToken() can be used to create a token which does not
5302    /// participate in constraints aggregation with its parent, and whose
5303    /// failure at any time does not propagate to its parent, and whose delay
5304    /// providing constraints does not prevent the parent from completing its
5305    /// buffer allocation.
5306    ///
5307    /// An initiator may in some scenarios choose to initially use a dispensable
5308    /// token for a given instance of a participant, and then later if the first
5309    /// instance of that participant fails, a new second instance of that
5310    /// participant my be given a token created with AttachToken().
5311    ///
5312    /// If a client uses this message, the client should not rely on the
5313    /// client's own BufferCollectionToken or BufferCollection channel to close
5314    /// from the server end due to abrupt failure of any BufferCollectionToken
5315    /// or BufferCollection that the client has SetDispensable() and given out
5316    /// to another process.  For this reason, the client should take extra care
5317    /// to notice failure of that other process via other means.
5318    ///
5319    /// While it is possible (and potentially useful) to SetDispensable() on a
5320    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
5321    /// replace a failed dispensable token that was a direct child of a group
5322    /// with a new token using AttachToken() (since there's no AttachToken() on
5323    /// a group).  Instead, to enable AttachToken() replacement in this case,
5324    /// create an additional non-dispensable token (node) that's a direct child
5325    /// of the group and make the existing dispensable token a child of the
5326    /// additional token (node).  This way, the additional token (node) that is
5327    /// a direct child of the group has BufferCollection.AttachToken() which can
5328    /// be used to replace the failed dispensable token.
5329    ///
5330    /// SetDispensable() on an already-dispensable token is idempotent.
5331    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5332        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5333    }
5334
5335    /// Most sysmem clients and many participants don't need to care about this
5336    /// message or about BufferCollectionTokenGroup(s) in general.
5337    ///
5338    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
5339    /// tokens.  The child tokens which are not selected during aggregation will
5340    /// fail (close), which a potential participant should notice when their
5341    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
5342    /// participant to clean up the speculative usage that didn't end up
5343    /// happening (similarly to a normal BufferCollection server end closing
5344    /// on failure of a logical buffer collection).
5345    ///
5346    /// See comments on protocol BufferCollectionTokenGroup.
5347    ///
5348    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
5349    /// applied to the whole group can be achieved with a token for this purpose
5350    /// as a direct parent of the group.
5351    ///
5352    /// group_request - the server end of a BufferCollectionTokenGroup channel
5353    /// to be served by sysmem.
5354    pub fn r#create_buffer_collection_token_group(
5355        &self,
5356        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5357    ) -> Result<(), fidl::Error> {
5358        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(
5359            self,
5360            group_request,
5361        )
5362    }
5363}
5364
5365impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5366    type SyncResponseFut =
5367        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5368    fn r#sync(&self) -> Self::SyncResponseFut {
5369        fn _decode(
5370            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5371        ) -> Result<(), fidl::Error> {
5372            let _response = fidl::client::decode_transaction_body::<
5373                fidl::encoding::EmptyPayload,
5374                fidl::encoding::DefaultFuchsiaResourceDialect,
5375                0x4577e238ae26291,
5376            >(_buf?)?;
5377            Ok(_response)
5378        }
5379        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5380            (),
5381            0x4577e238ae26291,
5382            fidl::encoding::DynamicFlags::empty(),
5383            _decode,
5384        )
5385    }
5386
5387    fn r#close(&self) -> Result<(), fidl::Error> {
5388        self.client.send::<fidl::encoding::EmptyPayload>(
5389            (),
5390            0x5b1d7a4f5681fca7,
5391            fidl::encoding::DynamicFlags::empty(),
5392        )
5393    }
5394
5395    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5396        self.client.send::<NodeSetNameRequest>(
5397            (priority, name),
5398            0x77a41bb6217e2443,
5399            fidl::encoding::DynamicFlags::empty(),
5400        )
5401    }
5402
5403    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5404        self.client.send::<NodeSetDebugClientInfoRequest>(
5405            (name, id),
5406            0x7275759070eb5ee2,
5407            fidl::encoding::DynamicFlags::empty(),
5408        )
5409    }
5410
5411    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5412        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5413            (deadline,),
5414            0x46d38f4772638867,
5415            fidl::encoding::DynamicFlags::empty(),
5416        )
5417    }
5418
5419    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5420        self.client.send::<fidl::encoding::EmptyPayload>(
5421            (),
5422            0x6bfbe2cf1701d288,
5423            fidl::encoding::DynamicFlags::empty(),
5424        )
5425    }
5426
5427    type GetNodeRefResponseFut =
5428        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
5429    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5430        fn _decode(
5431            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5432        ) -> Result<fidl::Event, fidl::Error> {
5433            let _response = fidl::client::decode_transaction_body::<
5434                NodeGetNodeRefResponse,
5435                fidl::encoding::DefaultFuchsiaResourceDialect,
5436                0x467b7c75c35c3b84,
5437            >(_buf?)?;
5438            Ok(_response.node_ref)
5439        }
5440        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
5441            (),
5442            0x467b7c75c35c3b84,
5443            fidl::encoding::DynamicFlags::empty(),
5444            _decode,
5445        )
5446    }
5447
5448    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5449        NodeIsAlternateForResult,
5450        fidl::encoding::DefaultFuchsiaResourceDialect,
5451    >;
5452    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
5453        fn _decode(
5454            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5455        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5456            let _response = fidl::client::decode_transaction_body::<
5457                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
5458                fidl::encoding::DefaultFuchsiaResourceDialect,
5459                0x33a2a7aff2776c07,
5460            >(_buf?)?;
5461            Ok(_response.map(|x| x.is_alternate))
5462        }
5463        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5464            (node_ref,),
5465            0x33a2a7aff2776c07,
5466            fidl::encoding::DynamicFlags::empty(),
5467            _decode,
5468        )
5469    }
5470
5471    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5472        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5473        fidl::encoding::DefaultFuchsiaResourceDialect,
5474    >;
5475    fn r#duplicate_sync(
5476        &self,
5477        mut rights_attenuation_masks: &[fidl::Rights],
5478    ) -> Self::DuplicateSyncResponseFut {
5479        fn _decode(
5480            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5481        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
5482        {
5483            let _response = fidl::client::decode_transaction_body::<
5484                BufferCollectionTokenDuplicateSyncResponse,
5485                fidl::encoding::DefaultFuchsiaResourceDialect,
5486                0x49ed7ab7cc19f18,
5487            >(_buf?)?;
5488            Ok(_response.tokens)
5489        }
5490        self.client.send_query_and_decode::<
5491            BufferCollectionTokenDuplicateSyncRequest,
5492            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5493        >(
5494            (rights_attenuation_masks,),
5495            0x49ed7ab7cc19f18,
5496            fidl::encoding::DynamicFlags::empty(),
5497            _decode,
5498        )
5499    }
5500
5501    fn r#duplicate(
5502        &self,
5503        mut rights_attenuation_mask: u32,
5504        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5505    ) -> Result<(), fidl::Error> {
5506        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5507            (rights_attenuation_mask, token_request),
5508            0x2f9f81bdde4b7292,
5509            fidl::encoding::DynamicFlags::empty(),
5510        )
5511    }
5512
5513    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5514        self.client.send::<fidl::encoding::EmptyPayload>(
5515            (),
5516            0x76e4ec34fc2cf5b3,
5517            fidl::encoding::DynamicFlags::empty(),
5518        )
5519    }
5520
5521    fn r#create_buffer_collection_token_group(
5522        &self,
5523        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5524    ) -> Result<(), fidl::Error> {
5525        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5526            (group_request,),
5527            0x2f6243e05f22b9a7,
5528            fidl::encoding::DynamicFlags::empty(),
5529        )
5530    }
5531}
5532
5533pub struct BufferCollectionTokenEventStream {
5534    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5535}
5536
5537impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5538
5539impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5540    fn is_terminated(&self) -> bool {
5541        self.event_receiver.is_terminated()
5542    }
5543}
5544
5545impl futures::Stream for BufferCollectionTokenEventStream {
5546    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5547
5548    fn poll_next(
5549        mut self: std::pin::Pin<&mut Self>,
5550        cx: &mut std::task::Context<'_>,
5551    ) -> std::task::Poll<Option<Self::Item>> {
5552        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5553            &mut self.event_receiver,
5554            cx
5555        )?) {
5556            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5557            None => std::task::Poll::Ready(None),
5558        }
5559    }
5560}
5561
5562#[derive(Debug)]
5563pub enum BufferCollectionTokenEvent {}
5564
5565impl BufferCollectionTokenEvent {
5566    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5567    fn decode(
5568        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5569    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5570        let (bytes, _handles) = buf.split_mut();
5571        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5572        debug_assert_eq!(tx_header.tx_id, 0);
5573        match tx_header.ordinal {
5574            _ => Err(fidl::Error::UnknownOrdinal {
5575                ordinal: tx_header.ordinal,
5576                protocol_name:
5577                    <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5578            }),
5579        }
5580    }
5581}
5582
5583/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionToken.
5584pub struct BufferCollectionTokenRequestStream {
5585    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5586    is_terminated: bool,
5587}
5588
5589impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5590
5591impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5592    fn is_terminated(&self) -> bool {
5593        self.is_terminated
5594    }
5595}
5596
5597impl fidl::endpoints::RequestStream for BufferCollectionTokenRequestStream {
5598    type Protocol = BufferCollectionTokenMarker;
5599    type ControlHandle = BufferCollectionTokenControlHandle;
5600
5601    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5602        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5603    }
5604
5605    fn control_handle(&self) -> Self::ControlHandle {
5606        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5607    }
5608
5609    fn into_inner(
5610        self,
5611    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5612    {
5613        (self.inner, self.is_terminated)
5614    }
5615
5616    fn from_inner(
5617        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5618        is_terminated: bool,
5619    ) -> Self {
5620        Self { inner, is_terminated }
5621    }
5622}
5623
5624impl futures::Stream for BufferCollectionTokenRequestStream {
5625    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5626
5627    fn poll_next(
5628        mut self: std::pin::Pin<&mut Self>,
5629        cx: &mut std::task::Context<'_>,
5630    ) -> std::task::Poll<Option<Self::Item>> {
5631        let this = &mut *self;
5632        if this.inner.check_shutdown(cx) {
5633            this.is_terminated = true;
5634            return std::task::Poll::Ready(None);
5635        }
5636        if this.is_terminated {
5637            panic!("polled BufferCollectionTokenRequestStream after completion");
5638        }
5639        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5640            |bytes, handles| {
5641                match this.inner.channel().read_etc(cx, bytes, handles) {
5642                    std::task::Poll::Ready(Ok(())) => {}
5643                    std::task::Poll::Pending => return std::task::Poll::Pending,
5644                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5645                        this.is_terminated = true;
5646                        return std::task::Poll::Ready(None);
5647                    }
5648                    std::task::Poll::Ready(Err(e)) => {
5649                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5650                            e.into(),
5651                        ))))
5652                    }
5653                }
5654
5655                // A message has been received from the channel
5656                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5657
5658                std::task::Poll::Ready(Some(match header.ordinal {
5659                0x4577e238ae26291 => {
5660                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5661                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5662                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5663                    let control_handle = BufferCollectionTokenControlHandle {
5664                        inner: this.inner.clone(),
5665                    };
5666                    Ok(BufferCollectionTokenRequest::Sync {
5667                        responder: BufferCollectionTokenSyncResponder {
5668                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5669                            tx_id: header.tx_id,
5670                        },
5671                    })
5672                }
5673                0x5b1d7a4f5681fca7 => {
5674                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5675                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5676                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5677                    let control_handle = BufferCollectionTokenControlHandle {
5678                        inner: this.inner.clone(),
5679                    };
5680                    Ok(BufferCollectionTokenRequest::Close {
5681                        control_handle,
5682                    })
5683                }
5684                0x77a41bb6217e2443 => {
5685                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5686                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5687                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5688                    let control_handle = BufferCollectionTokenControlHandle {
5689                        inner: this.inner.clone(),
5690                    };
5691                    Ok(BufferCollectionTokenRequest::SetName {priority: req.priority,
5692name: req.name,
5693
5694                        control_handle,
5695                    })
5696                }
5697                0x7275759070eb5ee2 => {
5698                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5699                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5700                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5701                    let control_handle = BufferCollectionTokenControlHandle {
5702                        inner: this.inner.clone(),
5703                    };
5704                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {name: req.name,
5705id: req.id,
5706
5707                        control_handle,
5708                    })
5709                }
5710                0x46d38f4772638867 => {
5711                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5712                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5713                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5714                    let control_handle = BufferCollectionTokenControlHandle {
5715                        inner: this.inner.clone(),
5716                    };
5717                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
5718
5719                        control_handle,
5720                    })
5721                }
5722                0x6bfbe2cf1701d288 => {
5723                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5724                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5725                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5726                    let control_handle = BufferCollectionTokenControlHandle {
5727                        inner: this.inner.clone(),
5728                    };
5729                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5730                        control_handle,
5731                    })
5732                }
5733                0x467b7c75c35c3b84 => {
5734                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5735                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5736                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5737                    let control_handle = BufferCollectionTokenControlHandle {
5738                        inner: this.inner.clone(),
5739                    };
5740                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5741                        responder: BufferCollectionTokenGetNodeRefResponder {
5742                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5743                            tx_id: header.tx_id,
5744                        },
5745                    })
5746                }
5747                0x33a2a7aff2776c07 => {
5748                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5749                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5750                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5751                    let control_handle = BufferCollectionTokenControlHandle {
5752                        inner: this.inner.clone(),
5753                    };
5754                    Ok(BufferCollectionTokenRequest::IsAlternateFor {node_ref: req.node_ref,
5755
5756                        responder: BufferCollectionTokenIsAlternateForResponder {
5757                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5758                            tx_id: header.tx_id,
5759                        },
5760                    })
5761                }
5762                0x49ed7ab7cc19f18 => {
5763                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5764                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5765                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5766                    let control_handle = BufferCollectionTokenControlHandle {
5767                        inner: this.inner.clone(),
5768                    };
5769                    Ok(BufferCollectionTokenRequest::DuplicateSync {rights_attenuation_masks: req.rights_attenuation_masks,
5770
5771                        responder: BufferCollectionTokenDuplicateSyncResponder {
5772                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5773                            tx_id: header.tx_id,
5774                        },
5775                    })
5776                }
5777                0x2f9f81bdde4b7292 => {
5778                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5779                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5780                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5781                    let control_handle = BufferCollectionTokenControlHandle {
5782                        inner: this.inner.clone(),
5783                    };
5784                    Ok(BufferCollectionTokenRequest::Duplicate {rights_attenuation_mask: req.rights_attenuation_mask,
5785token_request: req.token_request,
5786
5787                        control_handle,
5788                    })
5789                }
5790                0x76e4ec34fc2cf5b3 => {
5791                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5792                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5793                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5794                    let control_handle = BufferCollectionTokenControlHandle {
5795                        inner: this.inner.clone(),
5796                    };
5797                    Ok(BufferCollectionTokenRequest::SetDispensable {
5798                        control_handle,
5799                    })
5800                }
5801                0x2f6243e05f22b9a7 => {
5802                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5803                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5804                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5805                    let control_handle = BufferCollectionTokenControlHandle {
5806                        inner: this.inner.clone(),
5807                    };
5808                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {group_request: req.group_request,
5809
5810                        control_handle,
5811                    })
5812                }
5813                _ => Err(fidl::Error::UnknownOrdinal {
5814                    ordinal: header.ordinal,
5815                    protocol_name: <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5816                }),
5817            }))
5818            },
5819        )
5820    }
5821}
5822
5823/// A BufferCollectionToken is not a BufferCollection, but rather a way to
5824/// identify a potential shared BufferCollection prior to the BufferCollection
5825/// being allocated.
5826///
5827/// We use a channel for the BufferCollectionToken instead of a single eventpair
5828/// (pair) because this way we can detect error conditions like a participant
5829/// dying mid-create.
5830///
5831/// The fuchsia.sysmem.BufferCollectionToken type is not yet deprecated due to
5832/// its use in some other protocols (for now), but all the internals of
5833/// fuchsia.sysmem.BufferCollectionToken are deprecated. Token channels serve
5834/// both fuchsia.sysmem.BufferCollectionToken and
5835/// fuchsia.sysmem2.BufferCollectionToken.
5836///
5837/// This protocol will be deprecated once other protocols have switched their
5838/// token fields to fuchsia.sysmem2.BufferCollectionToken.
5839#[derive(Debug)]
5840pub enum BufferCollectionTokenRequest {
5841    /// Ensure that previous messages, including Duplicate() messages on a
5842    /// token, collection, or group, have been received server side.
5843    ///
5844    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5845    /// valid sysmem token risks the Sync() hanging forever.  See
5846    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5847    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5848    /// Another way is to pass the token to BindSharedCollection(), which also
5849    /// validates the token as part of exchanging it for a BufferCollection
5850    /// channel, and BufferCollection Sync() can then be used.
5851    ///
5852    /// After a Sync(), it's then safe to send the client end of token_request
5853    /// to another participant knowing the server will recognize the token when
5854    /// it's sent into BindSharedCollection() by the other participant.
5855    ///
5856    /// Other options include waiting for each token.Duplicate() to complete
5857    /// individually (using separate call to token.Sync() after each), or
5858    /// calling Sync() on BufferCollection after the token has been turned in
5859    /// via BindSharedCollection().
5860    ///
5861    /// Another way to mitigate is to avoid calling Sync() on the token, and
5862    /// instead later deal with potential failure of BufferCollection.Sync() if
5863    /// the original token was invalid.  This option can be preferable from a
5864    /// performance point of view, but requires client code to delay sending
5865    /// tokens duplicated from this token until after client code has converted
5866    /// the duplicating token to a BufferCollection and received successful
5867    /// response from BufferCollection.Sync().
5868    ///
5869    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5870    /// When BufferCollection.Sync() isn't feasible, the caller must already
5871    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5872    /// hang forever.  See ValidateBufferCollectionToken() to check token
5873    /// validity first if the token isn't already known to be (is/was) valid.
5874    Sync { responder: BufferCollectionTokenSyncResponder },
5875    /// On a BufferCollectionToken channel:
5876    ///
5877    /// Normally a participant will convert a BufferCollectionToken into a
5878    /// BufferCollection view, but a participant is also free to Close() the
5879    /// token (and then close the channel immediately or shortly later in
5880    /// response to server closing its end), which avoids causing logical buffer
5881    /// collection failure.  Normally an unexpected token channel close will
5882    /// cause logical buffer collection failure (the only exceptions being
5883    /// certain cases involving AttachToken() or SetDispensable()).
5884    ///
5885    /// On a BufferCollection channel:
5886    ///
5887    /// By default the server handles unexpected failure of a BufferCollection
5888    /// by failing the whole logical buffer collection.  Partly this is to
5889    /// expedite closing VMO handles to reclaim memory when any participant
5890    /// fails.  If a participant would like to cleanly close a BufferCollection
5891    /// view without causing logical buffer collection failure, the participant
5892    /// can send Close() before closing the client end of the BufferCollection
5893    /// channel.  If this is the last BufferCollection view, the logical buffer
5894    /// collection will still go away.  The Close() can occur before or after
5895    /// SetConstraints().  If before SetConstraints(), the buffer collection
5896    /// won't require constraints from this node in order to allocate.  If
5897    /// after SetConstraints(), the constraints are retained and aggregated
5898    /// along with any subsequent logical allocation(s), despite the lack of
5899    /// channel connection.
5900    ///
5901    /// On a BufferCollectionTokenGroup channel:
5902    ///
5903    /// By default, unexpected failure of a BufferCollectionTokenGroup will
5904    /// trigger failure of the logical BufferCollectionTokenGroup and will
5905    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
5906    /// channel without failing the logical group or propagating failure, send
5907    /// Close() before closing the channel client endpoint.
5908    ///
5909    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5910    /// collection will still fail despite the Close() (because sysmem can't be
5911    /// sure whether all relevant children were created, so it's ambiguous
5912    /// whether all relevant constraints will be provided to sysmem).  If
5913    /// Close() occurs after AllChildrenPresent(), the children and all their
5914    /// constraints remain intact (just as they would if the
5915    /// BufferCollectionTokenGroup channel had remained open), and the close
5916    /// doesn't trigger or propagate failure.
5917    Close { control_handle: BufferCollectionTokenControlHandle },
5918    /// Set a name for VMOs in this buffer collection. The name may be truncated
5919    /// shorter. The name only affects VMOs allocated after it's set - this call
5920    /// does not rename existing VMOs. If multiple clients set different names
5921    /// then the larger priority value will win.
5922    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenControlHandle },
5923    /// Set information about the current client that can be used by sysmem to
5924    /// help debug leaking memory and hangs waiting for constraints. |name| can
5925    /// be an arbitrary string, but the current process name (see
5926    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5927    /// arbitrary id, but the current process ID (see
5928    /// fsl::GetCurrentProcessKoid()) is a good default.
5929    ///
5930    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5931    /// indicate which client is closing their channel first, leading to
5932    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5933    /// over, but if happening earlier than expected, the
5934    /// client-channel-specific name can help diagnose where the failure is
5935    /// first coming from, from sysmem's point of view).
5936    ///
5937    /// By default (unless overriden by this message or using
5938    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5939    /// parent Node at the time the child Node is created.  While this can be
5940    /// better than nothing, it's often better for each participant to use
5941    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5942    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5943    /// can be used to help disambiguate if a Node is suspected of having info
5944    /// that was copied from its parent.
5945    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionTokenControlHandle },
5946    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5947    /// after creating a collection. Clients can call this method to change
5948    /// when the log is printed. If multiple client set the deadline, it's
5949    /// unspecified which deadline will take effect.
5950    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionTokenControlHandle },
5951    /// Verbose logging includes constraints set via SetConstraints() from each
5952    /// client along with info set via SetDebugClientInfo() and the structure of
5953    /// the tree of Node(s).
5954    ///
5955    /// Normally sysmem prints only a single line complaint when aggregation
5956    /// fails, with just the specific detailed reason that aggregation failed,
5957    /// with minimal context.  While this is often enough to diagnose a problem
5958    /// if only a small change was made and the system had been working before
5959    /// the small change, it's often not particularly helpful for getting a new
5960    /// buffer collection to work for the first time.  Especially with more
5961    /// complex trees of nodes, involving things like AttachToken(),
5962    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5963    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5964    /// looks like and why it's failing a logical allocation, or why a tree or
5965    /// sub-tree is failing sooner than expected.
5966    ///
5967    /// The intent of the extra logging is to be acceptable from a performance
5968    /// point of view, if only enabled on a low number of buffer collections.
5969    /// If we're not tracking down a bug, we shouldn't send this message.
5970    ///
5971    /// If too many participants leave verbose logging enabled, we may end up
5972    /// needing to require that system-wide sysmem verbose logging be permitted
5973    /// via some other setting, to avoid sysmem spamming the log too much due to
5974    /// this message.
5975    ///
5976    /// This may be a NOP for some nodes due to intentional policy associated
5977    /// with the node, if we don't trust a node enough to let it turn on verbose
5978    /// logging.
5979    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
5980    /// This gets an event handle that can be used as a parameter to
5981    /// IsAlternateFor() called on any Node.  The client will not be granted the
5982    /// right to signal this event, as this handle should only be used as proof
5983    /// that the client obtained this handle from this Node.
5984    ///
5985    /// Because this is a get not a set, no Sync() is needed between the
5986    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5987    /// potentially being on different channels.
5988    ///
5989    /// See also IsAlternateFor().
5990    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
5991    /// This checks whether the calling node is in a subtree rooted at a
5992    /// different child token of a common parent BufferCollectionTokenGroup, in
5993    /// relation to the passed-in node_ref.
5994    ///
5995    /// This call is for assisting with admission control de-duplication, and
5996    /// with debugging.
5997    ///
5998    /// The node_ref must be obtained using GetNodeRef() of a
5999    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6000    ///
6001    /// The node_ref can be a duplicated handle; it's not necessary to call
6002    /// GetNodeRef() for every call to IsAlternateFor().
6003    ///
6004    /// If a calling token may not actually be a valid token at all due to
6005    /// a potentially hostile/untrusted provider of the token, call
6006    /// ValidateBufferCollectionToken() first instead of potentially getting
6007    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6008    /// token not being a real token (not really talking to sysmem).  Another
6009    /// option is to call BindSharedCollection with this token first which also
6010    /// validates the token along with converting it to a BufferCollection, then
6011    /// call BufferCollection IsAlternateFor().
6012    ///
6013    /// error values:
6014    ///
6015    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6016    /// buffer collection as the calling Node.  Before logical allocation and
6017    /// within the same logical allocation sub-tree, this essentially means that
6018    /// the node_ref was never part of this logical buffer collection, since
6019    /// before logical allocation all node_refs that come into existence remain
6020    /// in existence at least until logical allocation (including Node(s) that
6021    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6022    /// to be returned, this Node's channel needs to still be connected server
6023    /// side, which won't be the case if the whole logical allocation has
6024    /// failed.  After logical allocation or in a different logical allocation
6025    /// sub-tree there are additional potential reasons for this error.  For
6026    /// example a different logical allocation (separated from this Node(s)
6027    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6028    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6029    /// exist and may select a different child sub-tree than the sub-tree the
6030    /// node_ref is in causing deletion of the node_ref Node.  The only time
6031    /// sysmem keeps a Node around after that Node has no corresponding channel
6032    /// is when Close() is used and the Node's sub-tree has not yet failed.
6033    /// Another reason for this error is if the node_ref is an eventpair handle
6034    /// with sufficient rights, but isn't actually a real node_ref obtained from
6035    /// GetNodeRef().
6036    ///
6037    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6038    /// eventpair handle, or doesn't have the needed rights expected on a real
6039    /// node_ref.
6040    ///
6041    /// No other failing status codes are returned by this call.  However,
6042    /// sysmem may add additional codes in future, so the client should have
6043    /// sensible default handling for any failing status code.
6044    ///
6045    /// On success, is_alternate has the following meaning:
6046    ///   * true - The first parent node in common between the calling node and
6047    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
6048    ///     the calling Node and the node_ref Node will _not_ have both their
6049    ///     constraints apply - rather sysmem will choose one or the other of
6050    ///     the constraints - never both.  This is because only one child of
6051    ///     a BufferCollectionTokenGroup is selected during logical allocation,
6052    ///     with only that one child's sub-tree contributing to constraints
6053    ///     aggregation.
6054    ///   * false - The first parent node in common between the calling Node and
6055    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
6056    ///     this means the first parent node in common is a
6057    ///     BufferCollectionToken or BufferCollection (regardless of not
6058    ///     Close()ed or Close()ed).  This means that the calling Node and the
6059    ///     node_ref Node _may_ have both their constraints apply during
6060    ///     constraints aggregation of the logical allocation, if both Node(s)
6061    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
6062    ///     In this case, there is no BufferCollectionTokenGroup that will
6063    ///     directly prevent the two Node(s) from both being selected and their
6064    ///     constraints both aggregated, but even when false, one or both
6065    ///     Node(s) may still be eliminated from consideration if one or both
6066    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6067    ///     which selects a child sub-tree other than the sub-tree containing
6068    ///     the calling Node or node_ref Node.
6069    IsAlternateFor {
6070        node_ref: fidl::Event,
6071        responder: BufferCollectionTokenIsAlternateForResponder,
6072    },
6073    /// This method can be used to add more participants prior to creating a
6074    /// shared BufferCollection. A new token will be returned for each entry in
6075    /// the `rights_attenuation_masks` array. The return value is the client
6076    /// ends of each new participant token.
6077    ///
6078    /// If the calling token may not actually be a valid token at all due to
6079    /// a potentially hostile/untrusted provider of the token, consider using
6080    /// ValidateBufferCollectionToken() first instead of potentially getting
6081    /// stuck indefinitely if DuplicateSync() never responds due to the calling
6082    /// token not being a real token.
6083    ///
6084    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
6085    /// after calling this method.
6086    ///
6087    /// All tokens must be turned in via BindSharedCollection() or Close() for a
6088    /// BufferCollection to be successfully created.
6089    ///
6090    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
6091    /// will be absent in the buffer VMO rights obtainable via the corresponding
6092    /// returned token. This allows an initiator or intermediary participant to
6093    /// attenuate the rights available to a participant. This does not allow a
6094    /// participant to gain rights that the participant doesn't already have.
6095    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
6096    /// attenuation should be applied.
6097    DuplicateSync {
6098        rights_attenuation_masks: Vec<fidl::Rights>,
6099        responder: BufferCollectionTokenDuplicateSyncResponder,
6100    },
6101    /// This method can be used to add a participant prior to creating a shared
6102    /// BufferCollection. It should only be used instead of DuplicateSync in
6103    /// performance sensitive cases where it would be undesireable to wait for
6104    /// sysmem to respond as part of each duplicate.
6105    ///
6106    /// After sending one or more Duplicate() messages, and before sending the
6107    /// created tokens to other participants (or to other Allocator channels),
6108    /// the client should send a Sync() and wait for its response.  The Sync()
6109    /// call can be made on the token, or on the BufferCollection obtained by
6110    /// passing this token to BindSharedCollection().  Either will ensure that
6111    /// the server knows about the tokens created via Duplicate() before the
6112    /// other participant sends the token to the server via separate Allocator
6113    /// channel.
6114    ///
6115    /// All tokens must be turned in via BindSharedCollection() or Close() for a
6116    /// BufferCollection to be successfully created.
6117    ///
6118    /// When a client calls BindSharedCollection() to turn in a
6119    /// BufferCollectionToken, the server will process all Duplicate() messages
6120    /// before closing down the BufferCollectionToken.  This allows the client
6121    /// to Duplicate() and immediately turn in the BufferCollectionToken using
6122    /// BindSharedCollection, then later transfer the client end of token_request
6123    /// to another participant - the server will notice the existence of the
6124    /// token_request before considering this BufferCollectionToken fully closed.
6125    ///
6126    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
6127    /// absent in the buffer VMO rights obtainable via the client end of
6128    /// token_request. This allows an initiator or intermediary participant to
6129    /// attenuate the rights available to a participant. This does not allow a
6130    /// participant to gain rights that the participant doesn't already have.
6131    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
6132    /// attenuation should be applied.
6133    ///
6134    /// These values for rights_attenuation_mask result in no attenuation:
6135    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
6136    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
6137    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
6138    ///
6139    /// `token_request` is the server end of a BufferCollectionToken channel.
6140    /// The client end of this channel acts as another participant in creating the
6141    /// shared BufferCollection.
6142    Duplicate {
6143        rights_attenuation_mask: u32,
6144        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
6145        control_handle: BufferCollectionTokenControlHandle,
6146    },
6147    /// A dispensable token can fail after buffers are logically allocated
6148    /// without causing failure of its parent (if any).
6149    ///
6150    /// The dispensable token participates in constraints aggregation along with
6151    /// its parent before logical buffer allocation.  If the dispensable token
6152    /// fails before buffers are logically allocated, the failure propagates to
6153    /// the dispensable token's parent.
6154    ///
6155    /// After buffers are logically allocated, failure of the dispensable token
6156    /// (or any child of the dispensable token) does not propagate to the
6157    /// dispensable token's parent.  Failure does propagate from a normal
6158    /// child of a dispensable token to the dispensable token.  Failure
6159    /// of a child is blocked from reaching its parent if the child is attached,
6160    /// or if the child is dispensable and the failure occurred after logical
6161    /// allocation.
6162    ///
6163    /// A dispensable token can be used in cases where a participant needs to
6164    /// provide constraints, but after buffers are allocated, the participant
6165    /// can fail without causing buffer collection failure from the parent's
6166    /// point of view.
6167    ///
6168    /// In contrast, AttachToken() can be used to create a token which does not
6169    /// participate in constraints aggregation with its parent, and whose
6170    /// failure at any time does not propagate to its parent, and whose delay
6171    /// providing constraints does not prevent the parent from completing its
6172    /// buffer allocation.
6173    ///
6174    /// An initiator may in some scenarios choose to initially use a dispensable
6175    /// token for a given instance of a participant, and then later if the first
6176    /// instance of that participant fails, a new second instance of that
6177    /// participant my be given a token created with AttachToken().
6178    ///
6179    /// If a client uses this message, the client should not rely on the
6180    /// client's own BufferCollectionToken or BufferCollection channel to close
6181    /// from the server end due to abrupt failure of any BufferCollectionToken
6182    /// or BufferCollection that the client has SetDispensable() and given out
6183    /// to another process.  For this reason, the client should take extra care
6184    /// to notice failure of that other process via other means.
6185    ///
6186    /// While it is possible (and potentially useful) to SetDispensable() on a
6187    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
6188    /// replace a failed dispensable token that was a direct child of a group
6189    /// with a new token using AttachToken() (since there's no AttachToken() on
6190    /// a group).  Instead, to enable AttachToken() replacement in this case,
6191    /// create an additional non-dispensable token (node) that's a direct child
6192    /// of the group and make the existing dispensable token a child of the
6193    /// additional token (node).  This way, the additional token (node) that is
6194    /// a direct child of the group has BufferCollection.AttachToken() which can
6195    /// be used to replace the failed dispensable token.
6196    ///
6197    /// SetDispensable() on an already-dispensable token is idempotent.
6198    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
6199    /// Most sysmem clients and many participants don't need to care about this
6200    /// message or about BufferCollectionTokenGroup(s) in general.
6201    ///
6202    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
6203    /// tokens.  The child tokens which are not selected during aggregation will
6204    /// fail (close), which a potential participant should notice when their
6205    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
6206    /// participant to clean up the speculative usage that didn't end up
6207    /// happening (similarly to a normal BufferCollection server end closing
6208    /// on failure of a logical buffer collection).
6209    ///
6210    /// See comments on protocol BufferCollectionTokenGroup.
6211    ///
6212    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
6213    /// applied to the whole group can be achieved with a token for this purpose
6214    /// as a direct parent of the group.
6215    ///
6216    /// group_request - the server end of a BufferCollectionTokenGroup channel
6217    /// to be served by sysmem.
6218    CreateBufferCollectionTokenGroup {
6219        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6220        control_handle: BufferCollectionTokenControlHandle,
6221    },
6222}
6223
6224impl BufferCollectionTokenRequest {
6225    #[allow(irrefutable_let_patterns)]
6226    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6227        if let BufferCollectionTokenRequest::Sync { responder } = self {
6228            Some((responder))
6229        } else {
6230            None
6231        }
6232    }
6233
6234    #[allow(irrefutable_let_patterns)]
6235    pub fn into_close(self) -> Option<(BufferCollectionTokenControlHandle)> {
6236        if let BufferCollectionTokenRequest::Close { control_handle } = self {
6237            Some((control_handle))
6238        } else {
6239            None
6240        }
6241    }
6242
6243    #[allow(irrefutable_let_patterns)]
6244    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenControlHandle)> {
6245        if let BufferCollectionTokenRequest::SetName { priority, name, control_handle } = self {
6246            Some((priority, name, control_handle))
6247        } else {
6248            None
6249        }
6250    }
6251
6252    #[allow(irrefutable_let_patterns)]
6253    pub fn into_set_debug_client_info(
6254        self,
6255    ) -> Option<(String, u64, BufferCollectionTokenControlHandle)> {
6256        if let BufferCollectionTokenRequest::SetDebugClientInfo { name, id, control_handle } = self
6257        {
6258            Some((name, id, control_handle))
6259        } else {
6260            None
6261        }
6262    }
6263
6264    #[allow(irrefutable_let_patterns)]
6265    pub fn into_set_debug_timeout_log_deadline(
6266        self,
6267    ) -> Option<(i64, BufferCollectionTokenControlHandle)> {
6268        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6269            deadline,
6270            control_handle,
6271        } = self
6272        {
6273            Some((deadline, control_handle))
6274        } else {
6275            None
6276        }
6277    }
6278
6279    #[allow(irrefutable_let_patterns)]
6280    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6281        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6282            Some((control_handle))
6283        } else {
6284            None
6285        }
6286    }
6287
6288    #[allow(irrefutable_let_patterns)]
6289    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6290        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6291            Some((responder))
6292        } else {
6293            None
6294        }
6295    }
6296
6297    #[allow(irrefutable_let_patterns)]
6298    pub fn into_is_alternate_for(
6299        self,
6300    ) -> Option<(fidl::Event, BufferCollectionTokenIsAlternateForResponder)> {
6301        if let BufferCollectionTokenRequest::IsAlternateFor { node_ref, responder } = self {
6302            Some((node_ref, responder))
6303        } else {
6304            None
6305        }
6306    }
6307
6308    #[allow(irrefutable_let_patterns)]
6309    pub fn into_duplicate_sync(
6310        self,
6311    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenDuplicateSyncResponder)> {
6312        if let BufferCollectionTokenRequest::DuplicateSync { rights_attenuation_masks, responder } =
6313            self
6314        {
6315            Some((rights_attenuation_masks, responder))
6316        } else {
6317            None
6318        }
6319    }
6320
6321    #[allow(irrefutable_let_patterns)]
6322    pub fn into_duplicate(
6323        self,
6324    ) -> Option<(
6325        u32,
6326        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
6327        BufferCollectionTokenControlHandle,
6328    )> {
6329        if let BufferCollectionTokenRequest::Duplicate {
6330            rights_attenuation_mask,
6331            token_request,
6332            control_handle,
6333        } = self
6334        {
6335            Some((rights_attenuation_mask, token_request, control_handle))
6336        } else {
6337            None
6338        }
6339    }
6340
6341    #[allow(irrefutable_let_patterns)]
6342    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6343        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6344            Some((control_handle))
6345        } else {
6346            None
6347        }
6348    }
6349
6350    #[allow(irrefutable_let_patterns)]
6351    pub fn into_create_buffer_collection_token_group(
6352        self,
6353    ) -> Option<(
6354        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6355        BufferCollectionTokenControlHandle,
6356    )> {
6357        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6358            group_request,
6359            control_handle,
6360        } = self
6361        {
6362            Some((group_request, control_handle))
6363        } else {
6364            None
6365        }
6366    }
6367
6368    /// Name of the method defined in FIDL
6369    pub fn method_name(&self) -> &'static str {
6370        match *self {
6371            BufferCollectionTokenRequest::Sync { .. } => "sync",
6372            BufferCollectionTokenRequest::Close { .. } => "close",
6373            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6374            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6375            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6376                "set_debug_timeout_log_deadline"
6377            }
6378            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6379            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6380            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6381            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6382            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6383            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6384            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6385                "create_buffer_collection_token_group"
6386            }
6387        }
6388    }
6389}
6390
6391#[derive(Debug, Clone)]
6392pub struct BufferCollectionTokenControlHandle {
6393    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6394}
6395
6396impl fidl::endpoints::ControlHandle for BufferCollectionTokenControlHandle {
6397    fn shutdown(&self) {
6398        self.inner.shutdown()
6399    }
6400    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6401        self.inner.shutdown_with_epitaph(status)
6402    }
6403
6404    fn is_closed(&self) -> bool {
6405        self.inner.channel().is_closed()
6406    }
6407    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6408        self.inner.channel().on_closed()
6409    }
6410
6411    #[cfg(target_os = "fuchsia")]
6412    fn signal_peer(
6413        &self,
6414        clear_mask: zx::Signals,
6415        set_mask: zx::Signals,
6416    ) -> Result<(), zx_status::Status> {
6417        use fidl::Peered;
6418        self.inner.channel().signal_peer(clear_mask, set_mask)
6419    }
6420}
6421
6422impl BufferCollectionTokenControlHandle {}
6423
6424#[must_use = "FIDL methods require a response to be sent"]
6425#[derive(Debug)]
6426pub struct BufferCollectionTokenSyncResponder {
6427    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6428    tx_id: u32,
6429}
6430
6431/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6432/// if the responder is dropped without sending a response, so that the client
6433/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6434impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6435    fn drop(&mut self) {
6436        self.control_handle.shutdown();
6437        // Safety: drops once, never accessed again
6438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6439    }
6440}
6441
6442impl fidl::endpoints::Responder for BufferCollectionTokenSyncResponder {
6443    type ControlHandle = BufferCollectionTokenControlHandle;
6444
6445    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6446        &self.control_handle
6447    }
6448
6449    fn drop_without_shutdown(mut self) {
6450        // Safety: drops once, never accessed again due to mem::forget
6451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6452        // Prevent Drop from running (which would shut down the channel)
6453        std::mem::forget(self);
6454    }
6455}
6456
6457impl BufferCollectionTokenSyncResponder {
6458    /// Sends a response to the FIDL transaction.
6459    ///
6460    /// Sets the channel to shutdown if an error occurs.
6461    pub fn send(self) -> Result<(), fidl::Error> {
6462        let _result = self.send_raw();
6463        if _result.is_err() {
6464            self.control_handle.shutdown();
6465        }
6466        self.drop_without_shutdown();
6467        _result
6468    }
6469
6470    /// Similar to "send" but does not shutdown the channel if an error occurs.
6471    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6472        let _result = self.send_raw();
6473        self.drop_without_shutdown();
6474        _result
6475    }
6476
6477    fn send_raw(&self) -> Result<(), fidl::Error> {
6478        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6479            (),
6480            self.tx_id,
6481            0x4577e238ae26291,
6482            fidl::encoding::DynamicFlags::empty(),
6483        )
6484    }
6485}
6486
6487#[must_use = "FIDL methods require a response to be sent"]
6488#[derive(Debug)]
6489pub struct BufferCollectionTokenGetNodeRefResponder {
6490    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6491    tx_id: u32,
6492}
6493
6494/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6495/// if the responder is dropped without sending a response, so that the client
6496/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6497impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6498    fn drop(&mut self) {
6499        self.control_handle.shutdown();
6500        // Safety: drops once, never accessed again
6501        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6502    }
6503}
6504
6505impl fidl::endpoints::Responder for BufferCollectionTokenGetNodeRefResponder {
6506    type ControlHandle = BufferCollectionTokenControlHandle;
6507
6508    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6509        &self.control_handle
6510    }
6511
6512    fn drop_without_shutdown(mut self) {
6513        // Safety: drops once, never accessed again due to mem::forget
6514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6515        // Prevent Drop from running (which would shut down the channel)
6516        std::mem::forget(self);
6517    }
6518}
6519
6520impl BufferCollectionTokenGetNodeRefResponder {
6521    /// Sends a response to the FIDL transaction.
6522    ///
6523    /// Sets the channel to shutdown if an error occurs.
6524    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6525        let _result = self.send_raw(node_ref);
6526        if _result.is_err() {
6527            self.control_handle.shutdown();
6528        }
6529        self.drop_without_shutdown();
6530        _result
6531    }
6532
6533    /// Similar to "send" but does not shutdown the channel if an error occurs.
6534    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6535        let _result = self.send_raw(node_ref);
6536        self.drop_without_shutdown();
6537        _result
6538    }
6539
6540    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6541        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
6542            (node_ref,),
6543            self.tx_id,
6544            0x467b7c75c35c3b84,
6545            fidl::encoding::DynamicFlags::empty(),
6546        )
6547    }
6548}
6549
6550#[must_use = "FIDL methods require a response to be sent"]
6551#[derive(Debug)]
6552pub struct BufferCollectionTokenIsAlternateForResponder {
6553    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6554    tx_id: u32,
6555}
6556
6557/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6558/// if the responder is dropped without sending a response, so that the client
6559/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6560impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
6561    fn drop(&mut self) {
6562        self.control_handle.shutdown();
6563        // Safety: drops once, never accessed again
6564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6565    }
6566}
6567
6568impl fidl::endpoints::Responder for BufferCollectionTokenIsAlternateForResponder {
6569    type ControlHandle = BufferCollectionTokenControlHandle;
6570
6571    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6572        &self.control_handle
6573    }
6574
6575    fn drop_without_shutdown(mut self) {
6576        // Safety: drops once, never accessed again due to mem::forget
6577        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6578        // Prevent Drop from running (which would shut down the channel)
6579        std::mem::forget(self);
6580    }
6581}
6582
6583impl BufferCollectionTokenIsAlternateForResponder {
6584    /// Sends a response to the FIDL transaction.
6585    ///
6586    /// Sets the channel to shutdown if an error occurs.
6587    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6588        let _result = self.send_raw(result);
6589        if _result.is_err() {
6590            self.control_handle.shutdown();
6591        }
6592        self.drop_without_shutdown();
6593        _result
6594    }
6595
6596    /// Similar to "send" but does not shutdown the channel if an error occurs.
6597    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6598        let _result = self.send_raw(result);
6599        self.drop_without_shutdown();
6600        _result
6601    }
6602
6603    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6604        self.control_handle
6605            .inner
6606            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
6607                result.map(|is_alternate| (is_alternate,)),
6608                self.tx_id,
6609                0x33a2a7aff2776c07,
6610                fidl::encoding::DynamicFlags::empty(),
6611            )
6612    }
6613}
6614
6615#[must_use = "FIDL methods require a response to be sent"]
6616#[derive(Debug)]
6617pub struct BufferCollectionTokenDuplicateSyncResponder {
6618    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6619    tx_id: u32,
6620}
6621
6622/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6623/// if the responder is dropped without sending a response, so that the client
6624/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6625impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
6626    fn drop(&mut self) {
6627        self.control_handle.shutdown();
6628        // Safety: drops once, never accessed again
6629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6630    }
6631}
6632
6633impl fidl::endpoints::Responder for BufferCollectionTokenDuplicateSyncResponder {
6634    type ControlHandle = BufferCollectionTokenControlHandle;
6635
6636    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6637        &self.control_handle
6638    }
6639
6640    fn drop_without_shutdown(mut self) {
6641        // Safety: drops once, never accessed again due to mem::forget
6642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6643        // Prevent Drop from running (which would shut down the channel)
6644        std::mem::forget(self);
6645    }
6646}
6647
6648impl BufferCollectionTokenDuplicateSyncResponder {
6649    /// Sends a response to the FIDL transaction.
6650    ///
6651    /// Sets the channel to shutdown if an error occurs.
6652    pub fn send(
6653        self,
6654        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6655    ) -> Result<(), fidl::Error> {
6656        let _result = self.send_raw(tokens);
6657        if _result.is_err() {
6658            self.control_handle.shutdown();
6659        }
6660        self.drop_without_shutdown();
6661        _result
6662    }
6663
6664    /// Similar to "send" but does not shutdown the channel if an error occurs.
6665    pub fn send_no_shutdown_on_err(
6666        self,
6667        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6668    ) -> Result<(), fidl::Error> {
6669        let _result = self.send_raw(tokens);
6670        self.drop_without_shutdown();
6671        _result
6672    }
6673
6674    fn send_raw(
6675        &self,
6676        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6677    ) -> Result<(), fidl::Error> {
6678        self.control_handle.inner.send::<BufferCollectionTokenDuplicateSyncResponse>(
6679            (tokens.as_mut(),),
6680            self.tx_id,
6681            0x49ed7ab7cc19f18,
6682            fidl::encoding::DynamicFlags::empty(),
6683        )
6684    }
6685}
6686
6687#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6688pub struct BufferCollectionTokenGroupMarker;
6689
6690impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenGroupMarker {
6691    type Proxy = BufferCollectionTokenGroupProxy;
6692    type RequestStream = BufferCollectionTokenGroupRequestStream;
6693    #[cfg(target_os = "fuchsia")]
6694    type SynchronousProxy = BufferCollectionTokenGroupSynchronousProxy;
6695
6696    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
6697}
6698
6699pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
6700    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6701    fn r#sync(&self) -> Self::SyncResponseFut;
6702    fn r#close(&self) -> Result<(), fidl::Error>;
6703    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
6704    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
6705    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
6706    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
6707    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
6708        + Send;
6709    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
6710    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
6711        + Send;
6712    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
6713    fn r#create_child(
6714        &self,
6715        payload: BufferCollectionTokenGroupCreateChildRequest,
6716    ) -> Result<(), fidl::Error>;
6717    type CreateChildrenSyncResponseFut: std::future::Future<
6718            Output = Result<
6719                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6720                fidl::Error,
6721            >,
6722        > + Send;
6723    fn r#create_children_sync(
6724        &self,
6725        rights_attenuation_masks: &[fidl::Rights],
6726    ) -> Self::CreateChildrenSyncResponseFut;
6727    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
6728}
6729#[derive(Debug)]
6730#[cfg(target_os = "fuchsia")]
6731pub struct BufferCollectionTokenGroupSynchronousProxy {
6732    client: fidl::client::sync::Client,
6733}
6734
6735#[cfg(target_os = "fuchsia")]
6736impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenGroupSynchronousProxy {
6737    type Proxy = BufferCollectionTokenGroupProxy;
6738    type Protocol = BufferCollectionTokenGroupMarker;
6739
6740    fn from_channel(inner: fidl::Channel) -> Self {
6741        Self::new(inner)
6742    }
6743
6744    fn into_channel(self) -> fidl::Channel {
6745        self.client.into_channel()
6746    }
6747
6748    fn as_channel(&self) -> &fidl::Channel {
6749        self.client.as_channel()
6750    }
6751}
6752
6753#[cfg(target_os = "fuchsia")]
6754impl BufferCollectionTokenGroupSynchronousProxy {
6755    pub fn new(channel: fidl::Channel) -> Self {
6756        let protocol_name =
6757            <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6758        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6759    }
6760
6761    pub fn into_channel(self) -> fidl::Channel {
6762        self.client.into_channel()
6763    }
6764
6765    /// Waits until an event arrives and returns it. It is safe for other
6766    /// threads to make concurrent requests while waiting for an event.
6767    pub fn wait_for_event(
6768        &self,
6769        deadline: zx::MonotonicInstant,
6770    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
6771        BufferCollectionTokenGroupEvent::decode(self.client.wait_for_event(deadline)?)
6772    }
6773
6774    /// Ensure that previous messages, including Duplicate() messages on a
6775    /// token, collection, or group, have been received server side.
6776    ///
6777    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
6778    /// valid sysmem token risks the Sync() hanging forever.  See
6779    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
6780    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
6781    /// Another way is to pass the token to BindSharedCollection(), which also
6782    /// validates the token as part of exchanging it for a BufferCollection
6783    /// channel, and BufferCollection Sync() can then be used.
6784    ///
6785    /// After a Sync(), it's then safe to send the client end of token_request
6786    /// to another participant knowing the server will recognize the token when
6787    /// it's sent into BindSharedCollection() by the other participant.
6788    ///
6789    /// Other options include waiting for each token.Duplicate() to complete
6790    /// individually (using separate call to token.Sync() after each), or
6791    /// calling Sync() on BufferCollection after the token has been turned in
6792    /// via BindSharedCollection().
6793    ///
6794    /// Another way to mitigate is to avoid calling Sync() on the token, and
6795    /// instead later deal with potential failure of BufferCollection.Sync() if
6796    /// the original token was invalid.  This option can be preferable from a
6797    /// performance point of view, but requires client code to delay sending
6798    /// tokens duplicated from this token until after client code has converted
6799    /// the duplicating token to a BufferCollection and received successful
6800    /// response from BufferCollection.Sync().
6801    ///
6802    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
6803    /// When BufferCollection.Sync() isn't feasible, the caller must already
6804    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
6805    /// hang forever.  See ValidateBufferCollectionToken() to check token
6806    /// validity first if the token isn't already known to be (is/was) valid.
6807    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
6808        let _response =
6809            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
6810                (),
6811                0x4577e238ae26291,
6812                fidl::encoding::DynamicFlags::empty(),
6813                ___deadline,
6814            )?;
6815        Ok(_response)
6816    }
6817
6818    /// On a BufferCollectionToken channel:
6819    ///
6820    /// Normally a participant will convert a BufferCollectionToken into a
6821    /// BufferCollection view, but a participant is also free to Close() the
6822    /// token (and then close the channel immediately or shortly later in
6823    /// response to server closing its end), which avoids causing logical buffer
6824    /// collection failure.  Normally an unexpected token channel close will
6825    /// cause logical buffer collection failure (the only exceptions being
6826    /// certain cases involving AttachToken() or SetDispensable()).
6827    ///
6828    /// On a BufferCollection channel:
6829    ///
6830    /// By default the server handles unexpected failure of a BufferCollection
6831    /// by failing the whole logical buffer collection.  Partly this is to
6832    /// expedite closing VMO handles to reclaim memory when any participant
6833    /// fails.  If a participant would like to cleanly close a BufferCollection
6834    /// view without causing logical buffer collection failure, the participant
6835    /// can send Close() before closing the client end of the BufferCollection
6836    /// channel.  If this is the last BufferCollection view, the logical buffer
6837    /// collection will still go away.  The Close() can occur before or after
6838    /// SetConstraints().  If before SetConstraints(), the buffer collection
6839    /// won't require constraints from this node in order to allocate.  If
6840    /// after SetConstraints(), the constraints are retained and aggregated
6841    /// along with any subsequent logical allocation(s), despite the lack of
6842    /// channel connection.
6843    ///
6844    /// On a BufferCollectionTokenGroup channel:
6845    ///
6846    /// By default, unexpected failure of a BufferCollectionTokenGroup will
6847    /// trigger failure of the logical BufferCollectionTokenGroup and will
6848    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
6849    /// channel without failing the logical group or propagating failure, send
6850    /// Close() before closing the channel client endpoint.
6851    ///
6852    /// If Close() occurs before AllChildrenPresent(), the logical buffer
6853    /// collection will still fail despite the Close() (because sysmem can't be
6854    /// sure whether all relevant children were created, so it's ambiguous
6855    /// whether all relevant constraints will be provided to sysmem).  If
6856    /// Close() occurs after AllChildrenPresent(), the children and all their
6857    /// constraints remain intact (just as they would if the
6858    /// BufferCollectionTokenGroup channel had remained open), and the close
6859    /// doesn't trigger or propagate failure.
6860    pub fn r#close(&self) -> Result<(), fidl::Error> {
6861        self.client.send::<fidl::encoding::EmptyPayload>(
6862            (),
6863            0x5b1d7a4f5681fca7,
6864            fidl::encoding::DynamicFlags::empty(),
6865        )
6866    }
6867
6868    /// Set a name for VMOs in this buffer collection. The name may be truncated
6869    /// shorter. The name only affects VMOs allocated after it's set - this call
6870    /// does not rename existing VMOs. If multiple clients set different names
6871    /// then the larger priority value will win.
6872    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
6873        self.client.send::<NodeSetNameRequest>(
6874            (priority, name),
6875            0x77a41bb6217e2443,
6876            fidl::encoding::DynamicFlags::empty(),
6877        )
6878    }
6879
6880    /// Set information about the current client that can be used by sysmem to
6881    /// help debug leaking memory and hangs waiting for constraints. |name| can
6882    /// be an arbitrary string, but the current process name (see
6883    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6884    /// arbitrary id, but the current process ID (see
6885    /// fsl::GetCurrentProcessKoid()) is a good default.
6886    ///
6887    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6888    /// indicate which client is closing their channel first, leading to
6889    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6890    /// over, but if happening earlier than expected, the
6891    /// client-channel-specific name can help diagnose where the failure is
6892    /// first coming from, from sysmem's point of view).
6893    ///
6894    /// By default (unless overriden by this message or using
6895    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6896    /// parent Node at the time the child Node is created.  While this can be
6897    /// better than nothing, it's often better for each participant to use
6898    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6899    /// info directly relevant to the current client.  Also, SetVerboseLogging()
6900    /// can be used to help disambiguate if a Node is suspected of having info
6901    /// that was copied from its parent.
6902    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
6903        self.client.send::<NodeSetDebugClientInfoRequest>(
6904            (name, id),
6905            0x7275759070eb5ee2,
6906            fidl::encoding::DynamicFlags::empty(),
6907        )
6908    }
6909
6910    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6911    /// after creating a collection. Clients can call this method to change
6912    /// when the log is printed. If multiple client set the deadline, it's
6913    /// unspecified which deadline will take effect.
6914    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
6915        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
6916            (deadline,),
6917            0x46d38f4772638867,
6918            fidl::encoding::DynamicFlags::empty(),
6919        )
6920    }
6921
6922    /// Verbose logging includes constraints set via SetConstraints() from each
6923    /// client along with info set via SetDebugClientInfo() and the structure of
6924    /// the tree of Node(s).
6925    ///
6926    /// Normally sysmem prints only a single line complaint when aggregation
6927    /// fails, with just the specific detailed reason that aggregation failed,
6928    /// with minimal context.  While this is often enough to diagnose a problem
6929    /// if only a small change was made and the system had been working before
6930    /// the small change, it's often not particularly helpful for getting a new
6931    /// buffer collection to work for the first time.  Especially with more
6932    /// complex trees of nodes, involving things like AttachToken(),
6933    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6934    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6935    /// looks like and why it's failing a logical allocation, or why a tree or
6936    /// sub-tree is failing sooner than expected.
6937    ///
6938    /// The intent of the extra logging is to be acceptable from a performance
6939    /// point of view, if only enabled on a low number of buffer collections.
6940    /// If we're not tracking down a bug, we shouldn't send this message.
6941    ///
6942    /// If too many participants leave verbose logging enabled, we may end up
6943    /// needing to require that system-wide sysmem verbose logging be permitted
6944    /// via some other setting, to avoid sysmem spamming the log too much due to
6945    /// this message.
6946    ///
6947    /// This may be a NOP for some nodes due to intentional policy associated
6948    /// with the node, if we don't trust a node enough to let it turn on verbose
6949    /// logging.
6950    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
6951        self.client.send::<fidl::encoding::EmptyPayload>(
6952            (),
6953            0x6bfbe2cf1701d288,
6954            fidl::encoding::DynamicFlags::empty(),
6955        )
6956    }
6957
6958    /// This gets an event handle that can be used as a parameter to
6959    /// IsAlternateFor() called on any Node.  The client will not be granted the
6960    /// right to signal this event, as this handle should only be used as proof
6961    /// that the client obtained this handle from this Node.
6962    ///
6963    /// Because this is a get not a set, no Sync() is needed between the
6964    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6965    /// potentially being on different channels.
6966    ///
6967    /// See also IsAlternateFor().
6968    pub fn r#get_node_ref(
6969        &self,
6970        ___deadline: zx::MonotonicInstant,
6971    ) -> Result<fidl::Event, fidl::Error> {
6972        let _response =
6973            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
6974                (),
6975                0x467b7c75c35c3b84,
6976                fidl::encoding::DynamicFlags::empty(),
6977                ___deadline,
6978            )?;
6979        Ok(_response.node_ref)
6980    }
6981
6982    /// This checks whether the calling node is in a subtree rooted at a
6983    /// different child token of a common parent BufferCollectionTokenGroup, in
6984    /// relation to the passed-in node_ref.
6985    ///
6986    /// This call is for assisting with admission control de-duplication, and
6987    /// with debugging.
6988    ///
6989    /// The node_ref must be obtained using GetNodeRef() of a
6990    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6991    ///
6992    /// The node_ref can be a duplicated handle; it's not necessary to call
6993    /// GetNodeRef() for every call to IsAlternateFor().
6994    ///
6995    /// If a calling token may not actually be a valid token at all due to
6996    /// a potentially hostile/untrusted provider of the token, call
6997    /// ValidateBufferCollectionToken() first instead of potentially getting
6998    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6999    /// token not being a real token (not really talking to sysmem).  Another
7000    /// option is to call BindSharedCollection with this token first which also
7001    /// validates the token along with converting it to a BufferCollection, then
7002    /// call BufferCollection IsAlternateFor().
7003    ///
7004    /// error values:
7005    ///
7006    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7007    /// buffer collection as the calling Node.  Before logical allocation and
7008    /// within the same logical allocation sub-tree, this essentially means that
7009    /// the node_ref was never part of this logical buffer collection, since
7010    /// before logical allocation all node_refs that come into existence remain
7011    /// in existence at least until logical allocation (including Node(s) that
7012    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7013    /// to be returned, this Node's channel needs to still be connected server
7014    /// side, which won't be the case if the whole logical allocation has
7015    /// failed.  After logical allocation or in a different logical allocation
7016    /// sub-tree there are additional potential reasons for this error.  For
7017    /// example a different logical allocation (separated from this Node(s)
7018    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7019    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7020    /// exist and may select a different child sub-tree than the sub-tree the
7021    /// node_ref is in causing deletion of the node_ref Node.  The only time
7022    /// sysmem keeps a Node around after that Node has no corresponding channel
7023    /// is when Close() is used and the Node's sub-tree has not yet failed.
7024    /// Another reason for this error is if the node_ref is an eventpair handle
7025    /// with sufficient rights, but isn't actually a real node_ref obtained from
7026    /// GetNodeRef().
7027    ///
7028    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7029    /// eventpair handle, or doesn't have the needed rights expected on a real
7030    /// node_ref.
7031    ///
7032    /// No other failing status codes are returned by this call.  However,
7033    /// sysmem may add additional codes in future, so the client should have
7034    /// sensible default handling for any failing status code.
7035    ///
7036    /// On success, is_alternate has the following meaning:
7037    ///   * true - The first parent node in common between the calling node and
7038    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7039    ///     the calling Node and the node_ref Node will _not_ have both their
7040    ///     constraints apply - rather sysmem will choose one or the other of
7041    ///     the constraints - never both.  This is because only one child of
7042    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7043    ///     with only that one child's sub-tree contributing to constraints
7044    ///     aggregation.
7045    ///   * false - The first parent node in common between the calling Node and
7046    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7047    ///     this means the first parent node in common is a
7048    ///     BufferCollectionToken or BufferCollection (regardless of not
7049    ///     Close()ed or Close()ed).  This means that the calling Node and the
7050    ///     node_ref Node _may_ have both their constraints apply during
7051    ///     constraints aggregation of the logical allocation, if both Node(s)
7052    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7053    ///     In this case, there is no BufferCollectionTokenGroup that will
7054    ///     directly prevent the two Node(s) from both being selected and their
7055    ///     constraints both aggregated, but even when false, one or both
7056    ///     Node(s) may still be eliminated from consideration if one or both
7057    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7058    ///     which selects a child sub-tree other than the sub-tree containing
7059    ///     the calling Node or node_ref Node.
7060    pub fn r#is_alternate_for(
7061        &self,
7062        mut node_ref: fidl::Event,
7063        ___deadline: zx::MonotonicInstant,
7064    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7065        let _response = self.client.send_query::<
7066            NodeIsAlternateForRequest,
7067            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7068        >(
7069            (node_ref,),
7070            0x33a2a7aff2776c07,
7071            fidl::encoding::DynamicFlags::empty(),
7072            ___deadline,
7073        )?;
7074        Ok(_response.map(|x| x.is_alternate))
7075    }
7076
7077    /// Create a child token.  Before passing the client end of this token to
7078    /// BindSharedCollection(), completion of Sync() after CreateChild() is
7079    /// required.  Or the client can use CreateChildrenSync() which essentially
7080    /// includes the Sync().
7081    ///
7082    /// token_request - the server end of the new token channel.
7083    ///
7084    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
7085    /// allows the holder to get the same rights to buffers as the parent token
7086    /// (of the group) had.
7087    pub fn r#create_child(
7088        &self,
7089        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7090    ) -> Result<(), fidl::Error> {
7091        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7092            &mut payload,
7093            0x2e74f8bcbf59ee59,
7094            fidl::encoding::DynamicFlags::empty(),
7095        )
7096    }
7097
7098    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7099    /// CreateChild(), no Sync() completion is required before passing the
7100    /// client end of a returned token to BindSharedCollection().
7101    ///
7102    /// The size of the rights_attentuation_mask determines the number of
7103    /// created child tokens.
7104    ///
7105    /// The lower-index child tokens are higher priority (attempted sooner) than
7106    /// higher-index child tokens.
7107    ///
7108    /// As per all child tokens, successful aggregation will choose exactly one
7109    /// child among all created children (across all children created across
7110    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
7111    ///
7112    /// The maximum permissible total number of children per group, and total
7113    /// number of nodes in an overall tree (from the root) are capped to limits
7114    /// which are not configurable via these protocols.
7115    pub fn r#create_children_sync(
7116        &self,
7117        mut rights_attenuation_masks: &[fidl::Rights],
7118        ___deadline: zx::MonotonicInstant,
7119    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
7120        let _response = self.client.send_query::<
7121            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7122            BufferCollectionTokenGroupCreateChildrenSyncResponse,
7123        >(
7124            (rights_attenuation_masks,),
7125            0x569dc3ca2a98f535,
7126            fidl::encoding::DynamicFlags::empty(),
7127            ___deadline,
7128        )?;
7129        Ok(_response.tokens)
7130    }
7131
7132    /// AllChildrenPresent()
7133    ///
7134    /// After creating all children, the client must call AllChildrenPresent()
7135    /// to inform sysmem that no more children will be created, so that sysmem
7136    /// can know when it's ok to start aggregating constraints.
7137    ///
7138    /// If Close() is to be sent, it should be sent _after_
7139    /// AllChildrenPresent(), else failure of the group and propagation of the
7140    /// failure to the group's parent will still be triggered.
7141    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7142        self.client.send::<fidl::encoding::EmptyPayload>(
7143            (),
7144            0x1d41715f6f044b50,
7145            fidl::encoding::DynamicFlags::empty(),
7146        )
7147    }
7148}
7149
7150#[cfg(target_os = "fuchsia")]
7151impl From<BufferCollectionTokenGroupSynchronousProxy> for zx::Handle {
7152    fn from(value: BufferCollectionTokenGroupSynchronousProxy) -> Self {
7153        value.into_channel().into()
7154    }
7155}
7156
7157#[cfg(target_os = "fuchsia")]
7158impl From<fidl::Channel> for BufferCollectionTokenGroupSynchronousProxy {
7159    fn from(value: fidl::Channel) -> Self {
7160        Self::new(value)
7161    }
7162}
7163
7164#[derive(Debug, Clone)]
7165pub struct BufferCollectionTokenGroupProxy {
7166    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7167}
7168
7169impl fidl::endpoints::Proxy for BufferCollectionTokenGroupProxy {
7170    type Protocol = BufferCollectionTokenGroupMarker;
7171
7172    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7173        Self::new(inner)
7174    }
7175
7176    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7177        self.client.into_channel().map_err(|client| Self { client })
7178    }
7179
7180    fn as_channel(&self) -> &::fidl::AsyncChannel {
7181        self.client.as_channel()
7182    }
7183}
7184
7185impl BufferCollectionTokenGroupProxy {
7186    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionTokenGroup.
7187    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7188        let protocol_name =
7189            <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7190        Self { client: fidl::client::Client::new(channel, protocol_name) }
7191    }
7192
7193    /// Get a Stream of events from the remote end of the protocol.
7194    ///
7195    /// # Panics
7196    ///
7197    /// Panics if the event stream was already taken.
7198    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7199        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7200    }
7201
7202    /// Ensure that previous messages, including Duplicate() messages on a
7203    /// token, collection, or group, have been received server side.
7204    ///
7205    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7206    /// valid sysmem token risks the Sync() hanging forever.  See
7207    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7208    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7209    /// Another way is to pass the token to BindSharedCollection(), which also
7210    /// validates the token as part of exchanging it for a BufferCollection
7211    /// channel, and BufferCollection Sync() can then be used.
7212    ///
7213    /// After a Sync(), it's then safe to send the client end of token_request
7214    /// to another participant knowing the server will recognize the token when
7215    /// it's sent into BindSharedCollection() by the other participant.
7216    ///
7217    /// Other options include waiting for each token.Duplicate() to complete
7218    /// individually (using separate call to token.Sync() after each), or
7219    /// calling Sync() on BufferCollection after the token has been turned in
7220    /// via BindSharedCollection().
7221    ///
7222    /// Another way to mitigate is to avoid calling Sync() on the token, and
7223    /// instead later deal with potential failure of BufferCollection.Sync() if
7224    /// the original token was invalid.  This option can be preferable from a
7225    /// performance point of view, but requires client code to delay sending
7226    /// tokens duplicated from this token until after client code has converted
7227    /// the duplicating token to a BufferCollection and received successful
7228    /// response from BufferCollection.Sync().
7229    ///
7230    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7231    /// When BufferCollection.Sync() isn't feasible, the caller must already
7232    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7233    /// hang forever.  See ValidateBufferCollectionToken() to check token
7234    /// validity first if the token isn't already known to be (is/was) valid.
7235    pub fn r#sync(
7236        &self,
7237    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7238        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7239    }
7240
7241    /// On a BufferCollectionToken channel:
7242    ///
7243    /// Normally a participant will convert a BufferCollectionToken into a
7244    /// BufferCollection view, but a participant is also free to Close() the
7245    /// token (and then close the channel immediately or shortly later in
7246    /// response to server closing its end), which avoids causing logical buffer
7247    /// collection failure.  Normally an unexpected token channel close will
7248    /// cause logical buffer collection failure (the only exceptions being
7249    /// certain cases involving AttachToken() or SetDispensable()).
7250    ///
7251    /// On a BufferCollection channel:
7252    ///
7253    /// By default the server handles unexpected failure of a BufferCollection
7254    /// by failing the whole logical buffer collection.  Partly this is to
7255    /// expedite closing VMO handles to reclaim memory when any participant
7256    /// fails.  If a participant would like to cleanly close a BufferCollection
7257    /// view without causing logical buffer collection failure, the participant
7258    /// can send Close() before closing the client end of the BufferCollection
7259    /// channel.  If this is the last BufferCollection view, the logical buffer
7260    /// collection will still go away.  The Close() can occur before or after
7261    /// SetConstraints().  If before SetConstraints(), the buffer collection
7262    /// won't require constraints from this node in order to allocate.  If
7263    /// after SetConstraints(), the constraints are retained and aggregated
7264    /// along with any subsequent logical allocation(s), despite the lack of
7265    /// channel connection.
7266    ///
7267    /// On a BufferCollectionTokenGroup channel:
7268    ///
7269    /// By default, unexpected failure of a BufferCollectionTokenGroup will
7270    /// trigger failure of the logical BufferCollectionTokenGroup and will
7271    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
7272    /// channel without failing the logical group or propagating failure, send
7273    /// Close() before closing the channel client endpoint.
7274    ///
7275    /// If Close() occurs before AllChildrenPresent(), the logical buffer
7276    /// collection will still fail despite the Close() (because sysmem can't be
7277    /// sure whether all relevant children were created, so it's ambiguous
7278    /// whether all relevant constraints will be provided to sysmem).  If
7279    /// Close() occurs after AllChildrenPresent(), the children and all their
7280    /// constraints remain intact (just as they would if the
7281    /// BufferCollectionTokenGroup channel had remained open), and the close
7282    /// doesn't trigger or propagate failure.
7283    pub fn r#close(&self) -> Result<(), fidl::Error> {
7284        BufferCollectionTokenGroupProxyInterface::r#close(self)
7285    }
7286
7287    /// Set a name for VMOs in this buffer collection. The name may be truncated
7288    /// shorter. The name only affects VMOs allocated after it's set - this call
7289    /// does not rename existing VMOs. If multiple clients set different names
7290    /// then the larger priority value will win.
7291    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7292        BufferCollectionTokenGroupProxyInterface::r#set_name(self, priority, name)
7293    }
7294
7295    /// Set information about the current client that can be used by sysmem to
7296    /// help debug leaking memory and hangs waiting for constraints. |name| can
7297    /// be an arbitrary string, but the current process name (see
7298    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7299    /// arbitrary id, but the current process ID (see
7300    /// fsl::GetCurrentProcessKoid()) is a good default.
7301    ///
7302    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7303    /// indicate which client is closing their channel first, leading to
7304    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7305    /// over, but if happening earlier than expected, the
7306    /// client-channel-specific name can help diagnose where the failure is
7307    /// first coming from, from sysmem's point of view).
7308    ///
7309    /// By default (unless overriden by this message or using
7310    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7311    /// parent Node at the time the child Node is created.  While this can be
7312    /// better than nothing, it's often better for each participant to use
7313    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7314    /// info directly relevant to the current client.  Also, SetVerboseLogging()
7315    /// can be used to help disambiguate if a Node is suspected of having info
7316    /// that was copied from its parent.
7317    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7318        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, name, id)
7319    }
7320
7321    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7322    /// after creating a collection. Clients can call this method to change
7323    /// when the log is printed. If multiple client set the deadline, it's
7324    /// unspecified which deadline will take effect.
7325    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7326        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
7327    }
7328
7329    /// Verbose logging includes constraints set via SetConstraints() from each
7330    /// client along with info set via SetDebugClientInfo() and the structure of
7331    /// the tree of Node(s).
7332    ///
7333    /// Normally sysmem prints only a single line complaint when aggregation
7334    /// fails, with just the specific detailed reason that aggregation failed,
7335    /// with minimal context.  While this is often enough to diagnose a problem
7336    /// if only a small change was made and the system had been working before
7337    /// the small change, it's often not particularly helpful for getting a new
7338    /// buffer collection to work for the first time.  Especially with more
7339    /// complex trees of nodes, involving things like AttachToken(),
7340    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7341    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7342    /// looks like and why it's failing a logical allocation, or why a tree or
7343    /// sub-tree is failing sooner than expected.
7344    ///
7345    /// The intent of the extra logging is to be acceptable from a performance
7346    /// point of view, if only enabled on a low number of buffer collections.
7347    /// If we're not tracking down a bug, we shouldn't send this message.
7348    ///
7349    /// If too many participants leave verbose logging enabled, we may end up
7350    /// needing to require that system-wide sysmem verbose logging be permitted
7351    /// via some other setting, to avoid sysmem spamming the log too much due to
7352    /// this message.
7353    ///
7354    /// This may be a NOP for some nodes due to intentional policy associated
7355    /// with the node, if we don't trust a node enough to let it turn on verbose
7356    /// logging.
7357    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7358        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7359    }
7360
7361    /// This gets an event handle that can be used as a parameter to
7362    /// IsAlternateFor() called on any Node.  The client will not be granted the
7363    /// right to signal this event, as this handle should only be used as proof
7364    /// that the client obtained this handle from this Node.
7365    ///
7366    /// Because this is a get not a set, no Sync() is needed between the
7367    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7368    /// potentially being on different channels.
7369    ///
7370    /// See also IsAlternateFor().
7371    pub fn r#get_node_ref(
7372        &self,
7373    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
7374    {
7375        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7376    }
7377
7378    /// This checks whether the calling node is in a subtree rooted at a
7379    /// different child token of a common parent BufferCollectionTokenGroup, in
7380    /// relation to the passed-in node_ref.
7381    ///
7382    /// This call is for assisting with admission control de-duplication, and
7383    /// with debugging.
7384    ///
7385    /// The node_ref must be obtained using GetNodeRef() of a
7386    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7387    ///
7388    /// The node_ref can be a duplicated handle; it's not necessary to call
7389    /// GetNodeRef() for every call to IsAlternateFor().
7390    ///
7391    /// If a calling token may not actually be a valid token at all due to
7392    /// a potentially hostile/untrusted provider of the token, call
7393    /// ValidateBufferCollectionToken() first instead of potentially getting
7394    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7395    /// token not being a real token (not really talking to sysmem).  Another
7396    /// option is to call BindSharedCollection with this token first which also
7397    /// validates the token along with converting it to a BufferCollection, then
7398    /// call BufferCollection IsAlternateFor().
7399    ///
7400    /// error values:
7401    ///
7402    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7403    /// buffer collection as the calling Node.  Before logical allocation and
7404    /// within the same logical allocation sub-tree, this essentially means that
7405    /// the node_ref was never part of this logical buffer collection, since
7406    /// before logical allocation all node_refs that come into existence remain
7407    /// in existence at least until logical allocation (including Node(s) that
7408    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7409    /// to be returned, this Node's channel needs to still be connected server
7410    /// side, which won't be the case if the whole logical allocation has
7411    /// failed.  After logical allocation or in a different logical allocation
7412    /// sub-tree there are additional potential reasons for this error.  For
7413    /// example a different logical allocation (separated from this Node(s)
7414    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7415    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7416    /// exist and may select a different child sub-tree than the sub-tree the
7417    /// node_ref is in causing deletion of the node_ref Node.  The only time
7418    /// sysmem keeps a Node around after that Node has no corresponding channel
7419    /// is when Close() is used and the Node's sub-tree has not yet failed.
7420    /// Another reason for this error is if the node_ref is an eventpair handle
7421    /// with sufficient rights, but isn't actually a real node_ref obtained from
7422    /// GetNodeRef().
7423    ///
7424    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7425    /// eventpair handle, or doesn't have the needed rights expected on a real
7426    /// node_ref.
7427    ///
7428    /// No other failing status codes are returned by this call.  However,
7429    /// sysmem may add additional codes in future, so the client should have
7430    /// sensible default handling for any failing status code.
7431    ///
7432    /// On success, is_alternate has the following meaning:
7433    ///   * true - The first parent node in common between the calling node and
7434    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7435    ///     the calling Node and the node_ref Node will _not_ have both their
7436    ///     constraints apply - rather sysmem will choose one or the other of
7437    ///     the constraints - never both.  This is because only one child of
7438    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7439    ///     with only that one child's sub-tree contributing to constraints
7440    ///     aggregation.
7441    ///   * false - The first parent node in common between the calling Node and
7442    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7443    ///     this means the first parent node in common is a
7444    ///     BufferCollectionToken or BufferCollection (regardless of not
7445    ///     Close()ed or Close()ed).  This means that the calling Node and the
7446    ///     node_ref Node _may_ have both their constraints apply during
7447    ///     constraints aggregation of the logical allocation, if both Node(s)
7448    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7449    ///     In this case, there is no BufferCollectionTokenGroup that will
7450    ///     directly prevent the two Node(s) from both being selected and their
7451    ///     constraints both aggregated, but even when false, one or both
7452    ///     Node(s) may still be eliminated from consideration if one or both
7453    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7454    ///     which selects a child sub-tree other than the sub-tree containing
7455    ///     the calling Node or node_ref Node.
7456    pub fn r#is_alternate_for(
7457        &self,
7458        mut node_ref: fidl::Event,
7459    ) -> fidl::client::QueryResponseFut<
7460        NodeIsAlternateForResult,
7461        fidl::encoding::DefaultFuchsiaResourceDialect,
7462    > {
7463        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, node_ref)
7464    }
7465
7466    /// Create a child token.  Before passing the client end of this token to
7467    /// BindSharedCollection(), completion of Sync() after CreateChild() is
7468    /// required.  Or the client can use CreateChildrenSync() which essentially
7469    /// includes the Sync().
7470    ///
7471    /// token_request - the server end of the new token channel.
7472    ///
7473    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
7474    /// allows the holder to get the same rights to buffers as the parent token
7475    /// (of the group) had.
7476    pub fn r#create_child(
7477        &self,
7478        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7479    ) -> Result<(), fidl::Error> {
7480        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7481    }
7482
7483    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7484    /// CreateChild(), no Sync() completion is required before passing the
7485    /// client end of a returned token to BindSharedCollection().
7486    ///
7487    /// The size of the rights_attentuation_mask determines the number of
7488    /// created child tokens.
7489    ///
7490    /// The lower-index child tokens are higher priority (attempted sooner) than
7491    /// higher-index child tokens.
7492    ///
7493    /// As per all child tokens, successful aggregation will choose exactly one
7494    /// child among all created children (across all children created across
7495    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
7496    ///
7497    /// The maximum permissible total number of children per group, and total
7498    /// number of nodes in an overall tree (from the root) are capped to limits
7499    /// which are not configurable via these protocols.
7500    pub fn r#create_children_sync(
7501        &self,
7502        mut rights_attenuation_masks: &[fidl::Rights],
7503    ) -> fidl::client::QueryResponseFut<
7504        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7505        fidl::encoding::DefaultFuchsiaResourceDialect,
7506    > {
7507        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(
7508            self,
7509            rights_attenuation_masks,
7510        )
7511    }
7512
7513    /// AllChildrenPresent()
7514    ///
7515    /// After creating all children, the client must call AllChildrenPresent()
7516    /// to inform sysmem that no more children will be created, so that sysmem
7517    /// can know when it's ok to start aggregating constraints.
7518    ///
7519    /// If Close() is to be sent, it should be sent _after_
7520    /// AllChildrenPresent(), else failure of the group and propagation of the
7521    /// failure to the group's parent will still be triggered.
7522    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7523        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7524    }
7525}
7526
7527impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7528    type SyncResponseFut =
7529        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7530    fn r#sync(&self) -> Self::SyncResponseFut {
7531        fn _decode(
7532            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7533        ) -> Result<(), fidl::Error> {
7534            let _response = fidl::client::decode_transaction_body::<
7535                fidl::encoding::EmptyPayload,
7536                fidl::encoding::DefaultFuchsiaResourceDialect,
7537                0x4577e238ae26291,
7538            >(_buf?)?;
7539            Ok(_response)
7540        }
7541        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7542            (),
7543            0x4577e238ae26291,
7544            fidl::encoding::DynamicFlags::empty(),
7545            _decode,
7546        )
7547    }
7548
7549    fn r#close(&self) -> Result<(), fidl::Error> {
7550        self.client.send::<fidl::encoding::EmptyPayload>(
7551            (),
7552            0x5b1d7a4f5681fca7,
7553            fidl::encoding::DynamicFlags::empty(),
7554        )
7555    }
7556
7557    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7558        self.client.send::<NodeSetNameRequest>(
7559            (priority, name),
7560            0x77a41bb6217e2443,
7561            fidl::encoding::DynamicFlags::empty(),
7562        )
7563    }
7564
7565    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7566        self.client.send::<NodeSetDebugClientInfoRequest>(
7567            (name, id),
7568            0x7275759070eb5ee2,
7569            fidl::encoding::DynamicFlags::empty(),
7570        )
7571    }
7572
7573    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7574        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7575            (deadline,),
7576            0x46d38f4772638867,
7577            fidl::encoding::DynamicFlags::empty(),
7578        )
7579    }
7580
7581    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7582        self.client.send::<fidl::encoding::EmptyPayload>(
7583            (),
7584            0x6bfbe2cf1701d288,
7585            fidl::encoding::DynamicFlags::empty(),
7586        )
7587    }
7588
7589    type GetNodeRefResponseFut =
7590        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
7591    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7592        fn _decode(
7593            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7594        ) -> Result<fidl::Event, fidl::Error> {
7595            let _response = fidl::client::decode_transaction_body::<
7596                NodeGetNodeRefResponse,
7597                fidl::encoding::DefaultFuchsiaResourceDialect,
7598                0x467b7c75c35c3b84,
7599            >(_buf?)?;
7600            Ok(_response.node_ref)
7601        }
7602        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
7603            (),
7604            0x467b7c75c35c3b84,
7605            fidl::encoding::DynamicFlags::empty(),
7606            _decode,
7607        )
7608    }
7609
7610    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7611        NodeIsAlternateForResult,
7612        fidl::encoding::DefaultFuchsiaResourceDialect,
7613    >;
7614    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
7615        fn _decode(
7616            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7617        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7618            let _response = fidl::client::decode_transaction_body::<
7619                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7620                fidl::encoding::DefaultFuchsiaResourceDialect,
7621                0x33a2a7aff2776c07,
7622            >(_buf?)?;
7623            Ok(_response.map(|x| x.is_alternate))
7624        }
7625        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7626            (node_ref,),
7627            0x33a2a7aff2776c07,
7628            fidl::encoding::DynamicFlags::empty(),
7629            _decode,
7630        )
7631    }
7632
7633    fn r#create_child(
7634        &self,
7635        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7636    ) -> Result<(), fidl::Error> {
7637        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7638            &mut payload,
7639            0x2e74f8bcbf59ee59,
7640            fidl::encoding::DynamicFlags::empty(),
7641        )
7642    }
7643
7644    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
7645        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7646        fidl::encoding::DefaultFuchsiaResourceDialect,
7647    >;
7648    fn r#create_children_sync(
7649        &self,
7650        mut rights_attenuation_masks: &[fidl::Rights],
7651    ) -> Self::CreateChildrenSyncResponseFut {
7652        fn _decode(
7653            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7654        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
7655        {
7656            let _response = fidl::client::decode_transaction_body::<
7657                BufferCollectionTokenGroupCreateChildrenSyncResponse,
7658                fidl::encoding::DefaultFuchsiaResourceDialect,
7659                0x569dc3ca2a98f535,
7660            >(_buf?)?;
7661            Ok(_response.tokens)
7662        }
7663        self.client.send_query_and_decode::<
7664            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7665            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7666        >(
7667            (rights_attenuation_masks,),
7668            0x569dc3ca2a98f535,
7669            fidl::encoding::DynamicFlags::empty(),
7670            _decode,
7671        )
7672    }
7673
7674    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7675        self.client.send::<fidl::encoding::EmptyPayload>(
7676            (),
7677            0x1d41715f6f044b50,
7678            fidl::encoding::DynamicFlags::empty(),
7679        )
7680    }
7681}
7682
7683pub struct BufferCollectionTokenGroupEventStream {
7684    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7685}
7686
7687impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
7688
7689impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
7690    fn is_terminated(&self) -> bool {
7691        self.event_receiver.is_terminated()
7692    }
7693}
7694
7695impl futures::Stream for BufferCollectionTokenGroupEventStream {
7696    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
7697
7698    fn poll_next(
7699        mut self: std::pin::Pin<&mut Self>,
7700        cx: &mut std::task::Context<'_>,
7701    ) -> std::task::Poll<Option<Self::Item>> {
7702        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7703            &mut self.event_receiver,
7704            cx
7705        )?) {
7706            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
7707            None => std::task::Poll::Ready(None),
7708        }
7709    }
7710}
7711
7712#[derive(Debug)]
7713pub enum BufferCollectionTokenGroupEvent {}
7714
7715impl BufferCollectionTokenGroupEvent {
7716    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
7717    fn decode(
7718        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7719    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
7720        let (bytes, _handles) = buf.split_mut();
7721        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7722        debug_assert_eq!(tx_header.tx_id, 0);
7723        match tx_header.ordinal {
7724            _ => Err(fidl::Error::UnknownOrdinal {
7725                ordinal: tx_header.ordinal,
7726                protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7727            })
7728        }
7729    }
7730}
7731
7732/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionTokenGroup.
7733pub struct BufferCollectionTokenGroupRequestStream {
7734    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7735    is_terminated: bool,
7736}
7737
7738impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
7739
7740impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
7741    fn is_terminated(&self) -> bool {
7742        self.is_terminated
7743    }
7744}
7745
7746impl fidl::endpoints::RequestStream for BufferCollectionTokenGroupRequestStream {
7747    type Protocol = BufferCollectionTokenGroupMarker;
7748    type ControlHandle = BufferCollectionTokenGroupControlHandle;
7749
7750    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7751        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7752    }
7753
7754    fn control_handle(&self) -> Self::ControlHandle {
7755        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
7756    }
7757
7758    fn into_inner(
7759        self,
7760    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7761    {
7762        (self.inner, self.is_terminated)
7763    }
7764
7765    fn from_inner(
7766        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7767        is_terminated: bool,
7768    ) -> Self {
7769        Self { inner, is_terminated }
7770    }
7771}
7772
7773impl futures::Stream for BufferCollectionTokenGroupRequestStream {
7774    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
7775
7776    fn poll_next(
7777        mut self: std::pin::Pin<&mut Self>,
7778        cx: &mut std::task::Context<'_>,
7779    ) -> std::task::Poll<Option<Self::Item>> {
7780        let this = &mut *self;
7781        if this.inner.check_shutdown(cx) {
7782            this.is_terminated = true;
7783            return std::task::Poll::Ready(None);
7784        }
7785        if this.is_terminated {
7786            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
7787        }
7788        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7789            |bytes, handles| {
7790                match this.inner.channel().read_etc(cx, bytes, handles) {
7791                    std::task::Poll::Ready(Ok(())) => {}
7792                    std::task::Poll::Pending => return std::task::Poll::Pending,
7793                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7794                        this.is_terminated = true;
7795                        return std::task::Poll::Ready(None);
7796                    }
7797                    std::task::Poll::Ready(Err(e)) => {
7798                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7799                            e.into(),
7800                        ))))
7801                    }
7802                }
7803
7804                // A message has been received from the channel
7805                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7806
7807                std::task::Poll::Ready(Some(match header.ordinal {
7808                0x4577e238ae26291 => {
7809                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7810                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7811                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7812                    let control_handle = BufferCollectionTokenGroupControlHandle {
7813                        inner: this.inner.clone(),
7814                    };
7815                    Ok(BufferCollectionTokenGroupRequest::Sync {
7816                        responder: BufferCollectionTokenGroupSyncResponder {
7817                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7818                            tx_id: header.tx_id,
7819                        },
7820                    })
7821                }
7822                0x5b1d7a4f5681fca7 => {
7823                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7824                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7825                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7826                    let control_handle = BufferCollectionTokenGroupControlHandle {
7827                        inner: this.inner.clone(),
7828                    };
7829                    Ok(BufferCollectionTokenGroupRequest::Close {
7830                        control_handle,
7831                    })
7832                }
7833                0x77a41bb6217e2443 => {
7834                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7835                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7836                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
7837                    let control_handle = BufferCollectionTokenGroupControlHandle {
7838                        inner: this.inner.clone(),
7839                    };
7840                    Ok(BufferCollectionTokenGroupRequest::SetName {priority: req.priority,
7841name: req.name,
7842
7843                        control_handle,
7844                    })
7845                }
7846                0x7275759070eb5ee2 => {
7847                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7848                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7849                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
7850                    let control_handle = BufferCollectionTokenGroupControlHandle {
7851                        inner: this.inner.clone(),
7852                    };
7853                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {name: req.name,
7854id: req.id,
7855
7856                        control_handle,
7857                    })
7858                }
7859                0x46d38f4772638867 => {
7860                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7861                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7862                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
7863                    let control_handle = BufferCollectionTokenGroupControlHandle {
7864                        inner: this.inner.clone(),
7865                    };
7866                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
7867
7868                        control_handle,
7869                    })
7870                }
7871                0x6bfbe2cf1701d288 => {
7872                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7873                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7874                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7875                    let control_handle = BufferCollectionTokenGroupControlHandle {
7876                        inner: this.inner.clone(),
7877                    };
7878                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
7879                        control_handle,
7880                    })
7881                }
7882                0x467b7c75c35c3b84 => {
7883                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7884                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7885                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7886                    let control_handle = BufferCollectionTokenGroupControlHandle {
7887                        inner: this.inner.clone(),
7888                    };
7889                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
7890                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
7891                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7892                            tx_id: header.tx_id,
7893                        },
7894                    })
7895                }
7896                0x33a2a7aff2776c07 => {
7897                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7898                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7899                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
7900                    let control_handle = BufferCollectionTokenGroupControlHandle {
7901                        inner: this.inner.clone(),
7902                    };
7903                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {node_ref: req.node_ref,
7904
7905                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
7906                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7907                            tx_id: header.tx_id,
7908                        },
7909                    })
7910                }
7911                0x2e74f8bcbf59ee59 => {
7912                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7913                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7914                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
7915                    let control_handle = BufferCollectionTokenGroupControlHandle {
7916                        inner: this.inner.clone(),
7917                    };
7918                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
7919                        control_handle,
7920                    })
7921                }
7922                0x569dc3ca2a98f535 => {
7923                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7924                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7925                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
7926                    let control_handle = BufferCollectionTokenGroupControlHandle {
7927                        inner: this.inner.clone(),
7928                    };
7929                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {rights_attenuation_masks: req.rights_attenuation_masks,
7930
7931                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
7932                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7933                            tx_id: header.tx_id,
7934                        },
7935                    })
7936                }
7937                0x1d41715f6f044b50 => {
7938                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7939                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7940                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7941                    let control_handle = BufferCollectionTokenGroupControlHandle {
7942                        inner: this.inner.clone(),
7943                    };
7944                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
7945                        control_handle,
7946                    })
7947                }
7948                _ => Err(fidl::Error::UnknownOrdinal {
7949                    ordinal: header.ordinal,
7950                    protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7951                }),
7952            }))
7953            },
7954        )
7955    }
7956}
7957
7958/// The sysmem implementation is guaranteed to be consistent with a logical /
7959/// conceptual model as follows:
7960///
7961/// As usual, a logical allocation considers either the root and all nodes with
7962/// connectivity to the root that don't transit an AttachToken(), or a sub-tree
7963/// rooted at an AttachToken() token and all nodes with connectivity to that
7964/// subtree that don't transit another AttachToken().  This is called the
7965/// logical allocation pruned sub-tree, or pruned sub-tree for short.
7966///
7967/// During constraints aggregation, each BufferCollectionTokenGroup will select
7968/// a single child token among its children.  The rest of the children will
7969/// appear to fail the logical allocation, while the selected child may succeed.
7970///
7971/// When more than one BufferCollectionTokenGroup exists in the overall logical
7972/// allocation pruned sub-tree, the relative priority between two groups is
7973/// equivalent to their ordering in a DFS pre-order iteration of the tree, with
7974/// parents higher priority than children, and left children higher priority
7975/// than right children.
7976///
7977/// When a particular child of a group is selected (whether provisionally during
7978/// a constraints aggregation attempt, or as a final selection), the
7979/// non-selection of other children of the group can potentially "hide" other
7980/// groups under those non-selected children.
7981///
7982/// Within a logical allocation, aggregation is attempted first by provisionally
7983/// selecting the child 0 of the highest-priority group, and child 0 of the next
7984/// highest-priority group that isn't hidden by the provisional selections so
7985/// far, etc.
7986///
7987/// If that aggregation attempt fails, aggregation will be attempted with the
7988/// ordinal 0 child of all the same groups except the lowest priority non-hidden
7989/// group which will provisionally select its ordinal 1 child (and then child 2
7990/// and so on).  If a new lowest-priority group is un-hidden as provisional
7991/// selections are updated, that newly un-hidden lowest-priority group has all
7992/// its children considered in order, before changing the provisional selection
7993/// in the former lowest-priority group.  In terms of result, this is equivalent
7994/// to systematic enumeration of all possible combinations of choices in a
7995/// counting-like order updating the lowest-priority group the most often and
7996/// the highest-priority group the least often.  Rather than actually attempting
7997/// aggregation with all the combinations, we can skip over combinations which
7998/// are redundant/equivalent due to hiding without any change to the result.
7999///
8000/// Attempted aggregations of enumerated non-equivalent combinations of choices
8001/// continue in this manner until either (a) all aggregation attempts fail in
8002/// which case the overall logical allocation fails, or (b) until an attempted
8003/// aggregation succeeds, in which case buffer allocation (if needed) is
8004/// attempted once.  If buffer allocation based on the first successful
8005/// aggregation fails, the overall logical allocation fails (there is no buffer
8006/// allocation retry / re-attempt).  If buffer allocation succeeds (or is not
8007/// needed), the logical allocation succeeds.
8008///
8009/// If this prioritization scheme cannot reasonably work for your usage of
8010/// sysmem, please contact sysmem folks to discuss potentially adding a way to
8011/// achieve what you need.
8012///
8013/// Please avoid creating a large number of BufferCollectionTokenGroup(s) per
8014/// logical allocation, especially with large number of children overall, and
8015/// especially in cases where aggregation may reasonably be expected to often
8016/// fail using ordinal 0 children and possibly with later children as well.  We
8017/// anticipate mitigating potentially high time complexity of evaluating too
8018/// many child combinations/selections across too many groups by simply failing
8019/// logical allocation beyond a certain (fairly high, but not huge) max number
8020/// of considered group child combinations/selections.  More advanced (and more
8021/// complicated) mitigation is not anticipated to be practically necessary or
8022/// worth the added complexity.  Please contact sysmem folks if the max limit
8023/// is getting hit or if you anticipate it getting hit, to discuss potential
8024/// options.
8025///
8026/// Prefer to use multiple ImageFormatConstraints in a single
8027/// BufferCollectionConstraints when feasible (when a participant just needs to
8028/// express the ability to work with more than a single PixelFormat, with
8029/// sysmem choosing which PixelFormat to use among those supported by all
8030/// participants).
8031///
8032/// Similar to BufferCollectionToken and BufferCollection, closure of the
8033/// BufferCollectionTokenGroup channel without sending Close() first will cause
8034/// logical buffer collection failure (or sub-tree failure if using
8035/// SetDispensable() or AttachToken() and the BufferCollectionTokenGroup is part
8036/// of a sub-tree under such a node that doesn't propagate failure to its
8037/// parent).
8038#[derive(Debug)]
8039pub enum BufferCollectionTokenGroupRequest {
8040    /// Ensure that previous messages, including Duplicate() messages on a
8041    /// token, collection, or group, have been received server side.
8042    ///
8043    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
8044    /// valid sysmem token risks the Sync() hanging forever.  See
8045    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
8046    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
8047    /// Another way is to pass the token to BindSharedCollection(), which also
8048    /// validates the token as part of exchanging it for a BufferCollection
8049    /// channel, and BufferCollection Sync() can then be used.
8050    ///
8051    /// After a Sync(), it's then safe to send the client end of token_request
8052    /// to another participant knowing the server will recognize the token when
8053    /// it's sent into BindSharedCollection() by the other participant.
8054    ///
8055    /// Other options include waiting for each token.Duplicate() to complete
8056    /// individually (using separate call to token.Sync() after each), or
8057    /// calling Sync() on BufferCollection after the token has been turned in
8058    /// via BindSharedCollection().
8059    ///
8060    /// Another way to mitigate is to avoid calling Sync() on the token, and
8061    /// instead later deal with potential failure of BufferCollection.Sync() if
8062    /// the original token was invalid.  This option can be preferable from a
8063    /// performance point of view, but requires client code to delay sending
8064    /// tokens duplicated from this token until after client code has converted
8065    /// the duplicating token to a BufferCollection and received successful
8066    /// response from BufferCollection.Sync().
8067    ///
8068    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
8069    /// When BufferCollection.Sync() isn't feasible, the caller must already
8070    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
8071    /// hang forever.  See ValidateBufferCollectionToken() to check token
8072    /// validity first if the token isn't already known to be (is/was) valid.
8073    Sync { responder: BufferCollectionTokenGroupSyncResponder },
8074    /// On a BufferCollectionToken channel:
8075    ///
8076    /// Normally a participant will convert a BufferCollectionToken into a
8077    /// BufferCollection view, but a participant is also free to Close() the
8078    /// token (and then close the channel immediately or shortly later in
8079    /// response to server closing its end), which avoids causing logical buffer
8080    /// collection failure.  Normally an unexpected token channel close will
8081    /// cause logical buffer collection failure (the only exceptions being
8082    /// certain cases involving AttachToken() or SetDispensable()).
8083    ///
8084    /// On a BufferCollection channel:
8085    ///
8086    /// By default the server handles unexpected failure of a BufferCollection
8087    /// by failing the whole logical buffer collection.  Partly this is to
8088    /// expedite closing VMO handles to reclaim memory when any participant
8089    /// fails.  If a participant would like to cleanly close a BufferCollection
8090    /// view without causing logical buffer collection failure, the participant
8091    /// can send Close() before closing the client end of the BufferCollection
8092    /// channel.  If this is the last BufferCollection view, the logical buffer
8093    /// collection will still go away.  The Close() can occur before or after
8094    /// SetConstraints().  If before SetConstraints(), the buffer collection
8095    /// won't require constraints from this node in order to allocate.  If
8096    /// after SetConstraints(), the constraints are retained and aggregated
8097    /// along with any subsequent logical allocation(s), despite the lack of
8098    /// channel connection.
8099    ///
8100    /// On a BufferCollectionTokenGroup channel:
8101    ///
8102    /// By default, unexpected failure of a BufferCollectionTokenGroup will
8103    /// trigger failure of the logical BufferCollectionTokenGroup and will
8104    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
8105    /// channel without failing the logical group or propagating failure, send
8106    /// Close() before closing the channel client endpoint.
8107    ///
8108    /// If Close() occurs before AllChildrenPresent(), the logical buffer
8109    /// collection will still fail despite the Close() (because sysmem can't be
8110    /// sure whether all relevant children were created, so it's ambiguous
8111    /// whether all relevant constraints will be provided to sysmem).  If
8112    /// Close() occurs after AllChildrenPresent(), the children and all their
8113    /// constraints remain intact (just as they would if the
8114    /// BufferCollectionTokenGroup channel had remained open), and the close
8115    /// doesn't trigger or propagate failure.
8116    Close { control_handle: BufferCollectionTokenGroupControlHandle },
8117    /// Set a name for VMOs in this buffer collection. The name may be truncated
8118    /// shorter. The name only affects VMOs allocated after it's set - this call
8119    /// does not rename existing VMOs. If multiple clients set different names
8120    /// then the larger priority value will win.
8121    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenGroupControlHandle },
8122    /// Set information about the current client that can be used by sysmem to
8123    /// help debug leaking memory and hangs waiting for constraints. |name| can
8124    /// be an arbitrary string, but the current process name (see
8125    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
8126    /// arbitrary id, but the current process ID (see
8127    /// fsl::GetCurrentProcessKoid()) is a good default.
8128    ///
8129    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
8130    /// indicate which client is closing their channel first, leading to
8131    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
8132    /// over, but if happening earlier than expected, the
8133    /// client-channel-specific name can help diagnose where the failure is
8134    /// first coming from, from sysmem's point of view).
8135    ///
8136    /// By default (unless overriden by this message or using
8137    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
8138    /// parent Node at the time the child Node is created.  While this can be
8139    /// better than nothing, it's often better for each participant to use
8140    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
8141    /// info directly relevant to the current client.  Also, SetVerboseLogging()
8142    /// can be used to help disambiguate if a Node is suspected of having info
8143    /// that was copied from its parent.
8144    SetDebugClientInfo {
8145        name: String,
8146        id: u64,
8147        control_handle: BufferCollectionTokenGroupControlHandle,
8148    },
8149    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
8150    /// after creating a collection. Clients can call this method to change
8151    /// when the log is printed. If multiple client set the deadline, it's
8152    /// unspecified which deadline will take effect.
8153    SetDebugTimeoutLogDeadline {
8154        deadline: i64,
8155        control_handle: BufferCollectionTokenGroupControlHandle,
8156    },
8157    /// Verbose logging includes constraints set via SetConstraints() from each
8158    /// client along with info set via SetDebugClientInfo() and the structure of
8159    /// the tree of Node(s).
8160    ///
8161    /// Normally sysmem prints only a single line complaint when aggregation
8162    /// fails, with just the specific detailed reason that aggregation failed,
8163    /// with minimal context.  While this is often enough to diagnose a problem
8164    /// if only a small change was made and the system had been working before
8165    /// the small change, it's often not particularly helpful for getting a new
8166    /// buffer collection to work for the first time.  Especially with more
8167    /// complex trees of nodes, involving things like AttachToken(),
8168    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
8169    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
8170    /// looks like and why it's failing a logical allocation, or why a tree or
8171    /// sub-tree is failing sooner than expected.
8172    ///
8173    /// The intent of the extra logging is to be acceptable from a performance
8174    /// point of view, if only enabled on a low number of buffer collections.
8175    /// If we're not tracking down a bug, we shouldn't send this message.
8176    ///
8177    /// If too many participants leave verbose logging enabled, we may end up
8178    /// needing to require that system-wide sysmem verbose logging be permitted
8179    /// via some other setting, to avoid sysmem spamming the log too much due to
8180    /// this message.
8181    ///
8182    /// This may be a NOP for some nodes due to intentional policy associated
8183    /// with the node, if we don't trust a node enough to let it turn on verbose
8184    /// logging.
8185    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
8186    /// This gets an event handle that can be used as a parameter to
8187    /// IsAlternateFor() called on any Node.  The client will not be granted the
8188    /// right to signal this event, as this handle should only be used as proof
8189    /// that the client obtained this handle from this Node.
8190    ///
8191    /// Because this is a get not a set, no Sync() is needed between the
8192    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
8193    /// potentially being on different channels.
8194    ///
8195    /// See also IsAlternateFor().
8196    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8197    /// This checks whether the calling node is in a subtree rooted at a
8198    /// different child token of a common parent BufferCollectionTokenGroup, in
8199    /// relation to the passed-in node_ref.
8200    ///
8201    /// This call is for assisting with admission control de-duplication, and
8202    /// with debugging.
8203    ///
8204    /// The node_ref must be obtained using GetNodeRef() of a
8205    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
8206    ///
8207    /// The node_ref can be a duplicated handle; it's not necessary to call
8208    /// GetNodeRef() for every call to IsAlternateFor().
8209    ///
8210    /// If a calling token may not actually be a valid token at all due to
8211    /// a potentially hostile/untrusted provider of the token, call
8212    /// ValidateBufferCollectionToken() first instead of potentially getting
8213    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
8214    /// token not being a real token (not really talking to sysmem).  Another
8215    /// option is to call BindSharedCollection with this token first which also
8216    /// validates the token along with converting it to a BufferCollection, then
8217    /// call BufferCollection IsAlternateFor().
8218    ///
8219    /// error values:
8220    ///
8221    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
8222    /// buffer collection as the calling Node.  Before logical allocation and
8223    /// within the same logical allocation sub-tree, this essentially means that
8224    /// the node_ref was never part of this logical buffer collection, since
8225    /// before logical allocation all node_refs that come into existence remain
8226    /// in existence at least until logical allocation (including Node(s) that
8227    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
8228    /// to be returned, this Node's channel needs to still be connected server
8229    /// side, which won't be the case if the whole logical allocation has
8230    /// failed.  After logical allocation or in a different logical allocation
8231    /// sub-tree there are additional potential reasons for this error.  For
8232    /// example a different logical allocation (separated from this Node(s)
8233    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
8234    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
8235    /// exist and may select a different child sub-tree than the sub-tree the
8236    /// node_ref is in causing deletion of the node_ref Node.  The only time
8237    /// sysmem keeps a Node around after that Node has no corresponding channel
8238    /// is when Close() is used and the Node's sub-tree has not yet failed.
8239    /// Another reason for this error is if the node_ref is an eventpair handle
8240    /// with sufficient rights, but isn't actually a real node_ref obtained from
8241    /// GetNodeRef().
8242    ///
8243    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
8244    /// eventpair handle, or doesn't have the needed rights expected on a real
8245    /// node_ref.
8246    ///
8247    /// No other failing status codes are returned by this call.  However,
8248    /// sysmem may add additional codes in future, so the client should have
8249    /// sensible default handling for any failing status code.
8250    ///
8251    /// On success, is_alternate has the following meaning:
8252    ///   * true - The first parent node in common between the calling node and
8253    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
8254    ///     the calling Node and the node_ref Node will _not_ have both their
8255    ///     constraints apply - rather sysmem will choose one or the other of
8256    ///     the constraints - never both.  This is because only one child of
8257    ///     a BufferCollectionTokenGroup is selected during logical allocation,
8258    ///     with only that one child's sub-tree contributing to constraints
8259    ///     aggregation.
8260    ///   * false - The first parent node in common between the calling Node and
8261    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
8262    ///     this means the first parent node in common is a
8263    ///     BufferCollectionToken or BufferCollection (regardless of not
8264    ///     Close()ed or Close()ed).  This means that the calling Node and the
8265    ///     node_ref Node _may_ have both their constraints apply during
8266    ///     constraints aggregation of the logical allocation, if both Node(s)
8267    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
8268    ///     In this case, there is no BufferCollectionTokenGroup that will
8269    ///     directly prevent the two Node(s) from both being selected and their
8270    ///     constraints both aggregated, but even when false, one or both
8271    ///     Node(s) may still be eliminated from consideration if one or both
8272    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
8273    ///     which selects a child sub-tree other than the sub-tree containing
8274    ///     the calling Node or node_ref Node.
8275    IsAlternateFor {
8276        node_ref: fidl::Event,
8277        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8278    },
8279    /// Create a child token.  Before passing the client end of this token to
8280    /// BindSharedCollection(), completion of Sync() after CreateChild() is
8281    /// required.  Or the client can use CreateChildrenSync() which essentially
8282    /// includes the Sync().
8283    ///
8284    /// token_request - the server end of the new token channel.
8285    ///
8286    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
8287    /// allows the holder to get the same rights to buffers as the parent token
8288    /// (of the group) had.
8289    CreateChild {
8290        payload: BufferCollectionTokenGroupCreateChildRequest,
8291        control_handle: BufferCollectionTokenGroupControlHandle,
8292    },
8293    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8294    /// CreateChild(), no Sync() completion is required before passing the
8295    /// client end of a returned token to BindSharedCollection().
8296    ///
8297    /// The size of the rights_attentuation_mask determines the number of
8298    /// created child tokens.
8299    ///
8300    /// The lower-index child tokens are higher priority (attempted sooner) than
8301    /// higher-index child tokens.
8302    ///
8303    /// As per all child tokens, successful aggregation will choose exactly one
8304    /// child among all created children (across all children created across
8305    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
8306    ///
8307    /// The maximum permissible total number of children per group, and total
8308    /// number of nodes in an overall tree (from the root) are capped to limits
8309    /// which are not configurable via these protocols.
8310    CreateChildrenSync {
8311        rights_attenuation_masks: Vec<fidl::Rights>,
8312        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
8313    },
8314    /// AllChildrenPresent()
8315    ///
8316    /// After creating all children, the client must call AllChildrenPresent()
8317    /// to inform sysmem that no more children will be created, so that sysmem
8318    /// can know when it's ok to start aggregating constraints.
8319    ///
8320    /// If Close() is to be sent, it should be sent _after_
8321    /// AllChildrenPresent(), else failure of the group and propagation of the
8322    /// failure to the group's parent will still be triggered.
8323    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
8324}
8325
8326impl BufferCollectionTokenGroupRequest {
8327    #[allow(irrefutable_let_patterns)]
8328    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
8329        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
8330            Some((responder))
8331        } else {
8332            None
8333        }
8334    }
8335
8336    #[allow(irrefutable_let_patterns)]
8337    pub fn into_close(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8338        if let BufferCollectionTokenGroupRequest::Close { control_handle } = self {
8339            Some((control_handle))
8340        } else {
8341            None
8342        }
8343    }
8344
8345    #[allow(irrefutable_let_patterns)]
8346    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenGroupControlHandle)> {
8347        if let BufferCollectionTokenGroupRequest::SetName { priority, name, control_handle } = self
8348        {
8349            Some((priority, name, control_handle))
8350        } else {
8351            None
8352        }
8353    }
8354
8355    #[allow(irrefutable_let_patterns)]
8356    pub fn into_set_debug_client_info(
8357        self,
8358    ) -> Option<(String, u64, BufferCollectionTokenGroupControlHandle)> {
8359        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { name, id, control_handle } =
8360            self
8361        {
8362            Some((name, id, control_handle))
8363        } else {
8364            None
8365        }
8366    }
8367
8368    #[allow(irrefutable_let_patterns)]
8369    pub fn into_set_debug_timeout_log_deadline(
8370        self,
8371    ) -> Option<(i64, BufferCollectionTokenGroupControlHandle)> {
8372        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
8373            deadline,
8374            control_handle,
8375        } = self
8376        {
8377            Some((deadline, control_handle))
8378        } else {
8379            None
8380        }
8381    }
8382
8383    #[allow(irrefutable_let_patterns)]
8384    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8385        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
8386            Some((control_handle))
8387        } else {
8388            None
8389        }
8390    }
8391
8392    #[allow(irrefutable_let_patterns)]
8393    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
8394        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
8395            Some((responder))
8396        } else {
8397            None
8398        }
8399    }
8400
8401    #[allow(irrefutable_let_patterns)]
8402    pub fn into_is_alternate_for(
8403        self,
8404    ) -> Option<(fidl::Event, BufferCollectionTokenGroupIsAlternateForResponder)> {
8405        if let BufferCollectionTokenGroupRequest::IsAlternateFor { node_ref, responder } = self {
8406            Some((node_ref, responder))
8407        } else {
8408            None
8409        }
8410    }
8411
8412    #[allow(irrefutable_let_patterns)]
8413    pub fn into_create_child(
8414        self,
8415    ) -> Option<(
8416        BufferCollectionTokenGroupCreateChildRequest,
8417        BufferCollectionTokenGroupControlHandle,
8418    )> {
8419        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
8420            Some((payload, control_handle))
8421        } else {
8422            None
8423        }
8424    }
8425
8426    #[allow(irrefutable_let_patterns)]
8427    pub fn into_create_children_sync(
8428        self,
8429    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenGroupCreateChildrenSyncResponder)> {
8430        if let BufferCollectionTokenGroupRequest::CreateChildrenSync {
8431            rights_attenuation_masks,
8432            responder,
8433        } = self
8434        {
8435            Some((rights_attenuation_masks, responder))
8436        } else {
8437            None
8438        }
8439    }
8440
8441    #[allow(irrefutable_let_patterns)]
8442    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8443        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
8444            Some((control_handle))
8445        } else {
8446            None
8447        }
8448    }
8449
8450    /// Name of the method defined in FIDL
8451    pub fn method_name(&self) -> &'static str {
8452        match *self {
8453            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
8454            BufferCollectionTokenGroupRequest::Close { .. } => "close",
8455            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
8456            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
8457            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
8458                "set_debug_timeout_log_deadline"
8459            }
8460            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
8461            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
8462            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
8463            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
8464            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
8465            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
8466        }
8467    }
8468}
8469
8470#[derive(Debug, Clone)]
8471pub struct BufferCollectionTokenGroupControlHandle {
8472    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8473}
8474
8475impl fidl::endpoints::ControlHandle for BufferCollectionTokenGroupControlHandle {
8476    fn shutdown(&self) {
8477        self.inner.shutdown()
8478    }
8479    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8480        self.inner.shutdown_with_epitaph(status)
8481    }
8482
8483    fn is_closed(&self) -> bool {
8484        self.inner.channel().is_closed()
8485    }
8486    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8487        self.inner.channel().on_closed()
8488    }
8489
8490    #[cfg(target_os = "fuchsia")]
8491    fn signal_peer(
8492        &self,
8493        clear_mask: zx::Signals,
8494        set_mask: zx::Signals,
8495    ) -> Result<(), zx_status::Status> {
8496        use fidl::Peered;
8497        self.inner.channel().signal_peer(clear_mask, set_mask)
8498    }
8499}
8500
8501impl BufferCollectionTokenGroupControlHandle {}
8502
8503#[must_use = "FIDL methods require a response to be sent"]
8504#[derive(Debug)]
8505pub struct BufferCollectionTokenGroupSyncResponder {
8506    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8507    tx_id: u32,
8508}
8509
8510/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8511/// if the responder is dropped without sending a response, so that the client
8512/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8513impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
8514    fn drop(&mut self) {
8515        self.control_handle.shutdown();
8516        // Safety: drops once, never accessed again
8517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8518    }
8519}
8520
8521impl fidl::endpoints::Responder for BufferCollectionTokenGroupSyncResponder {
8522    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8523
8524    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8525        &self.control_handle
8526    }
8527
8528    fn drop_without_shutdown(mut self) {
8529        // Safety: drops once, never accessed again due to mem::forget
8530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8531        // Prevent Drop from running (which would shut down the channel)
8532        std::mem::forget(self);
8533    }
8534}
8535
8536impl BufferCollectionTokenGroupSyncResponder {
8537    /// Sends a response to the FIDL transaction.
8538    ///
8539    /// Sets the channel to shutdown if an error occurs.
8540    pub fn send(self) -> Result<(), fidl::Error> {
8541        let _result = self.send_raw();
8542        if _result.is_err() {
8543            self.control_handle.shutdown();
8544        }
8545        self.drop_without_shutdown();
8546        _result
8547    }
8548
8549    /// Similar to "send" but does not shutdown the channel if an error occurs.
8550    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8551        let _result = self.send_raw();
8552        self.drop_without_shutdown();
8553        _result
8554    }
8555
8556    fn send_raw(&self) -> Result<(), fidl::Error> {
8557        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8558            (),
8559            self.tx_id,
8560            0x4577e238ae26291,
8561            fidl::encoding::DynamicFlags::empty(),
8562        )
8563    }
8564}
8565
8566#[must_use = "FIDL methods require a response to be sent"]
8567#[derive(Debug)]
8568pub struct BufferCollectionTokenGroupGetNodeRefResponder {
8569    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8570    tx_id: u32,
8571}
8572
8573/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8574/// if the responder is dropped without sending a response, so that the client
8575/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8576impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
8577    fn drop(&mut self) {
8578        self.control_handle.shutdown();
8579        // Safety: drops once, never accessed again
8580        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8581    }
8582}
8583
8584impl fidl::endpoints::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
8585    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8586
8587    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8588        &self.control_handle
8589    }
8590
8591    fn drop_without_shutdown(mut self) {
8592        // Safety: drops once, never accessed again due to mem::forget
8593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8594        // Prevent Drop from running (which would shut down the channel)
8595        std::mem::forget(self);
8596    }
8597}
8598
8599impl BufferCollectionTokenGroupGetNodeRefResponder {
8600    /// Sends a response to the FIDL transaction.
8601    ///
8602    /// Sets the channel to shutdown if an error occurs.
8603    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8604        let _result = self.send_raw(node_ref);
8605        if _result.is_err() {
8606            self.control_handle.shutdown();
8607        }
8608        self.drop_without_shutdown();
8609        _result
8610    }
8611
8612    /// Similar to "send" but does not shutdown the channel if an error occurs.
8613    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8614        let _result = self.send_raw(node_ref);
8615        self.drop_without_shutdown();
8616        _result
8617    }
8618
8619    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8620        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
8621            (node_ref,),
8622            self.tx_id,
8623            0x467b7c75c35c3b84,
8624            fidl::encoding::DynamicFlags::empty(),
8625        )
8626    }
8627}
8628
8629#[must_use = "FIDL methods require a response to be sent"]
8630#[derive(Debug)]
8631pub struct BufferCollectionTokenGroupIsAlternateForResponder {
8632    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8633    tx_id: u32,
8634}
8635
8636/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8637/// if the responder is dropped without sending a response, so that the client
8638/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8639impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
8640    fn drop(&mut self) {
8641        self.control_handle.shutdown();
8642        // Safety: drops once, never accessed again
8643        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8644    }
8645}
8646
8647impl fidl::endpoints::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
8648    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8649
8650    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8651        &self.control_handle
8652    }
8653
8654    fn drop_without_shutdown(mut self) {
8655        // Safety: drops once, never accessed again due to mem::forget
8656        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8657        // Prevent Drop from running (which would shut down the channel)
8658        std::mem::forget(self);
8659    }
8660}
8661
8662impl BufferCollectionTokenGroupIsAlternateForResponder {
8663    /// Sends a response to the FIDL transaction.
8664    ///
8665    /// Sets the channel to shutdown if an error occurs.
8666    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8667        let _result = self.send_raw(result);
8668        if _result.is_err() {
8669            self.control_handle.shutdown();
8670        }
8671        self.drop_without_shutdown();
8672        _result
8673    }
8674
8675    /// Similar to "send" but does not shutdown the channel if an error occurs.
8676    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8677        let _result = self.send_raw(result);
8678        self.drop_without_shutdown();
8679        _result
8680    }
8681
8682    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8683        self.control_handle
8684            .inner
8685            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
8686                result.map(|is_alternate| (is_alternate,)),
8687                self.tx_id,
8688                0x33a2a7aff2776c07,
8689                fidl::encoding::DynamicFlags::empty(),
8690            )
8691    }
8692}
8693
8694#[must_use = "FIDL methods require a response to be sent"]
8695#[derive(Debug)]
8696pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
8697    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8698    tx_id: u32,
8699}
8700
8701/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8702/// if the responder is dropped without sending a response, so that the client
8703/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8704impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8705    fn drop(&mut self) {
8706        self.control_handle.shutdown();
8707        // Safety: drops once, never accessed again
8708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8709    }
8710}
8711
8712impl fidl::endpoints::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8713    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8714
8715    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8716        &self.control_handle
8717    }
8718
8719    fn drop_without_shutdown(mut self) {
8720        // Safety: drops once, never accessed again due to mem::forget
8721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8722        // Prevent Drop from running (which would shut down the channel)
8723        std::mem::forget(self);
8724    }
8725}
8726
8727impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
8728    /// Sends a response to the FIDL transaction.
8729    ///
8730    /// Sets the channel to shutdown if an error occurs.
8731    pub fn send(
8732        self,
8733        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8734    ) -> Result<(), fidl::Error> {
8735        let _result = self.send_raw(tokens);
8736        if _result.is_err() {
8737            self.control_handle.shutdown();
8738        }
8739        self.drop_without_shutdown();
8740        _result
8741    }
8742
8743    /// Similar to "send" but does not shutdown the channel if an error occurs.
8744    pub fn send_no_shutdown_on_err(
8745        self,
8746        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8747    ) -> Result<(), fidl::Error> {
8748        let _result = self.send_raw(tokens);
8749        self.drop_without_shutdown();
8750        _result
8751    }
8752
8753    fn send_raw(
8754        &self,
8755        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8756    ) -> Result<(), fidl::Error> {
8757        self.control_handle.inner.send::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(
8758            (tokens.as_mut(),),
8759            self.tx_id,
8760            0x569dc3ca2a98f535,
8761            fidl::encoding::DynamicFlags::empty(),
8762        )
8763    }
8764}
8765
8766#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8767pub struct NodeMarker;
8768
8769impl fidl::endpoints::ProtocolMarker for NodeMarker {
8770    type Proxy = NodeProxy;
8771    type RequestStream = NodeRequestStream;
8772    #[cfg(target_os = "fuchsia")]
8773    type SynchronousProxy = NodeSynchronousProxy;
8774
8775    const DEBUG_NAME: &'static str = "(anonymous) Node";
8776}
8777pub type NodeIsAlternateForResult = Result<bool, i32>;
8778
8779pub trait NodeProxyInterface: Send + Sync {
8780    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8781    fn r#sync(&self) -> Self::SyncResponseFut;
8782    fn r#close(&self) -> Result<(), fidl::Error>;
8783    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
8784    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
8785    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
8786    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
8787    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
8788        + Send;
8789    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
8790    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
8791        + Send;
8792    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
8793}
8794#[derive(Debug)]
8795#[cfg(target_os = "fuchsia")]
8796pub struct NodeSynchronousProxy {
8797    client: fidl::client::sync::Client,
8798}
8799
8800#[cfg(target_os = "fuchsia")]
8801impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
8802    type Proxy = NodeProxy;
8803    type Protocol = NodeMarker;
8804
8805    fn from_channel(inner: fidl::Channel) -> Self {
8806        Self::new(inner)
8807    }
8808
8809    fn into_channel(self) -> fidl::Channel {
8810        self.client.into_channel()
8811    }
8812
8813    fn as_channel(&self) -> &fidl::Channel {
8814        self.client.as_channel()
8815    }
8816}
8817
8818#[cfg(target_os = "fuchsia")]
8819impl NodeSynchronousProxy {
8820    pub fn new(channel: fidl::Channel) -> Self {
8821        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8822        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8823    }
8824
8825    pub fn into_channel(self) -> fidl::Channel {
8826        self.client.into_channel()
8827    }
8828
8829    /// Waits until an event arrives and returns it. It is safe for other
8830    /// threads to make concurrent requests while waiting for an event.
8831    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
8832        NodeEvent::decode(self.client.wait_for_event(deadline)?)
8833    }
8834
8835    /// Ensure that previous messages, including Duplicate() messages on a
8836    /// token, collection, or group, have been received server side.
8837    ///
8838    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
8839    /// valid sysmem token risks the Sync() hanging forever.  See
8840    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
8841    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
8842    /// Another way is to pass the token to BindSharedCollection(), which also
8843    /// validates the token as part of exchanging it for a BufferCollection
8844    /// channel, and BufferCollection Sync() can then be used.
8845    ///
8846    /// After a Sync(), it's then safe to send the client end of token_request
8847    /// to another participant knowing the server will recognize the token when
8848    /// it's sent into BindSharedCollection() by the other participant.
8849    ///
8850    /// Other options include waiting for each token.Duplicate() to complete
8851    /// individually (using separate call to token.Sync() after each), or
8852    /// calling Sync() on BufferCollection after the token has been turned in
8853    /// via BindSharedCollection().
8854    ///
8855    /// Another way to mitigate is to avoid calling Sync() on the token, and
8856    /// instead later deal with potential failure of BufferCollection.Sync() if
8857    /// the original token was invalid.  This option can be preferable from a
8858    /// performance point of view, but requires client code to delay sending
8859    /// tokens duplicated from this token until after client code has converted
8860    /// the duplicating token to a BufferCollection and received successful
8861    /// response from BufferCollection.Sync().
8862    ///
8863    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
8864    /// When BufferCollection.Sync() isn't feasible, the caller must already
8865    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
8866    /// hang forever.  See ValidateBufferCollectionToken() to check token
8867    /// validity first if the token isn't already known to be (is/was) valid.
8868    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8869        let _response =
8870            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8871                (),
8872                0x4577e238ae26291,
8873                fidl::encoding::DynamicFlags::empty(),
8874                ___deadline,
8875            )?;
8876        Ok(_response)
8877    }
8878
8879    /// On a BufferCollectionToken channel:
8880    ///
8881    /// Normally a participant will convert a BufferCollectionToken into a
8882    /// BufferCollection view, but a participant is also free to Close() the
8883    /// token (and then close the channel immediately or shortly later in
8884    /// response to server closing its end), which avoids causing logical buffer
8885    /// collection failure.  Normally an unexpected token channel close will
8886    /// cause logical buffer collection failure (the only exceptions being
8887    /// certain cases involving AttachToken() or SetDispensable()).
8888    ///
8889    /// On a BufferCollection channel:
8890    ///
8891    /// By default the server handles unexpected failure of a BufferCollection
8892    /// by failing the whole logical buffer collection.  Partly this is to
8893    /// expedite closing VMO handles to reclaim memory when any participant
8894    /// fails.  If a participant would like to cleanly close a BufferCollection
8895    /// view without causing logical buffer collection failure, the participant
8896    /// can send Close() before closing the client end of the BufferCollection
8897    /// channel.  If this is the last BufferCollection view, the logical buffer
8898    /// collection will still go away.  The Close() can occur before or after
8899    /// SetConstraints().  If before SetConstraints(), the buffer collection
8900    /// won't require constraints from this node in order to allocate.  If
8901    /// after SetConstraints(), the constraints are retained and aggregated
8902    /// along with any subsequent logical allocation(s), despite the lack of
8903    /// channel connection.
8904    ///
8905    /// On a BufferCollectionTokenGroup channel:
8906    ///
8907    /// By default, unexpected failure of a BufferCollectionTokenGroup will
8908    /// trigger failure of the logical BufferCollectionTokenGroup and will
8909    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
8910    /// channel without failing the logical group or propagating failure, send
8911    /// Close() before closing the channel client endpoint.
8912    ///
8913    /// If Close() occurs before AllChildrenPresent(), the logical buffer
8914    /// collection will still fail despite the Close() (because sysmem can't be
8915    /// sure whether all relevant children were created, so it's ambiguous
8916    /// whether all relevant constraints will be provided to sysmem).  If
8917    /// Close() occurs after AllChildrenPresent(), the children and all their
8918    /// constraints remain intact (just as they would if the
8919    /// BufferCollectionTokenGroup channel had remained open), and the close
8920    /// doesn't trigger or propagate failure.
8921    pub fn r#close(&self) -> Result<(), fidl::Error> {
8922        self.client.send::<fidl::encoding::EmptyPayload>(
8923            (),
8924            0x5b1d7a4f5681fca7,
8925            fidl::encoding::DynamicFlags::empty(),
8926        )
8927    }
8928
8929    /// Set a name for VMOs in this buffer collection. The name may be truncated
8930    /// shorter. The name only affects VMOs allocated after it's set - this call
8931    /// does not rename existing VMOs. If multiple clients set different names
8932    /// then the larger priority value will win.
8933    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
8934        self.client.send::<NodeSetNameRequest>(
8935            (priority, name),
8936            0x77a41bb6217e2443,
8937            fidl::encoding::DynamicFlags::empty(),
8938        )
8939    }
8940
8941    /// Set information about the current client that can be used by sysmem to
8942    /// help debug leaking memory and hangs waiting for constraints. |name| can
8943    /// be an arbitrary string, but the current process name (see
8944    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
8945    /// arbitrary id, but the current process ID (see
8946    /// fsl::GetCurrentProcessKoid()) is a good default.
8947    ///
8948    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
8949    /// indicate which client is closing their channel first, leading to
8950    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
8951    /// over, but if happening earlier than expected, the
8952    /// client-channel-specific name can help diagnose where the failure is
8953    /// first coming from, from sysmem's point of view).
8954    ///
8955    /// By default (unless overriden by this message or using
8956    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
8957    /// parent Node at the time the child Node is created.  While this can be
8958    /// better than nothing, it's often better for each participant to use
8959    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
8960    /// info directly relevant to the current client.  Also, SetVerboseLogging()
8961    /// can be used to help disambiguate if a Node is suspected of having info
8962    /// that was copied from its parent.
8963    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
8964        self.client.send::<NodeSetDebugClientInfoRequest>(
8965            (name, id),
8966            0x7275759070eb5ee2,
8967            fidl::encoding::DynamicFlags::empty(),
8968        )
8969    }
8970
8971    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
8972    /// after creating a collection. Clients can call this method to change
8973    /// when the log is printed. If multiple client set the deadline, it's
8974    /// unspecified which deadline will take effect.
8975    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
8976        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
8977            (deadline,),
8978            0x46d38f4772638867,
8979            fidl::encoding::DynamicFlags::empty(),
8980        )
8981    }
8982
8983    /// Verbose logging includes constraints set via SetConstraints() from each
8984    /// client along with info set via SetDebugClientInfo() and the structure of
8985    /// the tree of Node(s).
8986    ///
8987    /// Normally sysmem prints only a single line complaint when aggregation
8988    /// fails, with just the specific detailed reason that aggregation failed,
8989    /// with minimal context.  While this is often enough to diagnose a problem
8990    /// if only a small change was made and the system had been working before
8991    /// the small change, it's often not particularly helpful for getting a new
8992    /// buffer collection to work for the first time.  Especially with more
8993    /// complex trees of nodes, involving things like AttachToken(),
8994    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
8995    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
8996    /// looks like and why it's failing a logical allocation, or why a tree or
8997    /// sub-tree is failing sooner than expected.
8998    ///
8999    /// The intent of the extra logging is to be acceptable from a performance
9000    /// point of view, if only enabled on a low number of buffer collections.
9001    /// If we're not tracking down a bug, we shouldn't send this message.
9002    ///
9003    /// If too many participants leave verbose logging enabled, we may end up
9004    /// needing to require that system-wide sysmem verbose logging be permitted
9005    /// via some other setting, to avoid sysmem spamming the log too much due to
9006    /// this message.
9007    ///
9008    /// This may be a NOP for some nodes due to intentional policy associated
9009    /// with the node, if we don't trust a node enough to let it turn on verbose
9010    /// logging.
9011    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9012        self.client.send::<fidl::encoding::EmptyPayload>(
9013            (),
9014            0x6bfbe2cf1701d288,
9015            fidl::encoding::DynamicFlags::empty(),
9016        )
9017    }
9018
9019    /// This gets an event handle that can be used as a parameter to
9020    /// IsAlternateFor() called on any Node.  The client will not be granted the
9021    /// right to signal this event, as this handle should only be used as proof
9022    /// that the client obtained this handle from this Node.
9023    ///
9024    /// Because this is a get not a set, no Sync() is needed between the
9025    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9026    /// potentially being on different channels.
9027    ///
9028    /// See also IsAlternateFor().
9029    pub fn r#get_node_ref(
9030        &self,
9031        ___deadline: zx::MonotonicInstant,
9032    ) -> Result<fidl::Event, fidl::Error> {
9033        let _response =
9034            self.client.send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
9035                (),
9036                0x467b7c75c35c3b84,
9037                fidl::encoding::DynamicFlags::empty(),
9038                ___deadline,
9039            )?;
9040        Ok(_response.node_ref)
9041    }
9042
9043    /// This checks whether the calling node is in a subtree rooted at a
9044    /// different child token of a common parent BufferCollectionTokenGroup, in
9045    /// relation to the passed-in node_ref.
9046    ///
9047    /// This call is for assisting with admission control de-duplication, and
9048    /// with debugging.
9049    ///
9050    /// The node_ref must be obtained using GetNodeRef() of a
9051    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9052    ///
9053    /// The node_ref can be a duplicated handle; it's not necessary to call
9054    /// GetNodeRef() for every call to IsAlternateFor().
9055    ///
9056    /// If a calling token may not actually be a valid token at all due to
9057    /// a potentially hostile/untrusted provider of the token, call
9058    /// ValidateBufferCollectionToken() first instead of potentially getting
9059    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9060    /// token not being a real token (not really talking to sysmem).  Another
9061    /// option is to call BindSharedCollection with this token first which also
9062    /// validates the token along with converting it to a BufferCollection, then
9063    /// call BufferCollection IsAlternateFor().
9064    ///
9065    /// error values:
9066    ///
9067    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9068    /// buffer collection as the calling Node.  Before logical allocation and
9069    /// within the same logical allocation sub-tree, this essentially means that
9070    /// the node_ref was never part of this logical buffer collection, since
9071    /// before logical allocation all node_refs that come into existence remain
9072    /// in existence at least until logical allocation (including Node(s) that
9073    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9074    /// to be returned, this Node's channel needs to still be connected server
9075    /// side, which won't be the case if the whole logical allocation has
9076    /// failed.  After logical allocation or in a different logical allocation
9077    /// sub-tree there are additional potential reasons for this error.  For
9078    /// example a different logical allocation (separated from this Node(s)
9079    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9080    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9081    /// exist and may select a different child sub-tree than the sub-tree the
9082    /// node_ref is in causing deletion of the node_ref Node.  The only time
9083    /// sysmem keeps a Node around after that Node has no corresponding channel
9084    /// is when Close() is used and the Node's sub-tree has not yet failed.
9085    /// Another reason for this error is if the node_ref is an eventpair handle
9086    /// with sufficient rights, but isn't actually a real node_ref obtained from
9087    /// GetNodeRef().
9088    ///
9089    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9090    /// eventpair handle, or doesn't have the needed rights expected on a real
9091    /// node_ref.
9092    ///
9093    /// No other failing status codes are returned by this call.  However,
9094    /// sysmem may add additional codes in future, so the client should have
9095    /// sensible default handling for any failing status code.
9096    ///
9097    /// On success, is_alternate has the following meaning:
9098    ///   * true - The first parent node in common between the calling node and
9099    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9100    ///     the calling Node and the node_ref Node will _not_ have both their
9101    ///     constraints apply - rather sysmem will choose one or the other of
9102    ///     the constraints - never both.  This is because only one child of
9103    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9104    ///     with only that one child's sub-tree contributing to constraints
9105    ///     aggregation.
9106    ///   * false - The first parent node in common between the calling Node and
9107    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9108    ///     this means the first parent node in common is a
9109    ///     BufferCollectionToken or BufferCollection (regardless of not
9110    ///     Close()ed or Close()ed).  This means that the calling Node and the
9111    ///     node_ref Node _may_ have both their constraints apply during
9112    ///     constraints aggregation of the logical allocation, if both Node(s)
9113    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9114    ///     In this case, there is no BufferCollectionTokenGroup that will
9115    ///     directly prevent the two Node(s) from both being selected and their
9116    ///     constraints both aggregated, but even when false, one or both
9117    ///     Node(s) may still be eliminated from consideration if one or both
9118    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9119    ///     which selects a child sub-tree other than the sub-tree containing
9120    ///     the calling Node or node_ref Node.
9121    pub fn r#is_alternate_for(
9122        &self,
9123        mut node_ref: fidl::Event,
9124        ___deadline: zx::MonotonicInstant,
9125    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
9126        let _response = self.client.send_query::<
9127            NodeIsAlternateForRequest,
9128            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
9129        >(
9130            (node_ref,),
9131            0x33a2a7aff2776c07,
9132            fidl::encoding::DynamicFlags::empty(),
9133            ___deadline,
9134        )?;
9135        Ok(_response.map(|x| x.is_alternate))
9136    }
9137}
9138
9139#[cfg(target_os = "fuchsia")]
9140impl From<NodeSynchronousProxy> for zx::Handle {
9141    fn from(value: NodeSynchronousProxy) -> Self {
9142        value.into_channel().into()
9143    }
9144}
9145
9146#[cfg(target_os = "fuchsia")]
9147impl From<fidl::Channel> for NodeSynchronousProxy {
9148    fn from(value: fidl::Channel) -> Self {
9149        Self::new(value)
9150    }
9151}
9152
9153#[derive(Debug, Clone)]
9154pub struct NodeProxy {
9155    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9156}
9157
9158impl fidl::endpoints::Proxy for NodeProxy {
9159    type Protocol = NodeMarker;
9160
9161    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9162        Self::new(inner)
9163    }
9164
9165    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9166        self.client.into_channel().map_err(|client| Self { client })
9167    }
9168
9169    fn as_channel(&self) -> &::fidl::AsyncChannel {
9170        self.client.as_channel()
9171    }
9172}
9173
9174impl NodeProxy {
9175    /// Create a new Proxy for fuchsia.sysmem/Node.
9176    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9177        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9178        Self { client: fidl::client::Client::new(channel, protocol_name) }
9179    }
9180
9181    /// Get a Stream of events from the remote end of the protocol.
9182    ///
9183    /// # Panics
9184    ///
9185    /// Panics if the event stream was already taken.
9186    pub fn take_event_stream(&self) -> NodeEventStream {
9187        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9188    }
9189
9190    /// Ensure that previous messages, including Duplicate() messages on a
9191    /// token, collection, or group, have been received server side.
9192    ///
9193    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9194    /// valid sysmem token risks the Sync() hanging forever.  See
9195    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9196    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9197    /// Another way is to pass the token to BindSharedCollection(), which also
9198    /// validates the token as part of exchanging it for a BufferCollection
9199    /// channel, and BufferCollection Sync() can then be used.
9200    ///
9201    /// After a Sync(), it's then safe to send the client end of token_request
9202    /// to another participant knowing the server will recognize the token when
9203    /// it's sent into BindSharedCollection() by the other participant.
9204    ///
9205    /// Other options include waiting for each token.Duplicate() to complete
9206    /// individually (using separate call to token.Sync() after each), or
9207    /// calling Sync() on BufferCollection after the token has been turned in
9208    /// via BindSharedCollection().
9209    ///
9210    /// Another way to mitigate is to avoid calling Sync() on the token, and
9211    /// instead later deal with potential failure of BufferCollection.Sync() if
9212    /// the original token was invalid.  This option can be preferable from a
9213    /// performance point of view, but requires client code to delay sending
9214    /// tokens duplicated from this token until after client code has converted
9215    /// the duplicating token to a BufferCollection and received successful
9216    /// response from BufferCollection.Sync().
9217    ///
9218    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9219    /// When BufferCollection.Sync() isn't feasible, the caller must already
9220    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9221    /// hang forever.  See ValidateBufferCollectionToken() to check token
9222    /// validity first if the token isn't already known to be (is/was) valid.
9223    pub fn r#sync(
9224        &self,
9225    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9226        NodeProxyInterface::r#sync(self)
9227    }
9228
9229    /// On a BufferCollectionToken channel:
9230    ///
9231    /// Normally a participant will convert a BufferCollectionToken into a
9232    /// BufferCollection view, but a participant is also free to Close() the
9233    /// token (and then close the channel immediately or shortly later in
9234    /// response to server closing its end), which avoids causing logical buffer
9235    /// collection failure.  Normally an unexpected token channel close will
9236    /// cause logical buffer collection failure (the only exceptions being
9237    /// certain cases involving AttachToken() or SetDispensable()).
9238    ///
9239    /// On a BufferCollection channel:
9240    ///
9241    /// By default the server handles unexpected failure of a BufferCollection
9242    /// by failing the whole logical buffer collection.  Partly this is to
9243    /// expedite closing VMO handles to reclaim memory when any participant
9244    /// fails.  If a participant would like to cleanly close a BufferCollection
9245    /// view without causing logical buffer collection failure, the participant
9246    /// can send Close() before closing the client end of the BufferCollection
9247    /// channel.  If this is the last BufferCollection view, the logical buffer
9248    /// collection will still go away.  The Close() can occur before or after
9249    /// SetConstraints().  If before SetConstraints(), the buffer collection
9250    /// won't require constraints from this node in order to allocate.  If
9251    /// after SetConstraints(), the constraints are retained and aggregated
9252    /// along with any subsequent logical allocation(s), despite the lack of
9253    /// channel connection.
9254    ///
9255    /// On a BufferCollectionTokenGroup channel:
9256    ///
9257    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9258    /// trigger failure of the logical BufferCollectionTokenGroup and will
9259    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9260    /// channel without failing the logical group or propagating failure, send
9261    /// Close() before closing the channel client endpoint.
9262    ///
9263    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9264    /// collection will still fail despite the Close() (because sysmem can't be
9265    /// sure whether all relevant children were created, so it's ambiguous
9266    /// whether all relevant constraints will be provided to sysmem).  If
9267    /// Close() occurs after AllChildrenPresent(), the children and all their
9268    /// constraints remain intact (just as they would if the
9269    /// BufferCollectionTokenGroup channel had remained open), and the close
9270    /// doesn't trigger or propagate failure.
9271    pub fn r#close(&self) -> Result<(), fidl::Error> {
9272        NodeProxyInterface::r#close(self)
9273    }
9274
9275    /// Set a name for VMOs in this buffer collection. The name may be truncated
9276    /// shorter. The name only affects VMOs allocated after it's set - this call
9277    /// does not rename existing VMOs. If multiple clients set different names
9278    /// then the larger priority value will win.
9279    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9280        NodeProxyInterface::r#set_name(self, priority, name)
9281    }
9282
9283    /// Set information about the current client that can be used by sysmem to
9284    /// help debug leaking memory and hangs waiting for constraints. |name| can
9285    /// be an arbitrary string, but the current process name (see
9286    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9287    /// arbitrary id, but the current process ID (see
9288    /// fsl::GetCurrentProcessKoid()) is a good default.
9289    ///
9290    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9291    /// indicate which client is closing their channel first, leading to
9292    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9293    /// over, but if happening earlier than expected, the
9294    /// client-channel-specific name can help diagnose where the failure is
9295    /// first coming from, from sysmem's point of view).
9296    ///
9297    /// By default (unless overriden by this message or using
9298    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9299    /// parent Node at the time the child Node is created.  While this can be
9300    /// better than nothing, it's often better for each participant to use
9301    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9302    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9303    /// can be used to help disambiguate if a Node is suspected of having info
9304    /// that was copied from its parent.
9305    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9306        NodeProxyInterface::r#set_debug_client_info(self, name, id)
9307    }
9308
9309    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9310    /// after creating a collection. Clients can call this method to change
9311    /// when the log is printed. If multiple client set the deadline, it's
9312    /// unspecified which deadline will take effect.
9313    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9314        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
9315    }
9316
9317    /// Verbose logging includes constraints set via SetConstraints() from each
9318    /// client along with info set via SetDebugClientInfo() and the structure of
9319    /// the tree of Node(s).
9320    ///
9321    /// Normally sysmem prints only a single line complaint when aggregation
9322    /// fails, with just the specific detailed reason that aggregation failed,
9323    /// with minimal context.  While this is often enough to diagnose a problem
9324    /// if only a small change was made and the system had been working before
9325    /// the small change, it's often not particularly helpful for getting a new
9326    /// buffer collection to work for the first time.  Especially with more
9327    /// complex trees of nodes, involving things like AttachToken(),
9328    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9329    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9330    /// looks like and why it's failing a logical allocation, or why a tree or
9331    /// sub-tree is failing sooner than expected.
9332    ///
9333    /// The intent of the extra logging is to be acceptable from a performance
9334    /// point of view, if only enabled on a low number of buffer collections.
9335    /// If we're not tracking down a bug, we shouldn't send this message.
9336    ///
9337    /// If too many participants leave verbose logging enabled, we may end up
9338    /// needing to require that system-wide sysmem verbose logging be permitted
9339    /// via some other setting, to avoid sysmem spamming the log too much due to
9340    /// this message.
9341    ///
9342    /// This may be a NOP for some nodes due to intentional policy associated
9343    /// with the node, if we don't trust a node enough to let it turn on verbose
9344    /// logging.
9345    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9346        NodeProxyInterface::r#set_verbose_logging(self)
9347    }
9348
9349    /// This gets an event handle that can be used as a parameter to
9350    /// IsAlternateFor() called on any Node.  The client will not be granted the
9351    /// right to signal this event, as this handle should only be used as proof
9352    /// that the client obtained this handle from this Node.
9353    ///
9354    /// Because this is a get not a set, no Sync() is needed between the
9355    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9356    /// potentially being on different channels.
9357    ///
9358    /// See also IsAlternateFor().
9359    pub fn r#get_node_ref(
9360        &self,
9361    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
9362    {
9363        NodeProxyInterface::r#get_node_ref(self)
9364    }
9365
9366    /// This checks whether the calling node is in a subtree rooted at a
9367    /// different child token of a common parent BufferCollectionTokenGroup, in
9368    /// relation to the passed-in node_ref.
9369    ///
9370    /// This call is for assisting with admission control de-duplication, and
9371    /// with debugging.
9372    ///
9373    /// The node_ref must be obtained using GetNodeRef() of a
9374    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9375    ///
9376    /// The node_ref can be a duplicated handle; it's not necessary to call
9377    /// GetNodeRef() for every call to IsAlternateFor().
9378    ///
9379    /// If a calling token may not actually be a valid token at all due to
9380    /// a potentially hostile/untrusted provider of the token, call
9381    /// ValidateBufferCollectionToken() first instead of potentially getting
9382    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9383    /// token not being a real token (not really talking to sysmem).  Another
9384    /// option is to call BindSharedCollection with this token first which also
9385    /// validates the token along with converting it to a BufferCollection, then
9386    /// call BufferCollection IsAlternateFor().
9387    ///
9388    /// error values:
9389    ///
9390    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9391    /// buffer collection as the calling Node.  Before logical allocation and
9392    /// within the same logical allocation sub-tree, this essentially means that
9393    /// the node_ref was never part of this logical buffer collection, since
9394    /// before logical allocation all node_refs that come into existence remain
9395    /// in existence at least until logical allocation (including Node(s) that
9396    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9397    /// to be returned, this Node's channel needs to still be connected server
9398    /// side, which won't be the case if the whole logical allocation has
9399    /// failed.  After logical allocation or in a different logical allocation
9400    /// sub-tree there are additional potential reasons for this error.  For
9401    /// example a different logical allocation (separated from this Node(s)
9402    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9403    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9404    /// exist and may select a different child sub-tree than the sub-tree the
9405    /// node_ref is in causing deletion of the node_ref Node.  The only time
9406    /// sysmem keeps a Node around after that Node has no corresponding channel
9407    /// is when Close() is used and the Node's sub-tree has not yet failed.
9408    /// Another reason for this error is if the node_ref is an eventpair handle
9409    /// with sufficient rights, but isn't actually a real node_ref obtained from
9410    /// GetNodeRef().
9411    ///
9412    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9413    /// eventpair handle, or doesn't have the needed rights expected on a real
9414    /// node_ref.
9415    ///
9416    /// No other failing status codes are returned by this call.  However,
9417    /// sysmem may add additional codes in future, so the client should have
9418    /// sensible default handling for any failing status code.
9419    ///
9420    /// On success, is_alternate has the following meaning:
9421    ///   * true - The first parent node in common between the calling node and
9422    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9423    ///     the calling Node and the node_ref Node will _not_ have both their
9424    ///     constraints apply - rather sysmem will choose one or the other of
9425    ///     the constraints - never both.  This is because only one child of
9426    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9427    ///     with only that one child's sub-tree contributing to constraints
9428    ///     aggregation.
9429    ///   * false - The first parent node in common between the calling Node and
9430    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9431    ///     this means the first parent node in common is a
9432    ///     BufferCollectionToken or BufferCollection (regardless of not
9433    ///     Close()ed or Close()ed).  This means that the calling Node and the
9434    ///     node_ref Node _may_ have both their constraints apply during
9435    ///     constraints aggregation of the logical allocation, if both Node(s)
9436    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9437    ///     In this case, there is no BufferCollectionTokenGroup that will
9438    ///     directly prevent the two Node(s) from both being selected and their
9439    ///     constraints both aggregated, but even when false, one or both
9440    ///     Node(s) may still be eliminated from consideration if one or both
9441    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9442    ///     which selects a child sub-tree other than the sub-tree containing
9443    ///     the calling Node or node_ref Node.
9444    pub fn r#is_alternate_for(
9445        &self,
9446        mut node_ref: fidl::Event,
9447    ) -> fidl::client::QueryResponseFut<
9448        NodeIsAlternateForResult,
9449        fidl::encoding::DefaultFuchsiaResourceDialect,
9450    > {
9451        NodeProxyInterface::r#is_alternate_for(self, node_ref)
9452    }
9453}
9454
9455impl NodeProxyInterface for NodeProxy {
9456    type SyncResponseFut =
9457        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9458    fn r#sync(&self) -> Self::SyncResponseFut {
9459        fn _decode(
9460            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9461        ) -> Result<(), fidl::Error> {
9462            let _response = fidl::client::decode_transaction_body::<
9463                fidl::encoding::EmptyPayload,
9464                fidl::encoding::DefaultFuchsiaResourceDialect,
9465                0x4577e238ae26291,
9466            >(_buf?)?;
9467            Ok(_response)
9468        }
9469        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9470            (),
9471            0x4577e238ae26291,
9472            fidl::encoding::DynamicFlags::empty(),
9473            _decode,
9474        )
9475    }
9476
9477    fn r#close(&self) -> Result<(), fidl::Error> {
9478        self.client.send::<fidl::encoding::EmptyPayload>(
9479            (),
9480            0x5b1d7a4f5681fca7,
9481            fidl::encoding::DynamicFlags::empty(),
9482        )
9483    }
9484
9485    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9486        self.client.send::<NodeSetNameRequest>(
9487            (priority, name),
9488            0x77a41bb6217e2443,
9489            fidl::encoding::DynamicFlags::empty(),
9490        )
9491    }
9492
9493    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9494        self.client.send::<NodeSetDebugClientInfoRequest>(
9495            (name, id),
9496            0x7275759070eb5ee2,
9497            fidl::encoding::DynamicFlags::empty(),
9498        )
9499    }
9500
9501    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9502        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
9503            (deadline,),
9504            0x46d38f4772638867,
9505            fidl::encoding::DynamicFlags::empty(),
9506        )
9507    }
9508
9509    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9510        self.client.send::<fidl::encoding::EmptyPayload>(
9511            (),
9512            0x6bfbe2cf1701d288,
9513            fidl::encoding::DynamicFlags::empty(),
9514        )
9515    }
9516
9517    type GetNodeRefResponseFut =
9518        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
9519    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
9520        fn _decode(
9521            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9522        ) -> Result<fidl::Event, fidl::Error> {
9523            let _response = fidl::client::decode_transaction_body::<
9524                NodeGetNodeRefResponse,
9525                fidl::encoding::DefaultFuchsiaResourceDialect,
9526                0x467b7c75c35c3b84,
9527            >(_buf?)?;
9528            Ok(_response.node_ref)
9529        }
9530        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
9531            (),
9532            0x467b7c75c35c3b84,
9533            fidl::encoding::DynamicFlags::empty(),
9534            _decode,
9535        )
9536    }
9537
9538    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
9539        NodeIsAlternateForResult,
9540        fidl::encoding::DefaultFuchsiaResourceDialect,
9541    >;
9542    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
9543        fn _decode(
9544            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9545        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
9546            let _response = fidl::client::decode_transaction_body::<
9547                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
9548                fidl::encoding::DefaultFuchsiaResourceDialect,
9549                0x33a2a7aff2776c07,
9550            >(_buf?)?;
9551            Ok(_response.map(|x| x.is_alternate))
9552        }
9553        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
9554            (node_ref,),
9555            0x33a2a7aff2776c07,
9556            fidl::encoding::DynamicFlags::empty(),
9557            _decode,
9558        )
9559    }
9560}
9561
9562pub struct NodeEventStream {
9563    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9564}
9565
9566impl std::marker::Unpin for NodeEventStream {}
9567
9568impl futures::stream::FusedStream for NodeEventStream {
9569    fn is_terminated(&self) -> bool {
9570        self.event_receiver.is_terminated()
9571    }
9572}
9573
9574impl futures::Stream for NodeEventStream {
9575    type Item = Result<NodeEvent, fidl::Error>;
9576
9577    fn poll_next(
9578        mut self: std::pin::Pin<&mut Self>,
9579        cx: &mut std::task::Context<'_>,
9580    ) -> std::task::Poll<Option<Self::Item>> {
9581        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9582            &mut self.event_receiver,
9583            cx
9584        )?) {
9585            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
9586            None => std::task::Poll::Ready(None),
9587        }
9588    }
9589}
9590
9591#[derive(Debug)]
9592pub enum NodeEvent {}
9593
9594impl NodeEvent {
9595    /// Decodes a message buffer as a [`NodeEvent`].
9596    fn decode(
9597        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9598    ) -> Result<NodeEvent, fidl::Error> {
9599        let (bytes, _handles) = buf.split_mut();
9600        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9601        debug_assert_eq!(tx_header.tx_id, 0);
9602        match tx_header.ordinal {
9603            _ => Err(fidl::Error::UnknownOrdinal {
9604                ordinal: tx_header.ordinal,
9605                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9606            }),
9607        }
9608    }
9609}
9610
9611/// A Stream of incoming requests for fuchsia.sysmem/Node.
9612pub struct NodeRequestStream {
9613    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9614    is_terminated: bool,
9615}
9616
9617impl std::marker::Unpin for NodeRequestStream {}
9618
9619impl futures::stream::FusedStream for NodeRequestStream {
9620    fn is_terminated(&self) -> bool {
9621        self.is_terminated
9622    }
9623}
9624
9625impl fidl::endpoints::RequestStream for NodeRequestStream {
9626    type Protocol = NodeMarker;
9627    type ControlHandle = NodeControlHandle;
9628
9629    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9630        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9631    }
9632
9633    fn control_handle(&self) -> Self::ControlHandle {
9634        NodeControlHandle { inner: self.inner.clone() }
9635    }
9636
9637    fn into_inner(
9638        self,
9639    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9640    {
9641        (self.inner, self.is_terminated)
9642    }
9643
9644    fn from_inner(
9645        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9646        is_terminated: bool,
9647    ) -> Self {
9648        Self { inner, is_terminated }
9649    }
9650}
9651
9652impl futures::Stream for NodeRequestStream {
9653    type Item = Result<NodeRequest, fidl::Error>;
9654
9655    fn poll_next(
9656        mut self: std::pin::Pin<&mut Self>,
9657        cx: &mut std::task::Context<'_>,
9658    ) -> std::task::Poll<Option<Self::Item>> {
9659        let this = &mut *self;
9660        if this.inner.check_shutdown(cx) {
9661            this.is_terminated = true;
9662            return std::task::Poll::Ready(None);
9663        }
9664        if this.is_terminated {
9665            panic!("polled NodeRequestStream after completion");
9666        }
9667        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9668            |bytes, handles| {
9669                match this.inner.channel().read_etc(cx, bytes, handles) {
9670                    std::task::Poll::Ready(Ok(())) => {}
9671                    std::task::Poll::Pending => return std::task::Poll::Pending,
9672                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9673                        this.is_terminated = true;
9674                        return std::task::Poll::Ready(None);
9675                    }
9676                    std::task::Poll::Ready(Err(e)) => {
9677                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9678                            e.into(),
9679                        ))))
9680                    }
9681                }
9682
9683                // A message has been received from the channel
9684                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9685
9686                std::task::Poll::Ready(Some(match header.ordinal {
9687                    0x4577e238ae26291 => {
9688                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9689                        let mut req = fidl::new_empty!(
9690                            fidl::encoding::EmptyPayload,
9691                            fidl::encoding::DefaultFuchsiaResourceDialect
9692                        );
9693                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9694                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9695                        Ok(NodeRequest::Sync {
9696                            responder: NodeSyncResponder {
9697                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9698                                tx_id: header.tx_id,
9699                            },
9700                        })
9701                    }
9702                    0x5b1d7a4f5681fca7 => {
9703                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9704                        let mut req = fidl::new_empty!(
9705                            fidl::encoding::EmptyPayload,
9706                            fidl::encoding::DefaultFuchsiaResourceDialect
9707                        );
9708                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9709                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9710                        Ok(NodeRequest::Close { control_handle })
9711                    }
9712                    0x77a41bb6217e2443 => {
9713                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9714                        let mut req = fidl::new_empty!(
9715                            NodeSetNameRequest,
9716                            fidl::encoding::DefaultFuchsiaResourceDialect
9717                        );
9718                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
9719                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9720                        Ok(NodeRequest::SetName {
9721                            priority: req.priority,
9722                            name: req.name,
9723
9724                            control_handle,
9725                        })
9726                    }
9727                    0x7275759070eb5ee2 => {
9728                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9729                        let mut req = fidl::new_empty!(
9730                            NodeSetDebugClientInfoRequest,
9731                            fidl::encoding::DefaultFuchsiaResourceDialect
9732                        );
9733                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
9734                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9735                        Ok(NodeRequest::SetDebugClientInfo {
9736                            name: req.name,
9737                            id: req.id,
9738
9739                            control_handle,
9740                        })
9741                    }
9742                    0x46d38f4772638867 => {
9743                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9744                        let mut req = fidl::new_empty!(
9745                            NodeSetDebugTimeoutLogDeadlineRequest,
9746                            fidl::encoding::DefaultFuchsiaResourceDialect
9747                        );
9748                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
9749                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9750                        Ok(NodeRequest::SetDebugTimeoutLogDeadline {
9751                            deadline: req.deadline,
9752
9753                            control_handle,
9754                        })
9755                    }
9756                    0x6bfbe2cf1701d288 => {
9757                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9758                        let mut req = fidl::new_empty!(
9759                            fidl::encoding::EmptyPayload,
9760                            fidl::encoding::DefaultFuchsiaResourceDialect
9761                        );
9762                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9763                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9764                        Ok(NodeRequest::SetVerboseLogging { control_handle })
9765                    }
9766                    0x467b7c75c35c3b84 => {
9767                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9768                        let mut req = fidl::new_empty!(
9769                            fidl::encoding::EmptyPayload,
9770                            fidl::encoding::DefaultFuchsiaResourceDialect
9771                        );
9772                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9773                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9774                        Ok(NodeRequest::GetNodeRef {
9775                            responder: NodeGetNodeRefResponder {
9776                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9777                                tx_id: header.tx_id,
9778                            },
9779                        })
9780                    }
9781                    0x33a2a7aff2776c07 => {
9782                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9783                        let mut req = fidl::new_empty!(
9784                            NodeIsAlternateForRequest,
9785                            fidl::encoding::DefaultFuchsiaResourceDialect
9786                        );
9787                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
9788                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9789                        Ok(NodeRequest::IsAlternateFor {
9790                            node_ref: req.node_ref,
9791
9792                            responder: NodeIsAlternateForResponder {
9793                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9794                                tx_id: header.tx_id,
9795                            },
9796                        })
9797                    }
9798                    _ => Err(fidl::Error::UnknownOrdinal {
9799                        ordinal: header.ordinal,
9800                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9801                    }),
9802                }))
9803            },
9804        )
9805    }
9806}
9807
9808#[derive(Debug)]
9809pub enum NodeRequest {
9810    /// Ensure that previous messages, including Duplicate() messages on a
9811    /// token, collection, or group, have been received server side.
9812    ///
9813    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9814    /// valid sysmem token risks the Sync() hanging forever.  See
9815    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9816    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9817    /// Another way is to pass the token to BindSharedCollection(), which also
9818    /// validates the token as part of exchanging it for a BufferCollection
9819    /// channel, and BufferCollection Sync() can then be used.
9820    ///
9821    /// After a Sync(), it's then safe to send the client end of token_request
9822    /// to another participant knowing the server will recognize the token when
9823    /// it's sent into BindSharedCollection() by the other participant.
9824    ///
9825    /// Other options include waiting for each token.Duplicate() to complete
9826    /// individually (using separate call to token.Sync() after each), or
9827    /// calling Sync() on BufferCollection after the token has been turned in
9828    /// via BindSharedCollection().
9829    ///
9830    /// Another way to mitigate is to avoid calling Sync() on the token, and
9831    /// instead later deal with potential failure of BufferCollection.Sync() if
9832    /// the original token was invalid.  This option can be preferable from a
9833    /// performance point of view, but requires client code to delay sending
9834    /// tokens duplicated from this token until after client code has converted
9835    /// the duplicating token to a BufferCollection and received successful
9836    /// response from BufferCollection.Sync().
9837    ///
9838    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9839    /// When BufferCollection.Sync() isn't feasible, the caller must already
9840    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9841    /// hang forever.  See ValidateBufferCollectionToken() to check token
9842    /// validity first if the token isn't already known to be (is/was) valid.
9843    Sync { responder: NodeSyncResponder },
9844    /// On a BufferCollectionToken channel:
9845    ///
9846    /// Normally a participant will convert a BufferCollectionToken into a
9847    /// BufferCollection view, but a participant is also free to Close() the
9848    /// token (and then close the channel immediately or shortly later in
9849    /// response to server closing its end), which avoids causing logical buffer
9850    /// collection failure.  Normally an unexpected token channel close will
9851    /// cause logical buffer collection failure (the only exceptions being
9852    /// certain cases involving AttachToken() or SetDispensable()).
9853    ///
9854    /// On a BufferCollection channel:
9855    ///
9856    /// By default the server handles unexpected failure of a BufferCollection
9857    /// by failing the whole logical buffer collection.  Partly this is to
9858    /// expedite closing VMO handles to reclaim memory when any participant
9859    /// fails.  If a participant would like to cleanly close a BufferCollection
9860    /// view without causing logical buffer collection failure, the participant
9861    /// can send Close() before closing the client end of the BufferCollection
9862    /// channel.  If this is the last BufferCollection view, the logical buffer
9863    /// collection will still go away.  The Close() can occur before or after
9864    /// SetConstraints().  If before SetConstraints(), the buffer collection
9865    /// won't require constraints from this node in order to allocate.  If
9866    /// after SetConstraints(), the constraints are retained and aggregated
9867    /// along with any subsequent logical allocation(s), despite the lack of
9868    /// channel connection.
9869    ///
9870    /// On a BufferCollectionTokenGroup channel:
9871    ///
9872    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9873    /// trigger failure of the logical BufferCollectionTokenGroup and will
9874    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9875    /// channel without failing the logical group or propagating failure, send
9876    /// Close() before closing the channel client endpoint.
9877    ///
9878    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9879    /// collection will still fail despite the Close() (because sysmem can't be
9880    /// sure whether all relevant children were created, so it's ambiguous
9881    /// whether all relevant constraints will be provided to sysmem).  If
9882    /// Close() occurs after AllChildrenPresent(), the children and all their
9883    /// constraints remain intact (just as they would if the
9884    /// BufferCollectionTokenGroup channel had remained open), and the close
9885    /// doesn't trigger or propagate failure.
9886    Close { control_handle: NodeControlHandle },
9887    /// Set a name for VMOs in this buffer collection. The name may be truncated
9888    /// shorter. The name only affects VMOs allocated after it's set - this call
9889    /// does not rename existing VMOs. If multiple clients set different names
9890    /// then the larger priority value will win.
9891    SetName { priority: u32, name: String, control_handle: NodeControlHandle },
9892    /// Set information about the current client that can be used by sysmem to
9893    /// help debug leaking memory and hangs waiting for constraints. |name| can
9894    /// be an arbitrary string, but the current process name (see
9895    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9896    /// arbitrary id, but the current process ID (see
9897    /// fsl::GetCurrentProcessKoid()) is a good default.
9898    ///
9899    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9900    /// indicate which client is closing their channel first, leading to
9901    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9902    /// over, but if happening earlier than expected, the
9903    /// client-channel-specific name can help diagnose where the failure is
9904    /// first coming from, from sysmem's point of view).
9905    ///
9906    /// By default (unless overriden by this message or using
9907    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9908    /// parent Node at the time the child Node is created.  While this can be
9909    /// better than nothing, it's often better for each participant to use
9910    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9911    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9912    /// can be used to help disambiguate if a Node is suspected of having info
9913    /// that was copied from its parent.
9914    SetDebugClientInfo { name: String, id: u64, control_handle: NodeControlHandle },
9915    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9916    /// after creating a collection. Clients can call this method to change
9917    /// when the log is printed. If multiple client set the deadline, it's
9918    /// unspecified which deadline will take effect.
9919    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: NodeControlHandle },
9920    /// Verbose logging includes constraints set via SetConstraints() from each
9921    /// client along with info set via SetDebugClientInfo() and the structure of
9922    /// the tree of Node(s).
9923    ///
9924    /// Normally sysmem prints only a single line complaint when aggregation
9925    /// fails, with just the specific detailed reason that aggregation failed,
9926    /// with minimal context.  While this is often enough to diagnose a problem
9927    /// if only a small change was made and the system had been working before
9928    /// the small change, it's often not particularly helpful for getting a new
9929    /// buffer collection to work for the first time.  Especially with more
9930    /// complex trees of nodes, involving things like AttachToken(),
9931    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9932    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9933    /// looks like and why it's failing a logical allocation, or why a tree or
9934    /// sub-tree is failing sooner than expected.
9935    ///
9936    /// The intent of the extra logging is to be acceptable from a performance
9937    /// point of view, if only enabled on a low number of buffer collections.
9938    /// If we're not tracking down a bug, we shouldn't send this message.
9939    ///
9940    /// If too many participants leave verbose logging enabled, we may end up
9941    /// needing to require that system-wide sysmem verbose logging be permitted
9942    /// via some other setting, to avoid sysmem spamming the log too much due to
9943    /// this message.
9944    ///
9945    /// This may be a NOP for some nodes due to intentional policy associated
9946    /// with the node, if we don't trust a node enough to let it turn on verbose
9947    /// logging.
9948    SetVerboseLogging { control_handle: NodeControlHandle },
9949    /// This gets an event handle that can be used as a parameter to
9950    /// IsAlternateFor() called on any Node.  The client will not be granted the
9951    /// right to signal this event, as this handle should only be used as proof
9952    /// that the client obtained this handle from this Node.
9953    ///
9954    /// Because this is a get not a set, no Sync() is needed between the
9955    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9956    /// potentially being on different channels.
9957    ///
9958    /// See also IsAlternateFor().
9959    GetNodeRef { responder: NodeGetNodeRefResponder },
9960    /// This checks whether the calling node is in a subtree rooted at a
9961    /// different child token of a common parent BufferCollectionTokenGroup, in
9962    /// relation to the passed-in node_ref.
9963    ///
9964    /// This call is for assisting with admission control de-duplication, and
9965    /// with debugging.
9966    ///
9967    /// The node_ref must be obtained using GetNodeRef() of a
9968    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9969    ///
9970    /// The node_ref can be a duplicated handle; it's not necessary to call
9971    /// GetNodeRef() for every call to IsAlternateFor().
9972    ///
9973    /// If a calling token may not actually be a valid token at all due to
9974    /// a potentially hostile/untrusted provider of the token, call
9975    /// ValidateBufferCollectionToken() first instead of potentially getting
9976    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9977    /// token not being a real token (not really talking to sysmem).  Another
9978    /// option is to call BindSharedCollection with this token first which also
9979    /// validates the token along with converting it to a BufferCollection, then
9980    /// call BufferCollection IsAlternateFor().
9981    ///
9982    /// error values:
9983    ///
9984    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9985    /// buffer collection as the calling Node.  Before logical allocation and
9986    /// within the same logical allocation sub-tree, this essentially means that
9987    /// the node_ref was never part of this logical buffer collection, since
9988    /// before logical allocation all node_refs that come into existence remain
9989    /// in existence at least until logical allocation (including Node(s) that
9990    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9991    /// to be returned, this Node's channel needs to still be connected server
9992    /// side, which won't be the case if the whole logical allocation has
9993    /// failed.  After logical allocation or in a different logical allocation
9994    /// sub-tree there are additional potential reasons for this error.  For
9995    /// example a different logical allocation (separated from this Node(s)
9996    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9997    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9998    /// exist and may select a different child sub-tree than the sub-tree the
9999    /// node_ref is in causing deletion of the node_ref Node.  The only time
10000    /// sysmem keeps a Node around after that Node has no corresponding channel
10001    /// is when Close() is used and the Node's sub-tree has not yet failed.
10002    /// Another reason for this error is if the node_ref is an eventpair handle
10003    /// with sufficient rights, but isn't actually a real node_ref obtained from
10004    /// GetNodeRef().
10005    ///
10006    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
10007    /// eventpair handle, or doesn't have the needed rights expected on a real
10008    /// node_ref.
10009    ///
10010    /// No other failing status codes are returned by this call.  However,
10011    /// sysmem may add additional codes in future, so the client should have
10012    /// sensible default handling for any failing status code.
10013    ///
10014    /// On success, is_alternate has the following meaning:
10015    ///   * true - The first parent node in common between the calling node and
10016    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
10017    ///     the calling Node and the node_ref Node will _not_ have both their
10018    ///     constraints apply - rather sysmem will choose one or the other of
10019    ///     the constraints - never both.  This is because only one child of
10020    ///     a BufferCollectionTokenGroup is selected during logical allocation,
10021    ///     with only that one child's sub-tree contributing to constraints
10022    ///     aggregation.
10023    ///   * false - The first parent node in common between the calling Node and
10024    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
10025    ///     this means the first parent node in common is a
10026    ///     BufferCollectionToken or BufferCollection (regardless of not
10027    ///     Close()ed or Close()ed).  This means that the calling Node and the
10028    ///     node_ref Node _may_ have both their constraints apply during
10029    ///     constraints aggregation of the logical allocation, if both Node(s)
10030    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
10031    ///     In this case, there is no BufferCollectionTokenGroup that will
10032    ///     directly prevent the two Node(s) from both being selected and their
10033    ///     constraints both aggregated, but even when false, one or both
10034    ///     Node(s) may still be eliminated from consideration if one or both
10035    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
10036    ///     which selects a child sub-tree other than the sub-tree containing
10037    ///     the calling Node or node_ref Node.
10038    IsAlternateFor { node_ref: fidl::Event, responder: NodeIsAlternateForResponder },
10039}
10040
10041impl NodeRequest {
10042    #[allow(irrefutable_let_patterns)]
10043    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
10044        if let NodeRequest::Sync { responder } = self {
10045            Some((responder))
10046        } else {
10047            None
10048        }
10049    }
10050
10051    #[allow(irrefutable_let_patterns)]
10052    pub fn into_close(self) -> Option<(NodeControlHandle)> {
10053        if let NodeRequest::Close { control_handle } = self {
10054            Some((control_handle))
10055        } else {
10056            None
10057        }
10058    }
10059
10060    #[allow(irrefutable_let_patterns)]
10061    pub fn into_set_name(self) -> Option<(u32, String, NodeControlHandle)> {
10062        if let NodeRequest::SetName { priority, name, control_handle } = self {
10063            Some((priority, name, control_handle))
10064        } else {
10065            None
10066        }
10067    }
10068
10069    #[allow(irrefutable_let_patterns)]
10070    pub fn into_set_debug_client_info(self) -> Option<(String, u64, NodeControlHandle)> {
10071        if let NodeRequest::SetDebugClientInfo { name, id, control_handle } = self {
10072            Some((name, id, control_handle))
10073        } else {
10074            None
10075        }
10076    }
10077
10078    #[allow(irrefutable_let_patterns)]
10079    pub fn into_set_debug_timeout_log_deadline(self) -> Option<(i64, NodeControlHandle)> {
10080        if let NodeRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } = self {
10081            Some((deadline, control_handle))
10082        } else {
10083            None
10084        }
10085    }
10086
10087    #[allow(irrefutable_let_patterns)]
10088    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
10089        if let NodeRequest::SetVerboseLogging { control_handle } = self {
10090            Some((control_handle))
10091        } else {
10092            None
10093        }
10094    }
10095
10096    #[allow(irrefutable_let_patterns)]
10097    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
10098        if let NodeRequest::GetNodeRef { responder } = self {
10099            Some((responder))
10100        } else {
10101            None
10102        }
10103    }
10104
10105    #[allow(irrefutable_let_patterns)]
10106    pub fn into_is_alternate_for(self) -> Option<(fidl::Event, NodeIsAlternateForResponder)> {
10107        if let NodeRequest::IsAlternateFor { node_ref, responder } = self {
10108            Some((node_ref, responder))
10109        } else {
10110            None
10111        }
10112    }
10113
10114    /// Name of the method defined in FIDL
10115    pub fn method_name(&self) -> &'static str {
10116        match *self {
10117            NodeRequest::Sync { .. } => "sync",
10118            NodeRequest::Close { .. } => "close",
10119            NodeRequest::SetName { .. } => "set_name",
10120            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
10121            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
10122            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
10123            NodeRequest::GetNodeRef { .. } => "get_node_ref",
10124            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
10125        }
10126    }
10127}
10128
10129#[derive(Debug, Clone)]
10130pub struct NodeControlHandle {
10131    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10132}
10133
10134impl fidl::endpoints::ControlHandle for NodeControlHandle {
10135    fn shutdown(&self) {
10136        self.inner.shutdown()
10137    }
10138    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10139        self.inner.shutdown_with_epitaph(status)
10140    }
10141
10142    fn is_closed(&self) -> bool {
10143        self.inner.channel().is_closed()
10144    }
10145    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10146        self.inner.channel().on_closed()
10147    }
10148
10149    #[cfg(target_os = "fuchsia")]
10150    fn signal_peer(
10151        &self,
10152        clear_mask: zx::Signals,
10153        set_mask: zx::Signals,
10154    ) -> Result<(), zx_status::Status> {
10155        use fidl::Peered;
10156        self.inner.channel().signal_peer(clear_mask, set_mask)
10157    }
10158}
10159
10160impl NodeControlHandle {}
10161
10162#[must_use = "FIDL methods require a response to be sent"]
10163#[derive(Debug)]
10164pub struct NodeSyncResponder {
10165    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10166    tx_id: u32,
10167}
10168
10169/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10170/// if the responder is dropped without sending a response, so that the client
10171/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10172impl std::ops::Drop for NodeSyncResponder {
10173    fn drop(&mut self) {
10174        self.control_handle.shutdown();
10175        // Safety: drops once, never accessed again
10176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10177    }
10178}
10179
10180impl fidl::endpoints::Responder for NodeSyncResponder {
10181    type ControlHandle = NodeControlHandle;
10182
10183    fn control_handle(&self) -> &NodeControlHandle {
10184        &self.control_handle
10185    }
10186
10187    fn drop_without_shutdown(mut self) {
10188        // Safety: drops once, never accessed again due to mem::forget
10189        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10190        // Prevent Drop from running (which would shut down the channel)
10191        std::mem::forget(self);
10192    }
10193}
10194
10195impl NodeSyncResponder {
10196    /// Sends a response to the FIDL transaction.
10197    ///
10198    /// Sets the channel to shutdown if an error occurs.
10199    pub fn send(self) -> Result<(), fidl::Error> {
10200        let _result = self.send_raw();
10201        if _result.is_err() {
10202            self.control_handle.shutdown();
10203        }
10204        self.drop_without_shutdown();
10205        _result
10206    }
10207
10208    /// Similar to "send" but does not shutdown the channel if an error occurs.
10209    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10210        let _result = self.send_raw();
10211        self.drop_without_shutdown();
10212        _result
10213    }
10214
10215    fn send_raw(&self) -> Result<(), fidl::Error> {
10216        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10217            (),
10218            self.tx_id,
10219            0x4577e238ae26291,
10220            fidl::encoding::DynamicFlags::empty(),
10221        )
10222    }
10223}
10224
10225#[must_use = "FIDL methods require a response to be sent"]
10226#[derive(Debug)]
10227pub struct NodeGetNodeRefResponder {
10228    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10229    tx_id: u32,
10230}
10231
10232/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10233/// if the responder is dropped without sending a response, so that the client
10234/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10235impl std::ops::Drop for NodeGetNodeRefResponder {
10236    fn drop(&mut self) {
10237        self.control_handle.shutdown();
10238        // Safety: drops once, never accessed again
10239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10240    }
10241}
10242
10243impl fidl::endpoints::Responder for NodeGetNodeRefResponder {
10244    type ControlHandle = NodeControlHandle;
10245
10246    fn control_handle(&self) -> &NodeControlHandle {
10247        &self.control_handle
10248    }
10249
10250    fn drop_without_shutdown(mut self) {
10251        // Safety: drops once, never accessed again due to mem::forget
10252        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10253        // Prevent Drop from running (which would shut down the channel)
10254        std::mem::forget(self);
10255    }
10256}
10257
10258impl NodeGetNodeRefResponder {
10259    /// Sends a response to the FIDL transaction.
10260    ///
10261    /// Sets the channel to shutdown if an error occurs.
10262    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10263        let _result = self.send_raw(node_ref);
10264        if _result.is_err() {
10265            self.control_handle.shutdown();
10266        }
10267        self.drop_without_shutdown();
10268        _result
10269    }
10270
10271    /// Similar to "send" but does not shutdown the channel if an error occurs.
10272    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10273        let _result = self.send_raw(node_ref);
10274        self.drop_without_shutdown();
10275        _result
10276    }
10277
10278    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10279        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
10280            (node_ref,),
10281            self.tx_id,
10282            0x467b7c75c35c3b84,
10283            fidl::encoding::DynamicFlags::empty(),
10284        )
10285    }
10286}
10287
10288#[must_use = "FIDL methods require a response to be sent"]
10289#[derive(Debug)]
10290pub struct NodeIsAlternateForResponder {
10291    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10292    tx_id: u32,
10293}
10294
10295/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10296/// if the responder is dropped without sending a response, so that the client
10297/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10298impl std::ops::Drop for NodeIsAlternateForResponder {
10299    fn drop(&mut self) {
10300        self.control_handle.shutdown();
10301        // Safety: drops once, never accessed again
10302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10303    }
10304}
10305
10306impl fidl::endpoints::Responder for NodeIsAlternateForResponder {
10307    type ControlHandle = NodeControlHandle;
10308
10309    fn control_handle(&self) -> &NodeControlHandle {
10310        &self.control_handle
10311    }
10312
10313    fn drop_without_shutdown(mut self) {
10314        // Safety: drops once, never accessed again due to mem::forget
10315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10316        // Prevent Drop from running (which would shut down the channel)
10317        std::mem::forget(self);
10318    }
10319}
10320
10321impl NodeIsAlternateForResponder {
10322    /// Sends a response to the FIDL transaction.
10323    ///
10324    /// Sets the channel to shutdown if an error occurs.
10325    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10326        let _result = self.send_raw(result);
10327        if _result.is_err() {
10328            self.control_handle.shutdown();
10329        }
10330        self.drop_without_shutdown();
10331        _result
10332    }
10333
10334    /// Similar to "send" but does not shutdown the channel if an error occurs.
10335    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10336        let _result = self.send_raw(result);
10337        self.drop_without_shutdown();
10338        _result
10339    }
10340
10341    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10342        self.control_handle
10343            .inner
10344            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
10345                result.map(|is_alternate| (is_alternate,)),
10346                self.tx_id,
10347                0x33a2a7aff2776c07,
10348                fidl::encoding::DynamicFlags::empty(),
10349            )
10350    }
10351}
10352
10353#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10354pub struct SecureMemMarker;
10355
10356impl fidl::endpoints::ProtocolMarker for SecureMemMarker {
10357    type Proxy = SecureMemProxy;
10358    type RequestStream = SecureMemRequestStream;
10359    #[cfg(target_os = "fuchsia")]
10360    type SynchronousProxy = SecureMemSynchronousProxy;
10361
10362    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
10363}
10364pub type SecureMemGetPhysicalSecureHeapsResult = Result<SecureHeapsAndRanges, i32>;
10365pub type SecureMemGetPhysicalSecureHeapPropertiesResult = Result<SecureHeapProperties, i32>;
10366pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), i32>;
10367pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), i32>;
10368pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), i32>;
10369pub type SecureMemZeroSubRangeResult = Result<(), i32>;
10370
10371pub trait SecureMemProxyInterface: Send + Sync {
10372    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
10373        + Send;
10374    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
10375    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
10376            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
10377        > + Send;
10378    fn r#get_physical_secure_heap_properties(
10379        &self,
10380        entire_heap: &SecureHeapAndRange,
10381    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
10382    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
10383        + Send;
10384    fn r#add_secure_heap_physical_range(
10385        &self,
10386        heap_range: &SecureHeapAndRange,
10387    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
10388    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
10389            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
10390        > + Send;
10391    fn r#delete_secure_heap_physical_range(
10392        &self,
10393        heap_range: &SecureHeapAndRange,
10394    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
10395    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
10396            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
10397        > + Send;
10398    fn r#modify_secure_heap_physical_range(
10399        &self,
10400        range_modification: &SecureHeapAndRangeModification,
10401    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
10402    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
10403        + Send;
10404    fn r#zero_sub_range(
10405        &self,
10406        is_covering_range_explicit: bool,
10407        heap_range: &SecureHeapAndRange,
10408    ) -> Self::ZeroSubRangeResponseFut;
10409}
10410#[derive(Debug)]
10411#[cfg(target_os = "fuchsia")]
10412pub struct SecureMemSynchronousProxy {
10413    client: fidl::client::sync::Client,
10414}
10415
10416#[cfg(target_os = "fuchsia")]
10417impl fidl::endpoints::SynchronousProxy for SecureMemSynchronousProxy {
10418    type Proxy = SecureMemProxy;
10419    type Protocol = SecureMemMarker;
10420
10421    fn from_channel(inner: fidl::Channel) -> Self {
10422        Self::new(inner)
10423    }
10424
10425    fn into_channel(self) -> fidl::Channel {
10426        self.client.into_channel()
10427    }
10428
10429    fn as_channel(&self) -> &fidl::Channel {
10430        self.client.as_channel()
10431    }
10432}
10433
10434#[cfg(target_os = "fuchsia")]
10435impl SecureMemSynchronousProxy {
10436    pub fn new(channel: fidl::Channel) -> Self {
10437        let protocol_name = <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10438        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10439    }
10440
10441    pub fn into_channel(self) -> fidl::Channel {
10442        self.client.into_channel()
10443    }
10444
10445    /// Waits until an event arrives and returns it. It is safe for other
10446    /// threads to make concurrent requests while waiting for an event.
10447    pub fn wait_for_event(
10448        &self,
10449        deadline: zx::MonotonicInstant,
10450    ) -> Result<SecureMemEvent, fidl::Error> {
10451        SecureMemEvent::decode(self.client.wait_for_event(deadline)?)
10452    }
10453
10454    /// Gets the physical address and length of any secure heap whose physical
10455    /// range is configured via the TEE.
10456    ///
10457    /// Presently, these will be fixed physical addresses and lengths, with the
10458    /// location plumbed via the TEE.
10459    ///
10460    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10461    /// when there isn't any special heap-specific per-VMO setup or teardown
10462    /// required.
10463    ///
10464    /// The physical range must be secured/protected by the TEE before the
10465    /// securemem driver responds to this request with success.
10466    ///
10467    /// Sysmem should only call this once.  Returning zero heaps is not a
10468    /// failure.
10469    ///
10470    /// Errors:
10471    ///  * ZX_ERR_BAD_STATE - called more than once.
10472    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10473    ///    with TEE which doesn't generate zx_status_t errors).
10474    ///  * other errors are allowed; any other errors should be treated the same
10475    ///    as ZX_ERR_INTERNAL.
10476    pub fn r#get_physical_secure_heaps(
10477        &self,
10478        ___deadline: zx::MonotonicInstant,
10479    ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
10480        let _response = self.client.send_query::<
10481            fidl::encoding::EmptyPayload,
10482            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
10483        >(
10484            (),
10485            0x782319d6ce7fa05,
10486            fidl::encoding::DynamicFlags::empty(),
10487            ___deadline,
10488        )?;
10489        Ok(_response.map(|x| x.heaps))
10490    }
10491
10492    /// This request from sysmem to the securemem driver gets the properties of
10493    /// a protected/secure heap.
10494    ///
10495    /// This only handles heaps with a single contiguous physical extent.
10496    ///
10497    /// The heap's entire physical range is indicated in case this request needs
10498    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10499    /// temporary HW protection ranges will be deleted before this request
10500    /// completes.
10501    pub fn r#get_physical_secure_heap_properties(
10502        &self,
10503        mut entire_heap: &SecureHeapAndRange,
10504        ___deadline: zx::MonotonicInstant,
10505    ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
10506        let _response = self.client.send_query::<
10507            SecureMemGetPhysicalSecureHeapPropertiesRequest,
10508            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
10509        >(
10510            (entire_heap,),
10511            0x26404e23f1271214,
10512            fidl::encoding::DynamicFlags::empty(),
10513            ___deadline,
10514        )?;
10515        Ok(_response.map(|x| x.properties))
10516    }
10517
10518    /// This request from sysmem to the securemem driver conveys a physical
10519    /// range to add, for a heap whose physical range(s) are set up via
10520    /// sysmem.
10521    ///
10522    /// Only sysmem can call this because only sysmem is handed the client end
10523    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10524    /// securemem driver is the server end of this protocol.
10525    ///
10526    /// The securemem driver must configure all the covered offsets as protected
10527    /// before responding to this message with success.
10528    ///
10529    /// On failure, the securemem driver must ensure the protected range was not
10530    /// created.
10531    ///
10532    /// Sysmem must only call this up to once if dynamic_protection_ranges
10533    /// false.
10534    ///
10535    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10536    /// times as long as the current number of ranges never exceeds
10537    /// max_protected_range_count.
10538    ///
10539    /// The caller must not attempt to add a range that matches an
10540    /// already-existing range.  Added ranges can overlap each other as long as
10541    /// no two ranges match exactly.
10542    ///
10543    /// Errors:
10544    ///   * ZX_ERR_BAD_STATE - called more than once when
10545    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10546    ///     heap count to exceed max_protected_range_count.
10547    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10548    ///     to protected_range_granularity.
10549    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10550    ///     with TEE which doesn't generate zx_status_t errors).
10551    ///   * other errors are possible, such as from communication failures or
10552    ///     server propagation of zx_status_t failures.
10553    pub fn r#add_secure_heap_physical_range(
10554        &self,
10555        mut heap_range: &SecureHeapAndRange,
10556        ___deadline: zx::MonotonicInstant,
10557    ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
10558        let _response = self.client.send_query::<
10559            SecureMemAddSecureHeapPhysicalRangeRequest,
10560            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10561        >(
10562            (heap_range,),
10563            0x1ca1abcee8a0b33e,
10564            fidl::encoding::DynamicFlags::empty(),
10565            ___deadline,
10566        )?;
10567        Ok(_response.map(|x| x))
10568    }
10569
10570    /// This request from sysmem to the securemem driver conveys a physical
10571    /// range to delete, for a heap whose physical range(s) are set up via
10572    /// sysmem.
10573    ///
10574    /// Only sysmem can call this because only sysmem is handed the client end
10575    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10576    /// securemem driver is the server end of this protocol.
10577    ///
10578    /// The securemem driver must configure all the covered offsets as not
10579    /// protected before responding to this message with success.
10580    ///
10581    /// On failure, the securemem driver must ensure the protected range was not
10582    /// deleted.
10583    ///
10584    /// Sysmem must not call this if dynamic_protection_ranges false.
10585    ///
10586    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10587    /// on various ranges that exist at the time of the call.
10588    ///
10589    /// If any portion of the range being deleted is not also covered by another
10590    /// protected range, then any ongoing DMA to any part of the entire range
10591    /// may be interrupted / may fail, potentially in a way that's disruptive to
10592    /// the entire system (bus lockup or similar, depending on device details).
10593    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10594    /// any portion of the range being deleted, unless the caller has other
10595    /// active ranges covering every block of the range being deleted.  Ongoing
10596    /// DMA to/from blocks outside the range being deleted is never impacted by
10597    /// the deletion.
10598    ///
10599    /// Errors:
10600    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10601    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10602    ///     to protected_range_granularity.
10603    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10604    ///     with TEE which doesn't generate zx_status_t errors).
10605    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10606    ///   * other errors are possible, such as from communication failures or
10607    ///     server propagation of zx_status_t failures.
10608    pub fn r#delete_secure_heap_physical_range(
10609        &self,
10610        mut heap_range: &SecureHeapAndRange,
10611        ___deadline: zx::MonotonicInstant,
10612    ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
10613        let _response = self.client.send_query::<
10614            SecureMemDeleteSecureHeapPhysicalRangeRequest,
10615            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10616        >(
10617            (heap_range,),
10618            0x728a953e56df92ee,
10619            fidl::encoding::DynamicFlags::empty(),
10620            ___deadline,
10621        )?;
10622        Ok(_response.map(|x| x))
10623    }
10624
10625    /// This request from sysmem to the securemem driver conveys a physical
10626    /// range to modify and its new base and length, for a heap whose physical
10627    /// range(s) are set up via sysmem.
10628    ///
10629    /// Only sysmem can call this because only sysmem is handed the client end
10630    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10631    /// securemem driver is the server end of this protocol.
10632    ///
10633    /// The securemem driver must configure the range to cover only the new
10634    /// offsets before responding to this message with success.
10635    ///
10636    /// On failure, the securemem driver must ensure the range was not changed.
10637    ///
10638    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10639    /// must not call this if !is_mod_protected_range_available.
10640    ///
10641    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10642    /// on various ranges that exist at the time of the call.
10643    ///
10644    /// The range must only be modified at one end or the other, but not both.
10645    /// If the range is getting shorter, and the un-covered blocks are not
10646    /// covered by other active ranges, any ongoing DMA to the entire range
10647    /// that's geting shorter may fail in a way that disrupts the entire system
10648    /// (bus lockup or similar), so the caller must ensure that no DMA is
10649    /// ongoing to any portion of a range that is getting shorter, unless the
10650    /// blocks being un-covered by the modification to this range are all
10651    /// covered by other active ranges, in which case no disruption to ongoing
10652    /// DMA will occur.
10653    ///
10654    /// If a range is modified to become <= zero length, the range is deleted.
10655    ///
10656    /// Errors:
10657    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10658    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
10659    ///     that doesn't conform to protected_range_granularity, or old_range
10660    ///     and new_range differ in both begin and end (disallowed).
10661    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10662    ///     with TEE which doesn't generate zx_status_t errors).
10663    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10664    ///   * other errors are possible, such as from communication failures or
10665    ///     server propagation of zx_status_t failures.
10666    pub fn r#modify_secure_heap_physical_range(
10667        &self,
10668        mut range_modification: &SecureHeapAndRangeModification,
10669        ___deadline: zx::MonotonicInstant,
10670    ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
10671        let _response = self.client.send_query::<
10672            SecureMemModifySecureHeapPhysicalRangeRequest,
10673            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10674        >(
10675            (range_modification,),
10676            0x154fbfa3646a890d,
10677            fidl::encoding::DynamicFlags::empty(),
10678            ___deadline,
10679        )?;
10680        Ok(_response.map(|x| x))
10681    }
10682
10683    /// Zero a sub-range of a currently-existing physical range added via
10684    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
10685    /// exactly one physical range, and must not overlap with any other
10686    /// physical range.
10687    ///
10688    /// is_covering_range_explicit - When true, the covering range must be one
10689    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
10690    ///     possibly modified since.  When false, the covering range must not
10691    ///     be one of the ranges explicitly created via
10692    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
10693    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
10694    ///     covering range is typically the entire physical range (or a range
10695    ///     which covers even more) of a heap configured by the TEE and whose
10696    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
10697    ///
10698    /// Ongoing DMA is not disrupted by this request.
10699    pub fn r#zero_sub_range(
10700        &self,
10701        mut is_covering_range_explicit: bool,
10702        mut heap_range: &SecureHeapAndRange,
10703        ___deadline: zx::MonotonicInstant,
10704    ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
10705        let _response = self.client.send_query::<
10706            SecureMemZeroSubRangeRequest,
10707            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10708        >(
10709            (is_covering_range_explicit, heap_range,),
10710            0x7480f72bb5bc7e5b,
10711            fidl::encoding::DynamicFlags::empty(),
10712            ___deadline,
10713        )?;
10714        Ok(_response.map(|x| x))
10715    }
10716}
10717
10718#[cfg(target_os = "fuchsia")]
10719impl From<SecureMemSynchronousProxy> for zx::Handle {
10720    fn from(value: SecureMemSynchronousProxy) -> Self {
10721        value.into_channel().into()
10722    }
10723}
10724
10725#[cfg(target_os = "fuchsia")]
10726impl From<fidl::Channel> for SecureMemSynchronousProxy {
10727    fn from(value: fidl::Channel) -> Self {
10728        Self::new(value)
10729    }
10730}
10731
10732#[derive(Debug, Clone)]
10733pub struct SecureMemProxy {
10734    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10735}
10736
10737impl fidl::endpoints::Proxy for SecureMemProxy {
10738    type Protocol = SecureMemMarker;
10739
10740    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10741        Self::new(inner)
10742    }
10743
10744    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10745        self.client.into_channel().map_err(|client| Self { client })
10746    }
10747
10748    fn as_channel(&self) -> &::fidl::AsyncChannel {
10749        self.client.as_channel()
10750    }
10751}
10752
10753impl SecureMemProxy {
10754    /// Create a new Proxy for fuchsia.sysmem/SecureMem.
10755    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10756        let protocol_name = <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10757        Self { client: fidl::client::Client::new(channel, protocol_name) }
10758    }
10759
10760    /// Get a Stream of events from the remote end of the protocol.
10761    ///
10762    /// # Panics
10763    ///
10764    /// Panics if the event stream was already taken.
10765    pub fn take_event_stream(&self) -> SecureMemEventStream {
10766        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
10767    }
10768
10769    /// Gets the physical address and length of any secure heap whose physical
10770    /// range is configured via the TEE.
10771    ///
10772    /// Presently, these will be fixed physical addresses and lengths, with the
10773    /// location plumbed via the TEE.
10774    ///
10775    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10776    /// when there isn't any special heap-specific per-VMO setup or teardown
10777    /// required.
10778    ///
10779    /// The physical range must be secured/protected by the TEE before the
10780    /// securemem driver responds to this request with success.
10781    ///
10782    /// Sysmem should only call this once.  Returning zero heaps is not a
10783    /// failure.
10784    ///
10785    /// Errors:
10786    ///  * ZX_ERR_BAD_STATE - called more than once.
10787    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10788    ///    with TEE which doesn't generate zx_status_t errors).
10789    ///  * other errors are allowed; any other errors should be treated the same
10790    ///    as ZX_ERR_INTERNAL.
10791    pub fn r#get_physical_secure_heaps(
10792        &self,
10793    ) -> fidl::client::QueryResponseFut<
10794        SecureMemGetPhysicalSecureHeapsResult,
10795        fidl::encoding::DefaultFuchsiaResourceDialect,
10796    > {
10797        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
10798    }
10799
10800    /// This request from sysmem to the securemem driver gets the properties of
10801    /// a protected/secure heap.
10802    ///
10803    /// This only handles heaps with a single contiguous physical extent.
10804    ///
10805    /// The heap's entire physical range is indicated in case this request needs
10806    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10807    /// temporary HW protection ranges will be deleted before this request
10808    /// completes.
10809    pub fn r#get_physical_secure_heap_properties(
10810        &self,
10811        mut entire_heap: &SecureHeapAndRange,
10812    ) -> fidl::client::QueryResponseFut<
10813        SecureMemGetPhysicalSecureHeapPropertiesResult,
10814        fidl::encoding::DefaultFuchsiaResourceDialect,
10815    > {
10816        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, entire_heap)
10817    }
10818
10819    /// This request from sysmem to the securemem driver conveys a physical
10820    /// range to add, for a heap whose physical range(s) are set up via
10821    /// sysmem.
10822    ///
10823    /// Only sysmem can call this because only sysmem is handed the client end
10824    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10825    /// securemem driver is the server end of this protocol.
10826    ///
10827    /// The securemem driver must configure all the covered offsets as protected
10828    /// before responding to this message with success.
10829    ///
10830    /// On failure, the securemem driver must ensure the protected range was not
10831    /// created.
10832    ///
10833    /// Sysmem must only call this up to once if dynamic_protection_ranges
10834    /// false.
10835    ///
10836    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10837    /// times as long as the current number of ranges never exceeds
10838    /// max_protected_range_count.
10839    ///
10840    /// The caller must not attempt to add a range that matches an
10841    /// already-existing range.  Added ranges can overlap each other as long as
10842    /// no two ranges match exactly.
10843    ///
10844    /// Errors:
10845    ///   * ZX_ERR_BAD_STATE - called more than once when
10846    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10847    ///     heap count to exceed max_protected_range_count.
10848    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10849    ///     to protected_range_granularity.
10850    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10851    ///     with TEE which doesn't generate zx_status_t errors).
10852    ///   * other errors are possible, such as from communication failures or
10853    ///     server propagation of zx_status_t failures.
10854    pub fn r#add_secure_heap_physical_range(
10855        &self,
10856        mut heap_range: &SecureHeapAndRange,
10857    ) -> fidl::client::QueryResponseFut<
10858        SecureMemAddSecureHeapPhysicalRangeResult,
10859        fidl::encoding::DefaultFuchsiaResourceDialect,
10860    > {
10861        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, heap_range)
10862    }
10863
10864    /// This request from sysmem to the securemem driver conveys a physical
10865    /// range to delete, for a heap whose physical range(s) are set up via
10866    /// sysmem.
10867    ///
10868    /// Only sysmem can call this because only sysmem is handed the client end
10869    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10870    /// securemem driver is the server end of this protocol.
10871    ///
10872    /// The securemem driver must configure all the covered offsets as not
10873    /// protected before responding to this message with success.
10874    ///
10875    /// On failure, the securemem driver must ensure the protected range was not
10876    /// deleted.
10877    ///
10878    /// Sysmem must not call this if dynamic_protection_ranges false.
10879    ///
10880    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10881    /// on various ranges that exist at the time of the call.
10882    ///
10883    /// If any portion of the range being deleted is not also covered by another
10884    /// protected range, then any ongoing DMA to any part of the entire range
10885    /// may be interrupted / may fail, potentially in a way that's disruptive to
10886    /// the entire system (bus lockup or similar, depending on device details).
10887    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10888    /// any portion of the range being deleted, unless the caller has other
10889    /// active ranges covering every block of the range being deleted.  Ongoing
10890    /// DMA to/from blocks outside the range being deleted is never impacted by
10891    /// the deletion.
10892    ///
10893    /// Errors:
10894    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10895    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10896    ///     to protected_range_granularity.
10897    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10898    ///     with TEE which doesn't generate zx_status_t errors).
10899    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10900    ///   * other errors are possible, such as from communication failures or
10901    ///     server propagation of zx_status_t failures.
10902    pub fn r#delete_secure_heap_physical_range(
10903        &self,
10904        mut heap_range: &SecureHeapAndRange,
10905    ) -> fidl::client::QueryResponseFut<
10906        SecureMemDeleteSecureHeapPhysicalRangeResult,
10907        fidl::encoding::DefaultFuchsiaResourceDialect,
10908    > {
10909        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, heap_range)
10910    }
10911
10912    /// This request from sysmem to the securemem driver conveys a physical
10913    /// range to modify and its new base and length, for a heap whose physical
10914    /// range(s) are set up via sysmem.
10915    ///
10916    /// Only sysmem can call this because only sysmem is handed the client end
10917    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10918    /// securemem driver is the server end of this protocol.
10919    ///
10920    /// The securemem driver must configure the range to cover only the new
10921    /// offsets before responding to this message with success.
10922    ///
10923    /// On failure, the securemem driver must ensure the range was not changed.
10924    ///
10925    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10926    /// must not call this if !is_mod_protected_range_available.
10927    ///
10928    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10929    /// on various ranges that exist at the time of the call.
10930    ///
10931    /// The range must only be modified at one end or the other, but not both.
10932    /// If the range is getting shorter, and the un-covered blocks are not
10933    /// covered by other active ranges, any ongoing DMA to the entire range
10934    /// that's geting shorter may fail in a way that disrupts the entire system
10935    /// (bus lockup or similar), so the caller must ensure that no DMA is
10936    /// ongoing to any portion of a range that is getting shorter, unless the
10937    /// blocks being un-covered by the modification to this range are all
10938    /// covered by other active ranges, in which case no disruption to ongoing
10939    /// DMA will occur.
10940    ///
10941    /// If a range is modified to become <= zero length, the range is deleted.
10942    ///
10943    /// Errors:
10944    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10945    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
10946    ///     that doesn't conform to protected_range_granularity, or old_range
10947    ///     and new_range differ in both begin and end (disallowed).
10948    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10949    ///     with TEE which doesn't generate zx_status_t errors).
10950    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10951    ///   * other errors are possible, such as from communication failures or
10952    ///     server propagation of zx_status_t failures.
10953    pub fn r#modify_secure_heap_physical_range(
10954        &self,
10955        mut range_modification: &SecureHeapAndRangeModification,
10956    ) -> fidl::client::QueryResponseFut<
10957        SecureMemModifySecureHeapPhysicalRangeResult,
10958        fidl::encoding::DefaultFuchsiaResourceDialect,
10959    > {
10960        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, range_modification)
10961    }
10962
10963    /// Zero a sub-range of a currently-existing physical range added via
10964    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
10965    /// exactly one physical range, and must not overlap with any other
10966    /// physical range.
10967    ///
10968    /// is_covering_range_explicit - When true, the covering range must be one
10969    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
10970    ///     possibly modified since.  When false, the covering range must not
10971    ///     be one of the ranges explicitly created via
10972    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
10973    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
10974    ///     covering range is typically the entire physical range (or a range
10975    ///     which covers even more) of a heap configured by the TEE and whose
10976    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
10977    ///
10978    /// Ongoing DMA is not disrupted by this request.
10979    pub fn r#zero_sub_range(
10980        &self,
10981        mut is_covering_range_explicit: bool,
10982        mut heap_range: &SecureHeapAndRange,
10983    ) -> fidl::client::QueryResponseFut<
10984        SecureMemZeroSubRangeResult,
10985        fidl::encoding::DefaultFuchsiaResourceDialect,
10986    > {
10987        SecureMemProxyInterface::r#zero_sub_range(self, is_covering_range_explicit, heap_range)
10988    }
10989}
10990
10991impl SecureMemProxyInterface for SecureMemProxy {
10992    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
10993        SecureMemGetPhysicalSecureHeapsResult,
10994        fidl::encoding::DefaultFuchsiaResourceDialect,
10995    >;
10996    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
10997        fn _decode(
10998            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10999        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
11000            let _response = fidl::client::decode_transaction_body::<
11001                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
11002                fidl::encoding::DefaultFuchsiaResourceDialect,
11003                0x782319d6ce7fa05,
11004            >(_buf?)?;
11005            Ok(_response.map(|x| x.heaps))
11006        }
11007        self.client.send_query_and_decode::<
11008            fidl::encoding::EmptyPayload,
11009            SecureMemGetPhysicalSecureHeapsResult,
11010        >(
11011            (),
11012            0x782319d6ce7fa05,
11013            fidl::encoding::DynamicFlags::empty(),
11014            _decode,
11015        )
11016    }
11017
11018    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
11019        SecureMemGetPhysicalSecureHeapPropertiesResult,
11020        fidl::encoding::DefaultFuchsiaResourceDialect,
11021    >;
11022    fn r#get_physical_secure_heap_properties(
11023        &self,
11024        mut entire_heap: &SecureHeapAndRange,
11025    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
11026        fn _decode(
11027            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11028        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
11029            let _response = fidl::client::decode_transaction_body::<
11030                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
11031                fidl::encoding::DefaultFuchsiaResourceDialect,
11032                0x26404e23f1271214,
11033            >(_buf?)?;
11034            Ok(_response.map(|x| x.properties))
11035        }
11036        self.client.send_query_and_decode::<
11037            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11038            SecureMemGetPhysicalSecureHeapPropertiesResult,
11039        >(
11040            (entire_heap,),
11041            0x26404e23f1271214,
11042            fidl::encoding::DynamicFlags::empty(),
11043            _decode,
11044        )
11045    }
11046
11047    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11048        SecureMemAddSecureHeapPhysicalRangeResult,
11049        fidl::encoding::DefaultFuchsiaResourceDialect,
11050    >;
11051    fn r#add_secure_heap_physical_range(
11052        &self,
11053        mut heap_range: &SecureHeapAndRange,
11054    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
11055        fn _decode(
11056            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11057        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
11058            let _response = fidl::client::decode_transaction_body::<
11059                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11060                fidl::encoding::DefaultFuchsiaResourceDialect,
11061                0x1ca1abcee8a0b33e,
11062            >(_buf?)?;
11063            Ok(_response.map(|x| x))
11064        }
11065        self.client.send_query_and_decode::<
11066            SecureMemAddSecureHeapPhysicalRangeRequest,
11067            SecureMemAddSecureHeapPhysicalRangeResult,
11068        >(
11069            (heap_range,),
11070            0x1ca1abcee8a0b33e,
11071            fidl::encoding::DynamicFlags::empty(),
11072            _decode,
11073        )
11074    }
11075
11076    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11077        SecureMemDeleteSecureHeapPhysicalRangeResult,
11078        fidl::encoding::DefaultFuchsiaResourceDialect,
11079    >;
11080    fn r#delete_secure_heap_physical_range(
11081        &self,
11082        mut heap_range: &SecureHeapAndRange,
11083    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
11084        fn _decode(
11085            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11086        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
11087            let _response = fidl::client::decode_transaction_body::<
11088                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11089                fidl::encoding::DefaultFuchsiaResourceDialect,
11090                0x728a953e56df92ee,
11091            >(_buf?)?;
11092            Ok(_response.map(|x| x))
11093        }
11094        self.client.send_query_and_decode::<
11095            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11096            SecureMemDeleteSecureHeapPhysicalRangeResult,
11097        >(
11098            (heap_range,),
11099            0x728a953e56df92ee,
11100            fidl::encoding::DynamicFlags::empty(),
11101            _decode,
11102        )
11103    }
11104
11105    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11106        SecureMemModifySecureHeapPhysicalRangeResult,
11107        fidl::encoding::DefaultFuchsiaResourceDialect,
11108    >;
11109    fn r#modify_secure_heap_physical_range(
11110        &self,
11111        mut range_modification: &SecureHeapAndRangeModification,
11112    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
11113        fn _decode(
11114            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11115        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
11116            let _response = fidl::client::decode_transaction_body::<
11117                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11118                fidl::encoding::DefaultFuchsiaResourceDialect,
11119                0x154fbfa3646a890d,
11120            >(_buf?)?;
11121            Ok(_response.map(|x| x))
11122        }
11123        self.client.send_query_and_decode::<
11124            SecureMemModifySecureHeapPhysicalRangeRequest,
11125            SecureMemModifySecureHeapPhysicalRangeResult,
11126        >(
11127            (range_modification,),
11128            0x154fbfa3646a890d,
11129            fidl::encoding::DynamicFlags::empty(),
11130            _decode,
11131        )
11132    }
11133
11134    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
11135        SecureMemZeroSubRangeResult,
11136        fidl::encoding::DefaultFuchsiaResourceDialect,
11137    >;
11138    fn r#zero_sub_range(
11139        &self,
11140        mut is_covering_range_explicit: bool,
11141        mut heap_range: &SecureHeapAndRange,
11142    ) -> Self::ZeroSubRangeResponseFut {
11143        fn _decode(
11144            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11145        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
11146            let _response = fidl::client::decode_transaction_body::<
11147                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
11148                fidl::encoding::DefaultFuchsiaResourceDialect,
11149                0x7480f72bb5bc7e5b,
11150            >(_buf?)?;
11151            Ok(_response.map(|x| x))
11152        }
11153        self.client
11154            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
11155                (is_covering_range_explicit, heap_range),
11156                0x7480f72bb5bc7e5b,
11157                fidl::encoding::DynamicFlags::empty(),
11158                _decode,
11159            )
11160    }
11161}
11162
11163pub struct SecureMemEventStream {
11164    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11165}
11166
11167impl std::marker::Unpin for SecureMemEventStream {}
11168
11169impl futures::stream::FusedStream for SecureMemEventStream {
11170    fn is_terminated(&self) -> bool {
11171        self.event_receiver.is_terminated()
11172    }
11173}
11174
11175impl futures::Stream for SecureMemEventStream {
11176    type Item = Result<SecureMemEvent, fidl::Error>;
11177
11178    fn poll_next(
11179        mut self: std::pin::Pin<&mut Self>,
11180        cx: &mut std::task::Context<'_>,
11181    ) -> std::task::Poll<Option<Self::Item>> {
11182        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11183            &mut self.event_receiver,
11184            cx
11185        )?) {
11186            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
11187            None => std::task::Poll::Ready(None),
11188        }
11189    }
11190}
11191
11192#[derive(Debug)]
11193pub enum SecureMemEvent {}
11194
11195impl SecureMemEvent {
11196    /// Decodes a message buffer as a [`SecureMemEvent`].
11197    fn decode(
11198        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11199    ) -> Result<SecureMemEvent, fidl::Error> {
11200        let (bytes, _handles) = buf.split_mut();
11201        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11202        debug_assert_eq!(tx_header.tx_id, 0);
11203        match tx_header.ordinal {
11204            _ => Err(fidl::Error::UnknownOrdinal {
11205                ordinal: tx_header.ordinal,
11206                protocol_name: <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11207            }),
11208        }
11209    }
11210}
11211
11212/// A Stream of incoming requests for fuchsia.sysmem/SecureMem.
11213pub struct SecureMemRequestStream {
11214    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11215    is_terminated: bool,
11216}
11217
11218impl std::marker::Unpin for SecureMemRequestStream {}
11219
11220impl futures::stream::FusedStream for SecureMemRequestStream {
11221    fn is_terminated(&self) -> bool {
11222        self.is_terminated
11223    }
11224}
11225
11226impl fidl::endpoints::RequestStream for SecureMemRequestStream {
11227    type Protocol = SecureMemMarker;
11228    type ControlHandle = SecureMemControlHandle;
11229
11230    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11231        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11232    }
11233
11234    fn control_handle(&self) -> Self::ControlHandle {
11235        SecureMemControlHandle { inner: self.inner.clone() }
11236    }
11237
11238    fn into_inner(
11239        self,
11240    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11241    {
11242        (self.inner, self.is_terminated)
11243    }
11244
11245    fn from_inner(
11246        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11247        is_terminated: bool,
11248    ) -> Self {
11249        Self { inner, is_terminated }
11250    }
11251}
11252
11253impl futures::Stream for SecureMemRequestStream {
11254    type Item = Result<SecureMemRequest, fidl::Error>;
11255
11256    fn poll_next(
11257        mut self: std::pin::Pin<&mut Self>,
11258        cx: &mut std::task::Context<'_>,
11259    ) -> std::task::Poll<Option<Self::Item>> {
11260        let this = &mut *self;
11261        if this.inner.check_shutdown(cx) {
11262            this.is_terminated = true;
11263            return std::task::Poll::Ready(None);
11264        }
11265        if this.is_terminated {
11266            panic!("polled SecureMemRequestStream after completion");
11267        }
11268        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11269            |bytes, handles| {
11270                match this.inner.channel().read_etc(cx, bytes, handles) {
11271                    std::task::Poll::Ready(Ok(())) => {}
11272                    std::task::Poll::Pending => return std::task::Poll::Pending,
11273                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11274                        this.is_terminated = true;
11275                        return std::task::Poll::Ready(None);
11276                    }
11277                    std::task::Poll::Ready(Err(e)) => {
11278                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11279                            e.into(),
11280                        ))))
11281                    }
11282                }
11283
11284                // A message has been received from the channel
11285                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11286
11287                std::task::Poll::Ready(Some(match header.ordinal {
11288                    0x782319d6ce7fa05 => {
11289                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11290                        let mut req = fidl::new_empty!(
11291                            fidl::encoding::EmptyPayload,
11292                            fidl::encoding::DefaultFuchsiaResourceDialect
11293                        );
11294                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11295                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11296                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
11297                            responder: SecureMemGetPhysicalSecureHeapsResponder {
11298                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11299                                tx_id: header.tx_id,
11300                            },
11301                        })
11302                    }
11303                    0x26404e23f1271214 => {
11304                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11305                        let mut req = fidl::new_empty!(
11306                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11307                            fidl::encoding::DefaultFuchsiaResourceDialect
11308                        );
11309                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
11310                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11311                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
11312                            entire_heap: req.entire_heap,
11313
11314                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
11315                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11316                                tx_id: header.tx_id,
11317                            },
11318                        })
11319                    }
11320                    0x1ca1abcee8a0b33e => {
11321                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11322                        let mut req = fidl::new_empty!(
11323                            SecureMemAddSecureHeapPhysicalRangeRequest,
11324                            fidl::encoding::DefaultFuchsiaResourceDialect
11325                        );
11326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11327                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11328                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
11329                            heap_range: req.heap_range,
11330
11331                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
11332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11333                                tx_id: header.tx_id,
11334                            },
11335                        })
11336                    }
11337                    0x728a953e56df92ee => {
11338                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11339                        let mut req = fidl::new_empty!(
11340                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11341                            fidl::encoding::DefaultFuchsiaResourceDialect
11342                        );
11343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11344                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11345                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
11346                            heap_range: req.heap_range,
11347
11348                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
11349                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11350                                tx_id: header.tx_id,
11351                            },
11352                        })
11353                    }
11354                    0x154fbfa3646a890d => {
11355                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11356                        let mut req = fidl::new_empty!(
11357                            SecureMemModifySecureHeapPhysicalRangeRequest,
11358                            fidl::encoding::DefaultFuchsiaResourceDialect
11359                        );
11360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11361                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11362                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
11363                            range_modification: req.range_modification,
11364
11365                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
11366                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11367                                tx_id: header.tx_id,
11368                            },
11369                        })
11370                    }
11371                    0x7480f72bb5bc7e5b => {
11372                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11373                        let mut req = fidl::new_empty!(
11374                            SecureMemZeroSubRangeRequest,
11375                            fidl::encoding::DefaultFuchsiaResourceDialect
11376                        );
11377                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11378                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11379                        Ok(SecureMemRequest::ZeroSubRange {
11380                            is_covering_range_explicit: req.is_covering_range_explicit,
11381                            heap_range: req.heap_range,
11382
11383                            responder: SecureMemZeroSubRangeResponder {
11384                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11385                                tx_id: header.tx_id,
11386                            },
11387                        })
11388                    }
11389                    _ => Err(fidl::Error::UnknownOrdinal {
11390                        ordinal: header.ordinal,
11391                        protocol_name:
11392                            <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11393                    }),
11394                }))
11395            },
11396        )
11397    }
11398}
11399
11400/// SecureMem
11401///
11402/// The client is sysmem.  The server is securemem driver.
11403///
11404/// TEE - Trusted Execution Environment.
11405///
11406/// REE - Rich Execution Environment.
11407///
11408/// Enables sysmem to call the securemem driver to get any secure heaps
11409/// configured via the TEE (or via the securemem driver), and set any physical
11410/// secure heaps configured via sysmem.
11411///
11412/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
11413/// it starts quite early during boot and can successfully reserve contiguous
11414/// physical memory.  Presently, fixed-location secure heaps are configured via
11415/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
11416/// protocol intentionally doesn't care which heaps are dynamically-allocated
11417/// and which are fixed-location.
11418#[derive(Debug)]
11419pub enum SecureMemRequest {
11420    /// Gets the physical address and length of any secure heap whose physical
11421    /// range is configured via the TEE.
11422    ///
11423    /// Presently, these will be fixed physical addresses and lengths, with the
11424    /// location plumbed via the TEE.
11425    ///
11426    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11427    /// when there isn't any special heap-specific per-VMO setup or teardown
11428    /// required.
11429    ///
11430    /// The physical range must be secured/protected by the TEE before the
11431    /// securemem driver responds to this request with success.
11432    ///
11433    /// Sysmem should only call this once.  Returning zero heaps is not a
11434    /// failure.
11435    ///
11436    /// Errors:
11437    ///  * ZX_ERR_BAD_STATE - called more than once.
11438    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
11439    ///    with TEE which doesn't generate zx_status_t errors).
11440    ///  * other errors are allowed; any other errors should be treated the same
11441    ///    as ZX_ERR_INTERNAL.
11442    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
11443    /// This request from sysmem to the securemem driver gets the properties of
11444    /// a protected/secure heap.
11445    ///
11446    /// This only handles heaps with a single contiguous physical extent.
11447    ///
11448    /// The heap's entire physical range is indicated in case this request needs
11449    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11450    /// temporary HW protection ranges will be deleted before this request
11451    /// completes.
11452    GetPhysicalSecureHeapProperties {
11453        entire_heap: SecureHeapAndRange,
11454        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
11455    },
11456    /// This request from sysmem to the securemem driver conveys a physical
11457    /// range to add, for a heap whose physical range(s) are set up via
11458    /// sysmem.
11459    ///
11460    /// Only sysmem can call this because only sysmem is handed the client end
11461    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11462    /// securemem driver is the server end of this protocol.
11463    ///
11464    /// The securemem driver must configure all the covered offsets as protected
11465    /// before responding to this message with success.
11466    ///
11467    /// On failure, the securemem driver must ensure the protected range was not
11468    /// created.
11469    ///
11470    /// Sysmem must only call this up to once if dynamic_protection_ranges
11471    /// false.
11472    ///
11473    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11474    /// times as long as the current number of ranges never exceeds
11475    /// max_protected_range_count.
11476    ///
11477    /// The caller must not attempt to add a range that matches an
11478    /// already-existing range.  Added ranges can overlap each other as long as
11479    /// no two ranges match exactly.
11480    ///
11481    /// Errors:
11482    ///   * ZX_ERR_BAD_STATE - called more than once when
11483    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11484    ///     heap count to exceed max_protected_range_count.
11485    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11486    ///     to protected_range_granularity.
11487    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11488    ///     with TEE which doesn't generate zx_status_t errors).
11489    ///   * other errors are possible, such as from communication failures or
11490    ///     server propagation of zx_status_t failures.
11491    AddSecureHeapPhysicalRange {
11492        heap_range: SecureHeapAndRange,
11493        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
11494    },
11495    /// This request from sysmem to the securemem driver conveys a physical
11496    /// range to delete, for a heap whose physical range(s) are set up via
11497    /// sysmem.
11498    ///
11499    /// Only sysmem can call this because only sysmem is handed the client end
11500    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11501    /// securemem driver is the server end of this protocol.
11502    ///
11503    /// The securemem driver must configure all the covered offsets as not
11504    /// protected before responding to this message with success.
11505    ///
11506    /// On failure, the securemem driver must ensure the protected range was not
11507    /// deleted.
11508    ///
11509    /// Sysmem must not call this if dynamic_protection_ranges false.
11510    ///
11511    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11512    /// on various ranges that exist at the time of the call.
11513    ///
11514    /// If any portion of the range being deleted is not also covered by another
11515    /// protected range, then any ongoing DMA to any part of the entire range
11516    /// may be interrupted / may fail, potentially in a way that's disruptive to
11517    /// the entire system (bus lockup or similar, depending on device details).
11518    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11519    /// any portion of the range being deleted, unless the caller has other
11520    /// active ranges covering every block of the range being deleted.  Ongoing
11521    /// DMA to/from blocks outside the range being deleted is never impacted by
11522    /// the deletion.
11523    ///
11524    /// Errors:
11525    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11526    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11527    ///     to protected_range_granularity.
11528    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11529    ///     with TEE which doesn't generate zx_status_t errors).
11530    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11531    ///   * other errors are possible, such as from communication failures or
11532    ///     server propagation of zx_status_t failures.
11533    DeleteSecureHeapPhysicalRange {
11534        heap_range: SecureHeapAndRange,
11535        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
11536    },
11537    /// This request from sysmem to the securemem driver conveys a physical
11538    /// range to modify and its new base and length, for a heap whose physical
11539    /// range(s) are set up via sysmem.
11540    ///
11541    /// Only sysmem can call this because only sysmem is handed the client end
11542    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11543    /// securemem driver is the server end of this protocol.
11544    ///
11545    /// The securemem driver must configure the range to cover only the new
11546    /// offsets before responding to this message with success.
11547    ///
11548    /// On failure, the securemem driver must ensure the range was not changed.
11549    ///
11550    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11551    /// must not call this if !is_mod_protected_range_available.
11552    ///
11553    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11554    /// on various ranges that exist at the time of the call.
11555    ///
11556    /// The range must only be modified at one end or the other, but not both.
11557    /// If the range is getting shorter, and the un-covered blocks are not
11558    /// covered by other active ranges, any ongoing DMA to the entire range
11559    /// that's geting shorter may fail in a way that disrupts the entire system
11560    /// (bus lockup or similar), so the caller must ensure that no DMA is
11561    /// ongoing to any portion of a range that is getting shorter, unless the
11562    /// blocks being un-covered by the modification to this range are all
11563    /// covered by other active ranges, in which case no disruption to ongoing
11564    /// DMA will occur.
11565    ///
11566    /// If a range is modified to become <= zero length, the range is deleted.
11567    ///
11568    /// Errors:
11569    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11570    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
11571    ///     that doesn't conform to protected_range_granularity, or old_range
11572    ///     and new_range differ in both begin and end (disallowed).
11573    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11574    ///     with TEE which doesn't generate zx_status_t errors).
11575    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11576    ///   * other errors are possible, such as from communication failures or
11577    ///     server propagation of zx_status_t failures.
11578    ModifySecureHeapPhysicalRange {
11579        range_modification: SecureHeapAndRangeModification,
11580        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
11581    },
11582    /// Zero a sub-range of a currently-existing physical range added via
11583    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11584    /// exactly one physical range, and must not overlap with any other
11585    /// physical range.
11586    ///
11587    /// is_covering_range_explicit - When true, the covering range must be one
11588    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11589    ///     possibly modified since.  When false, the covering range must not
11590    ///     be one of the ranges explicitly created via
11591    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11592    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11593    ///     covering range is typically the entire physical range (or a range
11594    ///     which covers even more) of a heap configured by the TEE and whose
11595    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11596    ///
11597    /// Ongoing DMA is not disrupted by this request.
11598    ZeroSubRange {
11599        is_covering_range_explicit: bool,
11600        heap_range: SecureHeapAndRange,
11601        responder: SecureMemZeroSubRangeResponder,
11602    },
11603}
11604
11605impl SecureMemRequest {
11606    #[allow(irrefutable_let_patterns)]
11607    pub fn into_get_physical_secure_heaps(
11608        self,
11609    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
11610        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
11611            Some((responder))
11612        } else {
11613            None
11614        }
11615    }
11616
11617    #[allow(irrefutable_let_patterns)]
11618    pub fn into_get_physical_secure_heap_properties(
11619        self,
11620    ) -> Option<(SecureHeapAndRange, SecureMemGetPhysicalSecureHeapPropertiesResponder)> {
11621        if let SecureMemRequest::GetPhysicalSecureHeapProperties { entire_heap, responder } = self {
11622            Some((entire_heap, responder))
11623        } else {
11624            None
11625        }
11626    }
11627
11628    #[allow(irrefutable_let_patterns)]
11629    pub fn into_add_secure_heap_physical_range(
11630        self,
11631    ) -> Option<(SecureHeapAndRange, SecureMemAddSecureHeapPhysicalRangeResponder)> {
11632        if let SecureMemRequest::AddSecureHeapPhysicalRange { heap_range, responder } = self {
11633            Some((heap_range, responder))
11634        } else {
11635            None
11636        }
11637    }
11638
11639    #[allow(irrefutable_let_patterns)]
11640    pub fn into_delete_secure_heap_physical_range(
11641        self,
11642    ) -> Option<(SecureHeapAndRange, SecureMemDeleteSecureHeapPhysicalRangeResponder)> {
11643        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { heap_range, responder } = self {
11644            Some((heap_range, responder))
11645        } else {
11646            None
11647        }
11648    }
11649
11650    #[allow(irrefutable_let_patterns)]
11651    pub fn into_modify_secure_heap_physical_range(
11652        self,
11653    ) -> Option<(SecureHeapAndRangeModification, SecureMemModifySecureHeapPhysicalRangeResponder)>
11654    {
11655        if let SecureMemRequest::ModifySecureHeapPhysicalRange { range_modification, responder } =
11656            self
11657        {
11658            Some((range_modification, responder))
11659        } else {
11660            None
11661        }
11662    }
11663
11664    #[allow(irrefutable_let_patterns)]
11665    pub fn into_zero_sub_range(
11666        self,
11667    ) -> Option<(bool, SecureHeapAndRange, SecureMemZeroSubRangeResponder)> {
11668        if let SecureMemRequest::ZeroSubRange {
11669            is_covering_range_explicit,
11670            heap_range,
11671            responder,
11672        } = self
11673        {
11674            Some((is_covering_range_explicit, heap_range, responder))
11675        } else {
11676            None
11677        }
11678    }
11679
11680    /// Name of the method defined in FIDL
11681    pub fn method_name(&self) -> &'static str {
11682        match *self {
11683            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
11684            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
11685                "get_physical_secure_heap_properties"
11686            }
11687            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
11688            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
11689                "delete_secure_heap_physical_range"
11690            }
11691            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
11692                "modify_secure_heap_physical_range"
11693            }
11694            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
11695        }
11696    }
11697}
11698
11699#[derive(Debug, Clone)]
11700pub struct SecureMemControlHandle {
11701    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11702}
11703
11704impl fidl::endpoints::ControlHandle for SecureMemControlHandle {
11705    fn shutdown(&self) {
11706        self.inner.shutdown()
11707    }
11708    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11709        self.inner.shutdown_with_epitaph(status)
11710    }
11711
11712    fn is_closed(&self) -> bool {
11713        self.inner.channel().is_closed()
11714    }
11715    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11716        self.inner.channel().on_closed()
11717    }
11718
11719    #[cfg(target_os = "fuchsia")]
11720    fn signal_peer(
11721        &self,
11722        clear_mask: zx::Signals,
11723        set_mask: zx::Signals,
11724    ) -> Result<(), zx_status::Status> {
11725        use fidl::Peered;
11726        self.inner.channel().signal_peer(clear_mask, set_mask)
11727    }
11728}
11729
11730impl SecureMemControlHandle {}
11731
11732#[must_use = "FIDL methods require a response to be sent"]
11733#[derive(Debug)]
11734pub struct SecureMemGetPhysicalSecureHeapsResponder {
11735    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11736    tx_id: u32,
11737}
11738
11739/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11740/// if the responder is dropped without sending a response, so that the client
11741/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11742impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
11743    fn drop(&mut self) {
11744        self.control_handle.shutdown();
11745        // Safety: drops once, never accessed again
11746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11747    }
11748}
11749
11750impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapsResponder {
11751    type ControlHandle = SecureMemControlHandle;
11752
11753    fn control_handle(&self) -> &SecureMemControlHandle {
11754        &self.control_handle
11755    }
11756
11757    fn drop_without_shutdown(mut self) {
11758        // Safety: drops once, never accessed again due to mem::forget
11759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11760        // Prevent Drop from running (which would shut down the channel)
11761        std::mem::forget(self);
11762    }
11763}
11764
11765impl SecureMemGetPhysicalSecureHeapsResponder {
11766    /// Sends a response to the FIDL transaction.
11767    ///
11768    /// Sets the channel to shutdown if an error occurs.
11769    pub fn send(self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11770        let _result = self.send_raw(result);
11771        if _result.is_err() {
11772            self.control_handle.shutdown();
11773        }
11774        self.drop_without_shutdown();
11775        _result
11776    }
11777
11778    /// Similar to "send" but does not shutdown the channel if an error occurs.
11779    pub fn send_no_shutdown_on_err(
11780        self,
11781        mut result: Result<&SecureHeapsAndRanges, i32>,
11782    ) -> Result<(), fidl::Error> {
11783        let _result = self.send_raw(result);
11784        self.drop_without_shutdown();
11785        _result
11786    }
11787
11788    fn send_raw(&self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11789        self.control_handle.inner.send::<fidl::encoding::ResultType<
11790            SecureMemGetPhysicalSecureHeapsResponse,
11791            i32,
11792        >>(
11793            result.map(|heaps| (heaps,)),
11794            self.tx_id,
11795            0x782319d6ce7fa05,
11796            fidl::encoding::DynamicFlags::empty(),
11797        )
11798    }
11799}
11800
11801#[must_use = "FIDL methods require a response to be sent"]
11802#[derive(Debug)]
11803pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
11804    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11805    tx_id: u32,
11806}
11807
11808/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11809/// if the responder is dropped without sending a response, so that the client
11810/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11811impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11812    fn drop(&mut self) {
11813        self.control_handle.shutdown();
11814        // Safety: drops once, never accessed again
11815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11816    }
11817}
11818
11819impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11820    type ControlHandle = SecureMemControlHandle;
11821
11822    fn control_handle(&self) -> &SecureMemControlHandle {
11823        &self.control_handle
11824    }
11825
11826    fn drop_without_shutdown(mut self) {
11827        // Safety: drops once, never accessed again due to mem::forget
11828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11829        // Prevent Drop from running (which would shut down the channel)
11830        std::mem::forget(self);
11831    }
11832}
11833
11834impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
11835    /// Sends a response to the FIDL transaction.
11836    ///
11837    /// Sets the channel to shutdown if an error occurs.
11838    pub fn send(self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11839        let _result = self.send_raw(result);
11840        if _result.is_err() {
11841            self.control_handle.shutdown();
11842        }
11843        self.drop_without_shutdown();
11844        _result
11845    }
11846
11847    /// Similar to "send" but does not shutdown the channel if an error occurs.
11848    pub fn send_no_shutdown_on_err(
11849        self,
11850        mut result: Result<&SecureHeapProperties, i32>,
11851    ) -> Result<(), fidl::Error> {
11852        let _result = self.send_raw(result);
11853        self.drop_without_shutdown();
11854        _result
11855    }
11856
11857    fn send_raw(&self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11858        self.control_handle.inner.send::<fidl::encoding::ResultType<
11859            SecureMemGetPhysicalSecureHeapPropertiesResponse,
11860            i32,
11861        >>(
11862            result.map(|properties| (properties,)),
11863            self.tx_id,
11864            0x26404e23f1271214,
11865            fidl::encoding::DynamicFlags::empty(),
11866        )
11867    }
11868}
11869
11870#[must_use = "FIDL methods require a response to be sent"]
11871#[derive(Debug)]
11872pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
11873    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11874    tx_id: u32,
11875}
11876
11877/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11878/// if the responder is dropped without sending a response, so that the client
11879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11880impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
11881    fn drop(&mut self) {
11882        self.control_handle.shutdown();
11883        // Safety: drops once, never accessed again
11884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11885    }
11886}
11887
11888impl fidl::endpoints::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
11889    type ControlHandle = SecureMemControlHandle;
11890
11891    fn control_handle(&self) -> &SecureMemControlHandle {
11892        &self.control_handle
11893    }
11894
11895    fn drop_without_shutdown(mut self) {
11896        // Safety: drops once, never accessed again due to mem::forget
11897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11898        // Prevent Drop from running (which would shut down the channel)
11899        std::mem::forget(self);
11900    }
11901}
11902
11903impl SecureMemAddSecureHeapPhysicalRangeResponder {
11904    /// Sends a response to the FIDL transaction.
11905    ///
11906    /// Sets the channel to shutdown if an error occurs.
11907    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11908        let _result = self.send_raw(result);
11909        if _result.is_err() {
11910            self.control_handle.shutdown();
11911        }
11912        self.drop_without_shutdown();
11913        _result
11914    }
11915
11916    /// Similar to "send" but does not shutdown the channel if an error occurs.
11917    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11918        let _result = self.send_raw(result);
11919        self.drop_without_shutdown();
11920        _result
11921    }
11922
11923    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11924        self.control_handle
11925            .inner
11926            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11927                result,
11928                self.tx_id,
11929                0x1ca1abcee8a0b33e,
11930                fidl::encoding::DynamicFlags::empty(),
11931            )
11932    }
11933}
11934
11935#[must_use = "FIDL methods require a response to be sent"]
11936#[derive(Debug)]
11937pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
11938    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11939    tx_id: u32,
11940}
11941
11942/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11943/// if the responder is dropped without sending a response, so that the client
11944/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11945impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
11946    fn drop(&mut self) {
11947        self.control_handle.shutdown();
11948        // Safety: drops once, never accessed again
11949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11950    }
11951}
11952
11953impl fidl::endpoints::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
11954    type ControlHandle = SecureMemControlHandle;
11955
11956    fn control_handle(&self) -> &SecureMemControlHandle {
11957        &self.control_handle
11958    }
11959
11960    fn drop_without_shutdown(mut self) {
11961        // Safety: drops once, never accessed again due to mem::forget
11962        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11963        // Prevent Drop from running (which would shut down the channel)
11964        std::mem::forget(self);
11965    }
11966}
11967
11968impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
11969    /// Sends a response to the FIDL transaction.
11970    ///
11971    /// Sets the channel to shutdown if an error occurs.
11972    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11973        let _result = self.send_raw(result);
11974        if _result.is_err() {
11975            self.control_handle.shutdown();
11976        }
11977        self.drop_without_shutdown();
11978        _result
11979    }
11980
11981    /// Similar to "send" but does not shutdown the channel if an error occurs.
11982    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11983        let _result = self.send_raw(result);
11984        self.drop_without_shutdown();
11985        _result
11986    }
11987
11988    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11989        self.control_handle
11990            .inner
11991            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11992                result,
11993                self.tx_id,
11994                0x728a953e56df92ee,
11995                fidl::encoding::DynamicFlags::empty(),
11996            )
11997    }
11998}
11999
12000#[must_use = "FIDL methods require a response to be sent"]
12001#[derive(Debug)]
12002pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
12003    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12004    tx_id: u32,
12005}
12006
12007/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12008/// if the responder is dropped without sending a response, so that the client
12009/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12010impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
12011    fn drop(&mut self) {
12012        self.control_handle.shutdown();
12013        // Safety: drops once, never accessed again
12014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12015    }
12016}
12017
12018impl fidl::endpoints::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
12019    type ControlHandle = SecureMemControlHandle;
12020
12021    fn control_handle(&self) -> &SecureMemControlHandle {
12022        &self.control_handle
12023    }
12024
12025    fn drop_without_shutdown(mut self) {
12026        // Safety: drops once, never accessed again due to mem::forget
12027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12028        // Prevent Drop from running (which would shut down the channel)
12029        std::mem::forget(self);
12030    }
12031}
12032
12033impl SecureMemModifySecureHeapPhysicalRangeResponder {
12034    /// Sends a response to the FIDL transaction.
12035    ///
12036    /// Sets the channel to shutdown if an error occurs.
12037    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12038        let _result = self.send_raw(result);
12039        if _result.is_err() {
12040            self.control_handle.shutdown();
12041        }
12042        self.drop_without_shutdown();
12043        _result
12044    }
12045
12046    /// Similar to "send" but does not shutdown the channel if an error occurs.
12047    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12048        let _result = self.send_raw(result);
12049        self.drop_without_shutdown();
12050        _result
12051    }
12052
12053    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12054        self.control_handle
12055            .inner
12056            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
12057                result,
12058                self.tx_id,
12059                0x154fbfa3646a890d,
12060                fidl::encoding::DynamicFlags::empty(),
12061            )
12062    }
12063}
12064
12065#[must_use = "FIDL methods require a response to be sent"]
12066#[derive(Debug)]
12067pub struct SecureMemZeroSubRangeResponder {
12068    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12069    tx_id: u32,
12070}
12071
12072/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12073/// if the responder is dropped without sending a response, so that the client
12074/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12075impl std::ops::Drop for SecureMemZeroSubRangeResponder {
12076    fn drop(&mut self) {
12077        self.control_handle.shutdown();
12078        // Safety: drops once, never accessed again
12079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12080    }
12081}
12082
12083impl fidl::endpoints::Responder for SecureMemZeroSubRangeResponder {
12084    type ControlHandle = SecureMemControlHandle;
12085
12086    fn control_handle(&self) -> &SecureMemControlHandle {
12087        &self.control_handle
12088    }
12089
12090    fn drop_without_shutdown(mut self) {
12091        // Safety: drops once, never accessed again due to mem::forget
12092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12093        // Prevent Drop from running (which would shut down the channel)
12094        std::mem::forget(self);
12095    }
12096}
12097
12098impl SecureMemZeroSubRangeResponder {
12099    /// Sends a response to the FIDL transaction.
12100    ///
12101    /// Sets the channel to shutdown if an error occurs.
12102    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12103        let _result = self.send_raw(result);
12104        if _result.is_err() {
12105            self.control_handle.shutdown();
12106        }
12107        self.drop_without_shutdown();
12108        _result
12109    }
12110
12111    /// Similar to "send" but does not shutdown the channel if an error occurs.
12112    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12113        let _result = self.send_raw(result);
12114        self.drop_without_shutdown();
12115        _result
12116    }
12117
12118    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
12119        self.control_handle
12120            .inner
12121            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
12122                result,
12123                self.tx_id,
12124                0x7480f72bb5bc7e5b,
12125                fidl::encoding::DynamicFlags::empty(),
12126            )
12127    }
12128}
12129
12130mod internal {
12131    use super::*;
12132
12133    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
12134        type Borrowed<'a> = &'a mut Self;
12135        fn take_or_borrow<'a>(
12136            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12137        ) -> Self::Borrowed<'a> {
12138            value
12139        }
12140    }
12141
12142    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
12143        type Owned = Self;
12144
12145        #[inline(always)]
12146        fn inline_align(_context: fidl::encoding::Context) -> usize {
12147            4
12148        }
12149
12150        #[inline(always)]
12151        fn inline_size(_context: fidl::encoding::Context) -> usize {
12152            4
12153        }
12154    }
12155
12156    unsafe impl
12157        fidl::encoding::Encode<
12158            AllocatorAllocateNonSharedCollectionRequest,
12159            fidl::encoding::DefaultFuchsiaResourceDialect,
12160        > for &mut AllocatorAllocateNonSharedCollectionRequest
12161    {
12162        #[inline]
12163        unsafe fn encode(
12164            self,
12165            encoder: &mut fidl::encoding::Encoder<
12166                '_,
12167                fidl::encoding::DefaultFuchsiaResourceDialect,
12168            >,
12169            offset: usize,
12170            _depth: fidl::encoding::Depth,
12171        ) -> fidl::Result<()> {
12172            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
12173            // Delegate to tuple encoding.
12174            fidl::encoding::Encode::<AllocatorAllocateNonSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12175                (
12176                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.collection_request),
12177                ),
12178                encoder, offset, _depth
12179            )
12180        }
12181    }
12182    unsafe impl<
12183            T0: fidl::encoding::Encode<
12184                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12185                fidl::encoding::DefaultFuchsiaResourceDialect,
12186            >,
12187        >
12188        fidl::encoding::Encode<
12189            AllocatorAllocateNonSharedCollectionRequest,
12190            fidl::encoding::DefaultFuchsiaResourceDialect,
12191        > for (T0,)
12192    {
12193        #[inline]
12194        unsafe fn encode(
12195            self,
12196            encoder: &mut fidl::encoding::Encoder<
12197                '_,
12198                fidl::encoding::DefaultFuchsiaResourceDialect,
12199            >,
12200            offset: usize,
12201            depth: fidl::encoding::Depth,
12202        ) -> fidl::Result<()> {
12203            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
12204            // Zero out padding regions. There's no need to apply masks
12205            // because the unmasked parts will be overwritten by fields.
12206            // Write the fields.
12207            self.0.encode(encoder, offset + 0, depth)?;
12208            Ok(())
12209        }
12210    }
12211
12212    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12213        for AllocatorAllocateNonSharedCollectionRequest
12214    {
12215        #[inline(always)]
12216        fn new_empty() -> Self {
12217            Self {
12218                collection_request: fidl::new_empty!(
12219                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12220                    fidl::encoding::DefaultFuchsiaResourceDialect
12221                ),
12222            }
12223        }
12224
12225        #[inline]
12226        unsafe fn decode(
12227            &mut self,
12228            decoder: &mut fidl::encoding::Decoder<
12229                '_,
12230                fidl::encoding::DefaultFuchsiaResourceDialect,
12231            >,
12232            offset: usize,
12233            _depth: fidl::encoding::Depth,
12234        ) -> fidl::Result<()> {
12235            decoder.debug_check_bounds::<Self>(offset);
12236            // Verify that padding bytes are zero.
12237            fidl::decode!(
12238                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12239                fidl::encoding::DefaultFuchsiaResourceDialect,
12240                &mut self.collection_request,
12241                decoder,
12242                offset + 0,
12243                _depth
12244            )?;
12245            Ok(())
12246        }
12247    }
12248
12249    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
12250        type Borrowed<'a> = &'a mut Self;
12251        fn take_or_borrow<'a>(
12252            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12253        ) -> Self::Borrowed<'a> {
12254            value
12255        }
12256    }
12257
12258    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
12259        type Owned = Self;
12260
12261        #[inline(always)]
12262        fn inline_align(_context: fidl::encoding::Context) -> usize {
12263            4
12264        }
12265
12266        #[inline(always)]
12267        fn inline_size(_context: fidl::encoding::Context) -> usize {
12268            4
12269        }
12270    }
12271
12272    unsafe impl
12273        fidl::encoding::Encode<
12274            AllocatorAllocateSharedCollectionRequest,
12275            fidl::encoding::DefaultFuchsiaResourceDialect,
12276        > for &mut AllocatorAllocateSharedCollectionRequest
12277    {
12278        #[inline]
12279        unsafe fn encode(
12280            self,
12281            encoder: &mut fidl::encoding::Encoder<
12282                '_,
12283                fidl::encoding::DefaultFuchsiaResourceDialect,
12284            >,
12285            offset: usize,
12286            _depth: fidl::encoding::Depth,
12287        ) -> fidl::Result<()> {
12288            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12289            // Delegate to tuple encoding.
12290            fidl::encoding::Encode::<
12291                AllocatorAllocateSharedCollectionRequest,
12292                fidl::encoding::DefaultFuchsiaResourceDialect,
12293            >::encode(
12294                (
12295                    <fidl::encoding::Endpoint<
12296                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12297                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12298                        &mut self.token_request,
12299                    ),
12300                ),
12301                encoder,
12302                offset,
12303                _depth,
12304            )
12305        }
12306    }
12307    unsafe impl<
12308            T0: fidl::encoding::Encode<
12309                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12310                fidl::encoding::DefaultFuchsiaResourceDialect,
12311            >,
12312        >
12313        fidl::encoding::Encode<
12314            AllocatorAllocateSharedCollectionRequest,
12315            fidl::encoding::DefaultFuchsiaResourceDialect,
12316        > for (T0,)
12317    {
12318        #[inline]
12319        unsafe fn encode(
12320            self,
12321            encoder: &mut fidl::encoding::Encoder<
12322                '_,
12323                fidl::encoding::DefaultFuchsiaResourceDialect,
12324            >,
12325            offset: usize,
12326            depth: fidl::encoding::Depth,
12327        ) -> fidl::Result<()> {
12328            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12329            // Zero out padding regions. There's no need to apply masks
12330            // because the unmasked parts will be overwritten by fields.
12331            // Write the fields.
12332            self.0.encode(encoder, offset + 0, depth)?;
12333            Ok(())
12334        }
12335    }
12336
12337    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12338        for AllocatorAllocateSharedCollectionRequest
12339    {
12340        #[inline(always)]
12341        fn new_empty() -> Self {
12342            Self {
12343                token_request: fidl::new_empty!(
12344                    fidl::encoding::Endpoint<
12345                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12346                    >,
12347                    fidl::encoding::DefaultFuchsiaResourceDialect
12348                ),
12349            }
12350        }
12351
12352        #[inline]
12353        unsafe fn decode(
12354            &mut self,
12355            decoder: &mut fidl::encoding::Decoder<
12356                '_,
12357                fidl::encoding::DefaultFuchsiaResourceDialect,
12358            >,
12359            offset: usize,
12360            _depth: fidl::encoding::Depth,
12361        ) -> fidl::Result<()> {
12362            decoder.debug_check_bounds::<Self>(offset);
12363            // Verify that padding bytes are zero.
12364            fidl::decode!(
12365                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12366                fidl::encoding::DefaultFuchsiaResourceDialect,
12367                &mut self.token_request,
12368                decoder,
12369                offset + 0,
12370                _depth
12371            )?;
12372            Ok(())
12373        }
12374    }
12375
12376    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
12377        type Borrowed<'a> = &'a mut Self;
12378        fn take_or_borrow<'a>(
12379            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12380        ) -> Self::Borrowed<'a> {
12381            value
12382        }
12383    }
12384
12385    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
12386        type Owned = Self;
12387
12388        #[inline(always)]
12389        fn inline_align(_context: fidl::encoding::Context) -> usize {
12390            4
12391        }
12392
12393        #[inline(always)]
12394        fn inline_size(_context: fidl::encoding::Context) -> usize {
12395            8
12396        }
12397    }
12398
12399    unsafe impl
12400        fidl::encoding::Encode<
12401            AllocatorBindSharedCollectionRequest,
12402            fidl::encoding::DefaultFuchsiaResourceDialect,
12403        > for &mut AllocatorBindSharedCollectionRequest
12404    {
12405        #[inline]
12406        unsafe fn encode(
12407            self,
12408            encoder: &mut fidl::encoding::Encoder<
12409                '_,
12410                fidl::encoding::DefaultFuchsiaResourceDialect,
12411            >,
12412            offset: usize,
12413            _depth: fidl::encoding::Depth,
12414        ) -> fidl::Result<()> {
12415            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12416            // Delegate to tuple encoding.
12417            fidl::encoding::Encode::<AllocatorBindSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12418                (
12419                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
12420                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer_collection_request),
12421                ),
12422                encoder, offset, _depth
12423            )
12424        }
12425    }
12426    unsafe impl<
12427            T0: fidl::encoding::Encode<
12428                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12429                fidl::encoding::DefaultFuchsiaResourceDialect,
12430            >,
12431            T1: fidl::encoding::Encode<
12432                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12433                fidl::encoding::DefaultFuchsiaResourceDialect,
12434            >,
12435        >
12436        fidl::encoding::Encode<
12437            AllocatorBindSharedCollectionRequest,
12438            fidl::encoding::DefaultFuchsiaResourceDialect,
12439        > for (T0, T1)
12440    {
12441        #[inline]
12442        unsafe fn encode(
12443            self,
12444            encoder: &mut fidl::encoding::Encoder<
12445                '_,
12446                fidl::encoding::DefaultFuchsiaResourceDialect,
12447            >,
12448            offset: usize,
12449            depth: fidl::encoding::Depth,
12450        ) -> fidl::Result<()> {
12451            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12452            // Zero out padding regions. There's no need to apply masks
12453            // because the unmasked parts will be overwritten by fields.
12454            // Write the fields.
12455            self.0.encode(encoder, offset + 0, depth)?;
12456            self.1.encode(encoder, offset + 4, depth)?;
12457            Ok(())
12458        }
12459    }
12460
12461    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12462        for AllocatorBindSharedCollectionRequest
12463    {
12464        #[inline(always)]
12465        fn new_empty() -> Self {
12466            Self {
12467                token: fidl::new_empty!(
12468                    fidl::encoding::Endpoint<
12469                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
12470                    >,
12471                    fidl::encoding::DefaultFuchsiaResourceDialect
12472                ),
12473                buffer_collection_request: fidl::new_empty!(
12474                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12475                    fidl::encoding::DefaultFuchsiaResourceDialect
12476                ),
12477            }
12478        }
12479
12480        #[inline]
12481        unsafe fn decode(
12482            &mut self,
12483            decoder: &mut fidl::encoding::Decoder<
12484                '_,
12485                fidl::encoding::DefaultFuchsiaResourceDialect,
12486            >,
12487            offset: usize,
12488            _depth: fidl::encoding::Depth,
12489        ) -> fidl::Result<()> {
12490            decoder.debug_check_bounds::<Self>(offset);
12491            // Verify that padding bytes are zero.
12492            fidl::decode!(
12493                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12494                fidl::encoding::DefaultFuchsiaResourceDialect,
12495                &mut self.token,
12496                decoder,
12497                offset + 0,
12498                _depth
12499            )?;
12500            fidl::decode!(
12501                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12502                fidl::encoding::DefaultFuchsiaResourceDialect,
12503                &mut self.buffer_collection_request,
12504                decoder,
12505                offset + 4,
12506                _depth
12507            )?;
12508            Ok(())
12509        }
12510    }
12511
12512    impl fidl::encoding::ResourceTypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12513        type Borrowed<'a> = &'a mut Self;
12514        fn take_or_borrow<'a>(
12515            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12516        ) -> Self::Borrowed<'a> {
12517            value
12518        }
12519    }
12520
12521    unsafe impl fidl::encoding::TypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12522        type Owned = Self;
12523
12524        #[inline(always)]
12525        fn inline_align(_context: fidl::encoding::Context) -> usize {
12526            4
12527        }
12528
12529        #[inline(always)]
12530        fn inline_size(_context: fidl::encoding::Context) -> usize {
12531            4
12532        }
12533    }
12534
12535    unsafe impl
12536        fidl::encoding::Encode<
12537            AllocatorConnectToSysmem2AllocatorRequest,
12538            fidl::encoding::DefaultFuchsiaResourceDialect,
12539        > for &mut AllocatorConnectToSysmem2AllocatorRequest
12540    {
12541        #[inline]
12542        unsafe fn encode(
12543            self,
12544            encoder: &mut fidl::encoding::Encoder<
12545                '_,
12546                fidl::encoding::DefaultFuchsiaResourceDialect,
12547            >,
12548            offset: usize,
12549            _depth: fidl::encoding::Depth,
12550        ) -> fidl::Result<()> {
12551            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12552            // Delegate to tuple encoding.
12553            fidl::encoding::Encode::<
12554                AllocatorConnectToSysmem2AllocatorRequest,
12555                fidl::encoding::DefaultFuchsiaResourceDialect,
12556            >::encode(
12557                (<fidl::encoding::Endpoint<
12558                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12559                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12560                    &mut self.allocator_request,
12561                ),),
12562                encoder,
12563                offset,
12564                _depth,
12565            )
12566        }
12567    }
12568    unsafe impl<
12569            T0: fidl::encoding::Encode<
12570                fidl::encoding::Endpoint<
12571                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12572                >,
12573                fidl::encoding::DefaultFuchsiaResourceDialect,
12574            >,
12575        >
12576        fidl::encoding::Encode<
12577            AllocatorConnectToSysmem2AllocatorRequest,
12578            fidl::encoding::DefaultFuchsiaResourceDialect,
12579        > for (T0,)
12580    {
12581        #[inline]
12582        unsafe fn encode(
12583            self,
12584            encoder: &mut fidl::encoding::Encoder<
12585                '_,
12586                fidl::encoding::DefaultFuchsiaResourceDialect,
12587            >,
12588            offset: usize,
12589            depth: fidl::encoding::Depth,
12590        ) -> fidl::Result<()> {
12591            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12592            // Zero out padding regions. There's no need to apply masks
12593            // because the unmasked parts will be overwritten by fields.
12594            // Write the fields.
12595            self.0.encode(encoder, offset + 0, depth)?;
12596            Ok(())
12597        }
12598    }
12599
12600    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12601        for AllocatorConnectToSysmem2AllocatorRequest
12602    {
12603        #[inline(always)]
12604        fn new_empty() -> Self {
12605            Self {
12606                allocator_request: fidl::new_empty!(
12607                    fidl::encoding::Endpoint<
12608                        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12609                    >,
12610                    fidl::encoding::DefaultFuchsiaResourceDialect
12611                ),
12612            }
12613        }
12614
12615        #[inline]
12616        unsafe fn decode(
12617            &mut self,
12618            decoder: &mut fidl::encoding::Decoder<
12619                '_,
12620                fidl::encoding::DefaultFuchsiaResourceDialect,
12621            >,
12622            offset: usize,
12623            _depth: fidl::encoding::Depth,
12624        ) -> fidl::Result<()> {
12625            decoder.debug_check_bounds::<Self>(offset);
12626            // Verify that padding bytes are zero.
12627            fidl::decode!(
12628                fidl::encoding::Endpoint<
12629                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12630                >,
12631                fidl::encoding::DefaultFuchsiaResourceDialect,
12632                &mut self.allocator_request,
12633                decoder,
12634                offset + 0,
12635                _depth
12636            )?;
12637            Ok(())
12638        }
12639    }
12640
12641    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12642        type Borrowed<'a> = &'a mut Self;
12643        fn take_or_borrow<'a>(
12644            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12645        ) -> Self::Borrowed<'a> {
12646            value
12647        }
12648    }
12649
12650    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12651        type Owned = Self;
12652
12653        #[inline(always)]
12654        fn inline_align(_context: fidl::encoding::Context) -> usize {
12655            4
12656        }
12657
12658        #[inline(always)]
12659        fn inline_size(_context: fidl::encoding::Context) -> usize {
12660            8
12661        }
12662    }
12663
12664    unsafe impl
12665        fidl::encoding::Encode<
12666            BufferCollectionAttachLifetimeTrackingRequest,
12667            fidl::encoding::DefaultFuchsiaResourceDialect,
12668        > for &mut BufferCollectionAttachLifetimeTrackingRequest
12669    {
12670        #[inline]
12671        unsafe fn encode(
12672            self,
12673            encoder: &mut fidl::encoding::Encoder<
12674                '_,
12675                fidl::encoding::DefaultFuchsiaResourceDialect,
12676            >,
12677            offset: usize,
12678            _depth: fidl::encoding::Depth,
12679        ) -> fidl::Result<()> {
12680            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12681            // Delegate to tuple encoding.
12682            fidl::encoding::Encode::<
12683                BufferCollectionAttachLifetimeTrackingRequest,
12684                fidl::encoding::DefaultFuchsiaResourceDialect,
12685            >::encode(
12686                (
12687                    <fidl::encoding::HandleType<
12688                        fidl::EventPair,
12689                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12690                        2147483648,
12691                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12692                        &mut self.server_end
12693                    ),
12694                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffers_remaining),
12695                ),
12696                encoder,
12697                offset,
12698                _depth,
12699            )
12700        }
12701    }
12702    unsafe impl<
12703            T0: fidl::encoding::Encode<
12704                fidl::encoding::HandleType<
12705                    fidl::EventPair,
12706                    { fidl::ObjectType::EVENTPAIR.into_raw() },
12707                    2147483648,
12708                >,
12709                fidl::encoding::DefaultFuchsiaResourceDialect,
12710            >,
12711            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12712        >
12713        fidl::encoding::Encode<
12714            BufferCollectionAttachLifetimeTrackingRequest,
12715            fidl::encoding::DefaultFuchsiaResourceDialect,
12716        > for (T0, T1)
12717    {
12718        #[inline]
12719        unsafe fn encode(
12720            self,
12721            encoder: &mut fidl::encoding::Encoder<
12722                '_,
12723                fidl::encoding::DefaultFuchsiaResourceDialect,
12724            >,
12725            offset: usize,
12726            depth: fidl::encoding::Depth,
12727        ) -> fidl::Result<()> {
12728            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12729            // Zero out padding regions. There's no need to apply masks
12730            // because the unmasked parts will be overwritten by fields.
12731            // Write the fields.
12732            self.0.encode(encoder, offset + 0, depth)?;
12733            self.1.encode(encoder, offset + 4, depth)?;
12734            Ok(())
12735        }
12736    }
12737
12738    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12739        for BufferCollectionAttachLifetimeTrackingRequest
12740    {
12741        #[inline(always)]
12742        fn new_empty() -> Self {
12743            Self {
12744                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12745                buffers_remaining: fidl::new_empty!(
12746                    u32,
12747                    fidl::encoding::DefaultFuchsiaResourceDialect
12748                ),
12749            }
12750        }
12751
12752        #[inline]
12753        unsafe fn decode(
12754            &mut self,
12755            decoder: &mut fidl::encoding::Decoder<
12756                '_,
12757                fidl::encoding::DefaultFuchsiaResourceDialect,
12758            >,
12759            offset: usize,
12760            _depth: fidl::encoding::Depth,
12761        ) -> fidl::Result<()> {
12762            decoder.debug_check_bounds::<Self>(offset);
12763            // Verify that padding bytes are zero.
12764            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 0, _depth)?;
12765            fidl::decode!(
12766                u32,
12767                fidl::encoding::DefaultFuchsiaResourceDialect,
12768                &mut self.buffers_remaining,
12769                decoder,
12770                offset + 4,
12771                _depth
12772            )?;
12773            Ok(())
12774        }
12775    }
12776
12777    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
12778        type Borrowed<'a> = &'a mut Self;
12779        fn take_or_borrow<'a>(
12780            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12781        ) -> Self::Borrowed<'a> {
12782            value
12783        }
12784    }
12785
12786    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
12787        type Owned = Self;
12788
12789        #[inline(always)]
12790        fn inline_align(_context: fidl::encoding::Context) -> usize {
12791            4
12792        }
12793
12794        #[inline(always)]
12795        fn inline_size(_context: fidl::encoding::Context) -> usize {
12796            8
12797        }
12798    }
12799
12800    unsafe impl
12801        fidl::encoding::Encode<
12802            BufferCollectionAttachTokenRequest,
12803            fidl::encoding::DefaultFuchsiaResourceDialect,
12804        > for &mut BufferCollectionAttachTokenRequest
12805    {
12806        #[inline]
12807        unsafe fn encode(
12808            self,
12809            encoder: &mut fidl::encoding::Encoder<
12810                '_,
12811                fidl::encoding::DefaultFuchsiaResourceDialect,
12812            >,
12813            offset: usize,
12814            _depth: fidl::encoding::Depth,
12815        ) -> fidl::Result<()> {
12816            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12817            // Delegate to tuple encoding.
12818            fidl::encoding::Encode::<
12819                BufferCollectionAttachTokenRequest,
12820                fidl::encoding::DefaultFuchsiaResourceDialect,
12821            >::encode(
12822                (
12823                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
12824                    <fidl::encoding::Endpoint<
12825                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12826                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12827                        &mut self.token_request,
12828                    ),
12829                ),
12830                encoder,
12831                offset,
12832                _depth,
12833            )
12834        }
12835    }
12836    unsafe impl<
12837            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12838            T1: fidl::encoding::Encode<
12839                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12840                fidl::encoding::DefaultFuchsiaResourceDialect,
12841            >,
12842        >
12843        fidl::encoding::Encode<
12844            BufferCollectionAttachTokenRequest,
12845            fidl::encoding::DefaultFuchsiaResourceDialect,
12846        > for (T0, T1)
12847    {
12848        #[inline]
12849        unsafe fn encode(
12850            self,
12851            encoder: &mut fidl::encoding::Encoder<
12852                '_,
12853                fidl::encoding::DefaultFuchsiaResourceDialect,
12854            >,
12855            offset: usize,
12856            depth: fidl::encoding::Depth,
12857        ) -> fidl::Result<()> {
12858            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12859            // Zero out padding regions. There's no need to apply masks
12860            // because the unmasked parts will be overwritten by fields.
12861            // Write the fields.
12862            self.0.encode(encoder, offset + 0, depth)?;
12863            self.1.encode(encoder, offset + 4, depth)?;
12864            Ok(())
12865        }
12866    }
12867
12868    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12869        for BufferCollectionAttachTokenRequest
12870    {
12871        #[inline(always)]
12872        fn new_empty() -> Self {
12873            Self {
12874                rights_attenuation_mask: fidl::new_empty!(
12875                    u32,
12876                    fidl::encoding::DefaultFuchsiaResourceDialect
12877                ),
12878                token_request: fidl::new_empty!(
12879                    fidl::encoding::Endpoint<
12880                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12881                    >,
12882                    fidl::encoding::DefaultFuchsiaResourceDialect
12883                ),
12884            }
12885        }
12886
12887        #[inline]
12888        unsafe fn decode(
12889            &mut self,
12890            decoder: &mut fidl::encoding::Decoder<
12891                '_,
12892                fidl::encoding::DefaultFuchsiaResourceDialect,
12893            >,
12894            offset: usize,
12895            _depth: fidl::encoding::Depth,
12896        ) -> fidl::Result<()> {
12897            decoder.debug_check_bounds::<Self>(offset);
12898            // Verify that padding bytes are zero.
12899            fidl::decode!(
12900                u32,
12901                fidl::encoding::DefaultFuchsiaResourceDialect,
12902                &mut self.rights_attenuation_mask,
12903                decoder,
12904                offset + 0,
12905                _depth
12906            )?;
12907            fidl::decode!(
12908                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12909                fidl::encoding::DefaultFuchsiaResourceDialect,
12910                &mut self.token_request,
12911                decoder,
12912                offset + 4,
12913                _depth
12914            )?;
12915            Ok(())
12916        }
12917    }
12918
12919    impl fidl::encoding::ResourceTypeMarker for BufferCollectionGetAuxBuffersResponse {
12920        type Borrowed<'a> = &'a mut Self;
12921        fn take_or_borrow<'a>(
12922            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12923        ) -> Self::Borrowed<'a> {
12924            value
12925        }
12926    }
12927
12928    unsafe impl fidl::encoding::TypeMarker for BufferCollectionGetAuxBuffersResponse {
12929        type Owned = Self;
12930
12931        #[inline(always)]
12932        fn inline_align(_context: fidl::encoding::Context) -> usize {
12933            8
12934        }
12935
12936        #[inline(always)]
12937        fn inline_size(_context: fidl::encoding::Context) -> usize {
12938            1304
12939        }
12940    }
12941
12942    unsafe impl
12943        fidl::encoding::Encode<
12944            BufferCollectionGetAuxBuffersResponse,
12945            fidl::encoding::DefaultFuchsiaResourceDialect,
12946        > for &mut BufferCollectionGetAuxBuffersResponse
12947    {
12948        #[inline]
12949        unsafe fn encode(
12950            self,
12951            encoder: &mut fidl::encoding::Encoder<
12952                '_,
12953                fidl::encoding::DefaultFuchsiaResourceDialect,
12954            >,
12955            offset: usize,
12956            _depth: fidl::encoding::Depth,
12957        ) -> fidl::Result<()> {
12958            encoder.debug_check_bounds::<BufferCollectionGetAuxBuffersResponse>(offset);
12959            // Delegate to tuple encoding.
12960            fidl::encoding::Encode::<
12961                BufferCollectionGetAuxBuffersResponse,
12962                fidl::encoding::DefaultFuchsiaResourceDialect,
12963            >::encode(
12964                (
12965                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
12966                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12967                        &mut self.buffer_collection_info_aux_buffers,
12968                    ),
12969                ),
12970                encoder,
12971                offset,
12972                _depth,
12973            )
12974        }
12975    }
12976    unsafe impl<
12977            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12978            T1: fidl::encoding::Encode<
12979                BufferCollectionInfo2,
12980                fidl::encoding::DefaultFuchsiaResourceDialect,
12981            >,
12982        >
12983        fidl::encoding::Encode<
12984            BufferCollectionGetAuxBuffersResponse,
12985            fidl::encoding::DefaultFuchsiaResourceDialect,
12986        > for (T0, T1)
12987    {
12988        #[inline]
12989        unsafe fn encode(
12990            self,
12991            encoder: &mut fidl::encoding::Encoder<
12992                '_,
12993                fidl::encoding::DefaultFuchsiaResourceDialect,
12994            >,
12995            offset: usize,
12996            depth: fidl::encoding::Depth,
12997        ) -> fidl::Result<()> {
12998            encoder.debug_check_bounds::<BufferCollectionGetAuxBuffersResponse>(offset);
12999            // Zero out padding regions. There's no need to apply masks
13000            // because the unmasked parts will be overwritten by fields.
13001            unsafe {
13002                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13003                (ptr as *mut u64).write_unaligned(0);
13004            }
13005            // Write the fields.
13006            self.0.encode(encoder, offset + 0, depth)?;
13007            self.1.encode(encoder, offset + 8, depth)?;
13008            Ok(())
13009        }
13010    }
13011
13012    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13013        for BufferCollectionGetAuxBuffersResponse
13014    {
13015        #[inline(always)]
13016        fn new_empty() -> Self {
13017            Self {
13018                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
13019                buffer_collection_info_aux_buffers: fidl::new_empty!(
13020                    BufferCollectionInfo2,
13021                    fidl::encoding::DefaultFuchsiaResourceDialect
13022                ),
13023            }
13024        }
13025
13026        #[inline]
13027        unsafe fn decode(
13028            &mut self,
13029            decoder: &mut fidl::encoding::Decoder<
13030                '_,
13031                fidl::encoding::DefaultFuchsiaResourceDialect,
13032            >,
13033            offset: usize,
13034            _depth: fidl::encoding::Depth,
13035        ) -> fidl::Result<()> {
13036            decoder.debug_check_bounds::<Self>(offset);
13037            // Verify that padding bytes are zero.
13038            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13039            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13040            let mask = 0xffffffff00000000u64;
13041            let maskedval = padval & mask;
13042            if maskedval != 0 {
13043                return Err(fidl::Error::NonZeroPadding {
13044                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13045                });
13046            }
13047            fidl::decode!(
13048                i32,
13049                fidl::encoding::DefaultFuchsiaResourceDialect,
13050                &mut self.status,
13051                decoder,
13052                offset + 0,
13053                _depth
13054            )?;
13055            fidl::decode!(
13056                BufferCollectionInfo2,
13057                fidl::encoding::DefaultFuchsiaResourceDialect,
13058                &mut self.buffer_collection_info_aux_buffers,
13059                decoder,
13060                offset + 8,
13061                _depth
13062            )?;
13063            Ok(())
13064        }
13065    }
13066
13067    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
13068        type Borrowed<'a> = &'a mut Self;
13069        fn take_or_borrow<'a>(
13070            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13071        ) -> Self::Borrowed<'a> {
13072            value
13073        }
13074    }
13075
13076    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
13077        type Owned = Self;
13078
13079        #[inline(always)]
13080        fn inline_align(_context: fidl::encoding::Context) -> usize {
13081            8
13082        }
13083
13084        #[inline(always)]
13085        fn inline_size(_context: fidl::encoding::Context) -> usize {
13086            352
13087        }
13088    }
13089
13090    unsafe impl
13091        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
13092        for &mut BufferCollectionInfo
13093    {
13094        #[inline]
13095        unsafe fn encode(
13096            self,
13097            encoder: &mut fidl::encoding::Encoder<
13098                '_,
13099                fidl::encoding::DefaultFuchsiaResourceDialect,
13100            >,
13101            offset: usize,
13102            _depth: fidl::encoding::Depth,
13103        ) -> fidl::Result<()> {
13104            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
13105            // Delegate to tuple encoding.
13106            fidl::encoding::Encode::<
13107                BufferCollectionInfo,
13108                fidl::encoding::DefaultFuchsiaResourceDialect,
13109            >::encode(
13110                (
13111                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
13112                    <BufferFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
13113                    <fidl::encoding::Array<
13114                        fidl::encoding::Optional<
13115                            fidl::encoding::HandleType<
13116                                fidl::Vmo,
13117                                { fidl::ObjectType::VMO.into_raw() },
13118                                2147483648,
13119                            >,
13120                        >,
13121                        64,
13122                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13123                        &mut self.vmos
13124                    ),
13125                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_size),
13126                ),
13127                encoder,
13128                offset,
13129                _depth,
13130            )
13131        }
13132    }
13133    unsafe impl<
13134            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13135            T1: fidl::encoding::Encode<BufferFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
13136            T2: fidl::encoding::Encode<
13137                fidl::encoding::Array<
13138                    fidl::encoding::Optional<
13139                        fidl::encoding::HandleType<
13140                            fidl::Vmo,
13141                            { fidl::ObjectType::VMO.into_raw() },
13142                            2147483648,
13143                        >,
13144                    >,
13145                    64,
13146                >,
13147                fidl::encoding::DefaultFuchsiaResourceDialect,
13148            >,
13149            T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
13150        >
13151        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
13152        for (T0, T1, T2, T3)
13153    {
13154        #[inline]
13155        unsafe fn encode(
13156            self,
13157            encoder: &mut fidl::encoding::Encoder<
13158                '_,
13159                fidl::encoding::DefaultFuchsiaResourceDialect,
13160            >,
13161            offset: usize,
13162            depth: fidl::encoding::Depth,
13163        ) -> fidl::Result<()> {
13164            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
13165            // Zero out padding regions. There's no need to apply masks
13166            // because the unmasked parts will be overwritten by fields.
13167            unsafe {
13168                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13169                (ptr as *mut u64).write_unaligned(0);
13170            }
13171            // Write the fields.
13172            self.0.encode(encoder, offset + 0, depth)?;
13173            self.1.encode(encoder, offset + 8, depth)?;
13174            self.2.encode(encoder, offset + 88, depth)?;
13175            self.3.encode(encoder, offset + 344, depth)?;
13176            Ok(())
13177        }
13178    }
13179
13180    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13181        for BufferCollectionInfo
13182    {
13183        #[inline(always)]
13184        fn new_empty() -> Self {
13185            Self {
13186                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13187                format: fidl::new_empty!(
13188                    BufferFormat,
13189                    fidl::encoding::DefaultFuchsiaResourceDialect
13190                ),
13191                vmos: fidl::new_empty!(
13192                    fidl::encoding::Array<
13193                        fidl::encoding::Optional<
13194                            fidl::encoding::HandleType<
13195                                fidl::Vmo,
13196                                { fidl::ObjectType::VMO.into_raw() },
13197                                2147483648,
13198                            >,
13199                        >,
13200                        64,
13201                    >,
13202                    fidl::encoding::DefaultFuchsiaResourceDialect
13203                ),
13204                vmo_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
13205            }
13206        }
13207
13208        #[inline]
13209        unsafe fn decode(
13210            &mut self,
13211            decoder: &mut fidl::encoding::Decoder<
13212                '_,
13213                fidl::encoding::DefaultFuchsiaResourceDialect,
13214            >,
13215            offset: usize,
13216            _depth: fidl::encoding::Depth,
13217        ) -> fidl::Result<()> {
13218            decoder.debug_check_bounds::<Self>(offset);
13219            // Verify that padding bytes are zero.
13220            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13221            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13222            let mask = 0xffffffff00000000u64;
13223            let maskedval = padval & mask;
13224            if maskedval != 0 {
13225                return Err(fidl::Error::NonZeroPadding {
13226                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13227                });
13228            }
13229            fidl::decode!(
13230                u32,
13231                fidl::encoding::DefaultFuchsiaResourceDialect,
13232                &mut self.buffer_count,
13233                decoder,
13234                offset + 0,
13235                _depth
13236            )?;
13237            fidl::decode!(
13238                BufferFormat,
13239                fidl::encoding::DefaultFuchsiaResourceDialect,
13240                &mut self.format,
13241                decoder,
13242                offset + 8,
13243                _depth
13244            )?;
13245            fidl::decode!(
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                &mut self.vmos,
13258                decoder,
13259                offset + 88,
13260                _depth
13261            )?;
13262            fidl::decode!(
13263                u64,
13264                fidl::encoding::DefaultFuchsiaResourceDialect,
13265                &mut self.vmo_size,
13266                decoder,
13267                offset + 344,
13268                _depth
13269            )?;
13270            Ok(())
13271        }
13272    }
13273
13274    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo2 {
13275        type Borrowed<'a> = &'a mut Self;
13276        fn take_or_borrow<'a>(
13277            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13278        ) -> Self::Borrowed<'a> {
13279            value
13280        }
13281    }
13282
13283    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo2 {
13284        type Owned = Self;
13285
13286        #[inline(always)]
13287        fn inline_align(_context: fidl::encoding::Context) -> usize {
13288            8
13289        }
13290
13291        #[inline(always)]
13292        fn inline_size(_context: fidl::encoding::Context) -> usize {
13293            1296
13294        }
13295    }
13296
13297    unsafe impl
13298        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
13299        for &mut BufferCollectionInfo2
13300    {
13301        #[inline]
13302        unsafe fn encode(
13303            self,
13304            encoder: &mut fidl::encoding::Encoder<
13305                '_,
13306                fidl::encoding::DefaultFuchsiaResourceDialect,
13307            >,
13308            offset: usize,
13309            _depth: fidl::encoding::Depth,
13310        ) -> fidl::Result<()> {
13311            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
13312            // Delegate to tuple encoding.
13313            fidl::encoding::Encode::<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13314                (
13315                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
13316                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
13317                    <fidl::encoding::Array<VmoBuffer, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
13318                ),
13319                encoder, offset, _depth
13320            )
13321        }
13322    }
13323    unsafe impl<
13324            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13325            T1: fidl::encoding::Encode<
13326                SingleBufferSettings,
13327                fidl::encoding::DefaultFuchsiaResourceDialect,
13328            >,
13329            T2: fidl::encoding::Encode<
13330                fidl::encoding::Array<VmoBuffer, 64>,
13331                fidl::encoding::DefaultFuchsiaResourceDialect,
13332            >,
13333        >
13334        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
13335        for (T0, T1, T2)
13336    {
13337        #[inline]
13338        unsafe fn encode(
13339            self,
13340            encoder: &mut fidl::encoding::Encoder<
13341                '_,
13342                fidl::encoding::DefaultFuchsiaResourceDialect,
13343            >,
13344            offset: usize,
13345            depth: fidl::encoding::Depth,
13346        ) -> fidl::Result<()> {
13347            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
13348            // Zero out padding regions. There's no need to apply masks
13349            // because the unmasked parts will be overwritten by fields.
13350            unsafe {
13351                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13352                (ptr as *mut u64).write_unaligned(0);
13353            }
13354            // Write the fields.
13355            self.0.encode(encoder, offset + 0, depth)?;
13356            self.1.encode(encoder, offset + 8, depth)?;
13357            self.2.encode(encoder, offset + 272, depth)?;
13358            Ok(())
13359        }
13360    }
13361
13362    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13363        for BufferCollectionInfo2
13364    {
13365        #[inline(always)]
13366        fn new_empty() -> Self {
13367            Self {
13368                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13369                settings: fidl::new_empty!(
13370                    SingleBufferSettings,
13371                    fidl::encoding::DefaultFuchsiaResourceDialect
13372                ),
13373                buffers: fidl::new_empty!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
13374            }
13375        }
13376
13377        #[inline]
13378        unsafe fn decode(
13379            &mut self,
13380            decoder: &mut fidl::encoding::Decoder<
13381                '_,
13382                fidl::encoding::DefaultFuchsiaResourceDialect,
13383            >,
13384            offset: usize,
13385            _depth: fidl::encoding::Depth,
13386        ) -> fidl::Result<()> {
13387            decoder.debug_check_bounds::<Self>(offset);
13388            // Verify that padding bytes are zero.
13389            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13390            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13391            let mask = 0xffffffff00000000u64;
13392            let maskedval = padval & mask;
13393            if maskedval != 0 {
13394                return Err(fidl::Error::NonZeroPadding {
13395                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13396                });
13397            }
13398            fidl::decode!(
13399                u32,
13400                fidl::encoding::DefaultFuchsiaResourceDialect,
13401                &mut self.buffer_count,
13402                decoder,
13403                offset + 0,
13404                _depth
13405            )?;
13406            fidl::decode!(
13407                SingleBufferSettings,
13408                fidl::encoding::DefaultFuchsiaResourceDialect,
13409                &mut self.settings,
13410                decoder,
13411                offset + 8,
13412                _depth
13413            )?;
13414            fidl::decode!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffers, decoder, offset + 272, _depth)?;
13415            Ok(())
13416        }
13417    }
13418
13419    impl fidl::encoding::ResourceTypeMarker
13420        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13421    {
13422        type Borrowed<'a> = &'a mut Self;
13423        fn take_or_borrow<'a>(
13424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13425        ) -> Self::Borrowed<'a> {
13426            value
13427        }
13428    }
13429
13430    unsafe impl fidl::encoding::TypeMarker
13431        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13432    {
13433        type Owned = Self;
13434
13435        #[inline(always)]
13436        fn inline_align(_context: fidl::encoding::Context) -> usize {
13437            4
13438        }
13439
13440        #[inline(always)]
13441        fn inline_size(_context: fidl::encoding::Context) -> usize {
13442            4
13443        }
13444    }
13445
13446    unsafe impl
13447        fidl::encoding::Encode<
13448            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13449            fidl::encoding::DefaultFuchsiaResourceDialect,
13450        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13451    {
13452        #[inline]
13453        unsafe fn encode(
13454            self,
13455            encoder: &mut fidl::encoding::Encoder<
13456                '_,
13457                fidl::encoding::DefaultFuchsiaResourceDialect,
13458            >,
13459            offset: usize,
13460            _depth: fidl::encoding::Depth,
13461        ) -> fidl::Result<()> {
13462            encoder
13463                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13464                    offset,
13465                );
13466            // Delegate to tuple encoding.
13467            fidl::encoding::Encode::<
13468                BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13469                fidl::encoding::DefaultFuchsiaResourceDialect,
13470            >::encode(
13471                (<fidl::encoding::Endpoint<
13472                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13473                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13474                    &mut self.group_request
13475                ),),
13476                encoder,
13477                offset,
13478                _depth,
13479            )
13480        }
13481    }
13482    unsafe impl<
13483            T0: fidl::encoding::Encode<
13484                fidl::encoding::Endpoint<
13485                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13486                >,
13487                fidl::encoding::DefaultFuchsiaResourceDialect,
13488            >,
13489        >
13490        fidl::encoding::Encode<
13491            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13492            fidl::encoding::DefaultFuchsiaResourceDialect,
13493        > for (T0,)
13494    {
13495        #[inline]
13496        unsafe fn encode(
13497            self,
13498            encoder: &mut fidl::encoding::Encoder<
13499                '_,
13500                fidl::encoding::DefaultFuchsiaResourceDialect,
13501            >,
13502            offset: usize,
13503            depth: fidl::encoding::Depth,
13504        ) -> fidl::Result<()> {
13505            encoder
13506                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13507                    offset,
13508                );
13509            // Zero out padding regions. There's no need to apply masks
13510            // because the unmasked parts will be overwritten by fields.
13511            // Write the fields.
13512            self.0.encode(encoder, offset + 0, depth)?;
13513            Ok(())
13514        }
13515    }
13516
13517    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13518        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13519    {
13520        #[inline(always)]
13521        fn new_empty() -> Self {
13522            Self {
13523                group_request: fidl::new_empty!(
13524                    fidl::encoding::Endpoint<
13525                        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13526                    >,
13527                    fidl::encoding::DefaultFuchsiaResourceDialect
13528                ),
13529            }
13530        }
13531
13532        #[inline]
13533        unsafe fn decode(
13534            &mut self,
13535            decoder: &mut fidl::encoding::Decoder<
13536                '_,
13537                fidl::encoding::DefaultFuchsiaResourceDialect,
13538            >,
13539            offset: usize,
13540            _depth: fidl::encoding::Depth,
13541        ) -> fidl::Result<()> {
13542            decoder.debug_check_bounds::<Self>(offset);
13543            // Verify that padding bytes are zero.
13544            fidl::decode!(
13545                fidl::encoding::Endpoint<
13546                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13547                >,
13548                fidl::encoding::DefaultFuchsiaResourceDialect,
13549                &mut self.group_request,
13550                decoder,
13551                offset + 0,
13552                _depth
13553            )?;
13554            Ok(())
13555        }
13556    }
13557
13558    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
13559        type Borrowed<'a> = &'a mut Self;
13560        fn take_or_borrow<'a>(
13561            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13562        ) -> Self::Borrowed<'a> {
13563            value
13564        }
13565    }
13566
13567    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
13568        type Owned = Self;
13569
13570        #[inline(always)]
13571        fn inline_align(_context: fidl::encoding::Context) -> usize {
13572            4
13573        }
13574
13575        #[inline(always)]
13576        fn inline_size(_context: fidl::encoding::Context) -> usize {
13577            8
13578        }
13579    }
13580
13581    unsafe impl
13582        fidl::encoding::Encode<
13583            BufferCollectionTokenDuplicateRequest,
13584            fidl::encoding::DefaultFuchsiaResourceDialect,
13585        > for &mut BufferCollectionTokenDuplicateRequest
13586    {
13587        #[inline]
13588        unsafe fn encode(
13589            self,
13590            encoder: &mut fidl::encoding::Encoder<
13591                '_,
13592                fidl::encoding::DefaultFuchsiaResourceDialect,
13593            >,
13594            offset: usize,
13595            _depth: fidl::encoding::Depth,
13596        ) -> fidl::Result<()> {
13597            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13598            // Delegate to tuple encoding.
13599            fidl::encoding::Encode::<
13600                BufferCollectionTokenDuplicateRequest,
13601                fidl::encoding::DefaultFuchsiaResourceDialect,
13602            >::encode(
13603                (
13604                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
13605                    <fidl::encoding::Endpoint<
13606                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13607                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13608                        &mut self.token_request,
13609                    ),
13610                ),
13611                encoder,
13612                offset,
13613                _depth,
13614            )
13615        }
13616    }
13617    unsafe impl<
13618            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13619            T1: fidl::encoding::Encode<
13620                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13621                fidl::encoding::DefaultFuchsiaResourceDialect,
13622            >,
13623        >
13624        fidl::encoding::Encode<
13625            BufferCollectionTokenDuplicateRequest,
13626            fidl::encoding::DefaultFuchsiaResourceDialect,
13627        > for (T0, T1)
13628    {
13629        #[inline]
13630        unsafe fn encode(
13631            self,
13632            encoder: &mut fidl::encoding::Encoder<
13633                '_,
13634                fidl::encoding::DefaultFuchsiaResourceDialect,
13635            >,
13636            offset: usize,
13637            depth: fidl::encoding::Depth,
13638        ) -> fidl::Result<()> {
13639            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13640            // Zero out padding regions. There's no need to apply masks
13641            // because the unmasked parts will be overwritten by fields.
13642            // Write the fields.
13643            self.0.encode(encoder, offset + 0, depth)?;
13644            self.1.encode(encoder, offset + 4, depth)?;
13645            Ok(())
13646        }
13647    }
13648
13649    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13650        for BufferCollectionTokenDuplicateRequest
13651    {
13652        #[inline(always)]
13653        fn new_empty() -> Self {
13654            Self {
13655                rights_attenuation_mask: fidl::new_empty!(
13656                    u32,
13657                    fidl::encoding::DefaultFuchsiaResourceDialect
13658                ),
13659                token_request: fidl::new_empty!(
13660                    fidl::encoding::Endpoint<
13661                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13662                    >,
13663                    fidl::encoding::DefaultFuchsiaResourceDialect
13664                ),
13665            }
13666        }
13667
13668        #[inline]
13669        unsafe fn decode(
13670            &mut self,
13671            decoder: &mut fidl::encoding::Decoder<
13672                '_,
13673                fidl::encoding::DefaultFuchsiaResourceDialect,
13674            >,
13675            offset: usize,
13676            _depth: fidl::encoding::Depth,
13677        ) -> fidl::Result<()> {
13678            decoder.debug_check_bounds::<Self>(offset);
13679            // Verify that padding bytes are zero.
13680            fidl::decode!(
13681                u32,
13682                fidl::encoding::DefaultFuchsiaResourceDialect,
13683                &mut self.rights_attenuation_mask,
13684                decoder,
13685                offset + 0,
13686                _depth
13687            )?;
13688            fidl::decode!(
13689                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13690                fidl::encoding::DefaultFuchsiaResourceDialect,
13691                &mut self.token_request,
13692                decoder,
13693                offset + 4,
13694                _depth
13695            )?;
13696            Ok(())
13697        }
13698    }
13699
13700    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13701        type Borrowed<'a> = &'a mut Self;
13702        fn take_or_borrow<'a>(
13703            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13704        ) -> Self::Borrowed<'a> {
13705            value
13706        }
13707    }
13708
13709    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13710        type Owned = Self;
13711
13712        #[inline(always)]
13713        fn inline_align(_context: fidl::encoding::Context) -> usize {
13714            8
13715        }
13716
13717        #[inline(always)]
13718        fn inline_size(_context: fidl::encoding::Context) -> usize {
13719            16
13720        }
13721    }
13722
13723    unsafe impl
13724        fidl::encoding::Encode<
13725            BufferCollectionTokenDuplicateSyncResponse,
13726            fidl::encoding::DefaultFuchsiaResourceDialect,
13727        > for &mut BufferCollectionTokenDuplicateSyncResponse
13728    {
13729        #[inline]
13730        unsafe fn encode(
13731            self,
13732            encoder: &mut fidl::encoding::Encoder<
13733                '_,
13734                fidl::encoding::DefaultFuchsiaResourceDialect,
13735            >,
13736            offset: usize,
13737            _depth: fidl::encoding::Depth,
13738        ) -> fidl::Result<()> {
13739            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13740            // Delegate to tuple encoding.
13741            fidl::encoding::Encode::<
13742                BufferCollectionTokenDuplicateSyncResponse,
13743                fidl::encoding::DefaultFuchsiaResourceDialect,
13744            >::encode(
13745                (<fidl::encoding::Vector<
13746                    fidl::encoding::Endpoint<
13747                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13748                    >,
13749                    64,
13750                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13751                    &mut self.tokens
13752                ),),
13753                encoder,
13754                offset,
13755                _depth,
13756            )
13757        }
13758    }
13759    unsafe impl<
13760            T0: fidl::encoding::Encode<
13761                fidl::encoding::Vector<
13762                    fidl::encoding::Endpoint<
13763                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13764                    >,
13765                    64,
13766                >,
13767                fidl::encoding::DefaultFuchsiaResourceDialect,
13768            >,
13769        >
13770        fidl::encoding::Encode<
13771            BufferCollectionTokenDuplicateSyncResponse,
13772            fidl::encoding::DefaultFuchsiaResourceDialect,
13773        > for (T0,)
13774    {
13775        #[inline]
13776        unsafe fn encode(
13777            self,
13778            encoder: &mut fidl::encoding::Encoder<
13779                '_,
13780                fidl::encoding::DefaultFuchsiaResourceDialect,
13781            >,
13782            offset: usize,
13783            depth: fidl::encoding::Depth,
13784        ) -> fidl::Result<()> {
13785            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13786            // Zero out padding regions. There's no need to apply masks
13787            // because the unmasked parts will be overwritten by fields.
13788            // Write the fields.
13789            self.0.encode(encoder, offset + 0, depth)?;
13790            Ok(())
13791        }
13792    }
13793
13794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13795        for BufferCollectionTokenDuplicateSyncResponse
13796    {
13797        #[inline(always)]
13798        fn new_empty() -> Self {
13799            Self {
13800                tokens: fidl::new_empty!(
13801                    fidl::encoding::Vector<
13802                        fidl::encoding::Endpoint<
13803                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13804                        >,
13805                        64,
13806                    >,
13807                    fidl::encoding::DefaultFuchsiaResourceDialect
13808                ),
13809            }
13810        }
13811
13812        #[inline]
13813        unsafe fn decode(
13814            &mut self,
13815            decoder: &mut fidl::encoding::Decoder<
13816                '_,
13817                fidl::encoding::DefaultFuchsiaResourceDialect,
13818            >,
13819            offset: usize,
13820            _depth: fidl::encoding::Depth,
13821        ) -> fidl::Result<()> {
13822            decoder.debug_check_bounds::<Self>(offset);
13823            // Verify that padding bytes are zero.
13824            fidl::decode!(
13825                fidl::encoding::Vector<
13826                    fidl::encoding::Endpoint<
13827                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13828                    >,
13829                    64,
13830                >,
13831                fidl::encoding::DefaultFuchsiaResourceDialect,
13832                &mut self.tokens,
13833                decoder,
13834                offset + 0,
13835                _depth
13836            )?;
13837            Ok(())
13838        }
13839    }
13840
13841    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13842        type Borrowed<'a> = &'a mut Self;
13843        fn take_or_borrow<'a>(
13844            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13845        ) -> Self::Borrowed<'a> {
13846            value
13847        }
13848    }
13849
13850    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13851        type Owned = Self;
13852
13853        #[inline(always)]
13854        fn inline_align(_context: fidl::encoding::Context) -> usize {
13855            8
13856        }
13857
13858        #[inline(always)]
13859        fn inline_size(_context: fidl::encoding::Context) -> usize {
13860            16
13861        }
13862    }
13863
13864    unsafe impl
13865        fidl::encoding::Encode<
13866            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13867            fidl::encoding::DefaultFuchsiaResourceDialect,
13868        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
13869    {
13870        #[inline]
13871        unsafe fn encode(
13872            self,
13873            encoder: &mut fidl::encoding::Encoder<
13874                '_,
13875                fidl::encoding::DefaultFuchsiaResourceDialect,
13876            >,
13877            offset: usize,
13878            _depth: fidl::encoding::Depth,
13879        ) -> fidl::Result<()> {
13880            encoder
13881                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13882            // Delegate to tuple encoding.
13883            fidl::encoding::Encode::<
13884                BufferCollectionTokenGroupCreateChildrenSyncResponse,
13885                fidl::encoding::DefaultFuchsiaResourceDialect,
13886            >::encode(
13887                (<fidl::encoding::Vector<
13888                    fidl::encoding::Endpoint<
13889                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13890                    >,
13891                    64,
13892                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13893                    &mut self.tokens
13894                ),),
13895                encoder,
13896                offset,
13897                _depth,
13898            )
13899        }
13900    }
13901    unsafe impl<
13902            T0: fidl::encoding::Encode<
13903                fidl::encoding::Vector<
13904                    fidl::encoding::Endpoint<
13905                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13906                    >,
13907                    64,
13908                >,
13909                fidl::encoding::DefaultFuchsiaResourceDialect,
13910            >,
13911        >
13912        fidl::encoding::Encode<
13913            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13914            fidl::encoding::DefaultFuchsiaResourceDialect,
13915        > for (T0,)
13916    {
13917        #[inline]
13918        unsafe fn encode(
13919            self,
13920            encoder: &mut fidl::encoding::Encoder<
13921                '_,
13922                fidl::encoding::DefaultFuchsiaResourceDialect,
13923            >,
13924            offset: usize,
13925            depth: fidl::encoding::Depth,
13926        ) -> fidl::Result<()> {
13927            encoder
13928                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13929            // Zero out padding regions. There's no need to apply masks
13930            // because the unmasked parts will be overwritten by fields.
13931            // Write the fields.
13932            self.0.encode(encoder, offset + 0, depth)?;
13933            Ok(())
13934        }
13935    }
13936
13937    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13938        for BufferCollectionTokenGroupCreateChildrenSyncResponse
13939    {
13940        #[inline(always)]
13941        fn new_empty() -> Self {
13942            Self {
13943                tokens: fidl::new_empty!(
13944                    fidl::encoding::Vector<
13945                        fidl::encoding::Endpoint<
13946                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13947                        >,
13948                        64,
13949                    >,
13950                    fidl::encoding::DefaultFuchsiaResourceDialect
13951                ),
13952            }
13953        }
13954
13955        #[inline]
13956        unsafe fn decode(
13957            &mut self,
13958            decoder: &mut fidl::encoding::Decoder<
13959                '_,
13960                fidl::encoding::DefaultFuchsiaResourceDialect,
13961            >,
13962            offset: usize,
13963            _depth: fidl::encoding::Depth,
13964        ) -> fidl::Result<()> {
13965            decoder.debug_check_bounds::<Self>(offset);
13966            // Verify that padding bytes are zero.
13967            fidl::decode!(
13968                fidl::encoding::Vector<
13969                    fidl::encoding::Endpoint<
13970                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13971                    >,
13972                    64,
13973                >,
13974                fidl::encoding::DefaultFuchsiaResourceDialect,
13975                &mut self.tokens,
13976                decoder,
13977                offset + 0,
13978                _depth
13979            )?;
13980            Ok(())
13981        }
13982    }
13983
13984    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
13985        type Borrowed<'a> = &'a mut Self;
13986        fn take_or_borrow<'a>(
13987            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13988        ) -> Self::Borrowed<'a> {
13989            value
13990        }
13991    }
13992
13993    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
13994        type Owned = Self;
13995
13996        #[inline(always)]
13997        fn inline_align(_context: fidl::encoding::Context) -> usize {
13998            8
13999        }
14000
14001        #[inline(always)]
14002        fn inline_size(_context: fidl::encoding::Context) -> usize {
14003            1304
14004        }
14005    }
14006
14007    unsafe impl
14008        fidl::encoding::Encode<
14009            BufferCollectionWaitForBuffersAllocatedResponse,
14010            fidl::encoding::DefaultFuchsiaResourceDialect,
14011        > for &mut BufferCollectionWaitForBuffersAllocatedResponse
14012    {
14013        #[inline]
14014        unsafe fn encode(
14015            self,
14016            encoder: &mut fidl::encoding::Encoder<
14017                '_,
14018                fidl::encoding::DefaultFuchsiaResourceDialect,
14019            >,
14020            offset: usize,
14021            _depth: fidl::encoding::Depth,
14022        ) -> fidl::Result<()> {
14023            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
14024            // Delegate to tuple encoding.
14025            fidl::encoding::Encode::<
14026                BufferCollectionWaitForBuffersAllocatedResponse,
14027                fidl::encoding::DefaultFuchsiaResourceDialect,
14028            >::encode(
14029                (
14030                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
14031                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14032                        &mut self.buffer_collection_info,
14033                    ),
14034                ),
14035                encoder,
14036                offset,
14037                _depth,
14038            )
14039        }
14040    }
14041    unsafe impl<
14042            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
14043            T1: fidl::encoding::Encode<
14044                BufferCollectionInfo2,
14045                fidl::encoding::DefaultFuchsiaResourceDialect,
14046            >,
14047        >
14048        fidl::encoding::Encode<
14049            BufferCollectionWaitForBuffersAllocatedResponse,
14050            fidl::encoding::DefaultFuchsiaResourceDialect,
14051        > for (T0, T1)
14052    {
14053        #[inline]
14054        unsafe fn encode(
14055            self,
14056            encoder: &mut fidl::encoding::Encoder<
14057                '_,
14058                fidl::encoding::DefaultFuchsiaResourceDialect,
14059            >,
14060            offset: usize,
14061            depth: fidl::encoding::Depth,
14062        ) -> fidl::Result<()> {
14063            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
14064            // Zero out padding regions. There's no need to apply masks
14065            // because the unmasked parts will be overwritten by fields.
14066            unsafe {
14067                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14068                (ptr as *mut u64).write_unaligned(0);
14069            }
14070            // Write the fields.
14071            self.0.encode(encoder, offset + 0, depth)?;
14072            self.1.encode(encoder, offset + 8, depth)?;
14073            Ok(())
14074        }
14075    }
14076
14077    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14078        for BufferCollectionWaitForBuffersAllocatedResponse
14079    {
14080        #[inline(always)]
14081        fn new_empty() -> Self {
14082            Self {
14083                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
14084                buffer_collection_info: fidl::new_empty!(
14085                    BufferCollectionInfo2,
14086                    fidl::encoding::DefaultFuchsiaResourceDialect
14087                ),
14088            }
14089        }
14090
14091        #[inline]
14092        unsafe fn decode(
14093            &mut self,
14094            decoder: &mut fidl::encoding::Decoder<
14095                '_,
14096                fidl::encoding::DefaultFuchsiaResourceDialect,
14097            >,
14098            offset: usize,
14099            _depth: fidl::encoding::Depth,
14100        ) -> fidl::Result<()> {
14101            decoder.debug_check_bounds::<Self>(offset);
14102            // Verify that padding bytes are zero.
14103            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14104            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14105            let mask = 0xffffffff00000000u64;
14106            let maskedval = padval & mask;
14107            if maskedval != 0 {
14108                return Err(fidl::Error::NonZeroPadding {
14109                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14110                });
14111            }
14112            fidl::decode!(
14113                i32,
14114                fidl::encoding::DefaultFuchsiaResourceDialect,
14115                &mut self.status,
14116                decoder,
14117                offset + 0,
14118                _depth
14119            )?;
14120            fidl::decode!(
14121                BufferCollectionInfo2,
14122                fidl::encoding::DefaultFuchsiaResourceDialect,
14123                &mut self.buffer_collection_info,
14124                decoder,
14125                offset + 8,
14126                _depth
14127            )?;
14128            Ok(())
14129        }
14130    }
14131
14132    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
14133        type Borrowed<'a> = &'a mut Self;
14134        fn take_or_borrow<'a>(
14135            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14136        ) -> Self::Borrowed<'a> {
14137            value
14138        }
14139    }
14140
14141    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
14142        type Owned = Self;
14143
14144        #[inline(always)]
14145        fn inline_align(_context: fidl::encoding::Context) -> usize {
14146            4
14147        }
14148
14149        #[inline(always)]
14150        fn inline_size(_context: fidl::encoding::Context) -> usize {
14151            4
14152        }
14153    }
14154
14155    unsafe impl
14156        fidl::encoding::Encode<
14157            NodeGetNodeRefResponse,
14158            fidl::encoding::DefaultFuchsiaResourceDialect,
14159        > for &mut NodeGetNodeRefResponse
14160    {
14161        #[inline]
14162        unsafe fn encode(
14163            self,
14164            encoder: &mut fidl::encoding::Encoder<
14165                '_,
14166                fidl::encoding::DefaultFuchsiaResourceDialect,
14167            >,
14168            offset: usize,
14169            _depth: fidl::encoding::Depth,
14170        ) -> fidl::Result<()> {
14171            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
14172            // Delegate to tuple encoding.
14173            fidl::encoding::Encode::<
14174                NodeGetNodeRefResponse,
14175                fidl::encoding::DefaultFuchsiaResourceDialect,
14176            >::encode(
14177                (<fidl::encoding::HandleType<
14178                    fidl::Event,
14179                    { fidl::ObjectType::EVENT.into_raw() },
14180                    2147483648,
14181                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14182                    &mut self.node_ref
14183                ),),
14184                encoder,
14185                offset,
14186                _depth,
14187            )
14188        }
14189    }
14190    unsafe impl<
14191            T0: fidl::encoding::Encode<
14192                fidl::encoding::HandleType<
14193                    fidl::Event,
14194                    { fidl::ObjectType::EVENT.into_raw() },
14195                    2147483648,
14196                >,
14197                fidl::encoding::DefaultFuchsiaResourceDialect,
14198            >,
14199        >
14200        fidl::encoding::Encode<
14201            NodeGetNodeRefResponse,
14202            fidl::encoding::DefaultFuchsiaResourceDialect,
14203        > for (T0,)
14204    {
14205        #[inline]
14206        unsafe fn encode(
14207            self,
14208            encoder: &mut fidl::encoding::Encoder<
14209                '_,
14210                fidl::encoding::DefaultFuchsiaResourceDialect,
14211            >,
14212            offset: usize,
14213            depth: fidl::encoding::Depth,
14214        ) -> fidl::Result<()> {
14215            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
14216            // Zero out padding regions. There's no need to apply masks
14217            // because the unmasked parts will be overwritten by fields.
14218            // Write the fields.
14219            self.0.encode(encoder, offset + 0, depth)?;
14220            Ok(())
14221        }
14222    }
14223
14224    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14225        for NodeGetNodeRefResponse
14226    {
14227        #[inline(always)]
14228        fn new_empty() -> Self {
14229            Self {
14230                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14231            }
14232        }
14233
14234        #[inline]
14235        unsafe fn decode(
14236            &mut self,
14237            decoder: &mut fidl::encoding::Decoder<
14238                '_,
14239                fidl::encoding::DefaultFuchsiaResourceDialect,
14240            >,
14241            offset: usize,
14242            _depth: fidl::encoding::Depth,
14243        ) -> fidl::Result<()> {
14244            decoder.debug_check_bounds::<Self>(offset);
14245            // Verify that padding bytes are zero.
14246            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
14247            Ok(())
14248        }
14249    }
14250
14251    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
14252        type Borrowed<'a> = &'a mut Self;
14253        fn take_or_borrow<'a>(
14254            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14255        ) -> Self::Borrowed<'a> {
14256            value
14257        }
14258    }
14259
14260    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
14261        type Owned = Self;
14262
14263        #[inline(always)]
14264        fn inline_align(_context: fidl::encoding::Context) -> usize {
14265            4
14266        }
14267
14268        #[inline(always)]
14269        fn inline_size(_context: fidl::encoding::Context) -> usize {
14270            4
14271        }
14272    }
14273
14274    unsafe impl
14275        fidl::encoding::Encode<
14276            NodeIsAlternateForRequest,
14277            fidl::encoding::DefaultFuchsiaResourceDialect,
14278        > for &mut NodeIsAlternateForRequest
14279    {
14280        #[inline]
14281        unsafe fn encode(
14282            self,
14283            encoder: &mut fidl::encoding::Encoder<
14284                '_,
14285                fidl::encoding::DefaultFuchsiaResourceDialect,
14286            >,
14287            offset: usize,
14288            _depth: fidl::encoding::Depth,
14289        ) -> fidl::Result<()> {
14290            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
14291            // Delegate to tuple encoding.
14292            fidl::encoding::Encode::<
14293                NodeIsAlternateForRequest,
14294                fidl::encoding::DefaultFuchsiaResourceDialect,
14295            >::encode(
14296                (<fidl::encoding::HandleType<
14297                    fidl::Event,
14298                    { fidl::ObjectType::EVENT.into_raw() },
14299                    2147483648,
14300                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14301                    &mut self.node_ref
14302                ),),
14303                encoder,
14304                offset,
14305                _depth,
14306            )
14307        }
14308    }
14309    unsafe impl<
14310            T0: fidl::encoding::Encode<
14311                fidl::encoding::HandleType<
14312                    fidl::Event,
14313                    { fidl::ObjectType::EVENT.into_raw() },
14314                    2147483648,
14315                >,
14316                fidl::encoding::DefaultFuchsiaResourceDialect,
14317            >,
14318        >
14319        fidl::encoding::Encode<
14320            NodeIsAlternateForRequest,
14321            fidl::encoding::DefaultFuchsiaResourceDialect,
14322        > for (T0,)
14323    {
14324        #[inline]
14325        unsafe fn encode(
14326            self,
14327            encoder: &mut fidl::encoding::Encoder<
14328                '_,
14329                fidl::encoding::DefaultFuchsiaResourceDialect,
14330            >,
14331            offset: usize,
14332            depth: fidl::encoding::Depth,
14333        ) -> fidl::Result<()> {
14334            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
14335            // Zero out padding regions. There's no need to apply masks
14336            // because the unmasked parts will be overwritten by fields.
14337            // Write the fields.
14338            self.0.encode(encoder, offset + 0, depth)?;
14339            Ok(())
14340        }
14341    }
14342
14343    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14344        for NodeIsAlternateForRequest
14345    {
14346        #[inline(always)]
14347        fn new_empty() -> Self {
14348            Self {
14349                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14350            }
14351        }
14352
14353        #[inline]
14354        unsafe fn decode(
14355            &mut self,
14356            decoder: &mut fidl::encoding::Decoder<
14357                '_,
14358                fidl::encoding::DefaultFuchsiaResourceDialect,
14359            >,
14360            offset: usize,
14361            _depth: fidl::encoding::Depth,
14362        ) -> fidl::Result<()> {
14363            decoder.debug_check_bounds::<Self>(offset);
14364            // Verify that padding bytes are zero.
14365            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
14366            Ok(())
14367        }
14368    }
14369
14370    impl fidl::encoding::ResourceTypeMarker for SingleBufferInfo {
14371        type Borrowed<'a> = &'a mut Self;
14372        fn take_or_borrow<'a>(
14373            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14374        ) -> Self::Borrowed<'a> {
14375            value
14376        }
14377    }
14378
14379    unsafe impl fidl::encoding::TypeMarker for SingleBufferInfo {
14380        type Owned = Self;
14381
14382        #[inline(always)]
14383        fn inline_align(_context: fidl::encoding::Context) -> usize {
14384            8
14385        }
14386
14387        #[inline(always)]
14388        fn inline_size(_context: fidl::encoding::Context) -> usize {
14389            280
14390        }
14391    }
14392
14393    unsafe impl
14394        fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14395        for &mut SingleBufferInfo
14396    {
14397        #[inline]
14398        unsafe fn encode(
14399            self,
14400            encoder: &mut fidl::encoding::Encoder<
14401                '_,
14402                fidl::encoding::DefaultFuchsiaResourceDialect,
14403            >,
14404            offset: usize,
14405            _depth: fidl::encoding::Depth,
14406        ) -> fidl::Result<()> {
14407            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14408            // Delegate to tuple encoding.
14409            fidl::encoding::Encode::<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14410                (
14411                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
14412                    <VmoBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
14413                ),
14414                encoder, offset, _depth
14415            )
14416        }
14417    }
14418    unsafe impl<
14419            T0: fidl::encoding::Encode<
14420                SingleBufferSettings,
14421                fidl::encoding::DefaultFuchsiaResourceDialect,
14422            >,
14423            T1: fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>,
14424        >
14425        fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14426        for (T0, T1)
14427    {
14428        #[inline]
14429        unsafe fn encode(
14430            self,
14431            encoder: &mut fidl::encoding::Encoder<
14432                '_,
14433                fidl::encoding::DefaultFuchsiaResourceDialect,
14434            >,
14435            offset: usize,
14436            depth: fidl::encoding::Depth,
14437        ) -> fidl::Result<()> {
14438            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14439            // Zero out padding regions. There's no need to apply masks
14440            // because the unmasked parts will be overwritten by fields.
14441            // Write the fields.
14442            self.0.encode(encoder, offset + 0, depth)?;
14443            self.1.encode(encoder, offset + 264, depth)?;
14444            Ok(())
14445        }
14446    }
14447
14448    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14449        for SingleBufferInfo
14450    {
14451        #[inline(always)]
14452        fn new_empty() -> Self {
14453            Self {
14454                settings: fidl::new_empty!(
14455                    SingleBufferSettings,
14456                    fidl::encoding::DefaultFuchsiaResourceDialect
14457                ),
14458                buffer: fidl::new_empty!(VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect),
14459            }
14460        }
14461
14462        #[inline]
14463        unsafe fn decode(
14464            &mut self,
14465            decoder: &mut fidl::encoding::Decoder<
14466                '_,
14467                fidl::encoding::DefaultFuchsiaResourceDialect,
14468            >,
14469            offset: usize,
14470            _depth: fidl::encoding::Depth,
14471        ) -> fidl::Result<()> {
14472            decoder.debug_check_bounds::<Self>(offset);
14473            // Verify that padding bytes are zero.
14474            fidl::decode!(
14475                SingleBufferSettings,
14476                fidl::encoding::DefaultFuchsiaResourceDialect,
14477                &mut self.settings,
14478                decoder,
14479                offset + 0,
14480                _depth
14481            )?;
14482            fidl::decode!(
14483                VmoBuffer,
14484                fidl::encoding::DefaultFuchsiaResourceDialect,
14485                &mut self.buffer,
14486                decoder,
14487                offset + 264,
14488                _depth
14489            )?;
14490            Ok(())
14491        }
14492    }
14493
14494    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
14495        type Borrowed<'a> = &'a mut Self;
14496        fn take_or_borrow<'a>(
14497            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14498        ) -> Self::Borrowed<'a> {
14499            value
14500        }
14501    }
14502
14503    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
14504        type Owned = Self;
14505
14506        #[inline(always)]
14507        fn inline_align(_context: fidl::encoding::Context) -> usize {
14508            8
14509        }
14510
14511        #[inline(always)]
14512        fn inline_size(_context: fidl::encoding::Context) -> usize {
14513            16
14514        }
14515    }
14516
14517    unsafe impl fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14518        for &mut VmoBuffer
14519    {
14520        #[inline]
14521        unsafe fn encode(
14522            self,
14523            encoder: &mut fidl::encoding::Encoder<
14524                '_,
14525                fidl::encoding::DefaultFuchsiaResourceDialect,
14526            >,
14527            offset: usize,
14528            _depth: fidl::encoding::Depth,
14529        ) -> fidl::Result<()> {
14530            encoder.debug_check_bounds::<VmoBuffer>(offset);
14531            // Delegate to tuple encoding.
14532            fidl::encoding::Encode::<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14533                (
14534                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
14535                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_usable_start),
14536                ),
14537                encoder, offset, _depth
14538            )
14539        }
14540    }
14541    unsafe impl<
14542            T0: fidl::encoding::Encode<
14543                fidl::encoding::Optional<
14544                    fidl::encoding::HandleType<
14545                        fidl::Vmo,
14546                        { fidl::ObjectType::VMO.into_raw() },
14547                        2147483648,
14548                    >,
14549                >,
14550                fidl::encoding::DefaultFuchsiaResourceDialect,
14551            >,
14552            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
14553        > fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14554        for (T0, T1)
14555    {
14556        #[inline]
14557        unsafe fn encode(
14558            self,
14559            encoder: &mut fidl::encoding::Encoder<
14560                '_,
14561                fidl::encoding::DefaultFuchsiaResourceDialect,
14562            >,
14563            offset: usize,
14564            depth: fidl::encoding::Depth,
14565        ) -> fidl::Result<()> {
14566            encoder.debug_check_bounds::<VmoBuffer>(offset);
14567            // Zero out padding regions. There's no need to apply masks
14568            // because the unmasked parts will be overwritten by fields.
14569            unsafe {
14570                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14571                (ptr as *mut u64).write_unaligned(0);
14572            }
14573            // Write the fields.
14574            self.0.encode(encoder, offset + 0, depth)?;
14575            self.1.encode(encoder, offset + 8, depth)?;
14576            Ok(())
14577        }
14578    }
14579
14580    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoBuffer {
14581        #[inline(always)]
14582        fn new_empty() -> Self {
14583            Self {
14584                vmo: fidl::new_empty!(
14585                    fidl::encoding::Optional<
14586                        fidl::encoding::HandleType<
14587                            fidl::Vmo,
14588                            { fidl::ObjectType::VMO.into_raw() },
14589                            2147483648,
14590                        >,
14591                    >,
14592                    fidl::encoding::DefaultFuchsiaResourceDialect
14593                ),
14594                vmo_usable_start: fidl::new_empty!(
14595                    u64,
14596                    fidl::encoding::DefaultFuchsiaResourceDialect
14597                ),
14598            }
14599        }
14600
14601        #[inline]
14602        unsafe fn decode(
14603            &mut self,
14604            decoder: &mut fidl::encoding::Decoder<
14605                '_,
14606                fidl::encoding::DefaultFuchsiaResourceDialect,
14607            >,
14608            offset: usize,
14609            _depth: fidl::encoding::Depth,
14610        ) -> fidl::Result<()> {
14611            decoder.debug_check_bounds::<Self>(offset);
14612            // Verify that padding bytes are zero.
14613            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14614            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14615            let mask = 0xffffffff00000000u64;
14616            let maskedval = padval & mask;
14617            if maskedval != 0 {
14618                return Err(fidl::Error::NonZeroPadding {
14619                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14620                });
14621            }
14622            fidl::decode!(
14623                fidl::encoding::Optional<
14624                    fidl::encoding::HandleType<
14625                        fidl::Vmo,
14626                        { fidl::ObjectType::VMO.into_raw() },
14627                        2147483648,
14628                    >,
14629                >,
14630                fidl::encoding::DefaultFuchsiaResourceDialect,
14631                &mut self.vmo,
14632                decoder,
14633                offset + 0,
14634                _depth
14635            )?;
14636            fidl::decode!(
14637                u64,
14638                fidl::encoding::DefaultFuchsiaResourceDialect,
14639                &mut self.vmo_usable_start,
14640                decoder,
14641                offset + 8,
14642                _depth
14643            )?;
14644            Ok(())
14645        }
14646    }
14647
14648    impl BufferCollectionTokenGroupCreateChildRequest {
14649        #[inline(always)]
14650        fn max_ordinal_present(&self) -> u64 {
14651            if let Some(_) = self.rights_attenuation_mask {
14652                return 2;
14653            }
14654            if let Some(_) = self.token_request {
14655                return 1;
14656            }
14657            0
14658        }
14659    }
14660
14661    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14662        type Borrowed<'a> = &'a mut Self;
14663        fn take_or_borrow<'a>(
14664            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14665        ) -> Self::Borrowed<'a> {
14666            value
14667        }
14668    }
14669
14670    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14671        type Owned = Self;
14672
14673        #[inline(always)]
14674        fn inline_align(_context: fidl::encoding::Context) -> usize {
14675            8
14676        }
14677
14678        #[inline(always)]
14679        fn inline_size(_context: fidl::encoding::Context) -> usize {
14680            16
14681        }
14682    }
14683
14684    unsafe impl
14685        fidl::encoding::Encode<
14686            BufferCollectionTokenGroupCreateChildRequest,
14687            fidl::encoding::DefaultFuchsiaResourceDialect,
14688        > for &mut BufferCollectionTokenGroupCreateChildRequest
14689    {
14690        unsafe fn encode(
14691            self,
14692            encoder: &mut fidl::encoding::Encoder<
14693                '_,
14694                fidl::encoding::DefaultFuchsiaResourceDialect,
14695            >,
14696            offset: usize,
14697            mut depth: fidl::encoding::Depth,
14698        ) -> fidl::Result<()> {
14699            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
14700            // Vector header
14701            let max_ordinal: u64 = self.max_ordinal_present();
14702            encoder.write_num(max_ordinal, offset);
14703            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14704            // Calling encoder.out_of_line_offset(0) is not allowed.
14705            if max_ordinal == 0 {
14706                return Ok(());
14707            }
14708            depth.increment()?;
14709            let envelope_size = 8;
14710            let bytes_len = max_ordinal as usize * envelope_size;
14711            #[allow(unused_variables)]
14712            let offset = encoder.out_of_line_offset(bytes_len);
14713            let mut _prev_end_offset: usize = 0;
14714            if 1 > max_ordinal {
14715                return Ok(());
14716            }
14717
14718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14719            // are envelope_size bytes.
14720            let cur_offset: usize = (1 - 1) * envelope_size;
14721
14722            // Zero reserved fields.
14723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14724
14725            // Safety:
14726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14728            //   envelope_size bytes, there is always sufficient room.
14729            fidl::encoding::encode_in_envelope_optional::<
14730                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
14731                fidl::encoding::DefaultFuchsiaResourceDialect,
14732            >(
14733                self.token_request.as_mut().map(
14734                    <fidl::encoding::Endpoint<
14735                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14736                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14737                ),
14738                encoder,
14739                offset + cur_offset,
14740                depth,
14741            )?;
14742
14743            _prev_end_offset = cur_offset + envelope_size;
14744            if 2 > max_ordinal {
14745                return Ok(());
14746            }
14747
14748            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14749            // are envelope_size bytes.
14750            let cur_offset: usize = (2 - 1) * envelope_size;
14751
14752            // Zero reserved fields.
14753            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14754
14755            // Safety:
14756            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14757            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14758            //   envelope_size bytes, there is always sufficient room.
14759            fidl::encoding::encode_in_envelope_optional::<
14760                u32,
14761                fidl::encoding::DefaultFuchsiaResourceDialect,
14762            >(
14763                self.rights_attenuation_mask
14764                    .as_ref()
14765                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
14766                encoder,
14767                offset + cur_offset,
14768                depth,
14769            )?;
14770
14771            _prev_end_offset = cur_offset + envelope_size;
14772
14773            Ok(())
14774        }
14775    }
14776
14777    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14778        for BufferCollectionTokenGroupCreateChildRequest
14779    {
14780        #[inline(always)]
14781        fn new_empty() -> Self {
14782            Self::default()
14783        }
14784
14785        unsafe fn decode(
14786            &mut self,
14787            decoder: &mut fidl::encoding::Decoder<
14788                '_,
14789                fidl::encoding::DefaultFuchsiaResourceDialect,
14790            >,
14791            offset: usize,
14792            mut depth: fidl::encoding::Depth,
14793        ) -> fidl::Result<()> {
14794            decoder.debug_check_bounds::<Self>(offset);
14795            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14796                None => return Err(fidl::Error::NotNullable),
14797                Some(len) => len,
14798            };
14799            // Calling decoder.out_of_line_offset(0) is not allowed.
14800            if len == 0 {
14801                return Ok(());
14802            };
14803            depth.increment()?;
14804            let envelope_size = 8;
14805            let bytes_len = len * envelope_size;
14806            let offset = decoder.out_of_line_offset(bytes_len)?;
14807            // Decode the envelope for each type.
14808            let mut _next_ordinal_to_read = 0;
14809            let mut next_offset = offset;
14810            let end_offset = offset + bytes_len;
14811            _next_ordinal_to_read += 1;
14812            if next_offset >= end_offset {
14813                return Ok(());
14814            }
14815
14816            // Decode unknown envelopes for gaps in ordinals.
14817            while _next_ordinal_to_read < 1 {
14818                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14819                _next_ordinal_to_read += 1;
14820                next_offset += envelope_size;
14821            }
14822
14823            let next_out_of_line = decoder.next_out_of_line();
14824            let handles_before = decoder.remaining_handles();
14825            if let Some((inlined, num_bytes, num_handles)) =
14826                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14827            {
14828                let member_inline_size = <fidl::encoding::Endpoint<
14829                    fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14830                > as fidl::encoding::TypeMarker>::inline_size(
14831                    decoder.context
14832                );
14833                if inlined != (member_inline_size <= 4) {
14834                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14835                }
14836                let inner_offset;
14837                let mut inner_depth = depth.clone();
14838                if inlined {
14839                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14840                    inner_offset = next_offset;
14841                } else {
14842                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14843                    inner_depth.increment()?;
14844                }
14845                let val_ref = self.token_request.get_or_insert_with(|| {
14846                    fidl::new_empty!(
14847                        fidl::encoding::Endpoint<
14848                            fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14849                        >,
14850                        fidl::encoding::DefaultFuchsiaResourceDialect
14851                    )
14852                });
14853                fidl::decode!(
14854                    fidl::encoding::Endpoint<
14855                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14856                    >,
14857                    fidl::encoding::DefaultFuchsiaResourceDialect,
14858                    val_ref,
14859                    decoder,
14860                    inner_offset,
14861                    inner_depth
14862                )?;
14863                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14864                {
14865                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14866                }
14867                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14868                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14869                }
14870            }
14871
14872            next_offset += envelope_size;
14873            _next_ordinal_to_read += 1;
14874            if next_offset >= end_offset {
14875                return Ok(());
14876            }
14877
14878            // Decode unknown envelopes for gaps in ordinals.
14879            while _next_ordinal_to_read < 2 {
14880                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14881                _next_ordinal_to_read += 1;
14882                next_offset += envelope_size;
14883            }
14884
14885            let next_out_of_line = decoder.next_out_of_line();
14886            let handles_before = decoder.remaining_handles();
14887            if let Some((inlined, num_bytes, num_handles)) =
14888                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14889            {
14890                let member_inline_size =
14891                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14892                if inlined != (member_inline_size <= 4) {
14893                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14894                }
14895                let inner_offset;
14896                let mut inner_depth = depth.clone();
14897                if inlined {
14898                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14899                    inner_offset = next_offset;
14900                } else {
14901                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14902                    inner_depth.increment()?;
14903                }
14904                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
14905                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
14906                });
14907                fidl::decode!(
14908                    u32,
14909                    fidl::encoding::DefaultFuchsiaResourceDialect,
14910                    val_ref,
14911                    decoder,
14912                    inner_offset,
14913                    inner_depth
14914                )?;
14915                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14916                {
14917                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14918                }
14919                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14920                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14921                }
14922            }
14923
14924            next_offset += envelope_size;
14925
14926            // Decode the remaining unknown envelopes.
14927            while next_offset < end_offset {
14928                _next_ordinal_to_read += 1;
14929                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14930                next_offset += envelope_size;
14931            }
14932
14933            Ok(())
14934        }
14935    }
14936}