Skip to main content

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/// Deprecated. Use ['fuchsia.sysmem2.BufferCollectionInfo'].
78///
79/// This type is deprecated for new code but still used by some camera code.
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct BufferCollectionInfo {
82    /// The number of buffers in the collection.
83    pub buffer_count: u32,
84    /// Describes how the contents of buffers are represented.
85    /// All buffers within the collection have the same format.
86    pub format: BufferFormat,
87    /// VMO handles for each buffer in the collection.
88    /// The VMOs are only present when the buffers are backed by VMOs.
89    ///
90    /// If present, all the VMOs after `buffer_count` are invalid handles.
91    /// All buffer VMO handles have identical size and access rights.
92    /// The VMO access rights are determined based on the usages which the
93    /// client specified when allocating the buffer collection.  For example,
94    /// a client which expressed a read-only usage will receive VMOs without
95    /// write rights.
96    pub vmos: [Option<fidl::Vmo>; 64],
97    /// The size of each VMO provided.
98    /// This property is only present when the buffers are backed by VMOs.
99    pub vmo_size: u64,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BufferCollectionInfo {}
103
104/// Information about a buffer collection and its buffers.
105#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106pub struct BufferCollectionInfo2 {
107    /// The total number of buffers.
108    pub buffer_count: u32,
109    /// These settings apply to all the buffers in the initial buffer allocation.
110    pub settings: SingleBufferSettings,
111    /// VMO handles (and vmo_usable_start offset) for each buffer in the
112    /// collection.
113    ///
114    /// If present, all the VMOs at or after index `buffer_count` are invalid
115    /// (0) handles.
116    ///
117    /// All buffer VMO handles have identical size and access rights.  The size
118    /// is in settings.buffer_settings.size_bytes.
119    ///
120    /// The VMO access rights are determined based on the usages which the
121    /// client specified when allocating the buffer collection.  For example,
122    /// a client which expressed a read-only usage will receive VMOs without
123    /// write rights.  In addition, the rights can be attenuated by the
124    /// parameter to BufferCollectionToken.Duplicate() calls.
125    pub buffers: [VmoBuffer; 64],
126}
127
128impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BufferCollectionInfo2 {}
129
130#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
132    pub group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
136    for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
137{
138}
139
140#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
141pub struct BufferCollectionTokenDuplicateRequest {
142    pub rights_attenuation_mask: u32,
143    pub token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
144}
145
146impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
147    for BufferCollectionTokenDuplicateRequest
148{
149}
150
151#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152pub struct BufferCollectionTokenDuplicateSyncResponse {
153    pub tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
154}
155
156impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
157    for BufferCollectionTokenDuplicateSyncResponse
158{
159}
160
161#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
162pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
163    pub tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
164}
165
166impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
167    for BufferCollectionTokenGroupCreateChildrenSyncResponse
168{
169}
170
171#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
172pub struct BufferCollectionWaitForBuffersAllocatedResponse {
173    pub status: i32,
174    pub buffer_collection_info: BufferCollectionInfo2,
175}
176
177impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
178    for BufferCollectionWaitForBuffersAllocatedResponse
179{
180}
181
182#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
183pub struct NodeGetNodeRefResponse {
184    pub node_ref: fidl::Event,
185}
186
187impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeGetNodeRefResponse {}
188
189#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
190pub struct NodeIsAlternateForRequest {
191    pub node_ref: fidl::Event,
192}
193
194impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeIsAlternateForRequest {}
195
196/// There is no current replacement for this type, but if your use case needs
197/// incremental buffer allocation within a single collection, please reach out.
198#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
199pub struct SingleBufferInfo {
200    pub settings: SingleBufferSettings,
201    pub buffer: VmoBuffer,
202}
203
204impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SingleBufferInfo {}
205
206#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
207pub struct VmoBuffer {
208    /// The same VMO can be used by more than one CodecBuffer (only of the same
209    /// buffer_lifetime_ordinal), but each vmo handle must be a separate handle.
210    ///
211    /// The vmo field can be 0 if this is a VmoBuffer in BufferCollectionInfo_2
212    /// that's at or beyond BufferCollectionInfo_2.buffer_count.
213    pub vmo: Option<fidl::Vmo>,
214    /// Offset within the VMO of the first usable byte.  Must be < the VMO's
215    /// size in bytes, and leave sufficient room for
216    /// BufferMemorySettings.size_bytes before the end of the VMO.
217    pub vmo_usable_start: u64,
218}
219
220impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VmoBuffer {}
221
222#[derive(Debug, Default, PartialEq)]
223pub struct BufferCollectionTokenGroupCreateChildRequest {
224    /// Must be set.
225    pub token_request: Option<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
226    /// If not set, the default is ZX_RIGHT_SAME_RIGHTS.
227    pub rights_attenuation_mask: Option<u32>,
228    #[doc(hidden)]
229    pub __source_breaking: fidl::marker::SourceBreaking,
230}
231
232impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
233    for BufferCollectionTokenGroupCreateChildRequest
234{
235}
236
237#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
238pub struct AllocatorMarker;
239
240impl fidl::endpoints::ProtocolMarker for AllocatorMarker {
241    type Proxy = AllocatorProxy;
242    type RequestStream = AllocatorRequestStream;
243    #[cfg(target_os = "fuchsia")]
244    type SynchronousProxy = AllocatorSynchronousProxy;
245
246    const DEBUG_NAME: &'static str = "fuchsia.sysmem.Allocator";
247}
248impl fidl::endpoints::DiscoverableProtocolMarker for AllocatorMarker {}
249
250pub trait AllocatorProxyInterface: Send + Sync {
251    fn r#allocate_non_shared_collection(
252        &self,
253        collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
254    ) -> Result<(), fidl::Error>;
255    fn r#allocate_shared_collection(
256        &self,
257        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
258    ) -> Result<(), fidl::Error>;
259    fn r#bind_shared_collection(
260        &self,
261        token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
262        buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
263    ) -> Result<(), fidl::Error>;
264    type ValidateBufferCollectionTokenResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
265        + Send;
266    fn r#validate_buffer_collection_token(
267        &self,
268        token_server_koid: u64,
269    ) -> Self::ValidateBufferCollectionTokenResponseFut;
270    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
271    fn r#connect_to_sysmem2_allocator(
272        &self,
273        allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
274    ) -> Result<(), fidl::Error>;
275}
276#[derive(Debug)]
277#[cfg(target_os = "fuchsia")]
278pub struct AllocatorSynchronousProxy {
279    client: fidl::client::sync::Client,
280}
281
282#[cfg(target_os = "fuchsia")]
283impl fidl::endpoints::SynchronousProxy for AllocatorSynchronousProxy {
284    type Proxy = AllocatorProxy;
285    type Protocol = AllocatorMarker;
286
287    fn from_channel(inner: fidl::Channel) -> Self {
288        Self::new(inner)
289    }
290
291    fn into_channel(self) -> fidl::Channel {
292        self.client.into_channel()
293    }
294
295    fn as_channel(&self) -> &fidl::Channel {
296        self.client.as_channel()
297    }
298}
299
300#[cfg(target_os = "fuchsia")]
301impl AllocatorSynchronousProxy {
302    pub fn new(channel: fidl::Channel) -> Self {
303        Self { client: fidl::client::sync::Client::new(channel) }
304    }
305
306    pub fn into_channel(self) -> fidl::Channel {
307        self.client.into_channel()
308    }
309
310    /// Waits until an event arrives and returns it. It is safe for other
311    /// threads to make concurrent requests while waiting for an event.
312    pub fn wait_for_event(
313        &self,
314        deadline: zx::MonotonicInstant,
315    ) -> Result<AllocatorEvent, fidl::Error> {
316        AllocatorEvent::decode(self.client.wait_for_event::<AllocatorMarker>(deadline)?)
317    }
318
319    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
320    /// who is also the only participant (from the point of view of sysmem).
321    ///
322    /// This call exists mainly for temp/testing purposes.  This call skips the
323    /// BufferCollectionToken stage, so there's no way to allow another
324    /// participant to specify its constraints.
325    ///
326    /// Real clients are encouraged to use AllocateSharedCollection() instead,
327    /// and to let relevant participants directly convey their own constraints to
328    /// sysmem.
329    ///
330    /// `collection_request` is the server end of the BufferCollection FIDL
331    /// channel.  The client can call SetConstraints() and then
332    /// WaitForBuffersAllocated() on the client end of this channel to specify
333    /// constraints and then determine success/failure and get the
334    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
335    /// keep the client end of this channel open while using the
336    /// BufferCollection, and should notice when this channel closes and stop
337    /// using the BufferCollection ASAP.
338    pub fn r#allocate_non_shared_collection(
339        &self,
340        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
341    ) -> Result<(), fidl::Error> {
342        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
343            (collection_request,),
344            0x20f79299bbb4d2c6,
345            fidl::encoding::DynamicFlags::empty(),
346        )
347    }
348
349    /// Creates a logical BufferCollectionToken which can be shared among
350    /// participants (using BufferCollectionToken.Duplicate()), and then
351    /// converted into a BufferCollection using BindSharedCollection().
352    ///
353    /// Success/failure to populate the BufferCollection with buffers is
354    /// determined via the BufferCollection interface.
355    pub fn r#allocate_shared_collection(
356        &self,
357        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
358    ) -> Result<(), fidl::Error> {
359        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
360            (token_request,),
361            0x7a757a57bfda0f71,
362            fidl::encoding::DynamicFlags::empty(),
363        )
364    }
365
366    /// Convert a BufferCollectionToken into a connection to the logical
367    /// BufferCollection.  The BufferCollection hasn't yet been populated with
368    /// buffers - the participant must first also send SetConstraints() via the
369    /// client end of buffer_collection.
370    ///
371    /// All BufferCollectionToken(s) duplicated from a logical
372    /// BufferCollectionToken created via AllocateSharedCollection() must be
373    /// turned in via BindSharedCollection() before the logical BufferCollection
374    /// will be populated with buffers.
375    ///
376    /// `token` the client endpoint of a channel whose server end was sent to
377    /// sysmem using AllocateSharedCollection or whose server end was sent to
378    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
379    /// "exchanged" for a channel to the logical BufferCollection.
380    ///
381    /// `buffer_collection_request` the server end of a BufferCollection
382    /// channel.  The sender retains the client end as usual.  The
383    /// BufferCollection channel is a single participant's connection to the
384    /// logical BufferCollection.  There typically will be other participants
385    /// with their own BufferCollection channel to the logical BufferCollection.
386    pub fn r#bind_shared_collection(
387        &self,
388        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
389        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
390    ) -> Result<(), fidl::Error> {
391        self.client.send::<AllocatorBindSharedCollectionRequest>(
392            (token, buffer_collection_request),
393            0x146eca7ec46ff4ee,
394            fidl::encoding::DynamicFlags::empty(),
395        )
396    }
397
398    /// Validate that a BufferCollectionToken is known to the sysmem server.
399    ///
400    /// This can be used in cases where BindSharedCollection() won't be called
401    /// until after BufferCollectionToken.Duplicate() +
402    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
403    /// whether an incoming token is valid (so far).
404    ///
405    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
406    /// sysmem risks the Sync() hanging forever.
407    ///
408    /// Given that an incoming token can become invalid at any time if any
409    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
410    /// authors of client code are encouraged to consider not calling
411    /// ValidateBufferCollectionToken() and instead dealing with async failure
412    /// of the BufferCollection.Sync() after all the
413    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
414    /// sending any duplicate tokens to other processes).
415    ///
416    /// Regardless of the result of this call, this call has no effect on the
417    /// token with the referenced koid.
418    ///
419    /// A true result from this call doesn't guarantee that the token remains
420    /// valid for any duration afterwards.
421    ///
422    /// Client code will zx_object_get_info() on the client's token handle,
423    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
424    /// which then gets passed to ValidateBufferCollectionToken().
425    ///
426    /// If ValidateBufferCollectionToken() returns true, the token was known at
427    /// the time the sysmem server processed the call, but may no longer be
428    /// valid/known by the time the client code receives the response.
429    ///
430    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
431    /// at the time the sysmem server processed the call, but the token may
432    /// become known by the time the client code receives the response.  However
433    /// client code is not required to mitigate the possibility that the token
434    /// may become known late, since the source of the token should have synced
435    /// the token to sysmem before sending the token to the client code.
436    ///
437    /// If calling ValidateBufferCollectionToken() fails in some way, there will
438    /// be a zx_status_t from the FIDL layer.
439    ///
440    /// `token_server_koid` the koid of the server end of a channel that might
441    /// be a BufferCollectionToken channel.  This can be obtained from
442    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
443    pub fn r#validate_buffer_collection_token(
444        &self,
445        mut token_server_koid: u64,
446        ___deadline: zx::MonotonicInstant,
447    ) -> Result<bool, fidl::Error> {
448        let _response = self.client.send_query::<
449            AllocatorValidateBufferCollectionTokenRequest,
450            AllocatorValidateBufferCollectionTokenResponse,
451            AllocatorMarker,
452        >(
453            (token_server_koid,),
454            0x575b279b0236faea,
455            fidl::encoding::DynamicFlags::empty(),
456            ___deadline,
457        )?;
458        Ok(_response.is_known)
459    }
460
461    /// Set information about the current client that can be used by sysmem to
462    /// help debug leaking memory and hangs waiting for constraints. |name| can
463    /// be an arbitrary string, but the current process name (see
464    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
465    /// arbitrary id, but the current process ID (see
466    /// fsl::GetCurrentProcessKoid()) is a good default.
467    ///
468    /// This information is propagated to all BufferCollections created using
469    /// BindSharedCollection() or AllocateNonSharedCollection() from this
470    /// allocator. It does not affect BufferCollectionTokens, since they are
471    /// often passed cross-process and should have their names managed manually.
472    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
473        self.client.send::<AllocatorSetDebugClientInfoRequest>(
474            (name, id),
475            0x419f0d5b30728b26,
476            fidl::encoding::DynamicFlags::empty(),
477        )
478    }
479
480    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
481    /// `Allocator`.
482    ///
483    /// This is mainly useful in situations where library code is handed a
484    /// sysmem(1) allocator, but the library code has been updated to use
485    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
486    /// `Allocator` instead, but client code isn't always in the same repo, so
487    /// this message allows the library to still accept the sysmem(1) Allocator
488    /// temporarily.
489    ///
490    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
491    /// `Allocator`.
492    pub fn r#connect_to_sysmem2_allocator(
493        &self,
494        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
495    ) -> Result<(), fidl::Error> {
496        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
497            (allocator_request,),
498            0x13db3e3abac2e24,
499            fidl::encoding::DynamicFlags::empty(),
500        )
501    }
502}
503
504#[cfg(target_os = "fuchsia")]
505impl From<AllocatorSynchronousProxy> for zx::NullableHandle {
506    fn from(value: AllocatorSynchronousProxy) -> Self {
507        value.into_channel().into()
508    }
509}
510
511#[cfg(target_os = "fuchsia")]
512impl From<fidl::Channel> for AllocatorSynchronousProxy {
513    fn from(value: fidl::Channel) -> Self {
514        Self::new(value)
515    }
516}
517
518#[cfg(target_os = "fuchsia")]
519impl fidl::endpoints::FromClient for AllocatorSynchronousProxy {
520    type Protocol = AllocatorMarker;
521
522    fn from_client(value: fidl::endpoints::ClientEnd<AllocatorMarker>) -> Self {
523        Self::new(value.into_channel())
524    }
525}
526
527#[derive(Debug, Clone)]
528pub struct AllocatorProxy {
529    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
530}
531
532impl fidl::endpoints::Proxy for AllocatorProxy {
533    type Protocol = AllocatorMarker;
534
535    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
536        Self::new(inner)
537    }
538
539    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
540        self.client.into_channel().map_err(|client| Self { client })
541    }
542
543    fn as_channel(&self) -> &::fidl::AsyncChannel {
544        self.client.as_channel()
545    }
546}
547
548impl AllocatorProxy {
549    /// Create a new Proxy for fuchsia.sysmem/Allocator.
550    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
551        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
552        Self { client: fidl::client::Client::new(channel, protocol_name) }
553    }
554
555    /// Get a Stream of events from the remote end of the protocol.
556    ///
557    /// # Panics
558    ///
559    /// Panics if the event stream was already taken.
560    pub fn take_event_stream(&self) -> AllocatorEventStream {
561        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
562    }
563
564    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
565    /// who is also the only participant (from the point of view of sysmem).
566    ///
567    /// This call exists mainly for temp/testing purposes.  This call skips the
568    /// BufferCollectionToken stage, so there's no way to allow another
569    /// participant to specify its constraints.
570    ///
571    /// Real clients are encouraged to use AllocateSharedCollection() instead,
572    /// and to let relevant participants directly convey their own constraints to
573    /// sysmem.
574    ///
575    /// `collection_request` is the server end of the BufferCollection FIDL
576    /// channel.  The client can call SetConstraints() and then
577    /// WaitForBuffersAllocated() on the client end of this channel to specify
578    /// constraints and then determine success/failure and get the
579    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
580    /// keep the client end of this channel open while using the
581    /// BufferCollection, and should notice when this channel closes and stop
582    /// using the BufferCollection ASAP.
583    pub fn r#allocate_non_shared_collection(
584        &self,
585        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
586    ) -> Result<(), fidl::Error> {
587        AllocatorProxyInterface::r#allocate_non_shared_collection(self, collection_request)
588    }
589
590    /// Creates a logical BufferCollectionToken which can be shared among
591    /// participants (using BufferCollectionToken.Duplicate()), and then
592    /// converted into a BufferCollection using BindSharedCollection().
593    ///
594    /// Success/failure to populate the BufferCollection with buffers is
595    /// determined via the BufferCollection interface.
596    pub fn r#allocate_shared_collection(
597        &self,
598        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
599    ) -> Result<(), fidl::Error> {
600        AllocatorProxyInterface::r#allocate_shared_collection(self, token_request)
601    }
602
603    /// Convert a BufferCollectionToken into a connection to the logical
604    /// BufferCollection.  The BufferCollection hasn't yet been populated with
605    /// buffers - the participant must first also send SetConstraints() via the
606    /// client end of buffer_collection.
607    ///
608    /// All BufferCollectionToken(s) duplicated from a logical
609    /// BufferCollectionToken created via AllocateSharedCollection() must be
610    /// turned in via BindSharedCollection() before the logical BufferCollection
611    /// will be populated with buffers.
612    ///
613    /// `token` the client endpoint of a channel whose server end was sent to
614    /// sysmem using AllocateSharedCollection or whose server end was sent to
615    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
616    /// "exchanged" for a channel to the logical BufferCollection.
617    ///
618    /// `buffer_collection_request` the server end of a BufferCollection
619    /// channel.  The sender retains the client end as usual.  The
620    /// BufferCollection channel is a single participant's connection to the
621    /// logical BufferCollection.  There typically will be other participants
622    /// with their own BufferCollection channel to the logical BufferCollection.
623    pub fn r#bind_shared_collection(
624        &self,
625        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
626        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
627    ) -> Result<(), fidl::Error> {
628        AllocatorProxyInterface::r#bind_shared_collection(self, token, buffer_collection_request)
629    }
630
631    /// Validate that a BufferCollectionToken is known to the sysmem server.
632    ///
633    /// This can be used in cases where BindSharedCollection() won't be called
634    /// until after BufferCollectionToken.Duplicate() +
635    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
636    /// whether an incoming token is valid (so far).
637    ///
638    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
639    /// sysmem risks the Sync() hanging forever.
640    ///
641    /// Given that an incoming token can become invalid at any time if any
642    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
643    /// authors of client code are encouraged to consider not calling
644    /// ValidateBufferCollectionToken() and instead dealing with async failure
645    /// of the BufferCollection.Sync() after all the
646    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
647    /// sending any duplicate tokens to other processes).
648    ///
649    /// Regardless of the result of this call, this call has no effect on the
650    /// token with the referenced koid.
651    ///
652    /// A true result from this call doesn't guarantee that the token remains
653    /// valid for any duration afterwards.
654    ///
655    /// Client code will zx_object_get_info() on the client's token handle,
656    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
657    /// which then gets passed to ValidateBufferCollectionToken().
658    ///
659    /// If ValidateBufferCollectionToken() returns true, the token was known at
660    /// the time the sysmem server processed the call, but may no longer be
661    /// valid/known by the time the client code receives the response.
662    ///
663    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
664    /// at the time the sysmem server processed the call, but the token may
665    /// become known by the time the client code receives the response.  However
666    /// client code is not required to mitigate the possibility that the token
667    /// may become known late, since the source of the token should have synced
668    /// the token to sysmem before sending the token to the client code.
669    ///
670    /// If calling ValidateBufferCollectionToken() fails in some way, there will
671    /// be a zx_status_t from the FIDL layer.
672    ///
673    /// `token_server_koid` the koid of the server end of a channel that might
674    /// be a BufferCollectionToken channel.  This can be obtained from
675    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
676    pub fn r#validate_buffer_collection_token(
677        &self,
678        mut token_server_koid: u64,
679    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
680        AllocatorProxyInterface::r#validate_buffer_collection_token(self, token_server_koid)
681    }
682
683    /// Set information about the current client that can be used by sysmem to
684    /// help debug leaking memory and hangs waiting for constraints. |name| can
685    /// be an arbitrary string, but the current process name (see
686    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
687    /// arbitrary id, but the current process ID (see
688    /// fsl::GetCurrentProcessKoid()) is a good default.
689    ///
690    /// This information is propagated to all BufferCollections created using
691    /// BindSharedCollection() or AllocateNonSharedCollection() from this
692    /// allocator. It does not affect BufferCollectionTokens, since they are
693    /// often passed cross-process and should have their names managed manually.
694    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
695        AllocatorProxyInterface::r#set_debug_client_info(self, name, id)
696    }
697
698    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
699    /// `Allocator`.
700    ///
701    /// This is mainly useful in situations where library code is handed a
702    /// sysmem(1) allocator, but the library code has been updated to use
703    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
704    /// `Allocator` instead, but client code isn't always in the same repo, so
705    /// this message allows the library to still accept the sysmem(1) Allocator
706    /// temporarily.
707    ///
708    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
709    /// `Allocator`.
710    pub fn r#connect_to_sysmem2_allocator(
711        &self,
712        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
713    ) -> Result<(), fidl::Error> {
714        AllocatorProxyInterface::r#connect_to_sysmem2_allocator(self, allocator_request)
715    }
716}
717
718impl AllocatorProxyInterface for AllocatorProxy {
719    fn r#allocate_non_shared_collection(
720        &self,
721        mut collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
722    ) -> Result<(), fidl::Error> {
723        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
724            (collection_request,),
725            0x20f79299bbb4d2c6,
726            fidl::encoding::DynamicFlags::empty(),
727        )
728    }
729
730    fn r#allocate_shared_collection(
731        &self,
732        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
733    ) -> Result<(), fidl::Error> {
734        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
735            (token_request,),
736            0x7a757a57bfda0f71,
737            fidl::encoding::DynamicFlags::empty(),
738        )
739    }
740
741    fn r#bind_shared_collection(
742        &self,
743        mut token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
744        mut buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
745    ) -> Result<(), fidl::Error> {
746        self.client.send::<AllocatorBindSharedCollectionRequest>(
747            (token, buffer_collection_request),
748            0x146eca7ec46ff4ee,
749            fidl::encoding::DynamicFlags::empty(),
750        )
751    }
752
753    type ValidateBufferCollectionTokenResponseFut =
754        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
755    fn r#validate_buffer_collection_token(
756        &self,
757        mut token_server_koid: u64,
758    ) -> Self::ValidateBufferCollectionTokenResponseFut {
759        fn _decode(
760            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
761        ) -> Result<bool, fidl::Error> {
762            let _response = fidl::client::decode_transaction_body::<
763                AllocatorValidateBufferCollectionTokenResponse,
764                fidl::encoding::DefaultFuchsiaResourceDialect,
765                0x575b279b0236faea,
766            >(_buf?)?;
767            Ok(_response.is_known)
768        }
769        self.client.send_query_and_decode::<AllocatorValidateBufferCollectionTokenRequest, bool>(
770            (token_server_koid,),
771            0x575b279b0236faea,
772            fidl::encoding::DynamicFlags::empty(),
773            _decode,
774        )
775    }
776
777    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
778        self.client.send::<AllocatorSetDebugClientInfoRequest>(
779            (name, id),
780            0x419f0d5b30728b26,
781            fidl::encoding::DynamicFlags::empty(),
782        )
783    }
784
785    fn r#connect_to_sysmem2_allocator(
786        &self,
787        mut allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
788    ) -> Result<(), fidl::Error> {
789        self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
790            (allocator_request,),
791            0x13db3e3abac2e24,
792            fidl::encoding::DynamicFlags::empty(),
793        )
794    }
795}
796
797pub struct AllocatorEventStream {
798    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
799}
800
801impl std::marker::Unpin for AllocatorEventStream {}
802
803impl futures::stream::FusedStream for AllocatorEventStream {
804    fn is_terminated(&self) -> bool {
805        self.event_receiver.is_terminated()
806    }
807}
808
809impl futures::Stream for AllocatorEventStream {
810    type Item = Result<AllocatorEvent, fidl::Error>;
811
812    fn poll_next(
813        mut self: std::pin::Pin<&mut Self>,
814        cx: &mut std::task::Context<'_>,
815    ) -> std::task::Poll<Option<Self::Item>> {
816        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
817            &mut self.event_receiver,
818            cx
819        )?) {
820            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
821            None => std::task::Poll::Ready(None),
822        }
823    }
824}
825
826#[derive(Debug)]
827pub enum AllocatorEvent {}
828
829impl AllocatorEvent {
830    /// Decodes a message buffer as a [`AllocatorEvent`].
831    fn decode(
832        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
833    ) -> Result<AllocatorEvent, fidl::Error> {
834        let (bytes, _handles) = buf.split_mut();
835        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
836        debug_assert_eq!(tx_header.tx_id, 0);
837        match tx_header.ordinal {
838            _ => Err(fidl::Error::UnknownOrdinal {
839                ordinal: tx_header.ordinal,
840                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
841            }),
842        }
843    }
844}
845
846/// A Stream of incoming requests for fuchsia.sysmem/Allocator.
847pub struct AllocatorRequestStream {
848    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
849    is_terminated: bool,
850}
851
852impl std::marker::Unpin for AllocatorRequestStream {}
853
854impl futures::stream::FusedStream for AllocatorRequestStream {
855    fn is_terminated(&self) -> bool {
856        self.is_terminated
857    }
858}
859
860impl fidl::endpoints::RequestStream for AllocatorRequestStream {
861    type Protocol = AllocatorMarker;
862    type ControlHandle = AllocatorControlHandle;
863
864    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
865        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
866    }
867
868    fn control_handle(&self) -> Self::ControlHandle {
869        AllocatorControlHandle { inner: self.inner.clone() }
870    }
871
872    fn into_inner(
873        self,
874    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
875    {
876        (self.inner, self.is_terminated)
877    }
878
879    fn from_inner(
880        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
881        is_terminated: bool,
882    ) -> Self {
883        Self { inner, is_terminated }
884    }
885}
886
887impl futures::Stream for AllocatorRequestStream {
888    type Item = Result<AllocatorRequest, fidl::Error>;
889
890    fn poll_next(
891        mut self: std::pin::Pin<&mut Self>,
892        cx: &mut std::task::Context<'_>,
893    ) -> std::task::Poll<Option<Self::Item>> {
894        let this = &mut *self;
895        if this.inner.check_shutdown(cx) {
896            this.is_terminated = true;
897            return std::task::Poll::Ready(None);
898        }
899        if this.is_terminated {
900            panic!("polled AllocatorRequestStream after completion");
901        }
902        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
903            |bytes, handles| {
904                match this.inner.channel().read_etc(cx, bytes, handles) {
905                    std::task::Poll::Ready(Ok(())) => {}
906                    std::task::Poll::Pending => return std::task::Poll::Pending,
907                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
908                        this.is_terminated = true;
909                        return std::task::Poll::Ready(None);
910                    }
911                    std::task::Poll::Ready(Err(e)) => {
912                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
913                            e.into(),
914                        ))));
915                    }
916                }
917
918                // A message has been received from the channel
919                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
920
921                std::task::Poll::Ready(Some(match header.ordinal {
922                    0x20f79299bbb4d2c6 => {
923                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
924                        let mut req = fidl::new_empty!(
925                            AllocatorAllocateNonSharedCollectionRequest,
926                            fidl::encoding::DefaultFuchsiaResourceDialect
927                        );
928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
929                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
930                        Ok(AllocatorRequest::AllocateNonSharedCollection {
931                            collection_request: req.collection_request,
932
933                            control_handle,
934                        })
935                    }
936                    0x7a757a57bfda0f71 => {
937                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
938                        let mut req = fidl::new_empty!(
939                            AllocatorAllocateSharedCollectionRequest,
940                            fidl::encoding::DefaultFuchsiaResourceDialect
941                        );
942                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
943                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
944                        Ok(AllocatorRequest::AllocateSharedCollection {
945                            token_request: req.token_request,
946
947                            control_handle,
948                        })
949                    }
950                    0x146eca7ec46ff4ee => {
951                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
952                        let mut req = fidl::new_empty!(
953                            AllocatorBindSharedCollectionRequest,
954                            fidl::encoding::DefaultFuchsiaResourceDialect
955                        );
956                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
957                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
958                        Ok(AllocatorRequest::BindSharedCollection {
959                            token: req.token,
960                            buffer_collection_request: req.buffer_collection_request,
961
962                            control_handle,
963                        })
964                    }
965                    0x575b279b0236faea => {
966                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
967                        let mut req = fidl::new_empty!(
968                            AllocatorValidateBufferCollectionTokenRequest,
969                            fidl::encoding::DefaultFuchsiaResourceDialect
970                        );
971                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
972                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
973                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
974                            token_server_koid: req.token_server_koid,
975
976                            responder: AllocatorValidateBufferCollectionTokenResponder {
977                                control_handle: std::mem::ManuallyDrop::new(control_handle),
978                                tx_id: header.tx_id,
979                            },
980                        })
981                    }
982                    0x419f0d5b30728b26 => {
983                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
984                        let mut req = fidl::new_empty!(
985                            AllocatorSetDebugClientInfoRequest,
986                            fidl::encoding::DefaultFuchsiaResourceDialect
987                        );
988                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
989                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
990                        Ok(AllocatorRequest::SetDebugClientInfo {
991                            name: req.name,
992                            id: req.id,
993
994                            control_handle,
995                        })
996                    }
997                    0x13db3e3abac2e24 => {
998                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
999                        let mut req = fidl::new_empty!(
1000                            AllocatorConnectToSysmem2AllocatorRequest,
1001                            fidl::encoding::DefaultFuchsiaResourceDialect
1002                        );
1003                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorConnectToSysmem2AllocatorRequest>(&header, _body_bytes, handles, &mut req)?;
1004                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1005                        Ok(AllocatorRequest::ConnectToSysmem2Allocator {
1006                            allocator_request: req.allocator_request,
1007
1008                            control_handle,
1009                        })
1010                    }
1011                    _ => Err(fidl::Error::UnknownOrdinal {
1012                        ordinal: header.ordinal,
1013                        protocol_name:
1014                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1015                    }),
1016                }))
1017            },
1018        )
1019    }
1020}
1021
1022/// Allocates system memory buffers.
1023#[derive(Debug)]
1024pub enum AllocatorRequest {
1025    /// Allocates a BufferCollection on behalf of a single client (aka initiator)
1026    /// who is also the only participant (from the point of view of sysmem).
1027    ///
1028    /// This call exists mainly for temp/testing purposes.  This call skips the
1029    /// BufferCollectionToken stage, so there's no way to allow another
1030    /// participant to specify its constraints.
1031    ///
1032    /// Real clients are encouraged to use AllocateSharedCollection() instead,
1033    /// and to let relevant participants directly convey their own constraints to
1034    /// sysmem.
1035    ///
1036    /// `collection_request` is the server end of the BufferCollection FIDL
1037    /// channel.  The client can call SetConstraints() and then
1038    /// WaitForBuffersAllocated() on the client end of this channel to specify
1039    /// constraints and then determine success/failure and get the
1040    /// BufferCollectionInfo_2 for the BufferCollection.  The client should also
1041    /// keep the client end of this channel open while using the
1042    /// BufferCollection, and should notice when this channel closes and stop
1043    /// using the BufferCollection ASAP.
1044    AllocateNonSharedCollection {
1045        collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1046        control_handle: AllocatorControlHandle,
1047    },
1048    /// Creates a logical BufferCollectionToken which can be shared among
1049    /// participants (using BufferCollectionToken.Duplicate()), and then
1050    /// converted into a BufferCollection using BindSharedCollection().
1051    ///
1052    /// Success/failure to populate the BufferCollection with buffers is
1053    /// determined via the BufferCollection interface.
1054    AllocateSharedCollection {
1055        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1056        control_handle: AllocatorControlHandle,
1057    },
1058    /// Convert a BufferCollectionToken into a connection to the logical
1059    /// BufferCollection.  The BufferCollection hasn't yet been populated with
1060    /// buffers - the participant must first also send SetConstraints() via the
1061    /// client end of buffer_collection.
1062    ///
1063    /// All BufferCollectionToken(s) duplicated from a logical
1064    /// BufferCollectionToken created via AllocateSharedCollection() must be
1065    /// turned in via BindSharedCollection() before the logical BufferCollection
1066    /// will be populated with buffers.
1067    ///
1068    /// `token` the client endpoint of a channel whose server end was sent to
1069    /// sysmem using AllocateSharedCollection or whose server end was sent to
1070    /// sysmem using BufferCollectionToken.Duplicate().  The token is being
1071    /// "exchanged" for a channel to the logical BufferCollection.
1072    ///
1073    /// `buffer_collection_request` the server end of a BufferCollection
1074    /// channel.  The sender retains the client end as usual.  The
1075    /// BufferCollection channel is a single participant's connection to the
1076    /// logical BufferCollection.  There typically will be other participants
1077    /// with their own BufferCollection channel to the logical BufferCollection.
1078    BindSharedCollection {
1079        token: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1080        buffer_collection_request: fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1081        control_handle: AllocatorControlHandle,
1082    },
1083    /// Validate that a BufferCollectionToken is known to the sysmem server.
1084    ///
1085    /// This can be used in cases where BindSharedCollection() won't be called
1086    /// until after BufferCollectionToken.Duplicate() +
1087    /// BufferCollectionToken.Sync(), when the client code wants to know earlier
1088    /// whether an incoming token is valid (so far).
1089    ///
1090    /// Calling BufferCollectionToken.Sync() on a token that isn't known to
1091    /// sysmem risks the Sync() hanging forever.
1092    ///
1093    /// Given that an incoming token can become invalid at any time if any
1094    /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
1095    /// authors of client code are encouraged to consider not calling
1096    /// ValidateBufferCollectionToken() and instead dealing with async failure
1097    /// of the BufferCollection.Sync() after all the
1098    /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
1099    /// sending any duplicate tokens to other processes).
1100    ///
1101    /// Regardless of the result of this call, this call has no effect on the
1102    /// token with the referenced koid.
1103    ///
1104    /// A true result from this call doesn't guarantee that the token remains
1105    /// valid for any duration afterwards.
1106    ///
1107    /// Client code will zx_object_get_info() on the client's token handle,
1108    /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
1109    /// which then gets passed to ValidateBufferCollectionToken().
1110    ///
1111    /// If ValidateBufferCollectionToken() returns true, the token was known at
1112    /// the time the sysmem server processed the call, but may no longer be
1113    /// valid/known by the time the client code receives the response.
1114    ///
1115    /// If ValidateBufferCollectionToken() returns false, the token wasn't known
1116    /// at the time the sysmem server processed the call, but the token may
1117    /// become known by the time the client code receives the response.  However
1118    /// client code is not required to mitigate the possibility that the token
1119    /// may become known late, since the source of the token should have synced
1120    /// the token to sysmem before sending the token to the client code.
1121    ///
1122    /// If calling ValidateBufferCollectionToken() fails in some way, there will
1123    /// be a zx_status_t from the FIDL layer.
1124    ///
1125    /// `token_server_koid` the koid of the server end of a channel that might
1126    /// be a BufferCollectionToken channel.  This can be obtained from
1127    /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
1128    ValidateBufferCollectionToken {
1129        token_server_koid: u64,
1130        responder: AllocatorValidateBufferCollectionTokenResponder,
1131    },
1132    /// Set information about the current client that can be used by sysmem to
1133    /// help debug leaking memory and hangs waiting for constraints. |name| can
1134    /// be an arbitrary string, but the current process name (see
1135    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1136    /// arbitrary id, but the current process ID (see
1137    /// fsl::GetCurrentProcessKoid()) is a good default.
1138    ///
1139    /// This information is propagated to all BufferCollections created using
1140    /// BindSharedCollection() or AllocateNonSharedCollection() from this
1141    /// allocator. It does not affect BufferCollectionTokens, since they are
1142    /// often passed cross-process and should have their names managed manually.
1143    SetDebugClientInfo { name: String, id: u64, control_handle: AllocatorControlHandle },
1144    /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
1145    /// `Allocator`.
1146    ///
1147    /// This is mainly useful in situations where library code is handed a
1148    /// sysmem(1) allocator, but the library code has been updated to use
1149    /// sysmem2. Typically the library will provide a way to pass in a sysmem2
1150    /// `Allocator` instead, but client code isn't always in the same repo, so
1151    /// this message allows the library to still accept the sysmem(1) Allocator
1152    /// temporarily.
1153    ///
1154    /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
1155    /// `Allocator`.
1156    ConnectToSysmem2Allocator {
1157        allocator_request: fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1158        control_handle: AllocatorControlHandle,
1159    },
1160}
1161
1162impl AllocatorRequest {
1163    #[allow(irrefutable_let_patterns)]
1164    pub fn into_allocate_non_shared_collection(
1165        self,
1166    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionMarker>, AllocatorControlHandle)> {
1167        if let AllocatorRequest::AllocateNonSharedCollection {
1168            collection_request,
1169            control_handle,
1170        } = self
1171        {
1172            Some((collection_request, control_handle))
1173        } else {
1174            None
1175        }
1176    }
1177
1178    #[allow(irrefutable_let_patterns)]
1179    pub fn into_allocate_shared_collection(
1180        self,
1181    ) -> Option<(fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>, AllocatorControlHandle)>
1182    {
1183        if let AllocatorRequest::AllocateSharedCollection { token_request, control_handle } = self {
1184            Some((token_request, control_handle))
1185        } else {
1186            None
1187        }
1188    }
1189
1190    #[allow(irrefutable_let_patterns)]
1191    pub fn into_bind_shared_collection(
1192        self,
1193    ) -> Option<(
1194        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
1195        fidl::endpoints::ServerEnd<BufferCollectionMarker>,
1196        AllocatorControlHandle,
1197    )> {
1198        if let AllocatorRequest::BindSharedCollection {
1199            token,
1200            buffer_collection_request,
1201            control_handle,
1202        } = self
1203        {
1204            Some((token, buffer_collection_request, control_handle))
1205        } else {
1206            None
1207        }
1208    }
1209
1210    #[allow(irrefutable_let_patterns)]
1211    pub fn into_validate_buffer_collection_token(
1212        self,
1213    ) -> Option<(u64, AllocatorValidateBufferCollectionTokenResponder)> {
1214        if let AllocatorRequest::ValidateBufferCollectionToken { token_server_koid, responder } =
1215            self
1216        {
1217            Some((token_server_koid, responder))
1218        } else {
1219            None
1220        }
1221    }
1222
1223    #[allow(irrefutable_let_patterns)]
1224    pub fn into_set_debug_client_info(self) -> Option<(String, u64, AllocatorControlHandle)> {
1225        if let AllocatorRequest::SetDebugClientInfo { name, id, control_handle } = self {
1226            Some((name, id, control_handle))
1227        } else {
1228            None
1229        }
1230    }
1231
1232    #[allow(irrefutable_let_patterns)]
1233    pub fn into_connect_to_sysmem2_allocator(
1234        self,
1235    ) -> Option<(
1236        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
1237        AllocatorControlHandle,
1238    )> {
1239        if let AllocatorRequest::ConnectToSysmem2Allocator { allocator_request, control_handle } =
1240            self
1241        {
1242            Some((allocator_request, control_handle))
1243        } else {
1244            None
1245        }
1246    }
1247
1248    /// Name of the method defined in FIDL
1249    pub fn method_name(&self) -> &'static str {
1250        match *self {
1251            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1252                "allocate_non_shared_collection"
1253            }
1254            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1255            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1256            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1257                "validate_buffer_collection_token"
1258            }
1259            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1260            AllocatorRequest::ConnectToSysmem2Allocator { .. } => "connect_to_sysmem2_allocator",
1261        }
1262    }
1263}
1264
1265#[derive(Debug, Clone)]
1266pub struct AllocatorControlHandle {
1267    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1268}
1269
1270impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
1271    fn shutdown(&self) {
1272        self.inner.shutdown()
1273    }
1274
1275    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1276        self.inner.shutdown_with_epitaph(status)
1277    }
1278
1279    fn is_closed(&self) -> bool {
1280        self.inner.channel().is_closed()
1281    }
1282    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1283        self.inner.channel().on_closed()
1284    }
1285
1286    #[cfg(target_os = "fuchsia")]
1287    fn signal_peer(
1288        &self,
1289        clear_mask: zx::Signals,
1290        set_mask: zx::Signals,
1291    ) -> Result<(), zx_status::Status> {
1292        use fidl::Peered;
1293        self.inner.channel().signal_peer(clear_mask, set_mask)
1294    }
1295}
1296
1297impl AllocatorControlHandle {}
1298
1299#[must_use = "FIDL methods require a response to be sent"]
1300#[derive(Debug)]
1301pub struct AllocatorValidateBufferCollectionTokenResponder {
1302    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1303    tx_id: u32,
1304}
1305
1306/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1307/// if the responder is dropped without sending a response, so that the client
1308/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1309impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1310    fn drop(&mut self) {
1311        self.control_handle.shutdown();
1312        // Safety: drops once, never accessed again
1313        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1314    }
1315}
1316
1317impl fidl::endpoints::Responder for AllocatorValidateBufferCollectionTokenResponder {
1318    type ControlHandle = AllocatorControlHandle;
1319
1320    fn control_handle(&self) -> &AllocatorControlHandle {
1321        &self.control_handle
1322    }
1323
1324    fn drop_without_shutdown(mut self) {
1325        // Safety: drops once, never accessed again due to mem::forget
1326        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1327        // Prevent Drop from running (which would shut down the channel)
1328        std::mem::forget(self);
1329    }
1330}
1331
1332impl AllocatorValidateBufferCollectionTokenResponder {
1333    /// Sends a response to the FIDL transaction.
1334    ///
1335    /// Sets the channel to shutdown if an error occurs.
1336    pub fn send(self, mut is_known: bool) -> Result<(), fidl::Error> {
1337        let _result = self.send_raw(is_known);
1338        if _result.is_err() {
1339            self.control_handle.shutdown();
1340        }
1341        self.drop_without_shutdown();
1342        _result
1343    }
1344
1345    /// Similar to "send" but does not shutdown the channel if an error occurs.
1346    pub fn send_no_shutdown_on_err(self, mut is_known: bool) -> Result<(), fidl::Error> {
1347        let _result = self.send_raw(is_known);
1348        self.drop_without_shutdown();
1349        _result
1350    }
1351
1352    fn send_raw(&self, mut is_known: bool) -> Result<(), fidl::Error> {
1353        self.control_handle.inner.send::<AllocatorValidateBufferCollectionTokenResponse>(
1354            (is_known,),
1355            self.tx_id,
1356            0x575b279b0236faea,
1357            fidl::encoding::DynamicFlags::empty(),
1358        )
1359    }
1360}
1361
1362#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1363pub struct BufferCollectionMarker;
1364
1365impl fidl::endpoints::ProtocolMarker for BufferCollectionMarker {
1366    type Proxy = BufferCollectionProxy;
1367    type RequestStream = BufferCollectionRequestStream;
1368    #[cfg(target_os = "fuchsia")]
1369    type SynchronousProxy = BufferCollectionSynchronousProxy;
1370
1371    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1372}
1373
1374pub trait BufferCollectionProxyInterface: Send + Sync {
1375    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1376    fn r#sync(&self) -> Self::SyncResponseFut;
1377    fn r#close(&self) -> Result<(), fidl::Error>;
1378    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
1379    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
1380    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
1381    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1382    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
1383        + Send;
1384    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1385    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1386        + Send;
1387    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
1388    fn r#set_constraints(
1389        &self,
1390        has_constraints: bool,
1391        constraints: &BufferCollectionConstraints,
1392    ) -> Result<(), fidl::Error>;
1393    type WaitForBuffersAllocatedResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1394        + Send;
1395    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut;
1396    type CheckBuffersAllocatedResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1397        + Send;
1398    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut;
1399    fn r#attach_token(
1400        &self,
1401        rights_attenuation_mask: u32,
1402        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1403    ) -> Result<(), fidl::Error>;
1404    fn r#attach_lifetime_tracking(
1405        &self,
1406        server_end: fidl::EventPair,
1407        buffers_remaining: u32,
1408    ) -> Result<(), fidl::Error>;
1409}
1410#[derive(Debug)]
1411#[cfg(target_os = "fuchsia")]
1412pub struct BufferCollectionSynchronousProxy {
1413    client: fidl::client::sync::Client,
1414}
1415
1416#[cfg(target_os = "fuchsia")]
1417impl fidl::endpoints::SynchronousProxy for BufferCollectionSynchronousProxy {
1418    type Proxy = BufferCollectionProxy;
1419    type Protocol = BufferCollectionMarker;
1420
1421    fn from_channel(inner: fidl::Channel) -> Self {
1422        Self::new(inner)
1423    }
1424
1425    fn into_channel(self) -> fidl::Channel {
1426        self.client.into_channel()
1427    }
1428
1429    fn as_channel(&self) -> &fidl::Channel {
1430        self.client.as_channel()
1431    }
1432}
1433
1434#[cfg(target_os = "fuchsia")]
1435impl BufferCollectionSynchronousProxy {
1436    pub fn new(channel: fidl::Channel) -> Self {
1437        Self { client: fidl::client::sync::Client::new(channel) }
1438    }
1439
1440    pub fn into_channel(self) -> fidl::Channel {
1441        self.client.into_channel()
1442    }
1443
1444    /// Waits until an event arrives and returns it. It is safe for other
1445    /// threads to make concurrent requests while waiting for an event.
1446    pub fn wait_for_event(
1447        &self,
1448        deadline: zx::MonotonicInstant,
1449    ) -> Result<BufferCollectionEvent, fidl::Error> {
1450        BufferCollectionEvent::decode(
1451            self.client.wait_for_event::<BufferCollectionMarker>(deadline)?,
1452        )
1453    }
1454
1455    /// Ensure that previous messages, including Duplicate() messages on a
1456    /// token, collection, or group, have been received server side.
1457    ///
1458    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
1459    /// valid sysmem token risks the Sync() hanging forever.  See
1460    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
1461    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
1462    /// Another way is to pass the token to BindSharedCollection(), which also
1463    /// validates the token as part of exchanging it for a BufferCollection
1464    /// channel, and BufferCollection Sync() can then be used.
1465    ///
1466    /// After a Sync(), it's then safe to send the client end of token_request
1467    /// to another participant knowing the server will recognize the token when
1468    /// it's sent into BindSharedCollection() by the other participant.
1469    ///
1470    /// Other options include waiting for each token.Duplicate() to complete
1471    /// individually (using separate call to token.Sync() after each), or
1472    /// calling Sync() on BufferCollection after the token has been turned in
1473    /// via BindSharedCollection().
1474    ///
1475    /// Another way to mitigate is to avoid calling Sync() on the token, and
1476    /// instead later deal with potential failure of BufferCollection.Sync() if
1477    /// the original token was invalid.  This option can be preferable from a
1478    /// performance point of view, but requires client code to delay sending
1479    /// tokens duplicated from this token until after client code has converted
1480    /// the duplicating token to a BufferCollection and received successful
1481    /// response from BufferCollection.Sync().
1482    ///
1483    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
1484    /// When BufferCollection.Sync() isn't feasible, the caller must already
1485    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
1486    /// hang forever.  See ValidateBufferCollectionToken() to check token
1487    /// validity first if the token isn't already known to be (is/was) valid.
1488    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1489        let _response = self.client.send_query::<
1490            fidl::encoding::EmptyPayload,
1491            fidl::encoding::EmptyPayload,
1492            BufferCollectionMarker,
1493        >(
1494            (),
1495            0x4577e238ae26291,
1496            fidl::encoding::DynamicFlags::empty(),
1497            ___deadline,
1498        )?;
1499        Ok(_response)
1500    }
1501
1502    /// On a BufferCollectionToken channel:
1503    ///
1504    /// Normally a participant will convert a BufferCollectionToken into a
1505    /// BufferCollection view, but a participant is also free to Close() the
1506    /// token (and then close the channel immediately or shortly later in
1507    /// response to server closing its end), which avoids causing logical buffer
1508    /// collection failure.  Normally an unexpected token channel close will
1509    /// cause logical buffer collection failure (the only exceptions being
1510    /// certain cases involving AttachToken() or SetDispensable()).
1511    ///
1512    /// On a BufferCollection channel:
1513    ///
1514    /// By default the server handles unexpected failure of a BufferCollection
1515    /// by failing the whole logical buffer collection.  Partly this is to
1516    /// expedite closing VMO handles to reclaim memory when any participant
1517    /// fails.  If a participant would like to cleanly close a BufferCollection
1518    /// view without causing logical buffer collection failure, the participant
1519    /// can send Close() before closing the client end of the BufferCollection
1520    /// channel.  If this is the last BufferCollection view, the logical buffer
1521    /// collection will still go away.  The Close() can occur before or after
1522    /// SetConstraints().  If before SetConstraints(), the buffer collection
1523    /// won't require constraints from this node in order to allocate.  If
1524    /// after SetConstraints(), the constraints are retained and aggregated
1525    /// along with any subsequent logical allocation(s), despite the lack of
1526    /// channel connection.
1527    ///
1528    /// On a BufferCollectionTokenGroup channel:
1529    ///
1530    /// By default, unexpected failure of a BufferCollectionTokenGroup will
1531    /// trigger failure of the logical BufferCollectionTokenGroup and will
1532    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
1533    /// channel without failing the logical group or propagating failure, send
1534    /// Close() before closing the channel client endpoint.
1535    ///
1536    /// If Close() occurs before AllChildrenPresent(), the logical buffer
1537    /// collection will still fail despite the Close() (because sysmem can't be
1538    /// sure whether all relevant children were created, so it's ambiguous
1539    /// whether all relevant constraints will be provided to sysmem).  If
1540    /// Close() occurs after AllChildrenPresent(), the children and all their
1541    /// constraints remain intact (just as they would if the
1542    /// BufferCollectionTokenGroup channel had remained open), and the close
1543    /// doesn't trigger or propagate failure.
1544    pub fn r#close(&self) -> Result<(), fidl::Error> {
1545        self.client.send::<fidl::encoding::EmptyPayload>(
1546            (),
1547            0x5b1d7a4f5681fca7,
1548            fidl::encoding::DynamicFlags::empty(),
1549        )
1550    }
1551
1552    /// Set a name for VMOs in this buffer collection. The name may be truncated
1553    /// shorter. The name only affects VMOs allocated after it's set - this call
1554    /// does not rename existing VMOs. If multiple clients set different names
1555    /// then the larger priority value will win.
1556    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1557        self.client.send::<NodeSetNameRequest>(
1558            (priority, name),
1559            0x77a41bb6217e2443,
1560            fidl::encoding::DynamicFlags::empty(),
1561        )
1562    }
1563
1564    /// Set information about the current client that can be used by sysmem to
1565    /// help debug leaking memory and hangs waiting for constraints. |name| can
1566    /// be an arbitrary string, but the current process name (see
1567    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1568    /// arbitrary id, but the current process ID (see
1569    /// fsl::GetCurrentProcessKoid()) is a good default.
1570    ///
1571    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
1572    /// indicate which client is closing their channel first, leading to
1573    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
1574    /// over, but if happening earlier than expected, the
1575    /// client-channel-specific name can help diagnose where the failure is
1576    /// first coming from, from sysmem's point of view).
1577    ///
1578    /// By default (unless overriden by this message or using
1579    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
1580    /// parent Node at the time the child Node is created.  While this can be
1581    /// better than nothing, it's often better for each participant to use
1582    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
1583    /// info directly relevant to the current client.  Also, SetVerboseLogging()
1584    /// can be used to help disambiguate if a Node is suspected of having info
1585    /// that was copied from its parent.
1586    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1587        self.client.send::<NodeSetDebugClientInfoRequest>(
1588            (name, id),
1589            0x7275759070eb5ee2,
1590            fidl::encoding::DynamicFlags::empty(),
1591        )
1592    }
1593
1594    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
1595    /// after creating a collection. Clients can call this method to change
1596    /// when the log is printed. If multiple client set the deadline, it's
1597    /// unspecified which deadline will take effect.
1598    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1599        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
1600            (deadline,),
1601            0x46d38f4772638867,
1602            fidl::encoding::DynamicFlags::empty(),
1603        )
1604    }
1605
1606    /// Verbose logging includes constraints set via SetConstraints() from each
1607    /// client along with info set via SetDebugClientInfo() and the structure of
1608    /// the tree of Node(s).
1609    ///
1610    /// Normally sysmem prints only a single line complaint when aggregation
1611    /// fails, with just the specific detailed reason that aggregation failed,
1612    /// with minimal context.  While this is often enough to diagnose a problem
1613    /// if only a small change was made and the system had been working before
1614    /// the small change, it's often not particularly helpful for getting a new
1615    /// buffer collection to work for the first time.  Especially with more
1616    /// complex trees of nodes, involving things like AttachToken(),
1617    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
1618    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
1619    /// looks like and why it's failing a logical allocation, or why a tree or
1620    /// sub-tree is failing sooner than expected.
1621    ///
1622    /// The intent of the extra logging is to be acceptable from a performance
1623    /// point of view, if only enabled on a low number of buffer collections.
1624    /// If we're not tracking down a bug, we shouldn't send this message.
1625    ///
1626    /// If too many participants leave verbose logging enabled, we may end up
1627    /// needing to require that system-wide sysmem verbose logging be permitted
1628    /// via some other setting, to avoid sysmem spamming the log too much due to
1629    /// this message.
1630    ///
1631    /// This may be a NOP for some nodes due to intentional policy associated
1632    /// with the node, if we don't trust a node enough to let it turn on verbose
1633    /// logging.
1634    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1635        self.client.send::<fidl::encoding::EmptyPayload>(
1636            (),
1637            0x6bfbe2cf1701d288,
1638            fidl::encoding::DynamicFlags::empty(),
1639        )
1640    }
1641
1642    /// This gets an event handle that can be used as a parameter to
1643    /// IsAlternateFor() called on any Node.  The client will not be granted the
1644    /// right to signal this event, as this handle should only be used as proof
1645    /// that the client obtained this handle from this Node.
1646    ///
1647    /// Because this is a get not a set, no Sync() is needed between the
1648    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
1649    /// potentially being on different channels.
1650    ///
1651    /// See also IsAlternateFor().
1652    pub fn r#get_node_ref(
1653        &self,
1654        ___deadline: zx::MonotonicInstant,
1655    ) -> Result<fidl::Event, fidl::Error> {
1656        let _response = self.client.send_query::<
1657            fidl::encoding::EmptyPayload,
1658            NodeGetNodeRefResponse,
1659            BufferCollectionMarker,
1660        >(
1661            (),
1662            0x467b7c75c35c3b84,
1663            fidl::encoding::DynamicFlags::empty(),
1664            ___deadline,
1665        )?;
1666        Ok(_response.node_ref)
1667    }
1668
1669    /// This checks whether the calling node is in a subtree rooted at a
1670    /// different child token of a common parent BufferCollectionTokenGroup, in
1671    /// relation to the passed-in node_ref.
1672    ///
1673    /// This call is for assisting with admission control de-duplication, and
1674    /// with debugging.
1675    ///
1676    /// The node_ref must be obtained using GetNodeRef() of a
1677    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
1678    ///
1679    /// The node_ref can be a duplicated handle; it's not necessary to call
1680    /// GetNodeRef() for every call to IsAlternateFor().
1681    ///
1682    /// If a calling token may not actually be a valid token at all due to
1683    /// a potentially hostile/untrusted provider of the token, call
1684    /// ValidateBufferCollectionToken() first instead of potentially getting
1685    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
1686    /// token not being a real token (not really talking to sysmem).  Another
1687    /// option is to call BindSharedCollection with this token first which also
1688    /// validates the token along with converting it to a BufferCollection, then
1689    /// call BufferCollection IsAlternateFor().
1690    ///
1691    /// error values:
1692    ///
1693    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
1694    /// buffer collection as the calling Node.  Before logical allocation and
1695    /// within the same logical allocation sub-tree, this essentially means that
1696    /// the node_ref was never part of this logical buffer collection, since
1697    /// before logical allocation all node_refs that come into existence remain
1698    /// in existence at least until logical allocation (including Node(s) that
1699    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
1700    /// to be returned, this Node's channel needs to still be connected server
1701    /// side, which won't be the case if the whole logical allocation has
1702    /// failed.  After logical allocation or in a different logical allocation
1703    /// sub-tree there are additional potential reasons for this error.  For
1704    /// example a different logical allocation (separated from this Node(s)
1705    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
1706    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
1707    /// exist and may select a different child sub-tree than the sub-tree the
1708    /// node_ref is in causing deletion of the node_ref Node.  The only time
1709    /// sysmem keeps a Node around after that Node has no corresponding channel
1710    /// is when Close() is used and the Node's sub-tree has not yet failed.
1711    /// Another reason for this error is if the node_ref is an eventpair handle
1712    /// with sufficient rights, but isn't actually a real node_ref obtained from
1713    /// GetNodeRef().
1714    ///
1715    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
1716    /// eventpair handle, or doesn't have the needed rights expected on a real
1717    /// node_ref.
1718    ///
1719    /// No other failing status codes are returned by this call.  However,
1720    /// sysmem may add additional codes in future, so the client should have
1721    /// sensible default handling for any failing status code.
1722    ///
1723    /// On success, is_alternate has the following meaning:
1724    ///   * true - The first parent node in common between the calling node and
1725    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
1726    ///     the calling Node and the node_ref Node will _not_ have both their
1727    ///     constraints apply - rather sysmem will choose one or the other of
1728    ///     the constraints - never both.  This is because only one child of
1729    ///     a BufferCollectionTokenGroup is selected during logical allocation,
1730    ///     with only that one child's sub-tree contributing to constraints
1731    ///     aggregation.
1732    ///   * false - The first parent node in common between the calling Node and
1733    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
1734    ///     this means the first parent node in common is a
1735    ///     BufferCollectionToken or BufferCollection (regardless of not
1736    ///     Close()ed or Close()ed).  This means that the calling Node and the
1737    ///     node_ref Node _may_ have both their constraints apply during
1738    ///     constraints aggregation of the logical allocation, if both Node(s)
1739    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
1740    ///     In this case, there is no BufferCollectionTokenGroup that will
1741    ///     directly prevent the two Node(s) from both being selected and their
1742    ///     constraints both aggregated, but even when false, one or both
1743    ///     Node(s) may still be eliminated from consideration if one or both
1744    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
1745    ///     which selects a child sub-tree other than the sub-tree containing
1746    ///     the calling Node or node_ref Node.
1747    pub fn r#is_alternate_for(
1748        &self,
1749        mut node_ref: fidl::Event,
1750        ___deadline: zx::MonotonicInstant,
1751    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
1752        let _response = self.client.send_query::<
1753            NodeIsAlternateForRequest,
1754            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
1755            BufferCollectionMarker,
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            BufferCollectionMarker,
1833        >(
1834            (),
1835            0x714667ea2a29a3a2,
1836            fidl::encoding::DynamicFlags::empty(),
1837            ___deadline,
1838        )?;
1839        Ok((_response.status, _response.buffer_collection_info))
1840    }
1841
1842    /// This returns the same result code as WaitForBuffersAllocated if the
1843    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
1844    /// if WaitForBuffersAllocated would block.
1845    pub fn r#check_buffers_allocated(
1846        &self,
1847        ___deadline: zx::MonotonicInstant,
1848    ) -> Result<i32, fidl::Error> {
1849        let _response = self.client.send_query::<
1850            fidl::encoding::EmptyPayload,
1851            BufferCollectionCheckBuffersAllocatedResponse,
1852            BufferCollectionMarker,
1853        >(
1854            (),
1855            0x245bb81f79189e9,
1856            fidl::encoding::DynamicFlags::empty(),
1857            ___deadline,
1858        )?;
1859        Ok(_response.status)
1860    }
1861
1862    /// Create a new token, for trying to add a new participant to an existing
1863    /// collection, if the existing collection's buffer counts, constraints,
1864    /// and participants allow.
1865    ///
1866    /// This can be useful in replacing a failed participant, and/or in
1867    /// adding/re-adding a participant after buffers have already been
1868    /// allocated.
1869    ///
1870    /// Failure of an attached token / collection does not propagate to the
1871    /// parent of the attached token.  Failure does propagate from a normal
1872    /// child of a dispensable token to the dispensable token.  Failure
1873    /// of a child is blocked from reaching its parent if the child is attached,
1874    /// or if the child is dispensable and the failure occurred after logical
1875    /// allocation.
1876    ///
1877    /// An initiator may in some scenarios choose to initially use a dispensable
1878    /// token for a given instance of a participant, and then later if the first
1879    /// instance of that participant fails, a new second instance of that
1880    /// participant my be given a token created with AttachToken().
1881    ///
1882    /// From the point of view of the client end of the BufferCollectionToken
1883    /// channel, the token acts like any other token.  The client can
1884    /// Duplicate() the token as needed, and can send the token to a different
1885    /// process.  The token should be converted to a BufferCollection channel
1886    /// as normal by calling BindSharedCollection().  SetConstraints() should
1887    /// be called on that BufferCollection channel.
1888    ///
1889    /// A success result from WaitForBuffersAllocated() means the new
1890    /// participant's constraints were satisfiable using the already-existing
1891    /// buffer collection, the already-established BufferCollectionInfo
1892    /// including image format constraints, and the already-existing other
1893    /// participants and their buffer counts.  A failure result means the new
1894    /// participant's constraints cannot be satisfied using the existing
1895    /// buffer collection and its already-logically-allocated participants.
1896    /// Creating a new collection instead may allow all participant's
1897    /// constraints to be satisfied, assuming SetDispensable() is used in place
1898    /// of AttachToken(), or a normal token is used.
1899    ///
1900    /// A token created with AttachToken() performs constraints aggregation with
1901    /// all constraints currently in effect on the buffer collection, plus the
1902    /// attached token under consideration plus child tokens under the attached
1903    /// token which are not themselves an attached token or under such a token.
1904    ///
1905    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
1906    /// first-come first-served, but a child can't logically allocate before
1907    /// all its parents have sent SetConstraints().
1908    ///
1909    /// See also SetDispensable(), which in contrast to AttachToken(), has the
1910    /// created token + children participate in constraints aggregation along
1911    /// with its parent.
1912    ///
1913    /// The newly created token needs to be Sync()ed to sysmem before the new
1914    /// token can be passed to BindSharedCollection().  The Sync() of the new
1915    /// token can be accomplished with BufferCollection.Sync() on this
1916    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
1917    /// token also works.  A BufferCollectionToken.Sync() can be started after
1918    /// any BufferCollectionToken.Duplicate() messages have been sent via the
1919    /// newly created token, to also sync those additional tokens to sysmem
1920    /// using a single round-trip.
1921    ///
1922    /// These values for rights_attenuation_mask result in no attenuation (note
1923    /// that 0 is not on this list; 0 will output an ERROR to the system log
1924    /// to help diagnose the bug in client code):
1925    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
1926    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
1927    pub fn r#attach_token(
1928        &self,
1929        mut rights_attenuation_mask: u32,
1930        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
1931    ) -> Result<(), fidl::Error> {
1932        self.client.send::<BufferCollectionAttachTokenRequest>(
1933            (rights_attenuation_mask, token_request),
1934            0x6f5adcca4ac7443e,
1935            fidl::encoding::DynamicFlags::empty(),
1936        )
1937    }
1938
1939    /// AttachLifetimeTracking:
1940    ///
1941    /// AttachLifetimeTracking() is intended to allow a client to wait until an
1942    /// old logical buffer collection is fully or mostly deallocated before
1943    /// attempting allocation of a new logical buffer collection.
1944    ///
1945    /// Attach an eventpair endpoint to the logical buffer collection, so that
1946    /// the server_end will be closed when the number of buffers allocated
1947    /// drops to 'buffers_remaining'.  The server_end won't close until after
1948    /// logical allocation has completed.
1949    ///
1950    /// If logical allocation fails, such as for an attached sub-tree (using
1951    /// AttachToken()), the server_end will close during that failure regardless
1952    /// of the number of buffers potenitally allocated in the overall logical
1953    /// buffer collection.
1954    ///
1955    /// The lifetime signalled by this event includes asynchronous cleanup of
1956    /// allocated buffers, and this asynchronous cleanup cannot occur until all
1957    /// holders of VMO handles to the buffers have closed those VMO handles.
1958    /// Therefore clients should take care not to become blocked forever waiting
1959    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
1960    /// participants using the logical buffer collection are less trusted or
1961    /// less reliable.
1962    ///
1963    /// The buffers_remaining parameter allows waiting for all but
1964    /// buffers_remaining buffers to be fully deallocated.  This can be useful
1965    /// in situations where a known number of buffers are intentionally not
1966    /// closed so that the data can continue to be used, such as for keeping the
1967    /// last available video picture displayed in the UI even if the video
1968    /// stream was using protected output buffers.  It's outside the scope of
1969    /// the BufferCollection interface (at least for now) to determine how many
1970    /// buffers may be held without closing, but it'll typically be in the range
1971    /// 0-2.
1972    ///
1973    /// This mechanism is meant to be compatible with other protocols providing
1974    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
1975    /// same event can be sent to more than one AttachLifetimeTracking(), and
1976    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
1977    /// over conditions are met (all holders of duplicates have closed their
1978    /// handle(s)).
1979    ///
1980    /// There is no way to cancel an attach.  Closing the client end of the
1981    /// eventpair doesn't subtract from the number of pending attach(es).
1982    ///
1983    /// Closing the client's end doesn't result in any action by the server.
1984    /// If the server listens to events from the client end at all, it is for
1985    /// debug logging only.
1986    ///
1987    /// The server intentionally doesn't "trust" any bits signalled by the
1988    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
1989    /// which can't be triggered early, and is only triggered when all handles
1990    /// to server_end are closed.  No meaning is associated with any of the
1991    /// other signal bits, and clients should functionally ignore any other
1992    /// signal bits on either end of the eventpair or its peer.
1993    ///
1994    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
1995    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
1996    /// transfer without causing CodecFactory channel failure).
1997    pub fn r#attach_lifetime_tracking(
1998        &self,
1999        mut server_end: fidl::EventPair,
2000        mut buffers_remaining: u32,
2001    ) -> Result<(), fidl::Error> {
2002        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2003            (server_end, buffers_remaining),
2004            0x170d0f1d89d50989,
2005            fidl::encoding::DynamicFlags::empty(),
2006        )
2007    }
2008}
2009
2010#[cfg(target_os = "fuchsia")]
2011impl From<BufferCollectionSynchronousProxy> for zx::NullableHandle {
2012    fn from(value: BufferCollectionSynchronousProxy) -> Self {
2013        value.into_channel().into()
2014    }
2015}
2016
2017#[cfg(target_os = "fuchsia")]
2018impl From<fidl::Channel> for BufferCollectionSynchronousProxy {
2019    fn from(value: fidl::Channel) -> Self {
2020        Self::new(value)
2021    }
2022}
2023
2024#[cfg(target_os = "fuchsia")]
2025impl fidl::endpoints::FromClient for BufferCollectionSynchronousProxy {
2026    type Protocol = BufferCollectionMarker;
2027
2028    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionMarker>) -> Self {
2029        Self::new(value.into_channel())
2030    }
2031}
2032
2033#[derive(Debug, Clone)]
2034pub struct BufferCollectionProxy {
2035    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2036}
2037
2038impl fidl::endpoints::Proxy for BufferCollectionProxy {
2039    type Protocol = BufferCollectionMarker;
2040
2041    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2042        Self::new(inner)
2043    }
2044
2045    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2046        self.client.into_channel().map_err(|client| Self { client })
2047    }
2048
2049    fn as_channel(&self) -> &::fidl::AsyncChannel {
2050        self.client.as_channel()
2051    }
2052}
2053
2054impl BufferCollectionProxy {
2055    /// Create a new Proxy for fuchsia.sysmem/BufferCollection.
2056    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2057        let protocol_name = <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2058        Self { client: fidl::client::Client::new(channel, protocol_name) }
2059    }
2060
2061    /// Get a Stream of events from the remote end of the protocol.
2062    ///
2063    /// # Panics
2064    ///
2065    /// Panics if the event stream was already taken.
2066    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
2067        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
2068    }
2069
2070    /// Ensure that previous messages, including Duplicate() messages on a
2071    /// token, collection, or group, have been received server side.
2072    ///
2073    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
2074    /// valid sysmem token risks the Sync() hanging forever.  See
2075    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
2076    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
2077    /// Another way is to pass the token to BindSharedCollection(), which also
2078    /// validates the token as part of exchanging it for a BufferCollection
2079    /// channel, and BufferCollection Sync() can then be used.
2080    ///
2081    /// After a Sync(), it's then safe to send the client end of token_request
2082    /// to another participant knowing the server will recognize the token when
2083    /// it's sent into BindSharedCollection() by the other participant.
2084    ///
2085    /// Other options include waiting for each token.Duplicate() to complete
2086    /// individually (using separate call to token.Sync() after each), or
2087    /// calling Sync() on BufferCollection after the token has been turned in
2088    /// via BindSharedCollection().
2089    ///
2090    /// Another way to mitigate is to avoid calling Sync() on the token, and
2091    /// instead later deal with potential failure of BufferCollection.Sync() if
2092    /// the original token was invalid.  This option can be preferable from a
2093    /// performance point of view, but requires client code to delay sending
2094    /// tokens duplicated from this token until after client code has converted
2095    /// the duplicating token to a BufferCollection and received successful
2096    /// response from BufferCollection.Sync().
2097    ///
2098    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
2099    /// When BufferCollection.Sync() isn't feasible, the caller must already
2100    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
2101    /// hang forever.  See ValidateBufferCollectionToken() to check token
2102    /// validity first if the token isn't already known to be (is/was) valid.
2103    pub fn r#sync(
2104        &self,
2105    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2106        BufferCollectionProxyInterface::r#sync(self)
2107    }
2108
2109    /// On a BufferCollectionToken channel:
2110    ///
2111    /// Normally a participant will convert a BufferCollectionToken into a
2112    /// BufferCollection view, but a participant is also free to Close() the
2113    /// token (and then close the channel immediately or shortly later in
2114    /// response to server closing its end), which avoids causing logical buffer
2115    /// collection failure.  Normally an unexpected token channel close will
2116    /// cause logical buffer collection failure (the only exceptions being
2117    /// certain cases involving AttachToken() or SetDispensable()).
2118    ///
2119    /// On a BufferCollection channel:
2120    ///
2121    /// By default the server handles unexpected failure of a BufferCollection
2122    /// by failing the whole logical buffer collection.  Partly this is to
2123    /// expedite closing VMO handles to reclaim memory when any participant
2124    /// fails.  If a participant would like to cleanly close a BufferCollection
2125    /// view without causing logical buffer collection failure, the participant
2126    /// can send Close() before closing the client end of the BufferCollection
2127    /// channel.  If this is the last BufferCollection view, the logical buffer
2128    /// collection will still go away.  The Close() can occur before or after
2129    /// SetConstraints().  If before SetConstraints(), the buffer collection
2130    /// won't require constraints from this node in order to allocate.  If
2131    /// after SetConstraints(), the constraints are retained and aggregated
2132    /// along with any subsequent logical allocation(s), despite the lack of
2133    /// channel connection.
2134    ///
2135    /// On a BufferCollectionTokenGroup channel:
2136    ///
2137    /// By default, unexpected failure of a BufferCollectionTokenGroup will
2138    /// trigger failure of the logical BufferCollectionTokenGroup and will
2139    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
2140    /// channel without failing the logical group or propagating failure, send
2141    /// Close() before closing the channel client endpoint.
2142    ///
2143    /// If Close() occurs before AllChildrenPresent(), the logical buffer
2144    /// collection will still fail despite the Close() (because sysmem can't be
2145    /// sure whether all relevant children were created, so it's ambiguous
2146    /// whether all relevant constraints will be provided to sysmem).  If
2147    /// Close() occurs after AllChildrenPresent(), the children and all their
2148    /// constraints remain intact (just as they would if the
2149    /// BufferCollectionTokenGroup channel had remained open), and the close
2150    /// doesn't trigger or propagate failure.
2151    pub fn r#close(&self) -> Result<(), fidl::Error> {
2152        BufferCollectionProxyInterface::r#close(self)
2153    }
2154
2155    /// Set a name for VMOs in this buffer collection. The name may be truncated
2156    /// shorter. The name only affects VMOs allocated after it's set - this call
2157    /// does not rename existing VMOs. If multiple clients set different names
2158    /// then the larger priority value will win.
2159    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2160        BufferCollectionProxyInterface::r#set_name(self, priority, name)
2161    }
2162
2163    /// Set information about the current client that can be used by sysmem to
2164    /// help debug leaking memory and hangs waiting for constraints. |name| can
2165    /// be an arbitrary string, but the current process name (see
2166    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
2167    /// arbitrary id, but the current process ID (see
2168    /// fsl::GetCurrentProcessKoid()) is a good default.
2169    ///
2170    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
2171    /// indicate which client is closing their channel first, leading to
2172    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
2173    /// over, but if happening earlier than expected, the
2174    /// client-channel-specific name can help diagnose where the failure is
2175    /// first coming from, from sysmem's point of view).
2176    ///
2177    /// By default (unless overriden by this message or using
2178    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
2179    /// parent Node at the time the child Node is created.  While this can be
2180    /// better than nothing, it's often better for each participant to use
2181    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
2182    /// info directly relevant to the current client.  Also, SetVerboseLogging()
2183    /// can be used to help disambiguate if a Node is suspected of having info
2184    /// that was copied from its parent.
2185    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2186        BufferCollectionProxyInterface::r#set_debug_client_info(self, name, id)
2187    }
2188
2189    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
2190    /// after creating a collection. Clients can call this method to change
2191    /// when the log is printed. If multiple client set the deadline, it's
2192    /// unspecified which deadline will take effect.
2193    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2194        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
2195    }
2196
2197    /// Verbose logging includes constraints set via SetConstraints() from each
2198    /// client along with info set via SetDebugClientInfo() and the structure of
2199    /// the tree of Node(s).
2200    ///
2201    /// Normally sysmem prints only a single line complaint when aggregation
2202    /// fails, with just the specific detailed reason that aggregation failed,
2203    /// with minimal context.  While this is often enough to diagnose a problem
2204    /// if only a small change was made and the system had been working before
2205    /// the small change, it's often not particularly helpful for getting a new
2206    /// buffer collection to work for the first time.  Especially with more
2207    /// complex trees of nodes, involving things like AttachToken(),
2208    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
2209    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
2210    /// looks like and why it's failing a logical allocation, or why a tree or
2211    /// sub-tree is failing sooner than expected.
2212    ///
2213    /// The intent of the extra logging is to be acceptable from a performance
2214    /// point of view, if only enabled on a low number of buffer collections.
2215    /// If we're not tracking down a bug, we shouldn't send this message.
2216    ///
2217    /// If too many participants leave verbose logging enabled, we may end up
2218    /// needing to require that system-wide sysmem verbose logging be permitted
2219    /// via some other setting, to avoid sysmem spamming the log too much due to
2220    /// this message.
2221    ///
2222    /// This may be a NOP for some nodes due to intentional policy associated
2223    /// with the node, if we don't trust a node enough to let it turn on verbose
2224    /// logging.
2225    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2226        BufferCollectionProxyInterface::r#set_verbose_logging(self)
2227    }
2228
2229    /// This gets an event handle that can be used as a parameter to
2230    /// IsAlternateFor() called on any Node.  The client will not be granted the
2231    /// right to signal this event, as this handle should only be used as proof
2232    /// that the client obtained this handle from this Node.
2233    ///
2234    /// Because this is a get not a set, no Sync() is needed between the
2235    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
2236    /// potentially being on different channels.
2237    ///
2238    /// See also IsAlternateFor().
2239    pub fn r#get_node_ref(
2240        &self,
2241    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
2242    {
2243        BufferCollectionProxyInterface::r#get_node_ref(self)
2244    }
2245
2246    /// This checks whether the calling node is in a subtree rooted at a
2247    /// different child token of a common parent BufferCollectionTokenGroup, in
2248    /// relation to the passed-in node_ref.
2249    ///
2250    /// This call is for assisting with admission control de-duplication, and
2251    /// with debugging.
2252    ///
2253    /// The node_ref must be obtained using GetNodeRef() of a
2254    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
2255    ///
2256    /// The node_ref can be a duplicated handle; it's not necessary to call
2257    /// GetNodeRef() for every call to IsAlternateFor().
2258    ///
2259    /// If a calling token may not actually be a valid token at all due to
2260    /// a potentially hostile/untrusted provider of the token, call
2261    /// ValidateBufferCollectionToken() first instead of potentially getting
2262    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
2263    /// token not being a real token (not really talking to sysmem).  Another
2264    /// option is to call BindSharedCollection with this token first which also
2265    /// validates the token along with converting it to a BufferCollection, then
2266    /// call BufferCollection IsAlternateFor().
2267    ///
2268    /// error values:
2269    ///
2270    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
2271    /// buffer collection as the calling Node.  Before logical allocation and
2272    /// within the same logical allocation sub-tree, this essentially means that
2273    /// the node_ref was never part of this logical buffer collection, since
2274    /// before logical allocation all node_refs that come into existence remain
2275    /// in existence at least until logical allocation (including Node(s) that
2276    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
2277    /// to be returned, this Node's channel needs to still be connected server
2278    /// side, which won't be the case if the whole logical allocation has
2279    /// failed.  After logical allocation or in a different logical allocation
2280    /// sub-tree there are additional potential reasons for this error.  For
2281    /// example a different logical allocation (separated from this Node(s)
2282    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
2283    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
2284    /// exist and may select a different child sub-tree than the sub-tree the
2285    /// node_ref is in causing deletion of the node_ref Node.  The only time
2286    /// sysmem keeps a Node around after that Node has no corresponding channel
2287    /// is when Close() is used and the Node's sub-tree has not yet failed.
2288    /// Another reason for this error is if the node_ref is an eventpair handle
2289    /// with sufficient rights, but isn't actually a real node_ref obtained from
2290    /// GetNodeRef().
2291    ///
2292    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
2293    /// eventpair handle, or doesn't have the needed rights expected on a real
2294    /// node_ref.
2295    ///
2296    /// No other failing status codes are returned by this call.  However,
2297    /// sysmem may add additional codes in future, so the client should have
2298    /// sensible default handling for any failing status code.
2299    ///
2300    /// On success, is_alternate has the following meaning:
2301    ///   * true - The first parent node in common between the calling node and
2302    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
2303    ///     the calling Node and the node_ref Node will _not_ have both their
2304    ///     constraints apply - rather sysmem will choose one or the other of
2305    ///     the constraints - never both.  This is because only one child of
2306    ///     a BufferCollectionTokenGroup is selected during logical allocation,
2307    ///     with only that one child's sub-tree contributing to constraints
2308    ///     aggregation.
2309    ///   * false - The first parent node in common between the calling Node and
2310    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
2311    ///     this means the first parent node in common is a
2312    ///     BufferCollectionToken or BufferCollection (regardless of not
2313    ///     Close()ed or Close()ed).  This means that the calling Node and the
2314    ///     node_ref Node _may_ have both their constraints apply during
2315    ///     constraints aggregation of the logical allocation, if both Node(s)
2316    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
2317    ///     In this case, there is no BufferCollectionTokenGroup that will
2318    ///     directly prevent the two Node(s) from both being selected and their
2319    ///     constraints both aggregated, but even when false, one or both
2320    ///     Node(s) may still be eliminated from consideration if one or both
2321    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
2322    ///     which selects a child sub-tree other than the sub-tree containing
2323    ///     the calling Node or node_ref Node.
2324    pub fn r#is_alternate_for(
2325        &self,
2326        mut node_ref: fidl::Event,
2327    ) -> fidl::client::QueryResponseFut<
2328        NodeIsAlternateForResult,
2329        fidl::encoding::DefaultFuchsiaResourceDialect,
2330    > {
2331        BufferCollectionProxyInterface::r#is_alternate_for(self, node_ref)
2332    }
2333
2334    /// Provide BufferCollectionConstraints to the logical BufferCollection.
2335    ///
2336    /// A participant may only call SetConstraints() once.
2337    ///
2338    /// Sometimes the initiator is a participant only in the sense of wanting to
2339    /// keep an eye on success/failure to populate with buffers, and zx.Status
2340    /// on failure.  In that case, `has_constraints` can be false, and
2341    /// `constraints` will be ignored.
2342    ///
2343    /// VMO handles will not be provided to the client that sends null
2344    /// constraints - that can be intentional for an initiator that doesn't need
2345    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
2346    /// adjusting which portion of a buffer is considered valid and similar, but
2347    /// the initiator can't hold a VMO handle open to prevent the logical
2348    /// BufferCollection from cleaning up if the logical BufferCollection needs
2349    /// to go away regardless of the initiator's degree of involvement for
2350    /// whatever reason.
2351    ///
2352    /// For population of buffers to be attempted, all holders of a
2353    /// BufferCollection client channel need to call SetConstraints() before
2354    /// sysmem will attempt to allocate buffers.
2355    ///
2356    /// `has_constraints` if false, the constraints are effectively null, and
2357    /// `constraints` are ignored.  The sender of null constraints won't get any
2358    /// VMO handles in BufferCollectionInfo, but can still find out how many
2359    /// buffers were allocated and can still refer to buffers by their
2360    /// buffer_index.
2361    ///
2362    /// `constraints` are constraints on the buffer collection.
2363    pub fn r#set_constraints(
2364        &self,
2365        mut has_constraints: bool,
2366        mut constraints: &BufferCollectionConstraints,
2367    ) -> Result<(), fidl::Error> {
2368        BufferCollectionProxyInterface::r#set_constraints(self, has_constraints, constraints)
2369    }
2370
2371    /// This request completes when buffers have been allocated, responds with
2372    /// some failure detail if allocation has been attempted but failed.
2373    ///
2374    /// The following must occur before buffers will be allocated:
2375    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
2376    ///     must be turned in via BindSharedCollection().
2377    ///   * All BufferCollection(s) of the logical BufferCollection must have
2378    ///     had SetConstraints() sent to them.
2379    ///
2380    /// Returns `ZX_OK` if successful.
2381    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
2382    /// fulfilled due to resource exhaustion.
2383    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
2384    /// obtain the buffers it requested.
2385    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
2386    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
2387    /// satisfied, perhaps due to hardware limitations.
2388    ///
2389    /// `buffer_collection_info` has the VMO handles and other related info.
2390    pub fn r#wait_for_buffers_allocated(
2391        &self,
2392    ) -> fidl::client::QueryResponseFut<
2393        (i32, BufferCollectionInfo2),
2394        fidl::encoding::DefaultFuchsiaResourceDialect,
2395    > {
2396        BufferCollectionProxyInterface::r#wait_for_buffers_allocated(self)
2397    }
2398
2399    /// This returns the same result code as WaitForBuffersAllocated if the
2400    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
2401    /// if WaitForBuffersAllocated would block.
2402    pub fn r#check_buffers_allocated(
2403        &self,
2404    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
2405        BufferCollectionProxyInterface::r#check_buffers_allocated(self)
2406    }
2407
2408    /// Create a new token, for trying to add a new participant to an existing
2409    /// collection, if the existing collection's buffer counts, constraints,
2410    /// and participants allow.
2411    ///
2412    /// This can be useful in replacing a failed participant, and/or in
2413    /// adding/re-adding a participant after buffers have already been
2414    /// allocated.
2415    ///
2416    /// Failure of an attached token / collection does not propagate to the
2417    /// parent of the attached token.  Failure does propagate from a normal
2418    /// child of a dispensable token to the dispensable token.  Failure
2419    /// of a child is blocked from reaching its parent if the child is attached,
2420    /// or if the child is dispensable and the failure occurred after logical
2421    /// allocation.
2422    ///
2423    /// An initiator may in some scenarios choose to initially use a dispensable
2424    /// token for a given instance of a participant, and then later if the first
2425    /// instance of that participant fails, a new second instance of that
2426    /// participant my be given a token created with AttachToken().
2427    ///
2428    /// From the point of view of the client end of the BufferCollectionToken
2429    /// channel, the token acts like any other token.  The client can
2430    /// Duplicate() the token as needed, and can send the token to a different
2431    /// process.  The token should be converted to a BufferCollection channel
2432    /// as normal by calling BindSharedCollection().  SetConstraints() should
2433    /// be called on that BufferCollection channel.
2434    ///
2435    /// A success result from WaitForBuffersAllocated() means the new
2436    /// participant's constraints were satisfiable using the already-existing
2437    /// buffer collection, the already-established BufferCollectionInfo
2438    /// including image format constraints, and the already-existing other
2439    /// participants and their buffer counts.  A failure result means the new
2440    /// participant's constraints cannot be satisfied using the existing
2441    /// buffer collection and its already-logically-allocated participants.
2442    /// Creating a new collection instead may allow all participant's
2443    /// constraints to be satisfied, assuming SetDispensable() is used in place
2444    /// of AttachToken(), or a normal token is used.
2445    ///
2446    /// A token created with AttachToken() performs constraints aggregation with
2447    /// all constraints currently in effect on the buffer collection, plus the
2448    /// attached token under consideration plus child tokens under the attached
2449    /// token which are not themselves an attached token or under such a token.
2450    ///
2451    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
2452    /// first-come first-served, but a child can't logically allocate before
2453    /// all its parents have sent SetConstraints().
2454    ///
2455    /// See also SetDispensable(), which in contrast to AttachToken(), has the
2456    /// created token + children participate in constraints aggregation along
2457    /// with its parent.
2458    ///
2459    /// The newly created token needs to be Sync()ed to sysmem before the new
2460    /// token can be passed to BindSharedCollection().  The Sync() of the new
2461    /// token can be accomplished with BufferCollection.Sync() on this
2462    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
2463    /// token also works.  A BufferCollectionToken.Sync() can be started after
2464    /// any BufferCollectionToken.Duplicate() messages have been sent via the
2465    /// newly created token, to also sync those additional tokens to sysmem
2466    /// using a single round-trip.
2467    ///
2468    /// These values for rights_attenuation_mask result in no attenuation (note
2469    /// that 0 is not on this list; 0 will output an ERROR to the system log
2470    /// to help diagnose the bug in client code):
2471    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
2472    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2473    pub fn r#attach_token(
2474        &self,
2475        mut rights_attenuation_mask: u32,
2476        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2477    ) -> Result<(), fidl::Error> {
2478        BufferCollectionProxyInterface::r#attach_token(self, rights_attenuation_mask, token_request)
2479    }
2480
2481    /// AttachLifetimeTracking:
2482    ///
2483    /// AttachLifetimeTracking() is intended to allow a client to wait until an
2484    /// old logical buffer collection is fully or mostly deallocated before
2485    /// attempting allocation of a new logical buffer collection.
2486    ///
2487    /// Attach an eventpair endpoint to the logical buffer collection, so that
2488    /// the server_end will be closed when the number of buffers allocated
2489    /// drops to 'buffers_remaining'.  The server_end won't close until after
2490    /// logical allocation has completed.
2491    ///
2492    /// If logical allocation fails, such as for an attached sub-tree (using
2493    /// AttachToken()), the server_end will close during that failure regardless
2494    /// of the number of buffers potenitally allocated in the overall logical
2495    /// buffer collection.
2496    ///
2497    /// The lifetime signalled by this event includes asynchronous cleanup of
2498    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2499    /// holders of VMO handles to the buffers have closed those VMO handles.
2500    /// Therefore clients should take care not to become blocked forever waiting
2501    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
2502    /// participants using the logical buffer collection are less trusted or
2503    /// less reliable.
2504    ///
2505    /// The buffers_remaining parameter allows waiting for all but
2506    /// buffers_remaining buffers to be fully deallocated.  This can be useful
2507    /// in situations where a known number of buffers are intentionally not
2508    /// closed so that the data can continue to be used, such as for keeping the
2509    /// last available video picture displayed in the UI even if the video
2510    /// stream was using protected output buffers.  It's outside the scope of
2511    /// the BufferCollection interface (at least for now) to determine how many
2512    /// buffers may be held without closing, but it'll typically be in the range
2513    /// 0-2.
2514    ///
2515    /// This mechanism is meant to be compatible with other protocols providing
2516    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2517    /// same event can be sent to more than one AttachLifetimeTracking(), and
2518    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2519    /// over conditions are met (all holders of duplicates have closed their
2520    /// handle(s)).
2521    ///
2522    /// There is no way to cancel an attach.  Closing the client end of the
2523    /// eventpair doesn't subtract from the number of pending attach(es).
2524    ///
2525    /// Closing the client's end doesn't result in any action by the server.
2526    /// If the server listens to events from the client end at all, it is for
2527    /// debug logging only.
2528    ///
2529    /// The server intentionally doesn't "trust" any bits signalled by the
2530    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2531    /// which can't be triggered early, and is only triggered when all handles
2532    /// to server_end are closed.  No meaning is associated with any of the
2533    /// other signal bits, and clients should functionally ignore any other
2534    /// signal bits on either end of the eventpair or its peer.
2535    ///
2536    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2537    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2538    /// transfer without causing CodecFactory channel failure).
2539    pub fn r#attach_lifetime_tracking(
2540        &self,
2541        mut server_end: fidl::EventPair,
2542        mut buffers_remaining: u32,
2543    ) -> Result<(), fidl::Error> {
2544        BufferCollectionProxyInterface::r#attach_lifetime_tracking(
2545            self,
2546            server_end,
2547            buffers_remaining,
2548        )
2549    }
2550}
2551
2552impl BufferCollectionProxyInterface for BufferCollectionProxy {
2553    type SyncResponseFut =
2554        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2555    fn r#sync(&self) -> Self::SyncResponseFut {
2556        fn _decode(
2557            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2558        ) -> Result<(), fidl::Error> {
2559            let _response = fidl::client::decode_transaction_body::<
2560                fidl::encoding::EmptyPayload,
2561                fidl::encoding::DefaultFuchsiaResourceDialect,
2562                0x4577e238ae26291,
2563            >(_buf?)?;
2564            Ok(_response)
2565        }
2566        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2567            (),
2568            0x4577e238ae26291,
2569            fidl::encoding::DynamicFlags::empty(),
2570            _decode,
2571        )
2572    }
2573
2574    fn r#close(&self) -> Result<(), fidl::Error> {
2575        self.client.send::<fidl::encoding::EmptyPayload>(
2576            (),
2577            0x5b1d7a4f5681fca7,
2578            fidl::encoding::DynamicFlags::empty(),
2579        )
2580    }
2581
2582    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
2583        self.client.send::<NodeSetNameRequest>(
2584            (priority, name),
2585            0x77a41bb6217e2443,
2586            fidl::encoding::DynamicFlags::empty(),
2587        )
2588    }
2589
2590    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
2591        self.client.send::<NodeSetDebugClientInfoRequest>(
2592            (name, id),
2593            0x7275759070eb5ee2,
2594            fidl::encoding::DynamicFlags::empty(),
2595        )
2596    }
2597
2598    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
2599        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2600            (deadline,),
2601            0x46d38f4772638867,
2602            fidl::encoding::DynamicFlags::empty(),
2603        )
2604    }
2605
2606    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2607        self.client.send::<fidl::encoding::EmptyPayload>(
2608            (),
2609            0x6bfbe2cf1701d288,
2610            fidl::encoding::DynamicFlags::empty(),
2611        )
2612    }
2613
2614    type GetNodeRefResponseFut =
2615        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
2616    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2617        fn _decode(
2618            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2619        ) -> Result<fidl::Event, fidl::Error> {
2620            let _response = fidl::client::decode_transaction_body::<
2621                NodeGetNodeRefResponse,
2622                fidl::encoding::DefaultFuchsiaResourceDialect,
2623                0x467b7c75c35c3b84,
2624            >(_buf?)?;
2625            Ok(_response.node_ref)
2626        }
2627        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
2628            (),
2629            0x467b7c75c35c3b84,
2630            fidl::encoding::DynamicFlags::empty(),
2631            _decode,
2632        )
2633    }
2634
2635    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2636        NodeIsAlternateForResult,
2637        fidl::encoding::DefaultFuchsiaResourceDialect,
2638    >;
2639    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
2640        fn _decode(
2641            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2642        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2643            let _response = fidl::client::decode_transaction_body::<
2644                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
2645                fidl::encoding::DefaultFuchsiaResourceDialect,
2646                0x33a2a7aff2776c07,
2647            >(_buf?)?;
2648            Ok(_response.map(|x| x.is_alternate))
2649        }
2650        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2651            (node_ref,),
2652            0x33a2a7aff2776c07,
2653            fidl::encoding::DynamicFlags::empty(),
2654            _decode,
2655        )
2656    }
2657
2658    fn r#set_constraints(
2659        &self,
2660        mut has_constraints: bool,
2661        mut constraints: &BufferCollectionConstraints,
2662    ) -> Result<(), fidl::Error> {
2663        self.client.send::<BufferCollectionSetConstraintsRequest>(
2664            (has_constraints, constraints),
2665            0x4d9c3406c213227b,
2666            fidl::encoding::DynamicFlags::empty(),
2667        )
2668    }
2669
2670    type WaitForBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2671        (i32, BufferCollectionInfo2),
2672        fidl::encoding::DefaultFuchsiaResourceDialect,
2673    >;
2674    fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut {
2675        fn _decode(
2676            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2677        ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
2678            let _response = fidl::client::decode_transaction_body::<
2679                BufferCollectionWaitForBuffersAllocatedResponse,
2680                fidl::encoding::DefaultFuchsiaResourceDialect,
2681                0x714667ea2a29a3a2,
2682            >(_buf?)?;
2683            Ok((_response.status, _response.buffer_collection_info))
2684        }
2685        self.client
2686            .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
2687                (),
2688                0x714667ea2a29a3a2,
2689                fidl::encoding::DynamicFlags::empty(),
2690                _decode,
2691            )
2692    }
2693
2694    type CheckBuffersAllocatedResponseFut =
2695        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
2696    fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut {
2697        fn _decode(
2698            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2699        ) -> Result<i32, fidl::Error> {
2700            let _response = fidl::client::decode_transaction_body::<
2701                BufferCollectionCheckBuffersAllocatedResponse,
2702                fidl::encoding::DefaultFuchsiaResourceDialect,
2703                0x245bb81f79189e9,
2704            >(_buf?)?;
2705            Ok(_response.status)
2706        }
2707        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
2708            (),
2709            0x245bb81f79189e9,
2710            fidl::encoding::DynamicFlags::empty(),
2711            _decode,
2712        )
2713    }
2714
2715    fn r#attach_token(
2716        &self,
2717        mut rights_attenuation_mask: u32,
2718        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
2719    ) -> Result<(), fidl::Error> {
2720        self.client.send::<BufferCollectionAttachTokenRequest>(
2721            (rights_attenuation_mask, token_request),
2722            0x6f5adcca4ac7443e,
2723            fidl::encoding::DynamicFlags::empty(),
2724        )
2725    }
2726
2727    fn r#attach_lifetime_tracking(
2728        &self,
2729        mut server_end: fidl::EventPair,
2730        mut buffers_remaining: u32,
2731    ) -> Result<(), fidl::Error> {
2732        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2733            (server_end, buffers_remaining),
2734            0x170d0f1d89d50989,
2735            fidl::encoding::DynamicFlags::empty(),
2736        )
2737    }
2738}
2739
2740pub struct BufferCollectionEventStream {
2741    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2742}
2743
2744impl std::marker::Unpin for BufferCollectionEventStream {}
2745
2746impl futures::stream::FusedStream for BufferCollectionEventStream {
2747    fn is_terminated(&self) -> bool {
2748        self.event_receiver.is_terminated()
2749    }
2750}
2751
2752impl futures::Stream for BufferCollectionEventStream {
2753    type Item = Result<BufferCollectionEvent, fidl::Error>;
2754
2755    fn poll_next(
2756        mut self: std::pin::Pin<&mut Self>,
2757        cx: &mut std::task::Context<'_>,
2758    ) -> std::task::Poll<Option<Self::Item>> {
2759        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2760            &mut self.event_receiver,
2761            cx
2762        )?) {
2763            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2764            None => std::task::Poll::Ready(None),
2765        }
2766    }
2767}
2768
2769#[derive(Debug)]
2770pub enum BufferCollectionEvent {}
2771
2772impl BufferCollectionEvent {
2773    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2774    fn decode(
2775        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2776    ) -> Result<BufferCollectionEvent, fidl::Error> {
2777        let (bytes, _handles) = buf.split_mut();
2778        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2779        debug_assert_eq!(tx_header.tx_id, 0);
2780        match tx_header.ordinal {
2781            _ => Err(fidl::Error::UnknownOrdinal {
2782                ordinal: tx_header.ordinal,
2783                protocol_name:
2784                    <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2785            }),
2786        }
2787    }
2788}
2789
2790/// A Stream of incoming requests for fuchsia.sysmem/BufferCollection.
2791pub struct BufferCollectionRequestStream {
2792    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2793    is_terminated: bool,
2794}
2795
2796impl std::marker::Unpin for BufferCollectionRequestStream {}
2797
2798impl futures::stream::FusedStream for BufferCollectionRequestStream {
2799    fn is_terminated(&self) -> bool {
2800        self.is_terminated
2801    }
2802}
2803
2804impl fidl::endpoints::RequestStream for BufferCollectionRequestStream {
2805    type Protocol = BufferCollectionMarker;
2806    type ControlHandle = BufferCollectionControlHandle;
2807
2808    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2809        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2810    }
2811
2812    fn control_handle(&self) -> Self::ControlHandle {
2813        BufferCollectionControlHandle { inner: self.inner.clone() }
2814    }
2815
2816    fn into_inner(
2817        self,
2818    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2819    {
2820        (self.inner, self.is_terminated)
2821    }
2822
2823    fn from_inner(
2824        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2825        is_terminated: bool,
2826    ) -> Self {
2827        Self { inner, is_terminated }
2828    }
2829}
2830
2831impl futures::Stream for BufferCollectionRequestStream {
2832    type Item = Result<BufferCollectionRequest, fidl::Error>;
2833
2834    fn poll_next(
2835        mut self: std::pin::Pin<&mut Self>,
2836        cx: &mut std::task::Context<'_>,
2837    ) -> std::task::Poll<Option<Self::Item>> {
2838        let this = &mut *self;
2839        if this.inner.check_shutdown(cx) {
2840            this.is_terminated = true;
2841            return std::task::Poll::Ready(None);
2842        }
2843        if this.is_terminated {
2844            panic!("polled BufferCollectionRequestStream after completion");
2845        }
2846        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2847            |bytes, handles| {
2848                match this.inner.channel().read_etc(cx, bytes, handles) {
2849                    std::task::Poll::Ready(Ok(())) => {}
2850                    std::task::Poll::Pending => return std::task::Poll::Pending,
2851                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2852                        this.is_terminated = true;
2853                        return std::task::Poll::Ready(None);
2854                    }
2855                    std::task::Poll::Ready(Err(e)) => {
2856                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2857                            e.into(),
2858                        ))));
2859                    }
2860                }
2861
2862                // A message has been received from the channel
2863                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2864
2865                std::task::Poll::Ready(Some(match header.ordinal {
2866                    0x4577e238ae26291 => {
2867                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2868                        let mut req = fidl::new_empty!(
2869                            fidl::encoding::EmptyPayload,
2870                            fidl::encoding::DefaultFuchsiaResourceDialect
2871                        );
2872                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2873                        let control_handle =
2874                            BufferCollectionControlHandle { inner: this.inner.clone() };
2875                        Ok(BufferCollectionRequest::Sync {
2876                            responder: BufferCollectionSyncResponder {
2877                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2878                                tx_id: header.tx_id,
2879                            },
2880                        })
2881                    }
2882                    0x5b1d7a4f5681fca7 => {
2883                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2884                        let mut req = fidl::new_empty!(
2885                            fidl::encoding::EmptyPayload,
2886                            fidl::encoding::DefaultFuchsiaResourceDialect
2887                        );
2888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2889                        let control_handle =
2890                            BufferCollectionControlHandle { inner: this.inner.clone() };
2891                        Ok(BufferCollectionRequest::Close { control_handle })
2892                    }
2893                    0x77a41bb6217e2443 => {
2894                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2895                        let mut req = fidl::new_empty!(
2896                            NodeSetNameRequest,
2897                            fidl::encoding::DefaultFuchsiaResourceDialect
2898                        );
2899                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2900                        let control_handle =
2901                            BufferCollectionControlHandle { inner: this.inner.clone() };
2902                        Ok(BufferCollectionRequest::SetName {
2903                            priority: req.priority,
2904                            name: req.name,
2905
2906                            control_handle,
2907                        })
2908                    }
2909                    0x7275759070eb5ee2 => {
2910                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2911                        let mut req = fidl::new_empty!(
2912                            NodeSetDebugClientInfoRequest,
2913                            fidl::encoding::DefaultFuchsiaResourceDialect
2914                        );
2915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
2916                        let control_handle =
2917                            BufferCollectionControlHandle { inner: this.inner.clone() };
2918                        Ok(BufferCollectionRequest::SetDebugClientInfo {
2919                            name: req.name,
2920                            id: req.id,
2921
2922                            control_handle,
2923                        })
2924                    }
2925                    0x46d38f4772638867 => {
2926                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2927                        let mut req = fidl::new_empty!(
2928                            NodeSetDebugTimeoutLogDeadlineRequest,
2929                            fidl::encoding::DefaultFuchsiaResourceDialect
2930                        );
2931                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2932                        let control_handle =
2933                            BufferCollectionControlHandle { inner: this.inner.clone() };
2934                        Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {
2935                            deadline: req.deadline,
2936
2937                            control_handle,
2938                        })
2939                    }
2940                    0x6bfbe2cf1701d288 => {
2941                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2942                        let mut req = fidl::new_empty!(
2943                            fidl::encoding::EmptyPayload,
2944                            fidl::encoding::DefaultFuchsiaResourceDialect
2945                        );
2946                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2947                        let control_handle =
2948                            BufferCollectionControlHandle { inner: this.inner.clone() };
2949                        Ok(BufferCollectionRequest::SetVerboseLogging { control_handle })
2950                    }
2951                    0x467b7c75c35c3b84 => {
2952                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2953                        let mut req = fidl::new_empty!(
2954                            fidl::encoding::EmptyPayload,
2955                            fidl::encoding::DefaultFuchsiaResourceDialect
2956                        );
2957                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2958                        let control_handle =
2959                            BufferCollectionControlHandle { inner: this.inner.clone() };
2960                        Ok(BufferCollectionRequest::GetNodeRef {
2961                            responder: BufferCollectionGetNodeRefResponder {
2962                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2963                                tx_id: header.tx_id,
2964                            },
2965                        })
2966                    }
2967                    0x33a2a7aff2776c07 => {
2968                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2969                        let mut req = fidl::new_empty!(
2970                            NodeIsAlternateForRequest,
2971                            fidl::encoding::DefaultFuchsiaResourceDialect
2972                        );
2973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
2974                        let control_handle =
2975                            BufferCollectionControlHandle { inner: this.inner.clone() };
2976                        Ok(BufferCollectionRequest::IsAlternateFor {
2977                            node_ref: req.node_ref,
2978
2979                            responder: BufferCollectionIsAlternateForResponder {
2980                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2981                                tx_id: header.tx_id,
2982                            },
2983                        })
2984                    }
2985                    0x4d9c3406c213227b => {
2986                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2987                        let mut req = fidl::new_empty!(
2988                            BufferCollectionSetConstraintsRequest,
2989                            fidl::encoding::DefaultFuchsiaResourceDialect
2990                        );
2991                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
2992                        let control_handle =
2993                            BufferCollectionControlHandle { inner: this.inner.clone() };
2994                        Ok(BufferCollectionRequest::SetConstraints {
2995                            has_constraints: req.has_constraints,
2996                            constraints: req.constraints,
2997
2998                            control_handle,
2999                        })
3000                    }
3001                    0x714667ea2a29a3a2 => {
3002                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3003                        let mut req = fidl::new_empty!(
3004                            fidl::encoding::EmptyPayload,
3005                            fidl::encoding::DefaultFuchsiaResourceDialect
3006                        );
3007                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3008                        let control_handle =
3009                            BufferCollectionControlHandle { inner: this.inner.clone() };
3010                        Ok(BufferCollectionRequest::WaitForBuffersAllocated {
3011                            responder: BufferCollectionWaitForBuffersAllocatedResponder {
3012                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3013                                tx_id: header.tx_id,
3014                            },
3015                        })
3016                    }
3017                    0x245bb81f79189e9 => {
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::CheckBuffersAllocated {
3027                            responder: BufferCollectionCheckBuffersAllocatedResponder {
3028                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3029                                tx_id: header.tx_id,
3030                            },
3031                        })
3032                    }
3033                    0x6f5adcca4ac7443e => {
3034                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3035                        let mut req = fidl::new_empty!(
3036                            BufferCollectionAttachTokenRequest,
3037                            fidl::encoding::DefaultFuchsiaResourceDialect
3038                        );
3039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
3040                        let control_handle =
3041                            BufferCollectionControlHandle { inner: this.inner.clone() };
3042                        Ok(BufferCollectionRequest::AttachToken {
3043                            rights_attenuation_mask: req.rights_attenuation_mask,
3044                            token_request: req.token_request,
3045
3046                            control_handle,
3047                        })
3048                    }
3049                    0x170d0f1d89d50989 => {
3050                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3051                        let mut req = fidl::new_empty!(
3052                            BufferCollectionAttachLifetimeTrackingRequest,
3053                            fidl::encoding::DefaultFuchsiaResourceDialect
3054                        );
3055                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3056                        let control_handle =
3057                            BufferCollectionControlHandle { inner: this.inner.clone() };
3058                        Ok(BufferCollectionRequest::AttachLifetimeTracking {
3059                            server_end: req.server_end,
3060                            buffers_remaining: req.buffers_remaining,
3061
3062                            control_handle,
3063                        })
3064                    }
3065                    _ => Err(fidl::Error::UnknownOrdinal {
3066                        ordinal: header.ordinal,
3067                        protocol_name:
3068                            <BufferCollectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3069                    }),
3070                }))
3071            },
3072        )
3073    }
3074}
3075
3076/// BufferCollection is a connection directly from a participant to sysmem re.
3077/// a logical BufferCollection; typically the logical BufferCollection is shared
3078/// with other participants.  In other words, an instance of the BufferCollection
3079/// interface is a view of a "logical buffer collection".
3080///
3081/// This connection exists to facilitate async indication of when the logical
3082/// BufferCollection has been populated with buffers.
3083///
3084/// Also, the channel's closure by the server is an indication to the client
3085/// that the client should close all VMO handles that were obtained from the
3086/// BufferCollection ASAP.
3087///
3088/// Also, this interface may in future allow specifying constraints in other
3089/// ways, and may allow for back-and-forth negotiation of constraints to some
3090/// degree.
3091///
3092/// This interface may in future allow for more than 64 VMO handles per
3093/// BufferCollection, but currently the limit is 64.
3094///
3095/// This interface may in future allow for allocating/deallocating single
3096/// buffers.
3097///
3098/// Some initiators may wait a short duration until all old logical
3099/// BufferCollection VMO handles have closed (or until the short duration times
3100/// out) before allocating a new BufferCollection, to help control physical
3101/// memory fragmentation and avoid overlap of buffer allocation lifetimes for
3102/// the old and new collections. Collections can be large enough that it's worth
3103/// avoiding allocation overlap (in time).
3104#[derive(Debug)]
3105pub enum BufferCollectionRequest {
3106    /// Ensure that previous messages, including Duplicate() messages on a
3107    /// token, collection, or group, have been received server side.
3108    ///
3109    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
3110    /// valid sysmem token risks the Sync() hanging forever.  See
3111    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
3112    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
3113    /// Another way is to pass the token to BindSharedCollection(), which also
3114    /// validates the token as part of exchanging it for a BufferCollection
3115    /// channel, and BufferCollection Sync() can then be used.
3116    ///
3117    /// After a Sync(), it's then safe to send the client end of token_request
3118    /// to another participant knowing the server will recognize the token when
3119    /// it's sent into BindSharedCollection() by the other participant.
3120    ///
3121    /// Other options include waiting for each token.Duplicate() to complete
3122    /// individually (using separate call to token.Sync() after each), or
3123    /// calling Sync() on BufferCollection after the token has been turned in
3124    /// via BindSharedCollection().
3125    ///
3126    /// Another way to mitigate is to avoid calling Sync() on the token, and
3127    /// instead later deal with potential failure of BufferCollection.Sync() if
3128    /// the original token was invalid.  This option can be preferable from a
3129    /// performance point of view, but requires client code to delay sending
3130    /// tokens duplicated from this token until after client code has converted
3131    /// the duplicating token to a BufferCollection and received successful
3132    /// response from BufferCollection.Sync().
3133    ///
3134    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
3135    /// When BufferCollection.Sync() isn't feasible, the caller must already
3136    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
3137    /// hang forever.  See ValidateBufferCollectionToken() to check token
3138    /// validity first if the token isn't already known to be (is/was) valid.
3139    Sync { responder: BufferCollectionSyncResponder },
3140    /// On a BufferCollectionToken channel:
3141    ///
3142    /// Normally a participant will convert a BufferCollectionToken into a
3143    /// BufferCollection view, but a participant is also free to Close() the
3144    /// token (and then close the channel immediately or shortly later in
3145    /// response to server closing its end), which avoids causing logical buffer
3146    /// collection failure.  Normally an unexpected token channel close will
3147    /// cause logical buffer collection failure (the only exceptions being
3148    /// certain cases involving AttachToken() or SetDispensable()).
3149    ///
3150    /// On a BufferCollection channel:
3151    ///
3152    /// By default the server handles unexpected failure of a BufferCollection
3153    /// by failing the whole logical buffer collection.  Partly this is to
3154    /// expedite closing VMO handles to reclaim memory when any participant
3155    /// fails.  If a participant would like to cleanly close a BufferCollection
3156    /// view without causing logical buffer collection failure, the participant
3157    /// can send Close() before closing the client end of the BufferCollection
3158    /// channel.  If this is the last BufferCollection view, the logical buffer
3159    /// collection will still go away.  The Close() can occur before or after
3160    /// SetConstraints().  If before SetConstraints(), the buffer collection
3161    /// won't require constraints from this node in order to allocate.  If
3162    /// after SetConstraints(), the constraints are retained and aggregated
3163    /// along with any subsequent logical allocation(s), despite the lack of
3164    /// channel connection.
3165    ///
3166    /// On a BufferCollectionTokenGroup channel:
3167    ///
3168    /// By default, unexpected failure of a BufferCollectionTokenGroup will
3169    /// trigger failure of the logical BufferCollectionTokenGroup and will
3170    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
3171    /// channel without failing the logical group or propagating failure, send
3172    /// Close() before closing the channel client endpoint.
3173    ///
3174    /// If Close() occurs before AllChildrenPresent(), the logical buffer
3175    /// collection will still fail despite the Close() (because sysmem can't be
3176    /// sure whether all relevant children were created, so it's ambiguous
3177    /// whether all relevant constraints will be provided to sysmem).  If
3178    /// Close() occurs after AllChildrenPresent(), the children and all their
3179    /// constraints remain intact (just as they would if the
3180    /// BufferCollectionTokenGroup channel had remained open), and the close
3181    /// doesn't trigger or propagate failure.
3182    Close { control_handle: BufferCollectionControlHandle },
3183    /// Set a name for VMOs in this buffer collection. The name may be truncated
3184    /// shorter. The name only affects VMOs allocated after it's set - this call
3185    /// does not rename existing VMOs. If multiple clients set different names
3186    /// then the larger priority value will win.
3187    SetName { priority: u32, name: String, control_handle: BufferCollectionControlHandle },
3188    /// Set information about the current client that can be used by sysmem to
3189    /// help debug leaking memory and hangs waiting for constraints. |name| can
3190    /// be an arbitrary string, but the current process name (see
3191    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
3192    /// arbitrary id, but the current process ID (see
3193    /// fsl::GetCurrentProcessKoid()) is a good default.
3194    ///
3195    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
3196    /// indicate which client is closing their channel first, leading to
3197    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
3198    /// over, but if happening earlier than expected, the
3199    /// client-channel-specific name can help diagnose where the failure is
3200    /// first coming from, from sysmem's point of view).
3201    ///
3202    /// By default (unless overriden by this message or using
3203    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
3204    /// parent Node at the time the child Node is created.  While this can be
3205    /// better than nothing, it's often better for each participant to use
3206    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
3207    /// info directly relevant to the current client.  Also, SetVerboseLogging()
3208    /// can be used to help disambiguate if a Node is suspected of having info
3209    /// that was copied from its parent.
3210    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionControlHandle },
3211    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
3212    /// after creating a collection. Clients can call this method to change
3213    /// when the log is printed. If multiple client set the deadline, it's
3214    /// unspecified which deadline will take effect.
3215    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionControlHandle },
3216    /// Verbose logging includes constraints set via SetConstraints() from each
3217    /// client along with info set via SetDebugClientInfo() and the structure of
3218    /// the tree of Node(s).
3219    ///
3220    /// Normally sysmem prints only a single line complaint when aggregation
3221    /// fails, with just the specific detailed reason that aggregation failed,
3222    /// with minimal context.  While this is often enough to diagnose a problem
3223    /// if only a small change was made and the system had been working before
3224    /// the small change, it's often not particularly helpful for getting a new
3225    /// buffer collection to work for the first time.  Especially with more
3226    /// complex trees of nodes, involving things like AttachToken(),
3227    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
3228    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
3229    /// looks like and why it's failing a logical allocation, or why a tree or
3230    /// sub-tree is failing sooner than expected.
3231    ///
3232    /// The intent of the extra logging is to be acceptable from a performance
3233    /// point of view, if only enabled on a low number of buffer collections.
3234    /// If we're not tracking down a bug, we shouldn't send this message.
3235    ///
3236    /// If too many participants leave verbose logging enabled, we may end up
3237    /// needing to require that system-wide sysmem verbose logging be permitted
3238    /// via some other setting, to avoid sysmem spamming the log too much due to
3239    /// this message.
3240    ///
3241    /// This may be a NOP for some nodes due to intentional policy associated
3242    /// with the node, if we don't trust a node enough to let it turn on verbose
3243    /// logging.
3244    SetVerboseLogging { control_handle: BufferCollectionControlHandle },
3245    /// This gets an event handle that can be used as a parameter to
3246    /// IsAlternateFor() called on any Node.  The client will not be granted the
3247    /// right to signal this event, as this handle should only be used as proof
3248    /// that the client obtained this handle from this Node.
3249    ///
3250    /// Because this is a get not a set, no Sync() is needed between the
3251    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
3252    /// potentially being on different channels.
3253    ///
3254    /// See also IsAlternateFor().
3255    GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
3256    /// This checks whether the calling node is in a subtree rooted at a
3257    /// different child token of a common parent BufferCollectionTokenGroup, in
3258    /// relation to the passed-in node_ref.
3259    ///
3260    /// This call is for assisting with admission control de-duplication, and
3261    /// with debugging.
3262    ///
3263    /// The node_ref must be obtained using GetNodeRef() of a
3264    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
3265    ///
3266    /// The node_ref can be a duplicated handle; it's not necessary to call
3267    /// GetNodeRef() for every call to IsAlternateFor().
3268    ///
3269    /// If a calling token may not actually be a valid token at all due to
3270    /// a potentially hostile/untrusted provider of the token, call
3271    /// ValidateBufferCollectionToken() first instead of potentially getting
3272    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
3273    /// token not being a real token (not really talking to sysmem).  Another
3274    /// option is to call BindSharedCollection with this token first which also
3275    /// validates the token along with converting it to a BufferCollection, then
3276    /// call BufferCollection IsAlternateFor().
3277    ///
3278    /// error values:
3279    ///
3280    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
3281    /// buffer collection as the calling Node.  Before logical allocation and
3282    /// within the same logical allocation sub-tree, this essentially means that
3283    /// the node_ref was never part of this logical buffer collection, since
3284    /// before logical allocation all node_refs that come into existence remain
3285    /// in existence at least until logical allocation (including Node(s) that
3286    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
3287    /// to be returned, this Node's channel needs to still be connected server
3288    /// side, which won't be the case if the whole logical allocation has
3289    /// failed.  After logical allocation or in a different logical allocation
3290    /// sub-tree there are additional potential reasons for this error.  For
3291    /// example a different logical allocation (separated from this Node(s)
3292    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
3293    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
3294    /// exist and may select a different child sub-tree than the sub-tree the
3295    /// node_ref is in causing deletion of the node_ref Node.  The only time
3296    /// sysmem keeps a Node around after that Node has no corresponding channel
3297    /// is when Close() is used and the Node's sub-tree has not yet failed.
3298    /// Another reason for this error is if the node_ref is an eventpair handle
3299    /// with sufficient rights, but isn't actually a real node_ref obtained from
3300    /// GetNodeRef().
3301    ///
3302    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
3303    /// eventpair handle, or doesn't have the needed rights expected on a real
3304    /// node_ref.
3305    ///
3306    /// No other failing status codes are returned by this call.  However,
3307    /// sysmem may add additional codes in future, so the client should have
3308    /// sensible default handling for any failing status code.
3309    ///
3310    /// On success, is_alternate has the following meaning:
3311    ///   * true - The first parent node in common between the calling node and
3312    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
3313    ///     the calling Node and the node_ref Node will _not_ have both their
3314    ///     constraints apply - rather sysmem will choose one or the other of
3315    ///     the constraints - never both.  This is because only one child of
3316    ///     a BufferCollectionTokenGroup is selected during logical allocation,
3317    ///     with only that one child's sub-tree contributing to constraints
3318    ///     aggregation.
3319    ///   * false - The first parent node in common between the calling Node and
3320    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
3321    ///     this means the first parent node in common is a
3322    ///     BufferCollectionToken or BufferCollection (regardless of not
3323    ///     Close()ed or Close()ed).  This means that the calling Node and the
3324    ///     node_ref Node _may_ have both their constraints apply during
3325    ///     constraints aggregation of the logical allocation, if both Node(s)
3326    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
3327    ///     In this case, there is no BufferCollectionTokenGroup that will
3328    ///     directly prevent the two Node(s) from both being selected and their
3329    ///     constraints both aggregated, but even when false, one or both
3330    ///     Node(s) may still be eliminated from consideration if one or both
3331    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
3332    ///     which selects a child sub-tree other than the sub-tree containing
3333    ///     the calling Node or node_ref Node.
3334    IsAlternateFor { node_ref: fidl::Event, responder: BufferCollectionIsAlternateForResponder },
3335    /// Provide BufferCollectionConstraints to the logical BufferCollection.
3336    ///
3337    /// A participant may only call SetConstraints() once.
3338    ///
3339    /// Sometimes the initiator is a participant only in the sense of wanting to
3340    /// keep an eye on success/failure to populate with buffers, and zx.Status
3341    /// on failure.  In that case, `has_constraints` can be false, and
3342    /// `constraints` will be ignored.
3343    ///
3344    /// VMO handles will not be provided to the client that sends null
3345    /// constraints - that can be intentional for an initiator that doesn't need
3346    /// VMO handles.  Not having VMO handles doesn't prevent the initator from
3347    /// adjusting which portion of a buffer is considered valid and similar, but
3348    /// the initiator can't hold a VMO handle open to prevent the logical
3349    /// BufferCollection from cleaning up if the logical BufferCollection needs
3350    /// to go away regardless of the initiator's degree of involvement for
3351    /// whatever reason.
3352    ///
3353    /// For population of buffers to be attempted, all holders of a
3354    /// BufferCollection client channel need to call SetConstraints() before
3355    /// sysmem will attempt to allocate buffers.
3356    ///
3357    /// `has_constraints` if false, the constraints are effectively null, and
3358    /// `constraints` are ignored.  The sender of null constraints won't get any
3359    /// VMO handles in BufferCollectionInfo, but can still find out how many
3360    /// buffers were allocated and can still refer to buffers by their
3361    /// buffer_index.
3362    ///
3363    /// `constraints` are constraints on the buffer collection.
3364    SetConstraints {
3365        has_constraints: bool,
3366        constraints: BufferCollectionConstraints,
3367        control_handle: BufferCollectionControlHandle,
3368    },
3369    /// This request completes when buffers have been allocated, responds with
3370    /// some failure detail if allocation has been attempted but failed.
3371    ///
3372    /// The following must occur before buffers will be allocated:
3373    ///   * All BufferCollectionToken(s) of the logical BufferCollectionToken
3374    ///     must be turned in via BindSharedCollection().
3375    ///   * All BufferCollection(s) of the logical BufferCollection must have
3376    ///     had SetConstraints() sent to them.
3377    ///
3378    /// Returns `ZX_OK` if successful.
3379    /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
3380    /// fulfilled due to resource exhaustion.
3381    /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
3382    /// obtain the buffers it requested.
3383    /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
3384    /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
3385    /// satisfied, perhaps due to hardware limitations.
3386    ///
3387    /// `buffer_collection_info` has the VMO handles and other related info.
3388    WaitForBuffersAllocated { responder: BufferCollectionWaitForBuffersAllocatedResponder },
3389    /// This returns the same result code as WaitForBuffersAllocated if the
3390    /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
3391    /// if WaitForBuffersAllocated would block.
3392    CheckBuffersAllocated { responder: BufferCollectionCheckBuffersAllocatedResponder },
3393    /// Create a new token, for trying to add a new participant to an existing
3394    /// collection, if the existing collection's buffer counts, constraints,
3395    /// and participants allow.
3396    ///
3397    /// This can be useful in replacing a failed participant, and/or in
3398    /// adding/re-adding a participant after buffers have already been
3399    /// allocated.
3400    ///
3401    /// Failure of an attached token / collection does not propagate to the
3402    /// parent of the attached token.  Failure does propagate from a normal
3403    /// child of a dispensable token to the dispensable token.  Failure
3404    /// of a child is blocked from reaching its parent if the child is attached,
3405    /// or if the child is dispensable and the failure occurred after logical
3406    /// allocation.
3407    ///
3408    /// An initiator may in some scenarios choose to initially use a dispensable
3409    /// token for a given instance of a participant, and then later if the first
3410    /// instance of that participant fails, a new second instance of that
3411    /// participant my be given a token created with AttachToken().
3412    ///
3413    /// From the point of view of the client end of the BufferCollectionToken
3414    /// channel, the token acts like any other token.  The client can
3415    /// Duplicate() the token as needed, and can send the token to a different
3416    /// process.  The token should be converted to a BufferCollection channel
3417    /// as normal by calling BindSharedCollection().  SetConstraints() should
3418    /// be called on that BufferCollection channel.
3419    ///
3420    /// A success result from WaitForBuffersAllocated() means the new
3421    /// participant's constraints were satisfiable using the already-existing
3422    /// buffer collection, the already-established BufferCollectionInfo
3423    /// including image format constraints, and the already-existing other
3424    /// participants and their buffer counts.  A failure result means the new
3425    /// participant's constraints cannot be satisfied using the existing
3426    /// buffer collection and its already-logically-allocated participants.
3427    /// Creating a new collection instead may allow all participant's
3428    /// constraints to be satisfied, assuming SetDispensable() is used in place
3429    /// of AttachToken(), or a normal token is used.
3430    ///
3431    /// A token created with AttachToken() performs constraints aggregation with
3432    /// all constraints currently in effect on the buffer collection, plus the
3433    /// attached token under consideration plus child tokens under the attached
3434    /// token which are not themselves an attached token or under such a token.
3435    ///
3436    /// Allocation of buffer_count to min_buffer_count_for_camping etc is
3437    /// first-come first-served, but a child can't logically allocate before
3438    /// all its parents have sent SetConstraints().
3439    ///
3440    /// See also SetDispensable(), which in contrast to AttachToken(), has the
3441    /// created token + children participate in constraints aggregation along
3442    /// with its parent.
3443    ///
3444    /// The newly created token needs to be Sync()ed to sysmem before the new
3445    /// token can be passed to BindSharedCollection().  The Sync() of the new
3446    /// token can be accomplished with BufferCollection.Sync() on this
3447    /// BufferCollection.  Alternately BufferCollectionToken.Sync() on the new
3448    /// token also works.  A BufferCollectionToken.Sync() can be started after
3449    /// any BufferCollectionToken.Duplicate() messages have been sent via the
3450    /// newly created token, to also sync those additional tokens to sysmem
3451    /// using a single round-trip.
3452    ///
3453    /// These values for rights_attenuation_mask result in no attenuation (note
3454    /// that 0 is not on this list; 0 will output an ERROR to the system log
3455    /// to help diagnose the bug in client code):
3456    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
3457    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3458    AttachToken {
3459        rights_attenuation_mask: u32,
3460        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3461        control_handle: BufferCollectionControlHandle,
3462    },
3463    /// AttachLifetimeTracking:
3464    ///
3465    /// AttachLifetimeTracking() is intended to allow a client to wait until an
3466    /// old logical buffer collection is fully or mostly deallocated before
3467    /// attempting allocation of a new logical buffer collection.
3468    ///
3469    /// Attach an eventpair endpoint to the logical buffer collection, so that
3470    /// the server_end will be closed when the number of buffers allocated
3471    /// drops to 'buffers_remaining'.  The server_end won't close until after
3472    /// logical allocation has completed.
3473    ///
3474    /// If logical allocation fails, such as for an attached sub-tree (using
3475    /// AttachToken()), the server_end will close during that failure regardless
3476    /// of the number of buffers potenitally allocated in the overall logical
3477    /// buffer collection.
3478    ///
3479    /// The lifetime signalled by this event includes asynchronous cleanup of
3480    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3481    /// holders of VMO handles to the buffers have closed those VMO handles.
3482    /// Therefore clients should take care not to become blocked forever waiting
3483    /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
3484    /// participants using the logical buffer collection are less trusted or
3485    /// less reliable.
3486    ///
3487    /// The buffers_remaining parameter allows waiting for all but
3488    /// buffers_remaining buffers to be fully deallocated.  This can be useful
3489    /// in situations where a known number of buffers are intentionally not
3490    /// closed so that the data can continue to be used, such as for keeping the
3491    /// last available video picture displayed in the UI even if the video
3492    /// stream was using protected output buffers.  It's outside the scope of
3493    /// the BufferCollection interface (at least for now) to determine how many
3494    /// buffers may be held without closing, but it'll typically be in the range
3495    /// 0-2.
3496    ///
3497    /// This mechanism is meant to be compatible with other protocols providing
3498    /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
3499    /// same event can be sent to more than one AttachLifetimeTracking(), and
3500    /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
3501    /// over conditions are met (all holders of duplicates have closed their
3502    /// handle(s)).
3503    ///
3504    /// There is no way to cancel an attach.  Closing the client end of the
3505    /// eventpair doesn't subtract from the number of pending attach(es).
3506    ///
3507    /// Closing the client's end doesn't result in any action by the server.
3508    /// If the server listens to events from the client end at all, it is for
3509    /// debug logging only.
3510    ///
3511    /// The server intentionally doesn't "trust" any bits signalled by the
3512    /// client.  This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
3513    /// which can't be triggered early, and is only triggered when all handles
3514    /// to server_end are closed.  No meaning is associated with any of the
3515    /// other signal bits, and clients should functionally ignore any other
3516    /// signal bits on either end of the eventpair or its peer.
3517    ///
3518    /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
3519    /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
3520    /// transfer without causing CodecFactory channel failure).
3521    AttachLifetimeTracking {
3522        server_end: fidl::EventPair,
3523        buffers_remaining: u32,
3524        control_handle: BufferCollectionControlHandle,
3525    },
3526}
3527
3528impl BufferCollectionRequest {
3529    #[allow(irrefutable_let_patterns)]
3530    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3531        if let BufferCollectionRequest::Sync { responder } = self {
3532            Some((responder))
3533        } else {
3534            None
3535        }
3536    }
3537
3538    #[allow(irrefutable_let_patterns)]
3539    pub fn into_close(self) -> Option<(BufferCollectionControlHandle)> {
3540        if let BufferCollectionRequest::Close { control_handle } = self {
3541            Some((control_handle))
3542        } else {
3543            None
3544        }
3545    }
3546
3547    #[allow(irrefutable_let_patterns)]
3548    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionControlHandle)> {
3549        if let BufferCollectionRequest::SetName { priority, name, control_handle } = self {
3550            Some((priority, name, control_handle))
3551        } else {
3552            None
3553        }
3554    }
3555
3556    #[allow(irrefutable_let_patterns)]
3557    pub fn into_set_debug_client_info(
3558        self,
3559    ) -> Option<(String, u64, BufferCollectionControlHandle)> {
3560        if let BufferCollectionRequest::SetDebugClientInfo { name, id, control_handle } = self {
3561            Some((name, id, control_handle))
3562        } else {
3563            None
3564        }
3565    }
3566
3567    #[allow(irrefutable_let_patterns)]
3568    pub fn into_set_debug_timeout_log_deadline(
3569        self,
3570    ) -> Option<(i64, BufferCollectionControlHandle)> {
3571        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } =
3572            self
3573        {
3574            Some((deadline, control_handle))
3575        } else {
3576            None
3577        }
3578    }
3579
3580    #[allow(irrefutable_let_patterns)]
3581    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3582        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3583            Some((control_handle))
3584        } else {
3585            None
3586        }
3587    }
3588
3589    #[allow(irrefutable_let_patterns)]
3590    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3591        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3592            Some((responder))
3593        } else {
3594            None
3595        }
3596    }
3597
3598    #[allow(irrefutable_let_patterns)]
3599    pub fn into_is_alternate_for(
3600        self,
3601    ) -> Option<(fidl::Event, BufferCollectionIsAlternateForResponder)> {
3602        if let BufferCollectionRequest::IsAlternateFor { node_ref, responder } = self {
3603            Some((node_ref, responder))
3604        } else {
3605            None
3606        }
3607    }
3608
3609    #[allow(irrefutable_let_patterns)]
3610    pub fn into_set_constraints(
3611        self,
3612    ) -> Option<(bool, BufferCollectionConstraints, BufferCollectionControlHandle)> {
3613        if let BufferCollectionRequest::SetConstraints {
3614            has_constraints,
3615            constraints,
3616            control_handle,
3617        } = self
3618        {
3619            Some((has_constraints, constraints, control_handle))
3620        } else {
3621            None
3622        }
3623    }
3624
3625    #[allow(irrefutable_let_patterns)]
3626    pub fn into_wait_for_buffers_allocated(
3627        self,
3628    ) -> Option<(BufferCollectionWaitForBuffersAllocatedResponder)> {
3629        if let BufferCollectionRequest::WaitForBuffersAllocated { responder } = self {
3630            Some((responder))
3631        } else {
3632            None
3633        }
3634    }
3635
3636    #[allow(irrefutable_let_patterns)]
3637    pub fn into_check_buffers_allocated(
3638        self,
3639    ) -> Option<(BufferCollectionCheckBuffersAllocatedResponder)> {
3640        if let BufferCollectionRequest::CheckBuffersAllocated { responder } = self {
3641            Some((responder))
3642        } else {
3643            None
3644        }
3645    }
3646
3647    #[allow(irrefutable_let_patterns)]
3648    pub fn into_attach_token(
3649        self,
3650    ) -> Option<(
3651        u32,
3652        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
3653        BufferCollectionControlHandle,
3654    )> {
3655        if let BufferCollectionRequest::AttachToken {
3656            rights_attenuation_mask,
3657            token_request,
3658            control_handle,
3659        } = self
3660        {
3661            Some((rights_attenuation_mask, token_request, control_handle))
3662        } else {
3663            None
3664        }
3665    }
3666
3667    #[allow(irrefutable_let_patterns)]
3668    pub fn into_attach_lifetime_tracking(
3669        self,
3670    ) -> Option<(fidl::EventPair, u32, BufferCollectionControlHandle)> {
3671        if let BufferCollectionRequest::AttachLifetimeTracking {
3672            server_end,
3673            buffers_remaining,
3674            control_handle,
3675        } = self
3676        {
3677            Some((server_end, buffers_remaining, control_handle))
3678        } else {
3679            None
3680        }
3681    }
3682
3683    /// Name of the method defined in FIDL
3684    pub fn method_name(&self) -> &'static str {
3685        match *self {
3686            BufferCollectionRequest::Sync { .. } => "sync",
3687            BufferCollectionRequest::Close { .. } => "close",
3688            BufferCollectionRequest::SetName { .. } => "set_name",
3689            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
3690            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
3691                "set_debug_timeout_log_deadline"
3692            }
3693            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
3694            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
3695            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
3696            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
3697            BufferCollectionRequest::WaitForBuffersAllocated { .. } => "wait_for_buffers_allocated",
3698            BufferCollectionRequest::CheckBuffersAllocated { .. } => "check_buffers_allocated",
3699            BufferCollectionRequest::AttachToken { .. } => "attach_token",
3700            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
3701        }
3702    }
3703}
3704
3705#[derive(Debug, Clone)]
3706pub struct BufferCollectionControlHandle {
3707    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3708}
3709
3710impl fidl::endpoints::ControlHandle for BufferCollectionControlHandle {
3711    fn shutdown(&self) {
3712        self.inner.shutdown()
3713    }
3714
3715    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3716        self.inner.shutdown_with_epitaph(status)
3717    }
3718
3719    fn is_closed(&self) -> bool {
3720        self.inner.channel().is_closed()
3721    }
3722    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3723        self.inner.channel().on_closed()
3724    }
3725
3726    #[cfg(target_os = "fuchsia")]
3727    fn signal_peer(
3728        &self,
3729        clear_mask: zx::Signals,
3730        set_mask: zx::Signals,
3731    ) -> Result<(), zx_status::Status> {
3732        use fidl::Peered;
3733        self.inner.channel().signal_peer(clear_mask, set_mask)
3734    }
3735}
3736
3737impl BufferCollectionControlHandle {}
3738
3739#[must_use = "FIDL methods require a response to be sent"]
3740#[derive(Debug)]
3741pub struct BufferCollectionSyncResponder {
3742    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3743    tx_id: u32,
3744}
3745
3746/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3747/// if the responder is dropped without sending a response, so that the client
3748/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3749impl std::ops::Drop for BufferCollectionSyncResponder {
3750    fn drop(&mut self) {
3751        self.control_handle.shutdown();
3752        // Safety: drops once, never accessed again
3753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3754    }
3755}
3756
3757impl fidl::endpoints::Responder for BufferCollectionSyncResponder {
3758    type ControlHandle = BufferCollectionControlHandle;
3759
3760    fn control_handle(&self) -> &BufferCollectionControlHandle {
3761        &self.control_handle
3762    }
3763
3764    fn drop_without_shutdown(mut self) {
3765        // Safety: drops once, never accessed again due to mem::forget
3766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3767        // Prevent Drop from running (which would shut down the channel)
3768        std::mem::forget(self);
3769    }
3770}
3771
3772impl BufferCollectionSyncResponder {
3773    /// Sends a response to the FIDL transaction.
3774    ///
3775    /// Sets the channel to shutdown if an error occurs.
3776    pub fn send(self) -> Result<(), fidl::Error> {
3777        let _result = self.send_raw();
3778        if _result.is_err() {
3779            self.control_handle.shutdown();
3780        }
3781        self.drop_without_shutdown();
3782        _result
3783    }
3784
3785    /// Similar to "send" but does not shutdown the channel if an error occurs.
3786    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3787        let _result = self.send_raw();
3788        self.drop_without_shutdown();
3789        _result
3790    }
3791
3792    fn send_raw(&self) -> Result<(), fidl::Error> {
3793        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3794            (),
3795            self.tx_id,
3796            0x4577e238ae26291,
3797            fidl::encoding::DynamicFlags::empty(),
3798        )
3799    }
3800}
3801
3802#[must_use = "FIDL methods require a response to be sent"]
3803#[derive(Debug)]
3804pub struct BufferCollectionGetNodeRefResponder {
3805    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3806    tx_id: u32,
3807}
3808
3809/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3810/// if the responder is dropped without sending a response, so that the client
3811/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3812impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
3813    fn drop(&mut self) {
3814        self.control_handle.shutdown();
3815        // Safety: drops once, never accessed again
3816        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3817    }
3818}
3819
3820impl fidl::endpoints::Responder for BufferCollectionGetNodeRefResponder {
3821    type ControlHandle = BufferCollectionControlHandle;
3822
3823    fn control_handle(&self) -> &BufferCollectionControlHandle {
3824        &self.control_handle
3825    }
3826
3827    fn drop_without_shutdown(mut self) {
3828        // Safety: drops once, never accessed again due to mem::forget
3829        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3830        // Prevent Drop from running (which would shut down the channel)
3831        std::mem::forget(self);
3832    }
3833}
3834
3835impl BufferCollectionGetNodeRefResponder {
3836    /// Sends a response to the FIDL transaction.
3837    ///
3838    /// Sets the channel to shutdown if an error occurs.
3839    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
3840        let _result = self.send_raw(node_ref);
3841        if _result.is_err() {
3842            self.control_handle.shutdown();
3843        }
3844        self.drop_without_shutdown();
3845        _result
3846    }
3847
3848    /// Similar to "send" but does not shutdown the channel if an error occurs.
3849    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
3850        let _result = self.send_raw(node_ref);
3851        self.drop_without_shutdown();
3852        _result
3853    }
3854
3855    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
3856        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
3857            (node_ref,),
3858            self.tx_id,
3859            0x467b7c75c35c3b84,
3860            fidl::encoding::DynamicFlags::empty(),
3861        )
3862    }
3863}
3864
3865#[must_use = "FIDL methods require a response to be sent"]
3866#[derive(Debug)]
3867pub struct BufferCollectionIsAlternateForResponder {
3868    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3869    tx_id: u32,
3870}
3871
3872/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3873/// if the responder is dropped without sending a response, so that the client
3874/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3875impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
3876    fn drop(&mut self) {
3877        self.control_handle.shutdown();
3878        // Safety: drops once, never accessed again
3879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3880    }
3881}
3882
3883impl fidl::endpoints::Responder for BufferCollectionIsAlternateForResponder {
3884    type ControlHandle = BufferCollectionControlHandle;
3885
3886    fn control_handle(&self) -> &BufferCollectionControlHandle {
3887        &self.control_handle
3888    }
3889
3890    fn drop_without_shutdown(mut self) {
3891        // Safety: drops once, never accessed again due to mem::forget
3892        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3893        // Prevent Drop from running (which would shut down the channel)
3894        std::mem::forget(self);
3895    }
3896}
3897
3898impl BufferCollectionIsAlternateForResponder {
3899    /// Sends a response to the FIDL transaction.
3900    ///
3901    /// Sets the channel to shutdown if an error occurs.
3902    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3903        let _result = self.send_raw(result);
3904        if _result.is_err() {
3905            self.control_handle.shutdown();
3906        }
3907        self.drop_without_shutdown();
3908        _result
3909    }
3910
3911    /// Similar to "send" but does not shutdown the channel if an error occurs.
3912    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3913        let _result = self.send_raw(result);
3914        self.drop_without_shutdown();
3915        _result
3916    }
3917
3918    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3919        self.control_handle
3920            .inner
3921            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
3922                result.map(|is_alternate| (is_alternate,)),
3923                self.tx_id,
3924                0x33a2a7aff2776c07,
3925                fidl::encoding::DynamicFlags::empty(),
3926            )
3927    }
3928}
3929
3930#[must_use = "FIDL methods require a response to be sent"]
3931#[derive(Debug)]
3932pub struct BufferCollectionWaitForBuffersAllocatedResponder {
3933    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3934    tx_id: u32,
3935}
3936
3937/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3938/// if the responder is dropped without sending a response, so that the client
3939/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3940impl std::ops::Drop for BufferCollectionWaitForBuffersAllocatedResponder {
3941    fn drop(&mut self) {
3942        self.control_handle.shutdown();
3943        // Safety: drops once, never accessed again
3944        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3945    }
3946}
3947
3948impl fidl::endpoints::Responder for BufferCollectionWaitForBuffersAllocatedResponder {
3949    type ControlHandle = BufferCollectionControlHandle;
3950
3951    fn control_handle(&self) -> &BufferCollectionControlHandle {
3952        &self.control_handle
3953    }
3954
3955    fn drop_without_shutdown(mut self) {
3956        // Safety: drops once, never accessed again due to mem::forget
3957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3958        // Prevent Drop from running (which would shut down the channel)
3959        std::mem::forget(self);
3960    }
3961}
3962
3963impl BufferCollectionWaitForBuffersAllocatedResponder {
3964    /// Sends a response to the FIDL transaction.
3965    ///
3966    /// Sets the channel to shutdown if an error occurs.
3967    pub fn send(
3968        self,
3969        mut status: i32,
3970        mut buffer_collection_info: BufferCollectionInfo2,
3971    ) -> Result<(), fidl::Error> {
3972        let _result = self.send_raw(status, buffer_collection_info);
3973        if _result.is_err() {
3974            self.control_handle.shutdown();
3975        }
3976        self.drop_without_shutdown();
3977        _result
3978    }
3979
3980    /// Similar to "send" but does not shutdown the channel if an error occurs.
3981    pub fn send_no_shutdown_on_err(
3982        self,
3983        mut status: i32,
3984        mut buffer_collection_info: BufferCollectionInfo2,
3985    ) -> Result<(), fidl::Error> {
3986        let _result = self.send_raw(status, buffer_collection_info);
3987        self.drop_without_shutdown();
3988        _result
3989    }
3990
3991    fn send_raw(
3992        &self,
3993        mut status: i32,
3994        mut buffer_collection_info: BufferCollectionInfo2,
3995    ) -> Result<(), fidl::Error> {
3996        self.control_handle.inner.send::<BufferCollectionWaitForBuffersAllocatedResponse>(
3997            (status, &mut buffer_collection_info),
3998            self.tx_id,
3999            0x714667ea2a29a3a2,
4000            fidl::encoding::DynamicFlags::empty(),
4001        )
4002    }
4003}
4004
4005#[must_use = "FIDL methods require a response to be sent"]
4006#[derive(Debug)]
4007pub struct BufferCollectionCheckBuffersAllocatedResponder {
4008    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4009    tx_id: u32,
4010}
4011
4012/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4013/// if the responder is dropped without sending a response, so that the client
4014/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4015impl std::ops::Drop for BufferCollectionCheckBuffersAllocatedResponder {
4016    fn drop(&mut self) {
4017        self.control_handle.shutdown();
4018        // Safety: drops once, never accessed again
4019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4020    }
4021}
4022
4023impl fidl::endpoints::Responder for BufferCollectionCheckBuffersAllocatedResponder {
4024    type ControlHandle = BufferCollectionControlHandle;
4025
4026    fn control_handle(&self) -> &BufferCollectionControlHandle {
4027        &self.control_handle
4028    }
4029
4030    fn drop_without_shutdown(mut self) {
4031        // Safety: drops once, never accessed again due to mem::forget
4032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4033        // Prevent Drop from running (which would shut down the channel)
4034        std::mem::forget(self);
4035    }
4036}
4037
4038impl BufferCollectionCheckBuffersAllocatedResponder {
4039    /// Sends a response to the FIDL transaction.
4040    ///
4041    /// Sets the channel to shutdown if an error occurs.
4042    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4043        let _result = self.send_raw(status);
4044        if _result.is_err() {
4045            self.control_handle.shutdown();
4046        }
4047        self.drop_without_shutdown();
4048        _result
4049    }
4050
4051    /// Similar to "send" but does not shutdown the channel if an error occurs.
4052    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4053        let _result = self.send_raw(status);
4054        self.drop_without_shutdown();
4055        _result
4056    }
4057
4058    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4059        self.control_handle.inner.send::<BufferCollectionCheckBuffersAllocatedResponse>(
4060            (status,),
4061            self.tx_id,
4062            0x245bb81f79189e9,
4063            fidl::encoding::DynamicFlags::empty(),
4064        )
4065    }
4066}
4067
4068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4069pub struct BufferCollectionTokenMarker;
4070
4071impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenMarker {
4072    type Proxy = BufferCollectionTokenProxy;
4073    type RequestStream = BufferCollectionTokenRequestStream;
4074    #[cfg(target_os = "fuchsia")]
4075    type SynchronousProxy = BufferCollectionTokenSynchronousProxy;
4076
4077    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4078}
4079
4080pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4081    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4082    fn r#sync(&self) -> Self::SyncResponseFut;
4083    fn r#close(&self) -> Result<(), fidl::Error>;
4084    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
4085    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
4086    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
4087    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4088    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
4089        + Send;
4090    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4091    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4092        + Send;
4093    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
4094    type DuplicateSyncResponseFut: std::future::Future<
4095            Output = Result<
4096                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
4097                fidl::Error,
4098            >,
4099        > + Send;
4100    fn r#duplicate_sync(
4101        &self,
4102        rights_attenuation_masks: &[fidl::Rights],
4103    ) -> Self::DuplicateSyncResponseFut;
4104    fn r#duplicate(
4105        &self,
4106        rights_attenuation_mask: u32,
4107        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4108    ) -> Result<(), fidl::Error>;
4109    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4110    fn r#create_buffer_collection_token_group(
4111        &self,
4112        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4113    ) -> Result<(), fidl::Error>;
4114}
4115#[derive(Debug)]
4116#[cfg(target_os = "fuchsia")]
4117pub struct BufferCollectionTokenSynchronousProxy {
4118    client: fidl::client::sync::Client,
4119}
4120
4121#[cfg(target_os = "fuchsia")]
4122impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenSynchronousProxy {
4123    type Proxy = BufferCollectionTokenProxy;
4124    type Protocol = BufferCollectionTokenMarker;
4125
4126    fn from_channel(inner: fidl::Channel) -> Self {
4127        Self::new(inner)
4128    }
4129
4130    fn into_channel(self) -> fidl::Channel {
4131        self.client.into_channel()
4132    }
4133
4134    fn as_channel(&self) -> &fidl::Channel {
4135        self.client.as_channel()
4136    }
4137}
4138
4139#[cfg(target_os = "fuchsia")]
4140impl BufferCollectionTokenSynchronousProxy {
4141    pub fn new(channel: fidl::Channel) -> Self {
4142        Self { client: fidl::client::sync::Client::new(channel) }
4143    }
4144
4145    pub fn into_channel(self) -> fidl::Channel {
4146        self.client.into_channel()
4147    }
4148
4149    /// Waits until an event arrives and returns it. It is safe for other
4150    /// threads to make concurrent requests while waiting for an event.
4151    pub fn wait_for_event(
4152        &self,
4153        deadline: zx::MonotonicInstant,
4154    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
4155        BufferCollectionTokenEvent::decode(
4156            self.client.wait_for_event::<BufferCollectionTokenMarker>(deadline)?,
4157        )
4158    }
4159
4160    /// Ensure that previous messages, including Duplicate() messages on a
4161    /// token, collection, or group, have been received server side.
4162    ///
4163    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4164    /// valid sysmem token risks the Sync() hanging forever.  See
4165    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4166    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4167    /// Another way is to pass the token to BindSharedCollection(), which also
4168    /// validates the token as part of exchanging it for a BufferCollection
4169    /// channel, and BufferCollection Sync() can then be used.
4170    ///
4171    /// After a Sync(), it's then safe to send the client end of token_request
4172    /// to another participant knowing the server will recognize the token when
4173    /// it's sent into BindSharedCollection() by the other participant.
4174    ///
4175    /// Other options include waiting for each token.Duplicate() to complete
4176    /// individually (using separate call to token.Sync() after each), or
4177    /// calling Sync() on BufferCollection after the token has been turned in
4178    /// via BindSharedCollection().
4179    ///
4180    /// Another way to mitigate is to avoid calling Sync() on the token, and
4181    /// instead later deal with potential failure of BufferCollection.Sync() if
4182    /// the original token was invalid.  This option can be preferable from a
4183    /// performance point of view, but requires client code to delay sending
4184    /// tokens duplicated from this token until after client code has converted
4185    /// the duplicating token to a BufferCollection and received successful
4186    /// response from BufferCollection.Sync().
4187    ///
4188    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4189    /// When BufferCollection.Sync() isn't feasible, the caller must already
4190    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4191    /// hang forever.  See ValidateBufferCollectionToken() to check token
4192    /// validity first if the token isn't already known to be (is/was) valid.
4193    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4194        let _response = self.client.send_query::<
4195            fidl::encoding::EmptyPayload,
4196            fidl::encoding::EmptyPayload,
4197            BufferCollectionTokenMarker,
4198        >(
4199            (),
4200            0x4577e238ae26291,
4201            fidl::encoding::DynamicFlags::empty(),
4202            ___deadline,
4203        )?;
4204        Ok(_response)
4205    }
4206
4207    /// On a BufferCollectionToken channel:
4208    ///
4209    /// Normally a participant will convert a BufferCollectionToken into a
4210    /// BufferCollection view, but a participant is also free to Close() the
4211    /// token (and then close the channel immediately or shortly later in
4212    /// response to server closing its end), which avoids causing logical buffer
4213    /// collection failure.  Normally an unexpected token channel close will
4214    /// cause logical buffer collection failure (the only exceptions being
4215    /// certain cases involving AttachToken() or SetDispensable()).
4216    ///
4217    /// On a BufferCollection channel:
4218    ///
4219    /// By default the server handles unexpected failure of a BufferCollection
4220    /// by failing the whole logical buffer collection.  Partly this is to
4221    /// expedite closing VMO handles to reclaim memory when any participant
4222    /// fails.  If a participant would like to cleanly close a BufferCollection
4223    /// view without causing logical buffer collection failure, the participant
4224    /// can send Close() before closing the client end of the BufferCollection
4225    /// channel.  If this is the last BufferCollection view, the logical buffer
4226    /// collection will still go away.  The Close() can occur before or after
4227    /// SetConstraints().  If before SetConstraints(), the buffer collection
4228    /// won't require constraints from this node in order to allocate.  If
4229    /// after SetConstraints(), the constraints are retained and aggregated
4230    /// along with any subsequent logical allocation(s), despite the lack of
4231    /// channel connection.
4232    ///
4233    /// On a BufferCollectionTokenGroup channel:
4234    ///
4235    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4236    /// trigger failure of the logical BufferCollectionTokenGroup and will
4237    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4238    /// channel without failing the logical group or propagating failure, send
4239    /// Close() before closing the channel client endpoint.
4240    ///
4241    /// If Close() occurs before AllChildrenPresent(), the logical buffer
4242    /// collection will still fail despite the Close() (because sysmem can't be
4243    /// sure whether all relevant children were created, so it's ambiguous
4244    /// whether all relevant constraints will be provided to sysmem).  If
4245    /// Close() occurs after AllChildrenPresent(), the children and all their
4246    /// constraints remain intact (just as they would if the
4247    /// BufferCollectionTokenGroup channel had remained open), and the close
4248    /// doesn't trigger or propagate failure.
4249    pub fn r#close(&self) -> Result<(), fidl::Error> {
4250        self.client.send::<fidl::encoding::EmptyPayload>(
4251            (),
4252            0x5b1d7a4f5681fca7,
4253            fidl::encoding::DynamicFlags::empty(),
4254        )
4255    }
4256
4257    /// Set a name for VMOs in this buffer collection. The name may be truncated
4258    /// shorter. The name only affects VMOs allocated after it's set - this call
4259    /// does not rename existing VMOs. If multiple clients set different names
4260    /// then the larger priority value will win.
4261    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
4262        self.client.send::<NodeSetNameRequest>(
4263            (priority, name),
4264            0x77a41bb6217e2443,
4265            fidl::encoding::DynamicFlags::empty(),
4266        )
4267    }
4268
4269    /// Set information about the current client that can be used by sysmem to
4270    /// help debug leaking memory and hangs waiting for constraints. |name| can
4271    /// be an arbitrary string, but the current process name (see
4272    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4273    /// arbitrary id, but the current process ID (see
4274    /// fsl::GetCurrentProcessKoid()) is a good default.
4275    ///
4276    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4277    /// indicate which client is closing their channel first, leading to
4278    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4279    /// over, but if happening earlier than expected, the
4280    /// client-channel-specific name can help diagnose where the failure is
4281    /// first coming from, from sysmem's point of view).
4282    ///
4283    /// By default (unless overriden by this message or using
4284    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4285    /// parent Node at the time the child Node is created.  While this can be
4286    /// better than nothing, it's often better for each participant to use
4287    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4288    /// info directly relevant to the current client.  Also, SetVerboseLogging()
4289    /// can be used to help disambiguate if a Node is suspected of having info
4290    /// that was copied from its parent.
4291    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
4292        self.client.send::<NodeSetDebugClientInfoRequest>(
4293            (name, id),
4294            0x7275759070eb5ee2,
4295            fidl::encoding::DynamicFlags::empty(),
4296        )
4297    }
4298
4299    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4300    /// after creating a collection. Clients can call this method to change
4301    /// when the log is printed. If multiple client set the deadline, it's
4302    /// unspecified which deadline will take effect.
4303    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
4304        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
4305            (deadline,),
4306            0x46d38f4772638867,
4307            fidl::encoding::DynamicFlags::empty(),
4308        )
4309    }
4310
4311    /// Verbose logging includes constraints set via SetConstraints() from each
4312    /// client along with info set via SetDebugClientInfo() and the structure of
4313    /// the tree of Node(s).
4314    ///
4315    /// Normally sysmem prints only a single line complaint when aggregation
4316    /// fails, with just the specific detailed reason that aggregation failed,
4317    /// with minimal context.  While this is often enough to diagnose a problem
4318    /// if only a small change was made and the system had been working before
4319    /// the small change, it's often not particularly helpful for getting a new
4320    /// buffer collection to work for the first time.  Especially with more
4321    /// complex trees of nodes, involving things like AttachToken(),
4322    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4323    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4324    /// looks like and why it's failing a logical allocation, or why a tree or
4325    /// sub-tree is failing sooner than expected.
4326    ///
4327    /// The intent of the extra logging is to be acceptable from a performance
4328    /// point of view, if only enabled on a low number of buffer collections.
4329    /// If we're not tracking down a bug, we shouldn't send this message.
4330    ///
4331    /// If too many participants leave verbose logging enabled, we may end up
4332    /// needing to require that system-wide sysmem verbose logging be permitted
4333    /// via some other setting, to avoid sysmem spamming the log too much due to
4334    /// this message.
4335    ///
4336    /// This may be a NOP for some nodes due to intentional policy associated
4337    /// with the node, if we don't trust a node enough to let it turn on verbose
4338    /// logging.
4339    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4340        self.client.send::<fidl::encoding::EmptyPayload>(
4341            (),
4342            0x6bfbe2cf1701d288,
4343            fidl::encoding::DynamicFlags::empty(),
4344        )
4345    }
4346
4347    /// This gets an event handle that can be used as a parameter to
4348    /// IsAlternateFor() called on any Node.  The client will not be granted the
4349    /// right to signal this event, as this handle should only be used as proof
4350    /// that the client obtained this handle from this Node.
4351    ///
4352    /// Because this is a get not a set, no Sync() is needed between the
4353    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4354    /// potentially being on different channels.
4355    ///
4356    /// See also IsAlternateFor().
4357    pub fn r#get_node_ref(
4358        &self,
4359        ___deadline: zx::MonotonicInstant,
4360    ) -> Result<fidl::Event, fidl::Error> {
4361        let _response = self.client.send_query::<
4362            fidl::encoding::EmptyPayload,
4363            NodeGetNodeRefResponse,
4364            BufferCollectionTokenMarker,
4365        >(
4366            (),
4367            0x467b7c75c35c3b84,
4368            fidl::encoding::DynamicFlags::empty(),
4369            ___deadline,
4370        )?;
4371        Ok(_response.node_ref)
4372    }
4373
4374    /// This checks whether the calling node is in a subtree rooted at a
4375    /// different child token of a common parent BufferCollectionTokenGroup, in
4376    /// relation to the passed-in node_ref.
4377    ///
4378    /// This call is for assisting with admission control de-duplication, and
4379    /// with debugging.
4380    ///
4381    /// The node_ref must be obtained using GetNodeRef() of a
4382    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4383    ///
4384    /// The node_ref can be a duplicated handle; it's not necessary to call
4385    /// GetNodeRef() for every call to IsAlternateFor().
4386    ///
4387    /// If a calling token may not actually be a valid token at all due to
4388    /// a potentially hostile/untrusted provider of the token, call
4389    /// ValidateBufferCollectionToken() first instead of potentially getting
4390    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4391    /// token not being a real token (not really talking to sysmem).  Another
4392    /// option is to call BindSharedCollection with this token first which also
4393    /// validates the token along with converting it to a BufferCollection, then
4394    /// call BufferCollection IsAlternateFor().
4395    ///
4396    /// error values:
4397    ///
4398    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4399    /// buffer collection as the calling Node.  Before logical allocation and
4400    /// within the same logical allocation sub-tree, this essentially means that
4401    /// the node_ref was never part of this logical buffer collection, since
4402    /// before logical allocation all node_refs that come into existence remain
4403    /// in existence at least until logical allocation (including Node(s) that
4404    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4405    /// to be returned, this Node's channel needs to still be connected server
4406    /// side, which won't be the case if the whole logical allocation has
4407    /// failed.  After logical allocation or in a different logical allocation
4408    /// sub-tree there are additional potential reasons for this error.  For
4409    /// example a different logical allocation (separated from this Node(s)
4410    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4411    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4412    /// exist and may select a different child sub-tree than the sub-tree the
4413    /// node_ref is in causing deletion of the node_ref Node.  The only time
4414    /// sysmem keeps a Node around after that Node has no corresponding channel
4415    /// is when Close() is used and the Node's sub-tree has not yet failed.
4416    /// Another reason for this error is if the node_ref is an eventpair handle
4417    /// with sufficient rights, but isn't actually a real node_ref obtained from
4418    /// GetNodeRef().
4419    ///
4420    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4421    /// eventpair handle, or doesn't have the needed rights expected on a real
4422    /// node_ref.
4423    ///
4424    /// No other failing status codes are returned by this call.  However,
4425    /// sysmem may add additional codes in future, so the client should have
4426    /// sensible default handling for any failing status code.
4427    ///
4428    /// On success, is_alternate has the following meaning:
4429    ///   * true - The first parent node in common between the calling node and
4430    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
4431    ///     the calling Node and the node_ref Node will _not_ have both their
4432    ///     constraints apply - rather sysmem will choose one or the other of
4433    ///     the constraints - never both.  This is because only one child of
4434    ///     a BufferCollectionTokenGroup is selected during logical allocation,
4435    ///     with only that one child's sub-tree contributing to constraints
4436    ///     aggregation.
4437    ///   * false - The first parent node in common between the calling Node and
4438    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
4439    ///     this means the first parent node in common is a
4440    ///     BufferCollectionToken or BufferCollection (regardless of not
4441    ///     Close()ed or Close()ed).  This means that the calling Node and the
4442    ///     node_ref Node _may_ have both their constraints apply during
4443    ///     constraints aggregation of the logical allocation, if both Node(s)
4444    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
4445    ///     In this case, there is no BufferCollectionTokenGroup that will
4446    ///     directly prevent the two Node(s) from both being selected and their
4447    ///     constraints both aggregated, but even when false, one or both
4448    ///     Node(s) may still be eliminated from consideration if one or both
4449    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4450    ///     which selects a child sub-tree other than the sub-tree containing
4451    ///     the calling Node or node_ref Node.
4452    pub fn r#is_alternate_for(
4453        &self,
4454        mut node_ref: fidl::Event,
4455        ___deadline: zx::MonotonicInstant,
4456    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
4457        let _response = self.client.send_query::<
4458            NodeIsAlternateForRequest,
4459            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
4460            BufferCollectionTokenMarker,
4461        >(
4462            (node_ref,),
4463            0x33a2a7aff2776c07,
4464            fidl::encoding::DynamicFlags::empty(),
4465            ___deadline,
4466        )?;
4467        Ok(_response.map(|x| x.is_alternate))
4468    }
4469
4470    /// This method can be used to add more participants prior to creating a
4471    /// shared BufferCollection. A new token will be returned for each entry in
4472    /// the `rights_attenuation_masks` array. The return value is the client
4473    /// ends of each new participant token.
4474    ///
4475    /// If the calling token may not actually be a valid token at all due to
4476    /// a potentially hostile/untrusted provider of the token, consider using
4477    /// ValidateBufferCollectionToken() first instead of potentially getting
4478    /// stuck indefinitely if DuplicateSync() never responds due to the calling
4479    /// token not being a real token.
4480    ///
4481    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4482    /// after calling this method.
4483    ///
4484    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4485    /// BufferCollection to be successfully created.
4486    ///
4487    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4488    /// will be absent in the buffer VMO rights obtainable via the corresponding
4489    /// returned token. This allows an initiator or intermediary participant to
4490    /// attenuate the rights available to a participant. This does not allow a
4491    /// participant to gain rights that the participant doesn't already have.
4492    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4493    /// attenuation should be applied.
4494    pub fn r#duplicate_sync(
4495        &self,
4496        mut rights_attenuation_masks: &[fidl::Rights],
4497        ___deadline: zx::MonotonicInstant,
4498    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
4499        let _response = self.client.send_query::<
4500            BufferCollectionTokenDuplicateSyncRequest,
4501            BufferCollectionTokenDuplicateSyncResponse,
4502            BufferCollectionTokenMarker,
4503        >(
4504            (rights_attenuation_masks,),
4505            0x49ed7ab7cc19f18,
4506            fidl::encoding::DynamicFlags::empty(),
4507            ___deadline,
4508        )?;
4509        Ok(_response.tokens)
4510    }
4511
4512    /// This method can be used to add a participant prior to creating a shared
4513    /// BufferCollection. It should only be used instead of DuplicateSync in
4514    /// performance sensitive cases where it would be undesireable to wait for
4515    /// sysmem to respond as part of each duplicate.
4516    ///
4517    /// After sending one or more Duplicate() messages, and before sending the
4518    /// created tokens to other participants (or to other Allocator channels),
4519    /// the client should send a Sync() and wait for its response.  The Sync()
4520    /// call can be made on the token, or on the BufferCollection obtained by
4521    /// passing this token to BindSharedCollection().  Either will ensure that
4522    /// the server knows about the tokens created via Duplicate() before the
4523    /// other participant sends the token to the server via separate Allocator
4524    /// channel.
4525    ///
4526    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4527    /// BufferCollection to be successfully created.
4528    ///
4529    /// When a client calls BindSharedCollection() to turn in a
4530    /// BufferCollectionToken, the server will process all Duplicate() messages
4531    /// before closing down the BufferCollectionToken.  This allows the client
4532    /// to Duplicate() and immediately turn in the BufferCollectionToken using
4533    /// BindSharedCollection, then later transfer the client end of token_request
4534    /// to another participant - the server will notice the existence of the
4535    /// token_request before considering this BufferCollectionToken fully closed.
4536    ///
4537    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
4538    /// absent in the buffer VMO rights obtainable via the client end of
4539    /// token_request. This allows an initiator or intermediary participant to
4540    /// attenuate the rights available to a participant. This does not allow a
4541    /// participant to gain rights that the participant doesn't already have.
4542    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4543    /// attenuation should be applied.
4544    ///
4545    /// These values for rights_attenuation_mask result in no attenuation:
4546    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
4547    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
4548    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
4549    ///
4550    /// `token_request` is the server end of a BufferCollectionToken channel.
4551    /// The client end of this channel acts as another participant in creating the
4552    /// shared BufferCollection.
4553    pub fn r#duplicate(
4554        &self,
4555        mut rights_attenuation_mask: u32,
4556        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
4557    ) -> Result<(), fidl::Error> {
4558        self.client.send::<BufferCollectionTokenDuplicateRequest>(
4559            (rights_attenuation_mask, token_request),
4560            0x2f9f81bdde4b7292,
4561            fidl::encoding::DynamicFlags::empty(),
4562        )
4563    }
4564
4565    /// A dispensable token can fail after buffers are logically allocated
4566    /// without causing failure of its parent (if any).
4567    ///
4568    /// The dispensable token participates in constraints aggregation along with
4569    /// its parent before logical buffer allocation.  If the dispensable token
4570    /// fails before buffers are logically allocated, the failure propagates to
4571    /// the dispensable token's parent.
4572    ///
4573    /// After buffers are logically allocated, failure of the dispensable token
4574    /// (or any child of the dispensable token) does not propagate to the
4575    /// dispensable token's parent.  Failure does propagate from a normal
4576    /// child of a dispensable token to the dispensable token.  Failure
4577    /// of a child is blocked from reaching its parent if the child is attached,
4578    /// or if the child is dispensable and the failure occurred after logical
4579    /// allocation.
4580    ///
4581    /// A dispensable token can be used in cases where a participant needs to
4582    /// provide constraints, but after buffers are allocated, the participant
4583    /// can fail without causing buffer collection failure from the parent's
4584    /// point of view.
4585    ///
4586    /// In contrast, AttachToken() can be used to create a token which does not
4587    /// participate in constraints aggregation with its parent, and whose
4588    /// failure at any time does not propagate to its parent, and whose delay
4589    /// providing constraints does not prevent the parent from completing its
4590    /// buffer allocation.
4591    ///
4592    /// An initiator may in some scenarios choose to initially use a dispensable
4593    /// token for a given instance of a participant, and then later if the first
4594    /// instance of that participant fails, a new second instance of that
4595    /// participant my be given a token created with AttachToken().
4596    ///
4597    /// If a client uses this message, the client should not rely on the
4598    /// client's own BufferCollectionToken or BufferCollection channel to close
4599    /// from the server end due to abrupt failure of any BufferCollectionToken
4600    /// or BufferCollection that the client has SetDispensable() and given out
4601    /// to another process.  For this reason, the client should take extra care
4602    /// to notice failure of that other process via other means.
4603    ///
4604    /// While it is possible (and potentially useful) to SetDispensable() on a
4605    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
4606    /// replace a failed dispensable token that was a direct child of a group
4607    /// with a new token using AttachToken() (since there's no AttachToken() on
4608    /// a group).  Instead, to enable AttachToken() replacement in this case,
4609    /// create an additional non-dispensable token (node) that's a direct child
4610    /// of the group and make the existing dispensable token a child of the
4611    /// additional token (node).  This way, the additional token (node) that is
4612    /// a direct child of the group has BufferCollection.AttachToken() which can
4613    /// be used to replace the failed dispensable token.
4614    ///
4615    /// SetDispensable() on an already-dispensable token is idempotent.
4616    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
4617        self.client.send::<fidl::encoding::EmptyPayload>(
4618            (),
4619            0x76e4ec34fc2cf5b3,
4620            fidl::encoding::DynamicFlags::empty(),
4621        )
4622    }
4623
4624    /// Most sysmem clients and many participants don't need to care about this
4625    /// message or about BufferCollectionTokenGroup(s) in general.
4626    ///
4627    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
4628    /// tokens.  The child tokens which are not selected during aggregation will
4629    /// fail (close), which a potential participant should notice when their
4630    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
4631    /// participant to clean up the speculative usage that didn't end up
4632    /// happening (similarly to a normal BufferCollection server end closing
4633    /// on failure of a logical buffer collection).
4634    ///
4635    /// See comments on protocol BufferCollectionTokenGroup.
4636    ///
4637    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
4638    /// applied to the whole group can be achieved with a token for this purpose
4639    /// as a direct parent of the group.
4640    ///
4641    /// group_request - the server end of a BufferCollectionTokenGroup channel
4642    /// to be served by sysmem.
4643    pub fn r#create_buffer_collection_token_group(
4644        &self,
4645        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
4646    ) -> Result<(), fidl::Error> {
4647        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
4648            (group_request,),
4649            0x2f6243e05f22b9a7,
4650            fidl::encoding::DynamicFlags::empty(),
4651        )
4652    }
4653}
4654
4655#[cfg(target_os = "fuchsia")]
4656impl From<BufferCollectionTokenSynchronousProxy> for zx::NullableHandle {
4657    fn from(value: BufferCollectionTokenSynchronousProxy) -> Self {
4658        value.into_channel().into()
4659    }
4660}
4661
4662#[cfg(target_os = "fuchsia")]
4663impl From<fidl::Channel> for BufferCollectionTokenSynchronousProxy {
4664    fn from(value: fidl::Channel) -> Self {
4665        Self::new(value)
4666    }
4667}
4668
4669#[cfg(target_os = "fuchsia")]
4670impl fidl::endpoints::FromClient for BufferCollectionTokenSynchronousProxy {
4671    type Protocol = BufferCollectionTokenMarker;
4672
4673    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>) -> Self {
4674        Self::new(value.into_channel())
4675    }
4676}
4677
4678#[derive(Debug, Clone)]
4679pub struct BufferCollectionTokenProxy {
4680    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4681}
4682
4683impl fidl::endpoints::Proxy for BufferCollectionTokenProxy {
4684    type Protocol = BufferCollectionTokenMarker;
4685
4686    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4687        Self::new(inner)
4688    }
4689
4690    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4691        self.client.into_channel().map_err(|client| Self { client })
4692    }
4693
4694    fn as_channel(&self) -> &::fidl::AsyncChannel {
4695        self.client.as_channel()
4696    }
4697}
4698
4699impl BufferCollectionTokenProxy {
4700    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionToken.
4701    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4702        let protocol_name =
4703            <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4704        Self { client: fidl::client::Client::new(channel, protocol_name) }
4705    }
4706
4707    /// Get a Stream of events from the remote end of the protocol.
4708    ///
4709    /// # Panics
4710    ///
4711    /// Panics if the event stream was already taken.
4712    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4713        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4714    }
4715
4716    /// Ensure that previous messages, including Duplicate() messages on a
4717    /// token, collection, or group, have been received server side.
4718    ///
4719    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4720    /// valid sysmem token risks the Sync() hanging forever.  See
4721    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4722    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4723    /// Another way is to pass the token to BindSharedCollection(), which also
4724    /// validates the token as part of exchanging it for a BufferCollection
4725    /// channel, and BufferCollection Sync() can then be used.
4726    ///
4727    /// After a Sync(), it's then safe to send the client end of token_request
4728    /// to another participant knowing the server will recognize the token when
4729    /// it's sent into BindSharedCollection() by the other participant.
4730    ///
4731    /// Other options include waiting for each token.Duplicate() to complete
4732    /// individually (using separate call to token.Sync() after each), or
4733    /// calling Sync() on BufferCollection after the token has been turned in
4734    /// via BindSharedCollection().
4735    ///
4736    /// Another way to mitigate is to avoid calling Sync() on the token, and
4737    /// instead later deal with potential failure of BufferCollection.Sync() if
4738    /// the original token was invalid.  This option can be preferable from a
4739    /// performance point of view, but requires client code to delay sending
4740    /// tokens duplicated from this token until after client code has converted
4741    /// the duplicating token to a BufferCollection and received successful
4742    /// response from BufferCollection.Sync().
4743    ///
4744    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4745    /// When BufferCollection.Sync() isn't feasible, the caller must already
4746    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4747    /// hang forever.  See ValidateBufferCollectionToken() to check token
4748    /// validity first if the token isn't already known to be (is/was) valid.
4749    pub fn r#sync(
4750        &self,
4751    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4752        BufferCollectionTokenProxyInterface::r#sync(self)
4753    }
4754
4755    /// On a BufferCollectionToken channel:
4756    ///
4757    /// Normally a participant will convert a BufferCollectionToken into a
4758    /// BufferCollection view, but a participant is also free to Close() the
4759    /// token (and then close the channel immediately or shortly later in
4760    /// response to server closing its end), which avoids causing logical buffer
4761    /// collection failure.  Normally an unexpected token channel close will
4762    /// cause logical buffer collection failure (the only exceptions being
4763    /// certain cases involving AttachToken() or SetDispensable()).
4764    ///
4765    /// On a BufferCollection channel:
4766    ///
4767    /// By default the server handles unexpected failure of a BufferCollection
4768    /// by failing the whole logical buffer collection.  Partly this is to
4769    /// expedite closing VMO handles to reclaim memory when any participant
4770    /// fails.  If a participant would like to cleanly close a BufferCollection
4771    /// view without causing logical buffer collection failure, the participant
4772    /// can send Close() before closing the client end of the BufferCollection
4773    /// channel.  If this is the last BufferCollection view, the logical buffer
4774    /// collection will still go away.  The Close() can occur before or after
4775    /// SetConstraints().  If before SetConstraints(), the buffer collection
4776    /// won't require constraints from this node in order to allocate.  If
4777    /// after SetConstraints(), the constraints are retained and aggregated
4778    /// along with any subsequent logical allocation(s), despite the lack of
4779    /// channel connection.
4780    ///
4781    /// On a BufferCollectionTokenGroup channel:
4782    ///
4783    /// By default, unexpected failure of a BufferCollectionTokenGroup will
4784    /// trigger failure of the logical BufferCollectionTokenGroup and will
4785    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
4786    /// channel without failing the logical group or propagating failure, send
4787    /// Close() before closing the channel client endpoint.
4788    ///
4789    /// If Close() occurs before AllChildrenPresent(), the logical buffer
4790    /// collection will still fail despite the Close() (because sysmem can't be
4791    /// sure whether all relevant children were created, so it's ambiguous
4792    /// whether all relevant constraints will be provided to sysmem).  If
4793    /// Close() occurs after AllChildrenPresent(), the children and all their
4794    /// constraints remain intact (just as they would if the
4795    /// BufferCollectionTokenGroup channel had remained open), and the close
4796    /// doesn't trigger or propagate failure.
4797    pub fn r#close(&self) -> Result<(), fidl::Error> {
4798        BufferCollectionTokenProxyInterface::r#close(self)
4799    }
4800
4801    /// Set a name for VMOs in this buffer collection. The name may be truncated
4802    /// shorter. The name only affects VMOs allocated after it's set - this call
4803    /// does not rename existing VMOs. If multiple clients set different names
4804    /// then the larger priority value will win.
4805    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
4806        BufferCollectionTokenProxyInterface::r#set_name(self, priority, name)
4807    }
4808
4809    /// Set information about the current client that can be used by sysmem to
4810    /// help debug leaking memory and hangs waiting for constraints. |name| can
4811    /// be an arbitrary string, but the current process name (see
4812    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4813    /// arbitrary id, but the current process ID (see
4814    /// fsl::GetCurrentProcessKoid()) is a good default.
4815    ///
4816    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4817    /// indicate which client is closing their channel first, leading to
4818    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4819    /// over, but if happening earlier than expected, the
4820    /// client-channel-specific name can help diagnose where the failure is
4821    /// first coming from, from sysmem's point of view).
4822    ///
4823    /// By default (unless overriden by this message or using
4824    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4825    /// parent Node at the time the child Node is created.  While this can be
4826    /// better than nothing, it's often better for each participant to use
4827    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4828    /// info directly relevant to the current client.  Also, SetVerboseLogging()
4829    /// can be used to help disambiguate if a Node is suspected of having info
4830    /// that was copied from its parent.
4831    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
4832        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, name, id)
4833    }
4834
4835    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4836    /// after creating a collection. Clients can call this method to change
4837    /// when the log is printed. If multiple client set the deadline, it's
4838    /// unspecified which deadline will take effect.
4839    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
4840        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
4841    }
4842
4843    /// Verbose logging includes constraints set via SetConstraints() from each
4844    /// client along with info set via SetDebugClientInfo() and the structure of
4845    /// the tree of Node(s).
4846    ///
4847    /// Normally sysmem prints only a single line complaint when aggregation
4848    /// fails, with just the specific detailed reason that aggregation failed,
4849    /// with minimal context.  While this is often enough to diagnose a problem
4850    /// if only a small change was made and the system had been working before
4851    /// the small change, it's often not particularly helpful for getting a new
4852    /// buffer collection to work for the first time.  Especially with more
4853    /// complex trees of nodes, involving things like AttachToken(),
4854    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4855    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4856    /// looks like and why it's failing a logical allocation, or why a tree or
4857    /// sub-tree is failing sooner than expected.
4858    ///
4859    /// The intent of the extra logging is to be acceptable from a performance
4860    /// point of view, if only enabled on a low number of buffer collections.
4861    /// If we're not tracking down a bug, we shouldn't send this message.
4862    ///
4863    /// If too many participants leave verbose logging enabled, we may end up
4864    /// needing to require that system-wide sysmem verbose logging be permitted
4865    /// via some other setting, to avoid sysmem spamming the log too much due to
4866    /// this message.
4867    ///
4868    /// This may be a NOP for some nodes due to intentional policy associated
4869    /// with the node, if we don't trust a node enough to let it turn on verbose
4870    /// logging.
4871    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4872        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
4873    }
4874
4875    /// This gets an event handle that can be used as a parameter to
4876    /// IsAlternateFor() called on any Node.  The client will not be granted the
4877    /// right to signal this event, as this handle should only be used as proof
4878    /// that the client obtained this handle from this Node.
4879    ///
4880    /// Because this is a get not a set, no Sync() is needed between the
4881    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4882    /// potentially being on different channels.
4883    ///
4884    /// See also IsAlternateFor().
4885    pub fn r#get_node_ref(
4886        &self,
4887    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
4888    {
4889        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
4890    }
4891
4892    /// This checks whether the calling node is in a subtree rooted at a
4893    /// different child token of a common parent BufferCollectionTokenGroup, in
4894    /// relation to the passed-in node_ref.
4895    ///
4896    /// This call is for assisting with admission control de-duplication, and
4897    /// with debugging.
4898    ///
4899    /// The node_ref must be obtained using GetNodeRef() of a
4900    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4901    ///
4902    /// The node_ref can be a duplicated handle; it's not necessary to call
4903    /// GetNodeRef() for every call to IsAlternateFor().
4904    ///
4905    /// If a calling token may not actually be a valid token at all due to
4906    /// a potentially hostile/untrusted provider of the token, call
4907    /// ValidateBufferCollectionToken() first instead of potentially getting
4908    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4909    /// token not being a real token (not really talking to sysmem).  Another
4910    /// option is to call BindSharedCollection with this token first which also
4911    /// validates the token along with converting it to a BufferCollection, then
4912    /// call BufferCollection IsAlternateFor().
4913    ///
4914    /// error values:
4915    ///
4916    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4917    /// buffer collection as the calling Node.  Before logical allocation and
4918    /// within the same logical allocation sub-tree, this essentially means that
4919    /// the node_ref was never part of this logical buffer collection, since
4920    /// before logical allocation all node_refs that come into existence remain
4921    /// in existence at least until logical allocation (including Node(s) that
4922    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4923    /// to be returned, this Node's channel needs to still be connected server
4924    /// side, which won't be the case if the whole logical allocation has
4925    /// failed.  After logical allocation or in a different logical allocation
4926    /// sub-tree there are additional potential reasons for this error.  For
4927    /// example a different logical allocation (separated from this Node(s)
4928    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4929    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4930    /// exist and may select a different child sub-tree than the sub-tree the
4931    /// node_ref is in causing deletion of the node_ref Node.  The only time
4932    /// sysmem keeps a Node around after that Node has no corresponding channel
4933    /// is when Close() is used and the Node's sub-tree has not yet failed.
4934    /// Another reason for this error is if the node_ref is an eventpair handle
4935    /// with sufficient rights, but isn't actually a real node_ref obtained from
4936    /// GetNodeRef().
4937    ///
4938    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4939    /// eventpair handle, or doesn't have the needed rights expected on a real
4940    /// node_ref.
4941    ///
4942    /// No other failing status codes are returned by this call.  However,
4943    /// sysmem may add additional codes in future, so the client should have
4944    /// sensible default handling for any failing status code.
4945    ///
4946    /// On success, is_alternate has the following meaning:
4947    ///   * true - The first parent node in common between the calling node and
4948    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
4949    ///     the calling Node and the node_ref Node will _not_ have both their
4950    ///     constraints apply - rather sysmem will choose one or the other of
4951    ///     the constraints - never both.  This is because only one child of
4952    ///     a BufferCollectionTokenGroup is selected during logical allocation,
4953    ///     with only that one child's sub-tree contributing to constraints
4954    ///     aggregation.
4955    ///   * false - The first parent node in common between the calling Node and
4956    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
4957    ///     this means the first parent node in common is a
4958    ///     BufferCollectionToken or BufferCollection (regardless of not
4959    ///     Close()ed or Close()ed).  This means that the calling Node and the
4960    ///     node_ref Node _may_ have both their constraints apply during
4961    ///     constraints aggregation of the logical allocation, if both Node(s)
4962    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
4963    ///     In this case, there is no BufferCollectionTokenGroup that will
4964    ///     directly prevent the two Node(s) from both being selected and their
4965    ///     constraints both aggregated, but even when false, one or both
4966    ///     Node(s) may still be eliminated from consideration if one or both
4967    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4968    ///     which selects a child sub-tree other than the sub-tree containing
4969    ///     the calling Node or node_ref Node.
4970    pub fn r#is_alternate_for(
4971        &self,
4972        mut node_ref: fidl::Event,
4973    ) -> fidl::client::QueryResponseFut<
4974        NodeIsAlternateForResult,
4975        fidl::encoding::DefaultFuchsiaResourceDialect,
4976    > {
4977        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, node_ref)
4978    }
4979
4980    /// This method can be used to add more participants prior to creating a
4981    /// shared BufferCollection. A new token will be returned for each entry in
4982    /// the `rights_attenuation_masks` array. The return value is the client
4983    /// ends of each new participant token.
4984    ///
4985    /// If the calling token may not actually be a valid token at all due to
4986    /// a potentially hostile/untrusted provider of the token, consider using
4987    /// ValidateBufferCollectionToken() first instead of potentially getting
4988    /// stuck indefinitely if DuplicateSync() never responds due to the calling
4989    /// token not being a real token.
4990    ///
4991    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4992    /// after calling this method.
4993    ///
4994    /// All tokens must be turned in via BindSharedCollection() or Close() for a
4995    /// BufferCollection to be successfully created.
4996    ///
4997    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4998    /// will be absent in the buffer VMO rights obtainable via the corresponding
4999    /// returned token. This allows an initiator or intermediary participant to
5000    /// attenuate the rights available to a participant. This does not allow a
5001    /// participant to gain rights that the participant doesn't already have.
5002    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5003    /// attenuation should be applied.
5004    pub fn r#duplicate_sync(
5005        &self,
5006        mut rights_attenuation_masks: &[fidl::Rights],
5007    ) -> fidl::client::QueryResponseFut<
5008        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5009        fidl::encoding::DefaultFuchsiaResourceDialect,
5010    > {
5011        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, rights_attenuation_masks)
5012    }
5013
5014    /// This method can be used to add a participant prior to creating a shared
5015    /// BufferCollection. It should only be used instead of DuplicateSync in
5016    /// performance sensitive cases where it would be undesireable to wait for
5017    /// sysmem to respond as part of each duplicate.
5018    ///
5019    /// After sending one or more Duplicate() messages, and before sending the
5020    /// created tokens to other participants (or to other Allocator channels),
5021    /// the client should send a Sync() and wait for its response.  The Sync()
5022    /// call can be made on the token, or on the BufferCollection obtained by
5023    /// passing this token to BindSharedCollection().  Either will ensure that
5024    /// the server knows about the tokens created via Duplicate() before the
5025    /// other participant sends the token to the server via separate Allocator
5026    /// channel.
5027    ///
5028    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5029    /// BufferCollection to be successfully created.
5030    ///
5031    /// When a client calls BindSharedCollection() to turn in a
5032    /// BufferCollectionToken, the server will process all Duplicate() messages
5033    /// before closing down the BufferCollectionToken.  This allows the client
5034    /// to Duplicate() and immediately turn in the BufferCollectionToken using
5035    /// BindSharedCollection, then later transfer the client end of token_request
5036    /// to another participant - the server will notice the existence of the
5037    /// token_request before considering this BufferCollectionToken fully closed.
5038    ///
5039    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
5040    /// absent in the buffer VMO rights obtainable via the client end of
5041    /// token_request. This allows an initiator or intermediary participant to
5042    /// attenuate the rights available to a participant. This does not allow a
5043    /// participant to gain rights that the participant doesn't already have.
5044    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5045    /// attenuation should be applied.
5046    ///
5047    /// These values for rights_attenuation_mask result in no attenuation:
5048    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
5049    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
5050    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
5051    ///
5052    /// `token_request` is the server end of a BufferCollectionToken channel.
5053    /// The client end of this channel acts as another participant in creating the
5054    /// shared BufferCollection.
5055    pub fn r#duplicate(
5056        &self,
5057        mut rights_attenuation_mask: u32,
5058        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5059    ) -> Result<(), fidl::Error> {
5060        BufferCollectionTokenProxyInterface::r#duplicate(
5061            self,
5062            rights_attenuation_mask,
5063            token_request,
5064        )
5065    }
5066
5067    /// A dispensable token can fail after buffers are logically allocated
5068    /// without causing failure of its parent (if any).
5069    ///
5070    /// The dispensable token participates in constraints aggregation along with
5071    /// its parent before logical buffer allocation.  If the dispensable token
5072    /// fails before buffers are logically allocated, the failure propagates to
5073    /// the dispensable token's parent.
5074    ///
5075    /// After buffers are logically allocated, failure of the dispensable token
5076    /// (or any child of the dispensable token) does not propagate to the
5077    /// dispensable token's parent.  Failure does propagate from a normal
5078    /// child of a dispensable token to the dispensable token.  Failure
5079    /// of a child is blocked from reaching its parent if the child is attached,
5080    /// or if the child is dispensable and the failure occurred after logical
5081    /// allocation.
5082    ///
5083    /// A dispensable token can be used in cases where a participant needs to
5084    /// provide constraints, but after buffers are allocated, the participant
5085    /// can fail without causing buffer collection failure from the parent's
5086    /// point of view.
5087    ///
5088    /// In contrast, AttachToken() can be used to create a token which does not
5089    /// participate in constraints aggregation with its parent, and whose
5090    /// failure at any time does not propagate to its parent, and whose delay
5091    /// providing constraints does not prevent the parent from completing its
5092    /// buffer allocation.
5093    ///
5094    /// An initiator may in some scenarios choose to initially use a dispensable
5095    /// token for a given instance of a participant, and then later if the first
5096    /// instance of that participant fails, a new second instance of that
5097    /// participant my be given a token created with AttachToken().
5098    ///
5099    /// If a client uses this message, the client should not rely on the
5100    /// client's own BufferCollectionToken or BufferCollection channel to close
5101    /// from the server end due to abrupt failure of any BufferCollectionToken
5102    /// or BufferCollection that the client has SetDispensable() and given out
5103    /// to another process.  For this reason, the client should take extra care
5104    /// to notice failure of that other process via other means.
5105    ///
5106    /// While it is possible (and potentially useful) to SetDispensable() on a
5107    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
5108    /// replace a failed dispensable token that was a direct child of a group
5109    /// with a new token using AttachToken() (since there's no AttachToken() on
5110    /// a group).  Instead, to enable AttachToken() replacement in this case,
5111    /// create an additional non-dispensable token (node) that's a direct child
5112    /// of the group and make the existing dispensable token a child of the
5113    /// additional token (node).  This way, the additional token (node) that is
5114    /// a direct child of the group has BufferCollection.AttachToken() which can
5115    /// be used to replace the failed dispensable token.
5116    ///
5117    /// SetDispensable() on an already-dispensable token is idempotent.
5118    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5119        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5120    }
5121
5122    /// Most sysmem clients and many participants don't need to care about this
5123    /// message or about BufferCollectionTokenGroup(s) in general.
5124    ///
5125    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
5126    /// tokens.  The child tokens which are not selected during aggregation will
5127    /// fail (close), which a potential participant should notice when their
5128    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
5129    /// participant to clean up the speculative usage that didn't end up
5130    /// happening (similarly to a normal BufferCollection server end closing
5131    /// on failure of a logical buffer collection).
5132    ///
5133    /// See comments on protocol BufferCollectionTokenGroup.
5134    ///
5135    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
5136    /// applied to the whole group can be achieved with a token for this purpose
5137    /// as a direct parent of the group.
5138    ///
5139    /// group_request - the server end of a BufferCollectionTokenGroup channel
5140    /// to be served by sysmem.
5141    pub fn r#create_buffer_collection_token_group(
5142        &self,
5143        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5144    ) -> Result<(), fidl::Error> {
5145        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(
5146            self,
5147            group_request,
5148        )
5149    }
5150}
5151
5152impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5153    type SyncResponseFut =
5154        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5155    fn r#sync(&self) -> Self::SyncResponseFut {
5156        fn _decode(
5157            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5158        ) -> Result<(), fidl::Error> {
5159            let _response = fidl::client::decode_transaction_body::<
5160                fidl::encoding::EmptyPayload,
5161                fidl::encoding::DefaultFuchsiaResourceDialect,
5162                0x4577e238ae26291,
5163            >(_buf?)?;
5164            Ok(_response)
5165        }
5166        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5167            (),
5168            0x4577e238ae26291,
5169            fidl::encoding::DynamicFlags::empty(),
5170            _decode,
5171        )
5172    }
5173
5174    fn r#close(&self) -> Result<(), fidl::Error> {
5175        self.client.send::<fidl::encoding::EmptyPayload>(
5176            (),
5177            0x5b1d7a4f5681fca7,
5178            fidl::encoding::DynamicFlags::empty(),
5179        )
5180    }
5181
5182    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5183        self.client.send::<NodeSetNameRequest>(
5184            (priority, name),
5185            0x77a41bb6217e2443,
5186            fidl::encoding::DynamicFlags::empty(),
5187        )
5188    }
5189
5190    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5191        self.client.send::<NodeSetDebugClientInfoRequest>(
5192            (name, id),
5193            0x7275759070eb5ee2,
5194            fidl::encoding::DynamicFlags::empty(),
5195        )
5196    }
5197
5198    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5199        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5200            (deadline,),
5201            0x46d38f4772638867,
5202            fidl::encoding::DynamicFlags::empty(),
5203        )
5204    }
5205
5206    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5207        self.client.send::<fidl::encoding::EmptyPayload>(
5208            (),
5209            0x6bfbe2cf1701d288,
5210            fidl::encoding::DynamicFlags::empty(),
5211        )
5212    }
5213
5214    type GetNodeRefResponseFut =
5215        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
5216    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5217        fn _decode(
5218            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5219        ) -> Result<fidl::Event, fidl::Error> {
5220            let _response = fidl::client::decode_transaction_body::<
5221                NodeGetNodeRefResponse,
5222                fidl::encoding::DefaultFuchsiaResourceDialect,
5223                0x467b7c75c35c3b84,
5224            >(_buf?)?;
5225            Ok(_response.node_ref)
5226        }
5227        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
5228            (),
5229            0x467b7c75c35c3b84,
5230            fidl::encoding::DynamicFlags::empty(),
5231            _decode,
5232        )
5233    }
5234
5235    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5236        NodeIsAlternateForResult,
5237        fidl::encoding::DefaultFuchsiaResourceDialect,
5238    >;
5239    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
5240        fn _decode(
5241            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5242        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5243            let _response = fidl::client::decode_transaction_body::<
5244                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
5245                fidl::encoding::DefaultFuchsiaResourceDialect,
5246                0x33a2a7aff2776c07,
5247            >(_buf?)?;
5248            Ok(_response.map(|x| x.is_alternate))
5249        }
5250        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5251            (node_ref,),
5252            0x33a2a7aff2776c07,
5253            fidl::encoding::DynamicFlags::empty(),
5254            _decode,
5255        )
5256    }
5257
5258    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5259        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5260        fidl::encoding::DefaultFuchsiaResourceDialect,
5261    >;
5262    fn r#duplicate_sync(
5263        &self,
5264        mut rights_attenuation_masks: &[fidl::Rights],
5265    ) -> Self::DuplicateSyncResponseFut {
5266        fn _decode(
5267            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5268        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
5269        {
5270            let _response = fidl::client::decode_transaction_body::<
5271                BufferCollectionTokenDuplicateSyncResponse,
5272                fidl::encoding::DefaultFuchsiaResourceDialect,
5273                0x49ed7ab7cc19f18,
5274            >(_buf?)?;
5275            Ok(_response.tokens)
5276        }
5277        self.client.send_query_and_decode::<
5278            BufferCollectionTokenDuplicateSyncRequest,
5279            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
5280        >(
5281            (rights_attenuation_masks,),
5282            0x49ed7ab7cc19f18,
5283            fidl::encoding::DynamicFlags::empty(),
5284            _decode,
5285        )
5286    }
5287
5288    fn r#duplicate(
5289        &self,
5290        mut rights_attenuation_mask: u32,
5291        mut token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5292    ) -> Result<(), fidl::Error> {
5293        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5294            (rights_attenuation_mask, token_request),
5295            0x2f9f81bdde4b7292,
5296            fidl::encoding::DynamicFlags::empty(),
5297        )
5298    }
5299
5300    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5301        self.client.send::<fidl::encoding::EmptyPayload>(
5302            (),
5303            0x76e4ec34fc2cf5b3,
5304            fidl::encoding::DynamicFlags::empty(),
5305        )
5306    }
5307
5308    fn r#create_buffer_collection_token_group(
5309        &self,
5310        mut group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
5311    ) -> Result<(), fidl::Error> {
5312        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5313            (group_request,),
5314            0x2f6243e05f22b9a7,
5315            fidl::encoding::DynamicFlags::empty(),
5316        )
5317    }
5318}
5319
5320pub struct BufferCollectionTokenEventStream {
5321    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5322}
5323
5324impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5325
5326impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5327    fn is_terminated(&self) -> bool {
5328        self.event_receiver.is_terminated()
5329    }
5330}
5331
5332impl futures::Stream for BufferCollectionTokenEventStream {
5333    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5334
5335    fn poll_next(
5336        mut self: std::pin::Pin<&mut Self>,
5337        cx: &mut std::task::Context<'_>,
5338    ) -> std::task::Poll<Option<Self::Item>> {
5339        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5340            &mut self.event_receiver,
5341            cx
5342        )?) {
5343            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5344            None => std::task::Poll::Ready(None),
5345        }
5346    }
5347}
5348
5349#[derive(Debug)]
5350pub enum BufferCollectionTokenEvent {}
5351
5352impl BufferCollectionTokenEvent {
5353    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5354    fn decode(
5355        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5356    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5357        let (bytes, _handles) = buf.split_mut();
5358        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5359        debug_assert_eq!(tx_header.tx_id, 0);
5360        match tx_header.ordinal {
5361            _ => Err(fidl::Error::UnknownOrdinal {
5362                ordinal: tx_header.ordinal,
5363                protocol_name:
5364                    <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5365            }),
5366        }
5367    }
5368}
5369
5370/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionToken.
5371pub struct BufferCollectionTokenRequestStream {
5372    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5373    is_terminated: bool,
5374}
5375
5376impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5377
5378impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5379    fn is_terminated(&self) -> bool {
5380        self.is_terminated
5381    }
5382}
5383
5384impl fidl::endpoints::RequestStream for BufferCollectionTokenRequestStream {
5385    type Protocol = BufferCollectionTokenMarker;
5386    type ControlHandle = BufferCollectionTokenControlHandle;
5387
5388    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5389        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5390    }
5391
5392    fn control_handle(&self) -> Self::ControlHandle {
5393        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5394    }
5395
5396    fn into_inner(
5397        self,
5398    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5399    {
5400        (self.inner, self.is_terminated)
5401    }
5402
5403    fn from_inner(
5404        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5405        is_terminated: bool,
5406    ) -> Self {
5407        Self { inner, is_terminated }
5408    }
5409}
5410
5411impl futures::Stream for BufferCollectionTokenRequestStream {
5412    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5413
5414    fn poll_next(
5415        mut self: std::pin::Pin<&mut Self>,
5416        cx: &mut std::task::Context<'_>,
5417    ) -> std::task::Poll<Option<Self::Item>> {
5418        let this = &mut *self;
5419        if this.inner.check_shutdown(cx) {
5420            this.is_terminated = true;
5421            return std::task::Poll::Ready(None);
5422        }
5423        if this.is_terminated {
5424            panic!("polled BufferCollectionTokenRequestStream after completion");
5425        }
5426        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5427            |bytes, handles| {
5428                match this.inner.channel().read_etc(cx, bytes, handles) {
5429                    std::task::Poll::Ready(Ok(())) => {}
5430                    std::task::Poll::Pending => return std::task::Poll::Pending,
5431                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5432                        this.is_terminated = true;
5433                        return std::task::Poll::Ready(None);
5434                    }
5435                    std::task::Poll::Ready(Err(e)) => {
5436                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5437                            e.into(),
5438                        ))));
5439                    }
5440                }
5441
5442                // A message has been received from the channel
5443                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5444
5445                std::task::Poll::Ready(Some(match header.ordinal {
5446                0x4577e238ae26291 => {
5447                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5448                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5449                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5450                    let control_handle = BufferCollectionTokenControlHandle {
5451                        inner: this.inner.clone(),
5452                    };
5453                    Ok(BufferCollectionTokenRequest::Sync {
5454                        responder: BufferCollectionTokenSyncResponder {
5455                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5456                            tx_id: header.tx_id,
5457                        },
5458                    })
5459                }
5460                0x5b1d7a4f5681fca7 => {
5461                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5462                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5463                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5464                    let control_handle = BufferCollectionTokenControlHandle {
5465                        inner: this.inner.clone(),
5466                    };
5467                    Ok(BufferCollectionTokenRequest::Close {
5468                        control_handle,
5469                    })
5470                }
5471                0x77a41bb6217e2443 => {
5472                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5473                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5474                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5475                    let control_handle = BufferCollectionTokenControlHandle {
5476                        inner: this.inner.clone(),
5477                    };
5478                    Ok(BufferCollectionTokenRequest::SetName {priority: req.priority,
5479name: req.name,
5480
5481                        control_handle,
5482                    })
5483                }
5484                0x7275759070eb5ee2 => {
5485                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5486                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5487                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5488                    let control_handle = BufferCollectionTokenControlHandle {
5489                        inner: this.inner.clone(),
5490                    };
5491                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {name: req.name,
5492id: req.id,
5493
5494                        control_handle,
5495                    })
5496                }
5497                0x46d38f4772638867 => {
5498                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5499                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5500                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5501                    let control_handle = BufferCollectionTokenControlHandle {
5502                        inner: this.inner.clone(),
5503                    };
5504                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
5505
5506                        control_handle,
5507                    })
5508                }
5509                0x6bfbe2cf1701d288 => {
5510                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5511                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5512                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5513                    let control_handle = BufferCollectionTokenControlHandle {
5514                        inner: this.inner.clone(),
5515                    };
5516                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5517                        control_handle,
5518                    })
5519                }
5520                0x467b7c75c35c3b84 => {
5521                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5522                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5523                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5524                    let control_handle = BufferCollectionTokenControlHandle {
5525                        inner: this.inner.clone(),
5526                    };
5527                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5528                        responder: BufferCollectionTokenGetNodeRefResponder {
5529                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5530                            tx_id: header.tx_id,
5531                        },
5532                    })
5533                }
5534                0x33a2a7aff2776c07 => {
5535                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5536                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5537                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5538                    let control_handle = BufferCollectionTokenControlHandle {
5539                        inner: this.inner.clone(),
5540                    };
5541                    Ok(BufferCollectionTokenRequest::IsAlternateFor {node_ref: req.node_ref,
5542
5543                        responder: BufferCollectionTokenIsAlternateForResponder {
5544                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5545                            tx_id: header.tx_id,
5546                        },
5547                    })
5548                }
5549                0x49ed7ab7cc19f18 => {
5550                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5551                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5552                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5553                    let control_handle = BufferCollectionTokenControlHandle {
5554                        inner: this.inner.clone(),
5555                    };
5556                    Ok(BufferCollectionTokenRequest::DuplicateSync {rights_attenuation_masks: req.rights_attenuation_masks,
5557
5558                        responder: BufferCollectionTokenDuplicateSyncResponder {
5559                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5560                            tx_id: header.tx_id,
5561                        },
5562                    })
5563                }
5564                0x2f9f81bdde4b7292 => {
5565                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5566                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5567                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5568                    let control_handle = BufferCollectionTokenControlHandle {
5569                        inner: this.inner.clone(),
5570                    };
5571                    Ok(BufferCollectionTokenRequest::Duplicate {rights_attenuation_mask: req.rights_attenuation_mask,
5572token_request: req.token_request,
5573
5574                        control_handle,
5575                    })
5576                }
5577                0x76e4ec34fc2cf5b3 => {
5578                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5579                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5580                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5581                    let control_handle = BufferCollectionTokenControlHandle {
5582                        inner: this.inner.clone(),
5583                    };
5584                    Ok(BufferCollectionTokenRequest::SetDispensable {
5585                        control_handle,
5586                    })
5587                }
5588                0x2f6243e05f22b9a7 => {
5589                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5590                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5591                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5592                    let control_handle = BufferCollectionTokenControlHandle {
5593                        inner: this.inner.clone(),
5594                    };
5595                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {group_request: req.group_request,
5596
5597                        control_handle,
5598                    })
5599                }
5600                _ => Err(fidl::Error::UnknownOrdinal {
5601                    ordinal: header.ordinal,
5602                    protocol_name: <BufferCollectionTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5603                }),
5604            }))
5605            },
5606        )
5607    }
5608}
5609
5610/// A BufferCollectionToken is not a BufferCollection, but rather a way to
5611/// identify a potential shared BufferCollection prior to the BufferCollection
5612/// being allocated.
5613///
5614/// We use a channel for the BufferCollectionToken instead of a single eventpair
5615/// (pair) because this way we can detect error conditions like a participant
5616/// dying mid-create.
5617///
5618/// The fuchsia.sysmem.BufferCollectionToken type is not yet deprecated due to
5619/// its use in some other protocols (for now), but all the internals of
5620/// fuchsia.sysmem.BufferCollectionToken are deprecated. Token channels serve
5621/// both fuchsia.sysmem.BufferCollectionToken and
5622/// fuchsia.sysmem2.BufferCollectionToken.
5623///
5624/// This protocol will be deprecated once other protocols have switched their
5625/// token fields to fuchsia.sysmem2.BufferCollectionToken.
5626#[derive(Debug)]
5627pub enum BufferCollectionTokenRequest {
5628    /// Ensure that previous messages, including Duplicate() messages on a
5629    /// token, collection, or group, have been received server side.
5630    ///
5631    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5632    /// valid sysmem token risks the Sync() hanging forever.  See
5633    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5634    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5635    /// Another way is to pass the token to BindSharedCollection(), which also
5636    /// validates the token as part of exchanging it for a BufferCollection
5637    /// channel, and BufferCollection Sync() can then be used.
5638    ///
5639    /// After a Sync(), it's then safe to send the client end of token_request
5640    /// to another participant knowing the server will recognize the token when
5641    /// it's sent into BindSharedCollection() by the other participant.
5642    ///
5643    /// Other options include waiting for each token.Duplicate() to complete
5644    /// individually (using separate call to token.Sync() after each), or
5645    /// calling Sync() on BufferCollection after the token has been turned in
5646    /// via BindSharedCollection().
5647    ///
5648    /// Another way to mitigate is to avoid calling Sync() on the token, and
5649    /// instead later deal with potential failure of BufferCollection.Sync() if
5650    /// the original token was invalid.  This option can be preferable from a
5651    /// performance point of view, but requires client code to delay sending
5652    /// tokens duplicated from this token until after client code has converted
5653    /// the duplicating token to a BufferCollection and received successful
5654    /// response from BufferCollection.Sync().
5655    ///
5656    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5657    /// When BufferCollection.Sync() isn't feasible, the caller must already
5658    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5659    /// hang forever.  See ValidateBufferCollectionToken() to check token
5660    /// validity first if the token isn't already known to be (is/was) valid.
5661    Sync { responder: BufferCollectionTokenSyncResponder },
5662    /// On a BufferCollectionToken channel:
5663    ///
5664    /// Normally a participant will convert a BufferCollectionToken into a
5665    /// BufferCollection view, but a participant is also free to Close() the
5666    /// token (and then close the channel immediately or shortly later in
5667    /// response to server closing its end), which avoids causing logical buffer
5668    /// collection failure.  Normally an unexpected token channel close will
5669    /// cause logical buffer collection failure (the only exceptions being
5670    /// certain cases involving AttachToken() or SetDispensable()).
5671    ///
5672    /// On a BufferCollection channel:
5673    ///
5674    /// By default the server handles unexpected failure of a BufferCollection
5675    /// by failing the whole logical buffer collection.  Partly this is to
5676    /// expedite closing VMO handles to reclaim memory when any participant
5677    /// fails.  If a participant would like to cleanly close a BufferCollection
5678    /// view without causing logical buffer collection failure, the participant
5679    /// can send Close() before closing the client end of the BufferCollection
5680    /// channel.  If this is the last BufferCollection view, the logical buffer
5681    /// collection will still go away.  The Close() can occur before or after
5682    /// SetConstraints().  If before SetConstraints(), the buffer collection
5683    /// won't require constraints from this node in order to allocate.  If
5684    /// after SetConstraints(), the constraints are retained and aggregated
5685    /// along with any subsequent logical allocation(s), despite the lack of
5686    /// channel connection.
5687    ///
5688    /// On a BufferCollectionTokenGroup channel:
5689    ///
5690    /// By default, unexpected failure of a BufferCollectionTokenGroup will
5691    /// trigger failure of the logical BufferCollectionTokenGroup and will
5692    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
5693    /// channel without failing the logical group or propagating failure, send
5694    /// Close() before closing the channel client endpoint.
5695    ///
5696    /// If Close() occurs before AllChildrenPresent(), the logical buffer
5697    /// collection will still fail despite the Close() (because sysmem can't be
5698    /// sure whether all relevant children were created, so it's ambiguous
5699    /// whether all relevant constraints will be provided to sysmem).  If
5700    /// Close() occurs after AllChildrenPresent(), the children and all their
5701    /// constraints remain intact (just as they would if the
5702    /// BufferCollectionTokenGroup channel had remained open), and the close
5703    /// doesn't trigger or propagate failure.
5704    Close { control_handle: BufferCollectionTokenControlHandle },
5705    /// Set a name for VMOs in this buffer collection. The name may be truncated
5706    /// shorter. The name only affects VMOs allocated after it's set - this call
5707    /// does not rename existing VMOs. If multiple clients set different names
5708    /// then the larger priority value will win.
5709    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenControlHandle },
5710    /// Set information about the current client that can be used by sysmem to
5711    /// help debug leaking memory and hangs waiting for constraints. |name| can
5712    /// be an arbitrary string, but the current process name (see
5713    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5714    /// arbitrary id, but the current process ID (see
5715    /// fsl::GetCurrentProcessKoid()) is a good default.
5716    ///
5717    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5718    /// indicate which client is closing their channel first, leading to
5719    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5720    /// over, but if happening earlier than expected, the
5721    /// client-channel-specific name can help diagnose where the failure is
5722    /// first coming from, from sysmem's point of view).
5723    ///
5724    /// By default (unless overriden by this message or using
5725    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5726    /// parent Node at the time the child Node is created.  While this can be
5727    /// better than nothing, it's often better for each participant to use
5728    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5729    /// info directly relevant to the current client.  Also, SetVerboseLogging()
5730    /// can be used to help disambiguate if a Node is suspected of having info
5731    /// that was copied from its parent.
5732    SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionTokenControlHandle },
5733    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5734    /// after creating a collection. Clients can call this method to change
5735    /// when the log is printed. If multiple client set the deadline, it's
5736    /// unspecified which deadline will take effect.
5737    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionTokenControlHandle },
5738    /// Verbose logging includes constraints set via SetConstraints() from each
5739    /// client along with info set via SetDebugClientInfo() and the structure of
5740    /// the tree of Node(s).
5741    ///
5742    /// Normally sysmem prints only a single line complaint when aggregation
5743    /// fails, with just the specific detailed reason that aggregation failed,
5744    /// with minimal context.  While this is often enough to diagnose a problem
5745    /// if only a small change was made and the system had been working before
5746    /// the small change, it's often not particularly helpful for getting a new
5747    /// buffer collection to work for the first time.  Especially with more
5748    /// complex trees of nodes, involving things like AttachToken(),
5749    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5750    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5751    /// looks like and why it's failing a logical allocation, or why a tree or
5752    /// sub-tree is failing sooner than expected.
5753    ///
5754    /// The intent of the extra logging is to be acceptable from a performance
5755    /// point of view, if only enabled on a low number of buffer collections.
5756    /// If we're not tracking down a bug, we shouldn't send this message.
5757    ///
5758    /// If too many participants leave verbose logging enabled, we may end up
5759    /// needing to require that system-wide sysmem verbose logging be permitted
5760    /// via some other setting, to avoid sysmem spamming the log too much due to
5761    /// this message.
5762    ///
5763    /// This may be a NOP for some nodes due to intentional policy associated
5764    /// with the node, if we don't trust a node enough to let it turn on verbose
5765    /// logging.
5766    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
5767    /// This gets an event handle that can be used as a parameter to
5768    /// IsAlternateFor() called on any Node.  The client will not be granted the
5769    /// right to signal this event, as this handle should only be used as proof
5770    /// that the client obtained this handle from this Node.
5771    ///
5772    /// Because this is a get not a set, no Sync() is needed between the
5773    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5774    /// potentially being on different channels.
5775    ///
5776    /// See also IsAlternateFor().
5777    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
5778    /// This checks whether the calling node is in a subtree rooted at a
5779    /// different child token of a common parent BufferCollectionTokenGroup, in
5780    /// relation to the passed-in node_ref.
5781    ///
5782    /// This call is for assisting with admission control de-duplication, and
5783    /// with debugging.
5784    ///
5785    /// The node_ref must be obtained using GetNodeRef() of a
5786    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
5787    ///
5788    /// The node_ref can be a duplicated handle; it's not necessary to call
5789    /// GetNodeRef() for every call to IsAlternateFor().
5790    ///
5791    /// If a calling token may not actually be a valid token at all due to
5792    /// a potentially hostile/untrusted provider of the token, call
5793    /// ValidateBufferCollectionToken() first instead of potentially getting
5794    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
5795    /// token not being a real token (not really talking to sysmem).  Another
5796    /// option is to call BindSharedCollection with this token first which also
5797    /// validates the token along with converting it to a BufferCollection, then
5798    /// call BufferCollection IsAlternateFor().
5799    ///
5800    /// error values:
5801    ///
5802    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
5803    /// buffer collection as the calling Node.  Before logical allocation and
5804    /// within the same logical allocation sub-tree, this essentially means that
5805    /// the node_ref was never part of this logical buffer collection, since
5806    /// before logical allocation all node_refs that come into existence remain
5807    /// in existence at least until logical allocation (including Node(s) that
5808    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
5809    /// to be returned, this Node's channel needs to still be connected server
5810    /// side, which won't be the case if the whole logical allocation has
5811    /// failed.  After logical allocation or in a different logical allocation
5812    /// sub-tree there are additional potential reasons for this error.  For
5813    /// example a different logical allocation (separated from this Node(s)
5814    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
5815    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
5816    /// exist and may select a different child sub-tree than the sub-tree the
5817    /// node_ref is in causing deletion of the node_ref Node.  The only time
5818    /// sysmem keeps a Node around after that Node has no corresponding channel
5819    /// is when Close() is used and the Node's sub-tree has not yet failed.
5820    /// Another reason for this error is if the node_ref is an eventpair handle
5821    /// with sufficient rights, but isn't actually a real node_ref obtained from
5822    /// GetNodeRef().
5823    ///
5824    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
5825    /// eventpair handle, or doesn't have the needed rights expected on a real
5826    /// node_ref.
5827    ///
5828    /// No other failing status codes are returned by this call.  However,
5829    /// sysmem may add additional codes in future, so the client should have
5830    /// sensible default handling for any failing status code.
5831    ///
5832    /// On success, is_alternate has the following meaning:
5833    ///   * true - The first parent node in common between the calling node and
5834    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
5835    ///     the calling Node and the node_ref Node will _not_ have both their
5836    ///     constraints apply - rather sysmem will choose one or the other of
5837    ///     the constraints - never both.  This is because only one child of
5838    ///     a BufferCollectionTokenGroup is selected during logical allocation,
5839    ///     with only that one child's sub-tree contributing to constraints
5840    ///     aggregation.
5841    ///   * false - The first parent node in common between the calling Node and
5842    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
5843    ///     this means the first parent node in common is a
5844    ///     BufferCollectionToken or BufferCollection (regardless of not
5845    ///     Close()ed or Close()ed).  This means that the calling Node and the
5846    ///     node_ref Node _may_ have both their constraints apply during
5847    ///     constraints aggregation of the logical allocation, if both Node(s)
5848    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
5849    ///     In this case, there is no BufferCollectionTokenGroup that will
5850    ///     directly prevent the two Node(s) from both being selected and their
5851    ///     constraints both aggregated, but even when false, one or both
5852    ///     Node(s) may still be eliminated from consideration if one or both
5853    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
5854    ///     which selects a child sub-tree other than the sub-tree containing
5855    ///     the calling Node or node_ref Node.
5856    IsAlternateFor {
5857        node_ref: fidl::Event,
5858        responder: BufferCollectionTokenIsAlternateForResponder,
5859    },
5860    /// This method can be used to add more participants prior to creating a
5861    /// shared BufferCollection. A new token will be returned for each entry in
5862    /// the `rights_attenuation_masks` array. The return value is the client
5863    /// ends of each new participant token.
5864    ///
5865    /// If the calling token may not actually be a valid token at all due to
5866    /// a potentially hostile/untrusted provider of the token, consider using
5867    /// ValidateBufferCollectionToken() first instead of potentially getting
5868    /// stuck indefinitely if DuplicateSync() never responds due to the calling
5869    /// token not being a real token.
5870    ///
5871    /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
5872    /// after calling this method.
5873    ///
5874    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5875    /// BufferCollection to be successfully created.
5876    ///
5877    /// In each entry of `rights_attenuation_masks`, rights bits that are zero
5878    /// will be absent in the buffer VMO rights obtainable via the corresponding
5879    /// returned token. This allows an initiator or intermediary participant to
5880    /// attenuate the rights available to a participant. This does not allow a
5881    /// participant to gain rights that the participant doesn't already have.
5882    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5883    /// attenuation should be applied.
5884    DuplicateSync {
5885        rights_attenuation_masks: Vec<fidl::Rights>,
5886        responder: BufferCollectionTokenDuplicateSyncResponder,
5887    },
5888    /// This method can be used to add a participant prior to creating a shared
5889    /// BufferCollection. It should only be used instead of DuplicateSync in
5890    /// performance sensitive cases where it would be undesireable to wait for
5891    /// sysmem to respond as part of each duplicate.
5892    ///
5893    /// After sending one or more Duplicate() messages, and before sending the
5894    /// created tokens to other participants (or to other Allocator channels),
5895    /// the client should send a Sync() and wait for its response.  The Sync()
5896    /// call can be made on the token, or on the BufferCollection obtained by
5897    /// passing this token to BindSharedCollection().  Either will ensure that
5898    /// the server knows about the tokens created via Duplicate() before the
5899    /// other participant sends the token to the server via separate Allocator
5900    /// channel.
5901    ///
5902    /// All tokens must be turned in via BindSharedCollection() or Close() for a
5903    /// BufferCollection to be successfully created.
5904    ///
5905    /// When a client calls BindSharedCollection() to turn in a
5906    /// BufferCollectionToken, the server will process all Duplicate() messages
5907    /// before closing down the BufferCollectionToken.  This allows the client
5908    /// to Duplicate() and immediately turn in the BufferCollectionToken using
5909    /// BindSharedCollection, then later transfer the client end of token_request
5910    /// to another participant - the server will notice the existence of the
5911    /// token_request before considering this BufferCollectionToken fully closed.
5912    ///
5913    /// `rights_attenuation_mask` rights bits that are zero in this mask will be
5914    /// absent in the buffer VMO rights obtainable via the client end of
5915    /// token_request. This allows an initiator or intermediary participant to
5916    /// attenuate the rights available to a participant. This does not allow a
5917    /// participant to gain rights that the participant doesn't already have.
5918    /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
5919    /// attenuation should be applied.
5920    ///
5921    /// These values for rights_attenuation_mask result in no attenuation:
5922    ///   * ZX_RIGHT_SAME_RIGHTS (preferred)
5923    ///   * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
5924    ///   * 0 (deprecated - do not use 0 - an ERROR will go to the log)
5925    ///
5926    /// `token_request` is the server end of a BufferCollectionToken channel.
5927    /// The client end of this channel acts as another participant in creating the
5928    /// shared BufferCollection.
5929    Duplicate {
5930        rights_attenuation_mask: u32,
5931        token_request: fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
5932        control_handle: BufferCollectionTokenControlHandle,
5933    },
5934    /// A dispensable token can fail after buffers are logically allocated
5935    /// without causing failure of its parent (if any).
5936    ///
5937    /// The dispensable token participates in constraints aggregation along with
5938    /// its parent before logical buffer allocation.  If the dispensable token
5939    /// fails before buffers are logically allocated, the failure propagates to
5940    /// the dispensable token's parent.
5941    ///
5942    /// After buffers are logically allocated, failure of the dispensable token
5943    /// (or any child of the dispensable token) does not propagate to the
5944    /// dispensable token's parent.  Failure does propagate from a normal
5945    /// child of a dispensable token to the dispensable token.  Failure
5946    /// of a child is blocked from reaching its parent if the child is attached,
5947    /// or if the child is dispensable and the failure occurred after logical
5948    /// allocation.
5949    ///
5950    /// A dispensable token can be used in cases where a participant needs to
5951    /// provide constraints, but after buffers are allocated, the participant
5952    /// can fail without causing buffer collection failure from the parent's
5953    /// point of view.
5954    ///
5955    /// In contrast, AttachToken() can be used to create a token which does not
5956    /// participate in constraints aggregation with its parent, and whose
5957    /// failure at any time does not propagate to its parent, and whose delay
5958    /// providing constraints does not prevent the parent from completing its
5959    /// buffer allocation.
5960    ///
5961    /// An initiator may in some scenarios choose to initially use a dispensable
5962    /// token for a given instance of a participant, and then later if the first
5963    /// instance of that participant fails, a new second instance of that
5964    /// participant my be given a token created with AttachToken().
5965    ///
5966    /// If a client uses this message, the client should not rely on the
5967    /// client's own BufferCollectionToken or BufferCollection channel to close
5968    /// from the server end due to abrupt failure of any BufferCollectionToken
5969    /// or BufferCollection that the client has SetDispensable() and given out
5970    /// to another process.  For this reason, the client should take extra care
5971    /// to notice failure of that other process via other means.
5972    ///
5973    /// While it is possible (and potentially useful) to SetDispensable() on a
5974    /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
5975    /// replace a failed dispensable token that was a direct child of a group
5976    /// with a new token using AttachToken() (since there's no AttachToken() on
5977    /// a group).  Instead, to enable AttachToken() replacement in this case,
5978    /// create an additional non-dispensable token (node) that's a direct child
5979    /// of the group and make the existing dispensable token a child of the
5980    /// additional token (node).  This way, the additional token (node) that is
5981    /// a direct child of the group has BufferCollection.AttachToken() which can
5982    /// be used to replace the failed dispensable token.
5983    ///
5984    /// SetDispensable() on an already-dispensable token is idempotent.
5985    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
5986    /// Most sysmem clients and many participants don't need to care about this
5987    /// message or about BufferCollectionTokenGroup(s) in general.
5988    ///
5989    /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
5990    /// tokens.  The child tokens which are not selected during aggregation will
5991    /// fail (close), which a potential participant should notice when their
5992    /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
5993    /// participant to clean up the speculative usage that didn't end up
5994    /// happening (similarly to a normal BufferCollection server end closing
5995    /// on failure of a logical buffer collection).
5996    ///
5997    /// See comments on protocol BufferCollectionTokenGroup.
5998    ///
5999    /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
6000    /// applied to the whole group can be achieved with a token for this purpose
6001    /// as a direct parent of the group.
6002    ///
6003    /// group_request - the server end of a BufferCollectionTokenGroup channel
6004    /// to be served by sysmem.
6005    CreateBufferCollectionTokenGroup {
6006        group_request: fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6007        control_handle: BufferCollectionTokenControlHandle,
6008    },
6009}
6010
6011impl BufferCollectionTokenRequest {
6012    #[allow(irrefutable_let_patterns)]
6013    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6014        if let BufferCollectionTokenRequest::Sync { responder } = self {
6015            Some((responder))
6016        } else {
6017            None
6018        }
6019    }
6020
6021    #[allow(irrefutable_let_patterns)]
6022    pub fn into_close(self) -> Option<(BufferCollectionTokenControlHandle)> {
6023        if let BufferCollectionTokenRequest::Close { control_handle } = self {
6024            Some((control_handle))
6025        } else {
6026            None
6027        }
6028    }
6029
6030    #[allow(irrefutable_let_patterns)]
6031    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenControlHandle)> {
6032        if let BufferCollectionTokenRequest::SetName { priority, name, control_handle } = self {
6033            Some((priority, name, control_handle))
6034        } else {
6035            None
6036        }
6037    }
6038
6039    #[allow(irrefutable_let_patterns)]
6040    pub fn into_set_debug_client_info(
6041        self,
6042    ) -> Option<(String, u64, BufferCollectionTokenControlHandle)> {
6043        if let BufferCollectionTokenRequest::SetDebugClientInfo { name, id, control_handle } = self
6044        {
6045            Some((name, id, control_handle))
6046        } else {
6047            None
6048        }
6049    }
6050
6051    #[allow(irrefutable_let_patterns)]
6052    pub fn into_set_debug_timeout_log_deadline(
6053        self,
6054    ) -> Option<(i64, BufferCollectionTokenControlHandle)> {
6055        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6056            deadline,
6057            control_handle,
6058        } = self
6059        {
6060            Some((deadline, control_handle))
6061        } else {
6062            None
6063        }
6064    }
6065
6066    #[allow(irrefutable_let_patterns)]
6067    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6068        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6069            Some((control_handle))
6070        } else {
6071            None
6072        }
6073    }
6074
6075    #[allow(irrefutable_let_patterns)]
6076    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6077        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6078            Some((responder))
6079        } else {
6080            None
6081        }
6082    }
6083
6084    #[allow(irrefutable_let_patterns)]
6085    pub fn into_is_alternate_for(
6086        self,
6087    ) -> Option<(fidl::Event, BufferCollectionTokenIsAlternateForResponder)> {
6088        if let BufferCollectionTokenRequest::IsAlternateFor { node_ref, responder } = self {
6089            Some((node_ref, responder))
6090        } else {
6091            None
6092        }
6093    }
6094
6095    #[allow(irrefutable_let_patterns)]
6096    pub fn into_duplicate_sync(
6097        self,
6098    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenDuplicateSyncResponder)> {
6099        if let BufferCollectionTokenRequest::DuplicateSync { rights_attenuation_masks, responder } =
6100            self
6101        {
6102            Some((rights_attenuation_masks, responder))
6103        } else {
6104            None
6105        }
6106    }
6107
6108    #[allow(irrefutable_let_patterns)]
6109    pub fn into_duplicate(
6110        self,
6111    ) -> Option<(
6112        u32,
6113        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
6114        BufferCollectionTokenControlHandle,
6115    )> {
6116        if let BufferCollectionTokenRequest::Duplicate {
6117            rights_attenuation_mask,
6118            token_request,
6119            control_handle,
6120        } = self
6121        {
6122            Some((rights_attenuation_mask, token_request, control_handle))
6123        } else {
6124            None
6125        }
6126    }
6127
6128    #[allow(irrefutable_let_patterns)]
6129    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6130        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6131            Some((control_handle))
6132        } else {
6133            None
6134        }
6135    }
6136
6137    #[allow(irrefutable_let_patterns)]
6138    pub fn into_create_buffer_collection_token_group(
6139        self,
6140    ) -> Option<(
6141        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
6142        BufferCollectionTokenControlHandle,
6143    )> {
6144        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6145            group_request,
6146            control_handle,
6147        } = self
6148        {
6149            Some((group_request, control_handle))
6150        } else {
6151            None
6152        }
6153    }
6154
6155    /// Name of the method defined in FIDL
6156    pub fn method_name(&self) -> &'static str {
6157        match *self {
6158            BufferCollectionTokenRequest::Sync { .. } => "sync",
6159            BufferCollectionTokenRequest::Close { .. } => "close",
6160            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6161            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6162            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6163                "set_debug_timeout_log_deadline"
6164            }
6165            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6166            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6167            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6168            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6169            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6170            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6171            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6172                "create_buffer_collection_token_group"
6173            }
6174        }
6175    }
6176}
6177
6178#[derive(Debug, Clone)]
6179pub struct BufferCollectionTokenControlHandle {
6180    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6181}
6182
6183impl fidl::endpoints::ControlHandle for BufferCollectionTokenControlHandle {
6184    fn shutdown(&self) {
6185        self.inner.shutdown()
6186    }
6187
6188    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6189        self.inner.shutdown_with_epitaph(status)
6190    }
6191
6192    fn is_closed(&self) -> bool {
6193        self.inner.channel().is_closed()
6194    }
6195    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6196        self.inner.channel().on_closed()
6197    }
6198
6199    #[cfg(target_os = "fuchsia")]
6200    fn signal_peer(
6201        &self,
6202        clear_mask: zx::Signals,
6203        set_mask: zx::Signals,
6204    ) -> Result<(), zx_status::Status> {
6205        use fidl::Peered;
6206        self.inner.channel().signal_peer(clear_mask, set_mask)
6207    }
6208}
6209
6210impl BufferCollectionTokenControlHandle {}
6211
6212#[must_use = "FIDL methods require a response to be sent"]
6213#[derive(Debug)]
6214pub struct BufferCollectionTokenSyncResponder {
6215    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6216    tx_id: u32,
6217}
6218
6219/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6220/// if the responder is dropped without sending a response, so that the client
6221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6222impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6223    fn drop(&mut self) {
6224        self.control_handle.shutdown();
6225        // Safety: drops once, never accessed again
6226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6227    }
6228}
6229
6230impl fidl::endpoints::Responder for BufferCollectionTokenSyncResponder {
6231    type ControlHandle = BufferCollectionTokenControlHandle;
6232
6233    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6234        &self.control_handle
6235    }
6236
6237    fn drop_without_shutdown(mut self) {
6238        // Safety: drops once, never accessed again due to mem::forget
6239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6240        // Prevent Drop from running (which would shut down the channel)
6241        std::mem::forget(self);
6242    }
6243}
6244
6245impl BufferCollectionTokenSyncResponder {
6246    /// Sends a response to the FIDL transaction.
6247    ///
6248    /// Sets the channel to shutdown if an error occurs.
6249    pub fn send(self) -> Result<(), fidl::Error> {
6250        let _result = self.send_raw();
6251        if _result.is_err() {
6252            self.control_handle.shutdown();
6253        }
6254        self.drop_without_shutdown();
6255        _result
6256    }
6257
6258    /// Similar to "send" but does not shutdown the channel if an error occurs.
6259    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6260        let _result = self.send_raw();
6261        self.drop_without_shutdown();
6262        _result
6263    }
6264
6265    fn send_raw(&self) -> Result<(), fidl::Error> {
6266        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6267            (),
6268            self.tx_id,
6269            0x4577e238ae26291,
6270            fidl::encoding::DynamicFlags::empty(),
6271        )
6272    }
6273}
6274
6275#[must_use = "FIDL methods require a response to be sent"]
6276#[derive(Debug)]
6277pub struct BufferCollectionTokenGetNodeRefResponder {
6278    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6279    tx_id: u32,
6280}
6281
6282/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6283/// if the responder is dropped without sending a response, so that the client
6284/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6285impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6286    fn drop(&mut self) {
6287        self.control_handle.shutdown();
6288        // Safety: drops once, never accessed again
6289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6290    }
6291}
6292
6293impl fidl::endpoints::Responder for BufferCollectionTokenGetNodeRefResponder {
6294    type ControlHandle = BufferCollectionTokenControlHandle;
6295
6296    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6297        &self.control_handle
6298    }
6299
6300    fn drop_without_shutdown(mut self) {
6301        // Safety: drops once, never accessed again due to mem::forget
6302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6303        // Prevent Drop from running (which would shut down the channel)
6304        std::mem::forget(self);
6305    }
6306}
6307
6308impl BufferCollectionTokenGetNodeRefResponder {
6309    /// Sends a response to the FIDL transaction.
6310    ///
6311    /// Sets the channel to shutdown if an error occurs.
6312    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6313        let _result = self.send_raw(node_ref);
6314        if _result.is_err() {
6315            self.control_handle.shutdown();
6316        }
6317        self.drop_without_shutdown();
6318        _result
6319    }
6320
6321    /// Similar to "send" but does not shutdown the channel if an error occurs.
6322    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6323        let _result = self.send_raw(node_ref);
6324        self.drop_without_shutdown();
6325        _result
6326    }
6327
6328    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
6329        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
6330            (node_ref,),
6331            self.tx_id,
6332            0x467b7c75c35c3b84,
6333            fidl::encoding::DynamicFlags::empty(),
6334        )
6335    }
6336}
6337
6338#[must_use = "FIDL methods require a response to be sent"]
6339#[derive(Debug)]
6340pub struct BufferCollectionTokenIsAlternateForResponder {
6341    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6342    tx_id: u32,
6343}
6344
6345/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6346/// if the responder is dropped without sending a response, so that the client
6347/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6348impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
6349    fn drop(&mut self) {
6350        self.control_handle.shutdown();
6351        // Safety: drops once, never accessed again
6352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6353    }
6354}
6355
6356impl fidl::endpoints::Responder for BufferCollectionTokenIsAlternateForResponder {
6357    type ControlHandle = BufferCollectionTokenControlHandle;
6358
6359    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6360        &self.control_handle
6361    }
6362
6363    fn drop_without_shutdown(mut self) {
6364        // Safety: drops once, never accessed again due to mem::forget
6365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6366        // Prevent Drop from running (which would shut down the channel)
6367        std::mem::forget(self);
6368    }
6369}
6370
6371impl BufferCollectionTokenIsAlternateForResponder {
6372    /// Sends a response to the FIDL transaction.
6373    ///
6374    /// Sets the channel to shutdown if an error occurs.
6375    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6376        let _result = self.send_raw(result);
6377        if _result.is_err() {
6378            self.control_handle.shutdown();
6379        }
6380        self.drop_without_shutdown();
6381        _result
6382    }
6383
6384    /// Similar to "send" but does not shutdown the channel if an error occurs.
6385    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6386        let _result = self.send_raw(result);
6387        self.drop_without_shutdown();
6388        _result
6389    }
6390
6391    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6392        self.control_handle
6393            .inner
6394            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
6395                result.map(|is_alternate| (is_alternate,)),
6396                self.tx_id,
6397                0x33a2a7aff2776c07,
6398                fidl::encoding::DynamicFlags::empty(),
6399            )
6400    }
6401}
6402
6403#[must_use = "FIDL methods require a response to be sent"]
6404#[derive(Debug)]
6405pub struct BufferCollectionTokenDuplicateSyncResponder {
6406    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6407    tx_id: u32,
6408}
6409
6410/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6411/// if the responder is dropped without sending a response, so that the client
6412/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6413impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
6414    fn drop(&mut self) {
6415        self.control_handle.shutdown();
6416        // Safety: drops once, never accessed again
6417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6418    }
6419}
6420
6421impl fidl::endpoints::Responder for BufferCollectionTokenDuplicateSyncResponder {
6422    type ControlHandle = BufferCollectionTokenControlHandle;
6423
6424    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6425        &self.control_handle
6426    }
6427
6428    fn drop_without_shutdown(mut self) {
6429        // Safety: drops once, never accessed again due to mem::forget
6430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6431        // Prevent Drop from running (which would shut down the channel)
6432        std::mem::forget(self);
6433    }
6434}
6435
6436impl BufferCollectionTokenDuplicateSyncResponder {
6437    /// Sends a response to the FIDL transaction.
6438    ///
6439    /// Sets the channel to shutdown if an error occurs.
6440    pub fn send(
6441        self,
6442        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6443    ) -> Result<(), fidl::Error> {
6444        let _result = self.send_raw(tokens);
6445        if _result.is_err() {
6446            self.control_handle.shutdown();
6447        }
6448        self.drop_without_shutdown();
6449        _result
6450    }
6451
6452    /// Similar to "send" but does not shutdown the channel if an error occurs.
6453    pub fn send_no_shutdown_on_err(
6454        self,
6455        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6456    ) -> Result<(), fidl::Error> {
6457        let _result = self.send_raw(tokens);
6458        self.drop_without_shutdown();
6459        _result
6460    }
6461
6462    fn send_raw(
6463        &self,
6464        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6465    ) -> Result<(), fidl::Error> {
6466        self.control_handle.inner.send::<BufferCollectionTokenDuplicateSyncResponse>(
6467            (tokens.as_mut(),),
6468            self.tx_id,
6469            0x49ed7ab7cc19f18,
6470            fidl::encoding::DynamicFlags::empty(),
6471        )
6472    }
6473}
6474
6475#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6476pub struct BufferCollectionTokenGroupMarker;
6477
6478impl fidl::endpoints::ProtocolMarker for BufferCollectionTokenGroupMarker {
6479    type Proxy = BufferCollectionTokenGroupProxy;
6480    type RequestStream = BufferCollectionTokenGroupRequestStream;
6481    #[cfg(target_os = "fuchsia")]
6482    type SynchronousProxy = BufferCollectionTokenGroupSynchronousProxy;
6483
6484    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
6485}
6486
6487pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
6488    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6489    fn r#sync(&self) -> Self::SyncResponseFut;
6490    fn r#close(&self) -> Result<(), fidl::Error>;
6491    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
6492    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
6493    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
6494    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
6495    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
6496        + Send;
6497    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
6498    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
6499        + Send;
6500    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
6501    fn r#create_child(
6502        &self,
6503        payload: BufferCollectionTokenGroupCreateChildRequest,
6504    ) -> Result<(), fidl::Error>;
6505    type CreateChildrenSyncResponseFut: std::future::Future<
6506            Output = Result<
6507                Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
6508                fidl::Error,
6509            >,
6510        > + Send;
6511    fn r#create_children_sync(
6512        &self,
6513        rights_attenuation_masks: &[fidl::Rights],
6514    ) -> Self::CreateChildrenSyncResponseFut;
6515    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
6516}
6517#[derive(Debug)]
6518#[cfg(target_os = "fuchsia")]
6519pub struct BufferCollectionTokenGroupSynchronousProxy {
6520    client: fidl::client::sync::Client,
6521}
6522
6523#[cfg(target_os = "fuchsia")]
6524impl fidl::endpoints::SynchronousProxy for BufferCollectionTokenGroupSynchronousProxy {
6525    type Proxy = BufferCollectionTokenGroupProxy;
6526    type Protocol = BufferCollectionTokenGroupMarker;
6527
6528    fn from_channel(inner: fidl::Channel) -> Self {
6529        Self::new(inner)
6530    }
6531
6532    fn into_channel(self) -> fidl::Channel {
6533        self.client.into_channel()
6534    }
6535
6536    fn as_channel(&self) -> &fidl::Channel {
6537        self.client.as_channel()
6538    }
6539}
6540
6541#[cfg(target_os = "fuchsia")]
6542impl BufferCollectionTokenGroupSynchronousProxy {
6543    pub fn new(channel: fidl::Channel) -> Self {
6544        Self { client: fidl::client::sync::Client::new(channel) }
6545    }
6546
6547    pub fn into_channel(self) -> fidl::Channel {
6548        self.client.into_channel()
6549    }
6550
6551    /// Waits until an event arrives and returns it. It is safe for other
6552    /// threads to make concurrent requests while waiting for an event.
6553    pub fn wait_for_event(
6554        &self,
6555        deadline: zx::MonotonicInstant,
6556    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
6557        BufferCollectionTokenGroupEvent::decode(
6558            self.client.wait_for_event::<BufferCollectionTokenGroupMarker>(deadline)?,
6559        )
6560    }
6561
6562    /// Ensure that previous messages, including Duplicate() messages on a
6563    /// token, collection, or group, have been received server side.
6564    ///
6565    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
6566    /// valid sysmem token risks the Sync() hanging forever.  See
6567    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
6568    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
6569    /// Another way is to pass the token to BindSharedCollection(), which also
6570    /// validates the token as part of exchanging it for a BufferCollection
6571    /// channel, and BufferCollection Sync() can then be used.
6572    ///
6573    /// After a Sync(), it's then safe to send the client end of token_request
6574    /// to another participant knowing the server will recognize the token when
6575    /// it's sent into BindSharedCollection() by the other participant.
6576    ///
6577    /// Other options include waiting for each token.Duplicate() to complete
6578    /// individually (using separate call to token.Sync() after each), or
6579    /// calling Sync() on BufferCollection after the token has been turned in
6580    /// via BindSharedCollection().
6581    ///
6582    /// Another way to mitigate is to avoid calling Sync() on the token, and
6583    /// instead later deal with potential failure of BufferCollection.Sync() if
6584    /// the original token was invalid.  This option can be preferable from a
6585    /// performance point of view, but requires client code to delay sending
6586    /// tokens duplicated from this token until after client code has converted
6587    /// the duplicating token to a BufferCollection and received successful
6588    /// response from BufferCollection.Sync().
6589    ///
6590    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
6591    /// When BufferCollection.Sync() isn't feasible, the caller must already
6592    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
6593    /// hang forever.  See ValidateBufferCollectionToken() to check token
6594    /// validity first if the token isn't already known to be (is/was) valid.
6595    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
6596        let _response = self.client.send_query::<
6597            fidl::encoding::EmptyPayload,
6598            fidl::encoding::EmptyPayload,
6599            BufferCollectionTokenGroupMarker,
6600        >(
6601            (),
6602            0x4577e238ae26291,
6603            fidl::encoding::DynamicFlags::empty(),
6604            ___deadline,
6605        )?;
6606        Ok(_response)
6607    }
6608
6609    /// On a BufferCollectionToken channel:
6610    ///
6611    /// Normally a participant will convert a BufferCollectionToken into a
6612    /// BufferCollection view, but a participant is also free to Close() the
6613    /// token (and then close the channel immediately or shortly later in
6614    /// response to server closing its end), which avoids causing logical buffer
6615    /// collection failure.  Normally an unexpected token channel close will
6616    /// cause logical buffer collection failure (the only exceptions being
6617    /// certain cases involving AttachToken() or SetDispensable()).
6618    ///
6619    /// On a BufferCollection channel:
6620    ///
6621    /// By default the server handles unexpected failure of a BufferCollection
6622    /// by failing the whole logical buffer collection.  Partly this is to
6623    /// expedite closing VMO handles to reclaim memory when any participant
6624    /// fails.  If a participant would like to cleanly close a BufferCollection
6625    /// view without causing logical buffer collection failure, the participant
6626    /// can send Close() before closing the client end of the BufferCollection
6627    /// channel.  If this is the last BufferCollection view, the logical buffer
6628    /// collection will still go away.  The Close() can occur before or after
6629    /// SetConstraints().  If before SetConstraints(), the buffer collection
6630    /// won't require constraints from this node in order to allocate.  If
6631    /// after SetConstraints(), the constraints are retained and aggregated
6632    /// along with any subsequent logical allocation(s), despite the lack of
6633    /// channel connection.
6634    ///
6635    /// On a BufferCollectionTokenGroup channel:
6636    ///
6637    /// By default, unexpected failure of a BufferCollectionTokenGroup will
6638    /// trigger failure of the logical BufferCollectionTokenGroup and will
6639    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
6640    /// channel without failing the logical group or propagating failure, send
6641    /// Close() before closing the channel client endpoint.
6642    ///
6643    /// If Close() occurs before AllChildrenPresent(), the logical buffer
6644    /// collection will still fail despite the Close() (because sysmem can't be
6645    /// sure whether all relevant children were created, so it's ambiguous
6646    /// whether all relevant constraints will be provided to sysmem).  If
6647    /// Close() occurs after AllChildrenPresent(), the children and all their
6648    /// constraints remain intact (just as they would if the
6649    /// BufferCollectionTokenGroup channel had remained open), and the close
6650    /// doesn't trigger or propagate failure.
6651    pub fn r#close(&self) -> Result<(), fidl::Error> {
6652        self.client.send::<fidl::encoding::EmptyPayload>(
6653            (),
6654            0x5b1d7a4f5681fca7,
6655            fidl::encoding::DynamicFlags::empty(),
6656        )
6657    }
6658
6659    /// Set a name for VMOs in this buffer collection. The name may be truncated
6660    /// shorter. The name only affects VMOs allocated after it's set - this call
6661    /// does not rename existing VMOs. If multiple clients set different names
6662    /// then the larger priority value will win.
6663    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
6664        self.client.send::<NodeSetNameRequest>(
6665            (priority, name),
6666            0x77a41bb6217e2443,
6667            fidl::encoding::DynamicFlags::empty(),
6668        )
6669    }
6670
6671    /// Set information about the current client that can be used by sysmem to
6672    /// help debug leaking memory and hangs waiting for constraints. |name| can
6673    /// be an arbitrary string, but the current process name (see
6674    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6675    /// arbitrary id, but the current process ID (see
6676    /// fsl::GetCurrentProcessKoid()) is a good default.
6677    ///
6678    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6679    /// indicate which client is closing their channel first, leading to
6680    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6681    /// over, but if happening earlier than expected, the
6682    /// client-channel-specific name can help diagnose where the failure is
6683    /// first coming from, from sysmem's point of view).
6684    ///
6685    /// By default (unless overriden by this message or using
6686    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6687    /// parent Node at the time the child Node is created.  While this can be
6688    /// better than nothing, it's often better for each participant to use
6689    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6690    /// info directly relevant to the current client.  Also, SetVerboseLogging()
6691    /// can be used to help disambiguate if a Node is suspected of having info
6692    /// that was copied from its parent.
6693    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
6694        self.client.send::<NodeSetDebugClientInfoRequest>(
6695            (name, id),
6696            0x7275759070eb5ee2,
6697            fidl::encoding::DynamicFlags::empty(),
6698        )
6699    }
6700
6701    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6702    /// after creating a collection. Clients can call this method to change
6703    /// when the log is printed. If multiple client set the deadline, it's
6704    /// unspecified which deadline will take effect.
6705    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
6706        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
6707            (deadline,),
6708            0x46d38f4772638867,
6709            fidl::encoding::DynamicFlags::empty(),
6710        )
6711    }
6712
6713    /// Verbose logging includes constraints set via SetConstraints() from each
6714    /// client along with info set via SetDebugClientInfo() and the structure of
6715    /// the tree of Node(s).
6716    ///
6717    /// Normally sysmem prints only a single line complaint when aggregation
6718    /// fails, with just the specific detailed reason that aggregation failed,
6719    /// with minimal context.  While this is often enough to diagnose a problem
6720    /// if only a small change was made and the system had been working before
6721    /// the small change, it's often not particularly helpful for getting a new
6722    /// buffer collection to work for the first time.  Especially with more
6723    /// complex trees of nodes, involving things like AttachToken(),
6724    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6725    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6726    /// looks like and why it's failing a logical allocation, or why a tree or
6727    /// sub-tree is failing sooner than expected.
6728    ///
6729    /// The intent of the extra logging is to be acceptable from a performance
6730    /// point of view, if only enabled on a low number of buffer collections.
6731    /// If we're not tracking down a bug, we shouldn't send this message.
6732    ///
6733    /// If too many participants leave verbose logging enabled, we may end up
6734    /// needing to require that system-wide sysmem verbose logging be permitted
6735    /// via some other setting, to avoid sysmem spamming the log too much due to
6736    /// this message.
6737    ///
6738    /// This may be a NOP for some nodes due to intentional policy associated
6739    /// with the node, if we don't trust a node enough to let it turn on verbose
6740    /// logging.
6741    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
6742        self.client.send::<fidl::encoding::EmptyPayload>(
6743            (),
6744            0x6bfbe2cf1701d288,
6745            fidl::encoding::DynamicFlags::empty(),
6746        )
6747    }
6748
6749    /// This gets an event handle that can be used as a parameter to
6750    /// IsAlternateFor() called on any Node.  The client will not be granted the
6751    /// right to signal this event, as this handle should only be used as proof
6752    /// that the client obtained this handle from this Node.
6753    ///
6754    /// Because this is a get not a set, no Sync() is needed between the
6755    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6756    /// potentially being on different channels.
6757    ///
6758    /// See also IsAlternateFor().
6759    pub fn r#get_node_ref(
6760        &self,
6761        ___deadline: zx::MonotonicInstant,
6762    ) -> Result<fidl::Event, fidl::Error> {
6763        let _response = self.client.send_query::<
6764            fidl::encoding::EmptyPayload,
6765            NodeGetNodeRefResponse,
6766            BufferCollectionTokenGroupMarker,
6767        >(
6768            (),
6769            0x467b7c75c35c3b84,
6770            fidl::encoding::DynamicFlags::empty(),
6771            ___deadline,
6772        )?;
6773        Ok(_response.node_ref)
6774    }
6775
6776    /// This checks whether the calling node is in a subtree rooted at a
6777    /// different child token of a common parent BufferCollectionTokenGroup, in
6778    /// relation to the passed-in node_ref.
6779    ///
6780    /// This call is for assisting with admission control de-duplication, and
6781    /// with debugging.
6782    ///
6783    /// The node_ref must be obtained using GetNodeRef() of a
6784    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6785    ///
6786    /// The node_ref can be a duplicated handle; it's not necessary to call
6787    /// GetNodeRef() for every call to IsAlternateFor().
6788    ///
6789    /// If a calling token may not actually be a valid token at all due to
6790    /// a potentially hostile/untrusted provider of the token, call
6791    /// ValidateBufferCollectionToken() first instead of potentially getting
6792    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6793    /// token not being a real token (not really talking to sysmem).  Another
6794    /// option is to call BindSharedCollection with this token first which also
6795    /// validates the token along with converting it to a BufferCollection, then
6796    /// call BufferCollection IsAlternateFor().
6797    ///
6798    /// error values:
6799    ///
6800    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6801    /// buffer collection as the calling Node.  Before logical allocation and
6802    /// within the same logical allocation sub-tree, this essentially means that
6803    /// the node_ref was never part of this logical buffer collection, since
6804    /// before logical allocation all node_refs that come into existence remain
6805    /// in existence at least until logical allocation (including Node(s) that
6806    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6807    /// to be returned, this Node's channel needs to still be connected server
6808    /// side, which won't be the case if the whole logical allocation has
6809    /// failed.  After logical allocation or in a different logical allocation
6810    /// sub-tree there are additional potential reasons for this error.  For
6811    /// example a different logical allocation (separated from this Node(s)
6812    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6813    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6814    /// exist and may select a different child sub-tree than the sub-tree the
6815    /// node_ref is in causing deletion of the node_ref Node.  The only time
6816    /// sysmem keeps a Node around after that Node has no corresponding channel
6817    /// is when Close() is used and the Node's sub-tree has not yet failed.
6818    /// Another reason for this error is if the node_ref is an eventpair handle
6819    /// with sufficient rights, but isn't actually a real node_ref obtained from
6820    /// GetNodeRef().
6821    ///
6822    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6823    /// eventpair handle, or doesn't have the needed rights expected on a real
6824    /// node_ref.
6825    ///
6826    /// No other failing status codes are returned by this call.  However,
6827    /// sysmem may add additional codes in future, so the client should have
6828    /// sensible default handling for any failing status code.
6829    ///
6830    /// On success, is_alternate has the following meaning:
6831    ///   * true - The first parent node in common between the calling node and
6832    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
6833    ///     the calling Node and the node_ref Node will _not_ have both their
6834    ///     constraints apply - rather sysmem will choose one or the other of
6835    ///     the constraints - never both.  This is because only one child of
6836    ///     a BufferCollectionTokenGroup is selected during logical allocation,
6837    ///     with only that one child's sub-tree contributing to constraints
6838    ///     aggregation.
6839    ///   * false - The first parent node in common between the calling Node and
6840    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
6841    ///     this means the first parent node in common is a
6842    ///     BufferCollectionToken or BufferCollection (regardless of not
6843    ///     Close()ed or Close()ed).  This means that the calling Node and the
6844    ///     node_ref Node _may_ have both their constraints apply during
6845    ///     constraints aggregation of the logical allocation, if both Node(s)
6846    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
6847    ///     In this case, there is no BufferCollectionTokenGroup that will
6848    ///     directly prevent the two Node(s) from both being selected and their
6849    ///     constraints both aggregated, but even when false, one or both
6850    ///     Node(s) may still be eliminated from consideration if one or both
6851    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6852    ///     which selects a child sub-tree other than the sub-tree containing
6853    ///     the calling Node or node_ref Node.
6854    pub fn r#is_alternate_for(
6855        &self,
6856        mut node_ref: fidl::Event,
6857        ___deadline: zx::MonotonicInstant,
6858    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
6859        let _response = self.client.send_query::<
6860            NodeIsAlternateForRequest,
6861            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
6862            BufferCollectionTokenGroupMarker,
6863        >(
6864            (node_ref,),
6865            0x33a2a7aff2776c07,
6866            fidl::encoding::DynamicFlags::empty(),
6867            ___deadline,
6868        )?;
6869        Ok(_response.map(|x| x.is_alternate))
6870    }
6871
6872    /// Create a child token.  Before passing the client end of this token to
6873    /// BindSharedCollection(), completion of Sync() after CreateChild() is
6874    /// required.  Or the client can use CreateChildrenSync() which essentially
6875    /// includes the Sync().
6876    ///
6877    /// token_request - the server end of the new token channel.
6878    ///
6879    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
6880    /// allows the holder to get the same rights to buffers as the parent token
6881    /// (of the group) had.
6882    pub fn r#create_child(
6883        &self,
6884        mut payload: BufferCollectionTokenGroupCreateChildRequest,
6885    ) -> Result<(), fidl::Error> {
6886        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
6887            &mut payload,
6888            0x2e74f8bcbf59ee59,
6889            fidl::encoding::DynamicFlags::empty(),
6890        )
6891    }
6892
6893    /// Create 1 or more child tokens at once, synchronously.  In contrast to
6894    /// CreateChild(), no Sync() completion is required before passing the
6895    /// client end of a returned token to BindSharedCollection().
6896    ///
6897    /// The size of the rights_attentuation_mask determines the number of
6898    /// created child tokens.
6899    ///
6900    /// The lower-index child tokens are higher priority (attempted sooner) than
6901    /// higher-index child tokens.
6902    ///
6903    /// As per all child tokens, successful aggregation will choose exactly one
6904    /// child among all created children (across all children created across
6905    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
6906    ///
6907    /// The maximum permissible total number of children per group, and total
6908    /// number of nodes in an overall tree (from the root) are capped to limits
6909    /// which are not configurable via these protocols.
6910    pub fn r#create_children_sync(
6911        &self,
6912        mut rights_attenuation_masks: &[fidl::Rights],
6913        ___deadline: zx::MonotonicInstant,
6914    ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error> {
6915        let _response = self.client.send_query::<
6916            BufferCollectionTokenGroupCreateChildrenSyncRequest,
6917            BufferCollectionTokenGroupCreateChildrenSyncResponse,
6918            BufferCollectionTokenGroupMarker,
6919        >(
6920            (rights_attenuation_masks,),
6921            0x569dc3ca2a98f535,
6922            fidl::encoding::DynamicFlags::empty(),
6923            ___deadline,
6924        )?;
6925        Ok(_response.tokens)
6926    }
6927
6928    /// AllChildrenPresent()
6929    ///
6930    /// After creating all children, the client must call AllChildrenPresent()
6931    /// to inform sysmem that no more children will be created, so that sysmem
6932    /// can know when it's ok to start aggregating constraints.
6933    ///
6934    /// If Close() is to be sent, it should be sent _after_
6935    /// AllChildrenPresent(), else failure of the group and propagation of the
6936    /// failure to the group's parent will still be triggered.
6937    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
6938        self.client.send::<fidl::encoding::EmptyPayload>(
6939            (),
6940            0x1d41715f6f044b50,
6941            fidl::encoding::DynamicFlags::empty(),
6942        )
6943    }
6944}
6945
6946#[cfg(target_os = "fuchsia")]
6947impl From<BufferCollectionTokenGroupSynchronousProxy> for zx::NullableHandle {
6948    fn from(value: BufferCollectionTokenGroupSynchronousProxy) -> Self {
6949        value.into_channel().into()
6950    }
6951}
6952
6953#[cfg(target_os = "fuchsia")]
6954impl From<fidl::Channel> for BufferCollectionTokenGroupSynchronousProxy {
6955    fn from(value: fidl::Channel) -> Self {
6956        Self::new(value)
6957    }
6958}
6959
6960#[cfg(target_os = "fuchsia")]
6961impl fidl::endpoints::FromClient for BufferCollectionTokenGroupSynchronousProxy {
6962    type Protocol = BufferCollectionTokenGroupMarker;
6963
6964    fn from_client(value: fidl::endpoints::ClientEnd<BufferCollectionTokenGroupMarker>) -> Self {
6965        Self::new(value.into_channel())
6966    }
6967}
6968
6969#[derive(Debug, Clone)]
6970pub struct BufferCollectionTokenGroupProxy {
6971    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6972}
6973
6974impl fidl::endpoints::Proxy for BufferCollectionTokenGroupProxy {
6975    type Protocol = BufferCollectionTokenGroupMarker;
6976
6977    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6978        Self::new(inner)
6979    }
6980
6981    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6982        self.client.into_channel().map_err(|client| Self { client })
6983    }
6984
6985    fn as_channel(&self) -> &::fidl::AsyncChannel {
6986        self.client.as_channel()
6987    }
6988}
6989
6990impl BufferCollectionTokenGroupProxy {
6991    /// Create a new Proxy for fuchsia.sysmem/BufferCollectionTokenGroup.
6992    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6993        let protocol_name =
6994            <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6995        Self { client: fidl::client::Client::new(channel, protocol_name) }
6996    }
6997
6998    /// Get a Stream of events from the remote end of the protocol.
6999    ///
7000    /// # Panics
7001    ///
7002    /// Panics if the event stream was already taken.
7003    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7004        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7005    }
7006
7007    /// Ensure that previous messages, including Duplicate() messages on a
7008    /// token, collection, or group, have been received server side.
7009    ///
7010    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7011    /// valid sysmem token risks the Sync() hanging forever.  See
7012    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7013    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7014    /// Another way is to pass the token to BindSharedCollection(), which also
7015    /// validates the token as part of exchanging it for a BufferCollection
7016    /// channel, and BufferCollection Sync() can then be used.
7017    ///
7018    /// After a Sync(), it's then safe to send the client end of token_request
7019    /// to another participant knowing the server will recognize the token when
7020    /// it's sent into BindSharedCollection() by the other participant.
7021    ///
7022    /// Other options include waiting for each token.Duplicate() to complete
7023    /// individually (using separate call to token.Sync() after each), or
7024    /// calling Sync() on BufferCollection after the token has been turned in
7025    /// via BindSharedCollection().
7026    ///
7027    /// Another way to mitigate is to avoid calling Sync() on the token, and
7028    /// instead later deal with potential failure of BufferCollection.Sync() if
7029    /// the original token was invalid.  This option can be preferable from a
7030    /// performance point of view, but requires client code to delay sending
7031    /// tokens duplicated from this token until after client code has converted
7032    /// the duplicating token to a BufferCollection and received successful
7033    /// response from BufferCollection.Sync().
7034    ///
7035    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7036    /// When BufferCollection.Sync() isn't feasible, the caller must already
7037    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7038    /// hang forever.  See ValidateBufferCollectionToken() to check token
7039    /// validity first if the token isn't already known to be (is/was) valid.
7040    pub fn r#sync(
7041        &self,
7042    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
7043        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7044    }
7045
7046    /// On a BufferCollectionToken channel:
7047    ///
7048    /// Normally a participant will convert a BufferCollectionToken into a
7049    /// BufferCollection view, but a participant is also free to Close() the
7050    /// token (and then close the channel immediately or shortly later in
7051    /// response to server closing its end), which avoids causing logical buffer
7052    /// collection failure.  Normally an unexpected token channel close will
7053    /// cause logical buffer collection failure (the only exceptions being
7054    /// certain cases involving AttachToken() or SetDispensable()).
7055    ///
7056    /// On a BufferCollection channel:
7057    ///
7058    /// By default the server handles unexpected failure of a BufferCollection
7059    /// by failing the whole logical buffer collection.  Partly this is to
7060    /// expedite closing VMO handles to reclaim memory when any participant
7061    /// fails.  If a participant would like to cleanly close a BufferCollection
7062    /// view without causing logical buffer collection failure, the participant
7063    /// can send Close() before closing the client end of the BufferCollection
7064    /// channel.  If this is the last BufferCollection view, the logical buffer
7065    /// collection will still go away.  The Close() can occur before or after
7066    /// SetConstraints().  If before SetConstraints(), the buffer collection
7067    /// won't require constraints from this node in order to allocate.  If
7068    /// after SetConstraints(), the constraints are retained and aggregated
7069    /// along with any subsequent logical allocation(s), despite the lack of
7070    /// channel connection.
7071    ///
7072    /// On a BufferCollectionTokenGroup channel:
7073    ///
7074    /// By default, unexpected failure of a BufferCollectionTokenGroup will
7075    /// trigger failure of the logical BufferCollectionTokenGroup and will
7076    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
7077    /// channel without failing the logical group or propagating failure, send
7078    /// Close() before closing the channel client endpoint.
7079    ///
7080    /// If Close() occurs before AllChildrenPresent(), the logical buffer
7081    /// collection will still fail despite the Close() (because sysmem can't be
7082    /// sure whether all relevant children were created, so it's ambiguous
7083    /// whether all relevant constraints will be provided to sysmem).  If
7084    /// Close() occurs after AllChildrenPresent(), the children and all their
7085    /// constraints remain intact (just as they would if the
7086    /// BufferCollectionTokenGroup channel had remained open), and the close
7087    /// doesn't trigger or propagate failure.
7088    pub fn r#close(&self) -> Result<(), fidl::Error> {
7089        BufferCollectionTokenGroupProxyInterface::r#close(self)
7090    }
7091
7092    /// Set a name for VMOs in this buffer collection. The name may be truncated
7093    /// shorter. The name only affects VMOs allocated after it's set - this call
7094    /// does not rename existing VMOs. If multiple clients set different names
7095    /// then the larger priority value will win.
7096    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7097        BufferCollectionTokenGroupProxyInterface::r#set_name(self, priority, name)
7098    }
7099
7100    /// Set information about the current client that can be used by sysmem to
7101    /// help debug leaking memory and hangs waiting for constraints. |name| can
7102    /// be an arbitrary string, but the current process name (see
7103    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7104    /// arbitrary id, but the current process ID (see
7105    /// fsl::GetCurrentProcessKoid()) is a good default.
7106    ///
7107    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7108    /// indicate which client is closing their channel first, leading to
7109    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7110    /// over, but if happening earlier than expected, the
7111    /// client-channel-specific name can help diagnose where the failure is
7112    /// first coming from, from sysmem's point of view).
7113    ///
7114    /// By default (unless overriden by this message or using
7115    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7116    /// parent Node at the time the child Node is created.  While this can be
7117    /// better than nothing, it's often better for each participant to use
7118    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7119    /// info directly relevant to the current client.  Also, SetVerboseLogging()
7120    /// can be used to help disambiguate if a Node is suspected of having info
7121    /// that was copied from its parent.
7122    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7123        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, name, id)
7124    }
7125
7126    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7127    /// after creating a collection. Clients can call this method to change
7128    /// when the log is printed. If multiple client set the deadline, it's
7129    /// unspecified which deadline will take effect.
7130    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7131        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
7132    }
7133
7134    /// Verbose logging includes constraints set via SetConstraints() from each
7135    /// client along with info set via SetDebugClientInfo() and the structure of
7136    /// the tree of Node(s).
7137    ///
7138    /// Normally sysmem prints only a single line complaint when aggregation
7139    /// fails, with just the specific detailed reason that aggregation failed,
7140    /// with minimal context.  While this is often enough to diagnose a problem
7141    /// if only a small change was made and the system had been working before
7142    /// the small change, it's often not particularly helpful for getting a new
7143    /// buffer collection to work for the first time.  Especially with more
7144    /// complex trees of nodes, involving things like AttachToken(),
7145    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7146    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7147    /// looks like and why it's failing a logical allocation, or why a tree or
7148    /// sub-tree is failing sooner than expected.
7149    ///
7150    /// The intent of the extra logging is to be acceptable from a performance
7151    /// point of view, if only enabled on a low number of buffer collections.
7152    /// If we're not tracking down a bug, we shouldn't send this message.
7153    ///
7154    /// If too many participants leave verbose logging enabled, we may end up
7155    /// needing to require that system-wide sysmem verbose logging be permitted
7156    /// via some other setting, to avoid sysmem spamming the log too much due to
7157    /// this message.
7158    ///
7159    /// This may be a NOP for some nodes due to intentional policy associated
7160    /// with the node, if we don't trust a node enough to let it turn on verbose
7161    /// logging.
7162    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7163        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7164    }
7165
7166    /// This gets an event handle that can be used as a parameter to
7167    /// IsAlternateFor() called on any Node.  The client will not be granted the
7168    /// right to signal this event, as this handle should only be used as proof
7169    /// that the client obtained this handle from this Node.
7170    ///
7171    /// Because this is a get not a set, no Sync() is needed between the
7172    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7173    /// potentially being on different channels.
7174    ///
7175    /// See also IsAlternateFor().
7176    pub fn r#get_node_ref(
7177        &self,
7178    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
7179    {
7180        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7181    }
7182
7183    /// This checks whether the calling node is in a subtree rooted at a
7184    /// different child token of a common parent BufferCollectionTokenGroup, in
7185    /// relation to the passed-in node_ref.
7186    ///
7187    /// This call is for assisting with admission control de-duplication, and
7188    /// with debugging.
7189    ///
7190    /// The node_ref must be obtained using GetNodeRef() of a
7191    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7192    ///
7193    /// The node_ref can be a duplicated handle; it's not necessary to call
7194    /// GetNodeRef() for every call to IsAlternateFor().
7195    ///
7196    /// If a calling token may not actually be a valid token at all due to
7197    /// a potentially hostile/untrusted provider of the token, call
7198    /// ValidateBufferCollectionToken() first instead of potentially getting
7199    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7200    /// token not being a real token (not really talking to sysmem).  Another
7201    /// option is to call BindSharedCollection with this token first which also
7202    /// validates the token along with converting it to a BufferCollection, then
7203    /// call BufferCollection IsAlternateFor().
7204    ///
7205    /// error values:
7206    ///
7207    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7208    /// buffer collection as the calling Node.  Before logical allocation and
7209    /// within the same logical allocation sub-tree, this essentially means that
7210    /// the node_ref was never part of this logical buffer collection, since
7211    /// before logical allocation all node_refs that come into existence remain
7212    /// in existence at least until logical allocation (including Node(s) that
7213    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7214    /// to be returned, this Node's channel needs to still be connected server
7215    /// side, which won't be the case if the whole logical allocation has
7216    /// failed.  After logical allocation or in a different logical allocation
7217    /// sub-tree there are additional potential reasons for this error.  For
7218    /// example a different logical allocation (separated from this Node(s)
7219    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7220    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7221    /// exist and may select a different child sub-tree than the sub-tree the
7222    /// node_ref is in causing deletion of the node_ref Node.  The only time
7223    /// sysmem keeps a Node around after that Node has no corresponding channel
7224    /// is when Close() is used and the Node's sub-tree has not yet failed.
7225    /// Another reason for this error is if the node_ref is an eventpair handle
7226    /// with sufficient rights, but isn't actually a real node_ref obtained from
7227    /// GetNodeRef().
7228    ///
7229    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7230    /// eventpair handle, or doesn't have the needed rights expected on a real
7231    /// node_ref.
7232    ///
7233    /// No other failing status codes are returned by this call.  However,
7234    /// sysmem may add additional codes in future, so the client should have
7235    /// sensible default handling for any failing status code.
7236    ///
7237    /// On success, is_alternate has the following meaning:
7238    ///   * true - The first parent node in common between the calling node and
7239    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
7240    ///     the calling Node and the node_ref Node will _not_ have both their
7241    ///     constraints apply - rather sysmem will choose one or the other of
7242    ///     the constraints - never both.  This is because only one child of
7243    ///     a BufferCollectionTokenGroup is selected during logical allocation,
7244    ///     with only that one child's sub-tree contributing to constraints
7245    ///     aggregation.
7246    ///   * false - The first parent node in common between the calling Node and
7247    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
7248    ///     this means the first parent node in common is a
7249    ///     BufferCollectionToken or BufferCollection (regardless of not
7250    ///     Close()ed or Close()ed).  This means that the calling Node and the
7251    ///     node_ref Node _may_ have both their constraints apply during
7252    ///     constraints aggregation of the logical allocation, if both Node(s)
7253    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
7254    ///     In this case, there is no BufferCollectionTokenGroup that will
7255    ///     directly prevent the two Node(s) from both being selected and their
7256    ///     constraints both aggregated, but even when false, one or both
7257    ///     Node(s) may still be eliminated from consideration if one or both
7258    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7259    ///     which selects a child sub-tree other than the sub-tree containing
7260    ///     the calling Node or node_ref Node.
7261    pub fn r#is_alternate_for(
7262        &self,
7263        mut node_ref: fidl::Event,
7264    ) -> fidl::client::QueryResponseFut<
7265        NodeIsAlternateForResult,
7266        fidl::encoding::DefaultFuchsiaResourceDialect,
7267    > {
7268        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, node_ref)
7269    }
7270
7271    /// Create a child token.  Before passing the client end of this token to
7272    /// BindSharedCollection(), completion of Sync() after CreateChild() is
7273    /// required.  Or the client can use CreateChildrenSync() which essentially
7274    /// includes the Sync().
7275    ///
7276    /// token_request - the server end of the new token channel.
7277    ///
7278    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
7279    /// allows the holder to get the same rights to buffers as the parent token
7280    /// (of the group) had.
7281    pub fn r#create_child(
7282        &self,
7283        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7284    ) -> Result<(), fidl::Error> {
7285        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7286    }
7287
7288    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7289    /// CreateChild(), no Sync() completion is required before passing the
7290    /// client end of a returned token to BindSharedCollection().
7291    ///
7292    /// The size of the rights_attentuation_mask determines the number of
7293    /// created child tokens.
7294    ///
7295    /// The lower-index child tokens are higher priority (attempted sooner) than
7296    /// higher-index child tokens.
7297    ///
7298    /// As per all child tokens, successful aggregation will choose exactly one
7299    /// child among all created children (across all children created across
7300    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
7301    ///
7302    /// The maximum permissible total number of children per group, and total
7303    /// number of nodes in an overall tree (from the root) are capped to limits
7304    /// which are not configurable via these protocols.
7305    pub fn r#create_children_sync(
7306        &self,
7307        mut rights_attenuation_masks: &[fidl::Rights],
7308    ) -> fidl::client::QueryResponseFut<
7309        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7310        fidl::encoding::DefaultFuchsiaResourceDialect,
7311    > {
7312        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(
7313            self,
7314            rights_attenuation_masks,
7315        )
7316    }
7317
7318    /// AllChildrenPresent()
7319    ///
7320    /// After creating all children, the client must call AllChildrenPresent()
7321    /// to inform sysmem that no more children will be created, so that sysmem
7322    /// can know when it's ok to start aggregating constraints.
7323    ///
7324    /// If Close() is to be sent, it should be sent _after_
7325    /// AllChildrenPresent(), else failure of the group and propagation of the
7326    /// failure to the group's parent will still be triggered.
7327    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7328        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7329    }
7330}
7331
7332impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7333    type SyncResponseFut =
7334        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
7335    fn r#sync(&self) -> Self::SyncResponseFut {
7336        fn _decode(
7337            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7338        ) -> Result<(), fidl::Error> {
7339            let _response = fidl::client::decode_transaction_body::<
7340                fidl::encoding::EmptyPayload,
7341                fidl::encoding::DefaultFuchsiaResourceDialect,
7342                0x4577e238ae26291,
7343            >(_buf?)?;
7344            Ok(_response)
7345        }
7346        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7347            (),
7348            0x4577e238ae26291,
7349            fidl::encoding::DynamicFlags::empty(),
7350            _decode,
7351        )
7352    }
7353
7354    fn r#close(&self) -> Result<(), fidl::Error> {
7355        self.client.send::<fidl::encoding::EmptyPayload>(
7356            (),
7357            0x5b1d7a4f5681fca7,
7358            fidl::encoding::DynamicFlags::empty(),
7359        )
7360    }
7361
7362    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7363        self.client.send::<NodeSetNameRequest>(
7364            (priority, name),
7365            0x77a41bb6217e2443,
7366            fidl::encoding::DynamicFlags::empty(),
7367        )
7368    }
7369
7370    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7371        self.client.send::<NodeSetDebugClientInfoRequest>(
7372            (name, id),
7373            0x7275759070eb5ee2,
7374            fidl::encoding::DynamicFlags::empty(),
7375        )
7376    }
7377
7378    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7379        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7380            (deadline,),
7381            0x46d38f4772638867,
7382            fidl::encoding::DynamicFlags::empty(),
7383        )
7384    }
7385
7386    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7387        self.client.send::<fidl::encoding::EmptyPayload>(
7388            (),
7389            0x6bfbe2cf1701d288,
7390            fidl::encoding::DynamicFlags::empty(),
7391        )
7392    }
7393
7394    type GetNodeRefResponseFut =
7395        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
7396    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7397        fn _decode(
7398            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7399        ) -> Result<fidl::Event, fidl::Error> {
7400            let _response = fidl::client::decode_transaction_body::<
7401                NodeGetNodeRefResponse,
7402                fidl::encoding::DefaultFuchsiaResourceDialect,
7403                0x467b7c75c35c3b84,
7404            >(_buf?)?;
7405            Ok(_response.node_ref)
7406        }
7407        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
7408            (),
7409            0x467b7c75c35c3b84,
7410            fidl::encoding::DynamicFlags::empty(),
7411            _decode,
7412        )
7413    }
7414
7415    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7416        NodeIsAlternateForResult,
7417        fidl::encoding::DefaultFuchsiaResourceDialect,
7418    >;
7419    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
7420        fn _decode(
7421            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7422        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7423            let _response = fidl::client::decode_transaction_body::<
7424                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7425                fidl::encoding::DefaultFuchsiaResourceDialect,
7426                0x33a2a7aff2776c07,
7427            >(_buf?)?;
7428            Ok(_response.map(|x| x.is_alternate))
7429        }
7430        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7431            (node_ref,),
7432            0x33a2a7aff2776c07,
7433            fidl::encoding::DynamicFlags::empty(),
7434            _decode,
7435        )
7436    }
7437
7438    fn r#create_child(
7439        &self,
7440        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7441    ) -> Result<(), fidl::Error> {
7442        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7443            &mut payload,
7444            0x2e74f8bcbf59ee59,
7445            fidl::encoding::DynamicFlags::empty(),
7446        )
7447    }
7448
7449    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
7450        Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7451        fidl::encoding::DefaultFuchsiaResourceDialect,
7452    >;
7453    fn r#create_children_sync(
7454        &self,
7455        mut rights_attenuation_masks: &[fidl::Rights],
7456    ) -> Self::CreateChildrenSyncResponseFut {
7457        fn _decode(
7458            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7459        ) -> Result<Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
7460        {
7461            let _response = fidl::client::decode_transaction_body::<
7462                BufferCollectionTokenGroupCreateChildrenSyncResponse,
7463                fidl::encoding::DefaultFuchsiaResourceDialect,
7464                0x569dc3ca2a98f535,
7465            >(_buf?)?;
7466            Ok(_response.tokens)
7467        }
7468        self.client.send_query_and_decode::<
7469            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7470            Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
7471        >(
7472            (rights_attenuation_masks,),
7473            0x569dc3ca2a98f535,
7474            fidl::encoding::DynamicFlags::empty(),
7475            _decode,
7476        )
7477    }
7478
7479    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7480        self.client.send::<fidl::encoding::EmptyPayload>(
7481            (),
7482            0x1d41715f6f044b50,
7483            fidl::encoding::DynamicFlags::empty(),
7484        )
7485    }
7486}
7487
7488pub struct BufferCollectionTokenGroupEventStream {
7489    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7490}
7491
7492impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
7493
7494impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
7495    fn is_terminated(&self) -> bool {
7496        self.event_receiver.is_terminated()
7497    }
7498}
7499
7500impl futures::Stream for BufferCollectionTokenGroupEventStream {
7501    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
7502
7503    fn poll_next(
7504        mut self: std::pin::Pin<&mut Self>,
7505        cx: &mut std::task::Context<'_>,
7506    ) -> std::task::Poll<Option<Self::Item>> {
7507        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7508            &mut self.event_receiver,
7509            cx
7510        )?) {
7511            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
7512            None => std::task::Poll::Ready(None),
7513        }
7514    }
7515}
7516
7517#[derive(Debug)]
7518pub enum BufferCollectionTokenGroupEvent {}
7519
7520impl BufferCollectionTokenGroupEvent {
7521    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
7522    fn decode(
7523        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7524    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
7525        let (bytes, _handles) = buf.split_mut();
7526        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7527        debug_assert_eq!(tx_header.tx_id, 0);
7528        match tx_header.ordinal {
7529            _ => Err(fidl::Error::UnknownOrdinal {
7530                ordinal: tx_header.ordinal,
7531                protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7532            })
7533        }
7534    }
7535}
7536
7537/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionTokenGroup.
7538pub struct BufferCollectionTokenGroupRequestStream {
7539    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7540    is_terminated: bool,
7541}
7542
7543impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
7544
7545impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
7546    fn is_terminated(&self) -> bool {
7547        self.is_terminated
7548    }
7549}
7550
7551impl fidl::endpoints::RequestStream for BufferCollectionTokenGroupRequestStream {
7552    type Protocol = BufferCollectionTokenGroupMarker;
7553    type ControlHandle = BufferCollectionTokenGroupControlHandle;
7554
7555    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7556        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7557    }
7558
7559    fn control_handle(&self) -> Self::ControlHandle {
7560        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
7561    }
7562
7563    fn into_inner(
7564        self,
7565    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7566    {
7567        (self.inner, self.is_terminated)
7568    }
7569
7570    fn from_inner(
7571        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7572        is_terminated: bool,
7573    ) -> Self {
7574        Self { inner, is_terminated }
7575    }
7576}
7577
7578impl futures::Stream for BufferCollectionTokenGroupRequestStream {
7579    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
7580
7581    fn poll_next(
7582        mut self: std::pin::Pin<&mut Self>,
7583        cx: &mut std::task::Context<'_>,
7584    ) -> std::task::Poll<Option<Self::Item>> {
7585        let this = &mut *self;
7586        if this.inner.check_shutdown(cx) {
7587            this.is_terminated = true;
7588            return std::task::Poll::Ready(None);
7589        }
7590        if this.is_terminated {
7591            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
7592        }
7593        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7594            |bytes, handles| {
7595                match this.inner.channel().read_etc(cx, bytes, handles) {
7596                    std::task::Poll::Ready(Ok(())) => {}
7597                    std::task::Poll::Pending => return std::task::Poll::Pending,
7598                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7599                        this.is_terminated = true;
7600                        return std::task::Poll::Ready(None);
7601                    }
7602                    std::task::Poll::Ready(Err(e)) => {
7603                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7604                            e.into(),
7605                        ))));
7606                    }
7607                }
7608
7609                // A message has been received from the channel
7610                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7611
7612                std::task::Poll::Ready(Some(match header.ordinal {
7613                0x4577e238ae26291 => {
7614                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7615                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7616                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7617                    let control_handle = BufferCollectionTokenGroupControlHandle {
7618                        inner: this.inner.clone(),
7619                    };
7620                    Ok(BufferCollectionTokenGroupRequest::Sync {
7621                        responder: BufferCollectionTokenGroupSyncResponder {
7622                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7623                            tx_id: header.tx_id,
7624                        },
7625                    })
7626                }
7627                0x5b1d7a4f5681fca7 => {
7628                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7629                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7630                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7631                    let control_handle = BufferCollectionTokenGroupControlHandle {
7632                        inner: this.inner.clone(),
7633                    };
7634                    Ok(BufferCollectionTokenGroupRequest::Close {
7635                        control_handle,
7636                    })
7637                }
7638                0x77a41bb6217e2443 => {
7639                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7640                    let mut req = fidl::new_empty!(NodeSetNameRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7641                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
7642                    let control_handle = BufferCollectionTokenGroupControlHandle {
7643                        inner: this.inner.clone(),
7644                    };
7645                    Ok(BufferCollectionTokenGroupRequest::SetName {priority: req.priority,
7646name: req.name,
7647
7648                        control_handle,
7649                    })
7650                }
7651                0x7275759070eb5ee2 => {
7652                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7653                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7654                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
7655                    let control_handle = BufferCollectionTokenGroupControlHandle {
7656                        inner: this.inner.clone(),
7657                    };
7658                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {name: req.name,
7659id: req.id,
7660
7661                        control_handle,
7662                    })
7663                }
7664                0x46d38f4772638867 => {
7665                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7666                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7667                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
7668                    let control_handle = BufferCollectionTokenGroupControlHandle {
7669                        inner: this.inner.clone(),
7670                    };
7671                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
7672
7673                        control_handle,
7674                    })
7675                }
7676                0x6bfbe2cf1701d288 => {
7677                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7678                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7679                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7680                    let control_handle = BufferCollectionTokenGroupControlHandle {
7681                        inner: this.inner.clone(),
7682                    };
7683                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
7684                        control_handle,
7685                    })
7686                }
7687                0x467b7c75c35c3b84 => {
7688                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7689                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7690                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7691                    let control_handle = BufferCollectionTokenGroupControlHandle {
7692                        inner: this.inner.clone(),
7693                    };
7694                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
7695                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
7696                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7697                            tx_id: header.tx_id,
7698                        },
7699                    })
7700                }
7701                0x33a2a7aff2776c07 => {
7702                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7703                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7704                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
7705                    let control_handle = BufferCollectionTokenGroupControlHandle {
7706                        inner: this.inner.clone(),
7707                    };
7708                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {node_ref: req.node_ref,
7709
7710                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
7711                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7712                            tx_id: header.tx_id,
7713                        },
7714                    })
7715                }
7716                0x2e74f8bcbf59ee59 => {
7717                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7718                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7719                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
7720                    let control_handle = BufferCollectionTokenGroupControlHandle {
7721                        inner: this.inner.clone(),
7722                    };
7723                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
7724                        control_handle,
7725                    })
7726                }
7727                0x569dc3ca2a98f535 => {
7728                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7729                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7730                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
7731                    let control_handle = BufferCollectionTokenGroupControlHandle {
7732                        inner: this.inner.clone(),
7733                    };
7734                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {rights_attenuation_masks: req.rights_attenuation_masks,
7735
7736                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
7737                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7738                            tx_id: header.tx_id,
7739                        },
7740                    })
7741                }
7742                0x1d41715f6f044b50 => {
7743                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7744                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7745                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7746                    let control_handle = BufferCollectionTokenGroupControlHandle {
7747                        inner: this.inner.clone(),
7748                    };
7749                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
7750                        control_handle,
7751                    })
7752                }
7753                _ => Err(fidl::Error::UnknownOrdinal {
7754                    ordinal: header.ordinal,
7755                    protocol_name: <BufferCollectionTokenGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7756                }),
7757            }))
7758            },
7759        )
7760    }
7761}
7762
7763/// The sysmem implementation is guaranteed to be consistent with a logical /
7764/// conceptual model as follows:
7765///
7766/// As usual, a logical allocation considers either the root and all nodes with
7767/// connectivity to the root that don't transit an AttachToken(), or a sub-tree
7768/// rooted at an AttachToken() token and all nodes with connectivity to that
7769/// subtree that don't transit another AttachToken().  This is called the
7770/// logical allocation pruned sub-tree, or pruned sub-tree for short.
7771///
7772/// During constraints aggregation, each BufferCollectionTokenGroup will select
7773/// a single child token among its children.  The rest of the children will
7774/// appear to fail the logical allocation, while the selected child may succeed.
7775///
7776/// When more than one BufferCollectionTokenGroup exists in the overall logical
7777/// allocation pruned sub-tree, the relative priority between two groups is
7778/// equivalent to their ordering in a DFS pre-order iteration of the tree, with
7779/// parents higher priority than children, and left children higher priority
7780/// than right children.
7781///
7782/// When a particular child of a group is selected (whether provisionally during
7783/// a constraints aggregation attempt, or as a final selection), the
7784/// non-selection of other children of the group can potentially "hide" other
7785/// groups under those non-selected children.
7786///
7787/// Within a logical allocation, aggregation is attempted first by provisionally
7788/// selecting the child 0 of the highest-priority group, and child 0 of the next
7789/// highest-priority group that isn't hidden by the provisional selections so
7790/// far, etc.
7791///
7792/// If that aggregation attempt fails, aggregation will be attempted with the
7793/// ordinal 0 child of all the same groups except the lowest priority non-hidden
7794/// group which will provisionally select its ordinal 1 child (and then child 2
7795/// and so on).  If a new lowest-priority group is un-hidden as provisional
7796/// selections are updated, that newly un-hidden lowest-priority group has all
7797/// its children considered in order, before changing the provisional selection
7798/// in the former lowest-priority group.  In terms of result, this is equivalent
7799/// to systematic enumeration of all possible combinations of choices in a
7800/// counting-like order updating the lowest-priority group the most often and
7801/// the highest-priority group the least often.  Rather than actually attempting
7802/// aggregation with all the combinations, we can skip over combinations which
7803/// are redundant/equivalent due to hiding without any change to the result.
7804///
7805/// Attempted aggregations of enumerated non-equivalent combinations of choices
7806/// continue in this manner until either (a) all aggregation attempts fail in
7807/// which case the overall logical allocation fails, or (b) until an attempted
7808/// aggregation succeeds, in which case buffer allocation (if needed) is
7809/// attempted once.  If buffer allocation based on the first successful
7810/// aggregation fails, the overall logical allocation fails (there is no buffer
7811/// allocation retry / re-attempt).  If buffer allocation succeeds (or is not
7812/// needed), the logical allocation succeeds.
7813///
7814/// If this prioritization scheme cannot reasonably work for your usage of
7815/// sysmem, please contact sysmem folks to discuss potentially adding a way to
7816/// achieve what you need.
7817///
7818/// Please avoid creating a large number of BufferCollectionTokenGroup(s) per
7819/// logical allocation, especially with large number of children overall, and
7820/// especially in cases where aggregation may reasonably be expected to often
7821/// fail using ordinal 0 children and possibly with later children as well.  We
7822/// anticipate mitigating potentially high time complexity of evaluating too
7823/// many child combinations/selections across too many groups by simply failing
7824/// logical allocation beyond a certain (fairly high, but not huge) max number
7825/// of considered group child combinations/selections.  More advanced (and more
7826/// complicated) mitigation is not anticipated to be practically necessary or
7827/// worth the added complexity.  Please contact sysmem folks if the max limit
7828/// is getting hit or if you anticipate it getting hit, to discuss potential
7829/// options.
7830///
7831/// Prefer to use multiple ImageFormatConstraints in a single
7832/// BufferCollectionConstraints when feasible (when a participant just needs to
7833/// express the ability to work with more than a single PixelFormat, with
7834/// sysmem choosing which PixelFormat to use among those supported by all
7835/// participants).
7836///
7837/// Similar to BufferCollectionToken and BufferCollection, closure of the
7838/// BufferCollectionTokenGroup channel without sending Close() first will cause
7839/// logical buffer collection failure (or sub-tree failure if using
7840/// SetDispensable() or AttachToken() and the BufferCollectionTokenGroup is part
7841/// of a sub-tree under such a node that doesn't propagate failure to its
7842/// parent).
7843#[derive(Debug)]
7844pub enum BufferCollectionTokenGroupRequest {
7845    /// Ensure that previous messages, including Duplicate() messages on a
7846    /// token, collection, or group, have been received server side.
7847    ///
7848    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7849    /// valid sysmem token risks the Sync() hanging forever.  See
7850    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7851    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7852    /// Another way is to pass the token to BindSharedCollection(), which also
7853    /// validates the token as part of exchanging it for a BufferCollection
7854    /// channel, and BufferCollection Sync() can then be used.
7855    ///
7856    /// After a Sync(), it's then safe to send the client end of token_request
7857    /// to another participant knowing the server will recognize the token when
7858    /// it's sent into BindSharedCollection() by the other participant.
7859    ///
7860    /// Other options include waiting for each token.Duplicate() to complete
7861    /// individually (using separate call to token.Sync() after each), or
7862    /// calling Sync() on BufferCollection after the token has been turned in
7863    /// via BindSharedCollection().
7864    ///
7865    /// Another way to mitigate is to avoid calling Sync() on the token, and
7866    /// instead later deal with potential failure of BufferCollection.Sync() if
7867    /// the original token was invalid.  This option can be preferable from a
7868    /// performance point of view, but requires client code to delay sending
7869    /// tokens duplicated from this token until after client code has converted
7870    /// the duplicating token to a BufferCollection and received successful
7871    /// response from BufferCollection.Sync().
7872    ///
7873    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7874    /// When BufferCollection.Sync() isn't feasible, the caller must already
7875    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7876    /// hang forever.  See ValidateBufferCollectionToken() to check token
7877    /// validity first if the token isn't already known to be (is/was) valid.
7878    Sync { responder: BufferCollectionTokenGroupSyncResponder },
7879    /// On a BufferCollectionToken channel:
7880    ///
7881    /// Normally a participant will convert a BufferCollectionToken into a
7882    /// BufferCollection view, but a participant is also free to Close() the
7883    /// token (and then close the channel immediately or shortly later in
7884    /// response to server closing its end), which avoids causing logical buffer
7885    /// collection failure.  Normally an unexpected token channel close will
7886    /// cause logical buffer collection failure (the only exceptions being
7887    /// certain cases involving AttachToken() or SetDispensable()).
7888    ///
7889    /// On a BufferCollection channel:
7890    ///
7891    /// By default the server handles unexpected failure of a BufferCollection
7892    /// by failing the whole logical buffer collection.  Partly this is to
7893    /// expedite closing VMO handles to reclaim memory when any participant
7894    /// fails.  If a participant would like to cleanly close a BufferCollection
7895    /// view without causing logical buffer collection failure, the participant
7896    /// can send Close() before closing the client end of the BufferCollection
7897    /// channel.  If this is the last BufferCollection view, the logical buffer
7898    /// collection will still go away.  The Close() can occur before or after
7899    /// SetConstraints().  If before SetConstraints(), the buffer collection
7900    /// won't require constraints from this node in order to allocate.  If
7901    /// after SetConstraints(), the constraints are retained and aggregated
7902    /// along with any subsequent logical allocation(s), despite the lack of
7903    /// channel connection.
7904    ///
7905    /// On a BufferCollectionTokenGroup channel:
7906    ///
7907    /// By default, unexpected failure of a BufferCollectionTokenGroup will
7908    /// trigger failure of the logical BufferCollectionTokenGroup and will
7909    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
7910    /// channel without failing the logical group or propagating failure, send
7911    /// Close() before closing the channel client endpoint.
7912    ///
7913    /// If Close() occurs before AllChildrenPresent(), the logical buffer
7914    /// collection will still fail despite the Close() (because sysmem can't be
7915    /// sure whether all relevant children were created, so it's ambiguous
7916    /// whether all relevant constraints will be provided to sysmem).  If
7917    /// Close() occurs after AllChildrenPresent(), the children and all their
7918    /// constraints remain intact (just as they would if the
7919    /// BufferCollectionTokenGroup channel had remained open), and the close
7920    /// doesn't trigger or propagate failure.
7921    Close { control_handle: BufferCollectionTokenGroupControlHandle },
7922    /// Set a name for VMOs in this buffer collection. The name may be truncated
7923    /// shorter. The name only affects VMOs allocated after it's set - this call
7924    /// does not rename existing VMOs. If multiple clients set different names
7925    /// then the larger priority value will win.
7926    SetName { priority: u32, name: String, control_handle: BufferCollectionTokenGroupControlHandle },
7927    /// Set information about the current client that can be used by sysmem to
7928    /// help debug leaking memory and hangs waiting for constraints. |name| can
7929    /// be an arbitrary string, but the current process name (see
7930    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7931    /// arbitrary id, but the current process ID (see
7932    /// fsl::GetCurrentProcessKoid()) is a good default.
7933    ///
7934    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7935    /// indicate which client is closing their channel first, leading to
7936    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7937    /// over, but if happening earlier than expected, the
7938    /// client-channel-specific name can help diagnose where the failure is
7939    /// first coming from, from sysmem's point of view).
7940    ///
7941    /// By default (unless overriden by this message or using
7942    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7943    /// parent Node at the time the child Node is created.  While this can be
7944    /// better than nothing, it's often better for each participant to use
7945    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7946    /// info directly relevant to the current client.  Also, SetVerboseLogging()
7947    /// can be used to help disambiguate if a Node is suspected of having info
7948    /// that was copied from its parent.
7949    SetDebugClientInfo {
7950        name: String,
7951        id: u64,
7952        control_handle: BufferCollectionTokenGroupControlHandle,
7953    },
7954    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7955    /// after creating a collection. Clients can call this method to change
7956    /// when the log is printed. If multiple client set the deadline, it's
7957    /// unspecified which deadline will take effect.
7958    SetDebugTimeoutLogDeadline {
7959        deadline: i64,
7960        control_handle: BufferCollectionTokenGroupControlHandle,
7961    },
7962    /// Verbose logging includes constraints set via SetConstraints() from each
7963    /// client along with info set via SetDebugClientInfo() and the structure of
7964    /// the tree of Node(s).
7965    ///
7966    /// Normally sysmem prints only a single line complaint when aggregation
7967    /// fails, with just the specific detailed reason that aggregation failed,
7968    /// with minimal context.  While this is often enough to diagnose a problem
7969    /// if only a small change was made and the system had been working before
7970    /// the small change, it's often not particularly helpful for getting a new
7971    /// buffer collection to work for the first time.  Especially with more
7972    /// complex trees of nodes, involving things like AttachToken(),
7973    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7974    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7975    /// looks like and why it's failing a logical allocation, or why a tree or
7976    /// sub-tree is failing sooner than expected.
7977    ///
7978    /// The intent of the extra logging is to be acceptable from a performance
7979    /// point of view, if only enabled on a low number of buffer collections.
7980    /// If we're not tracking down a bug, we shouldn't send this message.
7981    ///
7982    /// If too many participants leave verbose logging enabled, we may end up
7983    /// needing to require that system-wide sysmem verbose logging be permitted
7984    /// via some other setting, to avoid sysmem spamming the log too much due to
7985    /// this message.
7986    ///
7987    /// This may be a NOP for some nodes due to intentional policy associated
7988    /// with the node, if we don't trust a node enough to let it turn on verbose
7989    /// logging.
7990    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
7991    /// This gets an event handle that can be used as a parameter to
7992    /// IsAlternateFor() called on any Node.  The client will not be granted the
7993    /// right to signal this event, as this handle should only be used as proof
7994    /// that the client obtained this handle from this Node.
7995    ///
7996    /// Because this is a get not a set, no Sync() is needed between the
7997    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7998    /// potentially being on different channels.
7999    ///
8000    /// See also IsAlternateFor().
8001    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8002    /// This checks whether the calling node is in a subtree rooted at a
8003    /// different child token of a common parent BufferCollectionTokenGroup, in
8004    /// relation to the passed-in node_ref.
8005    ///
8006    /// This call is for assisting with admission control de-duplication, and
8007    /// with debugging.
8008    ///
8009    /// The node_ref must be obtained using GetNodeRef() of a
8010    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
8011    ///
8012    /// The node_ref can be a duplicated handle; it's not necessary to call
8013    /// GetNodeRef() for every call to IsAlternateFor().
8014    ///
8015    /// If a calling token may not actually be a valid token at all due to
8016    /// a potentially hostile/untrusted provider of the token, call
8017    /// ValidateBufferCollectionToken() first instead of potentially getting
8018    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
8019    /// token not being a real token (not really talking to sysmem).  Another
8020    /// option is to call BindSharedCollection with this token first which also
8021    /// validates the token along with converting it to a BufferCollection, then
8022    /// call BufferCollection IsAlternateFor().
8023    ///
8024    /// error values:
8025    ///
8026    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
8027    /// buffer collection as the calling Node.  Before logical allocation and
8028    /// within the same logical allocation sub-tree, this essentially means that
8029    /// the node_ref was never part of this logical buffer collection, since
8030    /// before logical allocation all node_refs that come into existence remain
8031    /// in existence at least until logical allocation (including Node(s) that
8032    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
8033    /// to be returned, this Node's channel needs to still be connected server
8034    /// side, which won't be the case if the whole logical allocation has
8035    /// failed.  After logical allocation or in a different logical allocation
8036    /// sub-tree there are additional potential reasons for this error.  For
8037    /// example a different logical allocation (separated from this Node(s)
8038    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
8039    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
8040    /// exist and may select a different child sub-tree than the sub-tree the
8041    /// node_ref is in causing deletion of the node_ref Node.  The only time
8042    /// sysmem keeps a Node around after that Node has no corresponding channel
8043    /// is when Close() is used and the Node's sub-tree has not yet failed.
8044    /// Another reason for this error is if the node_ref is an eventpair handle
8045    /// with sufficient rights, but isn't actually a real node_ref obtained from
8046    /// GetNodeRef().
8047    ///
8048    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
8049    /// eventpair handle, or doesn't have the needed rights expected on a real
8050    /// node_ref.
8051    ///
8052    /// No other failing status codes are returned by this call.  However,
8053    /// sysmem may add additional codes in future, so the client should have
8054    /// sensible default handling for any failing status code.
8055    ///
8056    /// On success, is_alternate has the following meaning:
8057    ///   * true - The first parent node in common between the calling node and
8058    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
8059    ///     the calling Node and the node_ref Node will _not_ have both their
8060    ///     constraints apply - rather sysmem will choose one or the other of
8061    ///     the constraints - never both.  This is because only one child of
8062    ///     a BufferCollectionTokenGroup is selected during logical allocation,
8063    ///     with only that one child's sub-tree contributing to constraints
8064    ///     aggregation.
8065    ///   * false - The first parent node in common between the calling Node and
8066    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
8067    ///     this means the first parent node in common is a
8068    ///     BufferCollectionToken or BufferCollection (regardless of not
8069    ///     Close()ed or Close()ed).  This means that the calling Node and the
8070    ///     node_ref Node _may_ have both their constraints apply during
8071    ///     constraints aggregation of the logical allocation, if both Node(s)
8072    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
8073    ///     In this case, there is no BufferCollectionTokenGroup that will
8074    ///     directly prevent the two Node(s) from both being selected and their
8075    ///     constraints both aggregated, but even when false, one or both
8076    ///     Node(s) may still be eliminated from consideration if one or both
8077    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
8078    ///     which selects a child sub-tree other than the sub-tree containing
8079    ///     the calling Node or node_ref Node.
8080    IsAlternateFor {
8081        node_ref: fidl::Event,
8082        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8083    },
8084    /// Create a child token.  Before passing the client end of this token to
8085    /// BindSharedCollection(), completion of Sync() after CreateChild() is
8086    /// required.  Or the client can use CreateChildrenSync() which essentially
8087    /// includes the Sync().
8088    ///
8089    /// token_request - the server end of the new token channel.
8090    ///
8091    /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
8092    /// allows the holder to get the same rights to buffers as the parent token
8093    /// (of the group) had.
8094    CreateChild {
8095        payload: BufferCollectionTokenGroupCreateChildRequest,
8096        control_handle: BufferCollectionTokenGroupControlHandle,
8097    },
8098    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8099    /// CreateChild(), no Sync() completion is required before passing the
8100    /// client end of a returned token to BindSharedCollection().
8101    ///
8102    /// The size of the rights_attentuation_mask determines the number of
8103    /// created child tokens.
8104    ///
8105    /// The lower-index child tokens are higher priority (attempted sooner) than
8106    /// higher-index child tokens.
8107    ///
8108    /// As per all child tokens, successful aggregation will choose exactly one
8109    /// child among all created children (across all children created across
8110    /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
8111    ///
8112    /// The maximum permissible total number of children per group, and total
8113    /// number of nodes in an overall tree (from the root) are capped to limits
8114    /// which are not configurable via these protocols.
8115    CreateChildrenSync {
8116        rights_attenuation_masks: Vec<fidl::Rights>,
8117        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
8118    },
8119    /// AllChildrenPresent()
8120    ///
8121    /// After creating all children, the client must call AllChildrenPresent()
8122    /// to inform sysmem that no more children will be created, so that sysmem
8123    /// can know when it's ok to start aggregating constraints.
8124    ///
8125    /// If Close() is to be sent, it should be sent _after_
8126    /// AllChildrenPresent(), else failure of the group and propagation of the
8127    /// failure to the group's parent will still be triggered.
8128    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
8129}
8130
8131impl BufferCollectionTokenGroupRequest {
8132    #[allow(irrefutable_let_patterns)]
8133    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
8134        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
8135            Some((responder))
8136        } else {
8137            None
8138        }
8139    }
8140
8141    #[allow(irrefutable_let_patterns)]
8142    pub fn into_close(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8143        if let BufferCollectionTokenGroupRequest::Close { control_handle } = self {
8144            Some((control_handle))
8145        } else {
8146            None
8147        }
8148    }
8149
8150    #[allow(irrefutable_let_patterns)]
8151    pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenGroupControlHandle)> {
8152        if let BufferCollectionTokenGroupRequest::SetName { priority, name, control_handle } = self
8153        {
8154            Some((priority, name, control_handle))
8155        } else {
8156            None
8157        }
8158    }
8159
8160    #[allow(irrefutable_let_patterns)]
8161    pub fn into_set_debug_client_info(
8162        self,
8163    ) -> Option<(String, u64, BufferCollectionTokenGroupControlHandle)> {
8164        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { name, id, control_handle } =
8165            self
8166        {
8167            Some((name, id, control_handle))
8168        } else {
8169            None
8170        }
8171    }
8172
8173    #[allow(irrefutable_let_patterns)]
8174    pub fn into_set_debug_timeout_log_deadline(
8175        self,
8176    ) -> Option<(i64, BufferCollectionTokenGroupControlHandle)> {
8177        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
8178            deadline,
8179            control_handle,
8180        } = self
8181        {
8182            Some((deadline, control_handle))
8183        } else {
8184            None
8185        }
8186    }
8187
8188    #[allow(irrefutable_let_patterns)]
8189    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8190        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
8191            Some((control_handle))
8192        } else {
8193            None
8194        }
8195    }
8196
8197    #[allow(irrefutable_let_patterns)]
8198    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
8199        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
8200            Some((responder))
8201        } else {
8202            None
8203        }
8204    }
8205
8206    #[allow(irrefutable_let_patterns)]
8207    pub fn into_is_alternate_for(
8208        self,
8209    ) -> Option<(fidl::Event, BufferCollectionTokenGroupIsAlternateForResponder)> {
8210        if let BufferCollectionTokenGroupRequest::IsAlternateFor { node_ref, responder } = self {
8211            Some((node_ref, responder))
8212        } else {
8213            None
8214        }
8215    }
8216
8217    #[allow(irrefutable_let_patterns)]
8218    pub fn into_create_child(
8219        self,
8220    ) -> Option<(
8221        BufferCollectionTokenGroupCreateChildRequest,
8222        BufferCollectionTokenGroupControlHandle,
8223    )> {
8224        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
8225            Some((payload, control_handle))
8226        } else {
8227            None
8228        }
8229    }
8230
8231    #[allow(irrefutable_let_patterns)]
8232    pub fn into_create_children_sync(
8233        self,
8234    ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenGroupCreateChildrenSyncResponder)> {
8235        if let BufferCollectionTokenGroupRequest::CreateChildrenSync {
8236            rights_attenuation_masks,
8237            responder,
8238        } = self
8239        {
8240            Some((rights_attenuation_masks, responder))
8241        } else {
8242            None
8243        }
8244    }
8245
8246    #[allow(irrefutable_let_patterns)]
8247    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8248        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
8249            Some((control_handle))
8250        } else {
8251            None
8252        }
8253    }
8254
8255    /// Name of the method defined in FIDL
8256    pub fn method_name(&self) -> &'static str {
8257        match *self {
8258            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
8259            BufferCollectionTokenGroupRequest::Close { .. } => "close",
8260            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
8261            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
8262            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
8263                "set_debug_timeout_log_deadline"
8264            }
8265            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
8266            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
8267            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
8268            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
8269            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
8270            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
8271        }
8272    }
8273}
8274
8275#[derive(Debug, Clone)]
8276pub struct BufferCollectionTokenGroupControlHandle {
8277    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8278}
8279
8280impl fidl::endpoints::ControlHandle for BufferCollectionTokenGroupControlHandle {
8281    fn shutdown(&self) {
8282        self.inner.shutdown()
8283    }
8284
8285    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8286        self.inner.shutdown_with_epitaph(status)
8287    }
8288
8289    fn is_closed(&self) -> bool {
8290        self.inner.channel().is_closed()
8291    }
8292    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8293        self.inner.channel().on_closed()
8294    }
8295
8296    #[cfg(target_os = "fuchsia")]
8297    fn signal_peer(
8298        &self,
8299        clear_mask: zx::Signals,
8300        set_mask: zx::Signals,
8301    ) -> Result<(), zx_status::Status> {
8302        use fidl::Peered;
8303        self.inner.channel().signal_peer(clear_mask, set_mask)
8304    }
8305}
8306
8307impl BufferCollectionTokenGroupControlHandle {}
8308
8309#[must_use = "FIDL methods require a response to be sent"]
8310#[derive(Debug)]
8311pub struct BufferCollectionTokenGroupSyncResponder {
8312    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8313    tx_id: u32,
8314}
8315
8316/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8317/// if the responder is dropped without sending a response, so that the client
8318/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8319impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
8320    fn drop(&mut self) {
8321        self.control_handle.shutdown();
8322        // Safety: drops once, never accessed again
8323        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8324    }
8325}
8326
8327impl fidl::endpoints::Responder for BufferCollectionTokenGroupSyncResponder {
8328    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8329
8330    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8331        &self.control_handle
8332    }
8333
8334    fn drop_without_shutdown(mut self) {
8335        // Safety: drops once, never accessed again due to mem::forget
8336        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8337        // Prevent Drop from running (which would shut down the channel)
8338        std::mem::forget(self);
8339    }
8340}
8341
8342impl BufferCollectionTokenGroupSyncResponder {
8343    /// Sends a response to the FIDL transaction.
8344    ///
8345    /// Sets the channel to shutdown if an error occurs.
8346    pub fn send(self) -> Result<(), fidl::Error> {
8347        let _result = self.send_raw();
8348        if _result.is_err() {
8349            self.control_handle.shutdown();
8350        }
8351        self.drop_without_shutdown();
8352        _result
8353    }
8354
8355    /// Similar to "send" but does not shutdown the channel if an error occurs.
8356    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8357        let _result = self.send_raw();
8358        self.drop_without_shutdown();
8359        _result
8360    }
8361
8362    fn send_raw(&self) -> Result<(), fidl::Error> {
8363        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8364            (),
8365            self.tx_id,
8366            0x4577e238ae26291,
8367            fidl::encoding::DynamicFlags::empty(),
8368        )
8369    }
8370}
8371
8372#[must_use = "FIDL methods require a response to be sent"]
8373#[derive(Debug)]
8374pub struct BufferCollectionTokenGroupGetNodeRefResponder {
8375    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8376    tx_id: u32,
8377}
8378
8379/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8380/// if the responder is dropped without sending a response, so that the client
8381/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8382impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
8383    fn drop(&mut self) {
8384        self.control_handle.shutdown();
8385        // Safety: drops once, never accessed again
8386        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8387    }
8388}
8389
8390impl fidl::endpoints::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
8391    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8392
8393    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8394        &self.control_handle
8395    }
8396
8397    fn drop_without_shutdown(mut self) {
8398        // Safety: drops once, never accessed again due to mem::forget
8399        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8400        // Prevent Drop from running (which would shut down the channel)
8401        std::mem::forget(self);
8402    }
8403}
8404
8405impl BufferCollectionTokenGroupGetNodeRefResponder {
8406    /// Sends a response to the FIDL transaction.
8407    ///
8408    /// Sets the channel to shutdown if an error occurs.
8409    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8410        let _result = self.send_raw(node_ref);
8411        if _result.is_err() {
8412            self.control_handle.shutdown();
8413        }
8414        self.drop_without_shutdown();
8415        _result
8416    }
8417
8418    /// Similar to "send" but does not shutdown the channel if an error occurs.
8419    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8420        let _result = self.send_raw(node_ref);
8421        self.drop_without_shutdown();
8422        _result
8423    }
8424
8425    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
8426        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
8427            (node_ref,),
8428            self.tx_id,
8429            0x467b7c75c35c3b84,
8430            fidl::encoding::DynamicFlags::empty(),
8431        )
8432    }
8433}
8434
8435#[must_use = "FIDL methods require a response to be sent"]
8436#[derive(Debug)]
8437pub struct BufferCollectionTokenGroupIsAlternateForResponder {
8438    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8439    tx_id: u32,
8440}
8441
8442/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8443/// if the responder is dropped without sending a response, so that the client
8444/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8445impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
8446    fn drop(&mut self) {
8447        self.control_handle.shutdown();
8448        // Safety: drops once, never accessed again
8449        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8450    }
8451}
8452
8453impl fidl::endpoints::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
8454    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8455
8456    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8457        &self.control_handle
8458    }
8459
8460    fn drop_without_shutdown(mut self) {
8461        // Safety: drops once, never accessed again due to mem::forget
8462        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8463        // Prevent Drop from running (which would shut down the channel)
8464        std::mem::forget(self);
8465    }
8466}
8467
8468impl BufferCollectionTokenGroupIsAlternateForResponder {
8469    /// Sends a response to the FIDL transaction.
8470    ///
8471    /// Sets the channel to shutdown if an error occurs.
8472    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8473        let _result = self.send_raw(result);
8474        if _result.is_err() {
8475            self.control_handle.shutdown();
8476        }
8477        self.drop_without_shutdown();
8478        _result
8479    }
8480
8481    /// Similar to "send" but does not shutdown the channel if an error occurs.
8482    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8483        let _result = self.send_raw(result);
8484        self.drop_without_shutdown();
8485        _result
8486    }
8487
8488    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
8489        self.control_handle
8490            .inner
8491            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
8492                result.map(|is_alternate| (is_alternate,)),
8493                self.tx_id,
8494                0x33a2a7aff2776c07,
8495                fidl::encoding::DynamicFlags::empty(),
8496            )
8497    }
8498}
8499
8500#[must_use = "FIDL methods require a response to be sent"]
8501#[derive(Debug)]
8502pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
8503    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
8504    tx_id: u32,
8505}
8506
8507/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
8508/// if the responder is dropped without sending a response, so that the client
8509/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8510impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8511    fn drop(&mut self) {
8512        self.control_handle.shutdown();
8513        // Safety: drops once, never accessed again
8514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8515    }
8516}
8517
8518impl fidl::endpoints::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
8519    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8520
8521    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
8522        &self.control_handle
8523    }
8524
8525    fn drop_without_shutdown(mut self) {
8526        // Safety: drops once, never accessed again due to mem::forget
8527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8528        // Prevent Drop from running (which would shut down the channel)
8529        std::mem::forget(self);
8530    }
8531}
8532
8533impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
8534    /// Sends a response to the FIDL transaction.
8535    ///
8536    /// Sets the channel to shutdown if an error occurs.
8537    pub fn send(
8538        self,
8539        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8540    ) -> Result<(), fidl::Error> {
8541        let _result = self.send_raw(tokens);
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(
8551        self,
8552        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8553    ) -> Result<(), fidl::Error> {
8554        let _result = self.send_raw(tokens);
8555        self.drop_without_shutdown();
8556        _result
8557    }
8558
8559    fn send_raw(
8560        &self,
8561        mut tokens: Vec<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
8562    ) -> Result<(), fidl::Error> {
8563        self.control_handle.inner.send::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(
8564            (tokens.as_mut(),),
8565            self.tx_id,
8566            0x569dc3ca2a98f535,
8567            fidl::encoding::DynamicFlags::empty(),
8568        )
8569    }
8570}
8571
8572#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8573pub struct NodeMarker;
8574
8575impl fidl::endpoints::ProtocolMarker for NodeMarker {
8576    type Proxy = NodeProxy;
8577    type RequestStream = NodeRequestStream;
8578    #[cfg(target_os = "fuchsia")]
8579    type SynchronousProxy = NodeSynchronousProxy;
8580
8581    const DEBUG_NAME: &'static str = "(anonymous) Node";
8582}
8583pub type NodeIsAlternateForResult = Result<bool, i32>;
8584
8585pub trait NodeProxyInterface: Send + Sync {
8586    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8587    fn r#sync(&self) -> Self::SyncResponseFut;
8588    fn r#close(&self) -> Result<(), fidl::Error>;
8589    fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
8590    fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
8591    fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
8592    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
8593    type GetNodeRefResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
8594        + Send;
8595    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
8596    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
8597        + Send;
8598    fn r#is_alternate_for(&self, node_ref: fidl::Event) -> Self::IsAlternateForResponseFut;
8599}
8600#[derive(Debug)]
8601#[cfg(target_os = "fuchsia")]
8602pub struct NodeSynchronousProxy {
8603    client: fidl::client::sync::Client,
8604}
8605
8606#[cfg(target_os = "fuchsia")]
8607impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
8608    type Proxy = NodeProxy;
8609    type Protocol = NodeMarker;
8610
8611    fn from_channel(inner: fidl::Channel) -> Self {
8612        Self::new(inner)
8613    }
8614
8615    fn into_channel(self) -> fidl::Channel {
8616        self.client.into_channel()
8617    }
8618
8619    fn as_channel(&self) -> &fidl::Channel {
8620        self.client.as_channel()
8621    }
8622}
8623
8624#[cfg(target_os = "fuchsia")]
8625impl NodeSynchronousProxy {
8626    pub fn new(channel: fidl::Channel) -> Self {
8627        Self { client: fidl::client::sync::Client::new(channel) }
8628    }
8629
8630    pub fn into_channel(self) -> fidl::Channel {
8631        self.client.into_channel()
8632    }
8633
8634    /// Waits until an event arrives and returns it. It is safe for other
8635    /// threads to make concurrent requests while waiting for an event.
8636    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
8637        NodeEvent::decode(self.client.wait_for_event::<NodeMarker>(deadline)?)
8638    }
8639
8640    /// Ensure that previous messages, including Duplicate() messages on a
8641    /// token, collection, or group, have been received server side.
8642    ///
8643    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
8644    /// valid sysmem token risks the Sync() hanging forever.  See
8645    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
8646    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
8647    /// Another way is to pass the token to BindSharedCollection(), which also
8648    /// validates the token as part of exchanging it for a BufferCollection
8649    /// channel, and BufferCollection Sync() can then be used.
8650    ///
8651    /// After a Sync(), it's then safe to send the client end of token_request
8652    /// to another participant knowing the server will recognize the token when
8653    /// it's sent into BindSharedCollection() by the other participant.
8654    ///
8655    /// Other options include waiting for each token.Duplicate() to complete
8656    /// individually (using separate call to token.Sync() after each), or
8657    /// calling Sync() on BufferCollection after the token has been turned in
8658    /// via BindSharedCollection().
8659    ///
8660    /// Another way to mitigate is to avoid calling Sync() on the token, and
8661    /// instead later deal with potential failure of BufferCollection.Sync() if
8662    /// the original token was invalid.  This option can be preferable from a
8663    /// performance point of view, but requires client code to delay sending
8664    /// tokens duplicated from this token until after client code has converted
8665    /// the duplicating token to a BufferCollection and received successful
8666    /// response from BufferCollection.Sync().
8667    ///
8668    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
8669    /// When BufferCollection.Sync() isn't feasible, the caller must already
8670    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
8671    /// hang forever.  See ValidateBufferCollectionToken() to check token
8672    /// validity first if the token isn't already known to be (is/was) valid.
8673    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
8674        let _response = self
8675            .client
8676            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload, NodeMarker>(
8677                (),
8678                0x4577e238ae26291,
8679                fidl::encoding::DynamicFlags::empty(),
8680                ___deadline,
8681            )?;
8682        Ok(_response)
8683    }
8684
8685    /// On a BufferCollectionToken channel:
8686    ///
8687    /// Normally a participant will convert a BufferCollectionToken into a
8688    /// BufferCollection view, but a participant is also free to Close() the
8689    /// token (and then close the channel immediately or shortly later in
8690    /// response to server closing its end), which avoids causing logical buffer
8691    /// collection failure.  Normally an unexpected token channel close will
8692    /// cause logical buffer collection failure (the only exceptions being
8693    /// certain cases involving AttachToken() or SetDispensable()).
8694    ///
8695    /// On a BufferCollection channel:
8696    ///
8697    /// By default the server handles unexpected failure of a BufferCollection
8698    /// by failing the whole logical buffer collection.  Partly this is to
8699    /// expedite closing VMO handles to reclaim memory when any participant
8700    /// fails.  If a participant would like to cleanly close a BufferCollection
8701    /// view without causing logical buffer collection failure, the participant
8702    /// can send Close() before closing the client end of the BufferCollection
8703    /// channel.  If this is the last BufferCollection view, the logical buffer
8704    /// collection will still go away.  The Close() can occur before or after
8705    /// SetConstraints().  If before SetConstraints(), the buffer collection
8706    /// won't require constraints from this node in order to allocate.  If
8707    /// after SetConstraints(), the constraints are retained and aggregated
8708    /// along with any subsequent logical allocation(s), despite the lack of
8709    /// channel connection.
8710    ///
8711    /// On a BufferCollectionTokenGroup channel:
8712    ///
8713    /// By default, unexpected failure of a BufferCollectionTokenGroup will
8714    /// trigger failure of the logical BufferCollectionTokenGroup and will
8715    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
8716    /// channel without failing the logical group or propagating failure, send
8717    /// Close() before closing the channel client endpoint.
8718    ///
8719    /// If Close() occurs before AllChildrenPresent(), the logical buffer
8720    /// collection will still fail despite the Close() (because sysmem can't be
8721    /// sure whether all relevant children were created, so it's ambiguous
8722    /// whether all relevant constraints will be provided to sysmem).  If
8723    /// Close() occurs after AllChildrenPresent(), the children and all their
8724    /// constraints remain intact (just as they would if the
8725    /// BufferCollectionTokenGroup channel had remained open), and the close
8726    /// doesn't trigger or propagate failure.
8727    pub fn r#close(&self) -> Result<(), fidl::Error> {
8728        self.client.send::<fidl::encoding::EmptyPayload>(
8729            (),
8730            0x5b1d7a4f5681fca7,
8731            fidl::encoding::DynamicFlags::empty(),
8732        )
8733    }
8734
8735    /// Set a name for VMOs in this buffer collection. The name may be truncated
8736    /// shorter. The name only affects VMOs allocated after it's set - this call
8737    /// does not rename existing VMOs. If multiple clients set different names
8738    /// then the larger priority value will win.
8739    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
8740        self.client.send::<NodeSetNameRequest>(
8741            (priority, name),
8742            0x77a41bb6217e2443,
8743            fidl::encoding::DynamicFlags::empty(),
8744        )
8745    }
8746
8747    /// Set information about the current client that can be used by sysmem to
8748    /// help debug leaking memory and hangs waiting for constraints. |name| can
8749    /// be an arbitrary string, but the current process name (see
8750    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
8751    /// arbitrary id, but the current process ID (see
8752    /// fsl::GetCurrentProcessKoid()) is a good default.
8753    ///
8754    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
8755    /// indicate which client is closing their channel first, leading to
8756    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
8757    /// over, but if happening earlier than expected, the
8758    /// client-channel-specific name can help diagnose where the failure is
8759    /// first coming from, from sysmem's point of view).
8760    ///
8761    /// By default (unless overriden by this message or using
8762    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
8763    /// parent Node at the time the child Node is created.  While this can be
8764    /// better than nothing, it's often better for each participant to use
8765    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
8766    /// info directly relevant to the current client.  Also, SetVerboseLogging()
8767    /// can be used to help disambiguate if a Node is suspected of having info
8768    /// that was copied from its parent.
8769    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
8770        self.client.send::<NodeSetDebugClientInfoRequest>(
8771            (name, id),
8772            0x7275759070eb5ee2,
8773            fidl::encoding::DynamicFlags::empty(),
8774        )
8775    }
8776
8777    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
8778    /// after creating a collection. Clients can call this method to change
8779    /// when the log is printed. If multiple client set the deadline, it's
8780    /// unspecified which deadline will take effect.
8781    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
8782        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
8783            (deadline,),
8784            0x46d38f4772638867,
8785            fidl::encoding::DynamicFlags::empty(),
8786        )
8787    }
8788
8789    /// Verbose logging includes constraints set via SetConstraints() from each
8790    /// client along with info set via SetDebugClientInfo() and the structure of
8791    /// the tree of Node(s).
8792    ///
8793    /// Normally sysmem prints only a single line complaint when aggregation
8794    /// fails, with just the specific detailed reason that aggregation failed,
8795    /// with minimal context.  While this is often enough to diagnose a problem
8796    /// if only a small change was made and the system had been working before
8797    /// the small change, it's often not particularly helpful for getting a new
8798    /// buffer collection to work for the first time.  Especially with more
8799    /// complex trees of nodes, involving things like AttachToken(),
8800    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
8801    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
8802    /// looks like and why it's failing a logical allocation, or why a tree or
8803    /// sub-tree is failing sooner than expected.
8804    ///
8805    /// The intent of the extra logging is to be acceptable from a performance
8806    /// point of view, if only enabled on a low number of buffer collections.
8807    /// If we're not tracking down a bug, we shouldn't send this message.
8808    ///
8809    /// If too many participants leave verbose logging enabled, we may end up
8810    /// needing to require that system-wide sysmem verbose logging be permitted
8811    /// via some other setting, to avoid sysmem spamming the log too much due to
8812    /// this message.
8813    ///
8814    /// This may be a NOP for some nodes due to intentional policy associated
8815    /// with the node, if we don't trust a node enough to let it turn on verbose
8816    /// logging.
8817    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
8818        self.client.send::<fidl::encoding::EmptyPayload>(
8819            (),
8820            0x6bfbe2cf1701d288,
8821            fidl::encoding::DynamicFlags::empty(),
8822        )
8823    }
8824
8825    /// This gets an event handle that can be used as a parameter to
8826    /// IsAlternateFor() called on any Node.  The client will not be granted the
8827    /// right to signal this event, as this handle should only be used as proof
8828    /// that the client obtained this handle from this Node.
8829    ///
8830    /// Because this is a get not a set, no Sync() is needed between the
8831    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
8832    /// potentially being on different channels.
8833    ///
8834    /// See also IsAlternateFor().
8835    pub fn r#get_node_ref(
8836        &self,
8837        ___deadline: zx::MonotonicInstant,
8838    ) -> Result<fidl::Event, fidl::Error> {
8839        let _response = self
8840            .client
8841            .send_query::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse, NodeMarker>(
8842                (),
8843                0x467b7c75c35c3b84,
8844                fidl::encoding::DynamicFlags::empty(),
8845                ___deadline,
8846            )?;
8847        Ok(_response.node_ref)
8848    }
8849
8850    /// This checks whether the calling node is in a subtree rooted at a
8851    /// different child token of a common parent BufferCollectionTokenGroup, in
8852    /// relation to the passed-in node_ref.
8853    ///
8854    /// This call is for assisting with admission control de-duplication, and
8855    /// with debugging.
8856    ///
8857    /// The node_ref must be obtained using GetNodeRef() of a
8858    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
8859    ///
8860    /// The node_ref can be a duplicated handle; it's not necessary to call
8861    /// GetNodeRef() for every call to IsAlternateFor().
8862    ///
8863    /// If a calling token may not actually be a valid token at all due to
8864    /// a potentially hostile/untrusted provider of the token, call
8865    /// ValidateBufferCollectionToken() first instead of potentially getting
8866    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
8867    /// token not being a real token (not really talking to sysmem).  Another
8868    /// option is to call BindSharedCollection with this token first which also
8869    /// validates the token along with converting it to a BufferCollection, then
8870    /// call BufferCollection IsAlternateFor().
8871    ///
8872    /// error values:
8873    ///
8874    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
8875    /// buffer collection as the calling Node.  Before logical allocation and
8876    /// within the same logical allocation sub-tree, this essentially means that
8877    /// the node_ref was never part of this logical buffer collection, since
8878    /// before logical allocation all node_refs that come into existence remain
8879    /// in existence at least until logical allocation (including Node(s) that
8880    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
8881    /// to be returned, this Node's channel needs to still be connected server
8882    /// side, which won't be the case if the whole logical allocation has
8883    /// failed.  After logical allocation or in a different logical allocation
8884    /// sub-tree there are additional potential reasons for this error.  For
8885    /// example a different logical allocation (separated from this Node(s)
8886    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
8887    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
8888    /// exist and may select a different child sub-tree than the sub-tree the
8889    /// node_ref is in causing deletion of the node_ref Node.  The only time
8890    /// sysmem keeps a Node around after that Node has no corresponding channel
8891    /// is when Close() is used and the Node's sub-tree has not yet failed.
8892    /// Another reason for this error is if the node_ref is an eventpair handle
8893    /// with sufficient rights, but isn't actually a real node_ref obtained from
8894    /// GetNodeRef().
8895    ///
8896    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
8897    /// eventpair handle, or doesn't have the needed rights expected on a real
8898    /// node_ref.
8899    ///
8900    /// No other failing status codes are returned by this call.  However,
8901    /// sysmem may add additional codes in future, so the client should have
8902    /// sensible default handling for any failing status code.
8903    ///
8904    /// On success, is_alternate has the following meaning:
8905    ///   * true - The first parent node in common between the calling node and
8906    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
8907    ///     the calling Node and the node_ref Node will _not_ have both their
8908    ///     constraints apply - rather sysmem will choose one or the other of
8909    ///     the constraints - never both.  This is because only one child of
8910    ///     a BufferCollectionTokenGroup is selected during logical allocation,
8911    ///     with only that one child's sub-tree contributing to constraints
8912    ///     aggregation.
8913    ///   * false - The first parent node in common between the calling Node and
8914    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
8915    ///     this means the first parent node in common is a
8916    ///     BufferCollectionToken or BufferCollection (regardless of not
8917    ///     Close()ed or Close()ed).  This means that the calling Node and the
8918    ///     node_ref Node _may_ have both their constraints apply during
8919    ///     constraints aggregation of the logical allocation, if both Node(s)
8920    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
8921    ///     In this case, there is no BufferCollectionTokenGroup that will
8922    ///     directly prevent the two Node(s) from both being selected and their
8923    ///     constraints both aggregated, but even when false, one or both
8924    ///     Node(s) may still be eliminated from consideration if one or both
8925    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
8926    ///     which selects a child sub-tree other than the sub-tree containing
8927    ///     the calling Node or node_ref Node.
8928    pub fn r#is_alternate_for(
8929        &self,
8930        mut node_ref: fidl::Event,
8931        ___deadline: zx::MonotonicInstant,
8932    ) -> Result<NodeIsAlternateForResult, fidl::Error> {
8933        let _response = self.client.send_query::<
8934            NodeIsAlternateForRequest,
8935            fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
8936            NodeMarker,
8937        >(
8938            (node_ref,),
8939            0x33a2a7aff2776c07,
8940            fidl::encoding::DynamicFlags::empty(),
8941            ___deadline,
8942        )?;
8943        Ok(_response.map(|x| x.is_alternate))
8944    }
8945}
8946
8947#[cfg(target_os = "fuchsia")]
8948impl From<NodeSynchronousProxy> for zx::NullableHandle {
8949    fn from(value: NodeSynchronousProxy) -> Self {
8950        value.into_channel().into()
8951    }
8952}
8953
8954#[cfg(target_os = "fuchsia")]
8955impl From<fidl::Channel> for NodeSynchronousProxy {
8956    fn from(value: fidl::Channel) -> Self {
8957        Self::new(value)
8958    }
8959}
8960
8961#[cfg(target_os = "fuchsia")]
8962impl fidl::endpoints::FromClient for NodeSynchronousProxy {
8963    type Protocol = NodeMarker;
8964
8965    fn from_client(value: fidl::endpoints::ClientEnd<NodeMarker>) -> Self {
8966        Self::new(value.into_channel())
8967    }
8968}
8969
8970#[derive(Debug, Clone)]
8971pub struct NodeProxy {
8972    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8973}
8974
8975impl fidl::endpoints::Proxy for NodeProxy {
8976    type Protocol = NodeMarker;
8977
8978    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8979        Self::new(inner)
8980    }
8981
8982    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8983        self.client.into_channel().map_err(|client| Self { client })
8984    }
8985
8986    fn as_channel(&self) -> &::fidl::AsyncChannel {
8987        self.client.as_channel()
8988    }
8989}
8990
8991impl NodeProxy {
8992    /// Create a new Proxy for fuchsia.sysmem/Node.
8993    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8994        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8995        Self { client: fidl::client::Client::new(channel, protocol_name) }
8996    }
8997
8998    /// Get a Stream of events from the remote end of the protocol.
8999    ///
9000    /// # Panics
9001    ///
9002    /// Panics if the event stream was already taken.
9003    pub fn take_event_stream(&self) -> NodeEventStream {
9004        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9005    }
9006
9007    /// Ensure that previous messages, including Duplicate() messages on a
9008    /// token, collection, or group, have been received server side.
9009    ///
9010    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9011    /// valid sysmem token risks the Sync() hanging forever.  See
9012    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9013    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9014    /// Another way is to pass the token to BindSharedCollection(), which also
9015    /// validates the token as part of exchanging it for a BufferCollection
9016    /// channel, and BufferCollection Sync() can then be used.
9017    ///
9018    /// After a Sync(), it's then safe to send the client end of token_request
9019    /// to another participant knowing the server will recognize the token when
9020    /// it's sent into BindSharedCollection() by the other participant.
9021    ///
9022    /// Other options include waiting for each token.Duplicate() to complete
9023    /// individually (using separate call to token.Sync() after each), or
9024    /// calling Sync() on BufferCollection after the token has been turned in
9025    /// via BindSharedCollection().
9026    ///
9027    /// Another way to mitigate is to avoid calling Sync() on the token, and
9028    /// instead later deal with potential failure of BufferCollection.Sync() if
9029    /// the original token was invalid.  This option can be preferable from a
9030    /// performance point of view, but requires client code to delay sending
9031    /// tokens duplicated from this token until after client code has converted
9032    /// the duplicating token to a BufferCollection and received successful
9033    /// response from BufferCollection.Sync().
9034    ///
9035    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9036    /// When BufferCollection.Sync() isn't feasible, the caller must already
9037    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9038    /// hang forever.  See ValidateBufferCollectionToken() to check token
9039    /// validity first if the token isn't already known to be (is/was) valid.
9040    pub fn r#sync(
9041        &self,
9042    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
9043        NodeProxyInterface::r#sync(self)
9044    }
9045
9046    /// On a BufferCollectionToken channel:
9047    ///
9048    /// Normally a participant will convert a BufferCollectionToken into a
9049    /// BufferCollection view, but a participant is also free to Close() the
9050    /// token (and then close the channel immediately or shortly later in
9051    /// response to server closing its end), which avoids causing logical buffer
9052    /// collection failure.  Normally an unexpected token channel close will
9053    /// cause logical buffer collection failure (the only exceptions being
9054    /// certain cases involving AttachToken() or SetDispensable()).
9055    ///
9056    /// On a BufferCollection channel:
9057    ///
9058    /// By default the server handles unexpected failure of a BufferCollection
9059    /// by failing the whole logical buffer collection.  Partly this is to
9060    /// expedite closing VMO handles to reclaim memory when any participant
9061    /// fails.  If a participant would like to cleanly close a BufferCollection
9062    /// view without causing logical buffer collection failure, the participant
9063    /// can send Close() before closing the client end of the BufferCollection
9064    /// channel.  If this is the last BufferCollection view, the logical buffer
9065    /// collection will still go away.  The Close() can occur before or after
9066    /// SetConstraints().  If before SetConstraints(), the buffer collection
9067    /// won't require constraints from this node in order to allocate.  If
9068    /// after SetConstraints(), the constraints are retained and aggregated
9069    /// along with any subsequent logical allocation(s), despite the lack of
9070    /// channel connection.
9071    ///
9072    /// On a BufferCollectionTokenGroup channel:
9073    ///
9074    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9075    /// trigger failure of the logical BufferCollectionTokenGroup and will
9076    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9077    /// channel without failing the logical group or propagating failure, send
9078    /// Close() before closing the channel client endpoint.
9079    ///
9080    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9081    /// collection will still fail despite the Close() (because sysmem can't be
9082    /// sure whether all relevant children were created, so it's ambiguous
9083    /// whether all relevant constraints will be provided to sysmem).  If
9084    /// Close() occurs after AllChildrenPresent(), the children and all their
9085    /// constraints remain intact (just as they would if the
9086    /// BufferCollectionTokenGroup channel had remained open), and the close
9087    /// doesn't trigger or propagate failure.
9088    pub fn r#close(&self) -> Result<(), fidl::Error> {
9089        NodeProxyInterface::r#close(self)
9090    }
9091
9092    /// Set a name for VMOs in this buffer collection. The name may be truncated
9093    /// shorter. The name only affects VMOs allocated after it's set - this call
9094    /// does not rename existing VMOs. If multiple clients set different names
9095    /// then the larger priority value will win.
9096    pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9097        NodeProxyInterface::r#set_name(self, priority, name)
9098    }
9099
9100    /// Set information about the current client that can be used by sysmem to
9101    /// help debug leaking memory and hangs waiting for constraints. |name| can
9102    /// be an arbitrary string, but the current process name (see
9103    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9104    /// arbitrary id, but the current process ID (see
9105    /// fsl::GetCurrentProcessKoid()) is a good default.
9106    ///
9107    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9108    /// indicate which client is closing their channel first, leading to
9109    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9110    /// over, but if happening earlier than expected, the
9111    /// client-channel-specific name can help diagnose where the failure is
9112    /// first coming from, from sysmem's point of view).
9113    ///
9114    /// By default (unless overriden by this message or using
9115    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9116    /// parent Node at the time the child Node is created.  While this can be
9117    /// better than nothing, it's often better for each participant to use
9118    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9119    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9120    /// can be used to help disambiguate if a Node is suspected of having info
9121    /// that was copied from its parent.
9122    pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9123        NodeProxyInterface::r#set_debug_client_info(self, name, id)
9124    }
9125
9126    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9127    /// after creating a collection. Clients can call this method to change
9128    /// when the log is printed. If multiple client set the deadline, it's
9129    /// unspecified which deadline will take effect.
9130    pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9131        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
9132    }
9133
9134    /// Verbose logging includes constraints set via SetConstraints() from each
9135    /// client along with info set via SetDebugClientInfo() and the structure of
9136    /// the tree of Node(s).
9137    ///
9138    /// Normally sysmem prints only a single line complaint when aggregation
9139    /// fails, with just the specific detailed reason that aggregation failed,
9140    /// with minimal context.  While this is often enough to diagnose a problem
9141    /// if only a small change was made and the system had been working before
9142    /// the small change, it's often not particularly helpful for getting a new
9143    /// buffer collection to work for the first time.  Especially with more
9144    /// complex trees of nodes, involving things like AttachToken(),
9145    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9146    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9147    /// looks like and why it's failing a logical allocation, or why a tree or
9148    /// sub-tree is failing sooner than expected.
9149    ///
9150    /// The intent of the extra logging is to be acceptable from a performance
9151    /// point of view, if only enabled on a low number of buffer collections.
9152    /// If we're not tracking down a bug, we shouldn't send this message.
9153    ///
9154    /// If too many participants leave verbose logging enabled, we may end up
9155    /// needing to require that system-wide sysmem verbose logging be permitted
9156    /// via some other setting, to avoid sysmem spamming the log too much due to
9157    /// this message.
9158    ///
9159    /// This may be a NOP for some nodes due to intentional policy associated
9160    /// with the node, if we don't trust a node enough to let it turn on verbose
9161    /// logging.
9162    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9163        NodeProxyInterface::r#set_verbose_logging(self)
9164    }
9165
9166    /// This gets an event handle that can be used as a parameter to
9167    /// IsAlternateFor() called on any Node.  The client will not be granted the
9168    /// right to signal this event, as this handle should only be used as proof
9169    /// that the client obtained this handle from this Node.
9170    ///
9171    /// Because this is a get not a set, no Sync() is needed between the
9172    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9173    /// potentially being on different channels.
9174    ///
9175    /// See also IsAlternateFor().
9176    pub fn r#get_node_ref(
9177        &self,
9178    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
9179    {
9180        NodeProxyInterface::r#get_node_ref(self)
9181    }
9182
9183    /// This checks whether the calling node is in a subtree rooted at a
9184    /// different child token of a common parent BufferCollectionTokenGroup, in
9185    /// relation to the passed-in node_ref.
9186    ///
9187    /// This call is for assisting with admission control de-duplication, and
9188    /// with debugging.
9189    ///
9190    /// The node_ref must be obtained using GetNodeRef() of a
9191    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9192    ///
9193    /// The node_ref can be a duplicated handle; it's not necessary to call
9194    /// GetNodeRef() for every call to IsAlternateFor().
9195    ///
9196    /// If a calling token may not actually be a valid token at all due to
9197    /// a potentially hostile/untrusted provider of the token, call
9198    /// ValidateBufferCollectionToken() first instead of potentially getting
9199    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9200    /// token not being a real token (not really talking to sysmem).  Another
9201    /// option is to call BindSharedCollection with this token first which also
9202    /// validates the token along with converting it to a BufferCollection, then
9203    /// call BufferCollection IsAlternateFor().
9204    ///
9205    /// error values:
9206    ///
9207    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9208    /// buffer collection as the calling Node.  Before logical allocation and
9209    /// within the same logical allocation sub-tree, this essentially means that
9210    /// the node_ref was never part of this logical buffer collection, since
9211    /// before logical allocation all node_refs that come into existence remain
9212    /// in existence at least until logical allocation (including Node(s) that
9213    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9214    /// to be returned, this Node's channel needs to still be connected server
9215    /// side, which won't be the case if the whole logical allocation has
9216    /// failed.  After logical allocation or in a different logical allocation
9217    /// sub-tree there are additional potential reasons for this error.  For
9218    /// example a different logical allocation (separated from this Node(s)
9219    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9220    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9221    /// exist and may select a different child sub-tree than the sub-tree the
9222    /// node_ref is in causing deletion of the node_ref Node.  The only time
9223    /// sysmem keeps a Node around after that Node has no corresponding channel
9224    /// is when Close() is used and the Node's sub-tree has not yet failed.
9225    /// Another reason for this error is if the node_ref is an eventpair handle
9226    /// with sufficient rights, but isn't actually a real node_ref obtained from
9227    /// GetNodeRef().
9228    ///
9229    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9230    /// eventpair handle, or doesn't have the needed rights expected on a real
9231    /// node_ref.
9232    ///
9233    /// No other failing status codes are returned by this call.  However,
9234    /// sysmem may add additional codes in future, so the client should have
9235    /// sensible default handling for any failing status code.
9236    ///
9237    /// On success, is_alternate has the following meaning:
9238    ///   * true - The first parent node in common between the calling node and
9239    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9240    ///     the calling Node and the node_ref Node will _not_ have both their
9241    ///     constraints apply - rather sysmem will choose one or the other of
9242    ///     the constraints - never both.  This is because only one child of
9243    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9244    ///     with only that one child's sub-tree contributing to constraints
9245    ///     aggregation.
9246    ///   * false - The first parent node in common between the calling Node and
9247    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9248    ///     this means the first parent node in common is a
9249    ///     BufferCollectionToken or BufferCollection (regardless of not
9250    ///     Close()ed or Close()ed).  This means that the calling Node and the
9251    ///     node_ref Node _may_ have both their constraints apply during
9252    ///     constraints aggregation of the logical allocation, if both Node(s)
9253    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9254    ///     In this case, there is no BufferCollectionTokenGroup that will
9255    ///     directly prevent the two Node(s) from both being selected and their
9256    ///     constraints both aggregated, but even when false, one or both
9257    ///     Node(s) may still be eliminated from consideration if one or both
9258    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9259    ///     which selects a child sub-tree other than the sub-tree containing
9260    ///     the calling Node or node_ref Node.
9261    pub fn r#is_alternate_for(
9262        &self,
9263        mut node_ref: fidl::Event,
9264    ) -> fidl::client::QueryResponseFut<
9265        NodeIsAlternateForResult,
9266        fidl::encoding::DefaultFuchsiaResourceDialect,
9267    > {
9268        NodeProxyInterface::r#is_alternate_for(self, node_ref)
9269    }
9270}
9271
9272impl NodeProxyInterface for NodeProxy {
9273    type SyncResponseFut =
9274        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9275    fn r#sync(&self) -> Self::SyncResponseFut {
9276        fn _decode(
9277            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9278        ) -> Result<(), fidl::Error> {
9279            let _response = fidl::client::decode_transaction_body::<
9280                fidl::encoding::EmptyPayload,
9281                fidl::encoding::DefaultFuchsiaResourceDialect,
9282                0x4577e238ae26291,
9283            >(_buf?)?;
9284            Ok(_response)
9285        }
9286        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9287            (),
9288            0x4577e238ae26291,
9289            fidl::encoding::DynamicFlags::empty(),
9290            _decode,
9291        )
9292    }
9293
9294    fn r#close(&self) -> Result<(), fidl::Error> {
9295        self.client.send::<fidl::encoding::EmptyPayload>(
9296            (),
9297            0x5b1d7a4f5681fca7,
9298            fidl::encoding::DynamicFlags::empty(),
9299        )
9300    }
9301
9302    fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
9303        self.client.send::<NodeSetNameRequest>(
9304            (priority, name),
9305            0x77a41bb6217e2443,
9306            fidl::encoding::DynamicFlags::empty(),
9307        )
9308    }
9309
9310    fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
9311        self.client.send::<NodeSetDebugClientInfoRequest>(
9312            (name, id),
9313            0x7275759070eb5ee2,
9314            fidl::encoding::DynamicFlags::empty(),
9315        )
9316    }
9317
9318    fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
9319        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
9320            (deadline,),
9321            0x46d38f4772638867,
9322            fidl::encoding::DynamicFlags::empty(),
9323        )
9324    }
9325
9326    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9327        self.client.send::<fidl::encoding::EmptyPayload>(
9328            (),
9329            0x6bfbe2cf1701d288,
9330            fidl::encoding::DynamicFlags::empty(),
9331        )
9332    }
9333
9334    type GetNodeRefResponseFut =
9335        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
9336    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
9337        fn _decode(
9338            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9339        ) -> Result<fidl::Event, fidl::Error> {
9340            let _response = fidl::client::decode_transaction_body::<
9341                NodeGetNodeRefResponse,
9342                fidl::encoding::DefaultFuchsiaResourceDialect,
9343                0x467b7c75c35c3b84,
9344            >(_buf?)?;
9345            Ok(_response.node_ref)
9346        }
9347        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
9348            (),
9349            0x467b7c75c35c3b84,
9350            fidl::encoding::DynamicFlags::empty(),
9351            _decode,
9352        )
9353    }
9354
9355    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
9356        NodeIsAlternateForResult,
9357        fidl::encoding::DefaultFuchsiaResourceDialect,
9358    >;
9359    fn r#is_alternate_for(&self, mut node_ref: fidl::Event) -> Self::IsAlternateForResponseFut {
9360        fn _decode(
9361            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9362        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
9363            let _response = fidl::client::decode_transaction_body::<
9364                fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
9365                fidl::encoding::DefaultFuchsiaResourceDialect,
9366                0x33a2a7aff2776c07,
9367            >(_buf?)?;
9368            Ok(_response.map(|x| x.is_alternate))
9369        }
9370        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
9371            (node_ref,),
9372            0x33a2a7aff2776c07,
9373            fidl::encoding::DynamicFlags::empty(),
9374            _decode,
9375        )
9376    }
9377}
9378
9379pub struct NodeEventStream {
9380    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9381}
9382
9383impl std::marker::Unpin for NodeEventStream {}
9384
9385impl futures::stream::FusedStream for NodeEventStream {
9386    fn is_terminated(&self) -> bool {
9387        self.event_receiver.is_terminated()
9388    }
9389}
9390
9391impl futures::Stream for NodeEventStream {
9392    type Item = Result<NodeEvent, fidl::Error>;
9393
9394    fn poll_next(
9395        mut self: std::pin::Pin<&mut Self>,
9396        cx: &mut std::task::Context<'_>,
9397    ) -> std::task::Poll<Option<Self::Item>> {
9398        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9399            &mut self.event_receiver,
9400            cx
9401        )?) {
9402            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
9403            None => std::task::Poll::Ready(None),
9404        }
9405    }
9406}
9407
9408#[derive(Debug)]
9409pub enum NodeEvent {}
9410
9411impl NodeEvent {
9412    /// Decodes a message buffer as a [`NodeEvent`].
9413    fn decode(
9414        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9415    ) -> Result<NodeEvent, fidl::Error> {
9416        let (bytes, _handles) = buf.split_mut();
9417        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9418        debug_assert_eq!(tx_header.tx_id, 0);
9419        match tx_header.ordinal {
9420            _ => Err(fidl::Error::UnknownOrdinal {
9421                ordinal: tx_header.ordinal,
9422                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9423            }),
9424        }
9425    }
9426}
9427
9428/// A Stream of incoming requests for fuchsia.sysmem/Node.
9429pub struct NodeRequestStream {
9430    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9431    is_terminated: bool,
9432}
9433
9434impl std::marker::Unpin for NodeRequestStream {}
9435
9436impl futures::stream::FusedStream for NodeRequestStream {
9437    fn is_terminated(&self) -> bool {
9438        self.is_terminated
9439    }
9440}
9441
9442impl fidl::endpoints::RequestStream for NodeRequestStream {
9443    type Protocol = NodeMarker;
9444    type ControlHandle = NodeControlHandle;
9445
9446    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9447        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9448    }
9449
9450    fn control_handle(&self) -> Self::ControlHandle {
9451        NodeControlHandle { inner: self.inner.clone() }
9452    }
9453
9454    fn into_inner(
9455        self,
9456    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9457    {
9458        (self.inner, self.is_terminated)
9459    }
9460
9461    fn from_inner(
9462        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9463        is_terminated: bool,
9464    ) -> Self {
9465        Self { inner, is_terminated }
9466    }
9467}
9468
9469impl futures::Stream for NodeRequestStream {
9470    type Item = Result<NodeRequest, fidl::Error>;
9471
9472    fn poll_next(
9473        mut self: std::pin::Pin<&mut Self>,
9474        cx: &mut std::task::Context<'_>,
9475    ) -> std::task::Poll<Option<Self::Item>> {
9476        let this = &mut *self;
9477        if this.inner.check_shutdown(cx) {
9478            this.is_terminated = true;
9479            return std::task::Poll::Ready(None);
9480        }
9481        if this.is_terminated {
9482            panic!("polled NodeRequestStream after completion");
9483        }
9484        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9485            |bytes, handles| {
9486                match this.inner.channel().read_etc(cx, bytes, handles) {
9487                    std::task::Poll::Ready(Ok(())) => {}
9488                    std::task::Poll::Pending => return std::task::Poll::Pending,
9489                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9490                        this.is_terminated = true;
9491                        return std::task::Poll::Ready(None);
9492                    }
9493                    std::task::Poll::Ready(Err(e)) => {
9494                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9495                            e.into(),
9496                        ))));
9497                    }
9498                }
9499
9500                // A message has been received from the channel
9501                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9502
9503                std::task::Poll::Ready(Some(match header.ordinal {
9504                    0x4577e238ae26291 => {
9505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9506                        let mut req = fidl::new_empty!(
9507                            fidl::encoding::EmptyPayload,
9508                            fidl::encoding::DefaultFuchsiaResourceDialect
9509                        );
9510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9511                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9512                        Ok(NodeRequest::Sync {
9513                            responder: NodeSyncResponder {
9514                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9515                                tx_id: header.tx_id,
9516                            },
9517                        })
9518                    }
9519                    0x5b1d7a4f5681fca7 => {
9520                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9521                        let mut req = fidl::new_empty!(
9522                            fidl::encoding::EmptyPayload,
9523                            fidl::encoding::DefaultFuchsiaResourceDialect
9524                        );
9525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9526                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9527                        Ok(NodeRequest::Close { control_handle })
9528                    }
9529                    0x77a41bb6217e2443 => {
9530                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9531                        let mut req = fidl::new_empty!(
9532                            NodeSetNameRequest,
9533                            fidl::encoding::DefaultFuchsiaResourceDialect
9534                        );
9535                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
9536                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9537                        Ok(NodeRequest::SetName {
9538                            priority: req.priority,
9539                            name: req.name,
9540
9541                            control_handle,
9542                        })
9543                    }
9544                    0x7275759070eb5ee2 => {
9545                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9546                        let mut req = fidl::new_empty!(
9547                            NodeSetDebugClientInfoRequest,
9548                            fidl::encoding::DefaultFuchsiaResourceDialect
9549                        );
9550                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
9551                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9552                        Ok(NodeRequest::SetDebugClientInfo {
9553                            name: req.name,
9554                            id: req.id,
9555
9556                            control_handle,
9557                        })
9558                    }
9559                    0x46d38f4772638867 => {
9560                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9561                        let mut req = fidl::new_empty!(
9562                            NodeSetDebugTimeoutLogDeadlineRequest,
9563                            fidl::encoding::DefaultFuchsiaResourceDialect
9564                        );
9565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
9566                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9567                        Ok(NodeRequest::SetDebugTimeoutLogDeadline {
9568                            deadline: req.deadline,
9569
9570                            control_handle,
9571                        })
9572                    }
9573                    0x6bfbe2cf1701d288 => {
9574                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9575                        let mut req = fidl::new_empty!(
9576                            fidl::encoding::EmptyPayload,
9577                            fidl::encoding::DefaultFuchsiaResourceDialect
9578                        );
9579                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9580                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9581                        Ok(NodeRequest::SetVerboseLogging { control_handle })
9582                    }
9583                    0x467b7c75c35c3b84 => {
9584                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9585                        let mut req = fidl::new_empty!(
9586                            fidl::encoding::EmptyPayload,
9587                            fidl::encoding::DefaultFuchsiaResourceDialect
9588                        );
9589                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9590                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9591                        Ok(NodeRequest::GetNodeRef {
9592                            responder: NodeGetNodeRefResponder {
9593                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9594                                tx_id: header.tx_id,
9595                            },
9596                        })
9597                    }
9598                    0x33a2a7aff2776c07 => {
9599                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9600                        let mut req = fidl::new_empty!(
9601                            NodeIsAlternateForRequest,
9602                            fidl::encoding::DefaultFuchsiaResourceDialect
9603                        );
9604                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
9605                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
9606                        Ok(NodeRequest::IsAlternateFor {
9607                            node_ref: req.node_ref,
9608
9609                            responder: NodeIsAlternateForResponder {
9610                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9611                                tx_id: header.tx_id,
9612                            },
9613                        })
9614                    }
9615                    _ => Err(fidl::Error::UnknownOrdinal {
9616                        ordinal: header.ordinal,
9617                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9618                    }),
9619                }))
9620            },
9621        )
9622    }
9623}
9624
9625#[derive(Debug)]
9626pub enum NodeRequest {
9627    /// Ensure that previous messages, including Duplicate() messages on a
9628    /// token, collection, or group, have been received server side.
9629    ///
9630    /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
9631    /// valid sysmem token risks the Sync() hanging forever.  See
9632    /// ValidateBufferCollectionToken() for one way to mitigate the possibility
9633    /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
9634    /// Another way is to pass the token to BindSharedCollection(), which also
9635    /// validates the token as part of exchanging it for a BufferCollection
9636    /// channel, and BufferCollection Sync() can then be used.
9637    ///
9638    /// After a Sync(), it's then safe to send the client end of token_request
9639    /// to another participant knowing the server will recognize the token when
9640    /// it's sent into BindSharedCollection() by the other participant.
9641    ///
9642    /// Other options include waiting for each token.Duplicate() to complete
9643    /// individually (using separate call to token.Sync() after each), or
9644    /// calling Sync() on BufferCollection after the token has been turned in
9645    /// via BindSharedCollection().
9646    ///
9647    /// Another way to mitigate is to avoid calling Sync() on the token, and
9648    /// instead later deal with potential failure of BufferCollection.Sync() if
9649    /// the original token was invalid.  This option can be preferable from a
9650    /// performance point of view, but requires client code to delay sending
9651    /// tokens duplicated from this token until after client code has converted
9652    /// the duplicating token to a BufferCollection and received successful
9653    /// response from BufferCollection.Sync().
9654    ///
9655    /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
9656    /// When BufferCollection.Sync() isn't feasible, the caller must already
9657    /// know that this token is/was valid, or BufferCollectionToken.Sync() may
9658    /// hang forever.  See ValidateBufferCollectionToken() to check token
9659    /// validity first if the token isn't already known to be (is/was) valid.
9660    Sync { responder: NodeSyncResponder },
9661    /// On a BufferCollectionToken channel:
9662    ///
9663    /// Normally a participant will convert a BufferCollectionToken into a
9664    /// BufferCollection view, but a participant is also free to Close() the
9665    /// token (and then close the channel immediately or shortly later in
9666    /// response to server closing its end), which avoids causing logical buffer
9667    /// collection failure.  Normally an unexpected token channel close will
9668    /// cause logical buffer collection failure (the only exceptions being
9669    /// certain cases involving AttachToken() or SetDispensable()).
9670    ///
9671    /// On a BufferCollection channel:
9672    ///
9673    /// By default the server handles unexpected failure of a BufferCollection
9674    /// by failing the whole logical buffer collection.  Partly this is to
9675    /// expedite closing VMO handles to reclaim memory when any participant
9676    /// fails.  If a participant would like to cleanly close a BufferCollection
9677    /// view without causing logical buffer collection failure, the participant
9678    /// can send Close() before closing the client end of the BufferCollection
9679    /// channel.  If this is the last BufferCollection view, the logical buffer
9680    /// collection will still go away.  The Close() can occur before or after
9681    /// SetConstraints().  If before SetConstraints(), the buffer collection
9682    /// won't require constraints from this node in order to allocate.  If
9683    /// after SetConstraints(), the constraints are retained and aggregated
9684    /// along with any subsequent logical allocation(s), despite the lack of
9685    /// channel connection.
9686    ///
9687    /// On a BufferCollectionTokenGroup channel:
9688    ///
9689    /// By default, unexpected failure of a BufferCollectionTokenGroup will
9690    /// trigger failure of the logical BufferCollectionTokenGroup and will
9691    /// propagate failure to its parent.  To close a BufferCollectionTokenGroup
9692    /// channel without failing the logical group or propagating failure, send
9693    /// Close() before closing the channel client endpoint.
9694    ///
9695    /// If Close() occurs before AllChildrenPresent(), the logical buffer
9696    /// collection will still fail despite the Close() (because sysmem can't be
9697    /// sure whether all relevant children were created, so it's ambiguous
9698    /// whether all relevant constraints will be provided to sysmem).  If
9699    /// Close() occurs after AllChildrenPresent(), the children and all their
9700    /// constraints remain intact (just as they would if the
9701    /// BufferCollectionTokenGroup channel had remained open), and the close
9702    /// doesn't trigger or propagate failure.
9703    Close { control_handle: NodeControlHandle },
9704    /// Set a name for VMOs in this buffer collection. The name may be truncated
9705    /// shorter. The name only affects VMOs allocated after it's set - this call
9706    /// does not rename existing VMOs. If multiple clients set different names
9707    /// then the larger priority value will win.
9708    SetName { priority: u32, name: String, control_handle: NodeControlHandle },
9709    /// Set information about the current client that can be used by sysmem to
9710    /// help debug leaking memory and hangs waiting for constraints. |name| can
9711    /// be an arbitrary string, but the current process name (see
9712    /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
9713    /// arbitrary id, but the current process ID (see
9714    /// fsl::GetCurrentProcessKoid()) is a good default.
9715    ///
9716    /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
9717    /// indicate which client is closing their channel first, leading to
9718    /// sub-tree failure (which can be normal if the purpose of the sub-tree is
9719    /// over, but if happening earlier than expected, the
9720    /// client-channel-specific name can help diagnose where the failure is
9721    /// first coming from, from sysmem's point of view).
9722    ///
9723    /// By default (unless overriden by this message or using
9724    /// Allocator.SetDebugClientInfo()), a Node will copy info from its
9725    /// parent Node at the time the child Node is created.  While this can be
9726    /// better than nothing, it's often better for each participant to use
9727    /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
9728    /// info directly relevant to the current client.  Also, SetVerboseLogging()
9729    /// can be used to help disambiguate if a Node is suspected of having info
9730    /// that was copied from its parent.
9731    SetDebugClientInfo { name: String, id: u64, control_handle: NodeControlHandle },
9732    /// Sysmem logs a warning if not all clients have set constraints 5 seconds
9733    /// after creating a collection. Clients can call this method to change
9734    /// when the log is printed. If multiple client set the deadline, it's
9735    /// unspecified which deadline will take effect.
9736    SetDebugTimeoutLogDeadline { deadline: i64, control_handle: NodeControlHandle },
9737    /// Verbose logging includes constraints set via SetConstraints() from each
9738    /// client along with info set via SetDebugClientInfo() and the structure of
9739    /// the tree of Node(s).
9740    ///
9741    /// Normally sysmem prints only a single line complaint when aggregation
9742    /// fails, with just the specific detailed reason that aggregation failed,
9743    /// with minimal context.  While this is often enough to diagnose a problem
9744    /// if only a small change was made and the system had been working before
9745    /// the small change, it's often not particularly helpful for getting a new
9746    /// buffer collection to work for the first time.  Especially with more
9747    /// complex trees of nodes, involving things like AttachToken(),
9748    /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
9749    /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
9750    /// looks like and why it's failing a logical allocation, or why a tree or
9751    /// sub-tree is failing sooner than expected.
9752    ///
9753    /// The intent of the extra logging is to be acceptable from a performance
9754    /// point of view, if only enabled on a low number of buffer collections.
9755    /// If we're not tracking down a bug, we shouldn't send this message.
9756    ///
9757    /// If too many participants leave verbose logging enabled, we may end up
9758    /// needing to require that system-wide sysmem verbose logging be permitted
9759    /// via some other setting, to avoid sysmem spamming the log too much due to
9760    /// this message.
9761    ///
9762    /// This may be a NOP for some nodes due to intentional policy associated
9763    /// with the node, if we don't trust a node enough to let it turn on verbose
9764    /// logging.
9765    SetVerboseLogging { control_handle: NodeControlHandle },
9766    /// This gets an event handle that can be used as a parameter to
9767    /// IsAlternateFor() called on any Node.  The client will not be granted the
9768    /// right to signal this event, as this handle should only be used as proof
9769    /// that the client obtained this handle from this Node.
9770    ///
9771    /// Because this is a get not a set, no Sync() is needed between the
9772    /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
9773    /// potentially being on different channels.
9774    ///
9775    /// See also IsAlternateFor().
9776    GetNodeRef { responder: NodeGetNodeRefResponder },
9777    /// This checks whether the calling node is in a subtree rooted at a
9778    /// different child token of a common parent BufferCollectionTokenGroup, in
9779    /// relation to the passed-in node_ref.
9780    ///
9781    /// This call is for assisting with admission control de-duplication, and
9782    /// with debugging.
9783    ///
9784    /// The node_ref must be obtained using GetNodeRef() of a
9785    /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
9786    ///
9787    /// The node_ref can be a duplicated handle; it's not necessary to call
9788    /// GetNodeRef() for every call to IsAlternateFor().
9789    ///
9790    /// If a calling token may not actually be a valid token at all due to
9791    /// a potentially hostile/untrusted provider of the token, call
9792    /// ValidateBufferCollectionToken() first instead of potentially getting
9793    /// stuck indefinitely if IsAlternateFor() never responds due to a calling
9794    /// token not being a real token (not really talking to sysmem).  Another
9795    /// option is to call BindSharedCollection with this token first which also
9796    /// validates the token along with converting it to a BufferCollection, then
9797    /// call BufferCollection IsAlternateFor().
9798    ///
9799    /// error values:
9800    ///
9801    /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
9802    /// buffer collection as the calling Node.  Before logical allocation and
9803    /// within the same logical allocation sub-tree, this essentially means that
9804    /// the node_ref was never part of this logical buffer collection, since
9805    /// before logical allocation all node_refs that come into existence remain
9806    /// in existence at least until logical allocation (including Node(s) that
9807    /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
9808    /// to be returned, this Node's channel needs to still be connected server
9809    /// side, which won't be the case if the whole logical allocation has
9810    /// failed.  After logical allocation or in a different logical allocation
9811    /// sub-tree there are additional potential reasons for this error.  For
9812    /// example a different logical allocation (separated from this Node(s)
9813    /// logical allocation by an AttachToken() or SetDispensable()) can fail its
9814    /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
9815    /// exist and may select a different child sub-tree than the sub-tree the
9816    /// node_ref is in causing deletion of the node_ref Node.  The only time
9817    /// sysmem keeps a Node around after that Node has no corresponding channel
9818    /// is when Close() is used and the Node's sub-tree has not yet failed.
9819    /// Another reason for this error is if the node_ref is an eventpair handle
9820    /// with sufficient rights, but isn't actually a real node_ref obtained from
9821    /// GetNodeRef().
9822    ///
9823    /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
9824    /// eventpair handle, or doesn't have the needed rights expected on a real
9825    /// node_ref.
9826    ///
9827    /// No other failing status codes are returned by this call.  However,
9828    /// sysmem may add additional codes in future, so the client should have
9829    /// sensible default handling for any failing status code.
9830    ///
9831    /// On success, is_alternate has the following meaning:
9832    ///   * true - The first parent node in common between the calling node and
9833    ///     the node_ref Node is a BufferCollectionTokenGroup.  This means that
9834    ///     the calling Node and the node_ref Node will _not_ have both their
9835    ///     constraints apply - rather sysmem will choose one or the other of
9836    ///     the constraints - never both.  This is because only one child of
9837    ///     a BufferCollectionTokenGroup is selected during logical allocation,
9838    ///     with only that one child's sub-tree contributing to constraints
9839    ///     aggregation.
9840    ///   * false - The first parent node in common between the calling Node and
9841    ///     the node_ref Node is not a BufferCollectionTokenGroup.  Currently,
9842    ///     this means the first parent node in common is a
9843    ///     BufferCollectionToken or BufferCollection (regardless of not
9844    ///     Close()ed or Close()ed).  This means that the calling Node and the
9845    ///     node_ref Node _may_ have both their constraints apply during
9846    ///     constraints aggregation of the logical allocation, if both Node(s)
9847    ///     are selected by any parent BufferCollectionTokenGroup(s) involved.
9848    ///     In this case, there is no BufferCollectionTokenGroup that will
9849    ///     directly prevent the two Node(s) from both being selected and their
9850    ///     constraints both aggregated, but even when false, one or both
9851    ///     Node(s) may still be eliminated from consideration if one or both
9852    ///     Node(s) has a direct or indirect parent BufferCollectionTokenGroup
9853    ///     which selects a child sub-tree other than the sub-tree containing
9854    ///     the calling Node or node_ref Node.
9855    IsAlternateFor { node_ref: fidl::Event, responder: NodeIsAlternateForResponder },
9856}
9857
9858impl NodeRequest {
9859    #[allow(irrefutable_let_patterns)]
9860    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
9861        if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
9862    }
9863
9864    #[allow(irrefutable_let_patterns)]
9865    pub fn into_close(self) -> Option<(NodeControlHandle)> {
9866        if let NodeRequest::Close { control_handle } = self { Some((control_handle)) } else { None }
9867    }
9868
9869    #[allow(irrefutable_let_patterns)]
9870    pub fn into_set_name(self) -> Option<(u32, String, NodeControlHandle)> {
9871        if let NodeRequest::SetName { priority, name, control_handle } = self {
9872            Some((priority, name, control_handle))
9873        } else {
9874            None
9875        }
9876    }
9877
9878    #[allow(irrefutable_let_patterns)]
9879    pub fn into_set_debug_client_info(self) -> Option<(String, u64, NodeControlHandle)> {
9880        if let NodeRequest::SetDebugClientInfo { name, id, control_handle } = self {
9881            Some((name, id, control_handle))
9882        } else {
9883            None
9884        }
9885    }
9886
9887    #[allow(irrefutable_let_patterns)]
9888    pub fn into_set_debug_timeout_log_deadline(self) -> Option<(i64, NodeControlHandle)> {
9889        if let NodeRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } = self {
9890            Some((deadline, control_handle))
9891        } else {
9892            None
9893        }
9894    }
9895
9896    #[allow(irrefutable_let_patterns)]
9897    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
9898        if let NodeRequest::SetVerboseLogging { control_handle } = self {
9899            Some((control_handle))
9900        } else {
9901            None
9902        }
9903    }
9904
9905    #[allow(irrefutable_let_patterns)]
9906    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
9907        if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
9908    }
9909
9910    #[allow(irrefutable_let_patterns)]
9911    pub fn into_is_alternate_for(self) -> Option<(fidl::Event, NodeIsAlternateForResponder)> {
9912        if let NodeRequest::IsAlternateFor { node_ref, responder } = self {
9913            Some((node_ref, responder))
9914        } else {
9915            None
9916        }
9917    }
9918
9919    /// Name of the method defined in FIDL
9920    pub fn method_name(&self) -> &'static str {
9921        match *self {
9922            NodeRequest::Sync { .. } => "sync",
9923            NodeRequest::Close { .. } => "close",
9924            NodeRequest::SetName { .. } => "set_name",
9925            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
9926            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
9927            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
9928            NodeRequest::GetNodeRef { .. } => "get_node_ref",
9929            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
9930        }
9931    }
9932}
9933
9934#[derive(Debug, Clone)]
9935pub struct NodeControlHandle {
9936    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9937}
9938
9939impl fidl::endpoints::ControlHandle for NodeControlHandle {
9940    fn shutdown(&self) {
9941        self.inner.shutdown()
9942    }
9943
9944    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9945        self.inner.shutdown_with_epitaph(status)
9946    }
9947
9948    fn is_closed(&self) -> bool {
9949        self.inner.channel().is_closed()
9950    }
9951    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9952        self.inner.channel().on_closed()
9953    }
9954
9955    #[cfg(target_os = "fuchsia")]
9956    fn signal_peer(
9957        &self,
9958        clear_mask: zx::Signals,
9959        set_mask: zx::Signals,
9960    ) -> Result<(), zx_status::Status> {
9961        use fidl::Peered;
9962        self.inner.channel().signal_peer(clear_mask, set_mask)
9963    }
9964}
9965
9966impl NodeControlHandle {}
9967
9968#[must_use = "FIDL methods require a response to be sent"]
9969#[derive(Debug)]
9970pub struct NodeSyncResponder {
9971    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
9972    tx_id: u32,
9973}
9974
9975/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
9976/// if the responder is dropped without sending a response, so that the client
9977/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9978impl std::ops::Drop for NodeSyncResponder {
9979    fn drop(&mut self) {
9980        self.control_handle.shutdown();
9981        // Safety: drops once, never accessed again
9982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9983    }
9984}
9985
9986impl fidl::endpoints::Responder for NodeSyncResponder {
9987    type ControlHandle = NodeControlHandle;
9988
9989    fn control_handle(&self) -> &NodeControlHandle {
9990        &self.control_handle
9991    }
9992
9993    fn drop_without_shutdown(mut self) {
9994        // Safety: drops once, never accessed again due to mem::forget
9995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9996        // Prevent Drop from running (which would shut down the channel)
9997        std::mem::forget(self);
9998    }
9999}
10000
10001impl NodeSyncResponder {
10002    /// Sends a response to the FIDL transaction.
10003    ///
10004    /// Sets the channel to shutdown if an error occurs.
10005    pub fn send(self) -> Result<(), fidl::Error> {
10006        let _result = self.send_raw();
10007        if _result.is_err() {
10008            self.control_handle.shutdown();
10009        }
10010        self.drop_without_shutdown();
10011        _result
10012    }
10013
10014    /// Similar to "send" but does not shutdown the channel if an error occurs.
10015    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10016        let _result = self.send_raw();
10017        self.drop_without_shutdown();
10018        _result
10019    }
10020
10021    fn send_raw(&self) -> Result<(), fidl::Error> {
10022        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10023            (),
10024            self.tx_id,
10025            0x4577e238ae26291,
10026            fidl::encoding::DynamicFlags::empty(),
10027        )
10028    }
10029}
10030
10031#[must_use = "FIDL methods require a response to be sent"]
10032#[derive(Debug)]
10033pub struct NodeGetNodeRefResponder {
10034    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10035    tx_id: u32,
10036}
10037
10038/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10039/// if the responder is dropped without sending a response, so that the client
10040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10041impl std::ops::Drop for NodeGetNodeRefResponder {
10042    fn drop(&mut self) {
10043        self.control_handle.shutdown();
10044        // Safety: drops once, never accessed again
10045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10046    }
10047}
10048
10049impl fidl::endpoints::Responder for NodeGetNodeRefResponder {
10050    type ControlHandle = NodeControlHandle;
10051
10052    fn control_handle(&self) -> &NodeControlHandle {
10053        &self.control_handle
10054    }
10055
10056    fn drop_without_shutdown(mut self) {
10057        // Safety: drops once, never accessed again due to mem::forget
10058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10059        // Prevent Drop from running (which would shut down the channel)
10060        std::mem::forget(self);
10061    }
10062}
10063
10064impl NodeGetNodeRefResponder {
10065    /// Sends a response to the FIDL transaction.
10066    ///
10067    /// Sets the channel to shutdown if an error occurs.
10068    pub fn send(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10069        let _result = self.send_raw(node_ref);
10070        if _result.is_err() {
10071            self.control_handle.shutdown();
10072        }
10073        self.drop_without_shutdown();
10074        _result
10075    }
10076
10077    /// Similar to "send" but does not shutdown the channel if an error occurs.
10078    pub fn send_no_shutdown_on_err(self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10079        let _result = self.send_raw(node_ref);
10080        self.drop_without_shutdown();
10081        _result
10082    }
10083
10084    fn send_raw(&self, mut node_ref: fidl::Event) -> Result<(), fidl::Error> {
10085        self.control_handle.inner.send::<NodeGetNodeRefResponse>(
10086            (node_ref,),
10087            self.tx_id,
10088            0x467b7c75c35c3b84,
10089            fidl::encoding::DynamicFlags::empty(),
10090        )
10091    }
10092}
10093
10094#[must_use = "FIDL methods require a response to be sent"]
10095#[derive(Debug)]
10096pub struct NodeIsAlternateForResponder {
10097    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
10098    tx_id: u32,
10099}
10100
10101/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
10102/// if the responder is dropped without sending a response, so that the client
10103/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10104impl std::ops::Drop for NodeIsAlternateForResponder {
10105    fn drop(&mut self) {
10106        self.control_handle.shutdown();
10107        // Safety: drops once, never accessed again
10108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10109    }
10110}
10111
10112impl fidl::endpoints::Responder for NodeIsAlternateForResponder {
10113    type ControlHandle = NodeControlHandle;
10114
10115    fn control_handle(&self) -> &NodeControlHandle {
10116        &self.control_handle
10117    }
10118
10119    fn drop_without_shutdown(mut self) {
10120        // Safety: drops once, never accessed again due to mem::forget
10121        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10122        // Prevent Drop from running (which would shut down the channel)
10123        std::mem::forget(self);
10124    }
10125}
10126
10127impl NodeIsAlternateForResponder {
10128    /// Sends a response to the FIDL transaction.
10129    ///
10130    /// Sets the channel to shutdown if an error occurs.
10131    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10132        let _result = self.send_raw(result);
10133        if _result.is_err() {
10134            self.control_handle.shutdown();
10135        }
10136        self.drop_without_shutdown();
10137        _result
10138    }
10139
10140    /// Similar to "send" but does not shutdown the channel if an error occurs.
10141    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10142        let _result = self.send_raw(result);
10143        self.drop_without_shutdown();
10144        _result
10145    }
10146
10147    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
10148        self.control_handle
10149            .inner
10150            .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
10151                result.map(|is_alternate| (is_alternate,)),
10152                self.tx_id,
10153                0x33a2a7aff2776c07,
10154                fidl::encoding::DynamicFlags::empty(),
10155            )
10156    }
10157}
10158
10159#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10160pub struct SecureMemMarker;
10161
10162impl fidl::endpoints::ProtocolMarker for SecureMemMarker {
10163    type Proxy = SecureMemProxy;
10164    type RequestStream = SecureMemRequestStream;
10165    #[cfg(target_os = "fuchsia")]
10166    type SynchronousProxy = SecureMemSynchronousProxy;
10167
10168    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
10169}
10170pub type SecureMemGetPhysicalSecureHeapsResult = Result<SecureHeapsAndRanges, i32>;
10171pub type SecureMemGetPhysicalSecureHeapPropertiesResult = Result<SecureHeapProperties, i32>;
10172pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), i32>;
10173pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), i32>;
10174pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), i32>;
10175pub type SecureMemZeroSubRangeResult = Result<(), i32>;
10176
10177pub trait SecureMemProxyInterface: Send + Sync {
10178    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
10179        + Send;
10180    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
10181    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
10182            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
10183        > + Send;
10184    fn r#get_physical_secure_heap_properties(
10185        &self,
10186        entire_heap: &SecureHeapAndRange,
10187    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
10188    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
10189        + Send;
10190    fn r#add_secure_heap_physical_range(
10191        &self,
10192        heap_range: &SecureHeapAndRange,
10193    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
10194    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
10195            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
10196        > + Send;
10197    fn r#delete_secure_heap_physical_range(
10198        &self,
10199        heap_range: &SecureHeapAndRange,
10200    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
10201    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
10202            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
10203        > + Send;
10204    fn r#modify_secure_heap_physical_range(
10205        &self,
10206        range_modification: &SecureHeapAndRangeModification,
10207    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
10208    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
10209        + Send;
10210    fn r#zero_sub_range(
10211        &self,
10212        is_covering_range_explicit: bool,
10213        heap_range: &SecureHeapAndRange,
10214    ) -> Self::ZeroSubRangeResponseFut;
10215}
10216#[derive(Debug)]
10217#[cfg(target_os = "fuchsia")]
10218pub struct SecureMemSynchronousProxy {
10219    client: fidl::client::sync::Client,
10220}
10221
10222#[cfg(target_os = "fuchsia")]
10223impl fidl::endpoints::SynchronousProxy for SecureMemSynchronousProxy {
10224    type Proxy = SecureMemProxy;
10225    type Protocol = SecureMemMarker;
10226
10227    fn from_channel(inner: fidl::Channel) -> Self {
10228        Self::new(inner)
10229    }
10230
10231    fn into_channel(self) -> fidl::Channel {
10232        self.client.into_channel()
10233    }
10234
10235    fn as_channel(&self) -> &fidl::Channel {
10236        self.client.as_channel()
10237    }
10238}
10239
10240#[cfg(target_os = "fuchsia")]
10241impl SecureMemSynchronousProxy {
10242    pub fn new(channel: fidl::Channel) -> Self {
10243        Self { client: fidl::client::sync::Client::new(channel) }
10244    }
10245
10246    pub fn into_channel(self) -> fidl::Channel {
10247        self.client.into_channel()
10248    }
10249
10250    /// Waits until an event arrives and returns it. It is safe for other
10251    /// threads to make concurrent requests while waiting for an event.
10252    pub fn wait_for_event(
10253        &self,
10254        deadline: zx::MonotonicInstant,
10255    ) -> Result<SecureMemEvent, fidl::Error> {
10256        SecureMemEvent::decode(self.client.wait_for_event::<SecureMemMarker>(deadline)?)
10257    }
10258
10259    /// Gets the physical address and length of any secure heap whose physical
10260    /// range is configured via the TEE.
10261    ///
10262    /// Presently, these will be fixed physical addresses and lengths, with the
10263    /// location plumbed via the TEE.
10264    ///
10265    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10266    /// when there isn't any special heap-specific per-VMO setup or teardown
10267    /// required.
10268    ///
10269    /// The physical range must be secured/protected by the TEE before the
10270    /// securemem driver responds to this request with success.
10271    ///
10272    /// Sysmem should only call this once.  Returning zero heaps is not a
10273    /// failure.
10274    ///
10275    /// Errors:
10276    ///  * ZX_ERR_BAD_STATE - called more than once.
10277    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10278    ///    with TEE which doesn't generate zx_status_t errors).
10279    ///  * other errors are allowed; any other errors should be treated the same
10280    ///    as ZX_ERR_INTERNAL.
10281    pub fn r#get_physical_secure_heaps(
10282        &self,
10283        ___deadline: zx::MonotonicInstant,
10284    ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
10285        let _response = self.client.send_query::<
10286            fidl::encoding::EmptyPayload,
10287            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
10288            SecureMemMarker,
10289        >(
10290            (),
10291            0x782319d6ce7fa05,
10292            fidl::encoding::DynamicFlags::empty(),
10293            ___deadline,
10294        )?;
10295        Ok(_response.map(|x| x.heaps))
10296    }
10297
10298    /// This request from sysmem to the securemem driver gets the properties of
10299    /// a protected/secure heap.
10300    ///
10301    /// This only handles heaps with a single contiguous physical extent.
10302    ///
10303    /// The heap's entire physical range is indicated in case this request needs
10304    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10305    /// temporary HW protection ranges will be deleted before this request
10306    /// completes.
10307    pub fn r#get_physical_secure_heap_properties(
10308        &self,
10309        mut entire_heap: &SecureHeapAndRange,
10310        ___deadline: zx::MonotonicInstant,
10311    ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
10312        let _response = self.client.send_query::<
10313            SecureMemGetPhysicalSecureHeapPropertiesRequest,
10314            fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
10315            SecureMemMarker,
10316        >(
10317            (entire_heap,),
10318            0x26404e23f1271214,
10319            fidl::encoding::DynamicFlags::empty(),
10320            ___deadline,
10321        )?;
10322        Ok(_response.map(|x| x.properties))
10323    }
10324
10325    /// This request from sysmem to the securemem driver conveys a physical
10326    /// range to add, for a heap whose physical range(s) are set up via
10327    /// sysmem.
10328    ///
10329    /// Only sysmem can call this because only sysmem is handed the client end
10330    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10331    /// securemem driver is the server end of this protocol.
10332    ///
10333    /// The securemem driver must configure all the covered offsets as protected
10334    /// before responding to this message with success.
10335    ///
10336    /// On failure, the securemem driver must ensure the protected range was not
10337    /// created.
10338    ///
10339    /// Sysmem must only call this up to once if dynamic_protection_ranges
10340    /// false.
10341    ///
10342    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10343    /// times as long as the current number of ranges never exceeds
10344    /// max_protected_range_count.
10345    ///
10346    /// The caller must not attempt to add a range that matches an
10347    /// already-existing range.  Added ranges can overlap each other as long as
10348    /// no two ranges match exactly.
10349    ///
10350    /// Errors:
10351    ///   * ZX_ERR_BAD_STATE - called more than once when
10352    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10353    ///     heap count to exceed max_protected_range_count.
10354    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10355    ///     to protected_range_granularity.
10356    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10357    ///     with TEE which doesn't generate zx_status_t errors).
10358    ///   * other errors are possible, such as from communication failures or
10359    ///     server propagation of zx_status_t failures.
10360    pub fn r#add_secure_heap_physical_range(
10361        &self,
10362        mut heap_range: &SecureHeapAndRange,
10363        ___deadline: zx::MonotonicInstant,
10364    ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
10365        let _response = self.client.send_query::<
10366            SecureMemAddSecureHeapPhysicalRangeRequest,
10367            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10368            SecureMemMarker,
10369        >(
10370            (heap_range,),
10371            0x1ca1abcee8a0b33e,
10372            fidl::encoding::DynamicFlags::empty(),
10373            ___deadline,
10374        )?;
10375        Ok(_response.map(|x| x))
10376    }
10377
10378    /// This request from sysmem to the securemem driver conveys a physical
10379    /// range to delete, for a heap whose physical range(s) are set up via
10380    /// sysmem.
10381    ///
10382    /// Only sysmem can call this because only sysmem is handed the client end
10383    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10384    /// securemem driver is the server end of this protocol.
10385    ///
10386    /// The securemem driver must configure all the covered offsets as not
10387    /// protected before responding to this message with success.
10388    ///
10389    /// On failure, the securemem driver must ensure the protected range was not
10390    /// deleted.
10391    ///
10392    /// Sysmem must not call this if dynamic_protection_ranges false.
10393    ///
10394    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10395    /// on various ranges that exist at the time of the call.
10396    ///
10397    /// If any portion of the range being deleted is not also covered by another
10398    /// protected range, then any ongoing DMA to any part of the entire range
10399    /// may be interrupted / may fail, potentially in a way that's disruptive to
10400    /// the entire system (bus lockup or similar, depending on device details).
10401    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10402    /// any portion of the range being deleted, unless the caller has other
10403    /// active ranges covering every block of the range being deleted.  Ongoing
10404    /// DMA to/from blocks outside the range being deleted is never impacted by
10405    /// the deletion.
10406    ///
10407    /// Errors:
10408    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10409    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10410    ///     to protected_range_granularity.
10411    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10412    ///     with TEE which doesn't generate zx_status_t errors).
10413    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10414    ///   * other errors are possible, such as from communication failures or
10415    ///     server propagation of zx_status_t failures.
10416    pub fn r#delete_secure_heap_physical_range(
10417        &self,
10418        mut heap_range: &SecureHeapAndRange,
10419        ___deadline: zx::MonotonicInstant,
10420    ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
10421        let _response = self.client.send_query::<
10422            SecureMemDeleteSecureHeapPhysicalRangeRequest,
10423            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10424            SecureMemMarker,
10425        >(
10426            (heap_range,),
10427            0x728a953e56df92ee,
10428            fidl::encoding::DynamicFlags::empty(),
10429            ___deadline,
10430        )?;
10431        Ok(_response.map(|x| x))
10432    }
10433
10434    /// This request from sysmem to the securemem driver conveys a physical
10435    /// range to modify and its new base and length, for a heap whose physical
10436    /// range(s) are set up via sysmem.
10437    ///
10438    /// Only sysmem can call this because only sysmem is handed the client end
10439    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10440    /// securemem driver is the server end of this protocol.
10441    ///
10442    /// The securemem driver must configure the range to cover only the new
10443    /// offsets before responding to this message with success.
10444    ///
10445    /// On failure, the securemem driver must ensure the range was not changed.
10446    ///
10447    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10448    /// must not call this if !is_mod_protected_range_available.
10449    ///
10450    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10451    /// on various ranges that exist at the time of the call.
10452    ///
10453    /// The range must only be modified at one end or the other, but not both.
10454    /// If the range is getting shorter, and the un-covered blocks are not
10455    /// covered by other active ranges, any ongoing DMA to the entire range
10456    /// that's geting shorter may fail in a way that disrupts the entire system
10457    /// (bus lockup or similar), so the caller must ensure that no DMA is
10458    /// ongoing to any portion of a range that is getting shorter, unless the
10459    /// blocks being un-covered by the modification to this range are all
10460    /// covered by other active ranges, in which case no disruption to ongoing
10461    /// DMA will occur.
10462    ///
10463    /// If a range is modified to become <= zero length, the range is deleted.
10464    ///
10465    /// Errors:
10466    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10467    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
10468    ///     that doesn't conform to protected_range_granularity, or old_range
10469    ///     and new_range differ in both begin and end (disallowed).
10470    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10471    ///     with TEE which doesn't generate zx_status_t errors).
10472    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10473    ///   * other errors are possible, such as from communication failures or
10474    ///     server propagation of zx_status_t failures.
10475    pub fn r#modify_secure_heap_physical_range(
10476        &self,
10477        mut range_modification: &SecureHeapAndRangeModification,
10478        ___deadline: zx::MonotonicInstant,
10479    ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
10480        let _response = self.client.send_query::<
10481            SecureMemModifySecureHeapPhysicalRangeRequest,
10482            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10483            SecureMemMarker,
10484        >(
10485            (range_modification,),
10486            0x154fbfa3646a890d,
10487            fidl::encoding::DynamicFlags::empty(),
10488            ___deadline,
10489        )?;
10490        Ok(_response.map(|x| x))
10491    }
10492
10493    /// Zero a sub-range of a currently-existing physical range added via
10494    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
10495    /// exactly one physical range, and must not overlap with any other
10496    /// physical range.
10497    ///
10498    /// is_covering_range_explicit - When true, the covering range must be one
10499    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
10500    ///     possibly modified since.  When false, the covering range must not
10501    ///     be one of the ranges explicitly created via
10502    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
10503    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
10504    ///     covering range is typically the entire physical range (or a range
10505    ///     which covers even more) of a heap configured by the TEE and whose
10506    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
10507    ///
10508    /// Ongoing DMA is not disrupted by this request.
10509    pub fn r#zero_sub_range(
10510        &self,
10511        mut is_covering_range_explicit: bool,
10512        mut heap_range: &SecureHeapAndRange,
10513        ___deadline: zx::MonotonicInstant,
10514    ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
10515        let _response = self.client.send_query::<
10516            SecureMemZeroSubRangeRequest,
10517            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10518            SecureMemMarker,
10519        >(
10520            (is_covering_range_explicit, heap_range,),
10521            0x7480f72bb5bc7e5b,
10522            fidl::encoding::DynamicFlags::empty(),
10523            ___deadline,
10524        )?;
10525        Ok(_response.map(|x| x))
10526    }
10527}
10528
10529#[cfg(target_os = "fuchsia")]
10530impl From<SecureMemSynchronousProxy> for zx::NullableHandle {
10531    fn from(value: SecureMemSynchronousProxy) -> Self {
10532        value.into_channel().into()
10533    }
10534}
10535
10536#[cfg(target_os = "fuchsia")]
10537impl From<fidl::Channel> for SecureMemSynchronousProxy {
10538    fn from(value: fidl::Channel) -> Self {
10539        Self::new(value)
10540    }
10541}
10542
10543#[cfg(target_os = "fuchsia")]
10544impl fidl::endpoints::FromClient for SecureMemSynchronousProxy {
10545    type Protocol = SecureMemMarker;
10546
10547    fn from_client(value: fidl::endpoints::ClientEnd<SecureMemMarker>) -> Self {
10548        Self::new(value.into_channel())
10549    }
10550}
10551
10552#[derive(Debug, Clone)]
10553pub struct SecureMemProxy {
10554    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10555}
10556
10557impl fidl::endpoints::Proxy for SecureMemProxy {
10558    type Protocol = SecureMemMarker;
10559
10560    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10561        Self::new(inner)
10562    }
10563
10564    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10565        self.client.into_channel().map_err(|client| Self { client })
10566    }
10567
10568    fn as_channel(&self) -> &::fidl::AsyncChannel {
10569        self.client.as_channel()
10570    }
10571}
10572
10573impl SecureMemProxy {
10574    /// Create a new Proxy for fuchsia.sysmem/SecureMem.
10575    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10576        let protocol_name = <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10577        Self { client: fidl::client::Client::new(channel, protocol_name) }
10578    }
10579
10580    /// Get a Stream of events from the remote end of the protocol.
10581    ///
10582    /// # Panics
10583    ///
10584    /// Panics if the event stream was already taken.
10585    pub fn take_event_stream(&self) -> SecureMemEventStream {
10586        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
10587    }
10588
10589    /// Gets the physical address and length of any secure heap whose physical
10590    /// range is configured via the TEE.
10591    ///
10592    /// Presently, these will be fixed physical addresses and lengths, with the
10593    /// location plumbed via the TEE.
10594    ///
10595    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
10596    /// when there isn't any special heap-specific per-VMO setup or teardown
10597    /// required.
10598    ///
10599    /// The physical range must be secured/protected by the TEE before the
10600    /// securemem driver responds to this request with success.
10601    ///
10602    /// Sysmem should only call this once.  Returning zero heaps is not a
10603    /// failure.
10604    ///
10605    /// Errors:
10606    ///  * ZX_ERR_BAD_STATE - called more than once.
10607    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
10608    ///    with TEE which doesn't generate zx_status_t errors).
10609    ///  * other errors are allowed; any other errors should be treated the same
10610    ///    as ZX_ERR_INTERNAL.
10611    pub fn r#get_physical_secure_heaps(
10612        &self,
10613    ) -> fidl::client::QueryResponseFut<
10614        SecureMemGetPhysicalSecureHeapsResult,
10615        fidl::encoding::DefaultFuchsiaResourceDialect,
10616    > {
10617        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
10618    }
10619
10620    /// This request from sysmem to the securemem driver gets the properties of
10621    /// a protected/secure heap.
10622    ///
10623    /// This only handles heaps with a single contiguous physical extent.
10624    ///
10625    /// The heap's entire physical range is indicated in case this request needs
10626    /// some physical space to auto-detect how many ranges are REE-usable.  Any
10627    /// temporary HW protection ranges will be deleted before this request
10628    /// completes.
10629    pub fn r#get_physical_secure_heap_properties(
10630        &self,
10631        mut entire_heap: &SecureHeapAndRange,
10632    ) -> fidl::client::QueryResponseFut<
10633        SecureMemGetPhysicalSecureHeapPropertiesResult,
10634        fidl::encoding::DefaultFuchsiaResourceDialect,
10635    > {
10636        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, entire_heap)
10637    }
10638
10639    /// This request from sysmem to the securemem driver conveys a physical
10640    /// range to add, for a heap whose physical range(s) are set up via
10641    /// sysmem.
10642    ///
10643    /// Only sysmem can call this because only sysmem is handed the client end
10644    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10645    /// securemem driver is the server end of this protocol.
10646    ///
10647    /// The securemem driver must configure all the covered offsets as protected
10648    /// before responding to this message with success.
10649    ///
10650    /// On failure, the securemem driver must ensure the protected range was not
10651    /// created.
10652    ///
10653    /// Sysmem must only call this up to once if dynamic_protection_ranges
10654    /// false.
10655    ///
10656    /// If dynamic_protection_ranges is true, sysmem can call this multiple
10657    /// times as long as the current number of ranges never exceeds
10658    /// max_protected_range_count.
10659    ///
10660    /// The caller must not attempt to add a range that matches an
10661    /// already-existing range.  Added ranges can overlap each other as long as
10662    /// no two ranges match exactly.
10663    ///
10664    /// Errors:
10665    ///   * ZX_ERR_BAD_STATE - called more than once when
10666    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
10667    ///     heap count to exceed max_protected_range_count.
10668    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10669    ///     to protected_range_granularity.
10670    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10671    ///     with TEE which doesn't generate zx_status_t errors).
10672    ///   * other errors are possible, such as from communication failures or
10673    ///     server propagation of zx_status_t failures.
10674    pub fn r#add_secure_heap_physical_range(
10675        &self,
10676        mut heap_range: &SecureHeapAndRange,
10677    ) -> fidl::client::QueryResponseFut<
10678        SecureMemAddSecureHeapPhysicalRangeResult,
10679        fidl::encoding::DefaultFuchsiaResourceDialect,
10680    > {
10681        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, heap_range)
10682    }
10683
10684    /// This request from sysmem to the securemem driver conveys a physical
10685    /// range to delete, for a heap whose physical range(s) are set up via
10686    /// sysmem.
10687    ///
10688    /// Only sysmem can call this because only sysmem is handed the client end
10689    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10690    /// securemem driver is the server end of this protocol.
10691    ///
10692    /// The securemem driver must configure all the covered offsets as not
10693    /// protected before responding to this message with success.
10694    ///
10695    /// On failure, the securemem driver must ensure the protected range was not
10696    /// deleted.
10697    ///
10698    /// Sysmem must not call this if dynamic_protection_ranges false.
10699    ///
10700    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10701    /// on various ranges that exist at the time of the call.
10702    ///
10703    /// If any portion of the range being deleted is not also covered by another
10704    /// protected range, then any ongoing DMA to any part of the entire range
10705    /// may be interrupted / may fail, potentially in a way that's disruptive to
10706    /// the entire system (bus lockup or similar, depending on device details).
10707    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
10708    /// any portion of the range being deleted, unless the caller has other
10709    /// active ranges covering every block of the range being deleted.  Ongoing
10710    /// DMA to/from blocks outside the range being deleted is never impacted by
10711    /// the deletion.
10712    ///
10713    /// Errors:
10714    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10715    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
10716    ///     to protected_range_granularity.
10717    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10718    ///     with TEE which doesn't generate zx_status_t errors).
10719    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10720    ///   * other errors are possible, such as from communication failures or
10721    ///     server propagation of zx_status_t failures.
10722    pub fn r#delete_secure_heap_physical_range(
10723        &self,
10724        mut heap_range: &SecureHeapAndRange,
10725    ) -> fidl::client::QueryResponseFut<
10726        SecureMemDeleteSecureHeapPhysicalRangeResult,
10727        fidl::encoding::DefaultFuchsiaResourceDialect,
10728    > {
10729        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, heap_range)
10730    }
10731
10732    /// This request from sysmem to the securemem driver conveys a physical
10733    /// range to modify and its new base and length, for a heap whose physical
10734    /// range(s) are set up via sysmem.
10735    ///
10736    /// Only sysmem can call this because only sysmem is handed the client end
10737    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
10738    /// securemem driver is the server end of this protocol.
10739    ///
10740    /// The securemem driver must configure the range to cover only the new
10741    /// offsets before responding to this message with success.
10742    ///
10743    /// On failure, the securemem driver must ensure the range was not changed.
10744    ///
10745    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
10746    /// must not call this if !is_mod_protected_range_available.
10747    ///
10748    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
10749    /// on various ranges that exist at the time of the call.
10750    ///
10751    /// The range must only be modified at one end or the other, but not both.
10752    /// If the range is getting shorter, and the un-covered blocks are not
10753    /// covered by other active ranges, any ongoing DMA to the entire range
10754    /// that's geting shorter may fail in a way that disrupts the entire system
10755    /// (bus lockup or similar), so the caller must ensure that no DMA is
10756    /// ongoing to any portion of a range that is getting shorter, unless the
10757    /// blocks being un-covered by the modification to this range are all
10758    /// covered by other active ranges, in which case no disruption to ongoing
10759    /// DMA will occur.
10760    ///
10761    /// If a range is modified to become <= zero length, the range is deleted.
10762    ///
10763    /// Errors:
10764    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
10765    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
10766    ///     that doesn't conform to protected_range_granularity, or old_range
10767    ///     and new_range differ in both begin and end (disallowed).
10768    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
10769    ///     with TEE which doesn't generate zx_status_t errors).
10770    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
10771    ///   * other errors are possible, such as from communication failures or
10772    ///     server propagation of zx_status_t failures.
10773    pub fn r#modify_secure_heap_physical_range(
10774        &self,
10775        mut range_modification: &SecureHeapAndRangeModification,
10776    ) -> fidl::client::QueryResponseFut<
10777        SecureMemModifySecureHeapPhysicalRangeResult,
10778        fidl::encoding::DefaultFuchsiaResourceDialect,
10779    > {
10780        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, range_modification)
10781    }
10782
10783    /// Zero a sub-range of a currently-existing physical range added via
10784    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
10785    /// exactly one physical range, and must not overlap with any other
10786    /// physical range.
10787    ///
10788    /// is_covering_range_explicit - When true, the covering range must be one
10789    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
10790    ///     possibly modified since.  When false, the covering range must not
10791    ///     be one of the ranges explicitly created via
10792    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
10793    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
10794    ///     covering range is typically the entire physical range (or a range
10795    ///     which covers even more) of a heap configured by the TEE and whose
10796    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
10797    ///
10798    /// Ongoing DMA is not disrupted by this request.
10799    pub fn r#zero_sub_range(
10800        &self,
10801        mut is_covering_range_explicit: bool,
10802        mut heap_range: &SecureHeapAndRange,
10803    ) -> fidl::client::QueryResponseFut<
10804        SecureMemZeroSubRangeResult,
10805        fidl::encoding::DefaultFuchsiaResourceDialect,
10806    > {
10807        SecureMemProxyInterface::r#zero_sub_range(self, is_covering_range_explicit, heap_range)
10808    }
10809}
10810
10811impl SecureMemProxyInterface for SecureMemProxy {
10812    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
10813        SecureMemGetPhysicalSecureHeapsResult,
10814        fidl::encoding::DefaultFuchsiaResourceDialect,
10815    >;
10816    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
10817        fn _decode(
10818            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10819        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
10820            let _response = fidl::client::decode_transaction_body::<
10821                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
10822                fidl::encoding::DefaultFuchsiaResourceDialect,
10823                0x782319d6ce7fa05,
10824            >(_buf?)?;
10825            Ok(_response.map(|x| x.heaps))
10826        }
10827        self.client.send_query_and_decode::<
10828            fidl::encoding::EmptyPayload,
10829            SecureMemGetPhysicalSecureHeapsResult,
10830        >(
10831            (),
10832            0x782319d6ce7fa05,
10833            fidl::encoding::DynamicFlags::empty(),
10834            _decode,
10835        )
10836    }
10837
10838    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
10839        SecureMemGetPhysicalSecureHeapPropertiesResult,
10840        fidl::encoding::DefaultFuchsiaResourceDialect,
10841    >;
10842    fn r#get_physical_secure_heap_properties(
10843        &self,
10844        mut entire_heap: &SecureHeapAndRange,
10845    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
10846        fn _decode(
10847            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10848        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
10849            let _response = fidl::client::decode_transaction_body::<
10850                fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
10851                fidl::encoding::DefaultFuchsiaResourceDialect,
10852                0x26404e23f1271214,
10853            >(_buf?)?;
10854            Ok(_response.map(|x| x.properties))
10855        }
10856        self.client.send_query_and_decode::<
10857            SecureMemGetPhysicalSecureHeapPropertiesRequest,
10858            SecureMemGetPhysicalSecureHeapPropertiesResult,
10859        >(
10860            (entire_heap,),
10861            0x26404e23f1271214,
10862            fidl::encoding::DynamicFlags::empty(),
10863            _decode,
10864        )
10865    }
10866
10867    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
10868        SecureMemAddSecureHeapPhysicalRangeResult,
10869        fidl::encoding::DefaultFuchsiaResourceDialect,
10870    >;
10871    fn r#add_secure_heap_physical_range(
10872        &self,
10873        mut heap_range: &SecureHeapAndRange,
10874    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
10875        fn _decode(
10876            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10877        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
10878            let _response = fidl::client::decode_transaction_body::<
10879                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10880                fidl::encoding::DefaultFuchsiaResourceDialect,
10881                0x1ca1abcee8a0b33e,
10882            >(_buf?)?;
10883            Ok(_response.map(|x| x))
10884        }
10885        self.client.send_query_and_decode::<
10886            SecureMemAddSecureHeapPhysicalRangeRequest,
10887            SecureMemAddSecureHeapPhysicalRangeResult,
10888        >(
10889            (heap_range,),
10890            0x1ca1abcee8a0b33e,
10891            fidl::encoding::DynamicFlags::empty(),
10892            _decode,
10893        )
10894    }
10895
10896    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
10897        SecureMemDeleteSecureHeapPhysicalRangeResult,
10898        fidl::encoding::DefaultFuchsiaResourceDialect,
10899    >;
10900    fn r#delete_secure_heap_physical_range(
10901        &self,
10902        mut heap_range: &SecureHeapAndRange,
10903    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
10904        fn _decode(
10905            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10906        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
10907            let _response = fidl::client::decode_transaction_body::<
10908                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10909                fidl::encoding::DefaultFuchsiaResourceDialect,
10910                0x728a953e56df92ee,
10911            >(_buf?)?;
10912            Ok(_response.map(|x| x))
10913        }
10914        self.client.send_query_and_decode::<
10915            SecureMemDeleteSecureHeapPhysicalRangeRequest,
10916            SecureMemDeleteSecureHeapPhysicalRangeResult,
10917        >(
10918            (heap_range,),
10919            0x728a953e56df92ee,
10920            fidl::encoding::DynamicFlags::empty(),
10921            _decode,
10922        )
10923    }
10924
10925    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
10926        SecureMemModifySecureHeapPhysicalRangeResult,
10927        fidl::encoding::DefaultFuchsiaResourceDialect,
10928    >;
10929    fn r#modify_secure_heap_physical_range(
10930        &self,
10931        mut range_modification: &SecureHeapAndRangeModification,
10932    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
10933        fn _decode(
10934            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10935        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
10936            let _response = fidl::client::decode_transaction_body::<
10937                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10938                fidl::encoding::DefaultFuchsiaResourceDialect,
10939                0x154fbfa3646a890d,
10940            >(_buf?)?;
10941            Ok(_response.map(|x| x))
10942        }
10943        self.client.send_query_and_decode::<
10944            SecureMemModifySecureHeapPhysicalRangeRequest,
10945            SecureMemModifySecureHeapPhysicalRangeResult,
10946        >(
10947            (range_modification,),
10948            0x154fbfa3646a890d,
10949            fidl::encoding::DynamicFlags::empty(),
10950            _decode,
10951        )
10952    }
10953
10954    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
10955        SecureMemZeroSubRangeResult,
10956        fidl::encoding::DefaultFuchsiaResourceDialect,
10957    >;
10958    fn r#zero_sub_range(
10959        &self,
10960        mut is_covering_range_explicit: bool,
10961        mut heap_range: &SecureHeapAndRange,
10962    ) -> Self::ZeroSubRangeResponseFut {
10963        fn _decode(
10964            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10965        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
10966            let _response = fidl::client::decode_transaction_body::<
10967                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
10968                fidl::encoding::DefaultFuchsiaResourceDialect,
10969                0x7480f72bb5bc7e5b,
10970            >(_buf?)?;
10971            Ok(_response.map(|x| x))
10972        }
10973        self.client
10974            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
10975                (is_covering_range_explicit, heap_range),
10976                0x7480f72bb5bc7e5b,
10977                fidl::encoding::DynamicFlags::empty(),
10978                _decode,
10979            )
10980    }
10981}
10982
10983pub struct SecureMemEventStream {
10984    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10985}
10986
10987impl std::marker::Unpin for SecureMemEventStream {}
10988
10989impl futures::stream::FusedStream for SecureMemEventStream {
10990    fn is_terminated(&self) -> bool {
10991        self.event_receiver.is_terminated()
10992    }
10993}
10994
10995impl futures::Stream for SecureMemEventStream {
10996    type Item = Result<SecureMemEvent, fidl::Error>;
10997
10998    fn poll_next(
10999        mut self: std::pin::Pin<&mut Self>,
11000        cx: &mut std::task::Context<'_>,
11001    ) -> std::task::Poll<Option<Self::Item>> {
11002        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11003            &mut self.event_receiver,
11004            cx
11005        )?) {
11006            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
11007            None => std::task::Poll::Ready(None),
11008        }
11009    }
11010}
11011
11012#[derive(Debug)]
11013pub enum SecureMemEvent {}
11014
11015impl SecureMemEvent {
11016    /// Decodes a message buffer as a [`SecureMemEvent`].
11017    fn decode(
11018        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11019    ) -> Result<SecureMemEvent, fidl::Error> {
11020        let (bytes, _handles) = buf.split_mut();
11021        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11022        debug_assert_eq!(tx_header.tx_id, 0);
11023        match tx_header.ordinal {
11024            _ => Err(fidl::Error::UnknownOrdinal {
11025                ordinal: tx_header.ordinal,
11026                protocol_name: <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11027            }),
11028        }
11029    }
11030}
11031
11032/// A Stream of incoming requests for fuchsia.sysmem/SecureMem.
11033pub struct SecureMemRequestStream {
11034    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11035    is_terminated: bool,
11036}
11037
11038impl std::marker::Unpin for SecureMemRequestStream {}
11039
11040impl futures::stream::FusedStream for SecureMemRequestStream {
11041    fn is_terminated(&self) -> bool {
11042        self.is_terminated
11043    }
11044}
11045
11046impl fidl::endpoints::RequestStream for SecureMemRequestStream {
11047    type Protocol = SecureMemMarker;
11048    type ControlHandle = SecureMemControlHandle;
11049
11050    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11051        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11052    }
11053
11054    fn control_handle(&self) -> Self::ControlHandle {
11055        SecureMemControlHandle { inner: self.inner.clone() }
11056    }
11057
11058    fn into_inner(
11059        self,
11060    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11061    {
11062        (self.inner, self.is_terminated)
11063    }
11064
11065    fn from_inner(
11066        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11067        is_terminated: bool,
11068    ) -> Self {
11069        Self { inner, is_terminated }
11070    }
11071}
11072
11073impl futures::Stream for SecureMemRequestStream {
11074    type Item = Result<SecureMemRequest, fidl::Error>;
11075
11076    fn poll_next(
11077        mut self: std::pin::Pin<&mut Self>,
11078        cx: &mut std::task::Context<'_>,
11079    ) -> std::task::Poll<Option<Self::Item>> {
11080        let this = &mut *self;
11081        if this.inner.check_shutdown(cx) {
11082            this.is_terminated = true;
11083            return std::task::Poll::Ready(None);
11084        }
11085        if this.is_terminated {
11086            panic!("polled SecureMemRequestStream after completion");
11087        }
11088        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11089            |bytes, handles| {
11090                match this.inner.channel().read_etc(cx, bytes, handles) {
11091                    std::task::Poll::Ready(Ok(())) => {}
11092                    std::task::Poll::Pending => return std::task::Poll::Pending,
11093                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11094                        this.is_terminated = true;
11095                        return std::task::Poll::Ready(None);
11096                    }
11097                    std::task::Poll::Ready(Err(e)) => {
11098                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11099                            e.into(),
11100                        ))));
11101                    }
11102                }
11103
11104                // A message has been received from the channel
11105                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11106
11107                std::task::Poll::Ready(Some(match header.ordinal {
11108                    0x782319d6ce7fa05 => {
11109                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11110                        let mut req = fidl::new_empty!(
11111                            fidl::encoding::EmptyPayload,
11112                            fidl::encoding::DefaultFuchsiaResourceDialect
11113                        );
11114                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11115                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11116                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
11117                            responder: SecureMemGetPhysicalSecureHeapsResponder {
11118                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11119                                tx_id: header.tx_id,
11120                            },
11121                        })
11122                    }
11123                    0x26404e23f1271214 => {
11124                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11125                        let mut req = fidl::new_empty!(
11126                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11127                            fidl::encoding::DefaultFuchsiaResourceDialect
11128                        );
11129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
11130                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11131                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
11132                            entire_heap: req.entire_heap,
11133
11134                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
11135                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11136                                tx_id: header.tx_id,
11137                            },
11138                        })
11139                    }
11140                    0x1ca1abcee8a0b33e => {
11141                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11142                        let mut req = fidl::new_empty!(
11143                            SecureMemAddSecureHeapPhysicalRangeRequest,
11144                            fidl::encoding::DefaultFuchsiaResourceDialect
11145                        );
11146                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11147                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11148                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
11149                            heap_range: req.heap_range,
11150
11151                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
11152                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11153                                tx_id: header.tx_id,
11154                            },
11155                        })
11156                    }
11157                    0x728a953e56df92ee => {
11158                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11159                        let mut req = fidl::new_empty!(
11160                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11161                            fidl::encoding::DefaultFuchsiaResourceDialect
11162                        );
11163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11164                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11165                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
11166                            heap_range: req.heap_range,
11167
11168                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
11169                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11170                                tx_id: header.tx_id,
11171                            },
11172                        })
11173                    }
11174                    0x154fbfa3646a890d => {
11175                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11176                        let mut req = fidl::new_empty!(
11177                            SecureMemModifySecureHeapPhysicalRangeRequest,
11178                            fidl::encoding::DefaultFuchsiaResourceDialect
11179                        );
11180                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11181                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11182                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
11183                            range_modification: req.range_modification,
11184
11185                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
11186                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11187                                tx_id: header.tx_id,
11188                            },
11189                        })
11190                    }
11191                    0x7480f72bb5bc7e5b => {
11192                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11193                        let mut req = fidl::new_empty!(
11194                            SecureMemZeroSubRangeRequest,
11195                            fidl::encoding::DefaultFuchsiaResourceDialect
11196                        );
11197                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11198                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11199                        Ok(SecureMemRequest::ZeroSubRange {
11200                            is_covering_range_explicit: req.is_covering_range_explicit,
11201                            heap_range: req.heap_range,
11202
11203                            responder: SecureMemZeroSubRangeResponder {
11204                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11205                                tx_id: header.tx_id,
11206                            },
11207                        })
11208                    }
11209                    _ => Err(fidl::Error::UnknownOrdinal {
11210                        ordinal: header.ordinal,
11211                        protocol_name:
11212                            <SecureMemMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11213                    }),
11214                }))
11215            },
11216        )
11217    }
11218}
11219
11220/// SecureMem
11221///
11222/// The client is sysmem.  The server is securemem driver.
11223///
11224/// TEE - Trusted Execution Environment.
11225///
11226/// REE - Rich Execution Environment.
11227///
11228/// Enables sysmem to call the securemem driver to get any secure heaps
11229/// configured via the TEE (or via the securemem driver), and set any physical
11230/// secure heaps configured via sysmem.
11231///
11232/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
11233/// it starts quite early during boot and can successfully reserve contiguous
11234/// physical memory.  Presently, fixed-location secure heaps are configured via
11235/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
11236/// protocol intentionally doesn't care which heaps are dynamically-allocated
11237/// and which are fixed-location.
11238#[derive(Debug)]
11239pub enum SecureMemRequest {
11240    /// Gets the physical address and length of any secure heap whose physical
11241    /// range is configured via the TEE.
11242    ///
11243    /// Presently, these will be fixed physical addresses and lengths, with the
11244    /// location plumbed via the TEE.
11245    ///
11246    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11247    /// when there isn't any special heap-specific per-VMO setup or teardown
11248    /// required.
11249    ///
11250    /// The physical range must be secured/protected by the TEE before the
11251    /// securemem driver responds to this request with success.
11252    ///
11253    /// Sysmem should only call this once.  Returning zero heaps is not a
11254    /// failure.
11255    ///
11256    /// Errors:
11257    ///  * ZX_ERR_BAD_STATE - called more than once.
11258    ///  * ZX_ERR_INTERNAL - generic internal error (such as in communication
11259    ///    with TEE which doesn't generate zx_status_t errors).
11260    ///  * other errors are allowed; any other errors should be treated the same
11261    ///    as ZX_ERR_INTERNAL.
11262    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
11263    /// This request from sysmem to the securemem driver gets the properties of
11264    /// a protected/secure heap.
11265    ///
11266    /// This only handles heaps with a single contiguous physical extent.
11267    ///
11268    /// The heap's entire physical range is indicated in case this request needs
11269    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11270    /// temporary HW protection ranges will be deleted before this request
11271    /// completes.
11272    GetPhysicalSecureHeapProperties {
11273        entire_heap: SecureHeapAndRange,
11274        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
11275    },
11276    /// This request from sysmem to the securemem driver conveys a physical
11277    /// range to add, for a heap whose physical range(s) are set up via
11278    /// sysmem.
11279    ///
11280    /// Only sysmem can call this because only sysmem is handed the client end
11281    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11282    /// securemem driver is the server end of this protocol.
11283    ///
11284    /// The securemem driver must configure all the covered offsets as protected
11285    /// before responding to this message with success.
11286    ///
11287    /// On failure, the securemem driver must ensure the protected range was not
11288    /// created.
11289    ///
11290    /// Sysmem must only call this up to once if dynamic_protection_ranges
11291    /// false.
11292    ///
11293    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11294    /// times as long as the current number of ranges never exceeds
11295    /// max_protected_range_count.
11296    ///
11297    /// The caller must not attempt to add a range that matches an
11298    /// already-existing range.  Added ranges can overlap each other as long as
11299    /// no two ranges match exactly.
11300    ///
11301    /// Errors:
11302    ///   * ZX_ERR_BAD_STATE - called more than once when
11303    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11304    ///     heap count to exceed max_protected_range_count.
11305    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11306    ///     to protected_range_granularity.
11307    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11308    ///     with TEE which doesn't generate zx_status_t errors).
11309    ///   * other errors are possible, such as from communication failures or
11310    ///     server propagation of zx_status_t failures.
11311    AddSecureHeapPhysicalRange {
11312        heap_range: SecureHeapAndRange,
11313        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
11314    },
11315    /// This request from sysmem to the securemem driver conveys a physical
11316    /// range to delete, for a heap whose physical range(s) are set up via
11317    /// sysmem.
11318    ///
11319    /// Only sysmem can call this because only sysmem is handed the client end
11320    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11321    /// securemem driver is the server end of this protocol.
11322    ///
11323    /// The securemem driver must configure all the covered offsets as not
11324    /// protected before responding to this message with success.
11325    ///
11326    /// On failure, the securemem driver must ensure the protected range was not
11327    /// deleted.
11328    ///
11329    /// Sysmem must not call this if dynamic_protection_ranges false.
11330    ///
11331    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11332    /// on various ranges that exist at the time of the call.
11333    ///
11334    /// If any portion of the range being deleted is not also covered by another
11335    /// protected range, then any ongoing DMA to any part of the entire range
11336    /// may be interrupted / may fail, potentially in a way that's disruptive to
11337    /// the entire system (bus lockup or similar, depending on device details).
11338    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11339    /// any portion of the range being deleted, unless the caller has other
11340    /// active ranges covering every block of the range being deleted.  Ongoing
11341    /// DMA to/from blocks outside the range being deleted is never impacted by
11342    /// the deletion.
11343    ///
11344    /// Errors:
11345    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11346    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
11347    ///     to protected_range_granularity.
11348    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11349    ///     with TEE which doesn't generate zx_status_t errors).
11350    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11351    ///   * other errors are possible, such as from communication failures or
11352    ///     server propagation of zx_status_t failures.
11353    DeleteSecureHeapPhysicalRange {
11354        heap_range: SecureHeapAndRange,
11355        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
11356    },
11357    /// This request from sysmem to the securemem driver conveys a physical
11358    /// range to modify and its new base and length, for a heap whose physical
11359    /// range(s) are set up via sysmem.
11360    ///
11361    /// Only sysmem can call this because only sysmem is handed the client end
11362    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11363    /// securemem driver is the server end of this protocol.
11364    ///
11365    /// The securemem driver must configure the range to cover only the new
11366    /// offsets before responding to this message with success.
11367    ///
11368    /// On failure, the securemem driver must ensure the range was not changed.
11369    ///
11370    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11371    /// must not call this if !is_mod_protected_range_available.
11372    ///
11373    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11374    /// on various ranges that exist at the time of the call.
11375    ///
11376    /// The range must only be modified at one end or the other, but not both.
11377    /// If the range is getting shorter, and the un-covered blocks are not
11378    /// covered by other active ranges, any ongoing DMA to the entire range
11379    /// that's geting shorter may fail in a way that disrupts the entire system
11380    /// (bus lockup or similar), so the caller must ensure that no DMA is
11381    /// ongoing to any portion of a range that is getting shorter, unless the
11382    /// blocks being un-covered by the modification to this range are all
11383    /// covered by other active ranges, in which case no disruption to ongoing
11384    /// DMA will occur.
11385    ///
11386    /// If a range is modified to become <= zero length, the range is deleted.
11387    ///
11388    /// Errors:
11389    ///   * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
11390    ///   * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
11391    ///     that doesn't conform to protected_range_granularity, or old_range
11392    ///     and new_range differ in both begin and end (disallowed).
11393    ///   * ZX_ERR_INTERNAL - generic internal error (such as in communication
11394    ///     with TEE which doesn't generate zx_status_t errors).
11395    ///   * ZX_ERR_NOT_FOUND - the specified range is not found.
11396    ///   * other errors are possible, such as from communication failures or
11397    ///     server propagation of zx_status_t failures.
11398    ModifySecureHeapPhysicalRange {
11399        range_modification: SecureHeapAndRangeModification,
11400        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
11401    },
11402    /// Zero a sub-range of a currently-existing physical range added via
11403    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11404    /// exactly one physical range, and must not overlap with any other
11405    /// physical range.
11406    ///
11407    /// is_covering_range_explicit - When true, the covering range must be one
11408    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11409    ///     possibly modified since.  When false, the covering range must not
11410    ///     be one of the ranges explicitly created via
11411    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11412    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11413    ///     covering range is typically the entire physical range (or a range
11414    ///     which covers even more) of a heap configured by the TEE and whose
11415    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11416    ///
11417    /// Ongoing DMA is not disrupted by this request.
11418    ZeroSubRange {
11419        is_covering_range_explicit: bool,
11420        heap_range: SecureHeapAndRange,
11421        responder: SecureMemZeroSubRangeResponder,
11422    },
11423}
11424
11425impl SecureMemRequest {
11426    #[allow(irrefutable_let_patterns)]
11427    pub fn into_get_physical_secure_heaps(
11428        self,
11429    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
11430        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
11431            Some((responder))
11432        } else {
11433            None
11434        }
11435    }
11436
11437    #[allow(irrefutable_let_patterns)]
11438    pub fn into_get_physical_secure_heap_properties(
11439        self,
11440    ) -> Option<(SecureHeapAndRange, SecureMemGetPhysicalSecureHeapPropertiesResponder)> {
11441        if let SecureMemRequest::GetPhysicalSecureHeapProperties { entire_heap, responder } = self {
11442            Some((entire_heap, responder))
11443        } else {
11444            None
11445        }
11446    }
11447
11448    #[allow(irrefutable_let_patterns)]
11449    pub fn into_add_secure_heap_physical_range(
11450        self,
11451    ) -> Option<(SecureHeapAndRange, SecureMemAddSecureHeapPhysicalRangeResponder)> {
11452        if let SecureMemRequest::AddSecureHeapPhysicalRange { heap_range, responder } = self {
11453            Some((heap_range, responder))
11454        } else {
11455            None
11456        }
11457    }
11458
11459    #[allow(irrefutable_let_patterns)]
11460    pub fn into_delete_secure_heap_physical_range(
11461        self,
11462    ) -> Option<(SecureHeapAndRange, SecureMemDeleteSecureHeapPhysicalRangeResponder)> {
11463        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { heap_range, responder } = self {
11464            Some((heap_range, responder))
11465        } else {
11466            None
11467        }
11468    }
11469
11470    #[allow(irrefutable_let_patterns)]
11471    pub fn into_modify_secure_heap_physical_range(
11472        self,
11473    ) -> Option<(SecureHeapAndRangeModification, SecureMemModifySecureHeapPhysicalRangeResponder)>
11474    {
11475        if let SecureMemRequest::ModifySecureHeapPhysicalRange { range_modification, responder } =
11476            self
11477        {
11478            Some((range_modification, responder))
11479        } else {
11480            None
11481        }
11482    }
11483
11484    #[allow(irrefutable_let_patterns)]
11485    pub fn into_zero_sub_range(
11486        self,
11487    ) -> Option<(bool, SecureHeapAndRange, SecureMemZeroSubRangeResponder)> {
11488        if let SecureMemRequest::ZeroSubRange {
11489            is_covering_range_explicit,
11490            heap_range,
11491            responder,
11492        } = self
11493        {
11494            Some((is_covering_range_explicit, heap_range, responder))
11495        } else {
11496            None
11497        }
11498    }
11499
11500    /// Name of the method defined in FIDL
11501    pub fn method_name(&self) -> &'static str {
11502        match *self {
11503            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
11504            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
11505                "get_physical_secure_heap_properties"
11506            }
11507            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
11508            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
11509                "delete_secure_heap_physical_range"
11510            }
11511            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
11512                "modify_secure_heap_physical_range"
11513            }
11514            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
11515        }
11516    }
11517}
11518
11519#[derive(Debug, Clone)]
11520pub struct SecureMemControlHandle {
11521    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11522}
11523
11524impl fidl::endpoints::ControlHandle for SecureMemControlHandle {
11525    fn shutdown(&self) {
11526        self.inner.shutdown()
11527    }
11528
11529    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11530        self.inner.shutdown_with_epitaph(status)
11531    }
11532
11533    fn is_closed(&self) -> bool {
11534        self.inner.channel().is_closed()
11535    }
11536    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11537        self.inner.channel().on_closed()
11538    }
11539
11540    #[cfg(target_os = "fuchsia")]
11541    fn signal_peer(
11542        &self,
11543        clear_mask: zx::Signals,
11544        set_mask: zx::Signals,
11545    ) -> Result<(), zx_status::Status> {
11546        use fidl::Peered;
11547        self.inner.channel().signal_peer(clear_mask, set_mask)
11548    }
11549}
11550
11551impl SecureMemControlHandle {}
11552
11553#[must_use = "FIDL methods require a response to be sent"]
11554#[derive(Debug)]
11555pub struct SecureMemGetPhysicalSecureHeapsResponder {
11556    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11557    tx_id: u32,
11558}
11559
11560/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11561/// if the responder is dropped without sending a response, so that the client
11562/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11563impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
11564    fn drop(&mut self) {
11565        self.control_handle.shutdown();
11566        // Safety: drops once, never accessed again
11567        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11568    }
11569}
11570
11571impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapsResponder {
11572    type ControlHandle = SecureMemControlHandle;
11573
11574    fn control_handle(&self) -> &SecureMemControlHandle {
11575        &self.control_handle
11576    }
11577
11578    fn drop_without_shutdown(mut self) {
11579        // Safety: drops once, never accessed again due to mem::forget
11580        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11581        // Prevent Drop from running (which would shut down the channel)
11582        std::mem::forget(self);
11583    }
11584}
11585
11586impl SecureMemGetPhysicalSecureHeapsResponder {
11587    /// Sends a response to the FIDL transaction.
11588    ///
11589    /// Sets the channel to shutdown if an error occurs.
11590    pub fn send(self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11591        let _result = self.send_raw(result);
11592        if _result.is_err() {
11593            self.control_handle.shutdown();
11594        }
11595        self.drop_without_shutdown();
11596        _result
11597    }
11598
11599    /// Similar to "send" but does not shutdown the channel if an error occurs.
11600    pub fn send_no_shutdown_on_err(
11601        self,
11602        mut result: Result<&SecureHeapsAndRanges, i32>,
11603    ) -> Result<(), fidl::Error> {
11604        let _result = self.send_raw(result);
11605        self.drop_without_shutdown();
11606        _result
11607    }
11608
11609    fn send_raw(&self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
11610        self.control_handle.inner.send::<fidl::encoding::ResultType<
11611            SecureMemGetPhysicalSecureHeapsResponse,
11612            i32,
11613        >>(
11614            result.map(|heaps| (heaps,)),
11615            self.tx_id,
11616            0x782319d6ce7fa05,
11617            fidl::encoding::DynamicFlags::empty(),
11618        )
11619    }
11620}
11621
11622#[must_use = "FIDL methods require a response to be sent"]
11623#[derive(Debug)]
11624pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
11625    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11626    tx_id: u32,
11627}
11628
11629/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11630/// if the responder is dropped without sending a response, so that the client
11631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11632impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11633    fn drop(&mut self) {
11634        self.control_handle.shutdown();
11635        // Safety: drops once, never accessed again
11636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11637    }
11638}
11639
11640impl fidl::endpoints::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
11641    type ControlHandle = SecureMemControlHandle;
11642
11643    fn control_handle(&self) -> &SecureMemControlHandle {
11644        &self.control_handle
11645    }
11646
11647    fn drop_without_shutdown(mut self) {
11648        // Safety: drops once, never accessed again due to mem::forget
11649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11650        // Prevent Drop from running (which would shut down the channel)
11651        std::mem::forget(self);
11652    }
11653}
11654
11655impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
11656    /// Sends a response to the FIDL transaction.
11657    ///
11658    /// Sets the channel to shutdown if an error occurs.
11659    pub fn send(self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11660        let _result = self.send_raw(result);
11661        if _result.is_err() {
11662            self.control_handle.shutdown();
11663        }
11664        self.drop_without_shutdown();
11665        _result
11666    }
11667
11668    /// Similar to "send" but does not shutdown the channel if an error occurs.
11669    pub fn send_no_shutdown_on_err(
11670        self,
11671        mut result: Result<&SecureHeapProperties, i32>,
11672    ) -> Result<(), fidl::Error> {
11673        let _result = self.send_raw(result);
11674        self.drop_without_shutdown();
11675        _result
11676    }
11677
11678    fn send_raw(&self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
11679        self.control_handle.inner.send::<fidl::encoding::ResultType<
11680            SecureMemGetPhysicalSecureHeapPropertiesResponse,
11681            i32,
11682        >>(
11683            result.map(|properties| (properties,)),
11684            self.tx_id,
11685            0x26404e23f1271214,
11686            fidl::encoding::DynamicFlags::empty(),
11687        )
11688    }
11689}
11690
11691#[must_use = "FIDL methods require a response to be sent"]
11692#[derive(Debug)]
11693pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
11694    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11695    tx_id: u32,
11696}
11697
11698/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11699/// if the responder is dropped without sending a response, so that the client
11700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11701impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
11702    fn drop(&mut self) {
11703        self.control_handle.shutdown();
11704        // Safety: drops once, never accessed again
11705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11706    }
11707}
11708
11709impl fidl::endpoints::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
11710    type ControlHandle = SecureMemControlHandle;
11711
11712    fn control_handle(&self) -> &SecureMemControlHandle {
11713        &self.control_handle
11714    }
11715
11716    fn drop_without_shutdown(mut self) {
11717        // Safety: drops once, never accessed again due to mem::forget
11718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11719        // Prevent Drop from running (which would shut down the channel)
11720        std::mem::forget(self);
11721    }
11722}
11723
11724impl SecureMemAddSecureHeapPhysicalRangeResponder {
11725    /// Sends a response to the FIDL transaction.
11726    ///
11727    /// Sets the channel to shutdown if an error occurs.
11728    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11729        let _result = self.send_raw(result);
11730        if _result.is_err() {
11731            self.control_handle.shutdown();
11732        }
11733        self.drop_without_shutdown();
11734        _result
11735    }
11736
11737    /// Similar to "send" but does not shutdown the channel if an error occurs.
11738    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11739        let _result = self.send_raw(result);
11740        self.drop_without_shutdown();
11741        _result
11742    }
11743
11744    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11745        self.control_handle
11746            .inner
11747            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11748                result,
11749                self.tx_id,
11750                0x1ca1abcee8a0b33e,
11751                fidl::encoding::DynamicFlags::empty(),
11752            )
11753    }
11754}
11755
11756#[must_use = "FIDL methods require a response to be sent"]
11757#[derive(Debug)]
11758pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
11759    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11760    tx_id: u32,
11761}
11762
11763/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11764/// if the responder is dropped without sending a response, so that the client
11765/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11766impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
11767    fn drop(&mut self) {
11768        self.control_handle.shutdown();
11769        // Safety: drops once, never accessed again
11770        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11771    }
11772}
11773
11774impl fidl::endpoints::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
11775    type ControlHandle = SecureMemControlHandle;
11776
11777    fn control_handle(&self) -> &SecureMemControlHandle {
11778        &self.control_handle
11779    }
11780
11781    fn drop_without_shutdown(mut self) {
11782        // Safety: drops once, never accessed again due to mem::forget
11783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11784        // Prevent Drop from running (which would shut down the channel)
11785        std::mem::forget(self);
11786    }
11787}
11788
11789impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
11790    /// Sends a response to the FIDL transaction.
11791    ///
11792    /// Sets the channel to shutdown if an error occurs.
11793    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11794        let _result = self.send_raw(result);
11795        if _result.is_err() {
11796            self.control_handle.shutdown();
11797        }
11798        self.drop_without_shutdown();
11799        _result
11800    }
11801
11802    /// Similar to "send" but does not shutdown the channel if an error occurs.
11803    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11804        let _result = self.send_raw(result);
11805        self.drop_without_shutdown();
11806        _result
11807    }
11808
11809    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11810        self.control_handle
11811            .inner
11812            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11813                result,
11814                self.tx_id,
11815                0x728a953e56df92ee,
11816                fidl::encoding::DynamicFlags::empty(),
11817            )
11818    }
11819}
11820
11821#[must_use = "FIDL methods require a response to be sent"]
11822#[derive(Debug)]
11823pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
11824    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11825    tx_id: u32,
11826}
11827
11828/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11829/// if the responder is dropped without sending a response, so that the client
11830/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11831impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
11832    fn drop(&mut self) {
11833        self.control_handle.shutdown();
11834        // Safety: drops once, never accessed again
11835        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11836    }
11837}
11838
11839impl fidl::endpoints::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
11840    type ControlHandle = SecureMemControlHandle;
11841
11842    fn control_handle(&self) -> &SecureMemControlHandle {
11843        &self.control_handle
11844    }
11845
11846    fn drop_without_shutdown(mut self) {
11847        // Safety: drops once, never accessed again due to mem::forget
11848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11849        // Prevent Drop from running (which would shut down the channel)
11850        std::mem::forget(self);
11851    }
11852}
11853
11854impl SecureMemModifySecureHeapPhysicalRangeResponder {
11855    /// Sends a response to the FIDL transaction.
11856    ///
11857    /// Sets the channel to shutdown if an error occurs.
11858    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11859        let _result = self.send_raw(result);
11860        if _result.is_err() {
11861            self.control_handle.shutdown();
11862        }
11863        self.drop_without_shutdown();
11864        _result
11865    }
11866
11867    /// Similar to "send" but does not shutdown the channel if an error occurs.
11868    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11869        let _result = self.send_raw(result);
11870        self.drop_without_shutdown();
11871        _result
11872    }
11873
11874    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11875        self.control_handle
11876            .inner
11877            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11878                result,
11879                self.tx_id,
11880                0x154fbfa3646a890d,
11881                fidl::encoding::DynamicFlags::empty(),
11882            )
11883    }
11884}
11885
11886#[must_use = "FIDL methods require a response to be sent"]
11887#[derive(Debug)]
11888pub struct SecureMemZeroSubRangeResponder {
11889    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
11890    tx_id: u32,
11891}
11892
11893/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
11894/// if the responder is dropped without sending a response, so that the client
11895/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11896impl std::ops::Drop for SecureMemZeroSubRangeResponder {
11897    fn drop(&mut self) {
11898        self.control_handle.shutdown();
11899        // Safety: drops once, never accessed again
11900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11901    }
11902}
11903
11904impl fidl::endpoints::Responder for SecureMemZeroSubRangeResponder {
11905    type ControlHandle = SecureMemControlHandle;
11906
11907    fn control_handle(&self) -> &SecureMemControlHandle {
11908        &self.control_handle
11909    }
11910
11911    fn drop_without_shutdown(mut self) {
11912        // Safety: drops once, never accessed again due to mem::forget
11913        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11914        // Prevent Drop from running (which would shut down the channel)
11915        std::mem::forget(self);
11916    }
11917}
11918
11919impl SecureMemZeroSubRangeResponder {
11920    /// Sends a response to the FIDL transaction.
11921    ///
11922    /// Sets the channel to shutdown if an error occurs.
11923    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11924        let _result = self.send_raw(result);
11925        if _result.is_err() {
11926            self.control_handle.shutdown();
11927        }
11928        self.drop_without_shutdown();
11929        _result
11930    }
11931
11932    /// Similar to "send" but does not shutdown the channel if an error occurs.
11933    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11934        let _result = self.send_raw(result);
11935        self.drop_without_shutdown();
11936        _result
11937    }
11938
11939    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
11940        self.control_handle
11941            .inner
11942            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
11943                result,
11944                self.tx_id,
11945                0x7480f72bb5bc7e5b,
11946                fidl::encoding::DynamicFlags::empty(),
11947            )
11948    }
11949}
11950
11951mod internal {
11952    use super::*;
11953
11954    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
11955        type Borrowed<'a> = &'a mut Self;
11956        fn take_or_borrow<'a>(
11957            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11958        ) -> Self::Borrowed<'a> {
11959            value
11960        }
11961    }
11962
11963    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
11964        type Owned = Self;
11965
11966        #[inline(always)]
11967        fn inline_align(_context: fidl::encoding::Context) -> usize {
11968            4
11969        }
11970
11971        #[inline(always)]
11972        fn inline_size(_context: fidl::encoding::Context) -> usize {
11973            4
11974        }
11975    }
11976
11977    unsafe impl
11978        fidl::encoding::Encode<
11979            AllocatorAllocateNonSharedCollectionRequest,
11980            fidl::encoding::DefaultFuchsiaResourceDialect,
11981        > for &mut AllocatorAllocateNonSharedCollectionRequest
11982    {
11983        #[inline]
11984        unsafe fn encode(
11985            self,
11986            encoder: &mut fidl::encoding::Encoder<
11987                '_,
11988                fidl::encoding::DefaultFuchsiaResourceDialect,
11989            >,
11990            offset: usize,
11991            _depth: fidl::encoding::Depth,
11992        ) -> fidl::Result<()> {
11993            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
11994            // Delegate to tuple encoding.
11995            fidl::encoding::Encode::<AllocatorAllocateNonSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
11996                (
11997                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.collection_request),
11998                ),
11999                encoder, offset, _depth
12000            )
12001        }
12002    }
12003    unsafe impl<
12004        T0: fidl::encoding::Encode<
12005                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12006                fidl::encoding::DefaultFuchsiaResourceDialect,
12007            >,
12008    >
12009        fidl::encoding::Encode<
12010            AllocatorAllocateNonSharedCollectionRequest,
12011            fidl::encoding::DefaultFuchsiaResourceDialect,
12012        > for (T0,)
12013    {
12014        #[inline]
12015        unsafe fn encode(
12016            self,
12017            encoder: &mut fidl::encoding::Encoder<
12018                '_,
12019                fidl::encoding::DefaultFuchsiaResourceDialect,
12020            >,
12021            offset: usize,
12022            depth: fidl::encoding::Depth,
12023        ) -> fidl::Result<()> {
12024            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
12025            // Zero out padding regions. There's no need to apply masks
12026            // because the unmasked parts will be overwritten by fields.
12027            // Write the fields.
12028            self.0.encode(encoder, offset + 0, depth)?;
12029            Ok(())
12030        }
12031    }
12032
12033    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12034        for AllocatorAllocateNonSharedCollectionRequest
12035    {
12036        #[inline(always)]
12037        fn new_empty() -> Self {
12038            Self {
12039                collection_request: fidl::new_empty!(
12040                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12041                    fidl::encoding::DefaultFuchsiaResourceDialect
12042                ),
12043            }
12044        }
12045
12046        #[inline]
12047        unsafe fn decode(
12048            &mut self,
12049            decoder: &mut fidl::encoding::Decoder<
12050                '_,
12051                fidl::encoding::DefaultFuchsiaResourceDialect,
12052            >,
12053            offset: usize,
12054            _depth: fidl::encoding::Depth,
12055        ) -> fidl::Result<()> {
12056            decoder.debug_check_bounds::<Self>(offset);
12057            // Verify that padding bytes are zero.
12058            fidl::decode!(
12059                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12060                fidl::encoding::DefaultFuchsiaResourceDialect,
12061                &mut self.collection_request,
12062                decoder,
12063                offset + 0,
12064                _depth
12065            )?;
12066            Ok(())
12067        }
12068    }
12069
12070    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
12071        type Borrowed<'a> = &'a mut Self;
12072        fn take_or_borrow<'a>(
12073            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12074        ) -> Self::Borrowed<'a> {
12075            value
12076        }
12077    }
12078
12079    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
12080        type Owned = Self;
12081
12082        #[inline(always)]
12083        fn inline_align(_context: fidl::encoding::Context) -> usize {
12084            4
12085        }
12086
12087        #[inline(always)]
12088        fn inline_size(_context: fidl::encoding::Context) -> usize {
12089            4
12090        }
12091    }
12092
12093    unsafe impl
12094        fidl::encoding::Encode<
12095            AllocatorAllocateSharedCollectionRequest,
12096            fidl::encoding::DefaultFuchsiaResourceDialect,
12097        > for &mut AllocatorAllocateSharedCollectionRequest
12098    {
12099        #[inline]
12100        unsafe fn encode(
12101            self,
12102            encoder: &mut fidl::encoding::Encoder<
12103                '_,
12104                fidl::encoding::DefaultFuchsiaResourceDialect,
12105            >,
12106            offset: usize,
12107            _depth: fidl::encoding::Depth,
12108        ) -> fidl::Result<()> {
12109            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12110            // Delegate to tuple encoding.
12111            fidl::encoding::Encode::<
12112                AllocatorAllocateSharedCollectionRequest,
12113                fidl::encoding::DefaultFuchsiaResourceDialect,
12114            >::encode(
12115                (
12116                    <fidl::encoding::Endpoint<
12117                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12118                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12119                        &mut self.token_request,
12120                    ),
12121                ),
12122                encoder,
12123                offset,
12124                _depth,
12125            )
12126        }
12127    }
12128    unsafe impl<
12129        T0: fidl::encoding::Encode<
12130                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12131                fidl::encoding::DefaultFuchsiaResourceDialect,
12132            >,
12133    >
12134        fidl::encoding::Encode<
12135            AllocatorAllocateSharedCollectionRequest,
12136            fidl::encoding::DefaultFuchsiaResourceDialect,
12137        > for (T0,)
12138    {
12139        #[inline]
12140        unsafe fn encode(
12141            self,
12142            encoder: &mut fidl::encoding::Encoder<
12143                '_,
12144                fidl::encoding::DefaultFuchsiaResourceDialect,
12145            >,
12146            offset: usize,
12147            depth: fidl::encoding::Depth,
12148        ) -> fidl::Result<()> {
12149            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
12150            // Zero out padding regions. There's no need to apply masks
12151            // because the unmasked parts will be overwritten by fields.
12152            // Write the fields.
12153            self.0.encode(encoder, offset + 0, depth)?;
12154            Ok(())
12155        }
12156    }
12157
12158    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12159        for AllocatorAllocateSharedCollectionRequest
12160    {
12161        #[inline(always)]
12162        fn new_empty() -> Self {
12163            Self {
12164                token_request: fidl::new_empty!(
12165                    fidl::encoding::Endpoint<
12166                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12167                    >,
12168                    fidl::encoding::DefaultFuchsiaResourceDialect
12169                ),
12170            }
12171        }
12172
12173        #[inline]
12174        unsafe fn decode(
12175            &mut self,
12176            decoder: &mut fidl::encoding::Decoder<
12177                '_,
12178                fidl::encoding::DefaultFuchsiaResourceDialect,
12179            >,
12180            offset: usize,
12181            _depth: fidl::encoding::Depth,
12182        ) -> fidl::Result<()> {
12183            decoder.debug_check_bounds::<Self>(offset);
12184            // Verify that padding bytes are zero.
12185            fidl::decode!(
12186                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12187                fidl::encoding::DefaultFuchsiaResourceDialect,
12188                &mut self.token_request,
12189                decoder,
12190                offset + 0,
12191                _depth
12192            )?;
12193            Ok(())
12194        }
12195    }
12196
12197    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
12198        type Borrowed<'a> = &'a mut Self;
12199        fn take_or_borrow<'a>(
12200            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12201        ) -> Self::Borrowed<'a> {
12202            value
12203        }
12204    }
12205
12206    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
12207        type Owned = Self;
12208
12209        #[inline(always)]
12210        fn inline_align(_context: fidl::encoding::Context) -> usize {
12211            4
12212        }
12213
12214        #[inline(always)]
12215        fn inline_size(_context: fidl::encoding::Context) -> usize {
12216            8
12217        }
12218    }
12219
12220    unsafe impl
12221        fidl::encoding::Encode<
12222            AllocatorBindSharedCollectionRequest,
12223            fidl::encoding::DefaultFuchsiaResourceDialect,
12224        > for &mut AllocatorBindSharedCollectionRequest
12225    {
12226        #[inline]
12227        unsafe fn encode(
12228            self,
12229            encoder: &mut fidl::encoding::Encoder<
12230                '_,
12231                fidl::encoding::DefaultFuchsiaResourceDialect,
12232            >,
12233            offset: usize,
12234            _depth: fidl::encoding::Depth,
12235        ) -> fidl::Result<()> {
12236            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12237            // Delegate to tuple encoding.
12238            fidl::encoding::Encode::<AllocatorBindSharedCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12239                (
12240                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
12241                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer_collection_request),
12242                ),
12243                encoder, offset, _depth
12244            )
12245        }
12246    }
12247    unsafe impl<
12248        T0: fidl::encoding::Encode<
12249                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12250                fidl::encoding::DefaultFuchsiaResourceDialect,
12251            >,
12252        T1: fidl::encoding::Encode<
12253                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12254                fidl::encoding::DefaultFuchsiaResourceDialect,
12255            >,
12256    >
12257        fidl::encoding::Encode<
12258            AllocatorBindSharedCollectionRequest,
12259            fidl::encoding::DefaultFuchsiaResourceDialect,
12260        > for (T0, T1)
12261    {
12262        #[inline]
12263        unsafe fn encode(
12264            self,
12265            encoder: &mut fidl::encoding::Encoder<
12266                '_,
12267                fidl::encoding::DefaultFuchsiaResourceDialect,
12268            >,
12269            offset: usize,
12270            depth: fidl::encoding::Depth,
12271        ) -> fidl::Result<()> {
12272            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
12273            // Zero out padding regions. There's no need to apply masks
12274            // because the unmasked parts will be overwritten by fields.
12275            // Write the fields.
12276            self.0.encode(encoder, offset + 0, depth)?;
12277            self.1.encode(encoder, offset + 4, depth)?;
12278            Ok(())
12279        }
12280    }
12281
12282    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12283        for AllocatorBindSharedCollectionRequest
12284    {
12285        #[inline(always)]
12286        fn new_empty() -> Self {
12287            Self {
12288                token: fidl::new_empty!(
12289                    fidl::encoding::Endpoint<
12290                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
12291                    >,
12292                    fidl::encoding::DefaultFuchsiaResourceDialect
12293                ),
12294                buffer_collection_request: fidl::new_empty!(
12295                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12296                    fidl::encoding::DefaultFuchsiaResourceDialect
12297                ),
12298            }
12299        }
12300
12301        #[inline]
12302        unsafe fn decode(
12303            &mut self,
12304            decoder: &mut fidl::encoding::Decoder<
12305                '_,
12306                fidl::encoding::DefaultFuchsiaResourceDialect,
12307            >,
12308            offset: usize,
12309            _depth: fidl::encoding::Depth,
12310        ) -> fidl::Result<()> {
12311            decoder.debug_check_bounds::<Self>(offset);
12312            // Verify that padding bytes are zero.
12313            fidl::decode!(
12314                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>>,
12315                fidl::encoding::DefaultFuchsiaResourceDialect,
12316                &mut self.token,
12317                decoder,
12318                offset + 0,
12319                _depth
12320            )?;
12321            fidl::decode!(
12322                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionMarker>>,
12323                fidl::encoding::DefaultFuchsiaResourceDialect,
12324                &mut self.buffer_collection_request,
12325                decoder,
12326                offset + 4,
12327                _depth
12328            )?;
12329            Ok(())
12330        }
12331    }
12332
12333    impl fidl::encoding::ResourceTypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12334        type Borrowed<'a> = &'a mut Self;
12335        fn take_or_borrow<'a>(
12336            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12337        ) -> Self::Borrowed<'a> {
12338            value
12339        }
12340    }
12341
12342    unsafe impl fidl::encoding::TypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
12343        type Owned = Self;
12344
12345        #[inline(always)]
12346        fn inline_align(_context: fidl::encoding::Context) -> usize {
12347            4
12348        }
12349
12350        #[inline(always)]
12351        fn inline_size(_context: fidl::encoding::Context) -> usize {
12352            4
12353        }
12354    }
12355
12356    unsafe impl
12357        fidl::encoding::Encode<
12358            AllocatorConnectToSysmem2AllocatorRequest,
12359            fidl::encoding::DefaultFuchsiaResourceDialect,
12360        > for &mut AllocatorConnectToSysmem2AllocatorRequest
12361    {
12362        #[inline]
12363        unsafe fn encode(
12364            self,
12365            encoder: &mut fidl::encoding::Encoder<
12366                '_,
12367                fidl::encoding::DefaultFuchsiaResourceDialect,
12368            >,
12369            offset: usize,
12370            _depth: fidl::encoding::Depth,
12371        ) -> fidl::Result<()> {
12372            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12373            // Delegate to tuple encoding.
12374            fidl::encoding::Encode::<
12375                AllocatorConnectToSysmem2AllocatorRequest,
12376                fidl::encoding::DefaultFuchsiaResourceDialect,
12377            >::encode(
12378                (<fidl::encoding::Endpoint<
12379                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12380                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12381                    &mut self.allocator_request,
12382                ),),
12383                encoder,
12384                offset,
12385                _depth,
12386            )
12387        }
12388    }
12389    unsafe impl<
12390        T0: fidl::encoding::Encode<
12391                fidl::encoding::Endpoint<
12392                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12393                >,
12394                fidl::encoding::DefaultFuchsiaResourceDialect,
12395            >,
12396    >
12397        fidl::encoding::Encode<
12398            AllocatorConnectToSysmem2AllocatorRequest,
12399            fidl::encoding::DefaultFuchsiaResourceDialect,
12400        > for (T0,)
12401    {
12402        #[inline]
12403        unsafe fn encode(
12404            self,
12405            encoder: &mut fidl::encoding::Encoder<
12406                '_,
12407                fidl::encoding::DefaultFuchsiaResourceDialect,
12408            >,
12409            offset: usize,
12410            depth: fidl::encoding::Depth,
12411        ) -> fidl::Result<()> {
12412            encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
12413            // Zero out padding regions. There's no need to apply masks
12414            // because the unmasked parts will be overwritten by fields.
12415            // Write the fields.
12416            self.0.encode(encoder, offset + 0, depth)?;
12417            Ok(())
12418        }
12419    }
12420
12421    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12422        for AllocatorConnectToSysmem2AllocatorRequest
12423    {
12424        #[inline(always)]
12425        fn new_empty() -> Self {
12426            Self {
12427                allocator_request: fidl::new_empty!(
12428                    fidl::encoding::Endpoint<
12429                        fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12430                    >,
12431                    fidl::encoding::DefaultFuchsiaResourceDialect
12432                ),
12433            }
12434        }
12435
12436        #[inline]
12437        unsafe fn decode(
12438            &mut self,
12439            decoder: &mut fidl::encoding::Decoder<
12440                '_,
12441                fidl::encoding::DefaultFuchsiaResourceDialect,
12442            >,
12443            offset: usize,
12444            _depth: fidl::encoding::Depth,
12445        ) -> fidl::Result<()> {
12446            decoder.debug_check_bounds::<Self>(offset);
12447            // Verify that padding bytes are zero.
12448            fidl::decode!(
12449                fidl::encoding::Endpoint<
12450                    fidl::endpoints::ServerEnd<fidl_fuchsia_sysmem2::AllocatorMarker>,
12451                >,
12452                fidl::encoding::DefaultFuchsiaResourceDialect,
12453                &mut self.allocator_request,
12454                decoder,
12455                offset + 0,
12456                _depth
12457            )?;
12458            Ok(())
12459        }
12460    }
12461
12462    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12463        type Borrowed<'a> = &'a mut Self;
12464        fn take_or_borrow<'a>(
12465            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12466        ) -> Self::Borrowed<'a> {
12467            value
12468        }
12469    }
12470
12471    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
12472        type Owned = Self;
12473
12474        #[inline(always)]
12475        fn inline_align(_context: fidl::encoding::Context) -> usize {
12476            4
12477        }
12478
12479        #[inline(always)]
12480        fn inline_size(_context: fidl::encoding::Context) -> usize {
12481            8
12482        }
12483    }
12484
12485    unsafe impl
12486        fidl::encoding::Encode<
12487            BufferCollectionAttachLifetimeTrackingRequest,
12488            fidl::encoding::DefaultFuchsiaResourceDialect,
12489        > for &mut BufferCollectionAttachLifetimeTrackingRequest
12490    {
12491        #[inline]
12492        unsafe fn encode(
12493            self,
12494            encoder: &mut fidl::encoding::Encoder<
12495                '_,
12496                fidl::encoding::DefaultFuchsiaResourceDialect,
12497            >,
12498            offset: usize,
12499            _depth: fidl::encoding::Depth,
12500        ) -> fidl::Result<()> {
12501            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12502            // Delegate to tuple encoding.
12503            fidl::encoding::Encode::<
12504                BufferCollectionAttachLifetimeTrackingRequest,
12505                fidl::encoding::DefaultFuchsiaResourceDialect,
12506            >::encode(
12507                (
12508                    <fidl::encoding::HandleType<
12509                        fidl::EventPair,
12510                        { fidl::ObjectType::EVENTPAIR.into_raw() },
12511                        2147483648,
12512                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12513                        &mut self.server_end
12514                    ),
12515                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffers_remaining),
12516                ),
12517                encoder,
12518                offset,
12519                _depth,
12520            )
12521        }
12522    }
12523    unsafe impl<
12524        T0: fidl::encoding::Encode<
12525                fidl::encoding::HandleType<
12526                    fidl::EventPair,
12527                    { fidl::ObjectType::EVENTPAIR.into_raw() },
12528                    2147483648,
12529                >,
12530                fidl::encoding::DefaultFuchsiaResourceDialect,
12531            >,
12532        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12533    >
12534        fidl::encoding::Encode<
12535            BufferCollectionAttachLifetimeTrackingRequest,
12536            fidl::encoding::DefaultFuchsiaResourceDialect,
12537        > for (T0, T1)
12538    {
12539        #[inline]
12540        unsafe fn encode(
12541            self,
12542            encoder: &mut fidl::encoding::Encoder<
12543                '_,
12544                fidl::encoding::DefaultFuchsiaResourceDialect,
12545            >,
12546            offset: usize,
12547            depth: fidl::encoding::Depth,
12548        ) -> fidl::Result<()> {
12549            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
12550            // Zero out padding regions. There's no need to apply masks
12551            // because the unmasked parts will be overwritten by fields.
12552            // Write the fields.
12553            self.0.encode(encoder, offset + 0, depth)?;
12554            self.1.encode(encoder, offset + 4, depth)?;
12555            Ok(())
12556        }
12557    }
12558
12559    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12560        for BufferCollectionAttachLifetimeTrackingRequest
12561    {
12562        #[inline(always)]
12563        fn new_empty() -> Self {
12564            Self {
12565                server_end: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
12566                buffers_remaining: fidl::new_empty!(
12567                    u32,
12568                    fidl::encoding::DefaultFuchsiaResourceDialect
12569                ),
12570            }
12571        }
12572
12573        #[inline]
12574        unsafe fn decode(
12575            &mut self,
12576            decoder: &mut fidl::encoding::Decoder<
12577                '_,
12578                fidl::encoding::DefaultFuchsiaResourceDialect,
12579            >,
12580            offset: usize,
12581            _depth: fidl::encoding::Depth,
12582        ) -> fidl::Result<()> {
12583            decoder.debug_check_bounds::<Self>(offset);
12584            // Verify that padding bytes are zero.
12585            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_end, decoder, offset + 0, _depth)?;
12586            fidl::decode!(
12587                u32,
12588                fidl::encoding::DefaultFuchsiaResourceDialect,
12589                &mut self.buffers_remaining,
12590                decoder,
12591                offset + 4,
12592                _depth
12593            )?;
12594            Ok(())
12595        }
12596    }
12597
12598    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
12599        type Borrowed<'a> = &'a mut Self;
12600        fn take_or_borrow<'a>(
12601            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12602        ) -> Self::Borrowed<'a> {
12603            value
12604        }
12605    }
12606
12607    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
12608        type Owned = Self;
12609
12610        #[inline(always)]
12611        fn inline_align(_context: fidl::encoding::Context) -> usize {
12612            4
12613        }
12614
12615        #[inline(always)]
12616        fn inline_size(_context: fidl::encoding::Context) -> usize {
12617            8
12618        }
12619    }
12620
12621    unsafe impl
12622        fidl::encoding::Encode<
12623            BufferCollectionAttachTokenRequest,
12624            fidl::encoding::DefaultFuchsiaResourceDialect,
12625        > for &mut BufferCollectionAttachTokenRequest
12626    {
12627        #[inline]
12628        unsafe fn encode(
12629            self,
12630            encoder: &mut fidl::encoding::Encoder<
12631                '_,
12632                fidl::encoding::DefaultFuchsiaResourceDialect,
12633            >,
12634            offset: usize,
12635            _depth: fidl::encoding::Depth,
12636        ) -> fidl::Result<()> {
12637            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12638            // Delegate to tuple encoding.
12639            fidl::encoding::Encode::<
12640                BufferCollectionAttachTokenRequest,
12641                fidl::encoding::DefaultFuchsiaResourceDialect,
12642            >::encode(
12643                (
12644                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
12645                    <fidl::encoding::Endpoint<
12646                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12647                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12648                        &mut self.token_request,
12649                    ),
12650                ),
12651                encoder,
12652                offset,
12653                _depth,
12654            )
12655        }
12656    }
12657    unsafe impl<
12658        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12659        T1: fidl::encoding::Encode<
12660                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12661                fidl::encoding::DefaultFuchsiaResourceDialect,
12662            >,
12663    >
12664        fidl::encoding::Encode<
12665            BufferCollectionAttachTokenRequest,
12666            fidl::encoding::DefaultFuchsiaResourceDialect,
12667        > for (T0, T1)
12668    {
12669        #[inline]
12670        unsafe fn encode(
12671            self,
12672            encoder: &mut fidl::encoding::Encoder<
12673                '_,
12674                fidl::encoding::DefaultFuchsiaResourceDialect,
12675            >,
12676            offset: usize,
12677            depth: fidl::encoding::Depth,
12678        ) -> fidl::Result<()> {
12679            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
12680            // Zero out padding regions. There's no need to apply masks
12681            // because the unmasked parts will be overwritten by fields.
12682            // Write the fields.
12683            self.0.encode(encoder, offset + 0, depth)?;
12684            self.1.encode(encoder, offset + 4, depth)?;
12685            Ok(())
12686        }
12687    }
12688
12689    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12690        for BufferCollectionAttachTokenRequest
12691    {
12692        #[inline(always)]
12693        fn new_empty() -> Self {
12694            Self {
12695                rights_attenuation_mask: fidl::new_empty!(
12696                    u32,
12697                    fidl::encoding::DefaultFuchsiaResourceDialect
12698                ),
12699                token_request: fidl::new_empty!(
12700                    fidl::encoding::Endpoint<
12701                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
12702                    >,
12703                    fidl::encoding::DefaultFuchsiaResourceDialect
12704                ),
12705            }
12706        }
12707
12708        #[inline]
12709        unsafe fn decode(
12710            &mut self,
12711            decoder: &mut fidl::encoding::Decoder<
12712                '_,
12713                fidl::encoding::DefaultFuchsiaResourceDialect,
12714            >,
12715            offset: usize,
12716            _depth: fidl::encoding::Depth,
12717        ) -> fidl::Result<()> {
12718            decoder.debug_check_bounds::<Self>(offset);
12719            // Verify that padding bytes are zero.
12720            fidl::decode!(
12721                u32,
12722                fidl::encoding::DefaultFuchsiaResourceDialect,
12723                &mut self.rights_attenuation_mask,
12724                decoder,
12725                offset + 0,
12726                _depth
12727            )?;
12728            fidl::decode!(
12729                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
12730                fidl::encoding::DefaultFuchsiaResourceDialect,
12731                &mut self.token_request,
12732                decoder,
12733                offset + 4,
12734                _depth
12735            )?;
12736            Ok(())
12737        }
12738    }
12739
12740    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
12741        type Borrowed<'a> = &'a mut Self;
12742        fn take_or_borrow<'a>(
12743            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12744        ) -> Self::Borrowed<'a> {
12745            value
12746        }
12747    }
12748
12749    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
12750        type Owned = Self;
12751
12752        #[inline(always)]
12753        fn inline_align(_context: fidl::encoding::Context) -> usize {
12754            8
12755        }
12756
12757        #[inline(always)]
12758        fn inline_size(_context: fidl::encoding::Context) -> usize {
12759            352
12760        }
12761    }
12762
12763    unsafe impl
12764        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
12765        for &mut BufferCollectionInfo
12766    {
12767        #[inline]
12768        unsafe fn encode(
12769            self,
12770            encoder: &mut fidl::encoding::Encoder<
12771                '_,
12772                fidl::encoding::DefaultFuchsiaResourceDialect,
12773            >,
12774            offset: usize,
12775            _depth: fidl::encoding::Depth,
12776        ) -> fidl::Result<()> {
12777            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
12778            // Delegate to tuple encoding.
12779            fidl::encoding::Encode::<
12780                BufferCollectionInfo,
12781                fidl::encoding::DefaultFuchsiaResourceDialect,
12782            >::encode(
12783                (
12784                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
12785                    <BufferFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
12786                    <fidl::encoding::Array<
12787                        fidl::encoding::Optional<
12788                            fidl::encoding::HandleType<
12789                                fidl::Vmo,
12790                                { fidl::ObjectType::VMO.into_raw() },
12791                                2147483648,
12792                            >,
12793                        >,
12794                        64,
12795                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
12796                        &mut self.vmos
12797                    ),
12798                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_size),
12799                ),
12800                encoder,
12801                offset,
12802                _depth,
12803            )
12804        }
12805    }
12806    unsafe impl<
12807        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12808        T1: fidl::encoding::Encode<BufferFormat, fidl::encoding::DefaultFuchsiaResourceDialect>,
12809        T2: fidl::encoding::Encode<
12810                fidl::encoding::Array<
12811                    fidl::encoding::Optional<
12812                        fidl::encoding::HandleType<
12813                            fidl::Vmo,
12814                            { fidl::ObjectType::VMO.into_raw() },
12815                            2147483648,
12816                        >,
12817                    >,
12818                    64,
12819                >,
12820                fidl::encoding::DefaultFuchsiaResourceDialect,
12821            >,
12822        T3: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
12823    >
12824        fidl::encoding::Encode<BufferCollectionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
12825        for (T0, T1, T2, T3)
12826    {
12827        #[inline]
12828        unsafe fn encode(
12829            self,
12830            encoder: &mut fidl::encoding::Encoder<
12831                '_,
12832                fidl::encoding::DefaultFuchsiaResourceDialect,
12833            >,
12834            offset: usize,
12835            depth: fidl::encoding::Depth,
12836        ) -> fidl::Result<()> {
12837            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
12838            // Zero out padding regions. There's no need to apply masks
12839            // because the unmasked parts will be overwritten by fields.
12840            unsafe {
12841                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
12842                (ptr as *mut u64).write_unaligned(0);
12843            }
12844            // Write the fields.
12845            self.0.encode(encoder, offset + 0, depth)?;
12846            self.1.encode(encoder, offset + 8, depth)?;
12847            self.2.encode(encoder, offset + 88, depth)?;
12848            self.3.encode(encoder, offset + 344, depth)?;
12849            Ok(())
12850        }
12851    }
12852
12853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12854        for BufferCollectionInfo
12855    {
12856        #[inline(always)]
12857        fn new_empty() -> Self {
12858            Self {
12859                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
12860                format: fidl::new_empty!(
12861                    BufferFormat,
12862                    fidl::encoding::DefaultFuchsiaResourceDialect
12863                ),
12864                vmos: fidl::new_empty!(
12865                    fidl::encoding::Array<
12866                        fidl::encoding::Optional<
12867                            fidl::encoding::HandleType<
12868                                fidl::Vmo,
12869                                { fidl::ObjectType::VMO.into_raw() },
12870                                2147483648,
12871                            >,
12872                        >,
12873                        64,
12874                    >,
12875                    fidl::encoding::DefaultFuchsiaResourceDialect
12876                ),
12877                vmo_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
12878            }
12879        }
12880
12881        #[inline]
12882        unsafe fn decode(
12883            &mut self,
12884            decoder: &mut fidl::encoding::Decoder<
12885                '_,
12886                fidl::encoding::DefaultFuchsiaResourceDialect,
12887            >,
12888            offset: usize,
12889            _depth: fidl::encoding::Depth,
12890        ) -> fidl::Result<()> {
12891            decoder.debug_check_bounds::<Self>(offset);
12892            // Verify that padding bytes are zero.
12893            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
12894            let padval = unsafe { (ptr as *const u64).read_unaligned() };
12895            let mask = 0xffffffff00000000u64;
12896            let maskedval = padval & mask;
12897            if maskedval != 0 {
12898                return Err(fidl::Error::NonZeroPadding {
12899                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
12900                });
12901            }
12902            fidl::decode!(
12903                u32,
12904                fidl::encoding::DefaultFuchsiaResourceDialect,
12905                &mut self.buffer_count,
12906                decoder,
12907                offset + 0,
12908                _depth
12909            )?;
12910            fidl::decode!(
12911                BufferFormat,
12912                fidl::encoding::DefaultFuchsiaResourceDialect,
12913                &mut self.format,
12914                decoder,
12915                offset + 8,
12916                _depth
12917            )?;
12918            fidl::decode!(
12919                fidl::encoding::Array<
12920                    fidl::encoding::Optional<
12921                        fidl::encoding::HandleType<
12922                            fidl::Vmo,
12923                            { fidl::ObjectType::VMO.into_raw() },
12924                            2147483648,
12925                        >,
12926                    >,
12927                    64,
12928                >,
12929                fidl::encoding::DefaultFuchsiaResourceDialect,
12930                &mut self.vmos,
12931                decoder,
12932                offset + 88,
12933                _depth
12934            )?;
12935            fidl::decode!(
12936                u64,
12937                fidl::encoding::DefaultFuchsiaResourceDialect,
12938                &mut self.vmo_size,
12939                decoder,
12940                offset + 344,
12941                _depth
12942            )?;
12943            Ok(())
12944        }
12945    }
12946
12947    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo2 {
12948        type Borrowed<'a> = &'a mut Self;
12949        fn take_or_borrow<'a>(
12950            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12951        ) -> Self::Borrowed<'a> {
12952            value
12953        }
12954    }
12955
12956    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo2 {
12957        type Owned = Self;
12958
12959        #[inline(always)]
12960        fn inline_align(_context: fidl::encoding::Context) -> usize {
12961            8
12962        }
12963
12964        #[inline(always)]
12965        fn inline_size(_context: fidl::encoding::Context) -> usize {
12966            1296
12967        }
12968    }
12969
12970    unsafe impl
12971        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
12972        for &mut BufferCollectionInfo2
12973    {
12974        #[inline]
12975        unsafe fn encode(
12976            self,
12977            encoder: &mut fidl::encoding::Encoder<
12978                '_,
12979                fidl::encoding::DefaultFuchsiaResourceDialect,
12980            >,
12981            offset: usize,
12982            _depth: fidl::encoding::Depth,
12983        ) -> fidl::Result<()> {
12984            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
12985            // Delegate to tuple encoding.
12986            fidl::encoding::Encode::<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
12987                (
12988                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
12989                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
12990                    <fidl::encoding::Array<VmoBuffer, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
12991                ),
12992                encoder, offset, _depth
12993            )
12994        }
12995    }
12996    unsafe impl<
12997        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
12998        T1: fidl::encoding::Encode<SingleBufferSettings, fidl::encoding::DefaultFuchsiaResourceDialect>,
12999        T2: fidl::encoding::Encode<
13000                fidl::encoding::Array<VmoBuffer, 64>,
13001                fidl::encoding::DefaultFuchsiaResourceDialect,
13002            >,
13003    >
13004        fidl::encoding::Encode<BufferCollectionInfo2, fidl::encoding::DefaultFuchsiaResourceDialect>
13005        for (T0, T1, T2)
13006    {
13007        #[inline]
13008        unsafe fn encode(
13009            self,
13010            encoder: &mut fidl::encoding::Encoder<
13011                '_,
13012                fidl::encoding::DefaultFuchsiaResourceDialect,
13013            >,
13014            offset: usize,
13015            depth: fidl::encoding::Depth,
13016        ) -> fidl::Result<()> {
13017            encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
13018            // Zero out padding regions. There's no need to apply masks
13019            // because the unmasked parts will be overwritten by fields.
13020            unsafe {
13021                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13022                (ptr as *mut u64).write_unaligned(0);
13023            }
13024            // Write the fields.
13025            self.0.encode(encoder, offset + 0, depth)?;
13026            self.1.encode(encoder, offset + 8, depth)?;
13027            self.2.encode(encoder, offset + 272, depth)?;
13028            Ok(())
13029        }
13030    }
13031
13032    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13033        for BufferCollectionInfo2
13034    {
13035        #[inline(always)]
13036        fn new_empty() -> Self {
13037            Self {
13038                buffer_count: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
13039                settings: fidl::new_empty!(
13040                    SingleBufferSettings,
13041                    fidl::encoding::DefaultFuchsiaResourceDialect
13042                ),
13043                buffers: fidl::new_empty!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
13044            }
13045        }
13046
13047        #[inline]
13048        unsafe fn decode(
13049            &mut self,
13050            decoder: &mut fidl::encoding::Decoder<
13051                '_,
13052                fidl::encoding::DefaultFuchsiaResourceDialect,
13053            >,
13054            offset: usize,
13055            _depth: fidl::encoding::Depth,
13056        ) -> fidl::Result<()> {
13057            decoder.debug_check_bounds::<Self>(offset);
13058            // Verify that padding bytes are zero.
13059            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13060            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13061            let mask = 0xffffffff00000000u64;
13062            let maskedval = padval & mask;
13063            if maskedval != 0 {
13064                return Err(fidl::Error::NonZeroPadding {
13065                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13066                });
13067            }
13068            fidl::decode!(
13069                u32,
13070                fidl::encoding::DefaultFuchsiaResourceDialect,
13071                &mut self.buffer_count,
13072                decoder,
13073                offset + 0,
13074                _depth
13075            )?;
13076            fidl::decode!(
13077                SingleBufferSettings,
13078                fidl::encoding::DefaultFuchsiaResourceDialect,
13079                &mut self.settings,
13080                decoder,
13081                offset + 8,
13082                _depth
13083            )?;
13084            fidl::decode!(fidl::encoding::Array<VmoBuffer, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffers, decoder, offset + 272, _depth)?;
13085            Ok(())
13086        }
13087    }
13088
13089    impl fidl::encoding::ResourceTypeMarker
13090        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13091    {
13092        type Borrowed<'a> = &'a mut Self;
13093        fn take_or_borrow<'a>(
13094            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13095        ) -> Self::Borrowed<'a> {
13096            value
13097        }
13098    }
13099
13100    unsafe impl fidl::encoding::TypeMarker
13101        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13102    {
13103        type Owned = Self;
13104
13105        #[inline(always)]
13106        fn inline_align(_context: fidl::encoding::Context) -> usize {
13107            4
13108        }
13109
13110        #[inline(always)]
13111        fn inline_size(_context: fidl::encoding::Context) -> usize {
13112            4
13113        }
13114    }
13115
13116    unsafe impl
13117        fidl::encoding::Encode<
13118            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13119            fidl::encoding::DefaultFuchsiaResourceDialect,
13120        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13121    {
13122        #[inline]
13123        unsafe fn encode(
13124            self,
13125            encoder: &mut fidl::encoding::Encoder<
13126                '_,
13127                fidl::encoding::DefaultFuchsiaResourceDialect,
13128            >,
13129            offset: usize,
13130            _depth: fidl::encoding::Depth,
13131        ) -> fidl::Result<()> {
13132            encoder
13133                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13134                    offset,
13135                );
13136            // Delegate to tuple encoding.
13137            fidl::encoding::Encode::<
13138                BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13139                fidl::encoding::DefaultFuchsiaResourceDialect,
13140            >::encode(
13141                (<fidl::encoding::Endpoint<
13142                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13143                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13144                    &mut self.group_request
13145                ),),
13146                encoder,
13147                offset,
13148                _depth,
13149            )
13150        }
13151    }
13152    unsafe impl<
13153        T0: fidl::encoding::Encode<
13154                fidl::encoding::Endpoint<
13155                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13156                >,
13157                fidl::encoding::DefaultFuchsiaResourceDialect,
13158            >,
13159    >
13160        fidl::encoding::Encode<
13161            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
13162            fidl::encoding::DefaultFuchsiaResourceDialect,
13163        > for (T0,)
13164    {
13165        #[inline]
13166        unsafe fn encode(
13167            self,
13168            encoder: &mut fidl::encoding::Encoder<
13169                '_,
13170                fidl::encoding::DefaultFuchsiaResourceDialect,
13171            >,
13172            offset: usize,
13173            depth: fidl::encoding::Depth,
13174        ) -> fidl::Result<()> {
13175            encoder
13176                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
13177                    offset,
13178                );
13179            // Zero out padding regions. There's no need to apply masks
13180            // because the unmasked parts will be overwritten by fields.
13181            // Write the fields.
13182            self.0.encode(encoder, offset + 0, depth)?;
13183            Ok(())
13184        }
13185    }
13186
13187    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13188        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
13189    {
13190        #[inline(always)]
13191        fn new_empty() -> Self {
13192            Self {
13193                group_request: fidl::new_empty!(
13194                    fidl::encoding::Endpoint<
13195                        fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13196                    >,
13197                    fidl::encoding::DefaultFuchsiaResourceDialect
13198                ),
13199            }
13200        }
13201
13202        #[inline]
13203        unsafe fn decode(
13204            &mut self,
13205            decoder: &mut fidl::encoding::Decoder<
13206                '_,
13207                fidl::encoding::DefaultFuchsiaResourceDialect,
13208            >,
13209            offset: usize,
13210            _depth: fidl::encoding::Depth,
13211        ) -> fidl::Result<()> {
13212            decoder.debug_check_bounds::<Self>(offset);
13213            // Verify that padding bytes are zero.
13214            fidl::decode!(
13215                fidl::encoding::Endpoint<
13216                    fidl::endpoints::ServerEnd<BufferCollectionTokenGroupMarker>,
13217                >,
13218                fidl::encoding::DefaultFuchsiaResourceDialect,
13219                &mut self.group_request,
13220                decoder,
13221                offset + 0,
13222                _depth
13223            )?;
13224            Ok(())
13225        }
13226    }
13227
13228    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
13229        type Borrowed<'a> = &'a mut Self;
13230        fn take_or_borrow<'a>(
13231            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13232        ) -> Self::Borrowed<'a> {
13233            value
13234        }
13235    }
13236
13237    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
13238        type Owned = Self;
13239
13240        #[inline(always)]
13241        fn inline_align(_context: fidl::encoding::Context) -> usize {
13242            4
13243        }
13244
13245        #[inline(always)]
13246        fn inline_size(_context: fidl::encoding::Context) -> usize {
13247            8
13248        }
13249    }
13250
13251    unsafe impl
13252        fidl::encoding::Encode<
13253            BufferCollectionTokenDuplicateRequest,
13254            fidl::encoding::DefaultFuchsiaResourceDialect,
13255        > for &mut BufferCollectionTokenDuplicateRequest
13256    {
13257        #[inline]
13258        unsafe fn encode(
13259            self,
13260            encoder: &mut fidl::encoding::Encoder<
13261                '_,
13262                fidl::encoding::DefaultFuchsiaResourceDialect,
13263            >,
13264            offset: usize,
13265            _depth: fidl::encoding::Depth,
13266        ) -> fidl::Result<()> {
13267            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13268            // Delegate to tuple encoding.
13269            fidl::encoding::Encode::<
13270                BufferCollectionTokenDuplicateRequest,
13271                fidl::encoding::DefaultFuchsiaResourceDialect,
13272            >::encode(
13273                (
13274                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
13275                    <fidl::encoding::Endpoint<
13276                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13277                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13278                        &mut self.token_request,
13279                    ),
13280                ),
13281                encoder,
13282                offset,
13283                _depth,
13284            )
13285        }
13286    }
13287    unsafe impl<
13288        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13289        T1: fidl::encoding::Encode<
13290                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13291                fidl::encoding::DefaultFuchsiaResourceDialect,
13292            >,
13293    >
13294        fidl::encoding::Encode<
13295            BufferCollectionTokenDuplicateRequest,
13296            fidl::encoding::DefaultFuchsiaResourceDialect,
13297        > for (T0, T1)
13298    {
13299        #[inline]
13300        unsafe fn encode(
13301            self,
13302            encoder: &mut fidl::encoding::Encoder<
13303                '_,
13304                fidl::encoding::DefaultFuchsiaResourceDialect,
13305            >,
13306            offset: usize,
13307            depth: fidl::encoding::Depth,
13308        ) -> fidl::Result<()> {
13309            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
13310            // Zero out padding regions. There's no need to apply masks
13311            // because the unmasked parts will be overwritten by fields.
13312            // Write the fields.
13313            self.0.encode(encoder, offset + 0, depth)?;
13314            self.1.encode(encoder, offset + 4, depth)?;
13315            Ok(())
13316        }
13317    }
13318
13319    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13320        for BufferCollectionTokenDuplicateRequest
13321    {
13322        #[inline(always)]
13323        fn new_empty() -> Self {
13324            Self {
13325                rights_attenuation_mask: fidl::new_empty!(
13326                    u32,
13327                    fidl::encoding::DefaultFuchsiaResourceDialect
13328                ),
13329                token_request: fidl::new_empty!(
13330                    fidl::encoding::Endpoint<
13331                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
13332                    >,
13333                    fidl::encoding::DefaultFuchsiaResourceDialect
13334                ),
13335            }
13336        }
13337
13338        #[inline]
13339        unsafe fn decode(
13340            &mut self,
13341            decoder: &mut fidl::encoding::Decoder<
13342                '_,
13343                fidl::encoding::DefaultFuchsiaResourceDialect,
13344            >,
13345            offset: usize,
13346            _depth: fidl::encoding::Depth,
13347        ) -> fidl::Result<()> {
13348            decoder.debug_check_bounds::<Self>(offset);
13349            // Verify that padding bytes are zero.
13350            fidl::decode!(
13351                u32,
13352                fidl::encoding::DefaultFuchsiaResourceDialect,
13353                &mut self.rights_attenuation_mask,
13354                decoder,
13355                offset + 0,
13356                _depth
13357            )?;
13358            fidl::decode!(
13359                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
13360                fidl::encoding::DefaultFuchsiaResourceDialect,
13361                &mut self.token_request,
13362                decoder,
13363                offset + 4,
13364                _depth
13365            )?;
13366            Ok(())
13367        }
13368    }
13369
13370    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13371        type Borrowed<'a> = &'a mut Self;
13372        fn take_or_borrow<'a>(
13373            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13374        ) -> Self::Borrowed<'a> {
13375            value
13376        }
13377    }
13378
13379    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
13380        type Owned = Self;
13381
13382        #[inline(always)]
13383        fn inline_align(_context: fidl::encoding::Context) -> usize {
13384            8
13385        }
13386
13387        #[inline(always)]
13388        fn inline_size(_context: fidl::encoding::Context) -> usize {
13389            16
13390        }
13391    }
13392
13393    unsafe impl
13394        fidl::encoding::Encode<
13395            BufferCollectionTokenDuplicateSyncResponse,
13396            fidl::encoding::DefaultFuchsiaResourceDialect,
13397        > for &mut BufferCollectionTokenDuplicateSyncResponse
13398    {
13399        #[inline]
13400        unsafe fn encode(
13401            self,
13402            encoder: &mut fidl::encoding::Encoder<
13403                '_,
13404                fidl::encoding::DefaultFuchsiaResourceDialect,
13405            >,
13406            offset: usize,
13407            _depth: fidl::encoding::Depth,
13408        ) -> fidl::Result<()> {
13409            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13410            // Delegate to tuple encoding.
13411            fidl::encoding::Encode::<
13412                BufferCollectionTokenDuplicateSyncResponse,
13413                fidl::encoding::DefaultFuchsiaResourceDialect,
13414            >::encode(
13415                (<fidl::encoding::Vector<
13416                    fidl::encoding::Endpoint<
13417                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13418                    >,
13419                    64,
13420                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13421                    &mut self.tokens
13422                ),),
13423                encoder,
13424                offset,
13425                _depth,
13426            )
13427        }
13428    }
13429    unsafe impl<
13430        T0: fidl::encoding::Encode<
13431                fidl::encoding::Vector<
13432                    fidl::encoding::Endpoint<
13433                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13434                    >,
13435                    64,
13436                >,
13437                fidl::encoding::DefaultFuchsiaResourceDialect,
13438            >,
13439    >
13440        fidl::encoding::Encode<
13441            BufferCollectionTokenDuplicateSyncResponse,
13442            fidl::encoding::DefaultFuchsiaResourceDialect,
13443        > for (T0,)
13444    {
13445        #[inline]
13446        unsafe fn encode(
13447            self,
13448            encoder: &mut fidl::encoding::Encoder<
13449                '_,
13450                fidl::encoding::DefaultFuchsiaResourceDialect,
13451            >,
13452            offset: usize,
13453            depth: fidl::encoding::Depth,
13454        ) -> fidl::Result<()> {
13455            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
13456            // Zero out padding regions. There's no need to apply masks
13457            // because the unmasked parts will be overwritten by fields.
13458            // Write the fields.
13459            self.0.encode(encoder, offset + 0, depth)?;
13460            Ok(())
13461        }
13462    }
13463
13464    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13465        for BufferCollectionTokenDuplicateSyncResponse
13466    {
13467        #[inline(always)]
13468        fn new_empty() -> Self {
13469            Self {
13470                tokens: fidl::new_empty!(
13471                    fidl::encoding::Vector<
13472                        fidl::encoding::Endpoint<
13473                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13474                        >,
13475                        64,
13476                    >,
13477                    fidl::encoding::DefaultFuchsiaResourceDialect
13478                ),
13479            }
13480        }
13481
13482        #[inline]
13483        unsafe fn decode(
13484            &mut self,
13485            decoder: &mut fidl::encoding::Decoder<
13486                '_,
13487                fidl::encoding::DefaultFuchsiaResourceDialect,
13488            >,
13489            offset: usize,
13490            _depth: fidl::encoding::Depth,
13491        ) -> fidl::Result<()> {
13492            decoder.debug_check_bounds::<Self>(offset);
13493            // Verify that padding bytes are zero.
13494            fidl::decode!(
13495                fidl::encoding::Vector<
13496                    fidl::encoding::Endpoint<
13497                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13498                    >,
13499                    64,
13500                >,
13501                fidl::encoding::DefaultFuchsiaResourceDialect,
13502                &mut self.tokens,
13503                decoder,
13504                offset + 0,
13505                _depth
13506            )?;
13507            Ok(())
13508        }
13509    }
13510
13511    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13512        type Borrowed<'a> = &'a mut Self;
13513        fn take_or_borrow<'a>(
13514            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13515        ) -> Self::Borrowed<'a> {
13516            value
13517        }
13518    }
13519
13520    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
13521        type Owned = Self;
13522
13523        #[inline(always)]
13524        fn inline_align(_context: fidl::encoding::Context) -> usize {
13525            8
13526        }
13527
13528        #[inline(always)]
13529        fn inline_size(_context: fidl::encoding::Context) -> usize {
13530            16
13531        }
13532    }
13533
13534    unsafe impl
13535        fidl::encoding::Encode<
13536            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13537            fidl::encoding::DefaultFuchsiaResourceDialect,
13538        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
13539    {
13540        #[inline]
13541        unsafe fn encode(
13542            self,
13543            encoder: &mut fidl::encoding::Encoder<
13544                '_,
13545                fidl::encoding::DefaultFuchsiaResourceDialect,
13546            >,
13547            offset: usize,
13548            _depth: fidl::encoding::Depth,
13549        ) -> fidl::Result<()> {
13550            encoder
13551                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13552            // Delegate to tuple encoding.
13553            fidl::encoding::Encode::<
13554                BufferCollectionTokenGroupCreateChildrenSyncResponse,
13555                fidl::encoding::DefaultFuchsiaResourceDialect,
13556            >::encode(
13557                (<fidl::encoding::Vector<
13558                    fidl::encoding::Endpoint<
13559                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13560                    >,
13561                    64,
13562                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13563                    &mut self.tokens
13564                ),),
13565                encoder,
13566                offset,
13567                _depth,
13568            )
13569        }
13570    }
13571    unsafe impl<
13572        T0: fidl::encoding::Encode<
13573                fidl::encoding::Vector<
13574                    fidl::encoding::Endpoint<
13575                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13576                    >,
13577                    64,
13578                >,
13579                fidl::encoding::DefaultFuchsiaResourceDialect,
13580            >,
13581    >
13582        fidl::encoding::Encode<
13583            BufferCollectionTokenGroupCreateChildrenSyncResponse,
13584            fidl::encoding::DefaultFuchsiaResourceDialect,
13585        > for (T0,)
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
13598                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
13599            // Zero out padding regions. There's no need to apply masks
13600            // because the unmasked parts will be overwritten by fields.
13601            // Write the fields.
13602            self.0.encode(encoder, offset + 0, depth)?;
13603            Ok(())
13604        }
13605    }
13606
13607    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13608        for BufferCollectionTokenGroupCreateChildrenSyncResponse
13609    {
13610        #[inline(always)]
13611        fn new_empty() -> Self {
13612            Self {
13613                tokens: fidl::new_empty!(
13614                    fidl::encoding::Vector<
13615                        fidl::encoding::Endpoint<
13616                            fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13617                        >,
13618                        64,
13619                    >,
13620                    fidl::encoding::DefaultFuchsiaResourceDialect
13621                ),
13622            }
13623        }
13624
13625        #[inline]
13626        unsafe fn decode(
13627            &mut self,
13628            decoder: &mut fidl::encoding::Decoder<
13629                '_,
13630                fidl::encoding::DefaultFuchsiaResourceDialect,
13631            >,
13632            offset: usize,
13633            _depth: fidl::encoding::Depth,
13634        ) -> fidl::Result<()> {
13635            decoder.debug_check_bounds::<Self>(offset);
13636            // Verify that padding bytes are zero.
13637            fidl::decode!(
13638                fidl::encoding::Vector<
13639                    fidl::encoding::Endpoint<
13640                        fidl::endpoints::ClientEnd<BufferCollectionTokenMarker>,
13641                    >,
13642                    64,
13643                >,
13644                fidl::encoding::DefaultFuchsiaResourceDialect,
13645                &mut self.tokens,
13646                decoder,
13647                offset + 0,
13648                _depth
13649            )?;
13650            Ok(())
13651        }
13652    }
13653
13654    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
13655        type Borrowed<'a> = &'a mut Self;
13656        fn take_or_borrow<'a>(
13657            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13658        ) -> Self::Borrowed<'a> {
13659            value
13660        }
13661    }
13662
13663    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
13664        type Owned = Self;
13665
13666        #[inline(always)]
13667        fn inline_align(_context: fidl::encoding::Context) -> usize {
13668            8
13669        }
13670
13671        #[inline(always)]
13672        fn inline_size(_context: fidl::encoding::Context) -> usize {
13673            1304
13674        }
13675    }
13676
13677    unsafe impl
13678        fidl::encoding::Encode<
13679            BufferCollectionWaitForBuffersAllocatedResponse,
13680            fidl::encoding::DefaultFuchsiaResourceDialect,
13681        > for &mut BufferCollectionWaitForBuffersAllocatedResponse
13682    {
13683        #[inline]
13684        unsafe fn encode(
13685            self,
13686            encoder: &mut fidl::encoding::Encoder<
13687                '_,
13688                fidl::encoding::DefaultFuchsiaResourceDialect,
13689            >,
13690            offset: usize,
13691            _depth: fidl::encoding::Depth,
13692        ) -> fidl::Result<()> {
13693            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
13694            // Delegate to tuple encoding.
13695            fidl::encoding::Encode::<
13696                BufferCollectionWaitForBuffersAllocatedResponse,
13697                fidl::encoding::DefaultFuchsiaResourceDialect,
13698            >::encode(
13699                (
13700                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
13701                    <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13702                        &mut self.buffer_collection_info,
13703                    ),
13704                ),
13705                encoder,
13706                offset,
13707                _depth,
13708            )
13709        }
13710    }
13711    unsafe impl<
13712        T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
13713        T1: fidl::encoding::Encode<
13714                BufferCollectionInfo2,
13715                fidl::encoding::DefaultFuchsiaResourceDialect,
13716            >,
13717    >
13718        fidl::encoding::Encode<
13719            BufferCollectionWaitForBuffersAllocatedResponse,
13720            fidl::encoding::DefaultFuchsiaResourceDialect,
13721        > for (T0, T1)
13722    {
13723        #[inline]
13724        unsafe fn encode(
13725            self,
13726            encoder: &mut fidl::encoding::Encoder<
13727                '_,
13728                fidl::encoding::DefaultFuchsiaResourceDialect,
13729            >,
13730            offset: usize,
13731            depth: fidl::encoding::Depth,
13732        ) -> fidl::Result<()> {
13733            encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
13734            // Zero out padding regions. There's no need to apply masks
13735            // because the unmasked parts will be overwritten by fields.
13736            unsafe {
13737                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
13738                (ptr as *mut u64).write_unaligned(0);
13739            }
13740            // Write the fields.
13741            self.0.encode(encoder, offset + 0, depth)?;
13742            self.1.encode(encoder, offset + 8, depth)?;
13743            Ok(())
13744        }
13745    }
13746
13747    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13748        for BufferCollectionWaitForBuffersAllocatedResponse
13749    {
13750        #[inline(always)]
13751        fn new_empty() -> Self {
13752            Self {
13753                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
13754                buffer_collection_info: fidl::new_empty!(
13755                    BufferCollectionInfo2,
13756                    fidl::encoding::DefaultFuchsiaResourceDialect
13757                ),
13758            }
13759        }
13760
13761        #[inline]
13762        unsafe fn decode(
13763            &mut self,
13764            decoder: &mut fidl::encoding::Decoder<
13765                '_,
13766                fidl::encoding::DefaultFuchsiaResourceDialect,
13767            >,
13768            offset: usize,
13769            _depth: fidl::encoding::Depth,
13770        ) -> fidl::Result<()> {
13771            decoder.debug_check_bounds::<Self>(offset);
13772            // Verify that padding bytes are zero.
13773            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
13774            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13775            let mask = 0xffffffff00000000u64;
13776            let maskedval = padval & mask;
13777            if maskedval != 0 {
13778                return Err(fidl::Error::NonZeroPadding {
13779                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
13780                });
13781            }
13782            fidl::decode!(
13783                i32,
13784                fidl::encoding::DefaultFuchsiaResourceDialect,
13785                &mut self.status,
13786                decoder,
13787                offset + 0,
13788                _depth
13789            )?;
13790            fidl::decode!(
13791                BufferCollectionInfo2,
13792                fidl::encoding::DefaultFuchsiaResourceDialect,
13793                &mut self.buffer_collection_info,
13794                decoder,
13795                offset + 8,
13796                _depth
13797            )?;
13798            Ok(())
13799        }
13800    }
13801
13802    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
13803        type Borrowed<'a> = &'a mut Self;
13804        fn take_or_borrow<'a>(
13805            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13806        ) -> Self::Borrowed<'a> {
13807            value
13808        }
13809    }
13810
13811    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
13812        type Owned = Self;
13813
13814        #[inline(always)]
13815        fn inline_align(_context: fidl::encoding::Context) -> usize {
13816            4
13817        }
13818
13819        #[inline(always)]
13820        fn inline_size(_context: fidl::encoding::Context) -> usize {
13821            4
13822        }
13823    }
13824
13825    unsafe impl
13826        fidl::encoding::Encode<
13827            NodeGetNodeRefResponse,
13828            fidl::encoding::DefaultFuchsiaResourceDialect,
13829        > for &mut NodeGetNodeRefResponse
13830    {
13831        #[inline]
13832        unsafe fn encode(
13833            self,
13834            encoder: &mut fidl::encoding::Encoder<
13835                '_,
13836                fidl::encoding::DefaultFuchsiaResourceDialect,
13837            >,
13838            offset: usize,
13839            _depth: fidl::encoding::Depth,
13840        ) -> fidl::Result<()> {
13841            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
13842            // Delegate to tuple encoding.
13843            fidl::encoding::Encode::<
13844                NodeGetNodeRefResponse,
13845                fidl::encoding::DefaultFuchsiaResourceDialect,
13846            >::encode(
13847                (<fidl::encoding::HandleType<
13848                    fidl::Event,
13849                    { fidl::ObjectType::EVENT.into_raw() },
13850                    2147483648,
13851                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13852                    &mut self.node_ref
13853                ),),
13854                encoder,
13855                offset,
13856                _depth,
13857            )
13858        }
13859    }
13860    unsafe impl<
13861        T0: fidl::encoding::Encode<
13862                fidl::encoding::HandleType<
13863                    fidl::Event,
13864                    { fidl::ObjectType::EVENT.into_raw() },
13865                    2147483648,
13866                >,
13867                fidl::encoding::DefaultFuchsiaResourceDialect,
13868            >,
13869    >
13870        fidl::encoding::Encode<
13871            NodeGetNodeRefResponse,
13872            fidl::encoding::DefaultFuchsiaResourceDialect,
13873        > for (T0,)
13874    {
13875        #[inline]
13876        unsafe fn encode(
13877            self,
13878            encoder: &mut fidl::encoding::Encoder<
13879                '_,
13880                fidl::encoding::DefaultFuchsiaResourceDialect,
13881            >,
13882            offset: usize,
13883            depth: fidl::encoding::Depth,
13884        ) -> fidl::Result<()> {
13885            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
13886            // Zero out padding regions. There's no need to apply masks
13887            // because the unmasked parts will be overwritten by fields.
13888            // Write the fields.
13889            self.0.encode(encoder, offset + 0, depth)?;
13890            Ok(())
13891        }
13892    }
13893
13894    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13895        for NodeGetNodeRefResponse
13896    {
13897        #[inline(always)]
13898        fn new_empty() -> Self {
13899            Self {
13900                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
13901            }
13902        }
13903
13904        #[inline]
13905        unsafe fn decode(
13906            &mut self,
13907            decoder: &mut fidl::encoding::Decoder<
13908                '_,
13909                fidl::encoding::DefaultFuchsiaResourceDialect,
13910            >,
13911            offset: usize,
13912            _depth: fidl::encoding::Depth,
13913        ) -> fidl::Result<()> {
13914            decoder.debug_check_bounds::<Self>(offset);
13915            // Verify that padding bytes are zero.
13916            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
13917            Ok(())
13918        }
13919    }
13920
13921    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
13922        type Borrowed<'a> = &'a mut Self;
13923        fn take_or_borrow<'a>(
13924            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13925        ) -> Self::Borrowed<'a> {
13926            value
13927        }
13928    }
13929
13930    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
13931        type Owned = Self;
13932
13933        #[inline(always)]
13934        fn inline_align(_context: fidl::encoding::Context) -> usize {
13935            4
13936        }
13937
13938        #[inline(always)]
13939        fn inline_size(_context: fidl::encoding::Context) -> usize {
13940            4
13941        }
13942    }
13943
13944    unsafe impl
13945        fidl::encoding::Encode<
13946            NodeIsAlternateForRequest,
13947            fidl::encoding::DefaultFuchsiaResourceDialect,
13948        > for &mut NodeIsAlternateForRequest
13949    {
13950        #[inline]
13951        unsafe fn encode(
13952            self,
13953            encoder: &mut fidl::encoding::Encoder<
13954                '_,
13955                fidl::encoding::DefaultFuchsiaResourceDialect,
13956            >,
13957            offset: usize,
13958            _depth: fidl::encoding::Depth,
13959        ) -> fidl::Result<()> {
13960            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
13961            // Delegate to tuple encoding.
13962            fidl::encoding::Encode::<
13963                NodeIsAlternateForRequest,
13964                fidl::encoding::DefaultFuchsiaResourceDialect,
13965            >::encode(
13966                (<fidl::encoding::HandleType<
13967                    fidl::Event,
13968                    { fidl::ObjectType::EVENT.into_raw() },
13969                    2147483648,
13970                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13971                    &mut self.node_ref
13972                ),),
13973                encoder,
13974                offset,
13975                _depth,
13976            )
13977        }
13978    }
13979    unsafe impl<
13980        T0: fidl::encoding::Encode<
13981                fidl::encoding::HandleType<
13982                    fidl::Event,
13983                    { fidl::ObjectType::EVENT.into_raw() },
13984                    2147483648,
13985                >,
13986                fidl::encoding::DefaultFuchsiaResourceDialect,
13987            >,
13988    >
13989        fidl::encoding::Encode<
13990            NodeIsAlternateForRequest,
13991            fidl::encoding::DefaultFuchsiaResourceDialect,
13992        > for (T0,)
13993    {
13994        #[inline]
13995        unsafe fn encode(
13996            self,
13997            encoder: &mut fidl::encoding::Encoder<
13998                '_,
13999                fidl::encoding::DefaultFuchsiaResourceDialect,
14000            >,
14001            offset: usize,
14002            depth: fidl::encoding::Depth,
14003        ) -> fidl::Result<()> {
14004            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
14005            // Zero out padding regions. There's no need to apply masks
14006            // because the unmasked parts will be overwritten by fields.
14007            // Write the fields.
14008            self.0.encode(encoder, offset + 0, depth)?;
14009            Ok(())
14010        }
14011    }
14012
14013    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14014        for NodeIsAlternateForRequest
14015    {
14016        #[inline(always)]
14017        fn new_empty() -> Self {
14018            Self {
14019                node_ref: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
14020            }
14021        }
14022
14023        #[inline]
14024        unsafe fn decode(
14025            &mut self,
14026            decoder: &mut fidl::encoding::Decoder<
14027                '_,
14028                fidl::encoding::DefaultFuchsiaResourceDialect,
14029            >,
14030            offset: usize,
14031            _depth: fidl::encoding::Depth,
14032        ) -> fidl::Result<()> {
14033            decoder.debug_check_bounds::<Self>(offset);
14034            // Verify that padding bytes are zero.
14035            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
14036            Ok(())
14037        }
14038    }
14039
14040    impl fidl::encoding::ResourceTypeMarker for SingleBufferInfo {
14041        type Borrowed<'a> = &'a mut Self;
14042        fn take_or_borrow<'a>(
14043            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14044        ) -> Self::Borrowed<'a> {
14045            value
14046        }
14047    }
14048
14049    unsafe impl fidl::encoding::TypeMarker for SingleBufferInfo {
14050        type Owned = Self;
14051
14052        #[inline(always)]
14053        fn inline_align(_context: fidl::encoding::Context) -> usize {
14054            8
14055        }
14056
14057        #[inline(always)]
14058        fn inline_size(_context: fidl::encoding::Context) -> usize {
14059            280
14060        }
14061    }
14062
14063    unsafe impl
14064        fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14065        for &mut SingleBufferInfo
14066    {
14067        #[inline]
14068        unsafe fn encode(
14069            self,
14070            encoder: &mut fidl::encoding::Encoder<
14071                '_,
14072                fidl::encoding::DefaultFuchsiaResourceDialect,
14073            >,
14074            offset: usize,
14075            _depth: fidl::encoding::Depth,
14076        ) -> fidl::Result<()> {
14077            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14078            // Delegate to tuple encoding.
14079            fidl::encoding::Encode::<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14080                (
14081                    <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
14082                    <VmoBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
14083                ),
14084                encoder, offset, _depth
14085            )
14086        }
14087    }
14088    unsafe impl<
14089        T0: fidl::encoding::Encode<SingleBufferSettings, fidl::encoding::DefaultFuchsiaResourceDialect>,
14090        T1: fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>,
14091    > fidl::encoding::Encode<SingleBufferInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
14092        for (T0, T1)
14093    {
14094        #[inline]
14095        unsafe fn encode(
14096            self,
14097            encoder: &mut fidl::encoding::Encoder<
14098                '_,
14099                fidl::encoding::DefaultFuchsiaResourceDialect,
14100            >,
14101            offset: usize,
14102            depth: fidl::encoding::Depth,
14103        ) -> fidl::Result<()> {
14104            encoder.debug_check_bounds::<SingleBufferInfo>(offset);
14105            // Zero out padding regions. There's no need to apply masks
14106            // because the unmasked parts will be overwritten by fields.
14107            // Write the fields.
14108            self.0.encode(encoder, offset + 0, depth)?;
14109            self.1.encode(encoder, offset + 264, depth)?;
14110            Ok(())
14111        }
14112    }
14113
14114    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14115        for SingleBufferInfo
14116    {
14117        #[inline(always)]
14118        fn new_empty() -> Self {
14119            Self {
14120                settings: fidl::new_empty!(
14121                    SingleBufferSettings,
14122                    fidl::encoding::DefaultFuchsiaResourceDialect
14123                ),
14124                buffer: fidl::new_empty!(VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect),
14125            }
14126        }
14127
14128        #[inline]
14129        unsafe fn decode(
14130            &mut self,
14131            decoder: &mut fidl::encoding::Decoder<
14132                '_,
14133                fidl::encoding::DefaultFuchsiaResourceDialect,
14134            >,
14135            offset: usize,
14136            _depth: fidl::encoding::Depth,
14137        ) -> fidl::Result<()> {
14138            decoder.debug_check_bounds::<Self>(offset);
14139            // Verify that padding bytes are zero.
14140            fidl::decode!(
14141                SingleBufferSettings,
14142                fidl::encoding::DefaultFuchsiaResourceDialect,
14143                &mut self.settings,
14144                decoder,
14145                offset + 0,
14146                _depth
14147            )?;
14148            fidl::decode!(
14149                VmoBuffer,
14150                fidl::encoding::DefaultFuchsiaResourceDialect,
14151                &mut self.buffer,
14152                decoder,
14153                offset + 264,
14154                _depth
14155            )?;
14156            Ok(())
14157        }
14158    }
14159
14160    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
14161        type Borrowed<'a> = &'a mut Self;
14162        fn take_or_borrow<'a>(
14163            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14164        ) -> Self::Borrowed<'a> {
14165            value
14166        }
14167    }
14168
14169    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
14170        type Owned = Self;
14171
14172        #[inline(always)]
14173        fn inline_align(_context: fidl::encoding::Context) -> usize {
14174            8
14175        }
14176
14177        #[inline(always)]
14178        fn inline_size(_context: fidl::encoding::Context) -> usize {
14179            16
14180        }
14181    }
14182
14183    unsafe impl fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14184        for &mut VmoBuffer
14185    {
14186        #[inline]
14187        unsafe fn encode(
14188            self,
14189            encoder: &mut fidl::encoding::Encoder<
14190                '_,
14191                fidl::encoding::DefaultFuchsiaResourceDialect,
14192            >,
14193            offset: usize,
14194            _depth: fidl::encoding::Depth,
14195        ) -> fidl::Result<()> {
14196            encoder.debug_check_bounds::<VmoBuffer>(offset);
14197            // Delegate to tuple encoding.
14198            fidl::encoding::Encode::<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14199                (
14200                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
14201                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_usable_start),
14202                ),
14203                encoder, offset, _depth
14204            )
14205        }
14206    }
14207    unsafe impl<
14208        T0: fidl::encoding::Encode<
14209                fidl::encoding::Optional<
14210                    fidl::encoding::HandleType<
14211                        fidl::Vmo,
14212                        { fidl::ObjectType::VMO.into_raw() },
14213                        2147483648,
14214                    >,
14215                >,
14216                fidl::encoding::DefaultFuchsiaResourceDialect,
14217            >,
14218        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
14219    > fidl::encoding::Encode<VmoBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>
14220        for (T0, T1)
14221    {
14222        #[inline]
14223        unsafe fn encode(
14224            self,
14225            encoder: &mut fidl::encoding::Encoder<
14226                '_,
14227                fidl::encoding::DefaultFuchsiaResourceDialect,
14228            >,
14229            offset: usize,
14230            depth: fidl::encoding::Depth,
14231        ) -> fidl::Result<()> {
14232            encoder.debug_check_bounds::<VmoBuffer>(offset);
14233            // Zero out padding regions. There's no need to apply masks
14234            // because the unmasked parts will be overwritten by fields.
14235            unsafe {
14236                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
14237                (ptr as *mut u64).write_unaligned(0);
14238            }
14239            // Write the fields.
14240            self.0.encode(encoder, offset + 0, depth)?;
14241            self.1.encode(encoder, offset + 8, depth)?;
14242            Ok(())
14243        }
14244    }
14245
14246    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoBuffer {
14247        #[inline(always)]
14248        fn new_empty() -> Self {
14249            Self {
14250                vmo: fidl::new_empty!(
14251                    fidl::encoding::Optional<
14252                        fidl::encoding::HandleType<
14253                            fidl::Vmo,
14254                            { fidl::ObjectType::VMO.into_raw() },
14255                            2147483648,
14256                        >,
14257                    >,
14258                    fidl::encoding::DefaultFuchsiaResourceDialect
14259                ),
14260                vmo_usable_start: fidl::new_empty!(
14261                    u64,
14262                    fidl::encoding::DefaultFuchsiaResourceDialect
14263                ),
14264            }
14265        }
14266
14267        #[inline]
14268        unsafe fn decode(
14269            &mut self,
14270            decoder: &mut fidl::encoding::Decoder<
14271                '_,
14272                fidl::encoding::DefaultFuchsiaResourceDialect,
14273            >,
14274            offset: usize,
14275            _depth: fidl::encoding::Depth,
14276        ) -> fidl::Result<()> {
14277            decoder.debug_check_bounds::<Self>(offset);
14278            // Verify that padding bytes are zero.
14279            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
14280            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14281            let mask = 0xffffffff00000000u64;
14282            let maskedval = padval & mask;
14283            if maskedval != 0 {
14284                return Err(fidl::Error::NonZeroPadding {
14285                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
14286                });
14287            }
14288            fidl::decode!(
14289                fidl::encoding::Optional<
14290                    fidl::encoding::HandleType<
14291                        fidl::Vmo,
14292                        { fidl::ObjectType::VMO.into_raw() },
14293                        2147483648,
14294                    >,
14295                >,
14296                fidl::encoding::DefaultFuchsiaResourceDialect,
14297                &mut self.vmo,
14298                decoder,
14299                offset + 0,
14300                _depth
14301            )?;
14302            fidl::decode!(
14303                u64,
14304                fidl::encoding::DefaultFuchsiaResourceDialect,
14305                &mut self.vmo_usable_start,
14306                decoder,
14307                offset + 8,
14308                _depth
14309            )?;
14310            Ok(())
14311        }
14312    }
14313
14314    impl BufferCollectionTokenGroupCreateChildRequest {
14315        #[inline(always)]
14316        fn max_ordinal_present(&self) -> u64 {
14317            if let Some(_) = self.rights_attenuation_mask {
14318                return 2;
14319            }
14320            if let Some(_) = self.token_request {
14321                return 1;
14322            }
14323            0
14324        }
14325    }
14326
14327    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14328        type Borrowed<'a> = &'a mut Self;
14329        fn take_or_borrow<'a>(
14330            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14331        ) -> Self::Borrowed<'a> {
14332            value
14333        }
14334    }
14335
14336    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
14337        type Owned = Self;
14338
14339        #[inline(always)]
14340        fn inline_align(_context: fidl::encoding::Context) -> usize {
14341            8
14342        }
14343
14344        #[inline(always)]
14345        fn inline_size(_context: fidl::encoding::Context) -> usize {
14346            16
14347        }
14348    }
14349
14350    unsafe impl
14351        fidl::encoding::Encode<
14352            BufferCollectionTokenGroupCreateChildRequest,
14353            fidl::encoding::DefaultFuchsiaResourceDialect,
14354        > for &mut BufferCollectionTokenGroupCreateChildRequest
14355    {
14356        unsafe fn encode(
14357            self,
14358            encoder: &mut fidl::encoding::Encoder<
14359                '_,
14360                fidl::encoding::DefaultFuchsiaResourceDialect,
14361            >,
14362            offset: usize,
14363            mut depth: fidl::encoding::Depth,
14364        ) -> fidl::Result<()> {
14365            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
14366            // Vector header
14367            let max_ordinal: u64 = self.max_ordinal_present();
14368            encoder.write_num(max_ordinal, offset);
14369            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14370            // Calling encoder.out_of_line_offset(0) is not allowed.
14371            if max_ordinal == 0 {
14372                return Ok(());
14373            }
14374            depth.increment()?;
14375            let envelope_size = 8;
14376            let bytes_len = max_ordinal as usize * envelope_size;
14377            #[allow(unused_variables)]
14378            let offset = encoder.out_of_line_offset(bytes_len);
14379            let mut _prev_end_offset: usize = 0;
14380            if 1 > max_ordinal {
14381                return Ok(());
14382            }
14383
14384            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14385            // are envelope_size bytes.
14386            let cur_offset: usize = (1 - 1) * envelope_size;
14387
14388            // Zero reserved fields.
14389            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14390
14391            // Safety:
14392            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14393            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14394            //   envelope_size bytes, there is always sufficient room.
14395            fidl::encoding::encode_in_envelope_optional::<
14396                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>>,
14397                fidl::encoding::DefaultFuchsiaResourceDialect,
14398            >(
14399                self.token_request.as_mut().map(
14400                    <fidl::encoding::Endpoint<
14401                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14402                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14403                ),
14404                encoder,
14405                offset + cur_offset,
14406                depth,
14407            )?;
14408
14409            _prev_end_offset = cur_offset + envelope_size;
14410            if 2 > max_ordinal {
14411                return Ok(());
14412            }
14413
14414            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14415            // are envelope_size bytes.
14416            let cur_offset: usize = (2 - 1) * envelope_size;
14417
14418            // Zero reserved fields.
14419            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14420
14421            // Safety:
14422            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14423            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14424            //   envelope_size bytes, there is always sufficient room.
14425            fidl::encoding::encode_in_envelope_optional::<
14426                u32,
14427                fidl::encoding::DefaultFuchsiaResourceDialect,
14428            >(
14429                self.rights_attenuation_mask
14430                    .as_ref()
14431                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
14432                encoder,
14433                offset + cur_offset,
14434                depth,
14435            )?;
14436
14437            _prev_end_offset = cur_offset + envelope_size;
14438
14439            Ok(())
14440        }
14441    }
14442
14443    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14444        for BufferCollectionTokenGroupCreateChildRequest
14445    {
14446        #[inline(always)]
14447        fn new_empty() -> Self {
14448            Self::default()
14449        }
14450
14451        unsafe fn decode(
14452            &mut self,
14453            decoder: &mut fidl::encoding::Decoder<
14454                '_,
14455                fidl::encoding::DefaultFuchsiaResourceDialect,
14456            >,
14457            offset: usize,
14458            mut depth: fidl::encoding::Depth,
14459        ) -> fidl::Result<()> {
14460            decoder.debug_check_bounds::<Self>(offset);
14461            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14462                None => return Err(fidl::Error::NotNullable),
14463                Some(len) => len,
14464            };
14465            // Calling decoder.out_of_line_offset(0) is not allowed.
14466            if len == 0 {
14467                return Ok(());
14468            };
14469            depth.increment()?;
14470            let envelope_size = 8;
14471            let bytes_len = len * envelope_size;
14472            let offset = decoder.out_of_line_offset(bytes_len)?;
14473            // Decode the envelope for each type.
14474            let mut _next_ordinal_to_read = 0;
14475            let mut next_offset = offset;
14476            let end_offset = offset + bytes_len;
14477            _next_ordinal_to_read += 1;
14478            if next_offset >= end_offset {
14479                return Ok(());
14480            }
14481
14482            // Decode unknown envelopes for gaps in ordinals.
14483            while _next_ordinal_to_read < 1 {
14484                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14485                _next_ordinal_to_read += 1;
14486                next_offset += envelope_size;
14487            }
14488
14489            let next_out_of_line = decoder.next_out_of_line();
14490            let handles_before = decoder.remaining_handles();
14491            if let Some((inlined, num_bytes, num_handles)) =
14492                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14493            {
14494                let member_inline_size = <fidl::encoding::Endpoint<
14495                    fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14496                > as fidl::encoding::TypeMarker>::inline_size(
14497                    decoder.context
14498                );
14499                if inlined != (member_inline_size <= 4) {
14500                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14501                }
14502                let inner_offset;
14503                let mut inner_depth = depth.clone();
14504                if inlined {
14505                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14506                    inner_offset = next_offset;
14507                } else {
14508                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14509                    inner_depth.increment()?;
14510                }
14511                let val_ref = self.token_request.get_or_insert_with(|| {
14512                    fidl::new_empty!(
14513                        fidl::encoding::Endpoint<
14514                            fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14515                        >,
14516                        fidl::encoding::DefaultFuchsiaResourceDialect
14517                    )
14518                });
14519                fidl::decode!(
14520                    fidl::encoding::Endpoint<
14521                        fidl::endpoints::ServerEnd<BufferCollectionTokenMarker>,
14522                    >,
14523                    fidl::encoding::DefaultFuchsiaResourceDialect,
14524                    val_ref,
14525                    decoder,
14526                    inner_offset,
14527                    inner_depth
14528                )?;
14529                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14530                {
14531                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14532                }
14533                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14534                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14535                }
14536            }
14537
14538            next_offset += envelope_size;
14539            _next_ordinal_to_read += 1;
14540            if next_offset >= end_offset {
14541                return Ok(());
14542            }
14543
14544            // Decode unknown envelopes for gaps in ordinals.
14545            while _next_ordinal_to_read < 2 {
14546                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14547                _next_ordinal_to_read += 1;
14548                next_offset += envelope_size;
14549            }
14550
14551            let next_out_of_line = decoder.next_out_of_line();
14552            let handles_before = decoder.remaining_handles();
14553            if let Some((inlined, num_bytes, num_handles)) =
14554                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14555            {
14556                let member_inline_size =
14557                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14558                if inlined != (member_inline_size <= 4) {
14559                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14560                }
14561                let inner_offset;
14562                let mut inner_depth = depth.clone();
14563                if inlined {
14564                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14565                    inner_offset = next_offset;
14566                } else {
14567                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14568                    inner_depth.increment()?;
14569                }
14570                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
14571                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
14572                });
14573                fidl::decode!(
14574                    u32,
14575                    fidl::encoding::DefaultFuchsiaResourceDialect,
14576                    val_ref,
14577                    decoder,
14578                    inner_offset,
14579                    inner_depth
14580                )?;
14581                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14582                {
14583                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14584                }
14585                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14586                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14587                }
14588            }
14589
14590            next_offset += envelope_size;
14591
14592            // Decode the remaining unknown envelopes.
14593            while next_offset < end_offset {
14594                _next_ordinal_to_read += 1;
14595                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14596                next_offset += envelope_size;
14597            }
14598
14599            Ok(())
14600        }
14601    }
14602}