Skip to main content

fdomain_fuchsia_media/
fdomain_fuchsia_media.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_media_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct AudioCapturerBindGainControlRequest {
15    pub gain_control_request:
16        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
17}
18
19impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
20    for AudioCapturerBindGainControlRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct AudioCapturerGetReferenceClockResponse {
26    pub reference_clock: fdomain_client::Clock,
27}
28
29impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
30    for AudioCapturerGetReferenceClockResponse
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AudioCapturerSetReferenceClockRequest {
36    pub reference_clock: Option<fdomain_client::Clock>,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
40    for AudioCapturerSetReferenceClockRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AudioConsumerBindVolumeControlRequest {
46    pub volume_control_request:
47        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
48}
49
50impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
51    for AudioConsumerBindVolumeControlRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct AudioConsumerCreateStreamSinkRequest {
57    pub buffers: Vec<fdomain_client::Vmo>,
58    pub stream_type: AudioStreamType,
59    pub compression: Option<Box<Compression>>,
60    pub stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
61}
62
63impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
64    for AudioConsumerCreateStreamSinkRequest
65{
66}
67
68#[derive(Debug, PartialEq)]
69pub struct AudioCoreBindUsageVolumeControl2Request {
70    pub usage: Usage2,
71    pub volume_control:
72        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
76    for AudioCoreBindUsageVolumeControl2Request
77{
78}
79
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct AudioCoreBindUsageVolumeControlRequest {
82    pub usage: Usage,
83    pub volume_control:
84        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
85}
86
87impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
88    for AudioCoreBindUsageVolumeControlRequest
89{
90}
91
92#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
93pub struct AudioCoreCreateAudioCapturerRequest {
94    pub loopback: bool,
95    pub audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
96}
97
98impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
99    for AudioCoreCreateAudioCapturerRequest
100{
101}
102
103#[derive(Debug, PartialEq)]
104pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
105    pub stream_type: AudioStreamType,
106    pub configuration: AudioCapturerConfiguration,
107    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
108}
109
110impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
111    for AudioCoreCreateAudioCapturerWithConfigurationRequest
112{
113}
114
115#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
116pub struct AudioCoreCreateAudioRendererRequest {
117    pub audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
118}
119
120impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
121    for AudioCoreCreateAudioRendererRequest
122{
123}
124
125#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
126pub struct AudioCreateAudioCapturerRequest {
127    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
128    pub loopback: bool,
129}
130
131impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
132    for AudioCreateAudioCapturerRequest
133{
134}
135
136#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137pub struct AudioCreateAudioRendererRequest {
138    pub audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
139}
140
141impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
142    for AudioCreateAudioRendererRequest
143{
144}
145
146#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
147pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
148    pub device_name: String,
149    pub is_input: bool,
150    pub channel:
151        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
152}
153
154impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
155    for AudioDeviceEnumeratorAddDeviceByChannelRequest
156{
157}
158
159#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
160pub struct AudioRendererBindGainControlRequest {
161    pub gain_control_request:
162        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
163}
164
165impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
166    for AudioRendererBindGainControlRequest
167{
168}
169
170#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
171pub struct AudioRendererGetReferenceClockResponse {
172    pub reference_clock: fdomain_client::Clock,
173}
174
175impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
176    for AudioRendererGetReferenceClockResponse
177{
178}
179
180#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
181pub struct AudioRendererSetReferenceClockRequest {
182    pub reference_clock: Option<fdomain_client::Clock>,
183}
184
185impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
186    for AudioRendererSetReferenceClockRequest
187{
188}
189
190#[derive(Debug, PartialEq, PartialOrd)]
191pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
192    pub thread_handle: fdomain_client::Thread,
193    pub name: String,
194    pub period: i64,
195    pub capacity: f32,
196}
197
198impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
199    for ProfileProviderRegisterHandlerWithCapacityRequest
200{
201}
202
203#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
204pub struct ProfileProviderRegisterMemoryRangeRequest {
205    pub vmar_handle: fdomain_client::Vmar,
206    pub name: String,
207}
208
209impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
210    for ProfileProviderRegisterMemoryRangeRequest
211{
212}
213
214#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
215pub struct ProfileProviderUnregisterHandlerRequest {
216    pub thread_handle: fdomain_client::Thread,
217    pub name: String,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
221    for ProfileProviderUnregisterHandlerRequest
222{
223}
224
225#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
226pub struct ProfileProviderUnregisterMemoryRangeRequest {
227    pub vmar_handle: fdomain_client::Vmar,
228}
229
230impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
231    for ProfileProviderUnregisterMemoryRangeRequest
232{
233}
234
235#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
236pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
237    pub session_id: u64,
238    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
239}
240
241impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
242    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
243{
244}
245
246#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
247pub struct StreamBufferSetAddPayloadBufferRequest {
248    pub id: u32,
249    pub payload_buffer: fdomain_client::Vmo,
250}
251
252impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
253    for StreamBufferSetAddPayloadBufferRequest
254{
255}
256
257#[derive(Debug, PartialEq)]
258pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
259    pub input_settings: StreamBufferPartialSettings,
260}
261
262impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
263    for StreamProcessorSetInputBufferPartialSettingsRequest
264{
265}
266
267#[derive(Debug, PartialEq)]
268pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
269    pub output_settings: StreamBufferPartialSettings,
270}
271
272impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
273    for StreamProcessorSetOutputBufferPartialSettingsRequest
274{
275}
276
277#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
278pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
279    pub usage: AudioRenderUsage2,
280    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
281}
282
283impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
284    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
285{
286}
287
288#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
289pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
290    pub usage: AudioRenderUsage,
291    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
292}
293
294impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
295    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
296{
297}
298
299#[derive(Debug, PartialEq)]
300pub struct UsageGainReporterRegisterListener2Request {
301    pub device_unique_id: String,
302    pub usage: Usage2,
303    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
304}
305
306impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
307    for UsageGainReporterRegisterListener2Request
308{
309}
310
311#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
312pub struct UsageGainReporterRegisterListenerRequest {
313    pub device_unique_id: String,
314    pub usage: Usage,
315    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
316}
317
318impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
319    for UsageGainReporterRegisterListenerRequest
320{
321}
322
323#[derive(Debug, PartialEq)]
324pub struct UsageReporterWatch2Request {
325    pub usage: Usage2,
326    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
327}
328
329impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatch2Request {}
330
331#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
332pub struct UsageReporterWatchRequest {
333    pub usage: Usage,
334    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
335}
336
337impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatchRequest {}
338
339#[derive(Debug, Default, PartialEq)]
340pub struct StreamBufferPartialSettings {
341    /// Each buffer is associated with a `buffer_lifetime_ordinal` value.
342    ///
343    /// There is a separate buffer_lifetime_ordinal for input vs. output.
344    ///
345    /// Values must be odd. Values must only increase (increasing by more than 2
346    /// is permitted).
347    ///
348    /// When using `SetInputBufferPartialSettings` or
349    /// `SetOutputBufferPartialSettings`, re-use of the same value (considering
350    /// input and output separately) for the new message is not allowed. Using
351    /// these messages, all the buffers of a given buffer_lifetime_ordinal value
352    /// are allocated as one sysmem buffer collection.
353    ///
354    /// When a new buffer_lifetime_ordinal starts, that also automatically
355    /// starts un-registering and releasing any buffers associated with prior
356    /// buffer_lifetime_ordinal values, but does not force them to complete
357    /// un-registration (or release) if they're still used by the codec for
358    /// reference purposes (VP9 can do this across a mid-stream dimensions
359    /// switch). A buffer can still be output by the server (as indicated by an
360    /// output packet) until un-registration completes.
361    ///
362    /// If the client wants the server to drop all buffers quickly, the client
363    /// can send `CloseCurrentStream` with `release_input_buffers` and/or
364    /// `release_output_buffers` set. This of course also stops decode of the
365    /// current stream. Closing the `StreamProcessor` client end is another
366    /// option.
367    pub buffer_lifetime_ordinal: Option<u64>,
368    /// This value indicates which version of constraints the client is/was
369    /// aware of so far.
370    ///
371    /// For input, this must always be 0 because constraints don't change for
372    /// input (settings can change, but there's no settings vs current
373    /// constraints synchronization issue on input).
374    ///
375    /// For output, this allows the server to know when the client is
376    /// sufficiently caught up before the server will generate any more output.
377    ///
378    /// When there is no active stream, a client is permitted to re-configure
379    /// buffers again using the same buffer_constraints_version_ordinal.
380    pub buffer_constraints_version_ordinal: Option<u64>,
381    pub single_buffer_mode: Option<bool>,
382    pub packet_count_for_server: Option<u32>,
383    pub packet_count_for_client: Option<u32>,
384    pub sysmem_token: Option<
385        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
386    >,
387    /// The client end of a BufferCollectionToken channel, which the
388    /// StreamProcessor will use to deliver constraints to sysmem and learn of
389    /// buffers allocated by sysmem.
390    ///
391    /// The client guarantees that the token is already known to sysmem (via
392    /// BufferCollectionToken.Sync(), BufferCollection.Sync(), or
393    /// BufferCollectionEvents.OnDuplicatedTokensKnownByServer()).
394    pub sysmem2_token: Option<
395        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
396    >,
397    #[doc(hidden)]
398    pub __source_breaking: fidl::marker::SourceBreaking,
399}
400
401impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
402    for StreamBufferPartialSettings
403{
404}
405
406#[derive(Debug, Default, PartialEq)]
407pub struct StreamProcessorAddBufferRequest {
408    /// Must be set. Which port (input or output) the buffer is for.
409    pub port: Option<Port>,
410    /// Typically this is the latest buffer_constraints_version_ordinal
411    /// known to the client based on OnInputConstraints/OnOutputConstraints.
412    /// Older values are not harmful to correctness.
413    ///
414    /// The server will ignore this message if the server has already
415    /// created a later buffer_constraints_version_ordinal value that has
416    /// action_required true. If the server ignores this message, a later
417    /// RemoveBuffer for this buffer will complete quickly and without
418    /// creating an error.
419    ///
420    /// A client is not required to ensure that every call to AddBuffer with
421    /// the same buffer_lifetime_ordinal uses the same
422    /// buffer_constraints_version_ordinal, but the client must ensure that
423    /// all buffer_constraints_version_ordinal values which share the same
424    /// buffer_lifetime_ordinal are within the same action_required true
425    /// interval. Each such interval starts with a value that has
426    /// action_required true, and lasts until but not including the next
427    /// value with action_required true, or until the current value if there
428    /// is not yet a next value with action_required true. If this would
429    /// create a problem for a server, that server should set
430    /// action_required true instead of false.
431    pub buffer_constraints_version_ordinal: Option<u64>,
432    /// These values are scoped to input/output separately.
433    ///
434    /// The first message from the client with a new (higher)
435    /// buffer_lifetime_ordinal value begins removing all buffers on the
436    /// same port with lower buffer_lifetime_ordinal. However, until removal
437    /// is complete, the older buffers can still be used by the codec.
438    ///
439    /// The AddBuffer message adds the buffer to this
440    /// buffer_lifetime_ordinal.
441    pub buffer_lifetime_ordinal: Option<u64>,
442    /// The buffer_index values under a buffer_lifetime_ordinal must be
443    /// unique among all added but not yet fully removed buffers. This value
444    /// is initially allocated/specified by the client using this field, and
445    /// then both the client and the server will then refer to a this added
446    /// buffer uniquely using input vs output, buffer_lifetime_ordinal, and
447    /// the buffer_index (all three parts are needed to unambiguously
448    /// specify this buffer).
449    ///
450    /// See RemoveBuffer doc comments for how to safely remove a buffer and
451    /// potentially re-use a buffer_index value.
452    ///
453    /// In contrast to using
454    /// SetInputBufferPartialSettings/SetOutputBufferPartialSettings, when
455    /// using AddBuffer and RemoveBuffer, the StreamProcessor buffer_index
456    /// value has no relation to the sysmem buffer_index (under the sysmem
457    /// buffer_collection_id). Instead, the StreamProcessor buffer_index is
458    /// specified by this field, not by using sysmem's buffer_index. This
459    /// way, two buffers from two sysmem collections having the same sysmem
460    /// buffer_index (under separate buffer_collection_id(s)) can be
461    /// specified unambiguously in StreamProcessor messages.
462    pub buffer_index: Option<u32>,
463    /// This is a VMO handle that the server can use to access the sysmem
464    /// buffer.
465    ///
466    /// This VMO is required to have been provided by sysmem, and required
467    /// to be compatible with the server's sysmem constraints.
468    ///
469    /// The buffer_constraints_version_ordinal check occurs first, and
470    /// failure of that check just silently ignores the remainder of this
471    /// message without checking the buffer field (buffer is just dropped).
472    ///
473    /// If the buffer_constraints_version_ordinal check passes, but `buffer`
474    /// isn't a sysmem-provided VMO or isn't consistent with the server's
475    /// sysmem constraints, the server will close the StreamProcessor
476    /// server_end. The client can avoid triggering this failure case by
477    /// allocating the buffers per the following.
478    ///
479    /// For video decoder input buffers, the client can allocate the buffer
480    /// using sysmem, with participation of this or another instance of the
481    /// same codec implementation, using ParticipateInBufferAllocation with
482    /// Port.INPUT. The same StreamProcessor instance isn't required
483    /// in this case, only the same codec implementation. If using a
484    /// different StreamProcessor instance (but still from the same codec
485    /// implementation), the client should take care to create the two
486    /// StreamProcessor instances with the same requirements specified to
487    /// CodecFactory (for example with secure_input_mode and
488    /// secure_output_mode set the same way). Video decoder server
489    /// implementations with supports_dynamic_buffers true are required to
490    /// support allocating input buffers using one StreamProcessor instance
491    /// then using them with a different StreamProcessor instance (in
492    /// contrast, for output buffers, this is not required).
493    ///
494    /// For video decoder output buffers, this can be achieved by allocating
495    /// the buffer using sysmem, with participation of the same
496    /// StreamProcessor instance, using ParticipateInBufferAllocation with
497    /// Port.OUTPUT.
498    ///
499    /// Servers should verify that this VMO is (a) provided by sysmem, and
500    /// (b) meets the server's current sysmem constraints. The server can
501    /// verify both (a) and (b) by checking the result of sysmem's
502    /// CheckVmoConstraints before using this VMO. If that check fails, the
503    /// server can close the StreamProcessor server_end.
504    pub buffer: Option<fdomain_client::Vmo>,
505    #[doc(hidden)]
506    pub __source_breaking: fidl::marker::SourceBreaking,
507}
508
509impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
510    for StreamProcessorAddBufferRequest
511{
512}
513
514#[derive(Debug, Default, PartialEq)]
515pub struct StreamProcessorParticipateInBufferAllocationRequest {
516    /// Which port (input or output) the buffer(s) are for.
517    ///
518    /// Must be set.
519    pub port: Option<Port>,
520    /// For input, this field must be set to 1, at least for now.
521    ///
522    /// For output, this field must set to the latest known (to the client)
523    /// buffer_constraints_version_ordinal value from the server. If the
524    /// value is less than the latest buffer_constraints_version_ordinal
525    /// created by the server which had action_reqiured true, then the
526    /// server will set generic sysmem constraints (just min_buffer_count 1)
527    /// and otherwise ignore this message. This is intended to allow
528    /// allocation to succeed (to allow simpler client error handling for
529    /// some clients); in this case a new buffer_constraints_version_ordinal
530    /// will reach the client and the client can catch up to the latest.
531    ///
532    /// If this value is a future value, the server will drop the
533    /// sysmem2_token which will cause allocation failure.
534    ///
535    /// Must be set.
536    pub buffer_constraints_version_ordinal: Option<u64>,
537    /// This sysmem token is used by the server to inform sysmem directly of
538    /// any applicable buffer constraints. These constraints are allowed to
539    /// (and in some cases must) depend on how this StreamProcessor instance
540    /// was created. For example, secure_input_mode/secure_output_mode
541    /// during StreamProcessor creation causes the server to set
542    /// secure_required for input/output respectively (as specified by
543    /// Port.INPUT or Port.OUTPUT respectively).
544    ///
545    /// Must be set.
546    pub sysmem2_token: Option<
547        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
548    >,
549    /// If set, and there's been at least one AddBuffer previously sent with
550    /// this buffer_lifetime_ordinal on the same StreamProcessor instance
551    /// which hasn't yet been removed server-side, the new buffer(s) will be
552    /// allocated with identical SingleBufferSettings, or fail allocation.
553    /// If any of the conditions in this paragraph aren't met, the effect is
554    /// the same as if this field is not set.
555    ///
556    /// If this field is not set, the sysmem constraints set by the server
557    /// will be suitable for a buffer of a new buffer_lifetime_ordinal, and
558    /// the new buffer's SingleBufferSettings might not match any previous
559    /// buffer's SingleBufferSettings.
560    ///
561    /// If the server has a current stream and `port` indicates the output
562    /// port, the constraints set will allow the stream to be correctly
563    /// processed across the switch to new buffer_lifetime_ordinal (assuming
564    /// the client is using a new buffer_lifetime_ordinal and adds the new
565    /// buffer(s) subsequently etc). If port indicates the input port, the
566    /// constraints set will be generic for the input port regardless of any
567    /// current stream.
568    ///
569    /// If this mechanism isn't used, the client must still ensure that all
570    /// AddBuffer with a given StreamProcessor instance, port, and
571    /// buffer_lifetime_ordinal have identical SingleBufferSettings. One way
572    /// to do this is to allocate all the buffers of a
573    /// buffer_lifetime_ordinal under a single sysmem buffer collection.
574    /// Another way is for the client to tell sysmem directly that a new
575    /// buffer collection must match the SingleBufferSettings of a prior
576    /// collection using
577    /// `[fuchsia.sysmem2/BufferCollectionConstraints.must_match_vmo]`
578    /// client-side.
579    ///
580    /// It's not recommended for a client to attempt to force a new
581    /// collecton's SingleBufferSettings to match an old collection's
582    /// SingleBufferSettings without sysmem's help and without
583    /// StreamProcessor's help via this field, because sysmem intentionally
584    /// allows clients participating in the same collection to be using
585    /// different versions of the sysmem interfaces, so the client may not
586    /// have enough information to successfully force the
587    /// SingleBufferSettings to match without using `must_match_vmo`, for
588    /// example if the client is unaware of a new SingleBufferSettings field
589    /// (or similar). The most common StreamProcessor server implementation
590    /// (CodecImpl) will handle this field using `must_match_vmo` on behalf
591    /// of the client as long as there's still at least one buffer of the
592    /// buffer_lifetime_ordinal active in the server. The ability to
593    /// dynamically add more buffers to an existing sysmem collection may be
594    /// added to sysmem at some point; that would give the client another
595    /// way to ensure identical SingleBufferSettings within a
596    /// buffer_lifetime_ordinal, but only if/when all sysmem collection
597    /// participants indicate support for a dynamic sysmem buffer
598    /// collection.
599    ///
600    /// For output, setting this field is strongly recommended if a client
601    /// is adding additional output buffers to an existing
602    /// buffer_lifetime_ordinal using a new/different sysmem buffer
603    /// collection, and setting this field is recommended for all output
604    /// buffer allocations.
605    ///
606    /// For input, if a client is using the same StreamProcessor instance
607    /// for this message and AddBuffer (which is itself recommended when
608    /// feasible), use of this field is recommended for those input buffers.
609    ///
610    /// If set, this value must match the buffer_lifetime_ordinal later sent
611    /// in AddBuffer.
612    ///
613    /// Clients should set this when feasible; see above.
614    pub buffer_lifetime_ordinal: Option<u64>,
615    /// If set to true, the server will leave all `buffer_count_*` fields
616    /// un-set when sending SetConstraints to sysmem, and will set
617    /// `min_buffer_count` to 1.
618    ///
619    /// If un-set or set to false, the server will fill out buffer count
620    /// fields when sending SetConstraints to sysmem based on the current
621    /// value of `buffer_count_for_server_current`, without any extra slack.
622    /// The client can add slack as desired via its own retained token.
623    ///
624    /// Regardless of whether this field is set to true, it's up to the
625    /// client to `AddBuffer` at least `buffer_count_for_server_current`
626    /// buffers so that processing can make progress.
627    pub allow_single_buffer: Option<bool>,
628    #[doc(hidden)]
629    pub __source_breaking: fidl::marker::SourceBreaking,
630}
631
632impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
633    for StreamProcessorParticipateInBufferAllocationRequest
634{
635}
636
637#[derive(Debug, Default, PartialEq)]
638pub struct StreamProcessorRemoveBufferRequest {
639    /// Must be set. Which port (input or output) the buffer is for.
640    pub port: Option<Port>,
641    /// Scoped to input or output, this is the buffer_lifetime_ordinal under
642    /// which the buffer_index is meaningful.
643    pub buffer_lifetime_ordinal: Option<u64>,
644    /// The buffer_index of the buffer previously established (and most
645    /// recently established) by AddBuffer, or by
646    /// SetInputBufferPartialSettings / SetOutputBufferPartialSettings. The
647    /// scope of this value is under input vs. output and under the
648    /// buffer_lifetime_ordinal value.
649    ///
650    /// When using dynamic buffers, the buffer_index values that are between
651    /// AddBuffer starting and RemoveBuffer completing (the active
652    /// buffer_index values) must be unique for a given Port value and
653    /// buffer_lifetime_ordinal value.
654    ///
655    /// Clients using dynamic buffers may wish to not re-use a buffer_index
656    /// value quickly upon completion of RemoveBuffer just to make
657    /// debugging/diagnosing easier, but technically re-use of buffer_index
658    /// in a subsequent AddBuffer is permitted as soon as RemoveBuffer
659    /// completes (from the StreamProcessor point of view - the client may
660    /// have its own reasons to not re-use that quickly). AddBuffer under an
661    /// old (not current) buffer_lifetime_ordinal is never allowed.
662    pub buffer_index: Option<u32>,
663    #[doc(hidden)]
664    pub __source_breaking: fidl::marker::SourceBreaking,
665}
666
667impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
668    for StreamProcessorRemoveBufferRequest
669{
670}
671
672#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
673pub struct ActivityReporterMarker;
674
675impl fdomain_client::fidl::ProtocolMarker for ActivityReporterMarker {
676    type Proxy = ActivityReporterProxy;
677    type RequestStream = ActivityReporterRequestStream;
678
679    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
680}
681impl fdomain_client::fidl::DiscoverableProtocolMarker for ActivityReporterMarker {}
682
683pub trait ActivityReporterProxyInterface: Send + Sync {
684    type WatchRenderActivityResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage>, fidl::Error>>
685        + Send;
686    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut;
687    type WatchRenderActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage2>, fidl::Error>>
688        + Send;
689    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut;
690    type WatchCaptureActivityResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage>, fidl::Error>>
691        + Send;
692    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut;
693    type WatchCaptureActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage2>, fidl::Error>>
694        + Send;
695    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut;
696}
697
698#[derive(Debug, Clone)]
699pub struct ActivityReporterProxy {
700    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
701}
702
703impl fdomain_client::fidl::Proxy for ActivityReporterProxy {
704    type Protocol = ActivityReporterMarker;
705
706    fn from_channel(inner: fdomain_client::Channel) -> Self {
707        Self::new(inner)
708    }
709
710    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
711        self.client.into_channel().map_err(|client| Self { client })
712    }
713
714    fn as_channel(&self) -> &fdomain_client::Channel {
715        self.client.as_channel()
716    }
717}
718
719impl ActivityReporterProxy {
720    /// Create a new Proxy for fuchsia.media/ActivityReporter.
721    pub fn new(channel: fdomain_client::Channel) -> Self {
722        let protocol_name =
723            <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
724        Self { client: fidl::client::Client::new(channel, protocol_name) }
725    }
726
727    /// Get a Stream of events from the remote end of the protocol.
728    ///
729    /// # Panics
730    ///
731    /// Panics if the event stream was already taken.
732    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
733        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
734    }
735
736    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
737    /// It returns immediately the first time that it is called.
738    pub fn r#watch_render_activity(
739        &self,
740    ) -> fidl::client::QueryResponseFut<
741        Vec<AudioRenderUsage>,
742        fdomain_client::fidl::FDomainResourceDialect,
743    > {
744        ActivityReporterProxyInterface::r#watch_render_activity(self)
745    }
746
747    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
748    /// It returns immediately the first time that it is called.
749    pub fn r#watch_render_activity2(
750        &self,
751    ) -> fidl::client::QueryResponseFut<
752        Vec<AudioRenderUsage2>,
753        fdomain_client::fidl::FDomainResourceDialect,
754    > {
755        ActivityReporterProxyInterface::r#watch_render_activity2(self)
756    }
757
758    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
759    /// It returns immediately the first time that it is called.
760    pub fn r#watch_capture_activity(
761        &self,
762    ) -> fidl::client::QueryResponseFut<
763        Vec<AudioCaptureUsage>,
764        fdomain_client::fidl::FDomainResourceDialect,
765    > {
766        ActivityReporterProxyInterface::r#watch_capture_activity(self)
767    }
768
769    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
770    /// It returns immediately the first time that it is called.
771    pub fn r#watch_capture_activity2(
772        &self,
773    ) -> fidl::client::QueryResponseFut<
774        Vec<AudioCaptureUsage2>,
775        fdomain_client::fidl::FDomainResourceDialect,
776    > {
777        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
778    }
779}
780
781impl ActivityReporterProxyInterface for ActivityReporterProxy {
782    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
783        Vec<AudioRenderUsage>,
784        fdomain_client::fidl::FDomainResourceDialect,
785    >;
786    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
787        fn _decode(
788            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
789        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
790            let _response = fidl::client::decode_transaction_body::<
791                ActivityReporterWatchRenderActivityResponse,
792                fdomain_client::fidl::FDomainResourceDialect,
793                0x2974e9f5880b2f1f,
794            >(_buf?)?;
795            Ok(_response.active_usages)
796        }
797        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
798            (),
799            0x2974e9f5880b2f1f,
800            fidl::encoding::DynamicFlags::empty(),
801            _decode,
802        )
803    }
804
805    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
806        Vec<AudioRenderUsage2>,
807        fdomain_client::fidl::FDomainResourceDialect,
808    >;
809    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
810        fn _decode(
811            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
812        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
813            let _response = fidl::client::decode_transaction_body::<
814                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
815                fdomain_client::fidl::FDomainResourceDialect,
816                0x484236fc11b363e6,
817            >(_buf?)?
818            .into_result_fdomain::<ActivityReporterMarker>("watch_render_activity2")?;
819            Ok(_response.active_usages)
820        }
821        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
822            (),
823            0x484236fc11b363e6,
824            fidl::encoding::DynamicFlags::FLEXIBLE,
825            _decode,
826        )
827    }
828
829    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
830        Vec<AudioCaptureUsage>,
831        fdomain_client::fidl::FDomainResourceDialect,
832    >;
833    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
834        fn _decode(
835            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
836        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
837            let _response = fidl::client::decode_transaction_body::<
838                ActivityReporterWatchCaptureActivityResponse,
839                fdomain_client::fidl::FDomainResourceDialect,
840                0x70e7038e9658e128,
841            >(_buf?)?;
842            Ok(_response.active_usages)
843        }
844        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
845            (),
846            0x70e7038e9658e128,
847            fidl::encoding::DynamicFlags::empty(),
848            _decode,
849        )
850    }
851
852    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
853        Vec<AudioCaptureUsage2>,
854        fdomain_client::fidl::FDomainResourceDialect,
855    >;
856    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
857        fn _decode(
858            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
859        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
860            let _response = fidl::client::decode_transaction_body::<
861                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
862                fdomain_client::fidl::FDomainResourceDialect,
863                0x3d137e0364f9d550,
864            >(_buf?)?
865            .into_result_fdomain::<ActivityReporterMarker>("watch_capture_activity2")?;
866            Ok(_response.active_usages)
867        }
868        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
869            (),
870            0x3d137e0364f9d550,
871            fidl::encoding::DynamicFlags::FLEXIBLE,
872            _decode,
873        )
874    }
875}
876
877pub struct ActivityReporterEventStream {
878    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
879}
880
881impl std::marker::Unpin for ActivityReporterEventStream {}
882
883impl futures::stream::FusedStream for ActivityReporterEventStream {
884    fn is_terminated(&self) -> bool {
885        self.event_receiver.is_terminated()
886    }
887}
888
889impl futures::Stream for ActivityReporterEventStream {
890    type Item = Result<ActivityReporterEvent, fidl::Error>;
891
892    fn poll_next(
893        mut self: std::pin::Pin<&mut Self>,
894        cx: &mut std::task::Context<'_>,
895    ) -> std::task::Poll<Option<Self::Item>> {
896        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
897            &mut self.event_receiver,
898            cx
899        )?) {
900            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
901            None => std::task::Poll::Ready(None),
902        }
903    }
904}
905
906#[derive(Debug)]
907pub enum ActivityReporterEvent {
908    #[non_exhaustive]
909    _UnknownEvent {
910        /// Ordinal of the event that was sent.
911        ordinal: u64,
912    },
913}
914
915impl ActivityReporterEvent {
916    /// Decodes a message buffer as a [`ActivityReporterEvent`].
917    fn decode(
918        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
919    ) -> Result<ActivityReporterEvent, fidl::Error> {
920        let (bytes, _handles) = buf.split_mut();
921        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
922        debug_assert_eq!(tx_header.tx_id, 0);
923        match tx_header.ordinal {
924            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
925                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
926            }
927            _ => Err(fidl::Error::UnknownOrdinal {
928                ordinal: tx_header.ordinal,
929                protocol_name:
930                    <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
931            }),
932        }
933    }
934}
935
936/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
937pub struct ActivityReporterRequestStream {
938    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
939    is_terminated: bool,
940}
941
942impl std::marker::Unpin for ActivityReporterRequestStream {}
943
944impl futures::stream::FusedStream for ActivityReporterRequestStream {
945    fn is_terminated(&self) -> bool {
946        self.is_terminated
947    }
948}
949
950impl fdomain_client::fidl::RequestStream for ActivityReporterRequestStream {
951    type Protocol = ActivityReporterMarker;
952    type ControlHandle = ActivityReporterControlHandle;
953
954    fn from_channel(channel: fdomain_client::Channel) -> Self {
955        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
956    }
957
958    fn control_handle(&self) -> Self::ControlHandle {
959        ActivityReporterControlHandle { inner: self.inner.clone() }
960    }
961
962    fn into_inner(
963        self,
964    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
965    {
966        (self.inner, self.is_terminated)
967    }
968
969    fn from_inner(
970        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
971        is_terminated: bool,
972    ) -> Self {
973        Self { inner, is_terminated }
974    }
975}
976
977impl futures::Stream for ActivityReporterRequestStream {
978    type Item = Result<ActivityReporterRequest, fidl::Error>;
979
980    fn poll_next(
981        mut self: std::pin::Pin<&mut Self>,
982        cx: &mut std::task::Context<'_>,
983    ) -> std::task::Poll<Option<Self::Item>> {
984        let this = &mut *self;
985        if this.inner.check_shutdown(cx) {
986            this.is_terminated = true;
987            return std::task::Poll::Ready(None);
988        }
989        if this.is_terminated {
990            panic!("polled ActivityReporterRequestStream after completion");
991        }
992        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
993            |bytes, handles| {
994                match this.inner.channel().read_etc(cx, bytes, handles) {
995                    std::task::Poll::Ready(Ok(())) => {}
996                    std::task::Poll::Pending => return std::task::Poll::Pending,
997                    std::task::Poll::Ready(Err(None)) => {
998                        this.is_terminated = true;
999                        return std::task::Poll::Ready(None);
1000                    }
1001                    std::task::Poll::Ready(Err(Some(e))) => {
1002                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1003                            e.into(),
1004                        ))));
1005                    }
1006                }
1007
1008                // A message has been received from the channel
1009                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1010
1011                std::task::Poll::Ready(Some(match header.ordinal {
1012                0x2974e9f5880b2f1f => {
1013                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1014                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1015                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1016                    let control_handle = ActivityReporterControlHandle {
1017                        inner: this.inner.clone(),
1018                    };
1019                    Ok(ActivityReporterRequest::WatchRenderActivity {
1020                        responder: ActivityReporterWatchRenderActivityResponder {
1021                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1022                            tx_id: header.tx_id,
1023                        },
1024                    })
1025                }
1026                0x484236fc11b363e6 => {
1027                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1028                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1029                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1030                    let control_handle = ActivityReporterControlHandle {
1031                        inner: this.inner.clone(),
1032                    };
1033                    Ok(ActivityReporterRequest::WatchRenderActivity2 {
1034                        responder: ActivityReporterWatchRenderActivity2Responder {
1035                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1036                            tx_id: header.tx_id,
1037                        },
1038                    })
1039                }
1040                0x70e7038e9658e128 => {
1041                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1042                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1043                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1044                    let control_handle = ActivityReporterControlHandle {
1045                        inner: this.inner.clone(),
1046                    };
1047                    Ok(ActivityReporterRequest::WatchCaptureActivity {
1048                        responder: ActivityReporterWatchCaptureActivityResponder {
1049                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1050                            tx_id: header.tx_id,
1051                        },
1052                    })
1053                }
1054                0x3d137e0364f9d550 => {
1055                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1056                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1057                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1058                    let control_handle = ActivityReporterControlHandle {
1059                        inner: this.inner.clone(),
1060                    };
1061                    Ok(ActivityReporterRequest::WatchCaptureActivity2 {
1062                        responder: ActivityReporterWatchCaptureActivity2Responder {
1063                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1064                            tx_id: header.tx_id,
1065                        },
1066                    })
1067                }
1068                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1069                    Ok(ActivityReporterRequest::_UnknownMethod {
1070                        ordinal: header.ordinal,
1071                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
1072                        method_type: fidl::MethodType::OneWay,
1073                    })
1074                }
1075                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1076                    this.inner.send_framework_err(
1077                        fidl::encoding::FrameworkErr::UnknownMethod,
1078                        header.tx_id,
1079                        header.ordinal,
1080                        header.dynamic_flags(),
1081                        (bytes, handles),
1082                    )?;
1083                    Ok(ActivityReporterRequest::_UnknownMethod {
1084                        ordinal: header.ordinal,
1085                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
1086                        method_type: fidl::MethodType::TwoWay,
1087                    })
1088                }
1089                _ => Err(fidl::Error::UnknownOrdinal {
1090                    ordinal: header.ordinal,
1091                    protocol_name: <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1092                }),
1093            }))
1094            },
1095        )
1096    }
1097}
1098
1099/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
1100#[derive(Debug)]
1101pub enum ActivityReporterRequest {
1102    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1103    /// It returns immediately the first time that it is called.
1104    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
1105    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1106    /// It returns immediately the first time that it is called.
1107    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
1108    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1109    /// It returns immediately the first time that it is called.
1110    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
1111    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1112    /// It returns immediately the first time that it is called.
1113    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
1114    /// An interaction was received which does not match any known method.
1115    #[non_exhaustive]
1116    _UnknownMethod {
1117        /// Ordinal of the method that was called.
1118        ordinal: u64,
1119        control_handle: ActivityReporterControlHandle,
1120        method_type: fidl::MethodType,
1121    },
1122}
1123
1124impl ActivityReporterRequest {
1125    #[allow(irrefutable_let_patterns)]
1126    pub fn into_watch_render_activity(
1127        self,
1128    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1129        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1130            Some((responder))
1131        } else {
1132            None
1133        }
1134    }
1135
1136    #[allow(irrefutable_let_patterns)]
1137    pub fn into_watch_render_activity2(
1138        self,
1139    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1140        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1141            Some((responder))
1142        } else {
1143            None
1144        }
1145    }
1146
1147    #[allow(irrefutable_let_patterns)]
1148    pub fn into_watch_capture_activity(
1149        self,
1150    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1151        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1152            Some((responder))
1153        } else {
1154            None
1155        }
1156    }
1157
1158    #[allow(irrefutable_let_patterns)]
1159    pub fn into_watch_capture_activity2(
1160        self,
1161    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1162        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1163            Some((responder))
1164        } else {
1165            None
1166        }
1167    }
1168
1169    /// Name of the method defined in FIDL
1170    pub fn method_name(&self) -> &'static str {
1171        match *self {
1172            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1173            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1174            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1175            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1176            ActivityReporterRequest::_UnknownMethod {
1177                method_type: fidl::MethodType::OneWay,
1178                ..
1179            } => "unknown one-way method",
1180            ActivityReporterRequest::_UnknownMethod {
1181                method_type: fidl::MethodType::TwoWay,
1182                ..
1183            } => "unknown two-way method",
1184        }
1185    }
1186}
1187
1188#[derive(Debug, Clone)]
1189pub struct ActivityReporterControlHandle {
1190    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1191}
1192
1193impl fdomain_client::fidl::ControlHandle for ActivityReporterControlHandle {
1194    fn shutdown(&self) {
1195        self.inner.shutdown()
1196    }
1197
1198    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1199        self.inner.shutdown_with_epitaph(status)
1200    }
1201
1202    fn is_closed(&self) -> bool {
1203        self.inner.channel().is_closed()
1204    }
1205    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1206        self.inner.channel().on_closed()
1207    }
1208}
1209
1210impl ActivityReporterControlHandle {}
1211
1212#[must_use = "FIDL methods require a response to be sent"]
1213#[derive(Debug)]
1214pub struct ActivityReporterWatchRenderActivityResponder {
1215    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1216    tx_id: u32,
1217}
1218
1219/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1220/// if the responder is dropped without sending a response, so that the client
1221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1222impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1223    fn drop(&mut self) {
1224        self.control_handle.shutdown();
1225        // Safety: drops once, never accessed again
1226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1227    }
1228}
1229
1230impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivityResponder {
1231    type ControlHandle = ActivityReporterControlHandle;
1232
1233    fn control_handle(&self) -> &ActivityReporterControlHandle {
1234        &self.control_handle
1235    }
1236
1237    fn drop_without_shutdown(mut self) {
1238        // Safety: drops once, never accessed again due to mem::forget
1239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1240        // Prevent Drop from running (which would shut down the channel)
1241        std::mem::forget(self);
1242    }
1243}
1244
1245impl ActivityReporterWatchRenderActivityResponder {
1246    /// Sends a response to the FIDL transaction.
1247    ///
1248    /// Sets the channel to shutdown if an error occurs.
1249    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1250        let _result = self.send_raw(active_usages);
1251        if _result.is_err() {
1252            self.control_handle.shutdown();
1253        }
1254        self.drop_without_shutdown();
1255        _result
1256    }
1257
1258    /// Similar to "send" but does not shutdown the channel if an error occurs.
1259    pub fn send_no_shutdown_on_err(
1260        self,
1261        mut active_usages: &[AudioRenderUsage],
1262    ) -> Result<(), fidl::Error> {
1263        let _result = self.send_raw(active_usages);
1264        self.drop_without_shutdown();
1265        _result
1266    }
1267
1268    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1269        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1270            (active_usages,),
1271            self.tx_id,
1272            0x2974e9f5880b2f1f,
1273            fidl::encoding::DynamicFlags::empty(),
1274        )
1275    }
1276}
1277
1278#[must_use = "FIDL methods require a response to be sent"]
1279#[derive(Debug)]
1280pub struct ActivityReporterWatchRenderActivity2Responder {
1281    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1282    tx_id: u32,
1283}
1284
1285/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1286/// if the responder is dropped without sending a response, so that the client
1287/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1288impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1289    fn drop(&mut self) {
1290        self.control_handle.shutdown();
1291        // Safety: drops once, never accessed again
1292        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1293    }
1294}
1295
1296impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivity2Responder {
1297    type ControlHandle = ActivityReporterControlHandle;
1298
1299    fn control_handle(&self) -> &ActivityReporterControlHandle {
1300        &self.control_handle
1301    }
1302
1303    fn drop_without_shutdown(mut self) {
1304        // Safety: drops once, never accessed again due to mem::forget
1305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1306        // Prevent Drop from running (which would shut down the channel)
1307        std::mem::forget(self);
1308    }
1309}
1310
1311impl ActivityReporterWatchRenderActivity2Responder {
1312    /// Sends a response to the FIDL transaction.
1313    ///
1314    /// Sets the channel to shutdown if an error occurs.
1315    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1316        let _result = self.send_raw(active_usages);
1317        if _result.is_err() {
1318            self.control_handle.shutdown();
1319        }
1320        self.drop_without_shutdown();
1321        _result
1322    }
1323
1324    /// Similar to "send" but does not shutdown the channel if an error occurs.
1325    pub fn send_no_shutdown_on_err(
1326        self,
1327        mut active_usages: &[AudioRenderUsage2],
1328    ) -> Result<(), fidl::Error> {
1329        let _result = self.send_raw(active_usages);
1330        self.drop_without_shutdown();
1331        _result
1332    }
1333
1334    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1335        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1336            ActivityReporterWatchRenderActivity2Response,
1337        >>(
1338            fidl::encoding::Flexible::new((active_usages,)),
1339            self.tx_id,
1340            0x484236fc11b363e6,
1341            fidl::encoding::DynamicFlags::FLEXIBLE,
1342        )
1343    }
1344}
1345
1346#[must_use = "FIDL methods require a response to be sent"]
1347#[derive(Debug)]
1348pub struct ActivityReporterWatchCaptureActivityResponder {
1349    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1350    tx_id: u32,
1351}
1352
1353/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1354/// if the responder is dropped without sending a response, so that the client
1355/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1356impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1357    fn drop(&mut self) {
1358        self.control_handle.shutdown();
1359        // Safety: drops once, never accessed again
1360        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1361    }
1362}
1363
1364impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivityResponder {
1365    type ControlHandle = ActivityReporterControlHandle;
1366
1367    fn control_handle(&self) -> &ActivityReporterControlHandle {
1368        &self.control_handle
1369    }
1370
1371    fn drop_without_shutdown(mut self) {
1372        // Safety: drops once, never accessed again due to mem::forget
1373        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1374        // Prevent Drop from running (which would shut down the channel)
1375        std::mem::forget(self);
1376    }
1377}
1378
1379impl ActivityReporterWatchCaptureActivityResponder {
1380    /// Sends a response to the FIDL transaction.
1381    ///
1382    /// Sets the channel to shutdown if an error occurs.
1383    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1384        let _result = self.send_raw(active_usages);
1385        if _result.is_err() {
1386            self.control_handle.shutdown();
1387        }
1388        self.drop_without_shutdown();
1389        _result
1390    }
1391
1392    /// Similar to "send" but does not shutdown the channel if an error occurs.
1393    pub fn send_no_shutdown_on_err(
1394        self,
1395        mut active_usages: &[AudioCaptureUsage],
1396    ) -> Result<(), fidl::Error> {
1397        let _result = self.send_raw(active_usages);
1398        self.drop_without_shutdown();
1399        _result
1400    }
1401
1402    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1403        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1404            (active_usages,),
1405            self.tx_id,
1406            0x70e7038e9658e128,
1407            fidl::encoding::DynamicFlags::empty(),
1408        )
1409    }
1410}
1411
1412#[must_use = "FIDL methods require a response to be sent"]
1413#[derive(Debug)]
1414pub struct ActivityReporterWatchCaptureActivity2Responder {
1415    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1416    tx_id: u32,
1417}
1418
1419/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1420/// if the responder is dropped without sending a response, so that the client
1421/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1422impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1423    fn drop(&mut self) {
1424        self.control_handle.shutdown();
1425        // Safety: drops once, never accessed again
1426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1427    }
1428}
1429
1430impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivity2Responder {
1431    type ControlHandle = ActivityReporterControlHandle;
1432
1433    fn control_handle(&self) -> &ActivityReporterControlHandle {
1434        &self.control_handle
1435    }
1436
1437    fn drop_without_shutdown(mut self) {
1438        // Safety: drops once, never accessed again due to mem::forget
1439        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1440        // Prevent Drop from running (which would shut down the channel)
1441        std::mem::forget(self);
1442    }
1443}
1444
1445impl ActivityReporterWatchCaptureActivity2Responder {
1446    /// Sends a response to the FIDL transaction.
1447    ///
1448    /// Sets the channel to shutdown if an error occurs.
1449    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1450        let _result = self.send_raw(active_usages);
1451        if _result.is_err() {
1452            self.control_handle.shutdown();
1453        }
1454        self.drop_without_shutdown();
1455        _result
1456    }
1457
1458    /// Similar to "send" but does not shutdown the channel if an error occurs.
1459    pub fn send_no_shutdown_on_err(
1460        self,
1461        mut active_usages: &[AudioCaptureUsage2],
1462    ) -> Result<(), fidl::Error> {
1463        let _result = self.send_raw(active_usages);
1464        self.drop_without_shutdown();
1465        _result
1466    }
1467
1468    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1469        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1470            ActivityReporterWatchCaptureActivity2Response,
1471        >>(
1472            fidl::encoding::Flexible::new((active_usages,)),
1473            self.tx_id,
1474            0x3d137e0364f9d550,
1475            fidl::encoding::DynamicFlags::FLEXIBLE,
1476        )
1477    }
1478}
1479
1480#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1481pub struct AudioMarker;
1482
1483impl fdomain_client::fidl::ProtocolMarker for AudioMarker {
1484    type Proxy = AudioProxy;
1485    type RequestStream = AudioRequestStream;
1486
1487    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1488}
1489impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioMarker {}
1490
1491pub trait AudioProxyInterface: Send + Sync {
1492    fn r#create_audio_renderer(
1493        &self,
1494        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1495    ) -> Result<(), fidl::Error>;
1496    fn r#create_audio_capturer(
1497        &self,
1498        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1499        loopback: bool,
1500    ) -> Result<(), fidl::Error>;
1501}
1502
1503#[derive(Debug, Clone)]
1504pub struct AudioProxy {
1505    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1506}
1507
1508impl fdomain_client::fidl::Proxy for AudioProxy {
1509    type Protocol = AudioMarker;
1510
1511    fn from_channel(inner: fdomain_client::Channel) -> Self {
1512        Self::new(inner)
1513    }
1514
1515    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1516        self.client.into_channel().map_err(|client| Self { client })
1517    }
1518
1519    fn as_channel(&self) -> &fdomain_client::Channel {
1520        self.client.as_channel()
1521    }
1522}
1523
1524impl AudioProxy {
1525    /// Create a new Proxy for fuchsia.media/Audio.
1526    pub fn new(channel: fdomain_client::Channel) -> Self {
1527        let protocol_name = <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1528        Self { client: fidl::client::Client::new(channel, protocol_name) }
1529    }
1530
1531    /// Get a Stream of events from the remote end of the protocol.
1532    ///
1533    /// # Panics
1534    ///
1535    /// Panics if the event stream was already taken.
1536    pub fn take_event_stream(&self) -> AudioEventStream {
1537        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1538    }
1539
1540    pub fn r#create_audio_renderer(
1541        &self,
1542        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1543    ) -> Result<(), fidl::Error> {
1544        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1545    }
1546
1547    /// Creates an AudioCapturer which either captures from the current default
1548    /// audio input device, or loops-back from the current default audio output
1549    /// device based on value passed for the loopback flag.
1550    pub fn r#create_audio_capturer(
1551        &self,
1552        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1553        mut loopback: bool,
1554    ) -> Result<(), fidl::Error> {
1555        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1556    }
1557}
1558
1559impl AudioProxyInterface for AudioProxy {
1560    fn r#create_audio_renderer(
1561        &self,
1562        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1563    ) -> Result<(), fidl::Error> {
1564        self.client.send::<AudioCreateAudioRendererRequest>(
1565            (audio_renderer_request,),
1566            0x572f413566fd58f1,
1567            fidl::encoding::DynamicFlags::empty(),
1568        )
1569    }
1570
1571    fn r#create_audio_capturer(
1572        &self,
1573        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1574        mut loopback: bool,
1575    ) -> Result<(), fidl::Error> {
1576        self.client.send::<AudioCreateAudioCapturerRequest>(
1577            (audio_capturer_request, loopback),
1578            0x44660fc63a6202f,
1579            fidl::encoding::DynamicFlags::empty(),
1580        )
1581    }
1582}
1583
1584pub struct AudioEventStream {
1585    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1586}
1587
1588impl std::marker::Unpin for AudioEventStream {}
1589
1590impl futures::stream::FusedStream for AudioEventStream {
1591    fn is_terminated(&self) -> bool {
1592        self.event_receiver.is_terminated()
1593    }
1594}
1595
1596impl futures::Stream for AudioEventStream {
1597    type Item = Result<AudioEvent, fidl::Error>;
1598
1599    fn poll_next(
1600        mut self: std::pin::Pin<&mut Self>,
1601        cx: &mut std::task::Context<'_>,
1602    ) -> std::task::Poll<Option<Self::Item>> {
1603        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1604            &mut self.event_receiver,
1605            cx
1606        )?) {
1607            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1608            None => std::task::Poll::Ready(None),
1609        }
1610    }
1611}
1612
1613#[derive(Debug)]
1614pub enum AudioEvent {}
1615
1616impl AudioEvent {
1617    /// Decodes a message buffer as a [`AudioEvent`].
1618    fn decode(
1619        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1620    ) -> Result<AudioEvent, fidl::Error> {
1621        let (bytes, _handles) = buf.split_mut();
1622        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1623        debug_assert_eq!(tx_header.tx_id, 0);
1624        match tx_header.ordinal {
1625            _ => Err(fidl::Error::UnknownOrdinal {
1626                ordinal: tx_header.ordinal,
1627                protocol_name: <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1628            }),
1629        }
1630    }
1631}
1632
1633/// A Stream of incoming requests for fuchsia.media/Audio.
1634pub struct AudioRequestStream {
1635    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1636    is_terminated: bool,
1637}
1638
1639impl std::marker::Unpin for AudioRequestStream {}
1640
1641impl futures::stream::FusedStream for AudioRequestStream {
1642    fn is_terminated(&self) -> bool {
1643        self.is_terminated
1644    }
1645}
1646
1647impl fdomain_client::fidl::RequestStream for AudioRequestStream {
1648    type Protocol = AudioMarker;
1649    type ControlHandle = AudioControlHandle;
1650
1651    fn from_channel(channel: fdomain_client::Channel) -> Self {
1652        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1653    }
1654
1655    fn control_handle(&self) -> Self::ControlHandle {
1656        AudioControlHandle { inner: self.inner.clone() }
1657    }
1658
1659    fn into_inner(
1660        self,
1661    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1662    {
1663        (self.inner, self.is_terminated)
1664    }
1665
1666    fn from_inner(
1667        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1668        is_terminated: bool,
1669    ) -> Self {
1670        Self { inner, is_terminated }
1671    }
1672}
1673
1674impl futures::Stream for AudioRequestStream {
1675    type Item = Result<AudioRequest, fidl::Error>;
1676
1677    fn poll_next(
1678        mut self: std::pin::Pin<&mut Self>,
1679        cx: &mut std::task::Context<'_>,
1680    ) -> std::task::Poll<Option<Self::Item>> {
1681        let this = &mut *self;
1682        if this.inner.check_shutdown(cx) {
1683            this.is_terminated = true;
1684            return std::task::Poll::Ready(None);
1685        }
1686        if this.is_terminated {
1687            panic!("polled AudioRequestStream after completion");
1688        }
1689        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1690            |bytes, handles| {
1691                match this.inner.channel().read_etc(cx, bytes, handles) {
1692                    std::task::Poll::Ready(Ok(())) => {}
1693                    std::task::Poll::Pending => return std::task::Poll::Pending,
1694                    std::task::Poll::Ready(Err(None)) => {
1695                        this.is_terminated = true;
1696                        return std::task::Poll::Ready(None);
1697                    }
1698                    std::task::Poll::Ready(Err(Some(e))) => {
1699                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1700                            e.into(),
1701                        ))));
1702                    }
1703                }
1704
1705                // A message has been received from the channel
1706                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1707
1708                std::task::Poll::Ready(Some(match header.ordinal {
1709                    0x572f413566fd58f1 => {
1710                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1711                        let mut req = fidl::new_empty!(
1712                            AudioCreateAudioRendererRequest,
1713                            fdomain_client::fidl::FDomainResourceDialect
1714                        );
1715                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1716                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1717                        Ok(AudioRequest::CreateAudioRenderer {
1718                            audio_renderer_request: req.audio_renderer_request,
1719
1720                            control_handle,
1721                        })
1722                    }
1723                    0x44660fc63a6202f => {
1724                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1725                        let mut req = fidl::new_empty!(
1726                            AudioCreateAudioCapturerRequest,
1727                            fdomain_client::fidl::FDomainResourceDialect
1728                        );
1729                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1730                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1731                        Ok(AudioRequest::CreateAudioCapturer {
1732                            audio_capturer_request: req.audio_capturer_request,
1733                            loopback: req.loopback,
1734
1735                            control_handle,
1736                        })
1737                    }
1738                    _ => Err(fidl::Error::UnknownOrdinal {
1739                        ordinal: header.ordinal,
1740                        protocol_name:
1741                            <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1742                    }),
1743                }))
1744            },
1745        )
1746    }
1747}
1748
1749#[derive(Debug)]
1750pub enum AudioRequest {
1751    CreateAudioRenderer {
1752        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1753        control_handle: AudioControlHandle,
1754    },
1755    /// Creates an AudioCapturer which either captures from the current default
1756    /// audio input device, or loops-back from the current default audio output
1757    /// device based on value passed for the loopback flag.
1758    CreateAudioCapturer {
1759        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1760        loopback: bool,
1761        control_handle: AudioControlHandle,
1762    },
1763}
1764
1765impl AudioRequest {
1766    #[allow(irrefutable_let_patterns)]
1767    pub fn into_create_audio_renderer(
1768        self,
1769    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1770        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1771            Some((audio_renderer_request, control_handle))
1772        } else {
1773            None
1774        }
1775    }
1776
1777    #[allow(irrefutable_let_patterns)]
1778    pub fn into_create_audio_capturer(
1779        self,
1780    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)>
1781    {
1782        if let AudioRequest::CreateAudioCapturer {
1783            audio_capturer_request,
1784            loopback,
1785            control_handle,
1786        } = self
1787        {
1788            Some((audio_capturer_request, loopback, control_handle))
1789        } else {
1790            None
1791        }
1792    }
1793
1794    /// Name of the method defined in FIDL
1795    pub fn method_name(&self) -> &'static str {
1796        match *self {
1797            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1798            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1799        }
1800    }
1801}
1802
1803#[derive(Debug, Clone)]
1804pub struct AudioControlHandle {
1805    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1806}
1807
1808impl fdomain_client::fidl::ControlHandle for AudioControlHandle {
1809    fn shutdown(&self) {
1810        self.inner.shutdown()
1811    }
1812
1813    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1814        self.inner.shutdown_with_epitaph(status)
1815    }
1816
1817    fn is_closed(&self) -> bool {
1818        self.inner.channel().is_closed()
1819    }
1820    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1821        self.inner.channel().on_closed()
1822    }
1823}
1824
1825impl AudioControlHandle {}
1826
1827#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1828pub struct AudioCapturerMarker;
1829
1830impl fdomain_client::fidl::ProtocolMarker for AudioCapturerMarker {
1831    type Proxy = AudioCapturerProxy;
1832    type RequestStream = AudioCapturerRequestStream;
1833
1834    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1835}
1836impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCapturerMarker {}
1837
1838pub trait AudioCapturerProxyInterface: Send + Sync {
1839    fn r#add_payload_buffer(
1840        &self,
1841        id: u32,
1842        payload_buffer: fdomain_client::Vmo,
1843    ) -> Result<(), fidl::Error>;
1844    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1845    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1846    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1847    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1848    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1849    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1850    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1851        + Send;
1852    fn r#capture_at(
1853        &self,
1854        payload_buffer_id: u32,
1855        payload_offset: u32,
1856        frames: u32,
1857    ) -> Self::CaptureAtResponseFut;
1858    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1859    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1860    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1861    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1862    fn r#bind_gain_control(
1863        &self,
1864        gain_control_request: fdomain_client::fidl::ServerEnd<
1865            fdomain_fuchsia_media_audio::GainControlMarker,
1866        >,
1867    ) -> Result<(), fidl::Error>;
1868    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
1869        + Send;
1870    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1871    fn r#set_reference_clock(
1872        &self,
1873        reference_clock: Option<fdomain_client::Clock>,
1874    ) -> Result<(), fidl::Error>;
1875    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1876    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1877    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1878        + Send;
1879    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1880}
1881
1882#[derive(Debug, Clone)]
1883pub struct AudioCapturerProxy {
1884    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1885}
1886
1887impl fdomain_client::fidl::Proxy for AudioCapturerProxy {
1888    type Protocol = AudioCapturerMarker;
1889
1890    fn from_channel(inner: fdomain_client::Channel) -> Self {
1891        Self::new(inner)
1892    }
1893
1894    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1895        self.client.into_channel().map_err(|client| Self { client })
1896    }
1897
1898    fn as_channel(&self) -> &fdomain_client::Channel {
1899        self.client.as_channel()
1900    }
1901}
1902
1903impl AudioCapturerProxy {
1904    /// Create a new Proxy for fuchsia.media/AudioCapturer.
1905    pub fn new(channel: fdomain_client::Channel) -> Self {
1906        let protocol_name =
1907            <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1908        Self { client: fidl::client::Client::new(channel, protocol_name) }
1909    }
1910
1911    /// Get a Stream of events from the remote end of the protocol.
1912    ///
1913    /// # Panics
1914    ///
1915    /// Panics if the event stream was already taken.
1916    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
1917        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
1918    }
1919
1920    /// Adds a payload buffer to the current buffer set associated with the
1921    /// connection. A `StreamPacket` struct reference a payload buffer in the
1922    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1923    ///
1924    /// A buffer with ID `id` must not be in the current set when this method is
1925    /// invoked, otherwise the service will close the connection.
1926    pub fn r#add_payload_buffer(
1927        &self,
1928        mut id: u32,
1929        mut payload_buffer: fdomain_client::Vmo,
1930    ) -> Result<(), fidl::Error> {
1931        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
1932    }
1933
1934    /// Removes a payload buffer from the current buffer set associated with the
1935    /// connection.
1936    ///
1937    /// A buffer with ID `id` must exist in the current set when this method is
1938    /// invoked, otherwise the service will will close the connection.
1939    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1940        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
1941    }
1942
1943    /// Releases payload memory associated with a packet previously delivered
1944    /// via `OnPacketProduced`.
1945    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1946        AudioCapturerProxyInterface::r#release_packet(self, packet)
1947    }
1948
1949    pub fn r#discard_all_packets(
1950        &self,
1951    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1952        AudioCapturerProxyInterface::r#discard_all_packets(self)
1953    }
1954
1955    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1956        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
1957    }
1958
1959    /// Sets the stream type of the stream to be delivered. Causes the source
1960    /// material to be reformatted/resampled if needed in order to produce the
1961    /// requested stream type. Must be called before the payload buffer is
1962    /// established.
1963    pub fn r#set_pcm_stream_type(
1964        &self,
1965        mut stream_type: &AudioStreamType,
1966    ) -> Result<(), fidl::Error> {
1967        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
1968    }
1969
1970    /// Explicitly specifies a region of the shared payload buffer for the audio
1971    /// input to capture into.
1972    pub fn r#capture_at(
1973        &self,
1974        mut payload_buffer_id: u32,
1975        mut payload_offset: u32,
1976        mut frames: u32,
1977    ) -> fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>
1978    {
1979        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
1980    }
1981
1982    /// Places the AudioCapturer into 'async' capture mode and begin to produce
1983    /// packets of exactly 'frames_per_packet' number of frames each. The
1984    /// OnPacketProduced event (of StreamSink) will be used to inform the client
1985    /// of produced packets.
1986    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
1987        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
1988    }
1989
1990    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
1991    /// that may be used by the client if explicit synchronization is needed.
1992    pub fn r#stop_async_capture(
1993        &self,
1994    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1995        AudioCapturerProxyInterface::r#stop_async_capture(self)
1996    }
1997
1998    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
1999        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2000    }
2001
2002    /// Binds to the gain control for this AudioCapturer.
2003    pub fn r#bind_gain_control(
2004        &self,
2005        mut gain_control_request: fdomain_client::fidl::ServerEnd<
2006            fdomain_fuchsia_media_audio::GainControlMarker,
2007        >,
2008    ) -> Result<(), fidl::Error> {
2009        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2010    }
2011
2012    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2013    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2014    pub fn r#get_reference_clock(
2015        &self,
2016    ) -> fidl::client::QueryResponseFut<
2017        fdomain_client::Clock,
2018        fdomain_client::fidl::FDomainResourceDialect,
2019    > {
2020        AudioCapturerProxyInterface::r#get_reference_clock(self)
2021    }
2022
2023    /// Sets the reference clock that controls this capturer's playback rate. If the input
2024    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2025    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2026    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2027    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2028    ///
2029    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2030    /// added. It also cannot be called a second time (even before capture).
2031    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2032    /// diverge at some later time, they should create a clone of the monotonic clock, set
2033    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2034    pub fn r#set_reference_clock(
2035        &self,
2036        mut reference_clock: Option<fdomain_client::Clock>,
2037    ) -> Result<(), fidl::Error> {
2038        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2039    }
2040
2041    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2042    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2043    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2044        AudioCapturerProxyInterface::r#set_usage(self, usage)
2045    }
2046
2047    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2048    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2049    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2050        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2051    }
2052
2053    /// Gets the currently configured stream type. Note: for an AudioCapturer
2054    /// which was just created and has not yet had its stream type explicitly
2055    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2056    /// was created -- of the source (input or looped-back output) to which the
2057    /// AudioCapturer is bound. Even if this matches the client's desired format,
2058    /// `SetPcmStreamType` must still be called.
2059    pub fn r#get_stream_type(
2060        &self,
2061    ) -> fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>
2062    {
2063        AudioCapturerProxyInterface::r#get_stream_type(self)
2064    }
2065}
2066
2067impl AudioCapturerProxyInterface for AudioCapturerProxy {
2068    fn r#add_payload_buffer(
2069        &self,
2070        mut id: u32,
2071        mut payload_buffer: fdomain_client::Vmo,
2072    ) -> Result<(), fidl::Error> {
2073        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2074            (id, payload_buffer),
2075            0x3b3a37fc34fe5b56,
2076            fidl::encoding::DynamicFlags::empty(),
2077        )
2078    }
2079
2080    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2081        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2082            (id,),
2083            0x5d1e4f74c3658262,
2084            fidl::encoding::DynamicFlags::empty(),
2085        )
2086    }
2087
2088    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2089        self.client.send::<StreamSourceReleasePacketRequest>(
2090            (packet,),
2091            0x7a7b57f0f7d9e4bb,
2092            fidl::encoding::DynamicFlags::empty(),
2093        )
2094    }
2095
2096    type DiscardAllPacketsResponseFut =
2097        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2098    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2099        fn _decode(
2100            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2101        ) -> Result<(), fidl::Error> {
2102            let _response = fidl::client::decode_transaction_body::<
2103                fidl::encoding::EmptyPayload,
2104                fdomain_client::fidl::FDomainResourceDialect,
2105                0x27afd605e97b09d2,
2106            >(_buf?)?;
2107            Ok(_response)
2108        }
2109        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2110            (),
2111            0x27afd605e97b09d2,
2112            fidl::encoding::DynamicFlags::empty(),
2113            _decode,
2114        )
2115    }
2116
2117    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2118        self.client.send::<fidl::encoding::EmptyPayload>(
2119            (),
2120            0x35f9d721e905b831,
2121            fidl::encoding::DynamicFlags::empty(),
2122        )
2123    }
2124
2125    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2126        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2127            (stream_type,),
2128            0x1531ea9ea2c852cd,
2129            fidl::encoding::DynamicFlags::empty(),
2130        )
2131    }
2132
2133    type CaptureAtResponseFut =
2134        fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>;
2135    fn r#capture_at(
2136        &self,
2137        mut payload_buffer_id: u32,
2138        mut payload_offset: u32,
2139        mut frames: u32,
2140    ) -> Self::CaptureAtResponseFut {
2141        fn _decode(
2142            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2143        ) -> Result<StreamPacket, fidl::Error> {
2144            let _response = fidl::client::decode_transaction_body::<
2145                AudioCapturerCaptureAtResponse,
2146                fdomain_client::fidl::FDomainResourceDialect,
2147                0x784e25df72cea780,
2148            >(_buf?)?;
2149            Ok(_response.captured_packet)
2150        }
2151        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2152            (payload_buffer_id, payload_offset, frames),
2153            0x784e25df72cea780,
2154            fidl::encoding::DynamicFlags::empty(),
2155            _decode,
2156        )
2157    }
2158
2159    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2160        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2161            (frames_per_packet,),
2162            0x7768adbb1ccfd7a6,
2163            fidl::encoding::DynamicFlags::empty(),
2164        )
2165    }
2166
2167    type StopAsyncCaptureResponseFut =
2168        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2169    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2170        fn _decode(
2171            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2172        ) -> Result<(), fidl::Error> {
2173            let _response = fidl::client::decode_transaction_body::<
2174                fidl::encoding::EmptyPayload,
2175                fdomain_client::fidl::FDomainResourceDialect,
2176                0x5bfc8790a8cef8cb,
2177            >(_buf?)?;
2178            Ok(_response)
2179        }
2180        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2181            (),
2182            0x5bfc8790a8cef8cb,
2183            fidl::encoding::DynamicFlags::empty(),
2184            _decode,
2185        )
2186    }
2187
2188    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2189        self.client.send::<fidl::encoding::EmptyPayload>(
2190            (),
2191            0x33223cb2962c95e3,
2192            fidl::encoding::DynamicFlags::empty(),
2193        )
2194    }
2195
2196    fn r#bind_gain_control(
2197        &self,
2198        mut gain_control_request: fdomain_client::fidl::ServerEnd<
2199            fdomain_fuchsia_media_audio::GainControlMarker,
2200        >,
2201    ) -> Result<(), fidl::Error> {
2202        self.client.send::<AudioCapturerBindGainControlRequest>(
2203            (gain_control_request,),
2204            0x658a6a17ddb3a8e0,
2205            fidl::encoding::DynamicFlags::empty(),
2206        )
2207    }
2208
2209    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
2210        fdomain_client::Clock,
2211        fdomain_client::fidl::FDomainResourceDialect,
2212    >;
2213    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2214        fn _decode(
2215            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2216        ) -> Result<fdomain_client::Clock, fidl::Error> {
2217            let _response = fidl::client::decode_transaction_body::<
2218                AudioCapturerGetReferenceClockResponse,
2219                fdomain_client::fidl::FDomainResourceDialect,
2220                0x50d037aa5a4b4d71,
2221            >(_buf?)?;
2222            Ok(_response.reference_clock)
2223        }
2224        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
2225            (),
2226            0x50d037aa5a4b4d71,
2227            fidl::encoding::DynamicFlags::empty(),
2228            _decode,
2229        )
2230    }
2231
2232    fn r#set_reference_clock(
2233        &self,
2234        mut reference_clock: Option<fdomain_client::Clock>,
2235    ) -> Result<(), fidl::Error> {
2236        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2237            (reference_clock,),
2238            0x732b2c496d521bcf,
2239            fidl::encoding::DynamicFlags::empty(),
2240        )
2241    }
2242
2243    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2244        self.client.send::<AudioCapturerSetUsageRequest>(
2245            (usage,),
2246            0x42a16f392bd21b25,
2247            fidl::encoding::DynamicFlags::empty(),
2248        )
2249    }
2250
2251    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2252        self.client.send::<AudioCapturerSetUsage2Request>(
2253            (usage,),
2254            0x7a73e251b8d2382b,
2255            fidl::encoding::DynamicFlags::FLEXIBLE,
2256        )
2257    }
2258
2259    type GetStreamTypeResponseFut =
2260        fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>;
2261    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2262        fn _decode(
2263            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2264        ) -> Result<StreamType, fidl::Error> {
2265            let _response = fidl::client::decode_transaction_body::<
2266                AudioCapturerGetStreamTypeResponse,
2267                fdomain_client::fidl::FDomainResourceDialect,
2268                0x5dcaaa670b433088,
2269            >(_buf?)?;
2270            Ok(_response.stream_type)
2271        }
2272        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2273            (),
2274            0x5dcaaa670b433088,
2275            fidl::encoding::DynamicFlags::empty(),
2276            _decode,
2277        )
2278    }
2279}
2280
2281pub struct AudioCapturerEventStream {
2282    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2283}
2284
2285impl std::marker::Unpin for AudioCapturerEventStream {}
2286
2287impl futures::stream::FusedStream for AudioCapturerEventStream {
2288    fn is_terminated(&self) -> bool {
2289        self.event_receiver.is_terminated()
2290    }
2291}
2292
2293impl futures::Stream for AudioCapturerEventStream {
2294    type Item = Result<AudioCapturerEvent, fidl::Error>;
2295
2296    fn poll_next(
2297        mut self: std::pin::Pin<&mut Self>,
2298        cx: &mut std::task::Context<'_>,
2299    ) -> std::task::Poll<Option<Self::Item>> {
2300        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2301            &mut self.event_receiver,
2302            cx
2303        )?) {
2304            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2305            None => std::task::Poll::Ready(None),
2306        }
2307    }
2308}
2309
2310#[derive(Debug)]
2311pub enum AudioCapturerEvent {
2312    OnPacketProduced {
2313        packet: StreamPacket,
2314    },
2315    OnEndOfStream {},
2316    #[non_exhaustive]
2317    _UnknownEvent {
2318        /// Ordinal of the event that was sent.
2319        ordinal: u64,
2320    },
2321}
2322
2323impl AudioCapturerEvent {
2324    #[allow(irrefutable_let_patterns)]
2325    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2326        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2327            Some((packet))
2328        } else {
2329            None
2330        }
2331    }
2332    #[allow(irrefutable_let_patterns)]
2333    pub fn into_on_end_of_stream(self) -> Option<()> {
2334        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2335    }
2336
2337    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2338    fn decode(
2339        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2340    ) -> Result<AudioCapturerEvent, fidl::Error> {
2341        let (bytes, _handles) = buf.split_mut();
2342        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2343        debug_assert_eq!(tx_header.tx_id, 0);
2344        match tx_header.ordinal {
2345            0x6bbe69746a3c8bd9 => {
2346                let mut out = fidl::new_empty!(
2347                    StreamSourceOnPacketProducedRequest,
2348                    fdomain_client::fidl::FDomainResourceDialect
2349                );
2350                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2351                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2352            }
2353            0x550e69b41d03e2c2 => {
2354                let mut out = fidl::new_empty!(
2355                    fidl::encoding::EmptyPayload,
2356                    fdomain_client::fidl::FDomainResourceDialect
2357                );
2358                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2359                Ok((AudioCapturerEvent::OnEndOfStream {}))
2360            }
2361            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2362                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2363            }
2364            _ => Err(fidl::Error::UnknownOrdinal {
2365                ordinal: tx_header.ordinal,
2366                protocol_name:
2367                    <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2368            }),
2369        }
2370    }
2371}
2372
2373/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2374pub struct AudioCapturerRequestStream {
2375    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2376    is_terminated: bool,
2377}
2378
2379impl std::marker::Unpin for AudioCapturerRequestStream {}
2380
2381impl futures::stream::FusedStream for AudioCapturerRequestStream {
2382    fn is_terminated(&self) -> bool {
2383        self.is_terminated
2384    }
2385}
2386
2387impl fdomain_client::fidl::RequestStream for AudioCapturerRequestStream {
2388    type Protocol = AudioCapturerMarker;
2389    type ControlHandle = AudioCapturerControlHandle;
2390
2391    fn from_channel(channel: fdomain_client::Channel) -> Self {
2392        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2393    }
2394
2395    fn control_handle(&self) -> Self::ControlHandle {
2396        AudioCapturerControlHandle { inner: self.inner.clone() }
2397    }
2398
2399    fn into_inner(
2400        self,
2401    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2402    {
2403        (self.inner, self.is_terminated)
2404    }
2405
2406    fn from_inner(
2407        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2408        is_terminated: bool,
2409    ) -> Self {
2410        Self { inner, is_terminated }
2411    }
2412}
2413
2414impl futures::Stream for AudioCapturerRequestStream {
2415    type Item = Result<AudioCapturerRequest, fidl::Error>;
2416
2417    fn poll_next(
2418        mut self: std::pin::Pin<&mut Self>,
2419        cx: &mut std::task::Context<'_>,
2420    ) -> std::task::Poll<Option<Self::Item>> {
2421        let this = &mut *self;
2422        if this.inner.check_shutdown(cx) {
2423            this.is_terminated = true;
2424            return std::task::Poll::Ready(None);
2425        }
2426        if this.is_terminated {
2427            panic!("polled AudioCapturerRequestStream after completion");
2428        }
2429        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2430            |bytes, handles| {
2431                match this.inner.channel().read_etc(cx, bytes, handles) {
2432                    std::task::Poll::Ready(Ok(())) => {}
2433                    std::task::Poll::Pending => return std::task::Poll::Pending,
2434                    std::task::Poll::Ready(Err(None)) => {
2435                        this.is_terminated = true;
2436                        return std::task::Poll::Ready(None);
2437                    }
2438                    std::task::Poll::Ready(Err(Some(e))) => {
2439                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2440                            e.into(),
2441                        ))));
2442                    }
2443                }
2444
2445                // A message has been received from the channel
2446                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2447
2448                std::task::Poll::Ready(Some(match header.ordinal {
2449                0x3b3a37fc34fe5b56 => {
2450                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2451                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2452                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2453                    let control_handle = AudioCapturerControlHandle {
2454                        inner: this.inner.clone(),
2455                    };
2456                    Ok(AudioCapturerRequest::AddPayloadBuffer {id: req.id,
2457payload_buffer: req.payload_buffer,
2458
2459                        control_handle,
2460                    })
2461                }
2462                0x5d1e4f74c3658262 => {
2463                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2464                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2465                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2466                    let control_handle = AudioCapturerControlHandle {
2467                        inner: this.inner.clone(),
2468                    };
2469                    Ok(AudioCapturerRequest::RemovePayloadBuffer {id: req.id,
2470
2471                        control_handle,
2472                    })
2473                }
2474                0x7a7b57f0f7d9e4bb => {
2475                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2476                    let mut req = fidl::new_empty!(StreamSourceReleasePacketRequest, fdomain_client::fidl::FDomainResourceDialect);
2477                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2478                    let control_handle = AudioCapturerControlHandle {
2479                        inner: this.inner.clone(),
2480                    };
2481                    Ok(AudioCapturerRequest::ReleasePacket {packet: req.packet,
2482
2483                        control_handle,
2484                    })
2485                }
2486                0x27afd605e97b09d2 => {
2487                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2488                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2489                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2490                    let control_handle = AudioCapturerControlHandle {
2491                        inner: this.inner.clone(),
2492                    };
2493                    Ok(AudioCapturerRequest::DiscardAllPackets {
2494                        responder: AudioCapturerDiscardAllPacketsResponder {
2495                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2496                            tx_id: header.tx_id,
2497                        },
2498                    })
2499                }
2500                0x35f9d721e905b831 => {
2501                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2502                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2503                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2504                    let control_handle = AudioCapturerControlHandle {
2505                        inner: this.inner.clone(),
2506                    };
2507                    Ok(AudioCapturerRequest::DiscardAllPacketsNoReply {
2508                        control_handle,
2509                    })
2510                }
2511                0x1531ea9ea2c852cd => {
2512                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2513                    let mut req = fidl::new_empty!(AudioCapturerSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
2514                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2515                    let control_handle = AudioCapturerControlHandle {
2516                        inner: this.inner.clone(),
2517                    };
2518                    Ok(AudioCapturerRequest::SetPcmStreamType {stream_type: req.stream_type,
2519
2520                        control_handle,
2521                    })
2522                }
2523                0x784e25df72cea780 => {
2524                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2525                    let mut req = fidl::new_empty!(AudioCapturerCaptureAtRequest, fdomain_client::fidl::FDomainResourceDialect);
2526                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2527                    let control_handle = AudioCapturerControlHandle {
2528                        inner: this.inner.clone(),
2529                    };
2530                    Ok(AudioCapturerRequest::CaptureAt {payload_buffer_id: req.payload_buffer_id,
2531payload_offset: req.payload_offset,
2532frames: req.frames,
2533
2534                        responder: AudioCapturerCaptureAtResponder {
2535                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2536                            tx_id: header.tx_id,
2537                        },
2538                    })
2539                }
2540                0x7768adbb1ccfd7a6 => {
2541                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2542                    let mut req = fidl::new_empty!(AudioCapturerStartAsyncCaptureRequest, fdomain_client::fidl::FDomainResourceDialect);
2543                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2544                    let control_handle = AudioCapturerControlHandle {
2545                        inner: this.inner.clone(),
2546                    };
2547                    Ok(AudioCapturerRequest::StartAsyncCapture {frames_per_packet: req.frames_per_packet,
2548
2549                        control_handle,
2550                    })
2551                }
2552                0x5bfc8790a8cef8cb => {
2553                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2554                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2555                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2556                    let control_handle = AudioCapturerControlHandle {
2557                        inner: this.inner.clone(),
2558                    };
2559                    Ok(AudioCapturerRequest::StopAsyncCapture {
2560                        responder: AudioCapturerStopAsyncCaptureResponder {
2561                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2562                            tx_id: header.tx_id,
2563                        },
2564                    })
2565                }
2566                0x33223cb2962c95e3 => {
2567                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2568                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2569                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2570                    let control_handle = AudioCapturerControlHandle {
2571                        inner: this.inner.clone(),
2572                    };
2573                    Ok(AudioCapturerRequest::StopAsyncCaptureNoReply {
2574                        control_handle,
2575                    })
2576                }
2577                0x658a6a17ddb3a8e0 => {
2578                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2579                    let mut req = fidl::new_empty!(AudioCapturerBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
2580                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2581                    let control_handle = AudioCapturerControlHandle {
2582                        inner: this.inner.clone(),
2583                    };
2584                    Ok(AudioCapturerRequest::BindGainControl {gain_control_request: req.gain_control_request,
2585
2586                        control_handle,
2587                    })
2588                }
2589                0x50d037aa5a4b4d71 => {
2590                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2591                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2592                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2593                    let control_handle = AudioCapturerControlHandle {
2594                        inner: this.inner.clone(),
2595                    };
2596                    Ok(AudioCapturerRequest::GetReferenceClock {
2597                        responder: AudioCapturerGetReferenceClockResponder {
2598                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2599                            tx_id: header.tx_id,
2600                        },
2601                    })
2602                }
2603                0x732b2c496d521bcf => {
2604                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2605                    let mut req = fidl::new_empty!(AudioCapturerSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
2606                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2607                    let control_handle = AudioCapturerControlHandle {
2608                        inner: this.inner.clone(),
2609                    };
2610                    Ok(AudioCapturerRequest::SetReferenceClock {reference_clock: req.reference_clock,
2611
2612                        control_handle,
2613                    })
2614                }
2615                0x42a16f392bd21b25 => {
2616                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2617                    let mut req = fidl::new_empty!(AudioCapturerSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
2618                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2619                    let control_handle = AudioCapturerControlHandle {
2620                        inner: this.inner.clone(),
2621                    };
2622                    Ok(AudioCapturerRequest::SetUsage {usage: req.usage,
2623
2624                        control_handle,
2625                    })
2626                }
2627                0x7a73e251b8d2382b => {
2628                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2629                    let mut req = fidl::new_empty!(AudioCapturerSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
2630                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2631                    let control_handle = AudioCapturerControlHandle {
2632                        inner: this.inner.clone(),
2633                    };
2634                    Ok(AudioCapturerRequest::SetUsage2 {usage: req.usage,
2635
2636                        control_handle,
2637                    })
2638                }
2639                0x5dcaaa670b433088 => {
2640                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2641                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2642                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2643                    let control_handle = AudioCapturerControlHandle {
2644                        inner: this.inner.clone(),
2645                    };
2646                    Ok(AudioCapturerRequest::GetStreamType {
2647                        responder: AudioCapturerGetStreamTypeResponder {
2648                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2649                            tx_id: header.tx_id,
2650                        },
2651                    })
2652                }
2653                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2654                    Ok(AudioCapturerRequest::_UnknownMethod {
2655                        ordinal: header.ordinal,
2656                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2657                        method_type: fidl::MethodType::OneWay,
2658                    })
2659                }
2660                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2661                    this.inner.send_framework_err(
2662                        fidl::encoding::FrameworkErr::UnknownMethod,
2663                        header.tx_id,
2664                        header.ordinal,
2665                        header.dynamic_flags(),
2666                        (bytes, handles),
2667                    )?;
2668                    Ok(AudioCapturerRequest::_UnknownMethod {
2669                        ordinal: header.ordinal,
2670                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2671                        method_type: fidl::MethodType::TwoWay,
2672                    })
2673                }
2674                _ => Err(fidl::Error::UnknownOrdinal {
2675                    ordinal: header.ordinal,
2676                    protocol_name: <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2677                }),
2678            }))
2679            },
2680        )
2681    }
2682}
2683
2684/// AudioCapturer
2685///
2686/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
2687/// CreateAudioCapturer method, which may be used by clients to capture audio
2688/// from either the current default audio input device, or the current default
2689/// audio output device depending on the flags passed during creation.
2690///
2691/// **Format support**
2692///
2693/// See (Get|Set)StreamType below. By default, the captured stream type will be
2694/// initially determined by the currently configured stream type of the source
2695/// that the AudioCapturer was bound to at creation time. Users may either fetch
2696/// this type using GetStreamType, or they may choose to have the media
2697/// resampled or converted to a type of their choosing by calling SetStreamType.
2698/// Note: the stream type may only be set while the system is not running,
2699/// meaning that there are no pending capture regions (specified using CaptureAt)
2700/// and that the system is not currently running in 'async' capture mode.
2701///
2702/// **Buffers and memory management**
2703///
2704/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
2705/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
2706/// following requirements related to the management of the payload buffer.
2707///
2708/// + The payload buffer must be supplied before any capture operation may
2709///   start. Any attempt to start capture (via either CaptureAt or
2710///   StartAsyncCapture) before a payload buffer has been established is an
2711///   error.
2712/// + The payload buffer may not be changed while there are any capture
2713///   operations pending.
2714/// + The stream type may not be changed after the payload buffer has been set.
2715/// + The payload buffer must be an integral number of audio frame sizes (in
2716///   bytes)
2717/// + When running in 'async' mode (see below), the payload buffer must be at
2718///   least as large as twice the frames_per_packet size specified during
2719///   StartAsyncCapture.
2720/// + The handle to the payload buffer supplied by the user must be readable,
2721///   writable, mappable and transferable.
2722/// + Users should always treat the payload buffer as read-only.
2723///
2724/// **Synchronous vs. Asynchronous capture mode**
2725///
2726/// The AudioCapturer interface can be used in one of two mutually exclusive
2727/// modes: Synchronous and Asynchronous. A description of each mode and their
2728/// tradeoffs is given below.
2729///
2730/// **Synchronous mode**
2731///
2732/// By default, AudioCapturer instances are running in 'sync' mode. They will
2733/// only capture data when a user supplies at least one region to capture into
2734/// using the CaptureAt method. Regions supplied in this way will be filled in
2735/// the order that they are received and returned to the client as StreamPackets
2736/// via the return value of the CaptureAt method. If an AudioCapturer instance
2737/// has data to capture, but no place to put it (because there are no more
2738/// pending regions to fill), the next payload generated will indicate that their
2739/// has been an overflow by setting the Discontinuity flag on the next produced
2740/// StreamPacket. Synchronous mode may not be used in conjunction with
2741/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
2742/// the system still regions supplied by CaptureAt waiting to be filled.
2743///
2744/// If a user has supplied regions to be filled by the AudioCapturer instance in
2745/// the past, but wishes to reclaim those regions, they may do so using the
2746/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
2747/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
2748/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
2749/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
2750/// an OnEndOfStream event will be produced. While an AudioCapturer will never
2751/// overwrite any region of the payload buffer after a completed region is
2752/// returned, it may overwrite the unfilled portions of a partially filled
2753/// buffer which has been returned as a result of a DiscardAllPackets operation.
2754///
2755/// **Asynchronous mode**
2756///
2757/// While running in 'async' mode, clients do not need to explicitly supply
2758/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
2759/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
2760/// callback interface and the number of frames to capture per-callback. Once
2761/// running in async mode, the AudioCapturer instance will identify which
2762/// payload buffer regions to capture into, capture the specified number of
2763/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
2764/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
2765/// 'sync' mode using the StopAsyncCapture method.
2766///
2767/// It is considered an error to attempt any of the following operations.
2768///
2769/// + To attempt to enter 'async' capture mode when no payload buffer has been
2770///   established.
2771/// + To specify a number of frames to capture per payload which does not permit
2772///   at least two contiguous capture payloads to exist in the established
2773///   shared payload buffer simultaneously.
2774/// + To send a region to capture into using the CaptureAt method while the
2775///   AudioCapturer instance is running in 'async' mode.
2776/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
2777///   running in 'async' mode.
2778/// + To attempt to re-start 'async' mode capturing without having first
2779///   stopped.
2780/// + To attempt any operation except for SetGain while in the process of
2781///   stopping.
2782///
2783/// **Synchronizing with a StopAsyncCapture operation**
2784///
2785/// Stopping asynchronous capture mode and returning to synchronous capture mode
2786/// is an operation which takes time. Aside from SetGain, users may not call any
2787/// other methods on the AudioCapturer interface after calling StopAsyncCapture
2788/// (including calling StopAsyncCapture again) until after the stop operation has
2789/// completed. Because of this, it is important for users to be able to
2790/// synchronize with the stop operation. Two mechanisms are provided for doing
2791/// so.
2792///
2793/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
2794/// callback has been called, they can be certain that stop operation is complete
2795/// and that the AudioCapturer instance has returned to synchronous operation
2796/// mode.
2797///
2798/// The second way to determine that a stop operation has completed is to use the
2799/// flags on the packets which get delivered via the user-supplied
2800/// AudioCapturerCallback interface after calling StopAsyncCapture. When
2801/// asked to stop, any partially filled packet will be returned to the user, and
2802/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
2803/// set on it to indicate that this is the final frame in the sequence. If
2804/// there is no partially filled packet to return, the AudioCapturer will
2805/// synthesize an empty packet with no timestamp, and offset/length set to zero,
2806/// in order to deliver a packet with the end-of-stream flag set on it. Once
2807/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
2808/// has finished the stop operation and returned to synchronous operating mode.
2809///
2810/// **Timing and Overflows**
2811///
2812/// All media packets produced by an AudioCapturer instance will have their PTS
2813/// field filled out with the capture time of the audio expressed as a timestamp
2814/// given by the reference clock timeline. Note: this timestamp is actually a
2815/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
2816/// PTS) and is meant to represent the underlying system's best estimate of the
2817/// capture time of the first frame of audio, including all outboard and hardware
2818/// introduced buffering delay. As a result, all timestamps produced by an
2819/// AudioCapturer should be expected to be in the past relative to 'now' on the
2820/// stream's reference clock timeline.
2821///
2822/// The one exception to the "everything has an explicit timestamp" rule is when
2823/// discarding submitted regions while operating in synchronous mode. Discarded
2824/// packets have no data in them, but FIDL demands that all pending
2825/// method-return-value callbacks be executed. Because of this, the regions will
2826/// be returned to the user, but their timestamps will be set to
2827/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
2828/// partially filled payload will have a valid timestamp, but a payload size
2829/// smaller than originally requested. The final discarded payload (if there
2830/// were any to discard) will be followed by an OnEndOfStream event.
2831///
2832/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
2833/// the first frame of audio contained in the second packet was captured exactly
2834/// one nominal frame time after the final frame of audio in the first packet.
2835/// If this relationship does not hold, the second StreamPacket will have the
2836/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
2837///
2838/// Even though explicit timestamps are provided on every StreamPacket produced,
2839/// users who have very precise timing requirements are encouraged to always
2840/// reason about time by counting frames delivered since the last discontinuity,
2841/// rather than simply using the raw capture timestamps. This is because the
2842/// explicit timestamps written on continuous packets may have a small amount of
2843/// rounding error based on whether or not the units of the capture timeline
2844/// reference clock are divisible by the chosen audio frame rate.
2845///
2846/// Users should always expect the first StreamPacket produced by an
2847/// AudioCapturer to have the discontinuous flag set on it (as there is no
2848/// previous packet to be continuous with). Similarly, the first StreamPacket
2849/// after a DiscardAllPackets or a Stop/Start cycle will always be
2850/// discontinuous. After that, there are only two reasons that a StreamPacket
2851/// will ever be discontinuous:
2852///
2853/// 1. The user is operating in synchronous mode and does not supply regions to
2854///    be filled quickly enough. If the next continuous frame of data has not
2855///    been captured by the time it needs to be purged from the source buffers,
2856///    an overflow has occurred and the AudioCapturer will flag the next captured
2857///    region as discontinuous.
2858/// 2. The user is operating in asynchronous mode and some internal error
2859///    prevents the AudioCapturer instance from capturing the next frame of audio
2860///    in a continuous fashion. This might be high system load or a hardware
2861///    error, but in general it is something which should never normally happen.
2862///    In practice, however, if it does, the next produced packet will be flagged
2863///    as being discontinuous.
2864///
2865/// **Synchronous vs. Asynchronous Trade-offs**
2866///
2867/// The choice of operating in synchronous vs. asynchronous mode is up to the
2868/// user, and depending on the user's requirements, there are some advantages and
2869/// disadvantages to each choice.
2870///
2871/// Synchronous mode requires only a single Zircon channel under the hood and can
2872/// achieve some small savings because of this. In addition, the user has
2873/// complete control over the buffer management. Users specify exactly where
2874/// audio will be captured to and in what order. Because of this, if users do
2875/// not need to always be capturing, it is simple to stop and restart the capture
2876/// later (just by ceasing to supply packets, then resuming later on). Payloads
2877/// do not need to be uniform in size either, clients may specify payloads of
2878/// whatever granularity is appropriate.
2879///
2880/// The primary downside of operating in synchronous mode is that two messages
2881/// will need to be sent for every packet to be captured. One to inform the
2882/// AudioCapturer of the instance to capture into, and one to inform the user
2883/// that the packet has been captured. This may end up increasing overhead and
2884/// potentially complicating client designs.
2885///
2886/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
2887/// however, when operating in 'async' mode, AudioCapturer instances have no way
2888/// of knowing if a user is processing the StreamPackets being sent in a timely
2889/// fashion, and no way of automatically detecting an overflow condition. Users
2890/// of 'async' mode should be careful to use a buffer large enough to ensure that
2891/// they will be able to process their data before an AudioCapturer will be
2892/// forced to overwrite it.
2893#[derive(Debug)]
2894pub enum AudioCapturerRequest {
2895    /// Adds a payload buffer to the current buffer set associated with the
2896    /// connection. A `StreamPacket` struct reference a payload buffer in the
2897    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2898    ///
2899    /// A buffer with ID `id` must not be in the current set when this method is
2900    /// invoked, otherwise the service will close the connection.
2901    AddPayloadBuffer {
2902        id: u32,
2903        payload_buffer: fdomain_client::Vmo,
2904        control_handle: AudioCapturerControlHandle,
2905    },
2906    /// Removes a payload buffer from the current buffer set associated with the
2907    /// connection.
2908    ///
2909    /// A buffer with ID `id` must exist in the current set when this method is
2910    /// invoked, otherwise the service will will close the connection.
2911    RemovePayloadBuffer {
2912        id: u32,
2913        control_handle: AudioCapturerControlHandle,
2914    },
2915    /// Releases payload memory associated with a packet previously delivered
2916    /// via `OnPacketProduced`.
2917    ReleasePacket {
2918        packet: StreamPacket,
2919        control_handle: AudioCapturerControlHandle,
2920    },
2921    DiscardAllPackets {
2922        responder: AudioCapturerDiscardAllPacketsResponder,
2923    },
2924    DiscardAllPacketsNoReply {
2925        control_handle: AudioCapturerControlHandle,
2926    },
2927    /// Sets the stream type of the stream to be delivered. Causes the source
2928    /// material to be reformatted/resampled if needed in order to produce the
2929    /// requested stream type. Must be called before the payload buffer is
2930    /// established.
2931    SetPcmStreamType {
2932        stream_type: AudioStreamType,
2933        control_handle: AudioCapturerControlHandle,
2934    },
2935    /// Explicitly specifies a region of the shared payload buffer for the audio
2936    /// input to capture into.
2937    CaptureAt {
2938        payload_buffer_id: u32,
2939        payload_offset: u32,
2940        frames: u32,
2941        responder: AudioCapturerCaptureAtResponder,
2942    },
2943    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2944    /// packets of exactly 'frames_per_packet' number of frames each. The
2945    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2946    /// of produced packets.
2947    StartAsyncCapture {
2948        frames_per_packet: u32,
2949        control_handle: AudioCapturerControlHandle,
2950    },
2951    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2952    /// that may be used by the client if explicit synchronization is needed.
2953    StopAsyncCapture {
2954        responder: AudioCapturerStopAsyncCaptureResponder,
2955    },
2956    StopAsyncCaptureNoReply {
2957        control_handle: AudioCapturerControlHandle,
2958    },
2959    /// Binds to the gain control for this AudioCapturer.
2960    BindGainControl {
2961        gain_control_request:
2962            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
2963        control_handle: AudioCapturerControlHandle,
2964    },
2965    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2966    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2967    GetReferenceClock {
2968        responder: AudioCapturerGetReferenceClockResponder,
2969    },
2970    /// Sets the reference clock that controls this capturer's playback rate. If the input
2971    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2972    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2973    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2974    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2975    ///
2976    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2977    /// added. It also cannot be called a second time (even before capture).
2978    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2979    /// diverge at some later time, they should create a clone of the monotonic clock, set
2980    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2981    SetReferenceClock {
2982        reference_clock: Option<fdomain_client::Clock>,
2983        control_handle: AudioCapturerControlHandle,
2984    },
2985    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2986    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2987    SetUsage {
2988        usage: AudioCaptureUsage,
2989        control_handle: AudioCapturerControlHandle,
2990    },
2991    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2992    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2993    SetUsage2 {
2994        usage: AudioCaptureUsage2,
2995        control_handle: AudioCapturerControlHandle,
2996    },
2997    /// Gets the currently configured stream type. Note: for an AudioCapturer
2998    /// which was just created and has not yet had its stream type explicitly
2999    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3000    /// was created -- of the source (input or looped-back output) to which the
3001    /// AudioCapturer is bound. Even if this matches the client's desired format,
3002    /// `SetPcmStreamType` must still be called.
3003    GetStreamType {
3004        responder: AudioCapturerGetStreamTypeResponder,
3005    },
3006    /// An interaction was received which does not match any known method.
3007    #[non_exhaustive]
3008    _UnknownMethod {
3009        /// Ordinal of the method that was called.
3010        ordinal: u64,
3011        control_handle: AudioCapturerControlHandle,
3012        method_type: fidl::MethodType,
3013    },
3014}
3015
3016impl AudioCapturerRequest {
3017    #[allow(irrefutable_let_patterns)]
3018    pub fn into_add_payload_buffer(
3019        self,
3020    ) -> Option<(u32, fdomain_client::Vmo, AudioCapturerControlHandle)> {
3021        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3022        {
3023            Some((id, payload_buffer, control_handle))
3024        } else {
3025            None
3026        }
3027    }
3028
3029    #[allow(irrefutable_let_patterns)]
3030    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3031        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3032            Some((id, control_handle))
3033        } else {
3034            None
3035        }
3036    }
3037
3038    #[allow(irrefutable_let_patterns)]
3039    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3040        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3041            Some((packet, control_handle))
3042        } else {
3043            None
3044        }
3045    }
3046
3047    #[allow(irrefutable_let_patterns)]
3048    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3049        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3050            Some((responder))
3051        } else {
3052            None
3053        }
3054    }
3055
3056    #[allow(irrefutable_let_patterns)]
3057    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3058        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3059            Some((control_handle))
3060        } else {
3061            None
3062        }
3063    }
3064
3065    #[allow(irrefutable_let_patterns)]
3066    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3067        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3068            Some((stream_type, control_handle))
3069        } else {
3070            None
3071        }
3072    }
3073
3074    #[allow(irrefutable_let_patterns)]
3075    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3076        if let AudioCapturerRequest::CaptureAt {
3077            payload_buffer_id,
3078            payload_offset,
3079            frames,
3080            responder,
3081        } = self
3082        {
3083            Some((payload_buffer_id, payload_offset, frames, responder))
3084        } else {
3085            None
3086        }
3087    }
3088
3089    #[allow(irrefutable_let_patterns)]
3090    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3091        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3092        {
3093            Some((frames_per_packet, control_handle))
3094        } else {
3095            None
3096        }
3097    }
3098
3099    #[allow(irrefutable_let_patterns)]
3100    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3101        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3102            Some((responder))
3103        } else {
3104            None
3105        }
3106    }
3107
3108    #[allow(irrefutable_let_patterns)]
3109    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3110        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3111            Some((control_handle))
3112        } else {
3113            None
3114        }
3115    }
3116
3117    #[allow(irrefutable_let_patterns)]
3118    pub fn into_bind_gain_control(
3119        self,
3120    ) -> Option<(
3121        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
3122        AudioCapturerControlHandle,
3123    )> {
3124        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3125        {
3126            Some((gain_control_request, control_handle))
3127        } else {
3128            None
3129        }
3130    }
3131
3132    #[allow(irrefutable_let_patterns)]
3133    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3134        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3135            Some((responder))
3136        } else {
3137            None
3138        }
3139    }
3140
3141    #[allow(irrefutable_let_patterns)]
3142    pub fn into_set_reference_clock(
3143        self,
3144    ) -> Option<(Option<fdomain_client::Clock>, AudioCapturerControlHandle)> {
3145        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3146            Some((reference_clock, control_handle))
3147        } else {
3148            None
3149        }
3150    }
3151
3152    #[allow(irrefutable_let_patterns)]
3153    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3154        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3155            Some((usage, control_handle))
3156        } else {
3157            None
3158        }
3159    }
3160
3161    #[allow(irrefutable_let_patterns)]
3162    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3163        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3164            Some((usage, control_handle))
3165        } else {
3166            None
3167        }
3168    }
3169
3170    #[allow(irrefutable_let_patterns)]
3171    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3172        if let AudioCapturerRequest::GetStreamType { responder } = self {
3173            Some((responder))
3174        } else {
3175            None
3176        }
3177    }
3178
3179    /// Name of the method defined in FIDL
3180    pub fn method_name(&self) -> &'static str {
3181        match *self {
3182            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3183            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3184            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3185            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3186            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3187            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3188            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3189            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3190            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3191            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3192            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3193            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3194            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3195            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3196            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3197            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3198            AudioCapturerRequest::_UnknownMethod {
3199                method_type: fidl::MethodType::OneWay, ..
3200            } => "unknown one-way method",
3201            AudioCapturerRequest::_UnknownMethod {
3202                method_type: fidl::MethodType::TwoWay, ..
3203            } => "unknown two-way method",
3204        }
3205    }
3206}
3207
3208#[derive(Debug, Clone)]
3209pub struct AudioCapturerControlHandle {
3210    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3211}
3212
3213impl fdomain_client::fidl::ControlHandle for AudioCapturerControlHandle {
3214    fn shutdown(&self) {
3215        self.inner.shutdown()
3216    }
3217
3218    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3219        self.inner.shutdown_with_epitaph(status)
3220    }
3221
3222    fn is_closed(&self) -> bool {
3223        self.inner.channel().is_closed()
3224    }
3225    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3226        self.inner.channel().on_closed()
3227    }
3228}
3229
3230impl AudioCapturerControlHandle {
3231    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3232        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3233            (packet,),
3234            0,
3235            0x6bbe69746a3c8bd9,
3236            fidl::encoding::DynamicFlags::empty(),
3237        )
3238    }
3239
3240    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3241        self.inner.send::<fidl::encoding::EmptyPayload>(
3242            (),
3243            0,
3244            0x550e69b41d03e2c2,
3245            fidl::encoding::DynamicFlags::empty(),
3246        )
3247    }
3248}
3249
3250#[must_use = "FIDL methods require a response to be sent"]
3251#[derive(Debug)]
3252pub struct AudioCapturerDiscardAllPacketsResponder {
3253    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3254    tx_id: u32,
3255}
3256
3257/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3258/// if the responder is dropped without sending a response, so that the client
3259/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3260impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3261    fn drop(&mut self) {
3262        self.control_handle.shutdown();
3263        // Safety: drops once, never accessed again
3264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3265    }
3266}
3267
3268impl fdomain_client::fidl::Responder for AudioCapturerDiscardAllPacketsResponder {
3269    type ControlHandle = AudioCapturerControlHandle;
3270
3271    fn control_handle(&self) -> &AudioCapturerControlHandle {
3272        &self.control_handle
3273    }
3274
3275    fn drop_without_shutdown(mut self) {
3276        // Safety: drops once, never accessed again due to mem::forget
3277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3278        // Prevent Drop from running (which would shut down the channel)
3279        std::mem::forget(self);
3280    }
3281}
3282
3283impl AudioCapturerDiscardAllPacketsResponder {
3284    /// Sends a response to the FIDL transaction.
3285    ///
3286    /// Sets the channel to shutdown if an error occurs.
3287    pub fn send(self) -> Result<(), fidl::Error> {
3288        let _result = self.send_raw();
3289        if _result.is_err() {
3290            self.control_handle.shutdown();
3291        }
3292        self.drop_without_shutdown();
3293        _result
3294    }
3295
3296    /// Similar to "send" but does not shutdown the channel if an error occurs.
3297    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3298        let _result = self.send_raw();
3299        self.drop_without_shutdown();
3300        _result
3301    }
3302
3303    fn send_raw(&self) -> Result<(), fidl::Error> {
3304        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3305            (),
3306            self.tx_id,
3307            0x27afd605e97b09d2,
3308            fidl::encoding::DynamicFlags::empty(),
3309        )
3310    }
3311}
3312
3313#[must_use = "FIDL methods require a response to be sent"]
3314#[derive(Debug)]
3315pub struct AudioCapturerCaptureAtResponder {
3316    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3317    tx_id: u32,
3318}
3319
3320/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3321/// if the responder is dropped without sending a response, so that the client
3322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3323impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3324    fn drop(&mut self) {
3325        self.control_handle.shutdown();
3326        // Safety: drops once, never accessed again
3327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3328    }
3329}
3330
3331impl fdomain_client::fidl::Responder for AudioCapturerCaptureAtResponder {
3332    type ControlHandle = AudioCapturerControlHandle;
3333
3334    fn control_handle(&self) -> &AudioCapturerControlHandle {
3335        &self.control_handle
3336    }
3337
3338    fn drop_without_shutdown(mut self) {
3339        // Safety: drops once, never accessed again due to mem::forget
3340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3341        // Prevent Drop from running (which would shut down the channel)
3342        std::mem::forget(self);
3343    }
3344}
3345
3346impl AudioCapturerCaptureAtResponder {
3347    /// Sends a response to the FIDL transaction.
3348    ///
3349    /// Sets the channel to shutdown if an error occurs.
3350    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3351        let _result = self.send_raw(captured_packet);
3352        if _result.is_err() {
3353            self.control_handle.shutdown();
3354        }
3355        self.drop_without_shutdown();
3356        _result
3357    }
3358
3359    /// Similar to "send" but does not shutdown the channel if an error occurs.
3360    pub fn send_no_shutdown_on_err(
3361        self,
3362        mut captured_packet: &StreamPacket,
3363    ) -> Result<(), fidl::Error> {
3364        let _result = self.send_raw(captured_packet);
3365        self.drop_without_shutdown();
3366        _result
3367    }
3368
3369    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3370        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3371            (captured_packet,),
3372            self.tx_id,
3373            0x784e25df72cea780,
3374            fidl::encoding::DynamicFlags::empty(),
3375        )
3376    }
3377}
3378
3379#[must_use = "FIDL methods require a response to be sent"]
3380#[derive(Debug)]
3381pub struct AudioCapturerStopAsyncCaptureResponder {
3382    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3383    tx_id: u32,
3384}
3385
3386/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3387/// if the responder is dropped without sending a response, so that the client
3388/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3389impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3390    fn drop(&mut self) {
3391        self.control_handle.shutdown();
3392        // Safety: drops once, never accessed again
3393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3394    }
3395}
3396
3397impl fdomain_client::fidl::Responder for AudioCapturerStopAsyncCaptureResponder {
3398    type ControlHandle = AudioCapturerControlHandle;
3399
3400    fn control_handle(&self) -> &AudioCapturerControlHandle {
3401        &self.control_handle
3402    }
3403
3404    fn drop_without_shutdown(mut self) {
3405        // Safety: drops once, never accessed again due to mem::forget
3406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3407        // Prevent Drop from running (which would shut down the channel)
3408        std::mem::forget(self);
3409    }
3410}
3411
3412impl AudioCapturerStopAsyncCaptureResponder {
3413    /// Sends a response to the FIDL transaction.
3414    ///
3415    /// Sets the channel to shutdown if an error occurs.
3416    pub fn send(self) -> Result<(), fidl::Error> {
3417        let _result = self.send_raw();
3418        if _result.is_err() {
3419            self.control_handle.shutdown();
3420        }
3421        self.drop_without_shutdown();
3422        _result
3423    }
3424
3425    /// Similar to "send" but does not shutdown the channel if an error occurs.
3426    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3427        let _result = self.send_raw();
3428        self.drop_without_shutdown();
3429        _result
3430    }
3431
3432    fn send_raw(&self) -> Result<(), fidl::Error> {
3433        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3434            (),
3435            self.tx_id,
3436            0x5bfc8790a8cef8cb,
3437            fidl::encoding::DynamicFlags::empty(),
3438        )
3439    }
3440}
3441
3442#[must_use = "FIDL methods require a response to be sent"]
3443#[derive(Debug)]
3444pub struct AudioCapturerGetReferenceClockResponder {
3445    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3446    tx_id: u32,
3447}
3448
3449/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3450/// if the responder is dropped without sending a response, so that the client
3451/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3452impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3453    fn drop(&mut self) {
3454        self.control_handle.shutdown();
3455        // Safety: drops once, never accessed again
3456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3457    }
3458}
3459
3460impl fdomain_client::fidl::Responder for AudioCapturerGetReferenceClockResponder {
3461    type ControlHandle = AudioCapturerControlHandle;
3462
3463    fn control_handle(&self) -> &AudioCapturerControlHandle {
3464        &self.control_handle
3465    }
3466
3467    fn drop_without_shutdown(mut self) {
3468        // Safety: drops once, never accessed again due to mem::forget
3469        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3470        // Prevent Drop from running (which would shut down the channel)
3471        std::mem::forget(self);
3472    }
3473}
3474
3475impl AudioCapturerGetReferenceClockResponder {
3476    /// Sends a response to the FIDL transaction.
3477    ///
3478    /// Sets the channel to shutdown if an error occurs.
3479    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3480        let _result = self.send_raw(reference_clock);
3481        if _result.is_err() {
3482            self.control_handle.shutdown();
3483        }
3484        self.drop_without_shutdown();
3485        _result
3486    }
3487
3488    /// Similar to "send" but does not shutdown the channel if an error occurs.
3489    pub fn send_no_shutdown_on_err(
3490        self,
3491        mut reference_clock: fdomain_client::Clock,
3492    ) -> Result<(), fidl::Error> {
3493        let _result = self.send_raw(reference_clock);
3494        self.drop_without_shutdown();
3495        _result
3496    }
3497
3498    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3499        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3500            (reference_clock,),
3501            self.tx_id,
3502            0x50d037aa5a4b4d71,
3503            fidl::encoding::DynamicFlags::empty(),
3504        )
3505    }
3506}
3507
3508#[must_use = "FIDL methods require a response to be sent"]
3509#[derive(Debug)]
3510pub struct AudioCapturerGetStreamTypeResponder {
3511    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3512    tx_id: u32,
3513}
3514
3515/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3516/// if the responder is dropped without sending a response, so that the client
3517/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3518impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3519    fn drop(&mut self) {
3520        self.control_handle.shutdown();
3521        // Safety: drops once, never accessed again
3522        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3523    }
3524}
3525
3526impl fdomain_client::fidl::Responder for AudioCapturerGetStreamTypeResponder {
3527    type ControlHandle = AudioCapturerControlHandle;
3528
3529    fn control_handle(&self) -> &AudioCapturerControlHandle {
3530        &self.control_handle
3531    }
3532
3533    fn drop_without_shutdown(mut self) {
3534        // Safety: drops once, never accessed again due to mem::forget
3535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3536        // Prevent Drop from running (which would shut down the channel)
3537        std::mem::forget(self);
3538    }
3539}
3540
3541impl AudioCapturerGetStreamTypeResponder {
3542    /// Sends a response to the FIDL transaction.
3543    ///
3544    /// Sets the channel to shutdown if an error occurs.
3545    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3546        let _result = self.send_raw(stream_type);
3547        if _result.is_err() {
3548            self.control_handle.shutdown();
3549        }
3550        self.drop_without_shutdown();
3551        _result
3552    }
3553
3554    /// Similar to "send" but does not shutdown the channel if an error occurs.
3555    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3556        let _result = self.send_raw(stream_type);
3557        self.drop_without_shutdown();
3558        _result
3559    }
3560
3561    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3562        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3563            (stream_type,),
3564            self.tx_id,
3565            0x5dcaaa670b433088,
3566            fidl::encoding::DynamicFlags::empty(),
3567        )
3568    }
3569}
3570
3571#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3572pub struct AudioConsumerMarker;
3573
3574impl fdomain_client::fidl::ProtocolMarker for AudioConsumerMarker {
3575    type Proxy = AudioConsumerProxy;
3576    type RequestStream = AudioConsumerRequestStream;
3577
3578    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3579}
3580
3581pub trait AudioConsumerProxyInterface: Send + Sync {
3582    fn r#create_stream_sink(
3583        &self,
3584        buffers: Vec<fdomain_client::Vmo>,
3585        stream_type: &AudioStreamType,
3586        compression: Option<&Compression>,
3587        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3588    ) -> Result<(), fidl::Error>;
3589    fn r#start(
3590        &self,
3591        flags: AudioConsumerStartFlags,
3592        reference_time: i64,
3593        media_time: i64,
3594    ) -> Result<(), fidl::Error>;
3595    fn r#stop(&self) -> Result<(), fidl::Error>;
3596    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3597    fn r#bind_volume_control(
3598        &self,
3599        volume_control_request: fdomain_client::fidl::ServerEnd<
3600            fdomain_fuchsia_media_audio::VolumeControlMarker,
3601        >,
3602    ) -> Result<(), fidl::Error>;
3603    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3604        + Send;
3605    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3606}
3607
3608#[derive(Debug, Clone)]
3609pub struct AudioConsumerProxy {
3610    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3611}
3612
3613impl fdomain_client::fidl::Proxy for AudioConsumerProxy {
3614    type Protocol = AudioConsumerMarker;
3615
3616    fn from_channel(inner: fdomain_client::Channel) -> Self {
3617        Self::new(inner)
3618    }
3619
3620    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3621        self.client.into_channel().map_err(|client| Self { client })
3622    }
3623
3624    fn as_channel(&self) -> &fdomain_client::Channel {
3625        self.client.as_channel()
3626    }
3627}
3628
3629impl AudioConsumerProxy {
3630    /// Create a new Proxy for fuchsia.media/AudioConsumer.
3631    pub fn new(channel: fdomain_client::Channel) -> Self {
3632        let protocol_name =
3633            <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3634        Self { client: fidl::client::Client::new(channel, protocol_name) }
3635    }
3636
3637    /// Get a Stream of events from the remote end of the protocol.
3638    ///
3639    /// # Panics
3640    ///
3641    /// Panics if the event stream was already taken.
3642    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
3643        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
3644    }
3645
3646    /// Creates a `StreamSink` for the consumer with the indicated properties.
3647    ///
3648    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3649    /// sequentially rather than concurrently. The first stream sink that's created using this
3650    /// method is used as the sole source of packets incoming to the logical consumer until that
3651    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3652    /// the second stream sink is used, and so on.
3653    ///
3654    /// If an unsupported compression type is supplied, the
3655    /// `stream_sink_request` request will be closed with an epitaph value of
3656    /// `ZX_ERR_INVALID_ARGS`.
3657    pub fn r#create_stream_sink(
3658        &self,
3659        mut buffers: Vec<fdomain_client::Vmo>,
3660        mut stream_type: &AudioStreamType,
3661        mut compression: Option<&Compression>,
3662        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3663    ) -> Result<(), fidl::Error> {
3664        AudioConsumerProxyInterface::r#create_stream_sink(
3665            self,
3666            buffers,
3667            stream_type,
3668            compression,
3669            stream_sink_request,
3670        )
3671    }
3672
3673    /// Starts rendering as indicated by `flags`.
3674    ///
3675    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
3676    /// Typically, this is the timestamp of the first packet that will be
3677    /// rendered. If packets will be supplied with no timestamps, this value
3678    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
3679    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
3680    ///     1. When starting for the first time, the default media time is the
3681    ///        timestamp on the first packet sent to the stream sink.
3682    ///     2. When resuming after stop, the default media time is the media
3683    ///        time at which the stream stopped.
3684    ///
3685    /// `reference_time` is the monotonic system time at which rendering should
3686    /// be started. For supply-driven sources, this must be the time at which
3687    /// the first packet was (or will be) sent plus a lead time, which must be
3688    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
3689    /// sources, the client must ensure that the lead time requirement is met at
3690    /// the start time.  Passing the default value of 0 for `reference_time`
3691    /// causes the consumer to choose a start time based on the availability of
3692    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
3693    /// specified.
3694    ///
3695    /// The actual start time will be reflected in the updated status.
3696    pub fn r#start(
3697        &self,
3698        mut flags: AudioConsumerStartFlags,
3699        mut reference_time: i64,
3700        mut media_time: i64,
3701    ) -> Result<(), fidl::Error> {
3702        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
3703    }
3704
3705    /// Stops rendering as soon as possible after this method is called. The actual stop time will
3706    /// be reflected in the updated status.
3707    pub fn r#stop(&self) -> Result<(), fidl::Error> {
3708        AudioConsumerProxyInterface::r#stop(self)
3709    }
3710
3711    /// Requests to change the playback rate of the renderer. 1.0 means normal
3712    /// playback. Negative rates are not supported. The new rate will be
3713    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
3714    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3715        AudioConsumerProxyInterface::r#set_rate(self, rate)
3716    }
3717
3718    /// Binds to this `AudioConsumer` volume control for control and notifications.
3719    pub fn r#bind_volume_control(
3720        &self,
3721        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3722            fdomain_fuchsia_media_audio::VolumeControlMarker,
3723        >,
3724    ) -> Result<(), fidl::Error> {
3725        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
3726    }
3727
3728    /// Gets the current status of the consumer using the long get pattern. The consumer responds
3729    /// to this method when the status changes - initially with respect to the initial status value
3730    /// and thereafter with respect to the previously-reported status value.
3731    pub fn r#watch_status(
3732        &self,
3733    ) -> fidl::client::QueryResponseFut<
3734        AudioConsumerStatus,
3735        fdomain_client::fidl::FDomainResourceDialect,
3736    > {
3737        AudioConsumerProxyInterface::r#watch_status(self)
3738    }
3739}
3740
3741impl AudioConsumerProxyInterface for AudioConsumerProxy {
3742    fn r#create_stream_sink(
3743        &self,
3744        mut buffers: Vec<fdomain_client::Vmo>,
3745        mut stream_type: &AudioStreamType,
3746        mut compression: Option<&Compression>,
3747        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3748    ) -> Result<(), fidl::Error> {
3749        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
3750            (buffers.as_mut(), stream_type, compression, stream_sink_request),
3751            0x525b3b97fdf7d884,
3752            fidl::encoding::DynamicFlags::empty(),
3753        )
3754    }
3755
3756    fn r#start(
3757        &self,
3758        mut flags: AudioConsumerStartFlags,
3759        mut reference_time: i64,
3760        mut media_time: i64,
3761    ) -> Result<(), fidl::Error> {
3762        self.client.send::<AudioConsumerStartRequest>(
3763            (flags, reference_time, media_time),
3764            0x4fdbd44b3f2a3a3c,
3765            fidl::encoding::DynamicFlags::empty(),
3766        )
3767    }
3768
3769    fn r#stop(&self) -> Result<(), fidl::Error> {
3770        self.client.send::<fidl::encoding::EmptyPayload>(
3771            (),
3772            0x3d46c3741686c40d,
3773            fidl::encoding::DynamicFlags::empty(),
3774        )
3775    }
3776
3777    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3778        self.client.send::<AudioConsumerSetRateRequest>(
3779            (rate,),
3780            0x45342b73968bfafe,
3781            fidl::encoding::DynamicFlags::empty(),
3782        )
3783    }
3784
3785    fn r#bind_volume_control(
3786        &self,
3787        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3788            fdomain_fuchsia_media_audio::VolumeControlMarker,
3789        >,
3790    ) -> Result<(), fidl::Error> {
3791        self.client.send::<AudioConsumerBindVolumeControlRequest>(
3792            (volume_control_request,),
3793            0x6f1b01fd887f5748,
3794            fidl::encoding::DynamicFlags::empty(),
3795        )
3796    }
3797
3798    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
3799        AudioConsumerStatus,
3800        fdomain_client::fidl::FDomainResourceDialect,
3801    >;
3802    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
3803        fn _decode(
3804            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3805        ) -> Result<AudioConsumerStatus, fidl::Error> {
3806            let _response = fidl::client::decode_transaction_body::<
3807                AudioConsumerWatchStatusResponse,
3808                fdomain_client::fidl::FDomainResourceDialect,
3809                0x35cf702c721e2cc6,
3810            >(_buf?)?;
3811            Ok(_response.status)
3812        }
3813        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
3814            (),
3815            0x35cf702c721e2cc6,
3816            fidl::encoding::DynamicFlags::empty(),
3817            _decode,
3818        )
3819    }
3820}
3821
3822pub struct AudioConsumerEventStream {
3823    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3824}
3825
3826impl std::marker::Unpin for AudioConsumerEventStream {}
3827
3828impl futures::stream::FusedStream for AudioConsumerEventStream {
3829    fn is_terminated(&self) -> bool {
3830        self.event_receiver.is_terminated()
3831    }
3832}
3833
3834impl futures::Stream for AudioConsumerEventStream {
3835    type Item = Result<AudioConsumerEvent, fidl::Error>;
3836
3837    fn poll_next(
3838        mut self: std::pin::Pin<&mut Self>,
3839        cx: &mut std::task::Context<'_>,
3840    ) -> std::task::Poll<Option<Self::Item>> {
3841        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3842            &mut self.event_receiver,
3843            cx
3844        )?) {
3845            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
3846            None => std::task::Poll::Ready(None),
3847        }
3848    }
3849}
3850
3851#[derive(Debug)]
3852pub enum AudioConsumerEvent {
3853    OnEndOfStream {},
3854}
3855
3856impl AudioConsumerEvent {
3857    #[allow(irrefutable_let_patterns)]
3858    pub fn into_on_end_of_stream(self) -> Option<()> {
3859        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
3860    }
3861
3862    /// Decodes a message buffer as a [`AudioConsumerEvent`].
3863    fn decode(
3864        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3865    ) -> Result<AudioConsumerEvent, fidl::Error> {
3866        let (bytes, _handles) = buf.split_mut();
3867        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3868        debug_assert_eq!(tx_header.tx_id, 0);
3869        match tx_header.ordinal {
3870            0x53a64e6d0e8f8a20 => {
3871                let mut out = fidl::new_empty!(
3872                    fidl::encoding::EmptyPayload,
3873                    fdomain_client::fidl::FDomainResourceDialect
3874                );
3875                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3876                Ok((AudioConsumerEvent::OnEndOfStream {}))
3877            }
3878            _ => Err(fidl::Error::UnknownOrdinal {
3879                ordinal: tx_header.ordinal,
3880                protocol_name:
3881                    <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3882            }),
3883        }
3884    }
3885}
3886
3887/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
3888pub struct AudioConsumerRequestStream {
3889    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3890    is_terminated: bool,
3891}
3892
3893impl std::marker::Unpin for AudioConsumerRequestStream {}
3894
3895impl futures::stream::FusedStream for AudioConsumerRequestStream {
3896    fn is_terminated(&self) -> bool {
3897        self.is_terminated
3898    }
3899}
3900
3901impl fdomain_client::fidl::RequestStream for AudioConsumerRequestStream {
3902    type Protocol = AudioConsumerMarker;
3903    type ControlHandle = AudioConsumerControlHandle;
3904
3905    fn from_channel(channel: fdomain_client::Channel) -> Self {
3906        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3907    }
3908
3909    fn control_handle(&self) -> Self::ControlHandle {
3910        AudioConsumerControlHandle { inner: self.inner.clone() }
3911    }
3912
3913    fn into_inner(
3914        self,
3915    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3916    {
3917        (self.inner, self.is_terminated)
3918    }
3919
3920    fn from_inner(
3921        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3922        is_terminated: bool,
3923    ) -> Self {
3924        Self { inner, is_terminated }
3925    }
3926}
3927
3928impl futures::Stream for AudioConsumerRequestStream {
3929    type Item = Result<AudioConsumerRequest, fidl::Error>;
3930
3931    fn poll_next(
3932        mut self: std::pin::Pin<&mut Self>,
3933        cx: &mut std::task::Context<'_>,
3934    ) -> std::task::Poll<Option<Self::Item>> {
3935        let this = &mut *self;
3936        if this.inner.check_shutdown(cx) {
3937            this.is_terminated = true;
3938            return std::task::Poll::Ready(None);
3939        }
3940        if this.is_terminated {
3941            panic!("polled AudioConsumerRequestStream after completion");
3942        }
3943        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3944            |bytes, handles| {
3945                match this.inner.channel().read_etc(cx, bytes, handles) {
3946                    std::task::Poll::Ready(Ok(())) => {}
3947                    std::task::Poll::Pending => return std::task::Poll::Pending,
3948                    std::task::Poll::Ready(Err(None)) => {
3949                        this.is_terminated = true;
3950                        return std::task::Poll::Ready(None);
3951                    }
3952                    std::task::Poll::Ready(Err(Some(e))) => {
3953                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3954                            e.into(),
3955                        ))));
3956                    }
3957                }
3958
3959                // A message has been received from the channel
3960                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3961
3962                std::task::Poll::Ready(Some(match header.ordinal {
3963                0x525b3b97fdf7d884 => {
3964                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3965                    let mut req = fidl::new_empty!(AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect);
3966                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
3967                    let control_handle = AudioConsumerControlHandle {
3968                        inner: this.inner.clone(),
3969                    };
3970                    Ok(AudioConsumerRequest::CreateStreamSink {buffers: req.buffers,
3971stream_type: req.stream_type,
3972compression: req.compression,
3973stream_sink_request: req.stream_sink_request,
3974
3975                        control_handle,
3976                    })
3977                }
3978                0x4fdbd44b3f2a3a3c => {
3979                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3980                    let mut req = fidl::new_empty!(AudioConsumerStartRequest, fdomain_client::fidl::FDomainResourceDialect);
3981                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
3982                    let control_handle = AudioConsumerControlHandle {
3983                        inner: this.inner.clone(),
3984                    };
3985                    Ok(AudioConsumerRequest::Start {flags: req.flags,
3986reference_time: req.reference_time,
3987media_time: req.media_time,
3988
3989                        control_handle,
3990                    })
3991                }
3992                0x3d46c3741686c40d => {
3993                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3994                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3995                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3996                    let control_handle = AudioConsumerControlHandle {
3997                        inner: this.inner.clone(),
3998                    };
3999                    Ok(AudioConsumerRequest::Stop {
4000                        control_handle,
4001                    })
4002                }
4003                0x45342b73968bfafe => {
4004                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4005                    let mut req = fidl::new_empty!(AudioConsumerSetRateRequest, fdomain_client::fidl::FDomainResourceDialect);
4006                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4007                    let control_handle = AudioConsumerControlHandle {
4008                        inner: this.inner.clone(),
4009                    };
4010                    Ok(AudioConsumerRequest::SetRate {rate: req.rate,
4011
4012                        control_handle,
4013                    })
4014                }
4015                0x6f1b01fd887f5748 => {
4016                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4017                    let mut req = fidl::new_empty!(AudioConsumerBindVolumeControlRequest, fdomain_client::fidl::FDomainResourceDialect);
4018                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4019                    let control_handle = AudioConsumerControlHandle {
4020                        inner: this.inner.clone(),
4021                    };
4022                    Ok(AudioConsumerRequest::BindVolumeControl {volume_control_request: req.volume_control_request,
4023
4024                        control_handle,
4025                    })
4026                }
4027                0x35cf702c721e2cc6 => {
4028                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4029                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4030                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4031                    let control_handle = AudioConsumerControlHandle {
4032                        inner: this.inner.clone(),
4033                    };
4034                    Ok(AudioConsumerRequest::WatchStatus {
4035                        responder: AudioConsumerWatchStatusResponder {
4036                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4037                            tx_id: header.tx_id,
4038                        },
4039                    })
4040                }
4041                _ => Err(fidl::Error::UnknownOrdinal {
4042                    ordinal: header.ordinal,
4043                    protocol_name: <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4044                }),
4045            }))
4046            },
4047        )
4048    }
4049}
4050
4051/// Interface for playing and controlling audio.
4052#[derive(Debug)]
4053pub enum AudioConsumerRequest {
4054    /// Creates a `StreamSink` for the consumer with the indicated properties.
4055    ///
4056    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4057    /// sequentially rather than concurrently. The first stream sink that's created using this
4058    /// method is used as the sole source of packets incoming to the logical consumer until that
4059    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4060    /// the second stream sink is used, and so on.
4061    ///
4062    /// If an unsupported compression type is supplied, the
4063    /// `stream_sink_request` request will be closed with an epitaph value of
4064    /// `ZX_ERR_INVALID_ARGS`.
4065    CreateStreamSink {
4066        buffers: Vec<fdomain_client::Vmo>,
4067        stream_type: AudioStreamType,
4068        compression: Option<Box<Compression>>,
4069        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
4070        control_handle: AudioConsumerControlHandle,
4071    },
4072    /// Starts rendering as indicated by `flags`.
4073    ///
4074    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4075    /// Typically, this is the timestamp of the first packet that will be
4076    /// rendered. If packets will be supplied with no timestamps, this value
4077    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4078    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4079    ///     1. When starting for the first time, the default media time is the
4080    ///        timestamp on the first packet sent to the stream sink.
4081    ///     2. When resuming after stop, the default media time is the media
4082    ///        time at which the stream stopped.
4083    ///
4084    /// `reference_time` is the monotonic system time at which rendering should
4085    /// be started. For supply-driven sources, this must be the time at which
4086    /// the first packet was (or will be) sent plus a lead time, which must be
4087    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4088    /// sources, the client must ensure that the lead time requirement is met at
4089    /// the start time.  Passing the default value of 0 for `reference_time`
4090    /// causes the consumer to choose a start time based on the availability of
4091    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4092    /// specified.
4093    ///
4094    /// The actual start time will be reflected in the updated status.
4095    Start {
4096        flags: AudioConsumerStartFlags,
4097        reference_time: i64,
4098        media_time: i64,
4099        control_handle: AudioConsumerControlHandle,
4100    },
4101    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4102    /// be reflected in the updated status.
4103    Stop { control_handle: AudioConsumerControlHandle },
4104    /// Requests to change the playback rate of the renderer. 1.0 means normal
4105    /// playback. Negative rates are not supported. The new rate will be
4106    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4107    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4108    /// Binds to this `AudioConsumer` volume control for control and notifications.
4109    BindVolumeControl {
4110        volume_control_request:
4111            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
4112        control_handle: AudioConsumerControlHandle,
4113    },
4114    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4115    /// to this method when the status changes - initially with respect to the initial status value
4116    /// and thereafter with respect to the previously-reported status value.
4117    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4118}
4119
4120impl AudioConsumerRequest {
4121    #[allow(irrefutable_let_patterns)]
4122    pub fn into_create_stream_sink(
4123        self,
4124    ) -> Option<(
4125        Vec<fdomain_client::Vmo>,
4126        AudioStreamType,
4127        Option<Box<Compression>>,
4128        fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
4129        AudioConsumerControlHandle,
4130    )> {
4131        if let AudioConsumerRequest::CreateStreamSink {
4132            buffers,
4133            stream_type,
4134            compression,
4135            stream_sink_request,
4136            control_handle,
4137        } = self
4138        {
4139            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4140        } else {
4141            None
4142        }
4143    }
4144
4145    #[allow(irrefutable_let_patterns)]
4146    pub fn into_start(
4147        self,
4148    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4149        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4150            self
4151        {
4152            Some((flags, reference_time, media_time, control_handle))
4153        } else {
4154            None
4155        }
4156    }
4157
4158    #[allow(irrefutable_let_patterns)]
4159    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4160        if let AudioConsumerRequest::Stop { control_handle } = self {
4161            Some((control_handle))
4162        } else {
4163            None
4164        }
4165    }
4166
4167    #[allow(irrefutable_let_patterns)]
4168    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4169        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4170            Some((rate, control_handle))
4171        } else {
4172            None
4173        }
4174    }
4175
4176    #[allow(irrefutable_let_patterns)]
4177    pub fn into_bind_volume_control(
4178        self,
4179    ) -> Option<(
4180        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
4181        AudioConsumerControlHandle,
4182    )> {
4183        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4184            self
4185        {
4186            Some((volume_control_request, control_handle))
4187        } else {
4188            None
4189        }
4190    }
4191
4192    #[allow(irrefutable_let_patterns)]
4193    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4194        if let AudioConsumerRequest::WatchStatus { responder } = self {
4195            Some((responder))
4196        } else {
4197            None
4198        }
4199    }
4200
4201    /// Name of the method defined in FIDL
4202    pub fn method_name(&self) -> &'static str {
4203        match *self {
4204            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4205            AudioConsumerRequest::Start { .. } => "start",
4206            AudioConsumerRequest::Stop { .. } => "stop",
4207            AudioConsumerRequest::SetRate { .. } => "set_rate",
4208            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4209            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4210        }
4211    }
4212}
4213
4214#[derive(Debug, Clone)]
4215pub struct AudioConsumerControlHandle {
4216    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4217}
4218
4219impl fdomain_client::fidl::ControlHandle for AudioConsumerControlHandle {
4220    fn shutdown(&self) {
4221        self.inner.shutdown()
4222    }
4223
4224    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4225        self.inner.shutdown_with_epitaph(status)
4226    }
4227
4228    fn is_closed(&self) -> bool {
4229        self.inner.channel().is_closed()
4230    }
4231    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4232        self.inner.channel().on_closed()
4233    }
4234}
4235
4236impl AudioConsumerControlHandle {
4237    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4238        self.inner.send::<fidl::encoding::EmptyPayload>(
4239            (),
4240            0,
4241            0x53a64e6d0e8f8a20,
4242            fidl::encoding::DynamicFlags::empty(),
4243        )
4244    }
4245}
4246
4247#[must_use = "FIDL methods require a response to be sent"]
4248#[derive(Debug)]
4249pub struct AudioConsumerWatchStatusResponder {
4250    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4251    tx_id: u32,
4252}
4253
4254/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4255/// if the responder is dropped without sending a response, so that the client
4256/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4257impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4258    fn drop(&mut self) {
4259        self.control_handle.shutdown();
4260        // Safety: drops once, never accessed again
4261        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4262    }
4263}
4264
4265impl fdomain_client::fidl::Responder for AudioConsumerWatchStatusResponder {
4266    type ControlHandle = AudioConsumerControlHandle;
4267
4268    fn control_handle(&self) -> &AudioConsumerControlHandle {
4269        &self.control_handle
4270    }
4271
4272    fn drop_without_shutdown(mut self) {
4273        // Safety: drops once, never accessed again due to mem::forget
4274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4275        // Prevent Drop from running (which would shut down the channel)
4276        std::mem::forget(self);
4277    }
4278}
4279
4280impl AudioConsumerWatchStatusResponder {
4281    /// Sends a response to the FIDL transaction.
4282    ///
4283    /// Sets the channel to shutdown if an error occurs.
4284    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4285        let _result = self.send_raw(status);
4286        if _result.is_err() {
4287            self.control_handle.shutdown();
4288        }
4289        self.drop_without_shutdown();
4290        _result
4291    }
4292
4293    /// Similar to "send" but does not shutdown the channel if an error occurs.
4294    pub fn send_no_shutdown_on_err(
4295        self,
4296        mut status: &AudioConsumerStatus,
4297    ) -> Result<(), fidl::Error> {
4298        let _result = self.send_raw(status);
4299        self.drop_without_shutdown();
4300        _result
4301    }
4302
4303    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4304        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4305            (status,),
4306            self.tx_id,
4307            0x35cf702c721e2cc6,
4308            fidl::encoding::DynamicFlags::empty(),
4309        )
4310    }
4311}
4312
4313#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4314pub struct AudioCoreMarker;
4315
4316impl fdomain_client::fidl::ProtocolMarker for AudioCoreMarker {
4317    type Proxy = AudioCoreProxy;
4318    type RequestStream = AudioCoreRequestStream;
4319
4320    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4321}
4322impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCoreMarker {}
4323
4324pub trait AudioCoreProxyInterface: Send + Sync {
4325    fn r#create_audio_renderer(
4326        &self,
4327        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4328    ) -> Result<(), fidl::Error>;
4329    fn r#create_audio_capturer_with_configuration(
4330        &self,
4331        stream_type: &AudioStreamType,
4332        configuration: &AudioCapturerConfiguration,
4333        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4334    ) -> Result<(), fidl::Error>;
4335    fn r#create_audio_capturer(
4336        &self,
4337        loopback: bool,
4338        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4339    ) -> Result<(), fidl::Error>;
4340    fn r#set_render_usage_gain(
4341        &self,
4342        usage: AudioRenderUsage,
4343        gain_db: f32,
4344    ) -> Result<(), fidl::Error>;
4345    fn r#set_render_usage_gain2(
4346        &self,
4347        usage: AudioRenderUsage2,
4348        gain_db: f32,
4349    ) -> Result<(), fidl::Error>;
4350    fn r#set_capture_usage_gain(
4351        &self,
4352        usage: AudioCaptureUsage,
4353        gain_db: f32,
4354    ) -> Result<(), fidl::Error>;
4355    fn r#set_capture_usage_gain2(
4356        &self,
4357        usage: AudioCaptureUsage2,
4358        gain_db: f32,
4359    ) -> Result<(), fidl::Error>;
4360    fn r#bind_usage_volume_control(
4361        &self,
4362        usage: &Usage,
4363        volume_control: fdomain_client::fidl::ServerEnd<
4364            fdomain_fuchsia_media_audio::VolumeControlMarker,
4365        >,
4366    ) -> Result<(), fidl::Error>;
4367    fn r#bind_usage_volume_control2(
4368        &self,
4369        usage: &Usage2,
4370        volume_control: fdomain_client::fidl::ServerEnd<
4371            fdomain_fuchsia_media_audio::VolumeControlMarker,
4372        >,
4373    ) -> Result<(), fidl::Error>;
4374    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4375    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4376    -> Self::GetVolumeFromDbResponseFut;
4377    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4378    fn r#get_volume_from_db2(
4379        &self,
4380        usage: &Usage2,
4381        gain_db: f32,
4382    ) -> Self::GetVolumeFromDb2ResponseFut;
4383    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4384    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4385    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4386    fn r#get_db_from_volume2(
4387        &self,
4388        usage: &Usage2,
4389        volume: f32,
4390    ) -> Self::GetDbFromVolume2ResponseFut;
4391    fn r#set_interaction(
4392        &self,
4393        active: &Usage,
4394        affected: &Usage,
4395        behavior: Behavior,
4396    ) -> Result<(), fidl::Error>;
4397    fn r#set_interaction2(
4398        &self,
4399        active: &Usage2,
4400        affected: &Usage2,
4401        behavior: Behavior,
4402    ) -> Result<(), fidl::Error>;
4403    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4404    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4405}
4406
4407#[derive(Debug, Clone)]
4408pub struct AudioCoreProxy {
4409    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4410}
4411
4412impl fdomain_client::fidl::Proxy for AudioCoreProxy {
4413    type Protocol = AudioCoreMarker;
4414
4415    fn from_channel(inner: fdomain_client::Channel) -> Self {
4416        Self::new(inner)
4417    }
4418
4419    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4420        self.client.into_channel().map_err(|client| Self { client })
4421    }
4422
4423    fn as_channel(&self) -> &fdomain_client::Channel {
4424        self.client.as_channel()
4425    }
4426}
4427
4428impl AudioCoreProxy {
4429    /// Create a new Proxy for fuchsia.media/AudioCore.
4430    pub fn new(channel: fdomain_client::Channel) -> Self {
4431        let protocol_name = <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4432        Self { client: fidl::client::Client::new(channel, protocol_name) }
4433    }
4434
4435    /// Get a Stream of events from the remote end of the protocol.
4436    ///
4437    /// # Panics
4438    ///
4439    /// Panics if the event stream was already taken.
4440    pub fn take_event_stream(&self) -> AudioCoreEventStream {
4441        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
4442    }
4443
4444    /// Creates an AudioRenderer which outputs audio to the default device.
4445    pub fn r#create_audio_renderer(
4446        &self,
4447        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4448    ) -> Result<(), fidl::Error> {
4449        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
4450    }
4451
4452    /// Creates an AudioCapturer according to the given requirements.
4453    ///
4454    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4455    /// It causes the source material to be reformatted/resampled if needed
4456    /// in order to produce the requested stream type.
4457    ///
4458    /// `usage` is used by Fuchsia to make decisions about user experience.
4459    /// See `AudioCaptureUsage` for more details.
4460    ///
4461    /// `configuration` must be initialized to a variant, or no capturer
4462    /// can be created.
4463    pub fn r#create_audio_capturer_with_configuration(
4464        &self,
4465        mut stream_type: &AudioStreamType,
4466        mut configuration: &AudioCapturerConfiguration,
4467        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4468    ) -> Result<(), fidl::Error> {
4469        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
4470            self,
4471            stream_type,
4472            configuration,
4473            audio_capturer_request,
4474        )
4475    }
4476
4477    /// Creates an AudioCapturer which either captures from the current default
4478    /// audio input device, or loops-back from the current default audio output
4479    /// device based on value passed for the loopback flag.
4480    pub fn r#create_audio_capturer(
4481        &self,
4482        mut loopback: bool,
4483        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4484    ) -> Result<(), fidl::Error> {
4485        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
4486    }
4487
4488    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4489    pub fn r#set_render_usage_gain(
4490        &self,
4491        mut usage: AudioRenderUsage,
4492        mut gain_db: f32,
4493    ) -> Result<(), fidl::Error> {
4494        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
4495    }
4496
4497    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4498    pub fn r#set_render_usage_gain2(
4499        &self,
4500        mut usage: AudioRenderUsage2,
4501        mut gain_db: f32,
4502    ) -> Result<(), fidl::Error> {
4503        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
4504    }
4505
4506    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4507    pub fn r#set_capture_usage_gain(
4508        &self,
4509        mut usage: AudioCaptureUsage,
4510        mut gain_db: f32,
4511    ) -> Result<(), fidl::Error> {
4512        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
4513    }
4514
4515    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4516    pub fn r#set_capture_usage_gain2(
4517        &self,
4518        mut usage: AudioCaptureUsage2,
4519        mut gain_db: f32,
4520    ) -> Result<(), fidl::Error> {
4521        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
4522    }
4523
4524    /// Binds to a volume control protocol for the given usage.
4525    pub fn r#bind_usage_volume_control(
4526        &self,
4527        mut usage: &Usage,
4528        mut volume_control: fdomain_client::fidl::ServerEnd<
4529            fdomain_fuchsia_media_audio::VolumeControlMarker,
4530        >,
4531    ) -> Result<(), fidl::Error> {
4532        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
4533    }
4534
4535    /// Binds to a volume control protocol for the given usage.
4536    pub fn r#bind_usage_volume_control2(
4537        &self,
4538        mut usage: &Usage2,
4539        mut volume_control: fdomain_client::fidl::ServerEnd<
4540            fdomain_fuchsia_media_audio::VolumeControlMarker,
4541        >,
4542    ) -> Result<(), fidl::Error> {
4543        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
4544    }
4545
4546    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4547    /// `usage`. This is the same mapping as used by the VolumeControl from
4548    /// `BindUsageVolumeControl`.
4549    pub fn r#get_volume_from_db(
4550        &self,
4551        mut usage: &Usage,
4552        mut gain_db: f32,
4553    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4554        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
4555    }
4556
4557    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4558    /// `usage`. This is the same mapping as used by the VolumeControl from
4559    /// `BindUsageVolumeControl`.
4560    pub fn r#get_volume_from_db2(
4561        &self,
4562        mut usage: &Usage2,
4563        mut gain_db: f32,
4564    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4565        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
4566    }
4567
4568    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4569    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4570    pub fn r#get_db_from_volume(
4571        &self,
4572        mut usage: &Usage,
4573        mut volume: f32,
4574    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4575        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
4576    }
4577
4578    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4579    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4580    pub fn r#get_db_from_volume2(
4581        &self,
4582        mut usage: &Usage2,
4583        mut volume: f32,
4584    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4585        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
4586    }
4587
4588    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4589    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4590    /// the Behavior specified will be applied to the streams of Usage `affected`.
4591    pub fn r#set_interaction(
4592        &self,
4593        mut active: &Usage,
4594        mut affected: &Usage,
4595        mut behavior: Behavior,
4596    ) -> Result<(), fidl::Error> {
4597        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
4598    }
4599
4600    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4601    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4602    /// the Behavior specified will be applied to the streams of Usage `affected`.
4603    pub fn r#set_interaction2(
4604        &self,
4605        mut active: &Usage2,
4606        mut affected: &Usage2,
4607        mut behavior: Behavior,
4608    ) -> Result<(), fidl::Error> {
4609        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
4610    }
4611
4612    /// Re-initializes the set of rules that are currently governing the interaction of streams in
4613    /// audio_core. The default behavior is 'NONE'.
4614    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4615        AudioCoreProxyInterface::r#reset_interactions(self)
4616    }
4617
4618    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
4619    /// does not provide a config.
4620    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4621        AudioCoreProxyInterface::r#load_defaults(self)
4622    }
4623}
4624
4625impl AudioCoreProxyInterface for AudioCoreProxy {
4626    fn r#create_audio_renderer(
4627        &self,
4628        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4629    ) -> Result<(), fidl::Error> {
4630        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4631            (audio_out_request,),
4632            0x2ac9beba47f83435,
4633            fidl::encoding::DynamicFlags::empty(),
4634        )
4635    }
4636
4637    fn r#create_audio_capturer_with_configuration(
4638        &self,
4639        mut stream_type: &AudioStreamType,
4640        mut configuration: &AudioCapturerConfiguration,
4641        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4642    ) -> Result<(), fidl::Error> {
4643        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
4644            (stream_type, configuration, audio_capturer_request),
4645            0x459de383b0d76d97,
4646            fidl::encoding::DynamicFlags::empty(),
4647        )
4648    }
4649
4650    fn r#create_audio_capturer(
4651        &self,
4652        mut loopback: bool,
4653        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4654    ) -> Result<(), fidl::Error> {
4655        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
4656            (loopback, audio_in_request),
4657            0x787db169df99aed0,
4658            fidl::encoding::DynamicFlags::empty(),
4659        )
4660    }
4661
4662    fn r#set_render_usage_gain(
4663        &self,
4664        mut usage: AudioRenderUsage,
4665        mut gain_db: f32,
4666    ) -> Result<(), fidl::Error> {
4667        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
4668            (usage, gain_db),
4669            0x48097f45f6e2b8e7,
4670            fidl::encoding::DynamicFlags::empty(),
4671        )
4672    }
4673
4674    fn r#set_render_usage_gain2(
4675        &self,
4676        mut usage: AudioRenderUsage2,
4677        mut gain_db: f32,
4678    ) -> Result<(), fidl::Error> {
4679        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
4680            (usage, gain_db),
4681            0x779b1531dc9e64f4,
4682            fidl::encoding::DynamicFlags::FLEXIBLE,
4683        )
4684    }
4685
4686    fn r#set_capture_usage_gain(
4687        &self,
4688        mut usage: AudioCaptureUsage,
4689        mut gain_db: f32,
4690    ) -> Result<(), fidl::Error> {
4691        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
4692            (usage, gain_db),
4693            0x457d29217d4ea248,
4694            fidl::encoding::DynamicFlags::empty(),
4695        )
4696    }
4697
4698    fn r#set_capture_usage_gain2(
4699        &self,
4700        mut usage: AudioCaptureUsage2,
4701        mut gain_db: f32,
4702    ) -> Result<(), fidl::Error> {
4703        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
4704            (usage, gain_db),
4705            0x15065ee308f44af0,
4706            fidl::encoding::DynamicFlags::FLEXIBLE,
4707        )
4708    }
4709
4710    fn r#bind_usage_volume_control(
4711        &self,
4712        mut usage: &Usage,
4713        mut volume_control: fdomain_client::fidl::ServerEnd<
4714            fdomain_fuchsia_media_audio::VolumeControlMarker,
4715        >,
4716    ) -> Result<(), fidl::Error> {
4717        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
4718            (usage, volume_control),
4719            0x7225be116aadc137,
4720            fidl::encoding::DynamicFlags::empty(),
4721        )
4722    }
4723
4724    fn r#bind_usage_volume_control2(
4725        &self,
4726        mut usage: &Usage2,
4727        mut volume_control: fdomain_client::fidl::ServerEnd<
4728            fdomain_fuchsia_media_audio::VolumeControlMarker,
4729        >,
4730    ) -> Result<(), fidl::Error> {
4731        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
4732            (usage, volume_control),
4733            0x729dff93019d055,
4734            fidl::encoding::DynamicFlags::FLEXIBLE,
4735        )
4736    }
4737
4738    type GetVolumeFromDbResponseFut =
4739        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4740    fn r#get_volume_from_db(
4741        &self,
4742        mut usage: &Usage,
4743        mut gain_db: f32,
4744    ) -> Self::GetVolumeFromDbResponseFut {
4745        fn _decode(
4746            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4747        ) -> Result<f32, fidl::Error> {
4748            let _response = fidl::client::decode_transaction_body::<
4749                AudioCoreGetVolumeFromDbResponse,
4750                fdomain_client::fidl::FDomainResourceDialect,
4751                0x50e3ca45509770bf,
4752            >(_buf?)?;
4753            Ok(_response.volume)
4754        }
4755        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
4756            (usage, gain_db),
4757            0x50e3ca45509770bf,
4758            fidl::encoding::DynamicFlags::empty(),
4759            _decode,
4760        )
4761    }
4762
4763    type GetVolumeFromDb2ResponseFut =
4764        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4765    fn r#get_volume_from_db2(
4766        &self,
4767        mut usage: &Usage2,
4768        mut gain_db: f32,
4769    ) -> Self::GetVolumeFromDb2ResponseFut {
4770        fn _decode(
4771            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4772        ) -> Result<f32, fidl::Error> {
4773            let _response = fidl::client::decode_transaction_body::<
4774                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
4775                fdomain_client::fidl::FDomainResourceDialect,
4776                0x165c811091ef99da,
4777            >(_buf?)?
4778            .into_result_fdomain::<AudioCoreMarker>("get_volume_from_db2")?;
4779            Ok(_response.volume)
4780        }
4781        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
4782            (usage, gain_db),
4783            0x165c811091ef99da,
4784            fidl::encoding::DynamicFlags::FLEXIBLE,
4785            _decode,
4786        )
4787    }
4788
4789    type GetDbFromVolumeResponseFut =
4790        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4791    fn r#get_db_from_volume(
4792        &self,
4793        mut usage: &Usage,
4794        mut volume: f32,
4795    ) -> Self::GetDbFromVolumeResponseFut {
4796        fn _decode(
4797            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4798        ) -> Result<f32, fidl::Error> {
4799            let _response = fidl::client::decode_transaction_body::<
4800                AudioCoreGetDbFromVolumeResponse,
4801                fdomain_client::fidl::FDomainResourceDialect,
4802                0x3e8eec27dd5a8bda,
4803            >(_buf?)?;
4804            Ok(_response.gain_db)
4805        }
4806        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
4807            (usage, volume),
4808            0x3e8eec27dd5a8bda,
4809            fidl::encoding::DynamicFlags::empty(),
4810            _decode,
4811        )
4812    }
4813
4814    type GetDbFromVolume2ResponseFut =
4815        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4816    fn r#get_db_from_volume2(
4817        &self,
4818        mut usage: &Usage2,
4819        mut volume: f32,
4820    ) -> Self::GetDbFromVolume2ResponseFut {
4821        fn _decode(
4822            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4823        ) -> Result<f32, fidl::Error> {
4824            let _response = fidl::client::decode_transaction_body::<
4825                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
4826                fdomain_client::fidl::FDomainResourceDialect,
4827                0x5f421a8ebf265bf3,
4828            >(_buf?)?
4829            .into_result_fdomain::<AudioCoreMarker>("get_db_from_volume2")?;
4830            Ok(_response.gain_db)
4831        }
4832        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
4833            (usage, volume),
4834            0x5f421a8ebf265bf3,
4835            fidl::encoding::DynamicFlags::FLEXIBLE,
4836            _decode,
4837        )
4838    }
4839
4840    fn r#set_interaction(
4841        &self,
4842        mut active: &Usage,
4843        mut affected: &Usage,
4844        mut behavior: Behavior,
4845    ) -> Result<(), fidl::Error> {
4846        self.client.send::<AudioCoreSetInteractionRequest>(
4847            (active, affected, behavior),
4848            0x7bfed14345ece7b7,
4849            fidl::encoding::DynamicFlags::empty(),
4850        )
4851    }
4852
4853    fn r#set_interaction2(
4854        &self,
4855        mut active: &Usage2,
4856        mut affected: &Usage2,
4857        mut behavior: Behavior,
4858    ) -> Result<(), fidl::Error> {
4859        self.client.send::<AudioCoreSetInteraction2Request>(
4860            (active, affected, behavior),
4861            0x7226c7c6e6edc62f,
4862            fidl::encoding::DynamicFlags::FLEXIBLE,
4863        )
4864    }
4865
4866    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4867        self.client.send::<fidl::encoding::EmptyPayload>(
4868            (),
4869            0x65bd94d9d0a28b5e,
4870            fidl::encoding::DynamicFlags::empty(),
4871        )
4872    }
4873
4874    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4875        self.client.send::<fidl::encoding::EmptyPayload>(
4876            (),
4877            0x54a0bebca85f6b31,
4878            fidl::encoding::DynamicFlags::empty(),
4879        )
4880    }
4881}
4882
4883pub struct AudioCoreEventStream {
4884    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4885}
4886
4887impl std::marker::Unpin for AudioCoreEventStream {}
4888
4889impl futures::stream::FusedStream for AudioCoreEventStream {
4890    fn is_terminated(&self) -> bool {
4891        self.event_receiver.is_terminated()
4892    }
4893}
4894
4895impl futures::Stream for AudioCoreEventStream {
4896    type Item = Result<AudioCoreEvent, fidl::Error>;
4897
4898    fn poll_next(
4899        mut self: std::pin::Pin<&mut Self>,
4900        cx: &mut std::task::Context<'_>,
4901    ) -> std::task::Poll<Option<Self::Item>> {
4902        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4903            &mut self.event_receiver,
4904            cx
4905        )?) {
4906            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
4907            None => std::task::Poll::Ready(None),
4908        }
4909    }
4910}
4911
4912#[derive(Debug)]
4913pub enum AudioCoreEvent {
4914    #[non_exhaustive]
4915    _UnknownEvent {
4916        /// Ordinal of the event that was sent.
4917        ordinal: u64,
4918    },
4919}
4920
4921impl AudioCoreEvent {
4922    /// Decodes a message buffer as a [`AudioCoreEvent`].
4923    fn decode(
4924        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4925    ) -> Result<AudioCoreEvent, fidl::Error> {
4926        let (bytes, _handles) = buf.split_mut();
4927        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4928        debug_assert_eq!(tx_header.tx_id, 0);
4929        match tx_header.ordinal {
4930            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4931                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4932            }
4933            _ => Err(fidl::Error::UnknownOrdinal {
4934                ordinal: tx_header.ordinal,
4935                protocol_name:
4936                    <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4937            }),
4938        }
4939    }
4940}
4941
4942/// A Stream of incoming requests for fuchsia.media/AudioCore.
4943pub struct AudioCoreRequestStream {
4944    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4945    is_terminated: bool,
4946}
4947
4948impl std::marker::Unpin for AudioCoreRequestStream {}
4949
4950impl futures::stream::FusedStream for AudioCoreRequestStream {
4951    fn is_terminated(&self) -> bool {
4952        self.is_terminated
4953    }
4954}
4955
4956impl fdomain_client::fidl::RequestStream for AudioCoreRequestStream {
4957    type Protocol = AudioCoreMarker;
4958    type ControlHandle = AudioCoreControlHandle;
4959
4960    fn from_channel(channel: fdomain_client::Channel) -> Self {
4961        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4962    }
4963
4964    fn control_handle(&self) -> Self::ControlHandle {
4965        AudioCoreControlHandle { inner: self.inner.clone() }
4966    }
4967
4968    fn into_inner(
4969        self,
4970    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4971    {
4972        (self.inner, self.is_terminated)
4973    }
4974
4975    fn from_inner(
4976        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4977        is_terminated: bool,
4978    ) -> Self {
4979        Self { inner, is_terminated }
4980    }
4981}
4982
4983impl futures::Stream for AudioCoreRequestStream {
4984    type Item = Result<AudioCoreRequest, fidl::Error>;
4985
4986    fn poll_next(
4987        mut self: std::pin::Pin<&mut Self>,
4988        cx: &mut std::task::Context<'_>,
4989    ) -> std::task::Poll<Option<Self::Item>> {
4990        let this = &mut *self;
4991        if this.inner.check_shutdown(cx) {
4992            this.is_terminated = true;
4993            return std::task::Poll::Ready(None);
4994        }
4995        if this.is_terminated {
4996            panic!("polled AudioCoreRequestStream after completion");
4997        }
4998        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
4999            |bytes, handles| {
5000                match this.inner.channel().read_etc(cx, bytes, handles) {
5001                    std::task::Poll::Ready(Ok(())) => {}
5002                    std::task::Poll::Pending => return std::task::Poll::Pending,
5003                    std::task::Poll::Ready(Err(None)) => {
5004                        this.is_terminated = true;
5005                        return std::task::Poll::Ready(None);
5006                    }
5007                    std::task::Poll::Ready(Err(Some(e))) => {
5008                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5009                            e.into(),
5010                        ))));
5011                    }
5012                }
5013
5014                // A message has been received from the channel
5015                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5016
5017                std::task::Poll::Ready(Some(match header.ordinal {
5018                    0x2ac9beba47f83435 => {
5019                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5020                        let mut req = fidl::new_empty!(
5021                            AudioCoreCreateAudioRendererRequest,
5022                            fdomain_client::fidl::FDomainResourceDialect
5023                        );
5024                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5025                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5026                        Ok(AudioCoreRequest::CreateAudioRenderer {
5027                            audio_out_request: req.audio_out_request,
5028
5029                            control_handle,
5030                        })
5031                    }
5032                    0x459de383b0d76d97 => {
5033                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5034                        let mut req = fidl::new_empty!(
5035                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5036                            fdomain_client::fidl::FDomainResourceDialect
5037                        );
5038                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5039                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5040                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5041                            stream_type: req.stream_type,
5042                            configuration: req.configuration,
5043                            audio_capturer_request: req.audio_capturer_request,
5044
5045                            control_handle,
5046                        })
5047                    }
5048                    0x787db169df99aed0 => {
5049                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5050                        let mut req = fidl::new_empty!(
5051                            AudioCoreCreateAudioCapturerRequest,
5052                            fdomain_client::fidl::FDomainResourceDialect
5053                        );
5054                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5055                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5056                        Ok(AudioCoreRequest::CreateAudioCapturer {
5057                            loopback: req.loopback,
5058                            audio_in_request: req.audio_in_request,
5059
5060                            control_handle,
5061                        })
5062                    }
5063                    0x48097f45f6e2b8e7 => {
5064                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5065                        let mut req = fidl::new_empty!(
5066                            AudioCoreSetRenderUsageGainRequest,
5067                            fdomain_client::fidl::FDomainResourceDialect
5068                        );
5069                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5070                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5071                        Ok(AudioCoreRequest::SetRenderUsageGain {
5072                            usage: req.usage,
5073                            gain_db: req.gain_db,
5074
5075                            control_handle,
5076                        })
5077                    }
5078                    0x779b1531dc9e64f4 => {
5079                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5080                        let mut req = fidl::new_empty!(
5081                            AudioCoreSetRenderUsageGain2Request,
5082                            fdomain_client::fidl::FDomainResourceDialect
5083                        );
5084                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5085                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5086                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5087                            usage: req.usage,
5088                            gain_db: req.gain_db,
5089
5090                            control_handle,
5091                        })
5092                    }
5093                    0x457d29217d4ea248 => {
5094                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5095                        let mut req = fidl::new_empty!(
5096                            AudioCoreSetCaptureUsageGainRequest,
5097                            fdomain_client::fidl::FDomainResourceDialect
5098                        );
5099                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5100                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5101                        Ok(AudioCoreRequest::SetCaptureUsageGain {
5102                            usage: req.usage,
5103                            gain_db: req.gain_db,
5104
5105                            control_handle,
5106                        })
5107                    }
5108                    0x15065ee308f44af0 => {
5109                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5110                        let mut req = fidl::new_empty!(
5111                            AudioCoreSetCaptureUsageGain2Request,
5112                            fdomain_client::fidl::FDomainResourceDialect
5113                        );
5114                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5115                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5116                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
5117                            usage: req.usage,
5118                            gain_db: req.gain_db,
5119
5120                            control_handle,
5121                        })
5122                    }
5123                    0x7225be116aadc137 => {
5124                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5125                        let mut req = fidl::new_empty!(
5126                            AudioCoreBindUsageVolumeControlRequest,
5127                            fdomain_client::fidl::FDomainResourceDialect
5128                        );
5129                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
5130                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5131                        Ok(AudioCoreRequest::BindUsageVolumeControl {
5132                            usage: req.usage,
5133                            volume_control: req.volume_control,
5134
5135                            control_handle,
5136                        })
5137                    }
5138                    0x729dff93019d055 => {
5139                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5140                        let mut req = fidl::new_empty!(
5141                            AudioCoreBindUsageVolumeControl2Request,
5142                            fdomain_client::fidl::FDomainResourceDialect
5143                        );
5144                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
5145                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5146                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
5147                            usage: req.usage,
5148                            volume_control: req.volume_control,
5149
5150                            control_handle,
5151                        })
5152                    }
5153                    0x50e3ca45509770bf => {
5154                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5155                        let mut req = fidl::new_empty!(
5156                            AudioCoreGetVolumeFromDbRequest,
5157                            fdomain_client::fidl::FDomainResourceDialect
5158                        );
5159                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
5160                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5161                        Ok(AudioCoreRequest::GetVolumeFromDb {
5162                            usage: req.usage,
5163                            gain_db: req.gain_db,
5164
5165                            responder: AudioCoreGetVolumeFromDbResponder {
5166                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5167                                tx_id: header.tx_id,
5168                            },
5169                        })
5170                    }
5171                    0x165c811091ef99da => {
5172                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5173                        let mut req = fidl::new_empty!(
5174                            AudioCoreGetVolumeFromDb2Request,
5175                            fdomain_client::fidl::FDomainResourceDialect
5176                        );
5177                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
5178                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5179                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
5180                            usage: req.usage,
5181                            gain_db: req.gain_db,
5182
5183                            responder: AudioCoreGetVolumeFromDb2Responder {
5184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5185                                tx_id: header.tx_id,
5186                            },
5187                        })
5188                    }
5189                    0x3e8eec27dd5a8bda => {
5190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5191                        let mut req = fidl::new_empty!(
5192                            AudioCoreGetDbFromVolumeRequest,
5193                            fdomain_client::fidl::FDomainResourceDialect
5194                        );
5195                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
5196                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5197                        Ok(AudioCoreRequest::GetDbFromVolume {
5198                            usage: req.usage,
5199                            volume: req.volume,
5200
5201                            responder: AudioCoreGetDbFromVolumeResponder {
5202                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5203                                tx_id: header.tx_id,
5204                            },
5205                        })
5206                    }
5207                    0x5f421a8ebf265bf3 => {
5208                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5209                        let mut req = fidl::new_empty!(
5210                            AudioCoreGetDbFromVolume2Request,
5211                            fdomain_client::fidl::FDomainResourceDialect
5212                        );
5213                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
5214                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5215                        Ok(AudioCoreRequest::GetDbFromVolume2 {
5216                            usage: req.usage,
5217                            volume: req.volume,
5218
5219                            responder: AudioCoreGetDbFromVolume2Responder {
5220                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5221                                tx_id: header.tx_id,
5222                            },
5223                        })
5224                    }
5225                    0x7bfed14345ece7b7 => {
5226                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5227                        let mut req = fidl::new_empty!(
5228                            AudioCoreSetInteractionRequest,
5229                            fdomain_client::fidl::FDomainResourceDialect
5230                        );
5231                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
5232                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5233                        Ok(AudioCoreRequest::SetInteraction {
5234                            active: req.active,
5235                            affected: req.affected,
5236                            behavior: req.behavior,
5237
5238                            control_handle,
5239                        })
5240                    }
5241                    0x7226c7c6e6edc62f => {
5242                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5243                        let mut req = fidl::new_empty!(
5244                            AudioCoreSetInteraction2Request,
5245                            fdomain_client::fidl::FDomainResourceDialect
5246                        );
5247                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
5248                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5249                        Ok(AudioCoreRequest::SetInteraction2 {
5250                            active: req.active,
5251                            affected: req.affected,
5252                            behavior: req.behavior,
5253
5254                            control_handle,
5255                        })
5256                    }
5257                    0x65bd94d9d0a28b5e => {
5258                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5259                        let mut req = fidl::new_empty!(
5260                            fidl::encoding::EmptyPayload,
5261                            fdomain_client::fidl::FDomainResourceDialect
5262                        );
5263                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5264                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5265                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
5266                    }
5267                    0x54a0bebca85f6b31 => {
5268                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5269                        let mut req = fidl::new_empty!(
5270                            fidl::encoding::EmptyPayload,
5271                            fdomain_client::fidl::FDomainResourceDialect
5272                        );
5273                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5274                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5275                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
5276                    }
5277                    _ if header.tx_id == 0
5278                        && header
5279                            .dynamic_flags()
5280                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5281                    {
5282                        Ok(AudioCoreRequest::_UnknownMethod {
5283                            ordinal: header.ordinal,
5284                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5285                            method_type: fidl::MethodType::OneWay,
5286                        })
5287                    }
5288                    _ if header
5289                        .dynamic_flags()
5290                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5291                    {
5292                        this.inner.send_framework_err(
5293                            fidl::encoding::FrameworkErr::UnknownMethod,
5294                            header.tx_id,
5295                            header.ordinal,
5296                            header.dynamic_flags(),
5297                            (bytes, handles),
5298                        )?;
5299                        Ok(AudioCoreRequest::_UnknownMethod {
5300                            ordinal: header.ordinal,
5301                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5302                            method_type: fidl::MethodType::TwoWay,
5303                        })
5304                    }
5305                    _ => Err(fidl::Error::UnknownOrdinal {
5306                        ordinal: header.ordinal,
5307                        protocol_name:
5308                            <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5309                    }),
5310                }))
5311            },
5312        )
5313    }
5314}
5315
5316#[derive(Debug)]
5317pub enum AudioCoreRequest {
5318    /// Creates an AudioRenderer which outputs audio to the default device.
5319    CreateAudioRenderer {
5320        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
5321        control_handle: AudioCoreControlHandle,
5322    },
5323    /// Creates an AudioCapturer according to the given requirements.
5324    ///
5325    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5326    /// It causes the source material to be reformatted/resampled if needed
5327    /// in order to produce the requested stream type.
5328    ///
5329    /// `usage` is used by Fuchsia to make decisions about user experience.
5330    /// See `AudioCaptureUsage` for more details.
5331    ///
5332    /// `configuration` must be initialized to a variant, or no capturer
5333    /// can be created.
5334    CreateAudioCapturerWithConfiguration {
5335        stream_type: AudioStreamType,
5336        configuration: AudioCapturerConfiguration,
5337        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5338        control_handle: AudioCoreControlHandle,
5339    },
5340    /// Creates an AudioCapturer which either captures from the current default
5341    /// audio input device, or loops-back from the current default audio output
5342    /// device based on value passed for the loopback flag.
5343    CreateAudioCapturer {
5344        loopback: bool,
5345        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5346        control_handle: AudioCoreControlHandle,
5347    },
5348    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5349    SetRenderUsageGain {
5350        usage: AudioRenderUsage,
5351        gain_db: f32,
5352        control_handle: AudioCoreControlHandle,
5353    },
5354    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5355    SetRenderUsageGain2 {
5356        usage: AudioRenderUsage2,
5357        gain_db: f32,
5358        control_handle: AudioCoreControlHandle,
5359    },
5360    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5361    SetCaptureUsageGain {
5362        usage: AudioCaptureUsage,
5363        gain_db: f32,
5364        control_handle: AudioCoreControlHandle,
5365    },
5366    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5367    SetCaptureUsageGain2 {
5368        usage: AudioCaptureUsage2,
5369        gain_db: f32,
5370        control_handle: AudioCoreControlHandle,
5371    },
5372    /// Binds to a volume control protocol for the given usage.
5373    BindUsageVolumeControl {
5374        usage: Usage,
5375        volume_control:
5376            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5377        control_handle: AudioCoreControlHandle,
5378    },
5379    /// Binds to a volume control protocol for the given usage.
5380    BindUsageVolumeControl2 {
5381        usage: Usage2,
5382        volume_control:
5383            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5384        control_handle: AudioCoreControlHandle,
5385    },
5386    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5387    /// `usage`. This is the same mapping as used by the VolumeControl from
5388    /// `BindUsageVolumeControl`.
5389    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
5390    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5391    /// `usage`. This is the same mapping as used by the VolumeControl from
5392    /// `BindUsageVolumeControl`.
5393    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
5394    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5395    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5396    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
5397    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5398    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5399    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
5400    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5401    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5402    /// the Behavior specified will be applied to the streams of Usage `affected`.
5403    SetInteraction {
5404        active: Usage,
5405        affected: Usage,
5406        behavior: Behavior,
5407        control_handle: AudioCoreControlHandle,
5408    },
5409    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5410    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5411    /// the Behavior specified will be applied to the streams of Usage `affected`.
5412    SetInteraction2 {
5413        active: Usage2,
5414        affected: Usage2,
5415        behavior: Behavior,
5416        control_handle: AudioCoreControlHandle,
5417    },
5418    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5419    /// audio_core. The default behavior is 'NONE'.
5420    ResetInteractions { control_handle: AudioCoreControlHandle },
5421    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5422    /// does not provide a config.
5423    LoadDefaults { control_handle: AudioCoreControlHandle },
5424    /// An interaction was received which does not match any known method.
5425    #[non_exhaustive]
5426    _UnknownMethod {
5427        /// Ordinal of the method that was called.
5428        ordinal: u64,
5429        control_handle: AudioCoreControlHandle,
5430        method_type: fidl::MethodType,
5431    },
5432}
5433
5434impl AudioCoreRequest {
5435    #[allow(irrefutable_let_patterns)]
5436    pub fn into_create_audio_renderer(
5437        self,
5438    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)>
5439    {
5440        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
5441            Some((audio_out_request, control_handle))
5442        } else {
5443            None
5444        }
5445    }
5446
5447    #[allow(irrefutable_let_patterns)]
5448    pub fn into_create_audio_capturer_with_configuration(
5449        self,
5450    ) -> Option<(
5451        AudioStreamType,
5452        AudioCapturerConfiguration,
5453        fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5454        AudioCoreControlHandle,
5455    )> {
5456        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5457            stream_type,
5458            configuration,
5459            audio_capturer_request,
5460            control_handle,
5461        } = self
5462        {
5463            Some((stream_type, configuration, audio_capturer_request, control_handle))
5464        } else {
5465            None
5466        }
5467    }
5468
5469    #[allow(irrefutable_let_patterns)]
5470    pub fn into_create_audio_capturer(
5471        self,
5472    ) -> Option<(bool, fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
5473    {
5474        if let AudioCoreRequest::CreateAudioCapturer {
5475            loopback,
5476            audio_in_request,
5477            control_handle,
5478        } = self
5479        {
5480            Some((loopback, audio_in_request, control_handle))
5481        } else {
5482            None
5483        }
5484    }
5485
5486    #[allow(irrefutable_let_patterns)]
5487    pub fn into_set_render_usage_gain(
5488        self,
5489    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
5490        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
5491            Some((usage, gain_db, control_handle))
5492        } else {
5493            None
5494        }
5495    }
5496
5497    #[allow(irrefutable_let_patterns)]
5498    pub fn into_set_render_usage_gain2(
5499        self,
5500    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
5501        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
5502            Some((usage, gain_db, control_handle))
5503        } else {
5504            None
5505        }
5506    }
5507
5508    #[allow(irrefutable_let_patterns)]
5509    pub fn into_set_capture_usage_gain(
5510        self,
5511    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
5512        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
5513            Some((usage, gain_db, control_handle))
5514        } else {
5515            None
5516        }
5517    }
5518
5519    #[allow(irrefutable_let_patterns)]
5520    pub fn into_set_capture_usage_gain2(
5521        self,
5522    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
5523        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
5524            Some((usage, gain_db, control_handle))
5525        } else {
5526            None
5527        }
5528    }
5529
5530    #[allow(irrefutable_let_patterns)]
5531    pub fn into_bind_usage_volume_control(
5532        self,
5533    ) -> Option<(
5534        Usage,
5535        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5536        AudioCoreControlHandle,
5537    )> {
5538        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
5539            self
5540        {
5541            Some((usage, volume_control, control_handle))
5542        } else {
5543            None
5544        }
5545    }
5546
5547    #[allow(irrefutable_let_patterns)]
5548    pub fn into_bind_usage_volume_control2(
5549        self,
5550    ) -> Option<(
5551        Usage2,
5552        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5553        AudioCoreControlHandle,
5554    )> {
5555        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
5556            self
5557        {
5558            Some((usage, volume_control, control_handle))
5559        } else {
5560            None
5561        }
5562    }
5563
5564    #[allow(irrefutable_let_patterns)]
5565    pub fn into_get_volume_from_db(
5566        self,
5567    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
5568        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
5569            Some((usage, gain_db, responder))
5570        } else {
5571            None
5572        }
5573    }
5574
5575    #[allow(irrefutable_let_patterns)]
5576    pub fn into_get_volume_from_db2(
5577        self,
5578    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
5579        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
5580            Some((usage, gain_db, responder))
5581        } else {
5582            None
5583        }
5584    }
5585
5586    #[allow(irrefutable_let_patterns)]
5587    pub fn into_get_db_from_volume(
5588        self,
5589    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
5590        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
5591            Some((usage, volume, responder))
5592        } else {
5593            None
5594        }
5595    }
5596
5597    #[allow(irrefutable_let_patterns)]
5598    pub fn into_get_db_from_volume2(
5599        self,
5600    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
5601        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
5602            Some((usage, volume, responder))
5603        } else {
5604            None
5605        }
5606    }
5607
5608    #[allow(irrefutable_let_patterns)]
5609    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
5610        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
5611            self
5612        {
5613            Some((active, affected, behavior, control_handle))
5614        } else {
5615            None
5616        }
5617    }
5618
5619    #[allow(irrefutable_let_patterns)]
5620    pub fn into_set_interaction2(
5621        self,
5622    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
5623        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
5624            self
5625        {
5626            Some((active, affected, behavior, control_handle))
5627        } else {
5628            None
5629        }
5630    }
5631
5632    #[allow(irrefutable_let_patterns)]
5633    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
5634        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
5635            Some((control_handle))
5636        } else {
5637            None
5638        }
5639    }
5640
5641    #[allow(irrefutable_let_patterns)]
5642    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
5643        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
5644            Some((control_handle))
5645        } else {
5646            None
5647        }
5648    }
5649
5650    /// Name of the method defined in FIDL
5651    pub fn method_name(&self) -> &'static str {
5652        match *self {
5653            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
5654            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
5655                "create_audio_capturer_with_configuration"
5656            }
5657            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
5658            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
5659            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
5660            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
5661            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
5662            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
5663            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
5664            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
5665            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
5666            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
5667            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
5668            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
5669            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
5670            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
5671            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
5672            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
5673                "unknown one-way method"
5674            }
5675            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
5676                "unknown two-way method"
5677            }
5678        }
5679    }
5680}
5681
5682#[derive(Debug, Clone)]
5683pub struct AudioCoreControlHandle {
5684    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5685}
5686
5687impl fdomain_client::fidl::ControlHandle for AudioCoreControlHandle {
5688    fn shutdown(&self) {
5689        self.inner.shutdown()
5690    }
5691
5692    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5693        self.inner.shutdown_with_epitaph(status)
5694    }
5695
5696    fn is_closed(&self) -> bool {
5697        self.inner.channel().is_closed()
5698    }
5699    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
5700        self.inner.channel().on_closed()
5701    }
5702}
5703
5704impl AudioCoreControlHandle {}
5705
5706#[must_use = "FIDL methods require a response to be sent"]
5707#[derive(Debug)]
5708pub struct AudioCoreGetVolumeFromDbResponder {
5709    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5710    tx_id: u32,
5711}
5712
5713/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5714/// if the responder is dropped without sending a response, so that the client
5715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5716impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
5717    fn drop(&mut self) {
5718        self.control_handle.shutdown();
5719        // Safety: drops once, never accessed again
5720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5721    }
5722}
5723
5724impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDbResponder {
5725    type ControlHandle = AudioCoreControlHandle;
5726
5727    fn control_handle(&self) -> &AudioCoreControlHandle {
5728        &self.control_handle
5729    }
5730
5731    fn drop_without_shutdown(mut self) {
5732        // Safety: drops once, never accessed again due to mem::forget
5733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5734        // Prevent Drop from running (which would shut down the channel)
5735        std::mem::forget(self);
5736    }
5737}
5738
5739impl AudioCoreGetVolumeFromDbResponder {
5740    /// Sends a response to the FIDL transaction.
5741    ///
5742    /// Sets the channel to shutdown if an error occurs.
5743    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5744        let _result = self.send_raw(volume);
5745        if _result.is_err() {
5746            self.control_handle.shutdown();
5747        }
5748        self.drop_without_shutdown();
5749        _result
5750    }
5751
5752    /// Similar to "send" but does not shutdown the channel if an error occurs.
5753    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5754        let _result = self.send_raw(volume);
5755        self.drop_without_shutdown();
5756        _result
5757    }
5758
5759    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5760        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
5761            (volume,),
5762            self.tx_id,
5763            0x50e3ca45509770bf,
5764            fidl::encoding::DynamicFlags::empty(),
5765        )
5766    }
5767}
5768
5769#[must_use = "FIDL methods require a response to be sent"]
5770#[derive(Debug)]
5771pub struct AudioCoreGetVolumeFromDb2Responder {
5772    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5773    tx_id: u32,
5774}
5775
5776/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5777/// if the responder is dropped without sending a response, so that the client
5778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5779impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
5780    fn drop(&mut self) {
5781        self.control_handle.shutdown();
5782        // Safety: drops once, never accessed again
5783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5784    }
5785}
5786
5787impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDb2Responder {
5788    type ControlHandle = AudioCoreControlHandle;
5789
5790    fn control_handle(&self) -> &AudioCoreControlHandle {
5791        &self.control_handle
5792    }
5793
5794    fn drop_without_shutdown(mut self) {
5795        // Safety: drops once, never accessed again due to mem::forget
5796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5797        // Prevent Drop from running (which would shut down the channel)
5798        std::mem::forget(self);
5799    }
5800}
5801
5802impl AudioCoreGetVolumeFromDb2Responder {
5803    /// Sends a response to the FIDL transaction.
5804    ///
5805    /// Sets the channel to shutdown if an error occurs.
5806    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5807        let _result = self.send_raw(volume);
5808        if _result.is_err() {
5809            self.control_handle.shutdown();
5810        }
5811        self.drop_without_shutdown();
5812        _result
5813    }
5814
5815    /// Similar to "send" but does not shutdown the channel if an error occurs.
5816    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5817        let _result = self.send_raw(volume);
5818        self.drop_without_shutdown();
5819        _result
5820    }
5821
5822    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5823        self.control_handle
5824            .inner
5825            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
5826                fidl::encoding::Flexible::new((volume,)),
5827                self.tx_id,
5828                0x165c811091ef99da,
5829                fidl::encoding::DynamicFlags::FLEXIBLE,
5830            )
5831    }
5832}
5833
5834#[must_use = "FIDL methods require a response to be sent"]
5835#[derive(Debug)]
5836pub struct AudioCoreGetDbFromVolumeResponder {
5837    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5838    tx_id: u32,
5839}
5840
5841/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5842/// if the responder is dropped without sending a response, so that the client
5843/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5844impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
5845    fn drop(&mut self) {
5846        self.control_handle.shutdown();
5847        // Safety: drops once, never accessed again
5848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5849    }
5850}
5851
5852impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolumeResponder {
5853    type ControlHandle = AudioCoreControlHandle;
5854
5855    fn control_handle(&self) -> &AudioCoreControlHandle {
5856        &self.control_handle
5857    }
5858
5859    fn drop_without_shutdown(mut self) {
5860        // Safety: drops once, never accessed again due to mem::forget
5861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5862        // Prevent Drop from running (which would shut down the channel)
5863        std::mem::forget(self);
5864    }
5865}
5866
5867impl AudioCoreGetDbFromVolumeResponder {
5868    /// Sends a response to the FIDL transaction.
5869    ///
5870    /// Sets the channel to shutdown if an error occurs.
5871    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5872        let _result = self.send_raw(gain_db);
5873        if _result.is_err() {
5874            self.control_handle.shutdown();
5875        }
5876        self.drop_without_shutdown();
5877        _result
5878    }
5879
5880    /// Similar to "send" but does not shutdown the channel if an error occurs.
5881    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5882        let _result = self.send_raw(gain_db);
5883        self.drop_without_shutdown();
5884        _result
5885    }
5886
5887    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5888        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
5889            (gain_db,),
5890            self.tx_id,
5891            0x3e8eec27dd5a8bda,
5892            fidl::encoding::DynamicFlags::empty(),
5893        )
5894    }
5895}
5896
5897#[must_use = "FIDL methods require a response to be sent"]
5898#[derive(Debug)]
5899pub struct AudioCoreGetDbFromVolume2Responder {
5900    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5901    tx_id: u32,
5902}
5903
5904/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5905/// if the responder is dropped without sending a response, so that the client
5906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5907impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
5908    fn drop(&mut self) {
5909        self.control_handle.shutdown();
5910        // Safety: drops once, never accessed again
5911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5912    }
5913}
5914
5915impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolume2Responder {
5916    type ControlHandle = AudioCoreControlHandle;
5917
5918    fn control_handle(&self) -> &AudioCoreControlHandle {
5919        &self.control_handle
5920    }
5921
5922    fn drop_without_shutdown(mut self) {
5923        // Safety: drops once, never accessed again due to mem::forget
5924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5925        // Prevent Drop from running (which would shut down the channel)
5926        std::mem::forget(self);
5927    }
5928}
5929
5930impl AudioCoreGetDbFromVolume2Responder {
5931    /// Sends a response to the FIDL transaction.
5932    ///
5933    /// Sets the channel to shutdown if an error occurs.
5934    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5935        let _result = self.send_raw(gain_db);
5936        if _result.is_err() {
5937            self.control_handle.shutdown();
5938        }
5939        self.drop_without_shutdown();
5940        _result
5941    }
5942
5943    /// Similar to "send" but does not shutdown the channel if an error occurs.
5944    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5945        let _result = self.send_raw(gain_db);
5946        self.drop_without_shutdown();
5947        _result
5948    }
5949
5950    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5951        self.control_handle
5952            .inner
5953            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
5954                fidl::encoding::Flexible::new((gain_db,)),
5955                self.tx_id,
5956                0x5f421a8ebf265bf3,
5957                fidl::encoding::DynamicFlags::FLEXIBLE,
5958            )
5959    }
5960}
5961
5962#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5963pub struct AudioDeviceEnumeratorMarker;
5964
5965impl fdomain_client::fidl::ProtocolMarker for AudioDeviceEnumeratorMarker {
5966    type Proxy = AudioDeviceEnumeratorProxy;
5967    type RequestStream = AudioDeviceEnumeratorRequestStream;
5968
5969    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
5970}
5971impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
5972
5973pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
5974    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
5975        + Send;
5976    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
5977    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
5978        + Send;
5979    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
5980    fn r#set_device_gain(
5981        &self,
5982        device_token: u64,
5983        gain_info: &AudioGainInfo,
5984        valid_flags: AudioGainValidFlags,
5985    ) -> Result<(), fidl::Error>;
5986    fn r#add_device_by_channel(
5987        &self,
5988        device_name: &str,
5989        is_input: bool,
5990        channel: fdomain_client::fidl::ClientEnd<
5991            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
5992        >,
5993    ) -> Result<(), fidl::Error>;
5994}
5995
5996#[derive(Debug, Clone)]
5997pub struct AudioDeviceEnumeratorProxy {
5998    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
5999}
6000
6001impl fdomain_client::fidl::Proxy for AudioDeviceEnumeratorProxy {
6002    type Protocol = AudioDeviceEnumeratorMarker;
6003
6004    fn from_channel(inner: fdomain_client::Channel) -> Self {
6005        Self::new(inner)
6006    }
6007
6008    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6009        self.client.into_channel().map_err(|client| Self { client })
6010    }
6011
6012    fn as_channel(&self) -> &fdomain_client::Channel {
6013        self.client.as_channel()
6014    }
6015}
6016
6017impl AudioDeviceEnumeratorProxy {
6018    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
6019    pub fn new(channel: fdomain_client::Channel) -> Self {
6020        let protocol_name =
6021            <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6022        Self { client: fidl::client::Client::new(channel, protocol_name) }
6023    }
6024
6025    /// Get a Stream of events from the remote end of the protocol.
6026    ///
6027    /// # Panics
6028    ///
6029    /// Panics if the event stream was already taken.
6030    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
6031        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
6032    }
6033
6034    /// Obtain the list of currently active audio devices.
6035    pub fn r#get_devices(
6036        &self,
6037    ) -> fidl::client::QueryResponseFut<
6038        Vec<AudioDeviceInfo>,
6039        fdomain_client::fidl::FDomainResourceDialect,
6040    > {
6041        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
6042    }
6043
6044    /// Gain/Mute/AGC control
6045    ///
6046    /// Note that each of these operations requires a device_token in order to
6047    /// target the proper input/output.
6048    ///
6049    /// The Get command returns the device_token of the device whose gain is
6050    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6051    /// device_token was invalid or the device had been removed from the system
6052    /// before the Get command could be processed.
6053    ///
6054    /// Set commands which are given an invalid device token are ignored and
6055    /// have no effect on the system. In addition, users do not need to control
6056    /// all of the gain settings for an audio device with each call. Only the
6057    /// settings with a corresponding flag set in the set_flags parameter will
6058    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6059    /// a SetDeviceGain call to care only about the mute setting in the
6060    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6061    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6062    /// status to be changed simultaneously.
6063    pub fn r#get_device_gain(
6064        &self,
6065        mut device_token: u64,
6066    ) -> fidl::client::QueryResponseFut<
6067        (u64, AudioGainInfo),
6068        fdomain_client::fidl::FDomainResourceDialect,
6069    > {
6070        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
6071    }
6072
6073    pub fn r#set_device_gain(
6074        &self,
6075        mut device_token: u64,
6076        mut gain_info: &AudioGainInfo,
6077        mut valid_flags: AudioGainValidFlags,
6078    ) -> Result<(), fidl::Error> {
6079        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
6080            self,
6081            device_token,
6082            gain_info,
6083            valid_flags,
6084        )
6085    }
6086
6087    /// # Deprecation
6088    ///
6089    /// StreamConfig is not supported anymore, instead use an
6090    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6091    /// , see
6092    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6093    pub fn r#add_device_by_channel(
6094        &self,
6095        mut device_name: &str,
6096        mut is_input: bool,
6097        mut channel: fdomain_client::fidl::ClientEnd<
6098            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
6099        >,
6100    ) -> Result<(), fidl::Error> {
6101        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
6102            self,
6103            device_name,
6104            is_input,
6105            channel,
6106        )
6107    }
6108}
6109
6110impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
6111    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
6112        Vec<AudioDeviceInfo>,
6113        fdomain_client::fidl::FDomainResourceDialect,
6114    >;
6115    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
6116        fn _decode(
6117            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6118        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6119            let _response = fidl::client::decode_transaction_body::<
6120                AudioDeviceEnumeratorGetDevicesResponse,
6121                fdomain_client::fidl::FDomainResourceDialect,
6122                0x4ce1aa218aeb12a6,
6123            >(_buf?)?;
6124            Ok(_response.devices)
6125        }
6126        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
6127            (),
6128            0x4ce1aa218aeb12a6,
6129            fidl::encoding::DynamicFlags::empty(),
6130            _decode,
6131        )
6132    }
6133
6134    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
6135        (u64, AudioGainInfo),
6136        fdomain_client::fidl::FDomainResourceDialect,
6137    >;
6138    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
6139        fn _decode(
6140            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6141        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
6142            let _response = fidl::client::decode_transaction_body::<
6143                AudioDeviceEnumeratorGetDeviceGainResponse,
6144                fdomain_client::fidl::FDomainResourceDialect,
6145                0x25dd4723403c414b,
6146            >(_buf?)?;
6147            Ok((_response.device_token, _response.gain_info))
6148        }
6149        self.client.send_query_and_decode::<
6150            AudioDeviceEnumeratorGetDeviceGainRequest,
6151            (u64, AudioGainInfo),
6152        >(
6153            (device_token,),
6154            0x25dd4723403c414b,
6155            fidl::encoding::DynamicFlags::empty(),
6156            _decode,
6157        )
6158    }
6159
6160    fn r#set_device_gain(
6161        &self,
6162        mut device_token: u64,
6163        mut gain_info: &AudioGainInfo,
6164        mut valid_flags: AudioGainValidFlags,
6165    ) -> Result<(), fidl::Error> {
6166        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
6167            (device_token, gain_info, valid_flags),
6168            0x5bdabc8ebe83591,
6169            fidl::encoding::DynamicFlags::empty(),
6170        )
6171    }
6172
6173    fn r#add_device_by_channel(
6174        &self,
6175        mut device_name: &str,
6176        mut is_input: bool,
6177        mut channel: fdomain_client::fidl::ClientEnd<
6178            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
6179        >,
6180    ) -> Result<(), fidl::Error> {
6181        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
6182            (device_name, is_input, channel),
6183            0x72cdbada4d70ed67,
6184            fidl::encoding::DynamicFlags::empty(),
6185        )
6186    }
6187}
6188
6189pub struct AudioDeviceEnumeratorEventStream {
6190    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
6191}
6192
6193impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
6194
6195impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
6196    fn is_terminated(&self) -> bool {
6197        self.event_receiver.is_terminated()
6198    }
6199}
6200
6201impl futures::Stream for AudioDeviceEnumeratorEventStream {
6202    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
6203
6204    fn poll_next(
6205        mut self: std::pin::Pin<&mut Self>,
6206        cx: &mut std::task::Context<'_>,
6207    ) -> std::task::Poll<Option<Self::Item>> {
6208        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6209            &mut self.event_receiver,
6210            cx
6211        )?) {
6212            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
6213            None => std::task::Poll::Ready(None),
6214        }
6215    }
6216}
6217
6218#[derive(Debug)]
6219pub enum AudioDeviceEnumeratorEvent {
6220    OnDeviceAdded { device: AudioDeviceInfo },
6221    OnDeviceRemoved { device_token: u64 },
6222    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
6223    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
6224}
6225
6226impl AudioDeviceEnumeratorEvent {
6227    #[allow(irrefutable_let_patterns)]
6228    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
6229        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
6230            Some((device))
6231        } else {
6232            None
6233        }
6234    }
6235    #[allow(irrefutable_let_patterns)]
6236    pub fn into_on_device_removed(self) -> Option<u64> {
6237        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
6238            Some((device_token))
6239        } else {
6240            None
6241        }
6242    }
6243    #[allow(irrefutable_let_patterns)]
6244    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
6245        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
6246            Some((device_token, gain_info))
6247        } else {
6248            None
6249        }
6250    }
6251    #[allow(irrefutable_let_patterns)]
6252    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
6253        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
6254            old_default_token,
6255            new_default_token,
6256        } = self
6257        {
6258            Some((old_default_token, new_default_token))
6259        } else {
6260            None
6261        }
6262    }
6263
6264    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
6265    fn decode(
6266        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6267    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6268        let (bytes, _handles) = buf.split_mut();
6269        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6270        debug_assert_eq!(tx_header.tx_id, 0);
6271        match tx_header.ordinal {
6272            0xe0fbe40057c4b44 => {
6273                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceAddedRequest, fdomain_client::fidl::FDomainResourceDialect);
6274                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6275                Ok((
6276                    AudioDeviceEnumeratorEvent::OnDeviceAdded {device: out.device,
6277
6278                    }
6279                ))
6280            }
6281            0x6f3b7574463d9ff8 => {
6282                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceRemovedRequest, fdomain_client::fidl::FDomainResourceDialect);
6283                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6284                Ok((
6285                    AudioDeviceEnumeratorEvent::OnDeviceRemoved {device_token: out.device_token,
6286
6287                    }
6288                ))
6289            }
6290            0x14aefcbbb076b0e9 => {
6291                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceGainChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6292                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6293                Ok((
6294                    AudioDeviceEnumeratorEvent::OnDeviceGainChanged {device_token: out.device_token,
6295gain_info: out.gain_info,
6296
6297                    }
6298                ))
6299            }
6300            0x16357b42d4c16e11 => {
6301                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDefaultDeviceChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6302                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6303                Ok((
6304                    AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {old_default_token: out.old_default_token,
6305new_default_token: out.new_default_token,
6306
6307                    }
6308                ))
6309            }
6310            _ => Err(fidl::Error::UnknownOrdinal {
6311                ordinal: tx_header.ordinal,
6312                protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6313            })
6314        }
6315    }
6316}
6317
6318/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
6319pub struct AudioDeviceEnumeratorRequestStream {
6320    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6321    is_terminated: bool,
6322}
6323
6324impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
6325
6326impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
6327    fn is_terminated(&self) -> bool {
6328        self.is_terminated
6329    }
6330}
6331
6332impl fdomain_client::fidl::RequestStream for AudioDeviceEnumeratorRequestStream {
6333    type Protocol = AudioDeviceEnumeratorMarker;
6334    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6335
6336    fn from_channel(channel: fdomain_client::Channel) -> Self {
6337        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6338    }
6339
6340    fn control_handle(&self) -> Self::ControlHandle {
6341        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
6342    }
6343
6344    fn into_inner(
6345        self,
6346    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
6347    {
6348        (self.inner, self.is_terminated)
6349    }
6350
6351    fn from_inner(
6352        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6353        is_terminated: bool,
6354    ) -> Self {
6355        Self { inner, is_terminated }
6356    }
6357}
6358
6359impl futures::Stream for AudioDeviceEnumeratorRequestStream {
6360    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
6361
6362    fn poll_next(
6363        mut self: std::pin::Pin<&mut Self>,
6364        cx: &mut std::task::Context<'_>,
6365    ) -> std::task::Poll<Option<Self::Item>> {
6366        let this = &mut *self;
6367        if this.inner.check_shutdown(cx) {
6368            this.is_terminated = true;
6369            return std::task::Poll::Ready(None);
6370        }
6371        if this.is_terminated {
6372            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
6373        }
6374        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
6375            |bytes, handles| {
6376                match this.inner.channel().read_etc(cx, bytes, handles) {
6377                    std::task::Poll::Ready(Ok(())) => {}
6378                    std::task::Poll::Pending => return std::task::Poll::Pending,
6379                    std::task::Poll::Ready(Err(None)) => {
6380                        this.is_terminated = true;
6381                        return std::task::Poll::Ready(None);
6382                    }
6383                    std::task::Poll::Ready(Err(Some(e))) => {
6384                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6385                            e.into(),
6386                        ))));
6387                    }
6388                }
6389
6390                // A message has been received from the channel
6391                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6392
6393                std::task::Poll::Ready(Some(match header.ordinal {
6394                0x4ce1aa218aeb12a6 => {
6395                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6396                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
6397                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6398                    let control_handle = AudioDeviceEnumeratorControlHandle {
6399                        inner: this.inner.clone(),
6400                    };
6401                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
6402                        responder: AudioDeviceEnumeratorGetDevicesResponder {
6403                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6404                            tx_id: header.tx_id,
6405                        },
6406                    })
6407                }
6408                0x25dd4723403c414b => {
6409                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6410                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6411                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6412                    let control_handle = AudioDeviceEnumeratorControlHandle {
6413                        inner: this.inner.clone(),
6414                    };
6415                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
6416
6417                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
6418                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6419                            tx_id: header.tx_id,
6420                        },
6421                    })
6422                }
6423                0x5bdabc8ebe83591 => {
6424                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6425                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6426                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6427                    let control_handle = AudioDeviceEnumeratorControlHandle {
6428                        inner: this.inner.clone(),
6429                    };
6430                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
6431gain_info: req.gain_info,
6432valid_flags: req.valid_flags,
6433
6434                        control_handle,
6435                    })
6436                }
6437                0x72cdbada4d70ed67 => {
6438                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6439                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fdomain_client::fidl::FDomainResourceDialect);
6440                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
6441                    let control_handle = AudioDeviceEnumeratorControlHandle {
6442                        inner: this.inner.clone(),
6443                    };
6444                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
6445is_input: req.is_input,
6446channel: req.channel,
6447
6448                        control_handle,
6449                    })
6450                }
6451                _ => Err(fidl::Error::UnknownOrdinal {
6452                    ordinal: header.ordinal,
6453                    protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6454                }),
6455            }))
6456            },
6457        )
6458    }
6459}
6460
6461#[derive(Debug)]
6462pub enum AudioDeviceEnumeratorRequest {
6463    /// Obtain the list of currently active audio devices.
6464    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
6465    /// Gain/Mute/AGC control
6466    ///
6467    /// Note that each of these operations requires a device_token in order to
6468    /// target the proper input/output.
6469    ///
6470    /// The Get command returns the device_token of the device whose gain is
6471    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6472    /// device_token was invalid or the device had been removed from the system
6473    /// before the Get command could be processed.
6474    ///
6475    /// Set commands which are given an invalid device token are ignored and
6476    /// have no effect on the system. In addition, users do not need to control
6477    /// all of the gain settings for an audio device with each call. Only the
6478    /// settings with a corresponding flag set in the set_flags parameter will
6479    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6480    /// a SetDeviceGain call to care only about the mute setting in the
6481    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6482    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6483    /// status to be changed simultaneously.
6484    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
6485    SetDeviceGain {
6486        device_token: u64,
6487        gain_info: AudioGainInfo,
6488        valid_flags: AudioGainValidFlags,
6489        control_handle: AudioDeviceEnumeratorControlHandle,
6490    },
6491    /// # Deprecation
6492    ///
6493    /// StreamConfig is not supported anymore, instead use an
6494    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6495    /// , see
6496    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6497    AddDeviceByChannel {
6498        device_name: String,
6499        is_input: bool,
6500        channel:
6501            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6502        control_handle: AudioDeviceEnumeratorControlHandle,
6503    },
6504}
6505
6506impl AudioDeviceEnumeratorRequest {
6507    #[allow(irrefutable_let_patterns)]
6508    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
6509        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
6510            Some((responder))
6511        } else {
6512            None
6513        }
6514    }
6515
6516    #[allow(irrefutable_let_patterns)]
6517    pub fn into_get_device_gain(
6518        self,
6519    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
6520        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
6521            Some((device_token, responder))
6522        } else {
6523            None
6524        }
6525    }
6526
6527    #[allow(irrefutable_let_patterns)]
6528    pub fn into_set_device_gain(
6529        self,
6530    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
6531        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
6532            device_token,
6533            gain_info,
6534            valid_flags,
6535            control_handle,
6536        } = self
6537        {
6538            Some((device_token, gain_info, valid_flags, control_handle))
6539        } else {
6540            None
6541        }
6542    }
6543
6544    #[allow(irrefutable_let_patterns)]
6545    pub fn into_add_device_by_channel(
6546        self,
6547    ) -> Option<(
6548        String,
6549        bool,
6550        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6551        AudioDeviceEnumeratorControlHandle,
6552    )> {
6553        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
6554            device_name,
6555            is_input,
6556            channel,
6557            control_handle,
6558        } = self
6559        {
6560            Some((device_name, is_input, channel, control_handle))
6561        } else {
6562            None
6563        }
6564    }
6565
6566    /// Name of the method defined in FIDL
6567    pub fn method_name(&self) -> &'static str {
6568        match *self {
6569            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
6570            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
6571            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
6572            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
6573        }
6574    }
6575}
6576
6577#[derive(Debug, Clone)]
6578pub struct AudioDeviceEnumeratorControlHandle {
6579    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6580}
6581
6582impl fdomain_client::fidl::ControlHandle for AudioDeviceEnumeratorControlHandle {
6583    fn shutdown(&self) {
6584        self.inner.shutdown()
6585    }
6586
6587    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6588        self.inner.shutdown_with_epitaph(status)
6589    }
6590
6591    fn is_closed(&self) -> bool {
6592        self.inner.channel().is_closed()
6593    }
6594    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6595        self.inner.channel().on_closed()
6596    }
6597}
6598
6599impl AudioDeviceEnumeratorControlHandle {
6600    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
6601        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
6602            (device,),
6603            0,
6604            0xe0fbe40057c4b44,
6605            fidl::encoding::DynamicFlags::empty(),
6606        )
6607    }
6608
6609    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
6610        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
6611            (device_token,),
6612            0,
6613            0x6f3b7574463d9ff8,
6614            fidl::encoding::DynamicFlags::empty(),
6615        )
6616    }
6617
6618    pub fn send_on_device_gain_changed(
6619        &self,
6620        mut device_token: u64,
6621        mut gain_info: &AudioGainInfo,
6622    ) -> Result<(), fidl::Error> {
6623        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
6624            (device_token, gain_info),
6625            0,
6626            0x14aefcbbb076b0e9,
6627            fidl::encoding::DynamicFlags::empty(),
6628        )
6629    }
6630
6631    pub fn send_on_default_device_changed(
6632        &self,
6633        mut old_default_token: u64,
6634        mut new_default_token: u64,
6635    ) -> Result<(), fidl::Error> {
6636        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
6637            (old_default_token, new_default_token),
6638            0,
6639            0x16357b42d4c16e11,
6640            fidl::encoding::DynamicFlags::empty(),
6641        )
6642    }
6643}
6644
6645#[must_use = "FIDL methods require a response to be sent"]
6646#[derive(Debug)]
6647pub struct AudioDeviceEnumeratorGetDevicesResponder {
6648    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6649    tx_id: u32,
6650}
6651
6652/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6653/// if the responder is dropped without sending a response, so that the client
6654/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6655impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
6656    fn drop(&mut self) {
6657        self.control_handle.shutdown();
6658        // Safety: drops once, never accessed again
6659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6660    }
6661}
6662
6663impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDevicesResponder {
6664    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6665
6666    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6667        &self.control_handle
6668    }
6669
6670    fn drop_without_shutdown(mut self) {
6671        // Safety: drops once, never accessed again due to mem::forget
6672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6673        // Prevent Drop from running (which would shut down the channel)
6674        std::mem::forget(self);
6675    }
6676}
6677
6678impl AudioDeviceEnumeratorGetDevicesResponder {
6679    /// Sends a response to the FIDL transaction.
6680    ///
6681    /// Sets the channel to shutdown if an error occurs.
6682    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6683        let _result = self.send_raw(devices);
6684        if _result.is_err() {
6685            self.control_handle.shutdown();
6686        }
6687        self.drop_without_shutdown();
6688        _result
6689    }
6690
6691    /// Similar to "send" but does not shutdown the channel if an error occurs.
6692    pub fn send_no_shutdown_on_err(
6693        self,
6694        mut devices: &[AudioDeviceInfo],
6695    ) -> Result<(), fidl::Error> {
6696        let _result = self.send_raw(devices);
6697        self.drop_without_shutdown();
6698        _result
6699    }
6700
6701    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6702        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
6703            (devices,),
6704            self.tx_id,
6705            0x4ce1aa218aeb12a6,
6706            fidl::encoding::DynamicFlags::empty(),
6707        )
6708    }
6709}
6710
6711#[must_use = "FIDL methods require a response to be sent"]
6712#[derive(Debug)]
6713pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
6714    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6715    tx_id: u32,
6716}
6717
6718/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6719/// if the responder is dropped without sending a response, so that the client
6720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6721impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
6722    fn drop(&mut self) {
6723        self.control_handle.shutdown();
6724        // Safety: drops once, never accessed again
6725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6726    }
6727}
6728
6729impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
6730    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6731
6732    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6733        &self.control_handle
6734    }
6735
6736    fn drop_without_shutdown(mut self) {
6737        // Safety: drops once, never accessed again due to mem::forget
6738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6739        // Prevent Drop from running (which would shut down the channel)
6740        std::mem::forget(self);
6741    }
6742}
6743
6744impl AudioDeviceEnumeratorGetDeviceGainResponder {
6745    /// Sends a response to the FIDL transaction.
6746    ///
6747    /// Sets the channel to shutdown if an error occurs.
6748    pub fn send(
6749        self,
6750        mut device_token: u64,
6751        mut gain_info: &AudioGainInfo,
6752    ) -> Result<(), fidl::Error> {
6753        let _result = self.send_raw(device_token, gain_info);
6754        if _result.is_err() {
6755            self.control_handle.shutdown();
6756        }
6757        self.drop_without_shutdown();
6758        _result
6759    }
6760
6761    /// Similar to "send" but does not shutdown the channel if an error occurs.
6762    pub fn send_no_shutdown_on_err(
6763        self,
6764        mut device_token: u64,
6765        mut gain_info: &AudioGainInfo,
6766    ) -> Result<(), fidl::Error> {
6767        let _result = self.send_raw(device_token, gain_info);
6768        self.drop_without_shutdown();
6769        _result
6770    }
6771
6772    fn send_raw(
6773        &self,
6774        mut device_token: u64,
6775        mut gain_info: &AudioGainInfo,
6776    ) -> Result<(), fidl::Error> {
6777        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
6778            (device_token, gain_info),
6779            self.tx_id,
6780            0x25dd4723403c414b,
6781            fidl::encoding::DynamicFlags::empty(),
6782        )
6783    }
6784}
6785
6786#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6787pub struct AudioRendererMarker;
6788
6789impl fdomain_client::fidl::ProtocolMarker for AudioRendererMarker {
6790    type Proxy = AudioRendererProxy;
6791    type RequestStream = AudioRendererRequestStream;
6792
6793    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
6794}
6795impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioRendererMarker {}
6796
6797pub trait AudioRendererProxyInterface: Send + Sync {
6798    fn r#add_payload_buffer(
6799        &self,
6800        id: u32,
6801        payload_buffer: fdomain_client::Vmo,
6802    ) -> Result<(), fidl::Error>;
6803    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
6804    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6805    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
6806    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
6807    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
6808    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6809    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
6810    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
6811    fn r#bind_gain_control(
6812        &self,
6813        gain_control_request: fdomain_client::fidl::ServerEnd<
6814            fdomain_fuchsia_media_audio::GainControlMarker,
6815        >,
6816    ) -> Result<(), fidl::Error>;
6817    fn r#set_pts_units(
6818        &self,
6819        tick_per_second_numerator: u32,
6820        tick_per_second_denominator: u32,
6821    ) -> Result<(), fidl::Error>;
6822    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
6823    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
6824        + Send;
6825    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
6826    fn r#set_reference_clock(
6827        &self,
6828        reference_clock: Option<fdomain_client::Clock>,
6829    ) -> Result<(), fidl::Error>;
6830    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
6831    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
6832    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
6833    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
6834    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
6835    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
6836    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6837    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
6838    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
6839    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6840    fn r#pause(&self) -> Self::PauseResponseFut;
6841    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
6842}
6843
6844#[derive(Debug, Clone)]
6845pub struct AudioRendererProxy {
6846    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6847}
6848
6849impl fdomain_client::fidl::Proxy for AudioRendererProxy {
6850    type Protocol = AudioRendererMarker;
6851
6852    fn from_channel(inner: fdomain_client::Channel) -> Self {
6853        Self::new(inner)
6854    }
6855
6856    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6857        self.client.into_channel().map_err(|client| Self { client })
6858    }
6859
6860    fn as_channel(&self) -> &fdomain_client::Channel {
6861        self.client.as_channel()
6862    }
6863}
6864
6865impl AudioRendererProxy {
6866    /// Create a new Proxy for fuchsia.media/AudioRenderer.
6867    pub fn new(channel: fdomain_client::Channel) -> Self {
6868        let protocol_name =
6869            <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6870        Self { client: fidl::client::Client::new(channel, protocol_name) }
6871    }
6872
6873    /// Get a Stream of events from the remote end of the protocol.
6874    ///
6875    /// # Panics
6876    ///
6877    /// Panics if the event stream was already taken.
6878    pub fn take_event_stream(&self) -> AudioRendererEventStream {
6879        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
6880    }
6881
6882    /// Adds a payload buffer to the current buffer set associated with the
6883    /// connection. A `StreamPacket` struct reference a payload buffer in the
6884    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
6885    ///
6886    /// A buffer with ID `id` must not be in the current set when this method is
6887    /// invoked, otherwise the service will close the connection.
6888    pub fn r#add_payload_buffer(
6889        &self,
6890        mut id: u32,
6891        mut payload_buffer: fdomain_client::Vmo,
6892    ) -> Result<(), fidl::Error> {
6893        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
6894    }
6895
6896    /// Removes a payload buffer from the current buffer set associated with the
6897    /// connection.
6898    ///
6899    /// A buffer with ID `id` must exist in the current set when this method is
6900    /// invoked, otherwise the service will will close the connection.
6901    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
6902        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
6903    }
6904
6905    /// Sends a packet to the service. The response is sent when the service is
6906    /// done with the associated payload memory.
6907    ///
6908    /// `packet` must be valid for the current buffer set, otherwise the service
6909    /// will close the connection.
6910    pub fn r#send_packet(
6911        &self,
6912        mut packet: &StreamPacket,
6913    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6914        AudioRendererProxyInterface::r#send_packet(self, packet)
6915    }
6916
6917    /// Sends a packet to the service. This interface doesn't define how the
6918    /// client knows when the sink is done with the associated payload memory.
6919    /// The inheriting interface must define that.
6920    ///
6921    /// `packet` must be valid for the current buffer set, otherwise the service
6922    /// will close the connection.
6923    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
6924        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
6925    }
6926
6927    /// Indicates the stream has ended. The precise semantics of this method are
6928    /// determined by the inheriting interface.
6929    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
6930        AudioRendererProxyInterface::r#end_of_stream(self)
6931    }
6932
6933    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6934    /// and not yet released. The response is sent after all packets have been
6935    /// released.
6936    pub fn r#discard_all_packets(
6937        &self,
6938    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6939        AudioRendererProxyInterface::r#discard_all_packets(self)
6940    }
6941
6942    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6943    /// and not yet released.
6944    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
6945        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
6946    }
6947
6948    /// Binds to the gain control for this AudioRenderer.
6949    pub fn r#bind_gain_control(
6950        &self,
6951        mut gain_control_request: fdomain_client::fidl::ServerEnd<
6952            fdomain_fuchsia_media_audio::GainControlMarker,
6953        >,
6954    ) -> Result<(), fidl::Error> {
6955        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
6956    }
6957
6958    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
6959    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
6960    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
6961    pub fn r#set_pts_units(
6962        &self,
6963        mut tick_per_second_numerator: u32,
6964        mut tick_per_second_denominator: u32,
6965    ) -> Result<(), fidl::Error> {
6966        AudioRendererProxyInterface::r#set_pts_units(
6967            self,
6968            tick_per_second_numerator,
6969            tick_per_second_denominator,
6970        )
6971    }
6972
6973    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
6974    /// and expected PTS (determined using interpolation). Beyond this threshold,
6975    /// a stream is no longer considered 'continuous' by the renderer.
6976    ///
6977    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
6978    /// Most users should not need to change this value from its default.
6979    ///
6980    /// Example:
6981    /// A user is playing back 48KHz audio from a container, which also contains
6982    /// video and needs to be synchronized with the audio. The timestamps are
6983    /// provided explicitly per packet by the container, and expressed in mSec
6984    /// units. This means that a single tick of the media timeline (1 mSec)
6985    /// represents exactly 48 frames of audio. The application in this scenario
6986    /// delivers packets of audio to the AudioRenderer, each with exactly 470
6987    /// frames of audio, and each with an explicit timestamp set to the best
6988    /// possible representation of the presentation time (given this media
6989    /// clock's resolution). So, starting from zero, the timestamps would be..
6990    ///
6991    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
6992    ///
6993    /// In this example, attempting to use the presentation time to compute the
6994    /// starting frame number of the audio in the packet would be wrong the
6995    /// majority of the time. The first timestamp is correct (by definition), but
6996    /// it will be 24 packets before the timestamps and frame numbers come back
6997    /// into alignment (the 24th packet would start with the 11280th audio frame
6998    /// and have a PTS of exactly 235).
6999    ///
7000    /// One way to fix this situation is to set the PTS continuity threshold
7001    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
7002    /// the number of frames contained within a single tick of the media clock,
7003    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
7004    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
7005    /// explicitly provided PTS would be considered to be a continuation of the
7006    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
7007    /// would work well.
7008    ///
7009    /// Other possible uses:
7010    /// Users who are scheduling audio explicitly, relative to a clock which has
7011    /// not been configured as the reference clock, can use this value to control
7012    /// the maximum acceptable synchronization error before a discontinuity is
7013    /// introduced. E.g., if a user is scheduling audio based on a recovered
7014    /// common media clock, and has not published that clock as the reference
7015    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
7016    /// can accumulate before the AudioRenderer deliberately inserts a
7017    /// presentation discontinuity to account for the error.
7018    ///
7019    /// Users whose need to deal with a container where their timestamps may be
7020    /// even less correct than +/- 1/2 of a PTS tick may set this value to
7021    /// something larger. This should be the maximum level of inaccuracy present
7022    /// in the container timestamps, if known. Failing that, it could be set to
7023    /// the maximum tolerable level of drift error before absolute timestamps are
7024    /// explicitly obeyed. Finally, a user could set this number to a very large
7025    /// value (86400.0 seconds, for example) to effectively cause *all*
7026    /// timestamps to be ignored after the first, thus treating all audio as
7027    /// continuous with previously delivered packets. Conversely, users who wish
7028    /// to *always* explicitly schedule their audio packets exactly may specify
7029    /// a CT of 0.
7030    ///
7031    /// Note: explicitly specifying high-frequency PTS units reduces the default
7032    /// continuity threshold accordingly. Internally, this threshold is stored as an
7033    /// integer of 1/8192 subframes. The default threshold is computed as follows:
7034    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
7035    /// For this reason, specifying PTS units with a frequency greater than 8192x
7036    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
7037    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
7038    pub fn r#set_pts_continuity_threshold(
7039        &self,
7040        mut threshold_seconds: f32,
7041    ) -> Result<(), fidl::Error> {
7042        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
7043    }
7044
7045    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
7046    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
7047    pub fn r#get_reference_clock(
7048        &self,
7049    ) -> fidl::client::QueryResponseFut<
7050        fdomain_client::Clock,
7051        fdomain_client::fidl::FDomainResourceDialect,
7052    > {
7053        AudioRendererProxyInterface::r#get_reference_clock(self)
7054    }
7055
7056    /// Sets the reference clock that controls this renderer's playback rate. If the input
7057    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
7058    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
7059    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
7060    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
7061    ///
7062    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
7063    /// cannot be called a second time (even if the renderer format has not yet been set).
7064    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
7065    /// diverge at some later time, they should create a clone of the monotonic clock, set
7066    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
7067    pub fn r#set_reference_clock(
7068        &self,
7069        mut reference_clock: Option<fdomain_client::Clock>,
7070    ) -> Result<(), fidl::Error> {
7071        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
7072    }
7073
7074    /// Sets the usage of the render stream. This method may not be called after
7075    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7076    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
7077        AudioRendererProxyInterface::r#set_usage(self, usage)
7078    }
7079
7080    /// Sets the usage of the render stream. This method may not be called after
7081    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7082    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
7083        AudioRendererProxyInterface::r#set_usage2(self, usage2)
7084    }
7085
7086    /// Sets the type of the stream to be delivered by the client. Using this method implies
7087    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
7088    ///
7089    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
7090    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
7091    /// methods such as `SendPacket`/`SendPacketNoReply`.
7092    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
7093        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
7094    }
7095
7096    /// Enables or disables notifications about changes to the minimum clock lead
7097    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
7098    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
7099    /// event with the current minimum lead time for the AudioRenderer. If the
7100    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
7101    /// new value. This behavior will continue until the user calls
7102    /// `EnableMinLeadTimeEvents(false)`.
7103    ///
7104    /// The minimum clock lead time is the amount of time ahead of the reference
7105    /// clock's understanding of "now" that packets needs to arrive (relative to
7106    /// the playback clock transformation) in order for the mixer to be able to
7107    /// mix packet. For example...
7108    ///
7109    /// + Let the PTS of packet X be P(X)
7110    /// + Let the function which transforms PTS -> RefClock be R(p) (this
7111    ///   function is determined by the call to Play(...)
7112    /// + Let the minimum lead time be MLT
7113    ///
7114    /// If R(P(X)) < RefClock.Now() + MLT
7115    /// Then the packet is late, and some (or all) of the packet's payload will
7116    /// need to be skipped in order to present the packet at the scheduled time.
7117    ///
7118    /// The value `min_lead_time_nsec = 0` is a special value which indicates
7119    /// that the AudioRenderer is not yet routed to an output device. If `Play`
7120    /// is called before the AudioRenderer is routed, any played packets will be
7121    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
7122    /// calling `Play`.
7123    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7124        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
7125    }
7126
7127    ///
7128    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
7129    /// there's little reason to do so. This is because lead time is a function
7130    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
7131    /// If min lead time events are enabled before `SetPcmStreamType` (with
7132    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
7133    /// response to `SetPcmStreamType`.
7134    pub fn r#get_min_lead_time(
7135        &self,
7136    ) -> fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect> {
7137        AudioRendererProxyInterface::r#get_min_lead_time(self)
7138    }
7139
7140    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
7141    /// of the media timeline, using specific values provided by the caller (or
7142    /// default values if not specified). In an optional callback, returns the
7143    /// timestamp values ultimately used -- these set the ongoing relationship
7144    /// between the media and reference timelines (i.e., how to translate between
7145    /// the domain of presentation timestamps, and the realm of local system
7146    /// time).
7147    ///
7148    /// Local system time is specified in units of nanoseconds; media_time is
7149    /// specified in the units defined by the user in the `SetPtsUnits` function,
7150    /// or nanoseconds if `SetPtsUnits` is not called.
7151    ///
7152    /// The act of placing an AudioRenderer into the playback state establishes a
7153    /// relationship between 1) the user-defined media (or presentation) timeline
7154    /// for this particular AudioRenderer, and 2) the real-world system reference
7155    /// timeline. To communicate how to translate between timelines, the Play()
7156    /// callback provides an equivalent timestamp in each time domain. The first
7157    /// value ('reference_time') is given in terms of this renderer's reference
7158    /// clock; the second value ('media_time') is what media instant exactly
7159    /// corresponds to that local time. Restated, the frame at 'media_time' in
7160    /// the audio stream should be presented at 'reference_time' according to
7161    /// the reference clock.
7162    ///
7163    /// Note: on calling this API, media_time immediately starts advancing. It is
7164    /// possible (if uncommon) for a caller to specify a system time that is
7165    /// far in the past, or far into the future. This, along with the specified
7166    /// media time, is simply used to determine what media time corresponds to
7167    /// 'now', and THAT media time is then intersected with presentation
7168    /// timestamps of packets already submitted, to determine which media frames
7169    /// should be presented next.
7170    ///
7171    /// With the corresponding reference_time and media_time values, a user can
7172    /// translate arbitrary time values from one timeline into the other. After
7173    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
7174    /// given the 'ref_start' and 'media_start' values from `Play`, then for
7175    /// any 'ref_time':
7176    ///
7177    /// media_time = ( (ref_time - ref_start) / 1e9
7178    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
7179    ///              + media_start
7180    ///
7181    /// Conversely, for any presentation timestamp 'media_time':
7182    ///
7183    /// ref_time = ( (media_time - media_start)
7184    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
7185    ///              * 1e9 )
7186    ///            + ref_start
7187    ///
7188    /// Users, depending on their use case, may optionally choose not to specify
7189    /// one or both of these timestamps. A timestamp may be omitted by supplying
7190    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
7191    /// any omitted timestamp value using the following rules:
7192    ///
7193    /// Reference Time
7194    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
7195    /// reference time to begin presentation, based on the minimum lead times for
7196    /// the output devices that are currently bound to this AudioRenderer. For
7197    /// example, if an AudioRenderer is bound to an internal audio output
7198    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
7199    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
7200    /// is omitted) select a reference time 80 mSec from now.
7201    ///
7202    /// Media Time
7203    /// If media_time is omitted, the AudioRenderer will select one of two
7204    /// values.
7205    /// - If the AudioRenderer is resuming from the paused state, and packets
7206    /// have not been discarded since being paused, then the AudioRenderer will
7207    /// use a media_time corresponding to the instant at which the presentation
7208    /// became paused.
7209    /// - If the AudioRenderer is being placed into a playing state for the first
7210    /// time following startup or a 'discard packets' operation, the initial
7211    /// media_time will be set to the PTS of the first payload in the pending
7212    /// packet queue. If the pending queue is empty, initial media_time will be
7213    /// set to zero.
7214    ///
7215    /// Return Value
7216    /// When requested, the AudioRenderer will return the 'reference_time' and
7217    /// 'media_time' which were selected and used (whether they were explicitly
7218    /// specified or not) in the return value of the play call.
7219    ///
7220    /// Examples
7221    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
7222    /// to start playing as soon as possible. The user may call Play without
7223    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
7224    ///
7225    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
7226    /// playback at a specified 'reference_time', in sync with some other media
7227    /// stream, either initially or after discarding packets. The user would call
7228    /// `Play(reference_time, NO_TIMESTAMP)`.
7229    ///
7230    /// 3. A user has queued some audio using `SendPacket`. The first of these
7231    /// packets has a PTS of zero, and the user wishes playback to begin as soon
7232    /// as possible, but wishes to skip all of the audio content between PTS 0
7233    /// and PTS 'media_time'. The user would call
7234    /// `Play(NO_TIMESTAMP, media_time)`.
7235    ///
7236    /// 4. A user has queued some audio using `SendPacket` and want to present
7237    /// this media in synch with another player in a different device. The
7238    /// coordinator of the group of distributed players sends an explicit
7239    /// message to each player telling them to begin presentation of audio at
7240    /// PTS 'media_time', at the time (based on the group's shared reference
7241    /// clock) 'reference_time'. Here the user would call
7242    /// `Play(reference_time, media_time)`.
7243    pub fn r#play(
7244        &self,
7245        mut reference_time: i64,
7246        mut media_time: i64,
7247    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
7248    {
7249        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
7250    }
7251
7252    pub fn r#play_no_reply(
7253        &self,
7254        mut reference_time: i64,
7255        mut media_time: i64,
7256    ) -> Result<(), fidl::Error> {
7257        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
7258    }
7259
7260    /// Immediately puts the AudioRenderer into the paused state and then report
7261    /// the relationship between the media and reference timelines which was
7262    /// established (if requested).
7263    ///
7264    /// If the AudioRenderer is already in the paused state when this called,
7265    /// the previously-established timeline values are returned (if requested).
7266    pub fn r#pause(
7267        &self,
7268    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
7269    {
7270        AudioRendererProxyInterface::r#pause(self)
7271    }
7272
7273    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
7274        AudioRendererProxyInterface::r#pause_no_reply(self)
7275    }
7276}
7277
7278impl AudioRendererProxyInterface for AudioRendererProxy {
7279    fn r#add_payload_buffer(
7280        &self,
7281        mut id: u32,
7282        mut payload_buffer: fdomain_client::Vmo,
7283    ) -> Result<(), fidl::Error> {
7284        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7285            (id, payload_buffer),
7286            0x3b3a37fc34fe5b56,
7287            fidl::encoding::DynamicFlags::empty(),
7288        )
7289    }
7290
7291    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7292        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7293            (id,),
7294            0x5d1e4f74c3658262,
7295            fidl::encoding::DynamicFlags::empty(),
7296        )
7297    }
7298
7299    type SendPacketResponseFut =
7300        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7301    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
7302        fn _decode(
7303            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7304        ) -> Result<(), fidl::Error> {
7305            let _response = fidl::client::decode_transaction_body::<
7306                fidl::encoding::EmptyPayload,
7307                fdomain_client::fidl::FDomainResourceDialect,
7308                0x67cddd607442775f,
7309            >(_buf?)?;
7310            Ok(_response)
7311        }
7312        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
7313            (packet,),
7314            0x67cddd607442775f,
7315            fidl::encoding::DynamicFlags::empty(),
7316            _decode,
7317        )
7318    }
7319
7320    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7321        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7322            (packet,),
7323            0x8d9b8b413ceba9d,
7324            fidl::encoding::DynamicFlags::empty(),
7325        )
7326    }
7327
7328    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
7329        self.client.send::<fidl::encoding::EmptyPayload>(
7330            (),
7331            0x6180fd6f7e793b71,
7332            fidl::encoding::DynamicFlags::empty(),
7333        )
7334    }
7335
7336    type DiscardAllPacketsResponseFut =
7337        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7338    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
7339        fn _decode(
7340            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7341        ) -> Result<(), fidl::Error> {
7342            let _response = fidl::client::decode_transaction_body::<
7343                fidl::encoding::EmptyPayload,
7344                fdomain_client::fidl::FDomainResourceDialect,
7345                0x6f4dad7af2917665,
7346            >(_buf?)?;
7347            Ok(_response)
7348        }
7349        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7350            (),
7351            0x6f4dad7af2917665,
7352            fidl::encoding::DynamicFlags::empty(),
7353            _decode,
7354        )
7355    }
7356
7357    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
7358        self.client.send::<fidl::encoding::EmptyPayload>(
7359            (),
7360            0x50d36d0d23081bc4,
7361            fidl::encoding::DynamicFlags::empty(),
7362        )
7363    }
7364
7365    fn r#bind_gain_control(
7366        &self,
7367        mut gain_control_request: fdomain_client::fidl::ServerEnd<
7368            fdomain_fuchsia_media_audio::GainControlMarker,
7369        >,
7370    ) -> Result<(), fidl::Error> {
7371        self.client.send::<AudioRendererBindGainControlRequest>(
7372            (gain_control_request,),
7373            0x293f5c7f8fba2bdc,
7374            fidl::encoding::DynamicFlags::empty(),
7375        )
7376    }
7377
7378    fn r#set_pts_units(
7379        &self,
7380        mut tick_per_second_numerator: u32,
7381        mut tick_per_second_denominator: u32,
7382    ) -> Result<(), fidl::Error> {
7383        self.client.send::<AudioRendererSetPtsUnitsRequest>(
7384            (tick_per_second_numerator, tick_per_second_denominator),
7385            0xf68cd108785a27c,
7386            fidl::encoding::DynamicFlags::empty(),
7387        )
7388    }
7389
7390    fn r#set_pts_continuity_threshold(
7391        &self,
7392        mut threshold_seconds: f32,
7393    ) -> Result<(), fidl::Error> {
7394        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
7395            (threshold_seconds,),
7396            0x2849ba571d1971ba,
7397            fidl::encoding::DynamicFlags::empty(),
7398        )
7399    }
7400
7401    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
7402        fdomain_client::Clock,
7403        fdomain_client::fidl::FDomainResourceDialect,
7404    >;
7405    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
7406        fn _decode(
7407            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7408        ) -> Result<fdomain_client::Clock, fidl::Error> {
7409            let _response = fidl::client::decode_transaction_body::<
7410                AudioRendererGetReferenceClockResponse,
7411                fdomain_client::fidl::FDomainResourceDialect,
7412                0x2f7a7f011a172f7e,
7413            >(_buf?)?;
7414            Ok(_response.reference_clock)
7415        }
7416        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
7417            (),
7418            0x2f7a7f011a172f7e,
7419            fidl::encoding::DynamicFlags::empty(),
7420            _decode,
7421        )
7422    }
7423
7424    fn r#set_reference_clock(
7425        &self,
7426        mut reference_clock: Option<fdomain_client::Clock>,
7427    ) -> Result<(), fidl::Error> {
7428        self.client.send::<AudioRendererSetReferenceClockRequest>(
7429            (reference_clock,),
7430            0x39acd05d832b5fed,
7431            fidl::encoding::DynamicFlags::empty(),
7432        )
7433    }
7434
7435    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
7436        self.client.send::<AudioRendererSetUsageRequest>(
7437            (usage,),
7438            0x3994bd23b55a733e,
7439            fidl::encoding::DynamicFlags::empty(),
7440        )
7441    }
7442
7443    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
7444        self.client.send::<AudioRendererSetUsage2Request>(
7445            (usage2,),
7446            0x2904035c7132b103,
7447            fidl::encoding::DynamicFlags::FLEXIBLE,
7448        )
7449    }
7450
7451    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
7452        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
7453            (type_,),
7454            0x27aa715d8901fa19,
7455            fidl::encoding::DynamicFlags::empty(),
7456        )
7457    }
7458
7459    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7460        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
7461            (enabled,),
7462            0x62808dfad72bf890,
7463            fidl::encoding::DynamicFlags::empty(),
7464        )
7465    }
7466
7467    type GetMinLeadTimeResponseFut =
7468        fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect>;
7469    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
7470        fn _decode(
7471            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7472        ) -> Result<i64, fidl::Error> {
7473            let _response = fidl::client::decode_transaction_body::<
7474                AudioRendererGetMinLeadTimeResponse,
7475                fdomain_client::fidl::FDomainResourceDialect,
7476                0x1cf3c3ecd8fec26b,
7477            >(_buf?)?;
7478            Ok(_response.min_lead_time_nsec)
7479        }
7480        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
7481            (),
7482            0x1cf3c3ecd8fec26b,
7483            fidl::encoding::DynamicFlags::empty(),
7484            _decode,
7485        )
7486    }
7487
7488    type PlayResponseFut =
7489        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7490    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
7491        fn _decode(
7492            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7493        ) -> Result<(i64, i64), fidl::Error> {
7494            let _response = fidl::client::decode_transaction_body::<
7495                AudioRendererPlayResponse,
7496                fdomain_client::fidl::FDomainResourceDialect,
7497                0x3c0162db084f74a3,
7498            >(_buf?)?;
7499            Ok((_response.reference_time, _response.media_time))
7500        }
7501        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
7502            (reference_time, media_time),
7503            0x3c0162db084f74a3,
7504            fidl::encoding::DynamicFlags::empty(),
7505            _decode,
7506        )
7507    }
7508
7509    fn r#play_no_reply(
7510        &self,
7511        mut reference_time: i64,
7512        mut media_time: i64,
7513    ) -> Result<(), fidl::Error> {
7514        self.client.send::<AudioRendererPlayNoReplyRequest>(
7515            (reference_time, media_time),
7516            0x1b7fe832b68c22ef,
7517            fidl::encoding::DynamicFlags::empty(),
7518        )
7519    }
7520
7521    type PauseResponseFut =
7522        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7523    fn r#pause(&self) -> Self::PauseResponseFut {
7524        fn _decode(
7525            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7526        ) -> Result<(i64, i64), fidl::Error> {
7527            let _response = fidl::client::decode_transaction_body::<
7528                AudioRendererPauseResponse,
7529                fdomain_client::fidl::FDomainResourceDialect,
7530                0x41d557588d93d153,
7531            >(_buf?)?;
7532            Ok((_response.reference_time, _response.media_time))
7533        }
7534        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
7535            (),
7536            0x41d557588d93d153,
7537            fidl::encoding::DynamicFlags::empty(),
7538            _decode,
7539        )
7540    }
7541
7542    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
7543        self.client.send::<fidl::encoding::EmptyPayload>(
7544            (),
7545            0x24cc45d4f3855ab,
7546            fidl::encoding::DynamicFlags::empty(),
7547        )
7548    }
7549}
7550
7551pub struct AudioRendererEventStream {
7552    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7553}
7554
7555impl std::marker::Unpin for AudioRendererEventStream {}
7556
7557impl futures::stream::FusedStream for AudioRendererEventStream {
7558    fn is_terminated(&self) -> bool {
7559        self.event_receiver.is_terminated()
7560    }
7561}
7562
7563impl futures::Stream for AudioRendererEventStream {
7564    type Item = Result<AudioRendererEvent, fidl::Error>;
7565
7566    fn poll_next(
7567        mut self: std::pin::Pin<&mut Self>,
7568        cx: &mut std::task::Context<'_>,
7569    ) -> std::task::Poll<Option<Self::Item>> {
7570        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7571            &mut self.event_receiver,
7572            cx
7573        )?) {
7574            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
7575            None => std::task::Poll::Ready(None),
7576        }
7577    }
7578}
7579
7580#[derive(Debug)]
7581pub enum AudioRendererEvent {
7582    OnMinLeadTimeChanged {
7583        min_lead_time_nsec: i64,
7584    },
7585    #[non_exhaustive]
7586    _UnknownEvent {
7587        /// Ordinal of the event that was sent.
7588        ordinal: u64,
7589    },
7590}
7591
7592impl AudioRendererEvent {
7593    #[allow(irrefutable_let_patterns)]
7594    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
7595        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
7596            Some((min_lead_time_nsec))
7597        } else {
7598            None
7599        }
7600    }
7601
7602    /// Decodes a message buffer as a [`AudioRendererEvent`].
7603    fn decode(
7604        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7605    ) -> Result<AudioRendererEvent, fidl::Error> {
7606        let (bytes, _handles) = buf.split_mut();
7607        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7608        debug_assert_eq!(tx_header.tx_id, 0);
7609        match tx_header.ordinal {
7610            0x4feff7d278978c4e => {
7611                let mut out = fidl::new_empty!(
7612                    AudioRendererOnMinLeadTimeChangedRequest,
7613                    fdomain_client::fidl::FDomainResourceDialect
7614                );
7615                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7616                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
7617                    min_lead_time_nsec: out.min_lead_time_nsec,
7618                }))
7619            }
7620            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7621                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7622            }
7623            _ => Err(fidl::Error::UnknownOrdinal {
7624                ordinal: tx_header.ordinal,
7625                protocol_name:
7626                    <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7627            }),
7628        }
7629    }
7630}
7631
7632/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
7633pub struct AudioRendererRequestStream {
7634    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7635    is_terminated: bool,
7636}
7637
7638impl std::marker::Unpin for AudioRendererRequestStream {}
7639
7640impl futures::stream::FusedStream for AudioRendererRequestStream {
7641    fn is_terminated(&self) -> bool {
7642        self.is_terminated
7643    }
7644}
7645
7646impl fdomain_client::fidl::RequestStream for AudioRendererRequestStream {
7647    type Protocol = AudioRendererMarker;
7648    type ControlHandle = AudioRendererControlHandle;
7649
7650    fn from_channel(channel: fdomain_client::Channel) -> Self {
7651        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7652    }
7653
7654    fn control_handle(&self) -> Self::ControlHandle {
7655        AudioRendererControlHandle { inner: self.inner.clone() }
7656    }
7657
7658    fn into_inner(
7659        self,
7660    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7661    {
7662        (self.inner, self.is_terminated)
7663    }
7664
7665    fn from_inner(
7666        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7667        is_terminated: bool,
7668    ) -> Self {
7669        Self { inner, is_terminated }
7670    }
7671}
7672
7673impl futures::Stream for AudioRendererRequestStream {
7674    type Item = Result<AudioRendererRequest, fidl::Error>;
7675
7676    fn poll_next(
7677        mut self: std::pin::Pin<&mut Self>,
7678        cx: &mut std::task::Context<'_>,
7679    ) -> std::task::Poll<Option<Self::Item>> {
7680        let this = &mut *self;
7681        if this.inner.check_shutdown(cx) {
7682            this.is_terminated = true;
7683            return std::task::Poll::Ready(None);
7684        }
7685        if this.is_terminated {
7686            panic!("polled AudioRendererRequestStream after completion");
7687        }
7688        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7689            |bytes, handles| {
7690                match this.inner.channel().read_etc(cx, bytes, handles) {
7691                    std::task::Poll::Ready(Ok(())) => {}
7692                    std::task::Poll::Pending => return std::task::Poll::Pending,
7693                    std::task::Poll::Ready(Err(None)) => {
7694                        this.is_terminated = true;
7695                        return std::task::Poll::Ready(None);
7696                    }
7697                    std::task::Poll::Ready(Err(Some(e))) => {
7698                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7699                            e.into(),
7700                        ))));
7701                    }
7702                }
7703
7704                // A message has been received from the channel
7705                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7706
7707                std::task::Poll::Ready(Some(match header.ordinal {
7708                0x3b3a37fc34fe5b56 => {
7709                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7710                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7711                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7712                    let control_handle = AudioRendererControlHandle {
7713                        inner: this.inner.clone(),
7714                    };
7715                    Ok(AudioRendererRequest::AddPayloadBuffer {id: req.id,
7716payload_buffer: req.payload_buffer,
7717
7718                        control_handle,
7719                    })
7720                }
7721                0x5d1e4f74c3658262 => {
7722                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7723                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7724                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7725                    let control_handle = AudioRendererControlHandle {
7726                        inner: this.inner.clone(),
7727                    };
7728                    Ok(AudioRendererRequest::RemovePayloadBuffer {id: req.id,
7729
7730                        control_handle,
7731                    })
7732                }
7733                0x67cddd607442775f => {
7734                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7735                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
7736                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
7737                    let control_handle = AudioRendererControlHandle {
7738                        inner: this.inner.clone(),
7739                    };
7740                    Ok(AudioRendererRequest::SendPacket {packet: req.packet,
7741
7742                        responder: AudioRendererSendPacketResponder {
7743                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7744                            tx_id: header.tx_id,
7745                        },
7746                    })
7747                }
7748                0x8d9b8b413ceba9d => {
7749                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7750                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7751                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7752                    let control_handle = AudioRendererControlHandle {
7753                        inner: this.inner.clone(),
7754                    };
7755                    Ok(AudioRendererRequest::SendPacketNoReply {packet: req.packet,
7756
7757                        control_handle,
7758                    })
7759                }
7760                0x6180fd6f7e793b71 => {
7761                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7762                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7763                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7764                    let control_handle = AudioRendererControlHandle {
7765                        inner: this.inner.clone(),
7766                    };
7767                    Ok(AudioRendererRequest::EndOfStream {
7768                        control_handle,
7769                    })
7770                }
7771                0x6f4dad7af2917665 => {
7772                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7773                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7774                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7775                    let control_handle = AudioRendererControlHandle {
7776                        inner: this.inner.clone(),
7777                    };
7778                    Ok(AudioRendererRequest::DiscardAllPackets {
7779                        responder: AudioRendererDiscardAllPacketsResponder {
7780                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7781                            tx_id: header.tx_id,
7782                        },
7783                    })
7784                }
7785                0x50d36d0d23081bc4 => {
7786                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7787                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7788                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7789                    let control_handle = AudioRendererControlHandle {
7790                        inner: this.inner.clone(),
7791                    };
7792                    Ok(AudioRendererRequest::DiscardAllPacketsNoReply {
7793                        control_handle,
7794                    })
7795                }
7796                0x293f5c7f8fba2bdc => {
7797                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7798                    let mut req = fidl::new_empty!(AudioRendererBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
7799                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
7800                    let control_handle = AudioRendererControlHandle {
7801                        inner: this.inner.clone(),
7802                    };
7803                    Ok(AudioRendererRequest::BindGainControl {gain_control_request: req.gain_control_request,
7804
7805                        control_handle,
7806                    })
7807                }
7808                0xf68cd108785a27c => {
7809                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7810                    let mut req = fidl::new_empty!(AudioRendererSetPtsUnitsRequest, fdomain_client::fidl::FDomainResourceDialect);
7811                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
7812                    let control_handle = AudioRendererControlHandle {
7813                        inner: this.inner.clone(),
7814                    };
7815                    Ok(AudioRendererRequest::SetPtsUnits {tick_per_second_numerator: req.tick_per_second_numerator,
7816tick_per_second_denominator: req.tick_per_second_denominator,
7817
7818                        control_handle,
7819                    })
7820                }
7821                0x2849ba571d1971ba => {
7822                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7823                    let mut req = fidl::new_empty!(AudioRendererSetPtsContinuityThresholdRequest, fdomain_client::fidl::FDomainResourceDialect);
7824                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
7825                    let control_handle = AudioRendererControlHandle {
7826                        inner: this.inner.clone(),
7827                    };
7828                    Ok(AudioRendererRequest::SetPtsContinuityThreshold {threshold_seconds: req.threshold_seconds,
7829
7830                        control_handle,
7831                    })
7832                }
7833                0x2f7a7f011a172f7e => {
7834                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7835                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7836                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7837                    let control_handle = AudioRendererControlHandle {
7838                        inner: this.inner.clone(),
7839                    };
7840                    Ok(AudioRendererRequest::GetReferenceClock {
7841                        responder: AudioRendererGetReferenceClockResponder {
7842                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7843                            tx_id: header.tx_id,
7844                        },
7845                    })
7846                }
7847                0x39acd05d832b5fed => {
7848                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7849                    let mut req = fidl::new_empty!(AudioRendererSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
7850                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
7851                    let control_handle = AudioRendererControlHandle {
7852                        inner: this.inner.clone(),
7853                    };
7854                    Ok(AudioRendererRequest::SetReferenceClock {reference_clock: req.reference_clock,
7855
7856                        control_handle,
7857                    })
7858                }
7859                0x3994bd23b55a733e => {
7860                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7861                    let mut req = fidl::new_empty!(AudioRendererSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
7862                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
7863                    let control_handle = AudioRendererControlHandle {
7864                        inner: this.inner.clone(),
7865                    };
7866                    Ok(AudioRendererRequest::SetUsage {usage: req.usage,
7867
7868                        control_handle,
7869                    })
7870                }
7871                0x2904035c7132b103 => {
7872                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7873                    let mut req = fidl::new_empty!(AudioRendererSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
7874                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
7875                    let control_handle = AudioRendererControlHandle {
7876                        inner: this.inner.clone(),
7877                    };
7878                    Ok(AudioRendererRequest::SetUsage2 {usage2: req.usage2,
7879
7880                        control_handle,
7881                    })
7882                }
7883                0x27aa715d8901fa19 => {
7884                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7885                    let mut req = fidl::new_empty!(AudioRendererSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
7886                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
7887                    let control_handle = AudioRendererControlHandle {
7888                        inner: this.inner.clone(),
7889                    };
7890                    Ok(AudioRendererRequest::SetPcmStreamType {type_: req.type_,
7891
7892                        control_handle,
7893                    })
7894                }
7895                0x62808dfad72bf890 => {
7896                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7897                    let mut req = fidl::new_empty!(AudioRendererEnableMinLeadTimeEventsRequest, fdomain_client::fidl::FDomainResourceDialect);
7898                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
7899                    let control_handle = AudioRendererControlHandle {
7900                        inner: this.inner.clone(),
7901                    };
7902                    Ok(AudioRendererRequest::EnableMinLeadTimeEvents {enabled: req.enabled,
7903
7904                        control_handle,
7905                    })
7906                }
7907                0x1cf3c3ecd8fec26b => {
7908                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7909                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7910                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7911                    let control_handle = AudioRendererControlHandle {
7912                        inner: this.inner.clone(),
7913                    };
7914                    Ok(AudioRendererRequest::GetMinLeadTime {
7915                        responder: AudioRendererGetMinLeadTimeResponder {
7916                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7917                            tx_id: header.tx_id,
7918                        },
7919                    })
7920                }
7921                0x3c0162db084f74a3 => {
7922                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7923                    let mut req = fidl::new_empty!(AudioRendererPlayRequest, fdomain_client::fidl::FDomainResourceDialect);
7924                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
7925                    let control_handle = AudioRendererControlHandle {
7926                        inner: this.inner.clone(),
7927                    };
7928                    Ok(AudioRendererRequest::Play {reference_time: req.reference_time,
7929media_time: req.media_time,
7930
7931                        responder: AudioRendererPlayResponder {
7932                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7933                            tx_id: header.tx_id,
7934                        },
7935                    })
7936                }
7937                0x1b7fe832b68c22ef => {
7938                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7939                    let mut req = fidl::new_empty!(AudioRendererPlayNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7940                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7941                    let control_handle = AudioRendererControlHandle {
7942                        inner: this.inner.clone(),
7943                    };
7944                    Ok(AudioRendererRequest::PlayNoReply {reference_time: req.reference_time,
7945media_time: req.media_time,
7946
7947                        control_handle,
7948                    })
7949                }
7950                0x41d557588d93d153 => {
7951                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7952                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7953                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7954                    let control_handle = AudioRendererControlHandle {
7955                        inner: this.inner.clone(),
7956                    };
7957                    Ok(AudioRendererRequest::Pause {
7958                        responder: AudioRendererPauseResponder {
7959                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7960                            tx_id: header.tx_id,
7961                        },
7962                    })
7963                }
7964                0x24cc45d4f3855ab => {
7965                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7966                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7967                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7968                    let control_handle = AudioRendererControlHandle {
7969                        inner: this.inner.clone(),
7970                    };
7971                    Ok(AudioRendererRequest::PauseNoReply {
7972                        control_handle,
7973                    })
7974                }
7975                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7976                    Ok(AudioRendererRequest::_UnknownMethod {
7977                        ordinal: header.ordinal,
7978                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
7979                        method_type: fidl::MethodType::OneWay,
7980                    })
7981                }
7982                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7983                    this.inner.send_framework_err(
7984                        fidl::encoding::FrameworkErr::UnknownMethod,
7985                        header.tx_id,
7986                        header.ordinal,
7987                        header.dynamic_flags(),
7988                        (bytes, handles),
7989                    )?;
7990                    Ok(AudioRendererRequest::_UnknownMethod {
7991                        ordinal: header.ordinal,
7992                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
7993                        method_type: fidl::MethodType::TwoWay,
7994                    })
7995                }
7996                _ => Err(fidl::Error::UnknownOrdinal {
7997                    ordinal: header.ordinal,
7998                    protocol_name: <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7999                }),
8000            }))
8001            },
8002        )
8003    }
8004}
8005
8006/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
8007/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
8008/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
8009/// methods are disallowed and will cause the audio service to disconnect the client's connection.
8010/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
8011/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
8012///
8013/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
8014/// enqueued when these "configuring" methods are called. Thus it is best practice to call
8015/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
8016/// to reconfiguring the renderer.
8017#[derive(Debug)]
8018pub enum AudioRendererRequest {
8019    /// Adds a payload buffer to the current buffer set associated with the
8020    /// connection. A `StreamPacket` struct reference a payload buffer in the
8021    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8022    ///
8023    /// A buffer with ID `id` must not be in the current set when this method is
8024    /// invoked, otherwise the service will close the connection.
8025    AddPayloadBuffer {
8026        id: u32,
8027        payload_buffer: fdomain_client::Vmo,
8028        control_handle: AudioRendererControlHandle,
8029    },
8030    /// Removes a payload buffer from the current buffer set associated with the
8031    /// connection.
8032    ///
8033    /// A buffer with ID `id` must exist in the current set when this method is
8034    /// invoked, otherwise the service will will close the connection.
8035    RemovePayloadBuffer {
8036        id: u32,
8037        control_handle: AudioRendererControlHandle,
8038    },
8039    /// Sends a packet to the service. The response is sent when the service is
8040    /// done with the associated payload memory.
8041    ///
8042    /// `packet` must be valid for the current buffer set, otherwise the service
8043    /// will close the connection.
8044    SendPacket {
8045        packet: StreamPacket,
8046        responder: AudioRendererSendPacketResponder,
8047    },
8048    /// Sends a packet to the service. This interface doesn't define how the
8049    /// client knows when the sink is done with the associated payload memory.
8050    /// The inheriting interface must define that.
8051    ///
8052    /// `packet` must be valid for the current buffer set, otherwise the service
8053    /// will close the connection.
8054    SendPacketNoReply {
8055        packet: StreamPacket,
8056        control_handle: AudioRendererControlHandle,
8057    },
8058    /// Indicates the stream has ended. The precise semantics of this method are
8059    /// determined by the inheriting interface.
8060    EndOfStream {
8061        control_handle: AudioRendererControlHandle,
8062    },
8063    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8064    /// and not yet released. The response is sent after all packets have been
8065    /// released.
8066    DiscardAllPackets {
8067        responder: AudioRendererDiscardAllPacketsResponder,
8068    },
8069    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8070    /// and not yet released.
8071    DiscardAllPacketsNoReply {
8072        control_handle: AudioRendererControlHandle,
8073    },
8074    /// Binds to the gain control for this AudioRenderer.
8075    BindGainControl {
8076        gain_control_request:
8077            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
8078        control_handle: AudioRendererControlHandle,
8079    },
8080    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8081    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8082    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8083    SetPtsUnits {
8084        tick_per_second_numerator: u32,
8085        tick_per_second_denominator: u32,
8086        control_handle: AudioRendererControlHandle,
8087    },
8088    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8089    /// and expected PTS (determined using interpolation). Beyond this threshold,
8090    /// a stream is no longer considered 'continuous' by the renderer.
8091    ///
8092    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8093    /// Most users should not need to change this value from its default.
8094    ///
8095    /// Example:
8096    /// A user is playing back 48KHz audio from a container, which also contains
8097    /// video and needs to be synchronized with the audio. The timestamps are
8098    /// provided explicitly per packet by the container, and expressed in mSec
8099    /// units. This means that a single tick of the media timeline (1 mSec)
8100    /// represents exactly 48 frames of audio. The application in this scenario
8101    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8102    /// frames of audio, and each with an explicit timestamp set to the best
8103    /// possible representation of the presentation time (given this media
8104    /// clock's resolution). So, starting from zero, the timestamps would be..
8105    ///
8106    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8107    ///
8108    /// In this example, attempting to use the presentation time to compute the
8109    /// starting frame number of the audio in the packet would be wrong the
8110    /// majority of the time. The first timestamp is correct (by definition), but
8111    /// it will be 24 packets before the timestamps and frame numbers come back
8112    /// into alignment (the 24th packet would start with the 11280th audio frame
8113    /// and have a PTS of exactly 235).
8114    ///
8115    /// One way to fix this situation is to set the PTS continuity threshold
8116    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8117    /// the number of frames contained within a single tick of the media clock,
8118    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8119    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8120    /// explicitly provided PTS would be considered to be a continuation of the
8121    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8122    /// would work well.
8123    ///
8124    /// Other possible uses:
8125    /// Users who are scheduling audio explicitly, relative to a clock which has
8126    /// not been configured as the reference clock, can use this value to control
8127    /// the maximum acceptable synchronization error before a discontinuity is
8128    /// introduced. E.g., if a user is scheduling audio based on a recovered
8129    /// common media clock, and has not published that clock as the reference
8130    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8131    /// can accumulate before the AudioRenderer deliberately inserts a
8132    /// presentation discontinuity to account for the error.
8133    ///
8134    /// Users whose need to deal with a container where their timestamps may be
8135    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8136    /// something larger. This should be the maximum level of inaccuracy present
8137    /// in the container timestamps, if known. Failing that, it could be set to
8138    /// the maximum tolerable level of drift error before absolute timestamps are
8139    /// explicitly obeyed. Finally, a user could set this number to a very large
8140    /// value (86400.0 seconds, for example) to effectively cause *all*
8141    /// timestamps to be ignored after the first, thus treating all audio as
8142    /// continuous with previously delivered packets. Conversely, users who wish
8143    /// to *always* explicitly schedule their audio packets exactly may specify
8144    /// a CT of 0.
8145    ///
8146    /// Note: explicitly specifying high-frequency PTS units reduces the default
8147    /// continuity threshold accordingly. Internally, this threshold is stored as an
8148    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8149    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8150    /// For this reason, specifying PTS units with a frequency greater than 8192x
8151    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8152    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8153    SetPtsContinuityThreshold {
8154        threshold_seconds: f32,
8155        control_handle: AudioRendererControlHandle,
8156    },
8157    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8158    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8159    GetReferenceClock {
8160        responder: AudioRendererGetReferenceClockResponder,
8161    },
8162    /// Sets the reference clock that controls this renderer's playback rate. If the input
8163    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8164    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8165    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8166    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8167    ///
8168    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8169    /// cannot be called a second time (even if the renderer format has not yet been set).
8170    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8171    /// diverge at some later time, they should create a clone of the monotonic clock, set
8172    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8173    SetReferenceClock {
8174        reference_clock: Option<fdomain_client::Clock>,
8175        control_handle: AudioRendererControlHandle,
8176    },
8177    /// Sets the usage of the render stream. This method may not be called after
8178    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8179    SetUsage {
8180        usage: AudioRenderUsage,
8181        control_handle: AudioRendererControlHandle,
8182    },
8183    /// Sets the usage of the render stream. This method may not be called after
8184    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8185    SetUsage2 {
8186        usage2: AudioRenderUsage2,
8187        control_handle: AudioRendererControlHandle,
8188    },
8189    /// Sets the type of the stream to be delivered by the client. Using this method implies
8190    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8191    ///
8192    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8193    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8194    /// methods such as `SendPacket`/`SendPacketNoReply`.
8195    SetPcmStreamType {
8196        type_: AudioStreamType,
8197        control_handle: AudioRendererControlHandle,
8198    },
8199    /// Enables or disables notifications about changes to the minimum clock lead
8200    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8201    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8202    /// event with the current minimum lead time for the AudioRenderer. If the
8203    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8204    /// new value. This behavior will continue until the user calls
8205    /// `EnableMinLeadTimeEvents(false)`.
8206    ///
8207    /// The minimum clock lead time is the amount of time ahead of the reference
8208    /// clock's understanding of "now" that packets needs to arrive (relative to
8209    /// the playback clock transformation) in order for the mixer to be able to
8210    /// mix packet. For example...
8211    ///
8212    /// + Let the PTS of packet X be P(X)
8213    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8214    ///   function is determined by the call to Play(...)
8215    /// + Let the minimum lead time be MLT
8216    ///
8217    /// If R(P(X)) < RefClock.Now() + MLT
8218    /// Then the packet is late, and some (or all) of the packet's payload will
8219    /// need to be skipped in order to present the packet at the scheduled time.
8220    ///
8221    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8222    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8223    /// is called before the AudioRenderer is routed, any played packets will be
8224    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8225    /// calling `Play`.
8226    EnableMinLeadTimeEvents {
8227        enabled: bool,
8228        control_handle: AudioRendererControlHandle,
8229    },
8230    ///
8231    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8232    /// there's little reason to do so. This is because lead time is a function
8233    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8234    /// If min lead time events are enabled before `SetPcmStreamType` (with
8235    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8236    /// response to `SetPcmStreamType`.
8237    GetMinLeadTime {
8238        responder: AudioRendererGetMinLeadTimeResponder,
8239    },
8240    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8241    /// of the media timeline, using specific values provided by the caller (or
8242    /// default values if not specified). In an optional callback, returns the
8243    /// timestamp values ultimately used -- these set the ongoing relationship
8244    /// between the media and reference timelines (i.e., how to translate between
8245    /// the domain of presentation timestamps, and the realm of local system
8246    /// time).
8247    ///
8248    /// Local system time is specified in units of nanoseconds; media_time is
8249    /// specified in the units defined by the user in the `SetPtsUnits` function,
8250    /// or nanoseconds if `SetPtsUnits` is not called.
8251    ///
8252    /// The act of placing an AudioRenderer into the playback state establishes a
8253    /// relationship between 1) the user-defined media (or presentation) timeline
8254    /// for this particular AudioRenderer, and 2) the real-world system reference
8255    /// timeline. To communicate how to translate between timelines, the Play()
8256    /// callback provides an equivalent timestamp in each time domain. The first
8257    /// value ('reference_time') is given in terms of this renderer's reference
8258    /// clock; the second value ('media_time') is what media instant exactly
8259    /// corresponds to that local time. Restated, the frame at 'media_time' in
8260    /// the audio stream should be presented at 'reference_time' according to
8261    /// the reference clock.
8262    ///
8263    /// Note: on calling this API, media_time immediately starts advancing. It is
8264    /// possible (if uncommon) for a caller to specify a system time that is
8265    /// far in the past, or far into the future. This, along with the specified
8266    /// media time, is simply used to determine what media time corresponds to
8267    /// 'now', and THAT media time is then intersected with presentation
8268    /// timestamps of packets already submitted, to determine which media frames
8269    /// should be presented next.
8270    ///
8271    /// With the corresponding reference_time and media_time values, a user can
8272    /// translate arbitrary time values from one timeline into the other. After
8273    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8274    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8275    /// any 'ref_time':
8276    ///
8277    /// media_time = ( (ref_time - ref_start) / 1e9
8278    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8279    ///              + media_start
8280    ///
8281    /// Conversely, for any presentation timestamp 'media_time':
8282    ///
8283    /// ref_time = ( (media_time - media_start)
8284    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8285    ///              * 1e9 )
8286    ///            + ref_start
8287    ///
8288    /// Users, depending on their use case, may optionally choose not to specify
8289    /// one or both of these timestamps. A timestamp may be omitted by supplying
8290    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8291    /// any omitted timestamp value using the following rules:
8292    ///
8293    /// Reference Time
8294    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8295    /// reference time to begin presentation, based on the minimum lead times for
8296    /// the output devices that are currently bound to this AudioRenderer. For
8297    /// example, if an AudioRenderer is bound to an internal audio output
8298    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8299    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8300    /// is omitted) select a reference time 80 mSec from now.
8301    ///
8302    /// Media Time
8303    /// If media_time is omitted, the AudioRenderer will select one of two
8304    /// values.
8305    /// - If the AudioRenderer is resuming from the paused state, and packets
8306    /// have not been discarded since being paused, then the AudioRenderer will
8307    /// use a media_time corresponding to the instant at which the presentation
8308    /// became paused.
8309    /// - If the AudioRenderer is being placed into a playing state for the first
8310    /// time following startup or a 'discard packets' operation, the initial
8311    /// media_time will be set to the PTS of the first payload in the pending
8312    /// packet queue. If the pending queue is empty, initial media_time will be
8313    /// set to zero.
8314    ///
8315    /// Return Value
8316    /// When requested, the AudioRenderer will return the 'reference_time' and
8317    /// 'media_time' which were selected and used (whether they were explicitly
8318    /// specified or not) in the return value of the play call.
8319    ///
8320    /// Examples
8321    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8322    /// to start playing as soon as possible. The user may call Play without
8323    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8324    ///
8325    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8326    /// playback at a specified 'reference_time', in sync with some other media
8327    /// stream, either initially or after discarding packets. The user would call
8328    /// `Play(reference_time, NO_TIMESTAMP)`.
8329    ///
8330    /// 3. A user has queued some audio using `SendPacket`. The first of these
8331    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8332    /// as possible, but wishes to skip all of the audio content between PTS 0
8333    /// and PTS 'media_time'. The user would call
8334    /// `Play(NO_TIMESTAMP, media_time)`.
8335    ///
8336    /// 4. A user has queued some audio using `SendPacket` and want to present
8337    /// this media in synch with another player in a different device. The
8338    /// coordinator of the group of distributed players sends an explicit
8339    /// message to each player telling them to begin presentation of audio at
8340    /// PTS 'media_time', at the time (based on the group's shared reference
8341    /// clock) 'reference_time'. Here the user would call
8342    /// `Play(reference_time, media_time)`.
8343    Play {
8344        reference_time: i64,
8345        media_time: i64,
8346        responder: AudioRendererPlayResponder,
8347    },
8348    PlayNoReply {
8349        reference_time: i64,
8350        media_time: i64,
8351        control_handle: AudioRendererControlHandle,
8352    },
8353    /// Immediately puts the AudioRenderer into the paused state and then report
8354    /// the relationship between the media and reference timelines which was
8355    /// established (if requested).
8356    ///
8357    /// If the AudioRenderer is already in the paused state when this called,
8358    /// the previously-established timeline values are returned (if requested).
8359    Pause {
8360        responder: AudioRendererPauseResponder,
8361    },
8362    PauseNoReply {
8363        control_handle: AudioRendererControlHandle,
8364    },
8365    /// An interaction was received which does not match any known method.
8366    #[non_exhaustive]
8367    _UnknownMethod {
8368        /// Ordinal of the method that was called.
8369        ordinal: u64,
8370        control_handle: AudioRendererControlHandle,
8371        method_type: fidl::MethodType,
8372    },
8373}
8374
8375impl AudioRendererRequest {
8376    #[allow(irrefutable_let_patterns)]
8377    pub fn into_add_payload_buffer(
8378        self,
8379    ) -> Option<(u32, fdomain_client::Vmo, AudioRendererControlHandle)> {
8380        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
8381        {
8382            Some((id, payload_buffer, control_handle))
8383        } else {
8384            None
8385        }
8386    }
8387
8388    #[allow(irrefutable_let_patterns)]
8389    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
8390        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
8391            Some((id, control_handle))
8392        } else {
8393            None
8394        }
8395    }
8396
8397    #[allow(irrefutable_let_patterns)]
8398    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
8399        if let AudioRendererRequest::SendPacket { packet, responder } = self {
8400            Some((packet, responder))
8401        } else {
8402            None
8403        }
8404    }
8405
8406    #[allow(irrefutable_let_patterns)]
8407    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
8408        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
8409            Some((packet, control_handle))
8410        } else {
8411            None
8412        }
8413    }
8414
8415    #[allow(irrefutable_let_patterns)]
8416    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
8417        if let AudioRendererRequest::EndOfStream { control_handle } = self {
8418            Some((control_handle))
8419        } else {
8420            None
8421        }
8422    }
8423
8424    #[allow(irrefutable_let_patterns)]
8425    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
8426        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
8427            Some((responder))
8428        } else {
8429            None
8430        }
8431    }
8432
8433    #[allow(irrefutable_let_patterns)]
8434    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8435        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
8436            Some((control_handle))
8437        } else {
8438            None
8439        }
8440    }
8441
8442    #[allow(irrefutable_let_patterns)]
8443    pub fn into_bind_gain_control(
8444        self,
8445    ) -> Option<(
8446        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
8447        AudioRendererControlHandle,
8448    )> {
8449        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
8450        {
8451            Some((gain_control_request, control_handle))
8452        } else {
8453            None
8454        }
8455    }
8456
8457    #[allow(irrefutable_let_patterns)]
8458    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
8459        if let AudioRendererRequest::SetPtsUnits {
8460            tick_per_second_numerator,
8461            tick_per_second_denominator,
8462            control_handle,
8463        } = self
8464        {
8465            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
8466        } else {
8467            None
8468        }
8469    }
8470
8471    #[allow(irrefutable_let_patterns)]
8472    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
8473        if let AudioRendererRequest::SetPtsContinuityThreshold {
8474            threshold_seconds,
8475            control_handle,
8476        } = self
8477        {
8478            Some((threshold_seconds, control_handle))
8479        } else {
8480            None
8481        }
8482    }
8483
8484    #[allow(irrefutable_let_patterns)]
8485    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
8486        if let AudioRendererRequest::GetReferenceClock { responder } = self {
8487            Some((responder))
8488        } else {
8489            None
8490        }
8491    }
8492
8493    #[allow(irrefutable_let_patterns)]
8494    pub fn into_set_reference_clock(
8495        self,
8496    ) -> Option<(Option<fdomain_client::Clock>, AudioRendererControlHandle)> {
8497        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
8498            Some((reference_clock, control_handle))
8499        } else {
8500            None
8501        }
8502    }
8503
8504    #[allow(irrefutable_let_patterns)]
8505    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
8506        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
8507            Some((usage, control_handle))
8508        } else {
8509            None
8510        }
8511    }
8512
8513    #[allow(irrefutable_let_patterns)]
8514    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
8515        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
8516            Some((usage2, control_handle))
8517        } else {
8518            None
8519        }
8520    }
8521
8522    #[allow(irrefutable_let_patterns)]
8523    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
8524        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
8525            Some((type_, control_handle))
8526        } else {
8527            None
8528        }
8529    }
8530
8531    #[allow(irrefutable_let_patterns)]
8532    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
8533        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
8534            Some((enabled, control_handle))
8535        } else {
8536            None
8537        }
8538    }
8539
8540    #[allow(irrefutable_let_patterns)]
8541    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
8542        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
8543            Some((responder))
8544        } else {
8545            None
8546        }
8547    }
8548
8549    #[allow(irrefutable_let_patterns)]
8550    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
8551        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
8552            Some((reference_time, media_time, responder))
8553        } else {
8554            None
8555        }
8556    }
8557
8558    #[allow(irrefutable_let_patterns)]
8559    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
8560        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
8561            self
8562        {
8563            Some((reference_time, media_time, control_handle))
8564        } else {
8565            None
8566        }
8567    }
8568
8569    #[allow(irrefutable_let_patterns)]
8570    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
8571        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
8572    }
8573
8574    #[allow(irrefutable_let_patterns)]
8575    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8576        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
8577            Some((control_handle))
8578        } else {
8579            None
8580        }
8581    }
8582
8583    /// Name of the method defined in FIDL
8584    pub fn method_name(&self) -> &'static str {
8585        match *self {
8586            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
8587            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
8588            AudioRendererRequest::SendPacket { .. } => "send_packet",
8589            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
8590            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
8591            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
8592            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
8593            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
8594            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
8595            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
8596                "set_pts_continuity_threshold"
8597            }
8598            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
8599            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
8600            AudioRendererRequest::SetUsage { .. } => "set_usage",
8601            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
8602            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
8603            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
8604            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
8605            AudioRendererRequest::Play { .. } => "play",
8606            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
8607            AudioRendererRequest::Pause { .. } => "pause",
8608            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
8609            AudioRendererRequest::_UnknownMethod {
8610                method_type: fidl::MethodType::OneWay, ..
8611            } => "unknown one-way method",
8612            AudioRendererRequest::_UnknownMethod {
8613                method_type: fidl::MethodType::TwoWay, ..
8614            } => "unknown two-way method",
8615        }
8616    }
8617}
8618
8619#[derive(Debug, Clone)]
8620pub struct AudioRendererControlHandle {
8621    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8622}
8623
8624impl fdomain_client::fidl::ControlHandle for AudioRendererControlHandle {
8625    fn shutdown(&self) {
8626        self.inner.shutdown()
8627    }
8628
8629    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8630        self.inner.shutdown_with_epitaph(status)
8631    }
8632
8633    fn is_closed(&self) -> bool {
8634        self.inner.channel().is_closed()
8635    }
8636    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
8637        self.inner.channel().on_closed()
8638    }
8639}
8640
8641impl AudioRendererControlHandle {
8642    pub fn send_on_min_lead_time_changed(
8643        &self,
8644        mut min_lead_time_nsec: i64,
8645    ) -> Result<(), fidl::Error> {
8646        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
8647            (min_lead_time_nsec,),
8648            0,
8649            0x4feff7d278978c4e,
8650            fidl::encoding::DynamicFlags::empty(),
8651        )
8652    }
8653}
8654
8655#[must_use = "FIDL methods require a response to be sent"]
8656#[derive(Debug)]
8657pub struct AudioRendererSendPacketResponder {
8658    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8659    tx_id: u32,
8660}
8661
8662/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8663/// if the responder is dropped without sending a response, so that the client
8664/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8665impl std::ops::Drop for AudioRendererSendPacketResponder {
8666    fn drop(&mut self) {
8667        self.control_handle.shutdown();
8668        // Safety: drops once, never accessed again
8669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8670    }
8671}
8672
8673impl fdomain_client::fidl::Responder for AudioRendererSendPacketResponder {
8674    type ControlHandle = AudioRendererControlHandle;
8675
8676    fn control_handle(&self) -> &AudioRendererControlHandle {
8677        &self.control_handle
8678    }
8679
8680    fn drop_without_shutdown(mut self) {
8681        // Safety: drops once, never accessed again due to mem::forget
8682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8683        // Prevent Drop from running (which would shut down the channel)
8684        std::mem::forget(self);
8685    }
8686}
8687
8688impl AudioRendererSendPacketResponder {
8689    /// Sends a response to the FIDL transaction.
8690    ///
8691    /// Sets the channel to shutdown if an error occurs.
8692    pub fn send(self) -> Result<(), fidl::Error> {
8693        let _result = self.send_raw();
8694        if _result.is_err() {
8695            self.control_handle.shutdown();
8696        }
8697        self.drop_without_shutdown();
8698        _result
8699    }
8700
8701    /// Similar to "send" but does not shutdown the channel if an error occurs.
8702    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8703        let _result = self.send_raw();
8704        self.drop_without_shutdown();
8705        _result
8706    }
8707
8708    fn send_raw(&self) -> Result<(), fidl::Error> {
8709        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8710            (),
8711            self.tx_id,
8712            0x67cddd607442775f,
8713            fidl::encoding::DynamicFlags::empty(),
8714        )
8715    }
8716}
8717
8718#[must_use = "FIDL methods require a response to be sent"]
8719#[derive(Debug)]
8720pub struct AudioRendererDiscardAllPacketsResponder {
8721    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8722    tx_id: u32,
8723}
8724
8725/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8726/// if the responder is dropped without sending a response, so that the client
8727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8728impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
8729    fn drop(&mut self) {
8730        self.control_handle.shutdown();
8731        // Safety: drops once, never accessed again
8732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8733    }
8734}
8735
8736impl fdomain_client::fidl::Responder for AudioRendererDiscardAllPacketsResponder {
8737    type ControlHandle = AudioRendererControlHandle;
8738
8739    fn control_handle(&self) -> &AudioRendererControlHandle {
8740        &self.control_handle
8741    }
8742
8743    fn drop_without_shutdown(mut self) {
8744        // Safety: drops once, never accessed again due to mem::forget
8745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8746        // Prevent Drop from running (which would shut down the channel)
8747        std::mem::forget(self);
8748    }
8749}
8750
8751impl AudioRendererDiscardAllPacketsResponder {
8752    /// Sends a response to the FIDL transaction.
8753    ///
8754    /// Sets the channel to shutdown if an error occurs.
8755    pub fn send(self) -> Result<(), fidl::Error> {
8756        let _result = self.send_raw();
8757        if _result.is_err() {
8758            self.control_handle.shutdown();
8759        }
8760        self.drop_without_shutdown();
8761        _result
8762    }
8763
8764    /// Similar to "send" but does not shutdown the channel if an error occurs.
8765    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8766        let _result = self.send_raw();
8767        self.drop_without_shutdown();
8768        _result
8769    }
8770
8771    fn send_raw(&self) -> Result<(), fidl::Error> {
8772        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8773            (),
8774            self.tx_id,
8775            0x6f4dad7af2917665,
8776            fidl::encoding::DynamicFlags::empty(),
8777        )
8778    }
8779}
8780
8781#[must_use = "FIDL methods require a response to be sent"]
8782#[derive(Debug)]
8783pub struct AudioRendererGetReferenceClockResponder {
8784    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8785    tx_id: u32,
8786}
8787
8788/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8789/// if the responder is dropped without sending a response, so that the client
8790/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8791impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
8792    fn drop(&mut self) {
8793        self.control_handle.shutdown();
8794        // Safety: drops once, never accessed again
8795        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8796    }
8797}
8798
8799impl fdomain_client::fidl::Responder for AudioRendererGetReferenceClockResponder {
8800    type ControlHandle = AudioRendererControlHandle;
8801
8802    fn control_handle(&self) -> &AudioRendererControlHandle {
8803        &self.control_handle
8804    }
8805
8806    fn drop_without_shutdown(mut self) {
8807        // Safety: drops once, never accessed again due to mem::forget
8808        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8809        // Prevent Drop from running (which would shut down the channel)
8810        std::mem::forget(self);
8811    }
8812}
8813
8814impl AudioRendererGetReferenceClockResponder {
8815    /// Sends a response to the FIDL transaction.
8816    ///
8817    /// Sets the channel to shutdown if an error occurs.
8818    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8819        let _result = self.send_raw(reference_clock);
8820        if _result.is_err() {
8821            self.control_handle.shutdown();
8822        }
8823        self.drop_without_shutdown();
8824        _result
8825    }
8826
8827    /// Similar to "send" but does not shutdown the channel if an error occurs.
8828    pub fn send_no_shutdown_on_err(
8829        self,
8830        mut reference_clock: fdomain_client::Clock,
8831    ) -> Result<(), fidl::Error> {
8832        let _result = self.send_raw(reference_clock);
8833        self.drop_without_shutdown();
8834        _result
8835    }
8836
8837    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8838        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
8839            (reference_clock,),
8840            self.tx_id,
8841            0x2f7a7f011a172f7e,
8842            fidl::encoding::DynamicFlags::empty(),
8843        )
8844    }
8845}
8846
8847#[must_use = "FIDL methods require a response to be sent"]
8848#[derive(Debug)]
8849pub struct AudioRendererGetMinLeadTimeResponder {
8850    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8851    tx_id: u32,
8852}
8853
8854/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8855/// if the responder is dropped without sending a response, so that the client
8856/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8857impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
8858    fn drop(&mut self) {
8859        self.control_handle.shutdown();
8860        // Safety: drops once, never accessed again
8861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8862    }
8863}
8864
8865impl fdomain_client::fidl::Responder for AudioRendererGetMinLeadTimeResponder {
8866    type ControlHandle = AudioRendererControlHandle;
8867
8868    fn control_handle(&self) -> &AudioRendererControlHandle {
8869        &self.control_handle
8870    }
8871
8872    fn drop_without_shutdown(mut self) {
8873        // Safety: drops once, never accessed again due to mem::forget
8874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8875        // Prevent Drop from running (which would shut down the channel)
8876        std::mem::forget(self);
8877    }
8878}
8879
8880impl AudioRendererGetMinLeadTimeResponder {
8881    /// Sends a response to the FIDL transaction.
8882    ///
8883    /// Sets the channel to shutdown if an error occurs.
8884    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8885        let _result = self.send_raw(min_lead_time_nsec);
8886        if _result.is_err() {
8887            self.control_handle.shutdown();
8888        }
8889        self.drop_without_shutdown();
8890        _result
8891    }
8892
8893    /// Similar to "send" but does not shutdown the channel if an error occurs.
8894    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8895        let _result = self.send_raw(min_lead_time_nsec);
8896        self.drop_without_shutdown();
8897        _result
8898    }
8899
8900    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8901        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
8902            (min_lead_time_nsec,),
8903            self.tx_id,
8904            0x1cf3c3ecd8fec26b,
8905            fidl::encoding::DynamicFlags::empty(),
8906        )
8907    }
8908}
8909
8910#[must_use = "FIDL methods require a response to be sent"]
8911#[derive(Debug)]
8912pub struct AudioRendererPlayResponder {
8913    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8914    tx_id: u32,
8915}
8916
8917/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8918/// if the responder is dropped without sending a response, so that the client
8919/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8920impl std::ops::Drop for AudioRendererPlayResponder {
8921    fn drop(&mut self) {
8922        self.control_handle.shutdown();
8923        // Safety: drops once, never accessed again
8924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8925    }
8926}
8927
8928impl fdomain_client::fidl::Responder for AudioRendererPlayResponder {
8929    type ControlHandle = AudioRendererControlHandle;
8930
8931    fn control_handle(&self) -> &AudioRendererControlHandle {
8932        &self.control_handle
8933    }
8934
8935    fn drop_without_shutdown(mut self) {
8936        // Safety: drops once, never accessed again due to mem::forget
8937        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8938        // Prevent Drop from running (which would shut down the channel)
8939        std::mem::forget(self);
8940    }
8941}
8942
8943impl AudioRendererPlayResponder {
8944    /// Sends a response to the FIDL transaction.
8945    ///
8946    /// Sets the channel to shutdown if an error occurs.
8947    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8948        let _result = self.send_raw(reference_time, media_time);
8949        if _result.is_err() {
8950            self.control_handle.shutdown();
8951        }
8952        self.drop_without_shutdown();
8953        _result
8954    }
8955
8956    /// Similar to "send" but does not shutdown the channel if an error occurs.
8957    pub fn send_no_shutdown_on_err(
8958        self,
8959        mut reference_time: i64,
8960        mut media_time: i64,
8961    ) -> Result<(), fidl::Error> {
8962        let _result = self.send_raw(reference_time, media_time);
8963        self.drop_without_shutdown();
8964        _result
8965    }
8966
8967    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8968        self.control_handle.inner.send::<AudioRendererPlayResponse>(
8969            (reference_time, media_time),
8970            self.tx_id,
8971            0x3c0162db084f74a3,
8972            fidl::encoding::DynamicFlags::empty(),
8973        )
8974    }
8975}
8976
8977#[must_use = "FIDL methods require a response to be sent"]
8978#[derive(Debug)]
8979pub struct AudioRendererPauseResponder {
8980    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8981    tx_id: u32,
8982}
8983
8984/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8985/// if the responder is dropped without sending a response, so that the client
8986/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8987impl std::ops::Drop for AudioRendererPauseResponder {
8988    fn drop(&mut self) {
8989        self.control_handle.shutdown();
8990        // Safety: drops once, never accessed again
8991        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8992    }
8993}
8994
8995impl fdomain_client::fidl::Responder for AudioRendererPauseResponder {
8996    type ControlHandle = AudioRendererControlHandle;
8997
8998    fn control_handle(&self) -> &AudioRendererControlHandle {
8999        &self.control_handle
9000    }
9001
9002    fn drop_without_shutdown(mut self) {
9003        // Safety: drops once, never accessed again due to mem::forget
9004        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9005        // Prevent Drop from running (which would shut down the channel)
9006        std::mem::forget(self);
9007    }
9008}
9009
9010impl AudioRendererPauseResponder {
9011    /// Sends a response to the FIDL transaction.
9012    ///
9013    /// Sets the channel to shutdown if an error occurs.
9014    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
9015        let _result = self.send_raw(reference_time, media_time);
9016        if _result.is_err() {
9017            self.control_handle.shutdown();
9018        }
9019        self.drop_without_shutdown();
9020        _result
9021    }
9022
9023    /// Similar to "send" but does not shutdown the channel if an error occurs.
9024    pub fn send_no_shutdown_on_err(
9025        self,
9026        mut reference_time: i64,
9027        mut media_time: i64,
9028    ) -> Result<(), fidl::Error> {
9029        let _result = self.send_raw(reference_time, media_time);
9030        self.drop_without_shutdown();
9031        _result
9032    }
9033
9034    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
9035        self.control_handle.inner.send::<AudioRendererPauseResponse>(
9036            (reference_time, media_time),
9037            self.tx_id,
9038            0x41d557588d93d153,
9039            fidl::encoding::DynamicFlags::empty(),
9040        )
9041    }
9042}
9043
9044#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9045pub struct ProfileProviderMarker;
9046
9047impl fdomain_client::fidl::ProtocolMarker for ProfileProviderMarker {
9048    type Proxy = ProfileProviderProxy;
9049    type RequestStream = ProfileProviderRequestStream;
9050
9051    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
9052}
9053impl fdomain_client::fidl::DiscoverableProtocolMarker for ProfileProviderMarker {}
9054
9055pub trait ProfileProviderProxyInterface: Send + Sync {
9056    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
9057        + Send;
9058    fn r#register_handler_with_capacity(
9059        &self,
9060        thread_handle: fdomain_client::Thread,
9061        name: &str,
9062        period: i64,
9063        capacity: f32,
9064    ) -> Self::RegisterHandlerWithCapacityResponseFut;
9065    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9066    fn r#unregister_handler(
9067        &self,
9068        thread_handle: fdomain_client::Thread,
9069        name: &str,
9070    ) -> Self::UnregisterHandlerResponseFut;
9071    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
9072        + Send;
9073    fn r#register_memory_range(
9074        &self,
9075        vmar_handle: fdomain_client::Vmar,
9076        name: &str,
9077    ) -> Self::RegisterMemoryRangeResponseFut;
9078    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
9079        + Send;
9080    fn r#unregister_memory_range(
9081        &self,
9082        vmar_handle: fdomain_client::Vmar,
9083    ) -> Self::UnregisterMemoryRangeResponseFut;
9084}
9085
9086#[derive(Debug, Clone)]
9087pub struct ProfileProviderProxy {
9088    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9089}
9090
9091impl fdomain_client::fidl::Proxy for ProfileProviderProxy {
9092    type Protocol = ProfileProviderMarker;
9093
9094    fn from_channel(inner: fdomain_client::Channel) -> Self {
9095        Self::new(inner)
9096    }
9097
9098    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9099        self.client.into_channel().map_err(|client| Self { client })
9100    }
9101
9102    fn as_channel(&self) -> &fdomain_client::Channel {
9103        self.client.as_channel()
9104    }
9105}
9106
9107impl ProfileProviderProxy {
9108    /// Create a new Proxy for fuchsia.media/ProfileProvider.
9109    pub fn new(channel: fdomain_client::Channel) -> Self {
9110        let protocol_name =
9111            <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9112        Self { client: fidl::client::Client::new(channel, protocol_name) }
9113    }
9114
9115    /// Get a Stream of events from the remote end of the protocol.
9116    ///
9117    /// # Panics
9118    ///
9119    /// Panics if the event stream was already taken.
9120    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
9121        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
9122    }
9123
9124    /// Register a thread as a media thread. This notifies the media subsystem that this thread
9125    /// should have an elevated scheduling profile applied to it in order to meet audio or video
9126    /// deadlines.
9127    ///
9128    /// `name` is the name of a system scheduling role to apply to the thread given by
9129    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
9130    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
9131    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
9132    /// the scheduling interval the thread needs to be running to achieve good performance or to
9133    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
9134    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
9135    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
9136    /// be rejected or result in scaling back the performance of other threads to fit resource
9137    /// limits.
9138    ///
9139    /// Capacity, max runtime, and period have the following relationship:
9140    ///
9141    ///   capacity = max runtime / period
9142    ///
9143    /// Where:
9144    ///
9145    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
9146    ///
9147    /// For heterogeneous systems, the capacity should be planned / measured against the highest
9148    /// performance processor(s) in the system. The system will automatically adjust the effective
9149    /// capacity to account for slower processors and operating points and will avoid processors and
9150    /// operating points that are too slow to meet the requested scheduling parameters (provided
9151    /// they are reasonable).
9152    ///
9153    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
9154    /// may be zero to indicate not applicable.
9155    pub fn r#register_handler_with_capacity(
9156        &self,
9157        mut thread_handle: fdomain_client::Thread,
9158        mut name: &str,
9159        mut period: i64,
9160        mut capacity: f32,
9161    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
9162    {
9163        ProfileProviderProxyInterface::r#register_handler_with_capacity(
9164            self,
9165            thread_handle,
9166            name,
9167            period,
9168            capacity,
9169        )
9170    }
9171
9172    /// Reset a thread's scheduling profile to the default.
9173    pub fn r#unregister_handler(
9174        &self,
9175        mut thread_handle: fdomain_client::Thread,
9176        mut name: &str,
9177    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9178        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
9179    }
9180
9181    /// Register a memory range as being used for media processing. This notifies the media
9182    /// subsystem that this memory should have an elevated memory profile applied to it in order to
9183    /// meet audio or video deadlines.
9184    ///
9185    /// `name` is the name of a system memory role to apply to the memory given by
9186    /// `vmar_handle` -- different products may customize the underlying memory strategy based
9187    /// on the requested role.
9188    pub fn r#register_memory_range(
9189        &self,
9190        mut vmar_handle: fdomain_client::Vmar,
9191        mut name: &str,
9192    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9193        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
9194    }
9195
9196    /// Reset a memory range's memory profile.
9197    pub fn r#unregister_memory_range(
9198        &self,
9199        mut vmar_handle: fdomain_client::Vmar,
9200    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9201        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
9202    }
9203}
9204
9205impl ProfileProviderProxyInterface for ProfileProviderProxy {
9206    type RegisterHandlerWithCapacityResponseFut =
9207        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
9208    fn r#register_handler_with_capacity(
9209        &self,
9210        mut thread_handle: fdomain_client::Thread,
9211        mut name: &str,
9212        mut period: i64,
9213        mut capacity: f32,
9214    ) -> Self::RegisterHandlerWithCapacityResponseFut {
9215        fn _decode(
9216            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9217        ) -> Result<(i64, i64), fidl::Error> {
9218            let _response = fidl::client::decode_transaction_body::<
9219                ProfileProviderRegisterHandlerWithCapacityResponse,
9220                fdomain_client::fidl::FDomainResourceDialect,
9221                0x60459ecef7458176,
9222            >(_buf?)?;
9223            Ok((_response.period, _response.capacity))
9224        }
9225        self.client
9226            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
9227                (thread_handle, name, period, capacity),
9228                0x60459ecef7458176,
9229                fidl::encoding::DynamicFlags::empty(),
9230                _decode,
9231            )
9232    }
9233
9234    type UnregisterHandlerResponseFut =
9235        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9236    fn r#unregister_handler(
9237        &self,
9238        mut thread_handle: fdomain_client::Thread,
9239        mut name: &str,
9240    ) -> Self::UnregisterHandlerResponseFut {
9241        fn _decode(
9242            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9243        ) -> Result<(), fidl::Error> {
9244            let _response = fidl::client::decode_transaction_body::<
9245                fidl::encoding::EmptyPayload,
9246                fdomain_client::fidl::FDomainResourceDialect,
9247                0x724d9d5fd8ef544c,
9248            >(_buf?)?;
9249            Ok(_response)
9250        }
9251        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
9252            (thread_handle, name),
9253            0x724d9d5fd8ef544c,
9254            fidl::encoding::DynamicFlags::empty(),
9255            _decode,
9256        )
9257    }
9258
9259    type RegisterMemoryRangeResponseFut =
9260        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9261    fn r#register_memory_range(
9262        &self,
9263        mut vmar_handle: fdomain_client::Vmar,
9264        mut name: &str,
9265    ) -> Self::RegisterMemoryRangeResponseFut {
9266        fn _decode(
9267            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9268        ) -> Result<(), fidl::Error> {
9269            let _response = fidl::client::decode_transaction_body::<
9270                fidl::encoding::EmptyPayload,
9271                fdomain_client::fidl::FDomainResourceDialect,
9272                0x2f509d3523e9562d,
9273            >(_buf?)?;
9274            Ok(_response)
9275        }
9276        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
9277            (vmar_handle, name),
9278            0x2f509d3523e9562d,
9279            fidl::encoding::DynamicFlags::empty(),
9280            _decode,
9281        )
9282    }
9283
9284    type UnregisterMemoryRangeResponseFut =
9285        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9286    fn r#unregister_memory_range(
9287        &self,
9288        mut vmar_handle: fdomain_client::Vmar,
9289    ) -> Self::UnregisterMemoryRangeResponseFut {
9290        fn _decode(
9291            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9292        ) -> Result<(), fidl::Error> {
9293            let _response = fidl::client::decode_transaction_body::<
9294                fidl::encoding::EmptyPayload,
9295                fdomain_client::fidl::FDomainResourceDialect,
9296                0x2dc313d6aa81ad27,
9297            >(_buf?)?;
9298            Ok(_response)
9299        }
9300        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
9301            (vmar_handle,),
9302            0x2dc313d6aa81ad27,
9303            fidl::encoding::DynamicFlags::empty(),
9304            _decode,
9305        )
9306    }
9307}
9308
9309pub struct ProfileProviderEventStream {
9310    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
9311}
9312
9313impl std::marker::Unpin for ProfileProviderEventStream {}
9314
9315impl futures::stream::FusedStream for ProfileProviderEventStream {
9316    fn is_terminated(&self) -> bool {
9317        self.event_receiver.is_terminated()
9318    }
9319}
9320
9321impl futures::Stream for ProfileProviderEventStream {
9322    type Item = Result<ProfileProviderEvent, fidl::Error>;
9323
9324    fn poll_next(
9325        mut self: std::pin::Pin<&mut Self>,
9326        cx: &mut std::task::Context<'_>,
9327    ) -> std::task::Poll<Option<Self::Item>> {
9328        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9329            &mut self.event_receiver,
9330            cx
9331        )?) {
9332            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
9333            None => std::task::Poll::Ready(None),
9334        }
9335    }
9336}
9337
9338#[derive(Debug)]
9339pub enum ProfileProviderEvent {}
9340
9341impl ProfileProviderEvent {
9342    /// Decodes a message buffer as a [`ProfileProviderEvent`].
9343    fn decode(
9344        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9345    ) -> Result<ProfileProviderEvent, fidl::Error> {
9346        let (bytes, _handles) = buf.split_mut();
9347        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9348        debug_assert_eq!(tx_header.tx_id, 0);
9349        match tx_header.ordinal {
9350            _ => Err(fidl::Error::UnknownOrdinal {
9351                ordinal: tx_header.ordinal,
9352                protocol_name:
9353                    <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9354            }),
9355        }
9356    }
9357}
9358
9359/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
9360pub struct ProfileProviderRequestStream {
9361    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9362    is_terminated: bool,
9363}
9364
9365impl std::marker::Unpin for ProfileProviderRequestStream {}
9366
9367impl futures::stream::FusedStream for ProfileProviderRequestStream {
9368    fn is_terminated(&self) -> bool {
9369        self.is_terminated
9370    }
9371}
9372
9373impl fdomain_client::fidl::RequestStream for ProfileProviderRequestStream {
9374    type Protocol = ProfileProviderMarker;
9375    type ControlHandle = ProfileProviderControlHandle;
9376
9377    fn from_channel(channel: fdomain_client::Channel) -> Self {
9378        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9379    }
9380
9381    fn control_handle(&self) -> Self::ControlHandle {
9382        ProfileProviderControlHandle { inner: self.inner.clone() }
9383    }
9384
9385    fn into_inner(
9386        self,
9387    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
9388    {
9389        (self.inner, self.is_terminated)
9390    }
9391
9392    fn from_inner(
9393        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9394        is_terminated: bool,
9395    ) -> Self {
9396        Self { inner, is_terminated }
9397    }
9398}
9399
9400impl futures::Stream for ProfileProviderRequestStream {
9401    type Item = Result<ProfileProviderRequest, fidl::Error>;
9402
9403    fn poll_next(
9404        mut self: std::pin::Pin<&mut Self>,
9405        cx: &mut std::task::Context<'_>,
9406    ) -> std::task::Poll<Option<Self::Item>> {
9407        let this = &mut *self;
9408        if this.inner.check_shutdown(cx) {
9409            this.is_terminated = true;
9410            return std::task::Poll::Ready(None);
9411        }
9412        if this.is_terminated {
9413            panic!("polled ProfileProviderRequestStream after completion");
9414        }
9415        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
9416            |bytes, handles| {
9417                match this.inner.channel().read_etc(cx, bytes, handles) {
9418                    std::task::Poll::Ready(Ok(())) => {}
9419                    std::task::Poll::Pending => return std::task::Poll::Pending,
9420                    std::task::Poll::Ready(Err(None)) => {
9421                        this.is_terminated = true;
9422                        return std::task::Poll::Ready(None);
9423                    }
9424                    std::task::Poll::Ready(Err(Some(e))) => {
9425                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9426                            e.into(),
9427                        ))));
9428                    }
9429                }
9430
9431                // A message has been received from the channel
9432                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9433
9434                std::task::Poll::Ready(Some(match header.ordinal {
9435                0x60459ecef7458176 => {
9436                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9437                    let mut req = fidl::new_empty!(ProfileProviderRegisterHandlerWithCapacityRequest, fdomain_client::fidl::FDomainResourceDialect);
9438                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
9439                    let control_handle = ProfileProviderControlHandle {
9440                        inner: this.inner.clone(),
9441                    };
9442                    Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {thread_handle: req.thread_handle,
9443name: req.name,
9444period: req.period,
9445capacity: req.capacity,
9446
9447                        responder: ProfileProviderRegisterHandlerWithCapacityResponder {
9448                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9449                            tx_id: header.tx_id,
9450                        },
9451                    })
9452                }
9453                0x724d9d5fd8ef544c => {
9454                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9455                    let mut req = fidl::new_empty!(ProfileProviderUnregisterHandlerRequest, fdomain_client::fidl::FDomainResourceDialect);
9456                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
9457                    let control_handle = ProfileProviderControlHandle {
9458                        inner: this.inner.clone(),
9459                    };
9460                    Ok(ProfileProviderRequest::UnregisterHandler {thread_handle: req.thread_handle,
9461name: req.name,
9462
9463                        responder: ProfileProviderUnregisterHandlerResponder {
9464                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9465                            tx_id: header.tx_id,
9466                        },
9467                    })
9468                }
9469                0x2f509d3523e9562d => {
9470                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9471                    let mut req = fidl::new_empty!(ProfileProviderRegisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9472                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9473                    let control_handle = ProfileProviderControlHandle {
9474                        inner: this.inner.clone(),
9475                    };
9476                    Ok(ProfileProviderRequest::RegisterMemoryRange {vmar_handle: req.vmar_handle,
9477name: req.name,
9478
9479                        responder: ProfileProviderRegisterMemoryRangeResponder {
9480                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9481                            tx_id: header.tx_id,
9482                        },
9483                    })
9484                }
9485                0x2dc313d6aa81ad27 => {
9486                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9487                    let mut req = fidl::new_empty!(ProfileProviderUnregisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9488                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9489                    let control_handle = ProfileProviderControlHandle {
9490                        inner: this.inner.clone(),
9491                    };
9492                    Ok(ProfileProviderRequest::UnregisterMemoryRange {vmar_handle: req.vmar_handle,
9493
9494                        responder: ProfileProviderUnregisterMemoryRangeResponder {
9495                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9496                            tx_id: header.tx_id,
9497                        },
9498                    })
9499                }
9500                _ => Err(fidl::Error::UnknownOrdinal {
9501                    ordinal: header.ordinal,
9502                    protocol_name: <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9503                }),
9504            }))
9505            },
9506        )
9507    }
9508}
9509
9510#[derive(Debug)]
9511pub enum ProfileProviderRequest {
9512    /// Register a thread as a media thread. This notifies the media subsystem that this thread
9513    /// should have an elevated scheduling profile applied to it in order to meet audio or video
9514    /// deadlines.
9515    ///
9516    /// `name` is the name of a system scheduling role to apply to the thread given by
9517    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
9518    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
9519    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
9520    /// the scheduling interval the thread needs to be running to achieve good performance or to
9521    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
9522    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
9523    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
9524    /// be rejected or result in scaling back the performance of other threads to fit resource
9525    /// limits.
9526    ///
9527    /// Capacity, max runtime, and period have the following relationship:
9528    ///
9529    ///   capacity = max runtime / period
9530    ///
9531    /// Where:
9532    ///
9533    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
9534    ///
9535    /// For heterogeneous systems, the capacity should be planned / measured against the highest
9536    /// performance processor(s) in the system. The system will automatically adjust the effective
9537    /// capacity to account for slower processors and operating points and will avoid processors and
9538    /// operating points that are too slow to meet the requested scheduling parameters (provided
9539    /// they are reasonable).
9540    ///
9541    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
9542    /// may be zero to indicate not applicable.
9543    RegisterHandlerWithCapacity {
9544        thread_handle: fdomain_client::Thread,
9545        name: String,
9546        period: i64,
9547        capacity: f32,
9548        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
9549    },
9550    /// Reset a thread's scheduling profile to the default.
9551    UnregisterHandler {
9552        thread_handle: fdomain_client::Thread,
9553        name: String,
9554        responder: ProfileProviderUnregisterHandlerResponder,
9555    },
9556    /// Register a memory range as being used for media processing. This notifies the media
9557    /// subsystem that this memory should have an elevated memory profile applied to it in order to
9558    /// meet audio or video deadlines.
9559    ///
9560    /// `name` is the name of a system memory role to apply to the memory given by
9561    /// `vmar_handle` -- different products may customize the underlying memory strategy based
9562    /// on the requested role.
9563    RegisterMemoryRange {
9564        vmar_handle: fdomain_client::Vmar,
9565        name: String,
9566        responder: ProfileProviderRegisterMemoryRangeResponder,
9567    },
9568    /// Reset a memory range's memory profile.
9569    UnregisterMemoryRange {
9570        vmar_handle: fdomain_client::Vmar,
9571        responder: ProfileProviderUnregisterMemoryRangeResponder,
9572    },
9573}
9574
9575impl ProfileProviderRequest {
9576    #[allow(irrefutable_let_patterns)]
9577    pub fn into_register_handler_with_capacity(
9578        self,
9579    ) -> Option<(
9580        fdomain_client::Thread,
9581        String,
9582        i64,
9583        f32,
9584        ProfileProviderRegisterHandlerWithCapacityResponder,
9585    )> {
9586        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
9587            thread_handle,
9588            name,
9589            period,
9590            capacity,
9591            responder,
9592        } = self
9593        {
9594            Some((thread_handle, name, period, capacity, responder))
9595        } else {
9596            None
9597        }
9598    }
9599
9600    #[allow(irrefutable_let_patterns)]
9601    pub fn into_unregister_handler(
9602        self,
9603    ) -> Option<(fdomain_client::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
9604        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
9605            Some((thread_handle, name, responder))
9606        } else {
9607            None
9608        }
9609    }
9610
9611    #[allow(irrefutable_let_patterns)]
9612    pub fn into_register_memory_range(
9613        self,
9614    ) -> Option<(fdomain_client::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
9615        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
9616            Some((vmar_handle, name, responder))
9617        } else {
9618            None
9619        }
9620    }
9621
9622    #[allow(irrefutable_let_patterns)]
9623    pub fn into_unregister_memory_range(
9624        self,
9625    ) -> Option<(fdomain_client::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
9626        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
9627            Some((vmar_handle, responder))
9628        } else {
9629            None
9630        }
9631    }
9632
9633    /// Name of the method defined in FIDL
9634    pub fn method_name(&self) -> &'static str {
9635        match *self {
9636            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
9637                "register_handler_with_capacity"
9638            }
9639            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
9640            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
9641            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
9642        }
9643    }
9644}
9645
9646#[derive(Debug, Clone)]
9647pub struct ProfileProviderControlHandle {
9648    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9649}
9650
9651impl fdomain_client::fidl::ControlHandle for ProfileProviderControlHandle {
9652    fn shutdown(&self) {
9653        self.inner.shutdown()
9654    }
9655
9656    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9657        self.inner.shutdown_with_epitaph(status)
9658    }
9659
9660    fn is_closed(&self) -> bool {
9661        self.inner.channel().is_closed()
9662    }
9663    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9664        self.inner.channel().on_closed()
9665    }
9666}
9667
9668impl ProfileProviderControlHandle {}
9669
9670#[must_use = "FIDL methods require a response to be sent"]
9671#[derive(Debug)]
9672pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
9673    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9674    tx_id: u32,
9675}
9676
9677/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9678/// if the responder is dropped without sending a response, so that the client
9679/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9680impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
9681    fn drop(&mut self) {
9682        self.control_handle.shutdown();
9683        // Safety: drops once, never accessed again
9684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9685    }
9686}
9687
9688impl fdomain_client::fidl::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
9689    type ControlHandle = ProfileProviderControlHandle;
9690
9691    fn control_handle(&self) -> &ProfileProviderControlHandle {
9692        &self.control_handle
9693    }
9694
9695    fn drop_without_shutdown(mut self) {
9696        // Safety: drops once, never accessed again due to mem::forget
9697        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9698        // Prevent Drop from running (which would shut down the channel)
9699        std::mem::forget(self);
9700    }
9701}
9702
9703impl ProfileProviderRegisterHandlerWithCapacityResponder {
9704    /// Sends a response to the FIDL transaction.
9705    ///
9706    /// Sets the channel to shutdown if an error occurs.
9707    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9708        let _result = self.send_raw(period, capacity);
9709        if _result.is_err() {
9710            self.control_handle.shutdown();
9711        }
9712        self.drop_without_shutdown();
9713        _result
9714    }
9715
9716    /// Similar to "send" but does not shutdown the channel if an error occurs.
9717    pub fn send_no_shutdown_on_err(
9718        self,
9719        mut period: i64,
9720        mut capacity: i64,
9721    ) -> Result<(), fidl::Error> {
9722        let _result = self.send_raw(period, capacity);
9723        self.drop_without_shutdown();
9724        _result
9725    }
9726
9727    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9728        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
9729            (period, capacity),
9730            self.tx_id,
9731            0x60459ecef7458176,
9732            fidl::encoding::DynamicFlags::empty(),
9733        )
9734    }
9735}
9736
9737#[must_use = "FIDL methods require a response to be sent"]
9738#[derive(Debug)]
9739pub struct ProfileProviderUnregisterHandlerResponder {
9740    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9741    tx_id: u32,
9742}
9743
9744/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9745/// if the responder is dropped without sending a response, so that the client
9746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9747impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
9748    fn drop(&mut self) {
9749        self.control_handle.shutdown();
9750        // Safety: drops once, never accessed again
9751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9752    }
9753}
9754
9755impl fdomain_client::fidl::Responder for ProfileProviderUnregisterHandlerResponder {
9756    type ControlHandle = ProfileProviderControlHandle;
9757
9758    fn control_handle(&self) -> &ProfileProviderControlHandle {
9759        &self.control_handle
9760    }
9761
9762    fn drop_without_shutdown(mut self) {
9763        // Safety: drops once, never accessed again due to mem::forget
9764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9765        // Prevent Drop from running (which would shut down the channel)
9766        std::mem::forget(self);
9767    }
9768}
9769
9770impl ProfileProviderUnregisterHandlerResponder {
9771    /// Sends a response to the FIDL transaction.
9772    ///
9773    /// Sets the channel to shutdown if an error occurs.
9774    pub fn send(self) -> Result<(), fidl::Error> {
9775        let _result = self.send_raw();
9776        if _result.is_err() {
9777            self.control_handle.shutdown();
9778        }
9779        self.drop_without_shutdown();
9780        _result
9781    }
9782
9783    /// Similar to "send" but does not shutdown the channel if an error occurs.
9784    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9785        let _result = self.send_raw();
9786        self.drop_without_shutdown();
9787        _result
9788    }
9789
9790    fn send_raw(&self) -> Result<(), fidl::Error> {
9791        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9792            (),
9793            self.tx_id,
9794            0x724d9d5fd8ef544c,
9795            fidl::encoding::DynamicFlags::empty(),
9796        )
9797    }
9798}
9799
9800#[must_use = "FIDL methods require a response to be sent"]
9801#[derive(Debug)]
9802pub struct ProfileProviderRegisterMemoryRangeResponder {
9803    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9804    tx_id: u32,
9805}
9806
9807/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9808/// if the responder is dropped without sending a response, so that the client
9809/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9810impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
9811    fn drop(&mut self) {
9812        self.control_handle.shutdown();
9813        // Safety: drops once, never accessed again
9814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9815    }
9816}
9817
9818impl fdomain_client::fidl::Responder for ProfileProviderRegisterMemoryRangeResponder {
9819    type ControlHandle = ProfileProviderControlHandle;
9820
9821    fn control_handle(&self) -> &ProfileProviderControlHandle {
9822        &self.control_handle
9823    }
9824
9825    fn drop_without_shutdown(mut self) {
9826        // Safety: drops once, never accessed again due to mem::forget
9827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9828        // Prevent Drop from running (which would shut down the channel)
9829        std::mem::forget(self);
9830    }
9831}
9832
9833impl ProfileProviderRegisterMemoryRangeResponder {
9834    /// Sends a response to the FIDL transaction.
9835    ///
9836    /// Sets the channel to shutdown if an error occurs.
9837    pub fn send(self) -> Result<(), fidl::Error> {
9838        let _result = self.send_raw();
9839        if _result.is_err() {
9840            self.control_handle.shutdown();
9841        }
9842        self.drop_without_shutdown();
9843        _result
9844    }
9845
9846    /// Similar to "send" but does not shutdown the channel if an error occurs.
9847    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9848        let _result = self.send_raw();
9849        self.drop_without_shutdown();
9850        _result
9851    }
9852
9853    fn send_raw(&self) -> Result<(), fidl::Error> {
9854        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9855            (),
9856            self.tx_id,
9857            0x2f509d3523e9562d,
9858            fidl::encoding::DynamicFlags::empty(),
9859        )
9860    }
9861}
9862
9863#[must_use = "FIDL methods require a response to be sent"]
9864#[derive(Debug)]
9865pub struct ProfileProviderUnregisterMemoryRangeResponder {
9866    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9867    tx_id: u32,
9868}
9869
9870/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9871/// if the responder is dropped without sending a response, so that the client
9872/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9873impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
9874    fn drop(&mut self) {
9875        self.control_handle.shutdown();
9876        // Safety: drops once, never accessed again
9877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9878    }
9879}
9880
9881impl fdomain_client::fidl::Responder for ProfileProviderUnregisterMemoryRangeResponder {
9882    type ControlHandle = ProfileProviderControlHandle;
9883
9884    fn control_handle(&self) -> &ProfileProviderControlHandle {
9885        &self.control_handle
9886    }
9887
9888    fn drop_without_shutdown(mut self) {
9889        // Safety: drops once, never accessed again due to mem::forget
9890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9891        // Prevent Drop from running (which would shut down the channel)
9892        std::mem::forget(self);
9893    }
9894}
9895
9896impl ProfileProviderUnregisterMemoryRangeResponder {
9897    /// Sends a response to the FIDL transaction.
9898    ///
9899    /// Sets the channel to shutdown if an error occurs.
9900    pub fn send(self) -> Result<(), fidl::Error> {
9901        let _result = self.send_raw();
9902        if _result.is_err() {
9903            self.control_handle.shutdown();
9904        }
9905        self.drop_without_shutdown();
9906        _result
9907    }
9908
9909    /// Similar to "send" but does not shutdown the channel if an error occurs.
9910    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9911        let _result = self.send_raw();
9912        self.drop_without_shutdown();
9913        _result
9914    }
9915
9916    fn send_raw(&self) -> Result<(), fidl::Error> {
9917        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9918            (),
9919            self.tx_id,
9920            0x2dc313d6aa81ad27,
9921            fidl::encoding::DynamicFlags::empty(),
9922        )
9923    }
9924}
9925
9926#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9927pub struct SessionAudioConsumerFactoryMarker;
9928
9929impl fdomain_client::fidl::ProtocolMarker for SessionAudioConsumerFactoryMarker {
9930    type Proxy = SessionAudioConsumerFactoryProxy;
9931    type RequestStream = SessionAudioConsumerFactoryRequestStream;
9932
9933    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
9934}
9935impl fdomain_client::fidl::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
9936
9937pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
9938    fn r#create_audio_consumer(
9939        &self,
9940        session_id: u64,
9941        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9942    ) -> Result<(), fidl::Error>;
9943}
9944
9945#[derive(Debug, Clone)]
9946pub struct SessionAudioConsumerFactoryProxy {
9947    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9948}
9949
9950impl fdomain_client::fidl::Proxy for SessionAudioConsumerFactoryProxy {
9951    type Protocol = SessionAudioConsumerFactoryMarker;
9952
9953    fn from_channel(inner: fdomain_client::Channel) -> Self {
9954        Self::new(inner)
9955    }
9956
9957    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9958        self.client.into_channel().map_err(|client| Self { client })
9959    }
9960
9961    fn as_channel(&self) -> &fdomain_client::Channel {
9962        self.client.as_channel()
9963    }
9964}
9965
9966impl SessionAudioConsumerFactoryProxy {
9967    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
9968    pub fn new(channel: fdomain_client::Channel) -> Self {
9969        let protocol_name =
9970            <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9971        Self { client: fidl::client::Client::new(channel, protocol_name) }
9972    }
9973
9974    /// Get a Stream of events from the remote end of the protocol.
9975    ///
9976    /// # Panics
9977    ///
9978    /// Panics if the event stream was already taken.
9979    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
9980        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
9981    }
9982
9983    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
9984    /// to a particular session. `session_id` is the identifier of the media session
9985    /// for which audio is to be rendered.
9986    pub fn r#create_audio_consumer(
9987        &self,
9988        mut session_id: u64,
9989        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9990    ) -> Result<(), fidl::Error> {
9991        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
9992            self,
9993            session_id,
9994            audio_consumer_request,
9995        )
9996    }
9997}
9998
9999impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
10000    fn r#create_audio_consumer(
10001        &self,
10002        mut session_id: u64,
10003        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10004    ) -> Result<(), fidl::Error> {
10005        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
10006            (session_id, audio_consumer_request),
10007            0x6fab96f988e7d7fb,
10008            fidl::encoding::DynamicFlags::empty(),
10009        )
10010    }
10011}
10012
10013pub struct SessionAudioConsumerFactoryEventStream {
10014    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10015}
10016
10017impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
10018
10019impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
10020    fn is_terminated(&self) -> bool {
10021        self.event_receiver.is_terminated()
10022    }
10023}
10024
10025impl futures::Stream for SessionAudioConsumerFactoryEventStream {
10026    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
10027
10028    fn poll_next(
10029        mut self: std::pin::Pin<&mut Self>,
10030        cx: &mut std::task::Context<'_>,
10031    ) -> std::task::Poll<Option<Self::Item>> {
10032        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10033            &mut self.event_receiver,
10034            cx
10035        )?) {
10036            Some(buf) => {
10037                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
10038            }
10039            None => std::task::Poll::Ready(None),
10040        }
10041    }
10042}
10043
10044#[derive(Debug)]
10045pub enum SessionAudioConsumerFactoryEvent {}
10046
10047impl SessionAudioConsumerFactoryEvent {
10048    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
10049    fn decode(
10050        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10051    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
10052        let (bytes, _handles) = buf.split_mut();
10053        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10054        debug_assert_eq!(tx_header.tx_id, 0);
10055        match tx_header.ordinal {
10056            _ => Err(fidl::Error::UnknownOrdinal {
10057                ordinal: tx_header.ordinal,
10058                protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10059            })
10060        }
10061    }
10062}
10063
10064/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
10065pub struct SessionAudioConsumerFactoryRequestStream {
10066    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10067    is_terminated: bool,
10068}
10069
10070impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
10071
10072impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
10073    fn is_terminated(&self) -> bool {
10074        self.is_terminated
10075    }
10076}
10077
10078impl fdomain_client::fidl::RequestStream for SessionAudioConsumerFactoryRequestStream {
10079    type Protocol = SessionAudioConsumerFactoryMarker;
10080    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
10081
10082    fn from_channel(channel: fdomain_client::Channel) -> Self {
10083        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10084    }
10085
10086    fn control_handle(&self) -> Self::ControlHandle {
10087        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
10088    }
10089
10090    fn into_inner(
10091        self,
10092    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10093    {
10094        (self.inner, self.is_terminated)
10095    }
10096
10097    fn from_inner(
10098        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10099        is_terminated: bool,
10100    ) -> Self {
10101        Self { inner, is_terminated }
10102    }
10103}
10104
10105impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
10106    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
10107
10108    fn poll_next(
10109        mut self: std::pin::Pin<&mut Self>,
10110        cx: &mut std::task::Context<'_>,
10111    ) -> std::task::Poll<Option<Self::Item>> {
10112        let this = &mut *self;
10113        if this.inner.check_shutdown(cx) {
10114            this.is_terminated = true;
10115            return std::task::Poll::Ready(None);
10116        }
10117        if this.is_terminated {
10118            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
10119        }
10120        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10121            |bytes, handles| {
10122                match this.inner.channel().read_etc(cx, bytes, handles) {
10123                    std::task::Poll::Ready(Ok(())) => {}
10124                    std::task::Poll::Pending => return std::task::Poll::Pending,
10125                    std::task::Poll::Ready(Err(None)) => {
10126                        this.is_terminated = true;
10127                        return std::task::Poll::Ready(None);
10128                    }
10129                    std::task::Poll::Ready(Err(Some(e))) => {
10130                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10131                            e.into(),
10132                        ))));
10133                    }
10134                }
10135
10136                // A message has been received from the channel
10137                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10138
10139                std::task::Poll::Ready(Some(match header.ordinal {
10140                0x6fab96f988e7d7fb => {
10141                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10142                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
10143                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
10144                    let control_handle = SessionAudioConsumerFactoryControlHandle {
10145                        inner: this.inner.clone(),
10146                    };
10147                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
10148audio_consumer_request: req.audio_consumer_request,
10149
10150                        control_handle,
10151                    })
10152                }
10153                _ => Err(fidl::Error::UnknownOrdinal {
10154                    ordinal: header.ordinal,
10155                    protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10156                }),
10157            }))
10158            },
10159        )
10160    }
10161}
10162
10163/// Interface for creating audio consumers bound to a session.
10164#[derive(Debug)]
10165pub enum SessionAudioConsumerFactoryRequest {
10166    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
10167    /// to a particular session. `session_id` is the identifier of the media session
10168    /// for which audio is to be rendered.
10169    CreateAudioConsumer {
10170        session_id: u64,
10171        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10172        control_handle: SessionAudioConsumerFactoryControlHandle,
10173    },
10174}
10175
10176impl SessionAudioConsumerFactoryRequest {
10177    #[allow(irrefutable_let_patterns)]
10178    pub fn into_create_audio_consumer(
10179        self,
10180    ) -> Option<(
10181        u64,
10182        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10183        SessionAudioConsumerFactoryControlHandle,
10184    )> {
10185        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
10186            session_id,
10187            audio_consumer_request,
10188            control_handle,
10189        } = self
10190        {
10191            Some((session_id, audio_consumer_request, control_handle))
10192        } else {
10193            None
10194        }
10195    }
10196
10197    /// Name of the method defined in FIDL
10198    pub fn method_name(&self) -> &'static str {
10199        match *self {
10200            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
10201                "create_audio_consumer"
10202            }
10203        }
10204    }
10205}
10206
10207#[derive(Debug, Clone)]
10208pub struct SessionAudioConsumerFactoryControlHandle {
10209    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10210}
10211
10212impl fdomain_client::fidl::ControlHandle for SessionAudioConsumerFactoryControlHandle {
10213    fn shutdown(&self) {
10214        self.inner.shutdown()
10215    }
10216
10217    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10218        self.inner.shutdown_with_epitaph(status)
10219    }
10220
10221    fn is_closed(&self) -> bool {
10222        self.inner.channel().is_closed()
10223    }
10224    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
10225        self.inner.channel().on_closed()
10226    }
10227}
10228
10229impl SessionAudioConsumerFactoryControlHandle {}
10230
10231#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10232pub struct SimpleStreamSinkMarker;
10233
10234impl fdomain_client::fidl::ProtocolMarker for SimpleStreamSinkMarker {
10235    type Proxy = SimpleStreamSinkProxy;
10236    type RequestStream = SimpleStreamSinkRequestStream;
10237
10238    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
10239}
10240
10241pub trait SimpleStreamSinkProxyInterface: Send + Sync {
10242    fn r#add_payload_buffer(
10243        &self,
10244        id: u32,
10245        payload_buffer: fdomain_client::Vmo,
10246    ) -> Result<(), fidl::Error>;
10247    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
10248    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10249    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
10250    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
10251    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
10252    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10253    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
10254    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
10255}
10256
10257#[derive(Debug, Clone)]
10258pub struct SimpleStreamSinkProxy {
10259    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
10260}
10261
10262impl fdomain_client::fidl::Proxy for SimpleStreamSinkProxy {
10263    type Protocol = SimpleStreamSinkMarker;
10264
10265    fn from_channel(inner: fdomain_client::Channel) -> Self {
10266        Self::new(inner)
10267    }
10268
10269    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
10270        self.client.into_channel().map_err(|client| Self { client })
10271    }
10272
10273    fn as_channel(&self) -> &fdomain_client::Channel {
10274        self.client.as_channel()
10275    }
10276}
10277
10278impl SimpleStreamSinkProxy {
10279    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
10280    pub fn new(channel: fdomain_client::Channel) -> Self {
10281        let protocol_name =
10282            <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
10283        Self { client: fidl::client::Client::new(channel, protocol_name) }
10284    }
10285
10286    /// Get a Stream of events from the remote end of the protocol.
10287    ///
10288    /// # Panics
10289    ///
10290    /// Panics if the event stream was already taken.
10291    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
10292        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
10293    }
10294
10295    /// Adds a payload buffer to the current buffer set associated with the
10296    /// connection. A `StreamPacket` struct reference a payload buffer in the
10297    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10298    ///
10299    /// A buffer with ID `id` must not be in the current set when this method is
10300    /// invoked, otherwise the service will close the connection.
10301    pub fn r#add_payload_buffer(
10302        &self,
10303        mut id: u32,
10304        mut payload_buffer: fdomain_client::Vmo,
10305    ) -> Result<(), fidl::Error> {
10306        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
10307    }
10308
10309    /// Removes a payload buffer from the current buffer set associated with the
10310    /// connection.
10311    ///
10312    /// A buffer with ID `id` must exist in the current set when this method is
10313    /// invoked, otherwise the service will will close the connection.
10314    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10315        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
10316    }
10317
10318    /// Sends a packet to the service. The response is sent when the service is
10319    /// done with the associated payload memory.
10320    ///
10321    /// `packet` must be valid for the current buffer set, otherwise the service
10322    /// will close the connection.
10323    pub fn r#send_packet(
10324        &self,
10325        mut packet: &StreamPacket,
10326    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10327        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
10328    }
10329
10330    /// Sends a packet to the service. This interface doesn't define how the
10331    /// client knows when the sink is done with the associated payload memory.
10332    /// The inheriting interface must define that.
10333    ///
10334    /// `packet` must be valid for the current buffer set, otherwise the service
10335    /// will close the connection.
10336    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10337        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
10338    }
10339
10340    /// Indicates the stream has ended. The precise semantics of this method are
10341    /// determined by the inheriting interface.
10342    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10343        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
10344    }
10345
10346    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10347    /// and not yet released. The response is sent after all packets have been
10348    /// released.
10349    pub fn r#discard_all_packets(
10350        &self,
10351    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10352        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
10353    }
10354
10355    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10356    /// and not yet released.
10357    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10358        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
10359    }
10360}
10361
10362impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
10363    fn r#add_payload_buffer(
10364        &self,
10365        mut id: u32,
10366        mut payload_buffer: fdomain_client::Vmo,
10367    ) -> Result<(), fidl::Error> {
10368        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
10369            (id, payload_buffer),
10370            0x3b3a37fc34fe5b56,
10371            fidl::encoding::DynamicFlags::empty(),
10372        )
10373    }
10374
10375    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10376        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
10377            (id,),
10378            0x5d1e4f74c3658262,
10379            fidl::encoding::DynamicFlags::empty(),
10380        )
10381    }
10382
10383    type SendPacketResponseFut =
10384        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10385    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
10386        fn _decode(
10387            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10388        ) -> Result<(), fidl::Error> {
10389            let _response = fidl::client::decode_transaction_body::<
10390                fidl::encoding::EmptyPayload,
10391                fdomain_client::fidl::FDomainResourceDialect,
10392                0x67cddd607442775f,
10393            >(_buf?)?;
10394            Ok(_response)
10395        }
10396        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
10397            (packet,),
10398            0x67cddd607442775f,
10399            fidl::encoding::DynamicFlags::empty(),
10400            _decode,
10401        )
10402    }
10403
10404    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10405        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
10406            (packet,),
10407            0x8d9b8b413ceba9d,
10408            fidl::encoding::DynamicFlags::empty(),
10409        )
10410    }
10411
10412    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10413        self.client.send::<fidl::encoding::EmptyPayload>(
10414            (),
10415            0x6180fd6f7e793b71,
10416            fidl::encoding::DynamicFlags::empty(),
10417        )
10418    }
10419
10420    type DiscardAllPacketsResponseFut =
10421        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10422    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
10423        fn _decode(
10424            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10425        ) -> Result<(), fidl::Error> {
10426            let _response = fidl::client::decode_transaction_body::<
10427                fidl::encoding::EmptyPayload,
10428                fdomain_client::fidl::FDomainResourceDialect,
10429                0x6f4dad7af2917665,
10430            >(_buf?)?;
10431            Ok(_response)
10432        }
10433        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
10434            (),
10435            0x6f4dad7af2917665,
10436            fidl::encoding::DynamicFlags::empty(),
10437            _decode,
10438        )
10439    }
10440
10441    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10442        self.client.send::<fidl::encoding::EmptyPayload>(
10443            (),
10444            0x50d36d0d23081bc4,
10445            fidl::encoding::DynamicFlags::empty(),
10446        )
10447    }
10448}
10449
10450pub struct SimpleStreamSinkEventStream {
10451    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10452}
10453
10454impl std::marker::Unpin for SimpleStreamSinkEventStream {}
10455
10456impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
10457    fn is_terminated(&self) -> bool {
10458        self.event_receiver.is_terminated()
10459    }
10460}
10461
10462impl futures::Stream for SimpleStreamSinkEventStream {
10463    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
10464
10465    fn poll_next(
10466        mut self: std::pin::Pin<&mut Self>,
10467        cx: &mut std::task::Context<'_>,
10468    ) -> std::task::Poll<Option<Self::Item>> {
10469        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10470            &mut self.event_receiver,
10471            cx
10472        )?) {
10473            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
10474            None => std::task::Poll::Ready(None),
10475        }
10476    }
10477}
10478
10479#[derive(Debug)]
10480pub enum SimpleStreamSinkEvent {}
10481
10482impl SimpleStreamSinkEvent {
10483    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
10484    fn decode(
10485        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10486    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
10487        let (bytes, _handles) = buf.split_mut();
10488        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10489        debug_assert_eq!(tx_header.tx_id, 0);
10490        match tx_header.ordinal {
10491            _ => Err(fidl::Error::UnknownOrdinal {
10492                ordinal: tx_header.ordinal,
10493                protocol_name:
10494                    <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10495            }),
10496        }
10497    }
10498}
10499
10500/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
10501pub struct SimpleStreamSinkRequestStream {
10502    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10503    is_terminated: bool,
10504}
10505
10506impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
10507
10508impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
10509    fn is_terminated(&self) -> bool {
10510        self.is_terminated
10511    }
10512}
10513
10514impl fdomain_client::fidl::RequestStream for SimpleStreamSinkRequestStream {
10515    type Protocol = SimpleStreamSinkMarker;
10516    type ControlHandle = SimpleStreamSinkControlHandle;
10517
10518    fn from_channel(channel: fdomain_client::Channel) -> Self {
10519        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10520    }
10521
10522    fn control_handle(&self) -> Self::ControlHandle {
10523        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
10524    }
10525
10526    fn into_inner(
10527        self,
10528    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10529    {
10530        (self.inner, self.is_terminated)
10531    }
10532
10533    fn from_inner(
10534        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10535        is_terminated: bool,
10536    ) -> Self {
10537        Self { inner, is_terminated }
10538    }
10539}
10540
10541impl futures::Stream for SimpleStreamSinkRequestStream {
10542    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
10543
10544    fn poll_next(
10545        mut self: std::pin::Pin<&mut Self>,
10546        cx: &mut std::task::Context<'_>,
10547    ) -> std::task::Poll<Option<Self::Item>> {
10548        let this = &mut *self;
10549        if this.inner.check_shutdown(cx) {
10550            this.is_terminated = true;
10551            return std::task::Poll::Ready(None);
10552        }
10553        if this.is_terminated {
10554            panic!("polled SimpleStreamSinkRequestStream after completion");
10555        }
10556        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10557            |bytes, handles| {
10558                match this.inner.channel().read_etc(cx, bytes, handles) {
10559                    std::task::Poll::Ready(Ok(())) => {}
10560                    std::task::Poll::Pending => return std::task::Poll::Pending,
10561                    std::task::Poll::Ready(Err(None)) => {
10562                        this.is_terminated = true;
10563                        return std::task::Poll::Ready(None);
10564                    }
10565                    std::task::Poll::Ready(Err(Some(e))) => {
10566                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10567                            e.into(),
10568                        ))));
10569                    }
10570                }
10571
10572                // A message has been received from the channel
10573                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10574
10575                std::task::Poll::Ready(Some(match header.ordinal {
10576                0x3b3a37fc34fe5b56 => {
10577                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10578                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10579                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10580                    let control_handle = SimpleStreamSinkControlHandle {
10581                        inner: this.inner.clone(),
10582                    };
10583                    Ok(SimpleStreamSinkRequest::AddPayloadBuffer {id: req.id,
10584payload_buffer: req.payload_buffer,
10585
10586                        control_handle,
10587                    })
10588                }
10589                0x5d1e4f74c3658262 => {
10590                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10591                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10592                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10593                    let control_handle = SimpleStreamSinkControlHandle {
10594                        inner: this.inner.clone(),
10595                    };
10596                    Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {id: req.id,
10597
10598                        control_handle,
10599                    })
10600                }
10601                0x67cddd607442775f => {
10602                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10603                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
10604                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
10605                    let control_handle = SimpleStreamSinkControlHandle {
10606                        inner: this.inner.clone(),
10607                    };
10608                    Ok(SimpleStreamSinkRequest::SendPacket {packet: req.packet,
10609
10610                        responder: SimpleStreamSinkSendPacketResponder {
10611                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10612                            tx_id: header.tx_id,
10613                        },
10614                    })
10615                }
10616                0x8d9b8b413ceba9d => {
10617                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10618                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
10619                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
10620                    let control_handle = SimpleStreamSinkControlHandle {
10621                        inner: this.inner.clone(),
10622                    };
10623                    Ok(SimpleStreamSinkRequest::SendPacketNoReply {packet: req.packet,
10624
10625                        control_handle,
10626                    })
10627                }
10628                0x6180fd6f7e793b71 => {
10629                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10630                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10631                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10632                    let control_handle = SimpleStreamSinkControlHandle {
10633                        inner: this.inner.clone(),
10634                    };
10635                    Ok(SimpleStreamSinkRequest::EndOfStream {
10636                        control_handle,
10637                    })
10638                }
10639                0x6f4dad7af2917665 => {
10640                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10641                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10642                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10643                    let control_handle = SimpleStreamSinkControlHandle {
10644                        inner: this.inner.clone(),
10645                    };
10646                    Ok(SimpleStreamSinkRequest::DiscardAllPackets {
10647                        responder: SimpleStreamSinkDiscardAllPacketsResponder {
10648                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10649                            tx_id: header.tx_id,
10650                        },
10651                    })
10652                }
10653                0x50d36d0d23081bc4 => {
10654                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10655                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10656                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10657                    let control_handle = SimpleStreamSinkControlHandle {
10658                        inner: this.inner.clone(),
10659                    };
10660                    Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply {
10661                        control_handle,
10662                    })
10663                }
10664                _ => Err(fidl::Error::UnknownOrdinal {
10665                    ordinal: header.ordinal,
10666                    protocol_name: <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10667                }),
10668            }))
10669            },
10670        )
10671    }
10672}
10673
10674/// A StreamSink that uses StreamBufferSet for buffer management.
10675#[derive(Debug)]
10676pub enum SimpleStreamSinkRequest {
10677    /// Adds a payload buffer to the current buffer set associated with the
10678    /// connection. A `StreamPacket` struct reference a payload buffer in the
10679    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10680    ///
10681    /// A buffer with ID `id` must not be in the current set when this method is
10682    /// invoked, otherwise the service will close the connection.
10683    AddPayloadBuffer {
10684        id: u32,
10685        payload_buffer: fdomain_client::Vmo,
10686        control_handle: SimpleStreamSinkControlHandle,
10687    },
10688    /// Removes a payload buffer from the current buffer set associated with the
10689    /// connection.
10690    ///
10691    /// A buffer with ID `id` must exist in the current set when this method is
10692    /// invoked, otherwise the service will will close the connection.
10693    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
10694    /// Sends a packet to the service. The response is sent when the service is
10695    /// done with the associated payload memory.
10696    ///
10697    /// `packet` must be valid for the current buffer set, otherwise the service
10698    /// will close the connection.
10699    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
10700    /// Sends a packet to the service. This interface doesn't define how the
10701    /// client knows when the sink is done with the associated payload memory.
10702    /// The inheriting interface must define that.
10703    ///
10704    /// `packet` must be valid for the current buffer set, otherwise the service
10705    /// will close the connection.
10706    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
10707    /// Indicates the stream has ended. The precise semantics of this method are
10708    /// determined by the inheriting interface.
10709    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
10710    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10711    /// and not yet released. The response is sent after all packets have been
10712    /// released.
10713    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
10714    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10715    /// and not yet released.
10716    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
10717}
10718
10719impl SimpleStreamSinkRequest {
10720    #[allow(irrefutable_let_patterns)]
10721    pub fn into_add_payload_buffer(
10722        self,
10723    ) -> Option<(u32, fdomain_client::Vmo, SimpleStreamSinkControlHandle)> {
10724        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
10725            self
10726        {
10727            Some((id, payload_buffer, control_handle))
10728        } else {
10729            None
10730        }
10731    }
10732
10733    #[allow(irrefutable_let_patterns)]
10734    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
10735        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
10736            Some((id, control_handle))
10737        } else {
10738            None
10739        }
10740    }
10741
10742    #[allow(irrefutable_let_patterns)]
10743    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
10744        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
10745            Some((packet, responder))
10746        } else {
10747            None
10748        }
10749    }
10750
10751    #[allow(irrefutable_let_patterns)]
10752    pub fn into_send_packet_no_reply(
10753        self,
10754    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
10755        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
10756            Some((packet, control_handle))
10757        } else {
10758            None
10759        }
10760    }
10761
10762    #[allow(irrefutable_let_patterns)]
10763    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
10764        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
10765            Some((control_handle))
10766        } else {
10767            None
10768        }
10769    }
10770
10771    #[allow(irrefutable_let_patterns)]
10772    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
10773        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
10774            Some((responder))
10775        } else {
10776            None
10777        }
10778    }
10779
10780    #[allow(irrefutable_let_patterns)]
10781    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
10782        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
10783            Some((control_handle))
10784        } else {
10785            None
10786        }
10787    }
10788
10789    /// Name of the method defined in FIDL
10790    pub fn method_name(&self) -> &'static str {
10791        match *self {
10792            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10793            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10794            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
10795            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10796            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
10797            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
10798            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
10799                "discard_all_packets_no_reply"
10800            }
10801        }
10802    }
10803}
10804
10805#[derive(Debug, Clone)]
10806pub struct SimpleStreamSinkControlHandle {
10807    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10808}
10809
10810impl fdomain_client::fidl::ControlHandle for SimpleStreamSinkControlHandle {
10811    fn shutdown(&self) {
10812        self.inner.shutdown()
10813    }
10814
10815    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10816        self.inner.shutdown_with_epitaph(status)
10817    }
10818
10819    fn is_closed(&self) -> bool {
10820        self.inner.channel().is_closed()
10821    }
10822    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
10823        self.inner.channel().on_closed()
10824    }
10825}
10826
10827impl SimpleStreamSinkControlHandle {}
10828
10829#[must_use = "FIDL methods require a response to be sent"]
10830#[derive(Debug)]
10831pub struct SimpleStreamSinkSendPacketResponder {
10832    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10833    tx_id: u32,
10834}
10835
10836/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10837/// if the responder is dropped without sending a response, so that the client
10838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10839impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
10840    fn drop(&mut self) {
10841        self.control_handle.shutdown();
10842        // Safety: drops once, never accessed again
10843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10844    }
10845}
10846
10847impl fdomain_client::fidl::Responder for SimpleStreamSinkSendPacketResponder {
10848    type ControlHandle = SimpleStreamSinkControlHandle;
10849
10850    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10851        &self.control_handle
10852    }
10853
10854    fn drop_without_shutdown(mut self) {
10855        // Safety: drops once, never accessed again due to mem::forget
10856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10857        // Prevent Drop from running (which would shut down the channel)
10858        std::mem::forget(self);
10859    }
10860}
10861
10862impl SimpleStreamSinkSendPacketResponder {
10863    /// Sends a response to the FIDL transaction.
10864    ///
10865    /// Sets the channel to shutdown if an error occurs.
10866    pub fn send(self) -> Result<(), fidl::Error> {
10867        let _result = self.send_raw();
10868        if _result.is_err() {
10869            self.control_handle.shutdown();
10870        }
10871        self.drop_without_shutdown();
10872        _result
10873    }
10874
10875    /// Similar to "send" but does not shutdown the channel if an error occurs.
10876    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10877        let _result = self.send_raw();
10878        self.drop_without_shutdown();
10879        _result
10880    }
10881
10882    fn send_raw(&self) -> Result<(), fidl::Error> {
10883        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10884            (),
10885            self.tx_id,
10886            0x67cddd607442775f,
10887            fidl::encoding::DynamicFlags::empty(),
10888        )
10889    }
10890}
10891
10892#[must_use = "FIDL methods require a response to be sent"]
10893#[derive(Debug)]
10894pub struct SimpleStreamSinkDiscardAllPacketsResponder {
10895    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10896    tx_id: u32,
10897}
10898
10899/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10900/// if the responder is dropped without sending a response, so that the client
10901/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10902impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
10903    fn drop(&mut self) {
10904        self.control_handle.shutdown();
10905        // Safety: drops once, never accessed again
10906        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10907    }
10908}
10909
10910impl fdomain_client::fidl::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
10911    type ControlHandle = SimpleStreamSinkControlHandle;
10912
10913    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10914        &self.control_handle
10915    }
10916
10917    fn drop_without_shutdown(mut self) {
10918        // Safety: drops once, never accessed again due to mem::forget
10919        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10920        // Prevent Drop from running (which would shut down the channel)
10921        std::mem::forget(self);
10922    }
10923}
10924
10925impl SimpleStreamSinkDiscardAllPacketsResponder {
10926    /// Sends a response to the FIDL transaction.
10927    ///
10928    /// Sets the channel to shutdown if an error occurs.
10929    pub fn send(self) -> Result<(), fidl::Error> {
10930        let _result = self.send_raw();
10931        if _result.is_err() {
10932            self.control_handle.shutdown();
10933        }
10934        self.drop_without_shutdown();
10935        _result
10936    }
10937
10938    /// Similar to "send" but does not shutdown the channel if an error occurs.
10939    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10940        let _result = self.send_raw();
10941        self.drop_without_shutdown();
10942        _result
10943    }
10944
10945    fn send_raw(&self) -> Result<(), fidl::Error> {
10946        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10947            (),
10948            self.tx_id,
10949            0x6f4dad7af2917665,
10950            fidl::encoding::DynamicFlags::empty(),
10951        )
10952    }
10953}
10954
10955#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10956pub struct StreamBufferSetMarker;
10957
10958impl fdomain_client::fidl::ProtocolMarker for StreamBufferSetMarker {
10959    type Proxy = StreamBufferSetProxy;
10960    type RequestStream = StreamBufferSetRequestStream;
10961
10962    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
10963}
10964
10965pub trait StreamBufferSetProxyInterface: Send + Sync {
10966    fn r#add_payload_buffer(
10967        &self,
10968        id: u32,
10969        payload_buffer: fdomain_client::Vmo,
10970    ) -> Result<(), fidl::Error>;
10971    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
10972}
10973
10974#[derive(Debug, Clone)]
10975pub struct StreamBufferSetProxy {
10976    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
10977}
10978
10979impl fdomain_client::fidl::Proxy for StreamBufferSetProxy {
10980    type Protocol = StreamBufferSetMarker;
10981
10982    fn from_channel(inner: fdomain_client::Channel) -> Self {
10983        Self::new(inner)
10984    }
10985
10986    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
10987        self.client.into_channel().map_err(|client| Self { client })
10988    }
10989
10990    fn as_channel(&self) -> &fdomain_client::Channel {
10991        self.client.as_channel()
10992    }
10993}
10994
10995impl StreamBufferSetProxy {
10996    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
10997    pub fn new(channel: fdomain_client::Channel) -> Self {
10998        let protocol_name =
10999            <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11000        Self { client: fidl::client::Client::new(channel, protocol_name) }
11001    }
11002
11003    /// Get a Stream of events from the remote end of the protocol.
11004    ///
11005    /// # Panics
11006    ///
11007    /// Panics if the event stream was already taken.
11008    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
11009        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
11010    }
11011
11012    /// Adds a payload buffer to the current buffer set associated with the
11013    /// connection. A `StreamPacket` struct reference a payload buffer in the
11014    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
11015    ///
11016    /// A buffer with ID `id` must not be in the current set when this method is
11017    /// invoked, otherwise the service will close the connection.
11018    pub fn r#add_payload_buffer(
11019        &self,
11020        mut id: u32,
11021        mut payload_buffer: fdomain_client::Vmo,
11022    ) -> Result<(), fidl::Error> {
11023        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
11024    }
11025
11026    /// Removes a payload buffer from the current buffer set associated with the
11027    /// connection.
11028    ///
11029    /// A buffer with ID `id` must exist in the current set when this method is
11030    /// invoked, otherwise the service will will close the connection.
11031    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
11032        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
11033    }
11034}
11035
11036impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
11037    fn r#add_payload_buffer(
11038        &self,
11039        mut id: u32,
11040        mut payload_buffer: fdomain_client::Vmo,
11041    ) -> Result<(), fidl::Error> {
11042        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
11043            (id, payload_buffer),
11044            0x3b3a37fc34fe5b56,
11045            fidl::encoding::DynamicFlags::empty(),
11046        )
11047    }
11048
11049    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
11050        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
11051            (id,),
11052            0x5d1e4f74c3658262,
11053            fidl::encoding::DynamicFlags::empty(),
11054        )
11055    }
11056}
11057
11058pub struct StreamBufferSetEventStream {
11059    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
11060}
11061
11062impl std::marker::Unpin for StreamBufferSetEventStream {}
11063
11064impl futures::stream::FusedStream for StreamBufferSetEventStream {
11065    fn is_terminated(&self) -> bool {
11066        self.event_receiver.is_terminated()
11067    }
11068}
11069
11070impl futures::Stream for StreamBufferSetEventStream {
11071    type Item = Result<StreamBufferSetEvent, fidl::Error>;
11072
11073    fn poll_next(
11074        mut self: std::pin::Pin<&mut Self>,
11075        cx: &mut std::task::Context<'_>,
11076    ) -> std::task::Poll<Option<Self::Item>> {
11077        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11078            &mut self.event_receiver,
11079            cx
11080        )?) {
11081            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
11082            None => std::task::Poll::Ready(None),
11083        }
11084    }
11085}
11086
11087#[derive(Debug)]
11088pub enum StreamBufferSetEvent {}
11089
11090impl StreamBufferSetEvent {
11091    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
11092    fn decode(
11093        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11094    ) -> Result<StreamBufferSetEvent, fidl::Error> {
11095        let (bytes, _handles) = buf.split_mut();
11096        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11097        debug_assert_eq!(tx_header.tx_id, 0);
11098        match tx_header.ordinal {
11099            _ => Err(fidl::Error::UnknownOrdinal {
11100                ordinal: tx_header.ordinal,
11101                protocol_name:
11102                    <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11103            }),
11104        }
11105    }
11106}
11107
11108/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
11109pub struct StreamBufferSetRequestStream {
11110    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11111    is_terminated: bool,
11112}
11113
11114impl std::marker::Unpin for StreamBufferSetRequestStream {}
11115
11116impl futures::stream::FusedStream for StreamBufferSetRequestStream {
11117    fn is_terminated(&self) -> bool {
11118        self.is_terminated
11119    }
11120}
11121
11122impl fdomain_client::fidl::RequestStream for StreamBufferSetRequestStream {
11123    type Protocol = StreamBufferSetMarker;
11124    type ControlHandle = StreamBufferSetControlHandle;
11125
11126    fn from_channel(channel: fdomain_client::Channel) -> Self {
11127        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11128    }
11129
11130    fn control_handle(&self) -> Self::ControlHandle {
11131        StreamBufferSetControlHandle { inner: self.inner.clone() }
11132    }
11133
11134    fn into_inner(
11135        self,
11136    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
11137    {
11138        (self.inner, self.is_terminated)
11139    }
11140
11141    fn from_inner(
11142        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11143        is_terminated: bool,
11144    ) -> Self {
11145        Self { inner, is_terminated }
11146    }
11147}
11148
11149impl futures::Stream for StreamBufferSetRequestStream {
11150    type Item = Result<StreamBufferSetRequest, fidl::Error>;
11151
11152    fn poll_next(
11153        mut self: std::pin::Pin<&mut Self>,
11154        cx: &mut std::task::Context<'_>,
11155    ) -> std::task::Poll<Option<Self::Item>> {
11156        let this = &mut *self;
11157        if this.inner.check_shutdown(cx) {
11158            this.is_terminated = true;
11159            return std::task::Poll::Ready(None);
11160        }
11161        if this.is_terminated {
11162            panic!("polled StreamBufferSetRequestStream after completion");
11163        }
11164        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
11165            |bytes, handles| {
11166                match this.inner.channel().read_etc(cx, bytes, handles) {
11167                    std::task::Poll::Ready(Ok(())) => {}
11168                    std::task::Poll::Pending => return std::task::Poll::Pending,
11169                    std::task::Poll::Ready(Err(None)) => {
11170                        this.is_terminated = true;
11171                        return std::task::Poll::Ready(None);
11172                    }
11173                    std::task::Poll::Ready(Err(Some(e))) => {
11174                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11175                            e.into(),
11176                        ))));
11177                    }
11178                }
11179
11180                // A message has been received from the channel
11181                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11182
11183                std::task::Poll::Ready(Some(match header.ordinal {
11184                0x3b3a37fc34fe5b56 => {
11185                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11186                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
11187                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
11188                    let control_handle = StreamBufferSetControlHandle {
11189                        inner: this.inner.clone(),
11190                    };
11191                    Ok(StreamBufferSetRequest::AddPayloadBuffer {id: req.id,
11192payload_buffer: req.payload_buffer,
11193
11194                        control_handle,
11195                    })
11196                }
11197                0x5d1e4f74c3658262 => {
11198                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11199                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
11200                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
11201                    let control_handle = StreamBufferSetControlHandle {
11202                        inner: this.inner.clone(),
11203                    };
11204                    Ok(StreamBufferSetRequest::RemovePayloadBuffer {id: req.id,
11205
11206                        control_handle,
11207                    })
11208                }
11209                _ => Err(fidl::Error::UnknownOrdinal {
11210                    ordinal: header.ordinal,
11211                    protocol_name: <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11212                }),
11213            }))
11214            },
11215        )
11216    }
11217}
11218
11219/// Manages a set of payload buffers for a stream. This interface is typically
11220/// inherited along with `StreamSink` or `StreamSource` to enable the transport
11221/// of elementary streams between clients and services.
11222#[derive(Debug)]
11223pub enum StreamBufferSetRequest {
11224    /// Adds a payload buffer to the current buffer set associated with the
11225    /// connection. A `StreamPacket` struct reference a payload buffer in the
11226    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
11227    ///
11228    /// A buffer with ID `id` must not be in the current set when this method is
11229    /// invoked, otherwise the service will close the connection.
11230    AddPayloadBuffer {
11231        id: u32,
11232        payload_buffer: fdomain_client::Vmo,
11233        control_handle: StreamBufferSetControlHandle,
11234    },
11235    /// Removes a payload buffer from the current buffer set associated with the
11236    /// connection.
11237    ///
11238    /// A buffer with ID `id` must exist in the current set when this method is
11239    /// invoked, otherwise the service will will close the connection.
11240    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
11241}
11242
11243impl StreamBufferSetRequest {
11244    #[allow(irrefutable_let_patterns)]
11245    pub fn into_add_payload_buffer(
11246        self,
11247    ) -> Option<(u32, fdomain_client::Vmo, StreamBufferSetControlHandle)> {
11248        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
11249            self
11250        {
11251            Some((id, payload_buffer, control_handle))
11252        } else {
11253            None
11254        }
11255    }
11256
11257    #[allow(irrefutable_let_patterns)]
11258    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
11259        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
11260            Some((id, control_handle))
11261        } else {
11262            None
11263        }
11264    }
11265
11266    /// Name of the method defined in FIDL
11267    pub fn method_name(&self) -> &'static str {
11268        match *self {
11269            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
11270            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
11271        }
11272    }
11273}
11274
11275#[derive(Debug, Clone)]
11276pub struct StreamBufferSetControlHandle {
11277    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11278}
11279
11280impl fdomain_client::fidl::ControlHandle for StreamBufferSetControlHandle {
11281    fn shutdown(&self) {
11282        self.inner.shutdown()
11283    }
11284
11285    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11286        self.inner.shutdown_with_epitaph(status)
11287    }
11288
11289    fn is_closed(&self) -> bool {
11290        self.inner.channel().is_closed()
11291    }
11292    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11293        self.inner.channel().on_closed()
11294    }
11295}
11296
11297impl StreamBufferSetControlHandle {}
11298
11299#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11300pub struct StreamProcessorMarker;
11301
11302impl fdomain_client::fidl::ProtocolMarker for StreamProcessorMarker {
11303    type Proxy = StreamProcessorProxy;
11304    type RequestStream = StreamProcessorRequestStream;
11305
11306    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
11307}
11308
11309pub trait StreamProcessorProxyInterface: Send + Sync {
11310    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
11311    fn r#set_input_buffer_partial_settings(
11312        &self,
11313        input_settings: StreamBufferPartialSettings,
11314    ) -> Result<(), fidl::Error>;
11315    fn r#set_output_buffer_partial_settings(
11316        &self,
11317        output_settings: StreamBufferPartialSettings,
11318    ) -> Result<(), fidl::Error>;
11319    fn r#complete_output_buffer_partial_settings(
11320        &self,
11321        buffer_lifetime_ordinal: u64,
11322    ) -> Result<(), fidl::Error>;
11323    fn r#flush_end_of_stream_and_close_stream(
11324        &self,
11325        stream_lifetime_ordinal: u64,
11326    ) -> Result<(), fidl::Error>;
11327    fn r#close_current_stream(
11328        &self,
11329        stream_lifetime_ordinal: u64,
11330        release_input_buffers: bool,
11331        release_output_buffers: bool,
11332    ) -> Result<(), fidl::Error>;
11333    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11334    fn r#sync(&self) -> Self::SyncResponseFut;
11335    fn r#recycle_output_packet(
11336        &self,
11337        available_output_packet: &PacketHeader,
11338    ) -> Result<(), fidl::Error>;
11339    fn r#queue_input_format_details(
11340        &self,
11341        stream_lifetime_ordinal: u64,
11342        format_details: &FormatDetails,
11343    ) -> Result<(), fidl::Error>;
11344    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
11345    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
11346    fn r#participate_in_buffer_allocation(
11347        &self,
11348        payload: StreamProcessorParticipateInBufferAllocationRequest,
11349    ) -> Result<(), fidl::Error>;
11350    fn r#add_buffer(&self, payload: StreamProcessorAddBufferRequest) -> Result<(), fidl::Error>;
11351    type RemoveBufferResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11352    fn r#remove_buffer(
11353        &self,
11354        payload: StreamProcessorRemoveBufferRequest,
11355    ) -> Self::RemoveBufferResponseFut;
11356    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error>;
11357    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error>;
11358    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error>;
11359}
11360
11361#[derive(Debug, Clone)]
11362pub struct StreamProcessorProxy {
11363    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11364}
11365
11366impl fdomain_client::fidl::Proxy for StreamProcessorProxy {
11367    type Protocol = StreamProcessorMarker;
11368
11369    fn from_channel(inner: fdomain_client::Channel) -> Self {
11370        Self::new(inner)
11371    }
11372
11373    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11374        self.client.into_channel().map_err(|client| Self { client })
11375    }
11376
11377    fn as_channel(&self) -> &fdomain_client::Channel {
11378        self.client.as_channel()
11379    }
11380}
11381
11382impl StreamProcessorProxy {
11383    /// Create a new Proxy for fuchsia.media/StreamProcessor.
11384    pub fn new(channel: fdomain_client::Channel) -> Self {
11385        let protocol_name =
11386            <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11387        Self { client: fidl::client::Client::new(channel, protocol_name) }
11388    }
11389
11390    /// Get a Stream of events from the remote end of the protocol.
11391    ///
11392    /// # Panics
11393    ///
11394    /// Panics if the event stream was already taken.
11395    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
11396        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
11397    }
11398
11399    /// Permit the server to use OnStreamFailed() instead of the server just
11400    /// closing the whole StreamProcessor channel on stream failure.
11401    ///
11402    /// If the server hasn't seen this message by the time a stream fails, the
11403    /// server will close the StreamProcessor channel instead of sending
11404    /// OnStreamFailed().
11405    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
11406        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
11407    }
11408
11409    /// When the client is not using dynamic buffers, a single
11410    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
11411    /// client-specified input settings and a BufferCollectionToken which the
11412    /// StreamProcessor will use to convey constraints to sysmem.  Both the
11413    /// client and the StreamProcessor will be informed of the allocated buffers
11414    /// directly by sysmem via their BufferCollection channel (not via the
11415    /// StreamProcessor channel).
11416    ///
11417    /// The client must not QueueInput...() until after sysmem informs the
11418    /// client that buffer allocation has completed and was successful.
11419    ///
11420    /// The server should be prepared to see QueueInput...() before the server
11421    /// has necessarily heard from sysmem that the buffers are allocated - the
11422    /// server must tolerate either ordering, as the QueueInput...() and
11423    /// notification of sysmem allocation completion arrive on different
11424    /// channels, so the client having heard that allocation is complete doesn't
11425    /// mean the server knows that allocation is complete yet.  However, the
11426    /// server can expect that allocation is in fact complete and can expect to
11427    /// get the allocation information from sysmem immediately upon requesting
11428    /// the information from sysmem.
11429    ///
11430    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
11431    /// while there are any buffers still active on the port. To successfully
11432    /// switch modes for a port, most clients will want to just start over with
11433    /// a new StreamProcessor instance. This can also be done reliably by first
11434    /// ensuring that every added buffer under the port up to "now" (including
11435    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11436    /// request. Only then is it known ok to switch modes for that port under
11437    /// the same StreamProcessor. Most clients will just use one way or the
11438    /// other to add buffers and never need to switch to the other way,
11439    /// especially within the same StreamProcessor.
11440    pub fn r#set_input_buffer_partial_settings(
11441        &self,
11442        mut input_settings: StreamBufferPartialSettings,
11443    ) -> Result<(), fidl::Error> {
11444        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
11445    }
11446
11447    /// This is the replacement for SetOutputBufferSettings().
11448    ///
11449    /// When the client is using sysmem to allocate buffers, this message is
11450    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
11451    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
11452    /// with the client-specified output settings and a BufferCollectionToken
11453    /// which the StreamProcessor will use to convey constraints to sysmem. Both
11454    /// the client and the StreamProcessor will be informed of the allocated
11455    /// buffers directly by sysmem via their BufferCollection channel (not via
11456    /// the StreamProcessor channel).
11457    ///
11458    /// Configuring output buffers is _required_ after OnOutputConstraints() is
11459    /// received by the client with buffer_constraints_action_required true and
11460    /// stream_lifetime_ordinal equal to the client's current
11461    /// stream_lifetime_ordinal (even if there is an active stream), and is
11462    /// _permitted_ any time there is no current stream.
11463    ///
11464    /// Closing the current stream occurs on the StreamControl ordering domain,
11465    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
11466    /// subsequent Sync() completion must be received by the client before the
11467    /// client knows that there's no longer a current stream.
11468    ///
11469    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
11470    /// while there are any buffers still active on the port. To successfully
11471    /// switch modes for a port, most clients will want to just start over with
11472    /// a new StreamProcessor instance. This can also be done reliably by first
11473    /// ensuring that every added buffer under the port up to "now" (including
11474    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11475    /// request. Only then is it known ok to switch modes for that port under
11476    /// the same StreamProcessor. Most clients will just use one way or the
11477    /// other to add buffers and never need to switch to the other way,
11478    /// especially not within the same StreamProcessor instance.
11479    ///
11480    /// See also CompleteOutputBufferPartialSettings().
11481    pub fn r#set_output_buffer_partial_settings(
11482        &self,
11483        mut output_settings: StreamBufferPartialSettings,
11484    ) -> Result<(), fidl::Error> {
11485        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
11486    }
11487
11488    /// After SetOutputBufferPartialSettings(), the server won't send
11489    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
11490    /// OnOutputEndOfStream() until after the client sends
11491    /// CompleteOutputBufferPartialSettings().
11492    ///
11493    /// This message isn't permitted after AddBuffer. When using dynamic buffers
11494    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
11495    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
11496    /// the case of OnOutputPacket there must also be at least one output buffer
11497    /// that's been added but not yet fully removed (RemoveBuffer not yet
11498    /// complete).
11499    ///
11500    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
11501    /// immediately after SetOutputBufferPartialSettings() - in that case the
11502    /// client needs to be prepared to receive output without knowing the buffer
11503    /// count or packet count yet - such clients may internally delay processing
11504    /// the received output until the client has heard from sysmem (which is
11505    /// when the client will learn the buffer count and packet count).
11506    ///
11507    /// Other clients may first wait for sysmem to allocate, prepare to receive
11508    /// output, and then send CompleteOutputBufferPartialSettings().
11509    pub fn r#complete_output_buffer_partial_settings(
11510        &self,
11511        mut buffer_lifetime_ordinal: u64,
11512    ) -> Result<(), fidl::Error> {
11513        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
11514            self,
11515            buffer_lifetime_ordinal,
11516        )
11517    }
11518
11519    /// This message is optional; a client isn't required to send this ever.
11520    ///
11521    /// Terminology note: In the name of this message, "flush" means flush
11522    /// through, sometimes called "drain". This messge does not discard. To
11523    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
11524    /// without first waiting for OnOutputEndOfStream of the old stream and
11525    /// without sending FlushEndOfStreamAndCloseStream.
11526    ///
11527    /// There is currently no way to cancel the flush effect of this message
11528    /// short of the client closing the StreamProcessor channel.
11529    ///
11530    /// This message is only valid after QueueInputEndOfStream() for this
11531    /// stream. The stream_lifetime_ordinal input parameter must match the
11532    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
11533    /// will close the channel.
11534    ///
11535    /// A client can use this message to flush through (drain, not discard) the
11536    /// last input data of a stream so that the stream processor server
11537    /// generates corresponding output data for all the input data before the
11538    /// server moves on to the next stream, without forcing the client to wait
11539    /// for OnOutputEndOfStream() before queueing data of another stream.
11540    ///
11541    /// The difference between QueueInputEndOfStream() and
11542    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
11543    /// from the client that there will not be any more input data for the
11544    /// stream (and this info is needed by some stream processors for the stream
11545    /// processor to ever emit the very last output data).  The
11546    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
11547    /// later completely discarding the rest of the current stream by closing
11548    /// the current stream (with or without a stream switch).  In contrast,
11549    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
11550    /// the previously-queued input data be processed including the logical
11551    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
11552    /// before moving on to any newer stream - this essentially changes the
11553    /// close-stream handling from discard to flush-through for this stream
11554    /// only.
11555    ///
11556    /// A client using this message can start providing input data for a new
11557    /// stream without that causing discard of old stream data.  That's the
11558    /// purpose of this message - to allow a client to flush through (not
11559    /// discard) the old stream's last data (instead of the default when closing
11560    /// or switching streams which is discard).
11561    ///
11562    /// Because the old stream is not done processing yet and the old stream's
11563    /// data is not being discarded, the client must be prepared to continue to
11564    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
11565    /// is done. The client will know the stream_lifetime_ordinal is done when
11566    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
11567    /// closes.
11568    pub fn r#flush_end_of_stream_and_close_stream(
11569        &self,
11570        mut stream_lifetime_ordinal: u64,
11571    ) -> Result<(), fidl::Error> {
11572        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
11573            self,
11574            stream_lifetime_ordinal,
11575        )
11576    }
11577
11578    /// This "closes" the current stream, leaving no current stream.  In
11579    /// addition, this message can optionally release (and unregister) input
11580    /// buffers or output buffers.
11581    ///
11582    /// If there has never been any active stream, the stream_lifetime_ordinal
11583    /// must be zero or the server will close the channel.  If there has been an
11584    /// active stream, the stream_lifetime_ordinal must be the most recent
11585    /// active stream whether that stream is still active or not.  Else the
11586    /// server will close the channel.
11587    ///
11588    /// Multiple of this message without any new active stream in between is not
11589    /// to be considered an error, which allows a client to use this message to
11590    /// close the current stream to stop wasting processing power on a stream
11591    /// the user no longer cares about, then later decide that buffers should be
11592    /// released and send this message again with release_input_buffers and/or
11593    /// release_output_buffers true to get the buffers released, if the client
11594    /// is interested in trying to avoid overlap in resource usage between old
11595    /// buffers and new buffers (not all clients are).
11596    ///
11597    /// See also Sync().
11598    pub fn r#close_current_stream(
11599        &self,
11600        mut stream_lifetime_ordinal: u64,
11601        mut release_input_buffers: bool,
11602        mut release_output_buffers: bool,
11603    ) -> Result<(), fidl::Error> {
11604        StreamProcessorProxyInterface::r#close_current_stream(
11605            self,
11606            stream_lifetime_ordinal,
11607            release_input_buffers,
11608            release_output_buffers,
11609        )
11610    }
11611
11612    /// On completion, all previous StreamProcessor calls have done what they're
11613    /// going to do server-side, _except_ for processing of data queued using
11614    /// QueueInputPacket().
11615    ///
11616    /// The main purpose of this call is to enable the client to wait until
11617    /// CloseCurrentStream() with release_input_buffers and/or
11618    /// release_output_buffers set to true to take effect, before the client
11619    /// allocates new buffers and re-sets-up input and/or output buffers.  This
11620    /// de-overlapping of resource usage can be worthwhile for media buffers
11621    /// which can consume resource types whose overall pools aren't necessarily
11622    /// vast in comparison to resources consumed.  Especially if a client is
11623    /// reconfiguring buffers multiple times.
11624    ///
11625    /// Note that Sync() prior to allocating new media buffers is not alone
11626    /// sufficient to achieve non-overlap of media buffer resource usage system
11627    /// wide, but it can be a useful part of achieving that.
11628    ///
11629    /// The Sync() transits the Output ordering domain and the StreamControl
11630    /// ordering domain, but not the InputData ordering domain.
11631    ///
11632    /// This request can be used to avoid hitting kMaxInFlightStreams which is
11633    /// presently 10.  A client that stays <= 8 in-flight streams will
11634    /// comfortably stay under the limit of 10.  While the protocol permits
11635    /// repeated SetInputBufferSettings() and the like, a client that spams the
11636    /// channel can expect that the channel will just close if the server or the
11637    /// channel itself gets too far behind.
11638    pub fn r#sync(
11639        &self,
11640    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
11641        StreamProcessorProxyInterface::r#sync(self)
11642    }
11643
11644    /// After the client is done with an output packet, the client needs to tell
11645    /// the stream processor that the output packet can be re-used for more
11646    /// output, using this message.
11647    ///
11648    /// It's not permitted to recycle an output packet that's already free with
11649    /// the stream processor server.
11650    ///
11651    /// If a client is using EnableOldOutputBuffers, the client must recycle all
11652    /// packets when done with them, even those of old buffer_lifetime_ordinal.
11653    /// This is also permitted behavior for all clients.
11654    ///
11655    /// If a client is not using EnableOldOutputBuffers, the client may
11656    /// optionally omit this message for packets with an old
11657    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
11658    /// or implicit output buffer de-configuration don't need to be recycled if
11659    /// the client isn't using and won't be using EnableOldOutputBuffers.
11660    pub fn r#recycle_output_packet(
11661        &self,
11662        mut available_output_packet: &PacketHeader,
11663    ) -> Result<(), fidl::Error> {
11664        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
11665    }
11666
11667    /// If the input format details are still the same as specified during
11668    /// StreamProcessor creation, this message is unnecessary and does not need
11669    /// to be sent.
11670    ///
11671    /// If the stream doesn't exist yet, this message creates the stream.
11672    ///
11673    /// The server won't send OnOutputConstraints() until after the client has
11674    /// sent at least one QueueInput* message.
11675    ///
11676    /// All servers must permit QueueInputFormatDetails() at the start of a
11677    /// stream without failing, as long as the new format is supported by the
11678    /// StreamProcessor instance. Technically this allows for a server to only
11679    /// support the exact input format set during StreamProcessor creation, and
11680    /// that is by design. A client that tries to switch formats and gets a
11681    /// StreamProcessor channel failure should try again one more time with a
11682    /// fresh StreamProcessor instance created with CodecFactory using the new
11683    /// input format during creation, before giving up.
11684    ///
11685    /// These format details override the format details specified during stream
11686    /// processor creation for this stream only. The next stream will default
11687    /// back to the format details set during stream processor creation.
11688    ///
11689    /// This message is permitted at the start of the first stream (just like at
11690    /// the start of any stream). The format specified need not match what was
11691    /// specified during stream processor creation, but if it doesn't match, the
11692    /// StreamProcessor channel might close as described above.
11693    pub fn r#queue_input_format_details(
11694        &self,
11695        mut stream_lifetime_ordinal: u64,
11696        mut format_details: &FormatDetails,
11697    ) -> Result<(), fidl::Error> {
11698        StreamProcessorProxyInterface::r#queue_input_format_details(
11699            self,
11700            stream_lifetime_ordinal,
11701            format_details,
11702        )
11703    }
11704
11705    /// This message queues input data to the stream processor for processing.
11706    ///
11707    /// If the stream doesn't exist yet, this message creates the new stream.
11708    ///
11709    /// The server won't send OnOutputConstraints() until after the client has
11710    /// sent at least one QueueInput* message.
11711    ///
11712    /// When using dynamic buffers the server can send OnOutputConstraints,
11713    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
11714    /// the first QueueInputPacket. In the case of OnOutputPacket there must
11715    /// also be at least one output buffer that's been added but not yet fully
11716    /// removed (RemoveBuffer not yet complete).
11717    ///
11718    /// The client must continue to deliver input data via this message even if
11719    /// the stream processor has not yet generated the first
11720    /// OnOutputConstraints, and even if the StreamProcessor is generating
11721    /// OnFreeInputPacket for previously-queued input packets.  The input data
11722    /// must continue as long as there are free packets to be assured that the
11723    /// server will ever generate the first OnOutputConstraints.
11724    ///
11725    /// The server will close the channel if this packet refers to an old
11726    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
11727    /// different dimensions to a video encoder can either (a) allocate buffers
11728    /// large enough to contain the range of needed image sizes and use those to
11729    /// deliver all the input images, (b) keep their own sets of buffers used
11730    /// for different image dimensions and re-add old buffers with AddBuffer,
11731    /// moving to a new buffer_lifetime_ordinal each time image dimensions
11732    /// change, or (c) allocate new buffers each time image dimensions change.
11733    /// The (a) option is preferred, for clients that have the flexibiilty to
11734    /// store images of varying dimensions in a single set of buffers. Clients
11735    /// that require each buffer to have a single image size can use option (b)
11736    /// or (c).
11737    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
11738        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
11739    }
11740
11741    /// Inform the server that all QueueInputPacket() messages for this stream
11742    /// have been sent.
11743    ///
11744    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
11745    /// or StreamProcessor channel closing), there will later be a corresponding
11746    /// OnOutputEndOfStream().
11747    ///
11748    /// The corresponding OnOutputEndOfStream() message will be generated only
11749    /// if the server finishes processing the stream before the server sees the
11750    /// client close the stream (such as by starting a new stream). A way to
11751    /// force the server to finish the stream before closing is to use
11752    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
11753    /// any new stream. Another way to force the server to finish the stream
11754    /// before closing is to wait for the OnOutputEndOfStream() before taking
11755    /// any action that closes the stream.
11756    ///
11757    /// In addition to serving as an "EndOfStream" marker to make it obvious
11758    /// client-side when all input data has been processed, if a client never
11759    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
11760    /// result in all input data getting processed through to the output. Some
11761    /// stream processors have some internally-delayed data which only gets
11762    /// drained (pushed through) by additional input data _or_ by this
11763    /// EndOfStream marker. In that sense, this message can be viewed as a drain
11764    /// at InputData domain level, but the drain only takes effect if the stream
11765    /// processor even gets that far before the stream is just closed at
11766    /// StreamControl domain level. This message is not alone sufficient to act
11767    /// as an overall drain at StreamControl level. For that, send this message
11768    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
11769    /// becomes possible to queue input data for a new stream without causing
11770    /// discard of this older stream's data). Alternately, the client can wait
11771    /// for the OnOutputEndOfStream before closing the current stream.
11772    ///
11773    /// After a client sends QueueInputEndOfStream for a stream, if the client
11774    /// then sends for the same stream any of QueueInputPacket,
11775    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
11776    /// the StreamProcessor channel.
11777    pub fn r#queue_input_end_of_stream(
11778        &self,
11779        mut stream_lifetime_ordinal: u64,
11780    ) -> Result<(), fidl::Error> {
11781        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
11782    }
11783
11784    /// This message results in channel closure unless supports_dynamic_buffers
11785    /// is set to true.
11786    ///
11787    /// This participates in allocation of buffers to be used with AddBuffer
11788    /// later. The client can get VMO handles for these buffers by also
11789    /// participating in the sysmem allocation, using the client's own related
11790    /// sysmem token (associated with the same logical buffer collection). It's
11791    /// up to the client to separately set any constraints needed by the client
11792    /// using the client's own related sysmem token, if any.
11793    ///
11794    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
11795    /// SetOutputBufferPartialSettings. Servers must support those messages.
11796    ///
11797    /// In handling this message, if `allow_single_buffer` is set to true, the
11798    /// server must not constrain the number of buffers allocated. The server
11799    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
11800    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
11801    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
11802    /// same value if the intent is to allocate exactly that many buffers. If
11803    /// `allow_single_buffer` is un-set or set to false, the server will
11804    /// indicate needed buffer counts to sysmem.
11805    ///
11806    /// The server's BufferCollection channel (created from the passed-in
11807    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
11808    /// particular, the server shouldn't expect the BufferCollection channel to
11809    /// remain connected to sysmem beyond the server sending SetConstraints. For
11810    /// this reason, the server may not be able to call
11811    /// WaitForAllBuffersAllocated or similar, so the server should just send
11812    /// SetConstraints, Close, then close the server's BufferCollection
11813    /// client_end. This means the server in general shouldn't attempt to get
11814    /// VMO handles for these buffers while processing this message.
11815    ///
11816    /// The server should not assume that these buffers will necessarily ever be
11817    /// added with AddBuffer to this StreamProcessor instance or any other
11818    /// StreamProcessor instance (owned by the server or not). These buffers may
11819    /// instead be dropped, or as a less-common example, possibly added to a
11820    /// different codec served by a different server implementation which also
11821    /// participated in the same sysmem buffer collection allocation.
11822    ///
11823    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
11824    /// StreamProcessor instance of the same codec (same per CodecFactory) is
11825    /// likely to work, but using the same StreamProcessor instance is
11826    /// recommended when feasible.
11827    ///
11828    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
11829    /// a different StreamProcessor instance of the same codec (same per
11830    /// CodecFactory) can't (within reason) be made work in general, especially
11831    /// for video decoders. Therefore, for output buffers, the same
11832    /// StreamProcessor instance must be used for this message and AddBuffer.
11833    /// While a client may currently be able to get away with using different
11834    /// StreamProcessor instances for this message and AddBuffer for output
11835    /// buffers for some codecs, this may break at any time without it being
11836    /// considered a server-side bug.
11837    ///
11838    /// The allocated buffers can later be added using AddBuffer (piecemeal),
11839    /// and can be removed (piecemeal) using RemoveBuffer.
11840    ///
11841    /// Multiple different ParticipateInBufferAllocation messages can have their
11842    /// buffers later added to the same StreamProcessor instance using the same
11843    /// buffer_lifetime_ordinal. This can be useful if the client wants to
11844    /// allocate buffers incrementally, or dynamically adjust the number of
11845    /// buffers, potentially while actively processing. See also the
11846    /// `buffer_lifetime_ordinal` field of this message.
11847    ///
11848    /// Server implementations may use sysmem to help verify buffer
11849    /// compatibility later when buffers are added with AddBuffer.
11850    pub fn r#participate_in_buffer_allocation(
11851        &self,
11852        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
11853    ) -> Result<(), fidl::Error> {
11854        StreamProcessorProxyInterface::r#participate_in_buffer_allocation(self, payload)
11855    }
11856
11857    /// Add buffers previously created with the help of
11858    /// ParticipateInBufferAllocation.
11859    ///
11860    /// For input buffers, the client can send QueueInputFormatDetails or
11861    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
11862    /// buffer must be added before a valid QueueInputPacket can be sent. Most
11863    /// clients will want to continue quickly adding buffers up to at least
11864    /// buffer_count_for_server_current to avoid the codec potentially stalling,
11865    /// and typically a low number of buffers beyond that to keep the pipeline
11866    /// running smoothly. Input buffers beyond the first input buffer can be
11867    /// added after the first QueueInputPacket.
11868    ///
11869    /// Even if buffer_constraints_version_ordinal is current, the server must
11870    /// not close the channel if the buffer isn't consistent with the current
11871    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
11872    /// consistent StreamProcessor constraints). Instead, the server must send a
11873    /// new OnOutputConstraints. This simplifies some edge cases for some
11874    /// clients, particularly when a client can't reliably detect whether a
11875    /// newly-obtained buffer was actually allocated after
11876    /// buffer_constraints_version_ordinal changed, or may have been cached from
11877    /// before.
11878    ///
11879    /// The client can add additional buffers to the same port and
11880    /// buffer_lifetime_ordinal at any time using this message. If the
11881    /// buffer_lifetime_ordinal is no longer the most recent, the message will
11882    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
11883    /// message re. the same buffer will complete immediately.
11884    ///
11885    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
11886    /// by the sum of buffers added by all AddBuffer calls with the same
11887    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
11888    /// required to close the channel in this case if performance degradation or
11889    /// un-tested behavior would result from adding too many buffers.
11890    ///
11891    /// Switching to a new buffer_lifetime_ordinal starts the process of
11892    /// removing buffers associated with an old buffer_lifetime_ordinal.
11893    /// However, until the remove is complete, those buffers can still be used
11894    /// by the codec as normal. See also RemoveBuffer, which can be used to
11895    /// detect when removal is complete, regardless of whether the RemoveBuffer
11896    /// started the removal (including when not using dynamic buffers).
11897    ///
11898    /// The buffer stays added until removal later completes. The buffer remains
11899    /// added across potentially multiple buffer re-uses. Removal can be
11900    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
11901    /// The codec server can unilaterally initiate buffer removal; if the server
11902    /// does this, it must send a new buffer_constraints_version_ordinal with
11903    /// action_required true. Some other client-initiated messages can also
11904    /// begin buffer removal, such as CloseCurrentStream with
11905    /// release_input_buffers and/or release_output_buffers. The buffers are
11906    /// also automatically removed and released if the client closes the
11907    /// StreamProcessor client_end or the server closes the StreamProcessor
11908    /// server_end.
11909    ///
11910    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
11911    /// SetOutputBufferPartialSettings is not allowed while there are any
11912    /// buffers still active on the port. To successfully switch modes for a
11913    /// port, most clients will want to just start over with a new
11914    /// StreamProcessor instance. This can also be done reliably by first
11915    /// ensuring that every added buffer under the port up to "now" (including
11916    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11917    /// request. Only then is it known ok to switch modes for that port under
11918    /// the same StreamProcessor. Most clients will just use one way or the
11919    /// other to add buffers and never need to switch to the other way,
11920    /// especially within the same StreamProcessor.
11921    ///
11922    /// If a client might plausibly "spam" creation of many new
11923    /// buffer_lifetime_ordinal values without the buffers seeing any actual
11924    /// usage in between, the client should consider starting a Sync every few
11925    /// buffer_lifetime_ordinal(s) to fence cleanup of old
11926    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
11927    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
11928    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
11929    /// getting too far ahead of closing out old ones. The threshold of 16 is
11930    /// well below the enforcement threshold. Clients don't need to Sync if they
11931    /// won't be spamming new buffer_lifetime_ordinal values, or if added
11932    /// buffers will see at least some actual usage visible to the client before
11933    /// being replaced again.
11934    ///
11935    /// All buffers of the same port and buffer_lifetime_ordinal must share the
11936    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
11937    /// this in various ways. One way is to use ParticipateInBufferAllocation
11938    /// then AddBuffer for at least the first buffer, before
11939    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
11940    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
11941    /// and bump to the next odd buffer_lifetime_ordinal value for the
11942    /// AddBuffer.
11943    pub fn r#add_buffer(
11944        &self,
11945        mut payload: StreamProcessorAddBufferRequest,
11946    ) -> Result<(), fidl::Error> {
11947        StreamProcessorProxyInterface::r#add_buffer(self, payload)
11948    }
11949
11950    /// When using dynamic buffers, this call removes a buffer as soon as the
11951    /// buffer can be removed without adversely impacting any ongoing processing
11952    /// or an in-flight output packet referring to the buffer.
11953    ///
11954    /// If a client wants to remove a buffer with an in-flight output packet
11955    /// referring to the buffer, the client must RecycleOutputPacket for that
11956    /// in-flight output packet before the RemoveBuffer will complete.
11957    ///
11958    /// When using SetInputBufferPartialSettings /
11959    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
11960    /// the buffer. This call will complete when the buffer is done removing due
11961    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
11962    ///
11963    /// Until RemoveBuffer completes, the codec is still allowed to send
11964    /// OnOutputPacket messages referencing the buffer, and the codec may still
11965    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
11966    /// codec guarantees that no subsequent output packet will reference the
11967    /// buffer, and that the server holds no VMO handles to the buffer.
11968    ///
11969    /// The client may need to recycle an output packet before the RemoveBuffer
11970    /// call can complete. Clients should take care to avoid blocking packet
11971    /// recycling while the RemoveBuffer request is in progress, since this
11972    /// would create a potential deadlock.
11973    ///
11974    /// The server closing any VMO handles to the buffer prior to completing
11975    /// this call is important for the client's ability to prevent memory usage
11976    /// spikes.
11977    ///
11978    /// If the client has "paused" processing by not providing any more input,
11979    /// the client will potentially need to send CloseCurrentStream before
11980    /// RemoveBuffer will complete. When using dynamic buffers, setting
11981    /// release_input_buffers or release_output_buffers to true is not
11982    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
11983    /// specific buffer. When not using dynamic buffers, the client will need to
11984    /// set release_input_buffers or release_output_buffers to true, since
11985    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
11986    /// buffers. A current "paused" stream needs to be stopped because frames
11987    /// can be held as reference frames, and codecs are never reqiured to copy
11988    /// their output data.
11989    ///
11990    /// For any video decoder output buffers being removed while there's an
11991    /// active stream (being fed input or not), it's typically best for the
11992    /// client to assume that removal of a video decoder output buffer may take
11993    /// a very long duration. This is because bitstreams, especially
11994    /// non-standard-compliant bitstreams, but in some cases potentially even
11995    /// standard-compliant bitstreams, can keep a video decoder output buffer in
11996    /// the set of active reference frames (aka DPB) indefinitely. The server is
11997    /// not required to notice that a stream is not conforming to a bitstream
11998    /// standard in this regard.
11999    ///
12000    /// In the case of h.264 decode, a standard-complient bitstream will limit
12001    /// the reorder delay to no longer than the max DPB occupancy. However, a
12002    /// server is not required to detect or reject non-compliant streams that
12003    /// potentially keep a frame in the DPB for longer.
12004    ///
12005    /// For HEVC, the situation is similar to h.264 (IIUC).
12006    ///
12007    /// In the case of VP9, there is nothing in the bitstream spec that limits
12008    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
12009    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
12010    /// required to detect or mitigate this.
12011    ///
12012    /// Until this call completes, the server may still be using the buffer. For
12013    /// output buffers, the server can still send OnOutputPacket message(s) that
12014    /// references this buffer, but only up until the RemoveBuffer completion
12015    /// message is sent by the server. The client must continue to
12016    /// RecycleOutputPacket for packets that reference the buffer, until
12017    /// RemoveBuffer completes.
12018    ///
12019    /// When using dynamic buffers, upon receiving this message, the server will
12020    /// stop selecting the buffer for any new usage (as in, for any usage that
12021    /// moves the buffer from "free" to "not free" within the server). This
12022    /// applies even if the server has no other buffers available for use (aka
12023    /// no other "free" buffers). Any existing usage of the buffer is not ended
12024    /// early by this call alone.
12025    ///
12026    /// When not using dynamic buffers, upon receiving this message, the server
12027    /// will just remember to complete this call shortly after the buffer has
12028    /// completed removal triggered by some other cause (removal is not
12029    /// triggered/caused by this call).
12030    ///
12031    /// For video decoders, when using dynamic buffers, typically the client
12032    /// should take care to avoid removing too many output buffers for continued
12033    /// decode to be possible. If this occurs, the decoder will wait until the
12034    /// client adds another output buffer with AddBuffer. This can be a deadlock
12035    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
12036    /// frame reordering, sending a single AddBuffer doesn't necessarily
12037    /// guarantee another OnOutputPacket, since additional output buffers can be
12038    /// needed before the server can send OnOutputPacket.
12039    ///
12040    /// The client must not call RemoveBuffer on the same buffer more than once,
12041    /// whether overlapping in time or not. The server should enforce this when
12042    /// not enforcing would require tracking additional concurrent requests. The
12043    /// server is not required to enforce this when enforcing would use more
12044    /// server memory.
12045    ///
12046    /// The server is allowed to complete this request quickly with success for
12047    /// buffer_lifetime_ordinal and buffer_index combinations that were never
12048    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
12049    /// hasn't been started by the client yet (no removing potential future
12050    /// buffers).
12051    ///
12052    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
12053    /// combination may be re-used after completion of RemoveBuffer, but only if
12054    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
12055    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
12056    ///
12057    /// Assuming a valid historical buffer is specified, successful completion
12058    /// of this call means the buffer has been fully released by the server and
12059    /// won't be referenced in any subsequent OnOutputPacket.
12060    pub fn r#remove_buffer(
12061        &self,
12062        mut payload: StreamProcessorRemoveBufferRequest,
12063    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
12064        StreamProcessorProxyInterface::r#remove_buffer(self, payload)
12065    }
12066
12067    /// This informs the StreamProcessor that the client is prepared to handle
12068    /// output packets that specify a buffer with buffer_lifetime_ordinal older
12069    /// than the most recent buffer_lifetime_ordinal.
12070    ///
12071    /// If the client doesn't send this message, the StreamProcessor will omit
12072    /// any such output, even if
12073    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
12074    /// decoders such as VP9 decoders, not sending this message can result in
12075    /// output that isn't bistream spec compliant, and the output can be
12076    /// visually different than intended by the bitstream.
12077    ///
12078    /// Such streams are only possible with some bitstream formats (such as
12079    /// VP9), and are rare, but can happen and can be valid per the bitstream
12080    /// spec. For example, this can be specified by a VP9 bitstream using
12081    /// show_existing_frame to output an old-dimensions buffer after having
12082    /// already output a new-dimensions buffer.
12083    ///
12084    /// Most clients that send this message will also want to use RemoveBuffer
12085    /// to know when it becomes safe to stop tracking an old buffer.
12086    ///
12087    /// Most of the time this makes no difference as most bitstreams don't
12088    /// actually emit old buffers, even if the bitstream spec would allow it.
12089    /// Old output buffers are especially rare for RTC streams which typically
12090    /// don't have any frame reordering in the first place.
12091    ///
12092    /// In most video streaming scenarios that use dimension switching as part
12093    /// of their bitrate control strategy (among those that I've observed), at
12094    /// the StreamProcessor layer the new dimensions are part of a new stream
12095    /// instead of being spliced together as a continuation of the old stream.
12096    /// That said, using a continuation of the old stream is also a completely
12097    /// valid way to implement dimension switching. When a stream switch occurs
12098    /// as part of dimension switching, the decoder state is not retained and
12099    /// there won't be any old buffer(s) emitted after new buffer(s), since the
12100    /// new stream doesn't know anything about old buffers filled by the old
12101    /// stream.
12102    ///
12103    /// Clients which haven't tested their ability to handle old output buffers
12104    /// should not send this message. Clients decoding bitstreams like VP9 for
12105    /// decoder compliance testing purposes should send this message (and use a
12106    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
12107    /// Clients which are required to support old output frames and/or fully
12108    /// comply with a relevant bitstream spec should/must send this message, and
12109    /// should test using a test stream that outputs packets referencing an old
12110    /// output buffer.
12111    ///
12112    /// Sending this message more than once closes the channel. If sent, this
12113    /// message must be sent prior to the client establishing the first output
12114    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
12115    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
12116    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
12117    /// client when this message was not sent by the client.
12118    ///
12119    /// This message is only permitted when
12120    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12121    /// is true.
12122    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
12123        StreamProcessorProxyInterface::r#enable_old_output_buffers(self)
12124    }
12125
12126    /// This informs the StreamProcessor that the client is prepared to handle
12127    /// output packets that specify the same buffer as another packet that's
12128    /// also concurrently in flight to the client (not yet recycled).
12129    ///
12130    /// Most bitstream formats don't do this. In formats that can do this such
12131    /// as VP9, most actual bitstreams don't do this.
12132    ///
12133    /// As an example, in VP9, a stream can cause the same output buffer to be
12134    /// used by another emitted output packet/frame by using show_existing_frame
12135    /// on the same VP9 reference/held frame slot more than once without
12136    /// decoding a new frame into that slot in between.
12137    ///
12138    /// Clients that need to achieve full bitstream spec compliance for such a
12139    /// bitstream format must send this message.
12140    ///
12141    /// If this message is not in effect, the server will omit any such output,
12142    /// which can result in output that is not compliant to the relevant
12143    /// bitstream spec, and which can be visually different than the stream
12144    /// intended.
12145    ///
12146    /// Sending this message more than once closes the channel. If sent, this
12147    /// message must be sent prior to the client establishing the first output
12148    /// buffer_lifetime_ordinal.
12149    ///
12150    /// This message is only permitted when
12151    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12152    /// is true.
12153    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
12154        StreamProcessorProxyInterface::r#enable_same_output_buffer_concurrently_in_flight(self)
12155    }
12156
12157    /// For video decoders, this forces the output buffers to be reallocated if
12158    /// the image size needs to change. This is wasteful as it forces extra
12159    /// buffer reallocations given typical video bitrate control strategies
12160    /// (applicable to both streaming and RTC) involving shifting the image
12161    /// dimensions up and down repeatedly as a logical video/stream plays,
12162    /// sometimes even if network conditions remain fairly stable. This extra
12163    /// buffer reallocation cost is incurred vs. baseline whether the dimension
12164    /// switching is achieved within a single StreamProcessor stream or by using
12165    /// a new StreamProcessor stream for new dimensions.
12166    ///
12167    /// A client should not send this message unless the client really must
12168    /// force the output buffers to be reallocated every time the output image
12169    /// size changes.
12170    ///
12171    /// Sending this message more than once closes the channel. If sent, this
12172    /// message must be sent prior to any SetInputBufferPartialSettings,
12173    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
12174    /// AddBuffer.
12175    ///
12176    /// This message is only permitted if this StreamProcessor is a video
12177    /// decoder.
12178    ///
12179    /// This message is only permitted when
12180    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12181    /// is true.
12182    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
12183        StreamProcessorProxyInterface::r#enable_force_output_buffers_fixed_image_size(self)
12184    }
12185}
12186
12187impl StreamProcessorProxyInterface for StreamProcessorProxy {
12188    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
12189        self.client.send::<fidl::encoding::EmptyPayload>(
12190            (),
12191            0x3940929617dbf02b,
12192            fidl::encoding::DynamicFlags::empty(),
12193        )
12194    }
12195
12196    fn r#set_input_buffer_partial_settings(
12197        &self,
12198        mut input_settings: StreamBufferPartialSettings,
12199    ) -> Result<(), fidl::Error> {
12200        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
12201            (&mut input_settings,),
12202            0xb02e0663a40e4c4,
12203            fidl::encoding::DynamicFlags::empty(),
12204        )
12205    }
12206
12207    fn r#set_output_buffer_partial_settings(
12208        &self,
12209        mut output_settings: StreamBufferPartialSettings,
12210    ) -> Result<(), fidl::Error> {
12211        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
12212            (&mut output_settings,),
12213            0x118bb8c819a7bbbb,
12214            fidl::encoding::DynamicFlags::empty(),
12215        )
12216    }
12217
12218    fn r#complete_output_buffer_partial_settings(
12219        &self,
12220        mut buffer_lifetime_ordinal: u64,
12221    ) -> Result<(), fidl::Error> {
12222        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
12223            (buffer_lifetime_ordinal,),
12224            0x50529e5c680ae3ab,
12225            fidl::encoding::DynamicFlags::empty(),
12226        )
12227    }
12228
12229    fn r#flush_end_of_stream_and_close_stream(
12230        &self,
12231        mut stream_lifetime_ordinal: u64,
12232    ) -> Result<(), fidl::Error> {
12233        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
12234            (stream_lifetime_ordinal,),
12235            0x2b62c3e26d0667e6,
12236            fidl::encoding::DynamicFlags::empty(),
12237        )
12238    }
12239
12240    fn r#close_current_stream(
12241        &self,
12242        mut stream_lifetime_ordinal: u64,
12243        mut release_input_buffers: bool,
12244        mut release_output_buffers: bool,
12245    ) -> Result<(), fidl::Error> {
12246        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
12247            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
12248            0x1d8a67522170ca07,
12249            fidl::encoding::DynamicFlags::empty(),
12250        )
12251    }
12252
12253    type SyncResponseFut =
12254        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12255    fn r#sync(&self) -> Self::SyncResponseFut {
12256        fn _decode(
12257            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12258        ) -> Result<(), fidl::Error> {
12259            let _response = fidl::client::decode_transaction_body::<
12260                fidl::encoding::EmptyPayload,
12261                fdomain_client::fidl::FDomainResourceDialect,
12262                0x4b3e44300b0ec6aa,
12263            >(_buf?)?;
12264            Ok(_response)
12265        }
12266        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12267            (),
12268            0x4b3e44300b0ec6aa,
12269            fidl::encoding::DynamicFlags::empty(),
12270            _decode,
12271        )
12272    }
12273
12274    fn r#recycle_output_packet(
12275        &self,
12276        mut available_output_packet: &PacketHeader,
12277    ) -> Result<(), fidl::Error> {
12278        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
12279            (available_output_packet,),
12280            0x32763632b94e0bd5,
12281            fidl::encoding::DynamicFlags::empty(),
12282        )
12283    }
12284
12285    fn r#queue_input_format_details(
12286        &self,
12287        mut stream_lifetime_ordinal: u64,
12288        mut format_details: &FormatDetails,
12289    ) -> Result<(), fidl::Error> {
12290        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
12291            (stream_lifetime_ordinal, format_details),
12292            0x170dc0979d52231,
12293            fidl::encoding::DynamicFlags::empty(),
12294        )
12295    }
12296
12297    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
12298        self.client.send::<StreamProcessorQueueInputPacketRequest>(
12299            (packet,),
12300            0x47173d2652d9df3b,
12301            fidl::encoding::DynamicFlags::empty(),
12302        )
12303    }
12304
12305    fn r#queue_input_end_of_stream(
12306        &self,
12307        mut stream_lifetime_ordinal: u64,
12308    ) -> Result<(), fidl::Error> {
12309        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
12310            (stream_lifetime_ordinal,),
12311            0x2051b6ad00f20b37,
12312            fidl::encoding::DynamicFlags::empty(),
12313        )
12314    }
12315
12316    fn r#participate_in_buffer_allocation(
12317        &self,
12318        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
12319    ) -> Result<(), fidl::Error> {
12320        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
12321            &mut payload,
12322            0x122be3b0096183cb,
12323            fidl::encoding::DynamicFlags::FLEXIBLE,
12324        )
12325    }
12326
12327    fn r#add_buffer(
12328        &self,
12329        mut payload: StreamProcessorAddBufferRequest,
12330    ) -> Result<(), fidl::Error> {
12331        self.client.send::<StreamProcessorAddBufferRequest>(
12332            &mut payload,
12333            0x6eca773e923e0ada,
12334            fidl::encoding::DynamicFlags::FLEXIBLE,
12335        )
12336    }
12337
12338    type RemoveBufferResponseFut =
12339        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12340    fn r#remove_buffer(
12341        &self,
12342        mut payload: StreamProcessorRemoveBufferRequest,
12343    ) -> Self::RemoveBufferResponseFut {
12344        fn _decode(
12345            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12346        ) -> Result<(), fidl::Error> {
12347            let _response = fidl::client::decode_transaction_body::<
12348                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
12349                fdomain_client::fidl::FDomainResourceDialect,
12350                0x40b967ffa6b2da43,
12351            >(_buf?)?
12352            .into_result_fdomain::<StreamProcessorMarker>("remove_buffer")?;
12353            Ok(_response)
12354        }
12355        self.client.send_query_and_decode::<StreamProcessorRemoveBufferRequest, ()>(
12356            &mut payload,
12357            0x40b967ffa6b2da43,
12358            fidl::encoding::DynamicFlags::FLEXIBLE,
12359            _decode,
12360        )
12361    }
12362
12363    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
12364        self.client.send::<fidl::encoding::EmptyPayload>(
12365            (),
12366            0x3aedefeedf3898b0,
12367            fidl::encoding::DynamicFlags::FLEXIBLE,
12368        )
12369    }
12370
12371    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
12372        self.client.send::<fidl::encoding::EmptyPayload>(
12373            (),
12374            0x244e9f43b29709e7,
12375            fidl::encoding::DynamicFlags::FLEXIBLE,
12376        )
12377    }
12378
12379    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
12380        self.client.send::<fidl::encoding::EmptyPayload>(
12381            (),
12382            0x3994b040f91dc1e9,
12383            fidl::encoding::DynamicFlags::FLEXIBLE,
12384        )
12385    }
12386}
12387
12388pub struct StreamProcessorEventStream {
12389    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
12390}
12391
12392impl std::marker::Unpin for StreamProcessorEventStream {}
12393
12394impl futures::stream::FusedStream for StreamProcessorEventStream {
12395    fn is_terminated(&self) -> bool {
12396        self.event_receiver.is_terminated()
12397    }
12398}
12399
12400impl futures::Stream for StreamProcessorEventStream {
12401    type Item = Result<StreamProcessorEvent, fidl::Error>;
12402
12403    fn poll_next(
12404        mut self: std::pin::Pin<&mut Self>,
12405        cx: &mut std::task::Context<'_>,
12406    ) -> std::task::Poll<Option<Self::Item>> {
12407        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12408            &mut self.event_receiver,
12409            cx
12410        )?) {
12411            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
12412            None => std::task::Poll::Ready(None),
12413        }
12414    }
12415}
12416
12417#[derive(Debug)]
12418pub enum StreamProcessorEvent {
12419    OnStreamFailed {
12420        stream_lifetime_ordinal: u64,
12421        error: StreamError,
12422    },
12423    OnInputConstraints {
12424        input_constraints: StreamBufferConstraints,
12425    },
12426    OnOutputConstraints {
12427        output_config: StreamOutputConstraints,
12428    },
12429    OnOutputFormat {
12430        output_format: StreamOutputFormat,
12431    },
12432    OnOutputPacket {
12433        output_packet: Packet,
12434        error_detected_before: bool,
12435        error_detected_during: bool,
12436    },
12437    OnOutputEndOfStream {
12438        stream_lifetime_ordinal: u64,
12439        error_detected_before: bool,
12440    },
12441    OnFreeInputPacket {
12442        free_input_packet: PacketHeader,
12443    },
12444    OnOutputTimestampHasNoOutput {
12445        payload: StreamProcessorOnOutputTimestampHasNoOutputRequest,
12446    },
12447    #[non_exhaustive]
12448    _UnknownEvent {
12449        /// Ordinal of the event that was sent.
12450        ordinal: u64,
12451    },
12452}
12453
12454impl StreamProcessorEvent {
12455    #[allow(irrefutable_let_patterns)]
12456    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
12457        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
12458            Some((stream_lifetime_ordinal, error))
12459        } else {
12460            None
12461        }
12462    }
12463    #[allow(irrefutable_let_patterns)]
12464    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
12465        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
12466            Some((input_constraints))
12467        } else {
12468            None
12469        }
12470    }
12471    #[allow(irrefutable_let_patterns)]
12472    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
12473        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
12474            Some((output_config))
12475        } else {
12476            None
12477        }
12478    }
12479    #[allow(irrefutable_let_patterns)]
12480    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
12481        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
12482            Some((output_format))
12483        } else {
12484            None
12485        }
12486    }
12487    #[allow(irrefutable_let_patterns)]
12488    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
12489        if let StreamProcessorEvent::OnOutputPacket {
12490            output_packet,
12491            error_detected_before,
12492            error_detected_during,
12493        } = self
12494        {
12495            Some((output_packet, error_detected_before, error_detected_during))
12496        } else {
12497            None
12498        }
12499    }
12500    #[allow(irrefutable_let_patterns)]
12501    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
12502        if let StreamProcessorEvent::OnOutputEndOfStream {
12503            stream_lifetime_ordinal,
12504            error_detected_before,
12505        } = self
12506        {
12507            Some((stream_lifetime_ordinal, error_detected_before))
12508        } else {
12509            None
12510        }
12511    }
12512    #[allow(irrefutable_let_patterns)]
12513    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
12514        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
12515            Some((free_input_packet))
12516        } else {
12517            None
12518        }
12519    }
12520    #[allow(irrefutable_let_patterns)]
12521    pub fn into_on_output_timestamp_has_no_output(
12522        self,
12523    ) -> Option<StreamProcessorOnOutputTimestampHasNoOutputRequest> {
12524        if let StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload } = self {
12525            Some((payload))
12526        } else {
12527            None
12528        }
12529    }
12530
12531    /// Decodes a message buffer as a [`StreamProcessorEvent`].
12532    fn decode(
12533        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12534    ) -> Result<StreamProcessorEvent, fidl::Error> {
12535        let (bytes, _handles) = buf.split_mut();
12536        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12537        debug_assert_eq!(tx_header.tx_id, 0);
12538        match tx_header.ordinal {
12539            0x77ccf70bb061cf8e => {
12540                let mut out = fidl::new_empty!(
12541                    StreamProcessorOnStreamFailedRequest,
12542                    fdomain_client::fidl::FDomainResourceDialect
12543                );
12544                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12545                Ok((StreamProcessorEvent::OnStreamFailed {
12546                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
12547                    error: out.error,
12548                }))
12549            }
12550            0x211da9966a8ca0 => {
12551                let mut out = fidl::new_empty!(
12552                    StreamProcessorOnInputConstraintsRequest,
12553                    fdomain_client::fidl::FDomainResourceDialect
12554                );
12555                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12556                Ok((StreamProcessorEvent::OnInputConstraints {
12557                    input_constraints: out.input_constraints,
12558                }))
12559            }
12560            0x40d8234504c170f3 => {
12561                let mut out = fidl::new_empty!(
12562                    StreamProcessorOnOutputConstraintsRequest,
12563                    fdomain_client::fidl::FDomainResourceDialect
12564                );
12565                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12566                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
12567            }
12568            0x131b77ae120360bc => {
12569                let mut out = fidl::new_empty!(
12570                    StreamProcessorOnOutputFormatRequest,
12571                    fdomain_client::fidl::FDomainResourceDialect
12572                );
12573                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12574                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
12575            }
12576            0x5c2029be1090ce93 => {
12577                let mut out = fidl::new_empty!(
12578                    StreamProcessorOnOutputPacketRequest,
12579                    fdomain_client::fidl::FDomainResourceDialect
12580                );
12581                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12582                Ok((StreamProcessorEvent::OnOutputPacket {
12583                    output_packet: out.output_packet,
12584                    error_detected_before: out.error_detected_before,
12585                    error_detected_during: out.error_detected_during,
12586                }))
12587            }
12588            0x3bb65d237cfa50e6 => {
12589                let mut out = fidl::new_empty!(
12590                    StreamProcessorOnOutputEndOfStreamRequest,
12591                    fdomain_client::fidl::FDomainResourceDialect
12592                );
12593                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12594                Ok((StreamProcessorEvent::OnOutputEndOfStream {
12595                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
12596                    error_detected_before: out.error_detected_before,
12597                }))
12598            }
12599            0xeef799b28708bbd => {
12600                let mut out = fidl::new_empty!(
12601                    StreamProcessorOnFreeInputPacketRequest,
12602                    fdomain_client::fidl::FDomainResourceDialect
12603                );
12604                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12605                Ok((StreamProcessorEvent::OnFreeInputPacket {
12606                    free_input_packet: out.free_input_packet,
12607                }))
12608            }
12609            0x7436457799a25cd4 => {
12610                let mut out = fidl::new_empty!(
12611                    StreamProcessorOnOutputTimestampHasNoOutputRequest,
12612                    fdomain_client::fidl::FDomainResourceDialect
12613                );
12614                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12615                Ok((StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload: out }))
12616            }
12617            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12618                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
12619            }
12620            _ => Err(fidl::Error::UnknownOrdinal {
12621                ordinal: tx_header.ordinal,
12622                protocol_name:
12623                    <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12624            }),
12625        }
12626    }
12627}
12628
12629/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
12630pub struct StreamProcessorRequestStream {
12631    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12632    is_terminated: bool,
12633}
12634
12635impl std::marker::Unpin for StreamProcessorRequestStream {}
12636
12637impl futures::stream::FusedStream for StreamProcessorRequestStream {
12638    fn is_terminated(&self) -> bool {
12639        self.is_terminated
12640    }
12641}
12642
12643impl fdomain_client::fidl::RequestStream for StreamProcessorRequestStream {
12644    type Protocol = StreamProcessorMarker;
12645    type ControlHandle = StreamProcessorControlHandle;
12646
12647    fn from_channel(channel: fdomain_client::Channel) -> Self {
12648        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12649    }
12650
12651    fn control_handle(&self) -> Self::ControlHandle {
12652        StreamProcessorControlHandle { inner: self.inner.clone() }
12653    }
12654
12655    fn into_inner(
12656        self,
12657    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
12658    {
12659        (self.inner, self.is_terminated)
12660    }
12661
12662    fn from_inner(
12663        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12664        is_terminated: bool,
12665    ) -> Self {
12666        Self { inner, is_terminated }
12667    }
12668}
12669
12670impl futures::Stream for StreamProcessorRequestStream {
12671    type Item = Result<StreamProcessorRequest, fidl::Error>;
12672
12673    fn poll_next(
12674        mut self: std::pin::Pin<&mut Self>,
12675        cx: &mut std::task::Context<'_>,
12676    ) -> std::task::Poll<Option<Self::Item>> {
12677        let this = &mut *self;
12678        if this.inner.check_shutdown(cx) {
12679            this.is_terminated = true;
12680            return std::task::Poll::Ready(None);
12681        }
12682        if this.is_terminated {
12683            panic!("polled StreamProcessorRequestStream after completion");
12684        }
12685        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
12686            |bytes, handles| {
12687                match this.inner.channel().read_etc(cx, bytes, handles) {
12688                    std::task::Poll::Ready(Ok(())) => {}
12689                    std::task::Poll::Pending => return std::task::Poll::Pending,
12690                    std::task::Poll::Ready(Err(None)) => {
12691                        this.is_terminated = true;
12692                        return std::task::Poll::Ready(None);
12693                    }
12694                    std::task::Poll::Ready(Err(Some(e))) => {
12695                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12696                            e.into(),
12697                        ))));
12698                    }
12699                }
12700
12701                // A message has been received from the channel
12702                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12703
12704                std::task::Poll::Ready(Some(match header.ordinal {
12705                0x3940929617dbf02b => {
12706                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12707                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12708                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12709                    let control_handle = StreamProcessorControlHandle {
12710                        inner: this.inner.clone(),
12711                    };
12712                    Ok(StreamProcessorRequest::EnableOnStreamFailed {
12713                        control_handle,
12714                    })
12715                }
12716                0xb02e0663a40e4c4 => {
12717                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12718                    let mut req = fidl::new_empty!(StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12719                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12720                    let control_handle = StreamProcessorControlHandle {
12721                        inner: this.inner.clone(),
12722                    };
12723                    Ok(StreamProcessorRequest::SetInputBufferPartialSettings {input_settings: req.input_settings,
12724
12725                        control_handle,
12726                    })
12727                }
12728                0x118bb8c819a7bbbb => {
12729                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12730                    let mut req = fidl::new_empty!(StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12731                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12732                    let control_handle = StreamProcessorControlHandle {
12733                        inner: this.inner.clone(),
12734                    };
12735                    Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {output_settings: req.output_settings,
12736
12737                        control_handle,
12738                    })
12739                }
12740                0x50529e5c680ae3ab => {
12741                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12742                    let mut req = fidl::new_empty!(StreamProcessorCompleteOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12743                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12744                    let control_handle = StreamProcessorControlHandle {
12745                        inner: this.inner.clone(),
12746                    };
12747                    Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
12748
12749                        control_handle,
12750                    })
12751                }
12752                0x2b62c3e26d0667e6 => {
12753                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12754                    let mut req = fidl::new_empty!(StreamProcessorFlushEndOfStreamAndCloseStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12755                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12756                    let control_handle = StreamProcessorControlHandle {
12757                        inner: this.inner.clone(),
12758                    };
12759                    Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12760
12761                        control_handle,
12762                    })
12763                }
12764                0x1d8a67522170ca07 => {
12765                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12766                    let mut req = fidl::new_empty!(StreamProcessorCloseCurrentStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12767                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12768                    let control_handle = StreamProcessorControlHandle {
12769                        inner: this.inner.clone(),
12770                    };
12771                    Ok(StreamProcessorRequest::CloseCurrentStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12772release_input_buffers: req.release_input_buffers,
12773release_output_buffers: req.release_output_buffers,
12774
12775                        control_handle,
12776                    })
12777                }
12778                0x4b3e44300b0ec6aa => {
12779                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12780                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12781                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12782                    let control_handle = StreamProcessorControlHandle {
12783                        inner: this.inner.clone(),
12784                    };
12785                    Ok(StreamProcessorRequest::Sync {
12786                        responder: StreamProcessorSyncResponder {
12787                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12788                            tx_id: header.tx_id,
12789                        },
12790                    })
12791                }
12792                0x32763632b94e0bd5 => {
12793                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12794                    let mut req = fidl::new_empty!(StreamProcessorRecycleOutputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
12795                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12796                    let control_handle = StreamProcessorControlHandle {
12797                        inner: this.inner.clone(),
12798                    };
12799                    Ok(StreamProcessorRequest::RecycleOutputPacket {available_output_packet: req.available_output_packet,
12800
12801                        control_handle,
12802                    })
12803                }
12804                0x170dc0979d52231 => {
12805                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12806                    let mut req = fidl::new_empty!(StreamProcessorQueueInputFormatDetailsRequest, fdomain_client::fidl::FDomainResourceDialect);
12807                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
12808                    let control_handle = StreamProcessorControlHandle {
12809                        inner: this.inner.clone(),
12810                    };
12811                    Ok(StreamProcessorRequest::QueueInputFormatDetails {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12812format_details: req.format_details,
12813
12814                        control_handle,
12815                    })
12816                }
12817                0x47173d2652d9df3b => {
12818                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12819                    let mut req = fidl::new_empty!(StreamProcessorQueueInputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
12820                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12821                    let control_handle = StreamProcessorControlHandle {
12822                        inner: this.inner.clone(),
12823                    };
12824                    Ok(StreamProcessorRequest::QueueInputPacket {packet: req.packet,
12825
12826                        control_handle,
12827                    })
12828                }
12829                0x2051b6ad00f20b37 => {
12830                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12831                    let mut req = fidl::new_empty!(StreamProcessorQueueInputEndOfStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12832                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12833                    let control_handle = StreamProcessorControlHandle {
12834                        inner: this.inner.clone(),
12835                    };
12836                    Ok(StreamProcessorRequest::QueueInputEndOfStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12837
12838                        control_handle,
12839                    })
12840                }
12841                0x122be3b0096183cb => {
12842                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12843                    let mut req = fidl::new_empty!(StreamProcessorParticipateInBufferAllocationRequest, fdomain_client::fidl::FDomainResourceDialect);
12844                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorParticipateInBufferAllocationRequest>(&header, _body_bytes, handles, &mut req)?;
12845                    let control_handle = StreamProcessorControlHandle {
12846                        inner: this.inner.clone(),
12847                    };
12848                    Ok(StreamProcessorRequest::ParticipateInBufferAllocation {payload: req,
12849                        control_handle,
12850                    })
12851                }
12852                0x6eca773e923e0ada => {
12853                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12854                    let mut req = fidl::new_empty!(StreamProcessorAddBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
12855                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorAddBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12856                    let control_handle = StreamProcessorControlHandle {
12857                        inner: this.inner.clone(),
12858                    };
12859                    Ok(StreamProcessorRequest::AddBuffer {payload: req,
12860                        control_handle,
12861                    })
12862                }
12863                0x40b967ffa6b2da43 => {
12864                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12865                    let mut req = fidl::new_empty!(StreamProcessorRemoveBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
12866                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorRemoveBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12867                    let control_handle = StreamProcessorControlHandle {
12868                        inner: this.inner.clone(),
12869                    };
12870                    Ok(StreamProcessorRequest::RemoveBuffer {payload: req,
12871                        responder: StreamProcessorRemoveBufferResponder {
12872                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12873                            tx_id: header.tx_id,
12874                        },
12875                    })
12876                }
12877                0x3aedefeedf3898b0 => {
12878                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12879                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12880                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12881                    let control_handle = StreamProcessorControlHandle {
12882                        inner: this.inner.clone(),
12883                    };
12884                    Ok(StreamProcessorRequest::EnableOldOutputBuffers {
12885                        control_handle,
12886                    })
12887                }
12888                0x244e9f43b29709e7 => {
12889                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12890                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12891                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12892                    let control_handle = StreamProcessorControlHandle {
12893                        inner: this.inner.clone(),
12894                    };
12895                    Ok(StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
12896                        control_handle,
12897                    })
12898                }
12899                0x3994b040f91dc1e9 => {
12900                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12901                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12902                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12903                    let control_handle = StreamProcessorControlHandle {
12904                        inner: this.inner.clone(),
12905                    };
12906                    Ok(StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize {
12907                        control_handle,
12908                    })
12909                }
12910                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12911                    Ok(StreamProcessorRequest::_UnknownMethod {
12912                        ordinal: header.ordinal,
12913                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
12914                        method_type: fidl::MethodType::OneWay,
12915                    })
12916                }
12917                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12918                    this.inner.send_framework_err(
12919                        fidl::encoding::FrameworkErr::UnknownMethod,
12920                        header.tx_id,
12921                        header.ordinal,
12922                        header.dynamic_flags(),
12923                        (bytes, handles),
12924                    )?;
12925                    Ok(StreamProcessorRequest::_UnknownMethod {
12926                        ordinal: header.ordinal,
12927                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
12928                        method_type: fidl::MethodType::TwoWay,
12929                    })
12930                }
12931                _ => Err(fidl::Error::UnknownOrdinal {
12932                    ordinal: header.ordinal,
12933                    protocol_name: <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12934                }),
12935            }))
12936            },
12937        )
12938    }
12939}
12940
12941/// Overview of operation:
12942///
12943/// 1. Create
12944///   * create via CodecFactory - see CodecFactory
12945///   * create via LicenseSession - see LicenseSession
12946/// 2. Get input constraints
12947///   * OnInputConstraints() - sent unsolicited by stream processor shortly
12948///     after stream processor creation.
12949/// 3. Provide input buffers ()
12950///   * SetInputBufferPartialSettings()
12951///   * or AddBuffer, if StreamProcessor reported support for dynamic buffers
12952///     via CodecFactory - in this case, QueueInputFormatDetails and
12953///     QueueInputEndOfStream do not require a prior AddBuffer, but
12954///     QueueInputPacket still does.
12955/// 4. Deliver input data
12956///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
12957///     possibly working through all input packets repeatedly before...
12958/// 5. Get output constraints and format
12959///   * OnOutputConstraints()
12960///   * This is not sent until after at least one QueueInput* message is sent by
12961///     the client, even if the underlying processor behind the StreamProcessor
12962///     doesn't fundamentally need any input data to determine its output
12963///     constraints.  This server behavior prevents clients taking an incorrect
12964///     dependency on the output constraints showing up before input is
12965///     delivered.
12966///   * A client must tolerate this arriving as late as after substantial input
12967///     data has been delivered, including lots of input packet recycling via
12968///     OnFreeInputPacket().
12969///   * This message can arrive more than once before the first output data.
12970/// 6. Provide output buffers
12971///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
12972/// 7. Data flows, with optional EndOfStream
12973///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
12974///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
12975///
12976/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
12977/// very few capabilities) just in case the decoding SW has a vulnerability
12978/// which could be used to take over the StreamProcessor server.  Clients of the
12979/// stream processor interface using decoders and processing streams of separate
12980/// security contexts, to a greater extent than some other interfaces, need to
12981/// protect themselves against invalid server behavior, such as double-free of a
12982/// packet_index and any other invalid server behavior.  Having fed in
12983/// compressed data of one security context, don't place too much trust in a
12984/// single StreamProcessor instance to not mix data among any buffers that
12985/// StreamProcessor server has ever been told about.  Instead, create separate
12986/// StreamProcessor instances for use by security-separate client-side contexts.
12987/// While the picture for HW-based decoders looks somewhat different and is out
12988/// of scope of this paragraph, the client should always use separate
12989/// StreamProcessor instances for security-separate client-side contexts.
12990///
12991/// Descriptions of actions taken by methods of this protocol and the states of
12992/// things are given as if the methods are synchronously executed by the stream
12993/// processor server, but in reality, as is typical of FIDL interfaces, the
12994/// message processing is async.  The states described are to be read as the
12995/// state from the client's point of view unless otherwise stated.  Events
12996/// coming back from the server are of course delivered async, and a client that
12997/// processes more than one stream per StreamProcessor instance needs to care
12998/// whether a given event is from the current stream vs. some older
12999/// soon-to-be-gone stream.
13000///
13001/// The Sync() method's main purpose is to enable the client to robustly prevent
13002/// having both old and new buffers allocated in the system at the same time,
13003/// since media buffers can be significantly large, depending. The Sync() method
13004/// achieves this by only delivering it's response when all previous calls to
13005/// the StreamProcessor protocol have actually taken effect in the
13006/// StreamControl ordering domain. Sync() can also be used to wait for the
13007/// stream processor server to catch up if there's a possibility that a client
13008/// might otherwise get too far ahead of the StreamProcessor server, by for
13009/// example requesting creation of a large number of streams in a row.  It can
13010/// also be used during debugging to ensure that a stream processor server
13011/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
13012/// for correctness - only potentially required to de-overlap resource usage.
13013///
13014/// It's possible to re-use a StreamProcessor instance for another stream, and
13015/// doing so can sometimes skip over re-allocation of buffers. This can be a
13016/// useful thing to do for cases like seeking to a new location - at the
13017/// StreamProcessor interface that can look like switching to a new stream.
13018#[derive(Debug)]
13019pub enum StreamProcessorRequest {
13020    /// Permit the server to use OnStreamFailed() instead of the server just
13021    /// closing the whole StreamProcessor channel on stream failure.
13022    ///
13023    /// If the server hasn't seen this message by the time a stream fails, the
13024    /// server will close the StreamProcessor channel instead of sending
13025    /// OnStreamFailed().
13026    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
13027    /// When the client is not using dynamic buffers, a single
13028    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
13029    /// client-specified input settings and a BufferCollectionToken which the
13030    /// StreamProcessor will use to convey constraints to sysmem.  Both the
13031    /// client and the StreamProcessor will be informed of the allocated buffers
13032    /// directly by sysmem via their BufferCollection channel (not via the
13033    /// StreamProcessor channel).
13034    ///
13035    /// The client must not QueueInput...() until after sysmem informs the
13036    /// client that buffer allocation has completed and was successful.
13037    ///
13038    /// The server should be prepared to see QueueInput...() before the server
13039    /// has necessarily heard from sysmem that the buffers are allocated - the
13040    /// server must tolerate either ordering, as the QueueInput...() and
13041    /// notification of sysmem allocation completion arrive on different
13042    /// channels, so the client having heard that allocation is complete doesn't
13043    /// mean the server knows that allocation is complete yet.  However, the
13044    /// server can expect that allocation is in fact complete and can expect to
13045    /// get the allocation information from sysmem immediately upon requesting
13046    /// the information from sysmem.
13047    ///
13048    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
13049    /// while there are any buffers still active on the port. To successfully
13050    /// switch modes for a port, most clients will want to just start over with
13051    /// a new StreamProcessor instance. This can also be done reliably by first
13052    /// ensuring that every added buffer under the port up to "now" (including
13053    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13054    /// request. Only then is it known ok to switch modes for that port under
13055    /// the same StreamProcessor. Most clients will just use one way or the
13056    /// other to add buffers and never need to switch to the other way,
13057    /// especially within the same StreamProcessor.
13058    SetInputBufferPartialSettings {
13059        input_settings: StreamBufferPartialSettings,
13060        control_handle: StreamProcessorControlHandle,
13061    },
13062    /// This is the replacement for SetOutputBufferSettings().
13063    ///
13064    /// When the client is using sysmem to allocate buffers, this message is
13065    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13066    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13067    /// with the client-specified output settings and a BufferCollectionToken
13068    /// which the StreamProcessor will use to convey constraints to sysmem. Both
13069    /// the client and the StreamProcessor will be informed of the allocated
13070    /// buffers directly by sysmem via their BufferCollection channel (not via
13071    /// the StreamProcessor channel).
13072    ///
13073    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13074    /// received by the client with buffer_constraints_action_required true and
13075    /// stream_lifetime_ordinal equal to the client's current
13076    /// stream_lifetime_ordinal (even if there is an active stream), and is
13077    /// _permitted_ any time there is no current stream.
13078    ///
13079    /// Closing the current stream occurs on the StreamControl ordering domain,
13080    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13081    /// subsequent Sync() completion must be received by the client before the
13082    /// client knows that there's no longer a current stream.
13083    ///
13084    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
13085    /// while there are any buffers still active on the port. To successfully
13086    /// switch modes for a port, most clients will want to just start over with
13087    /// a new StreamProcessor instance. This can also be done reliably by first
13088    /// ensuring that every added buffer under the port up to "now" (including
13089    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13090    /// request. Only then is it known ok to switch modes for that port under
13091    /// the same StreamProcessor. Most clients will just use one way or the
13092    /// other to add buffers and never need to switch to the other way,
13093    /// especially not within the same StreamProcessor instance.
13094    ///
13095    /// See also CompleteOutputBufferPartialSettings().
13096    SetOutputBufferPartialSettings {
13097        output_settings: StreamBufferPartialSettings,
13098        control_handle: StreamProcessorControlHandle,
13099    },
13100    /// After SetOutputBufferPartialSettings(), the server won't send
13101    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13102    /// OnOutputEndOfStream() until after the client sends
13103    /// CompleteOutputBufferPartialSettings().
13104    ///
13105    /// This message isn't permitted after AddBuffer. When using dynamic buffers
13106    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
13107    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
13108    /// the case of OnOutputPacket there must also be at least one output buffer
13109    /// that's been added but not yet fully removed (RemoveBuffer not yet
13110    /// complete).
13111    ///
13112    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
13113    /// immediately after SetOutputBufferPartialSettings() - in that case the
13114    /// client needs to be prepared to receive output without knowing the buffer
13115    /// count or packet count yet - such clients may internally delay processing
13116    /// the received output until the client has heard from sysmem (which is
13117    /// when the client will learn the buffer count and packet count).
13118    ///
13119    /// Other clients may first wait for sysmem to allocate, prepare to receive
13120    /// output, and then send CompleteOutputBufferPartialSettings().
13121    CompleteOutputBufferPartialSettings {
13122        buffer_lifetime_ordinal: u64,
13123        control_handle: StreamProcessorControlHandle,
13124    },
13125    /// This message is optional; a client isn't required to send this ever.
13126    ///
13127    /// Terminology note: In the name of this message, "flush" means flush
13128    /// through, sometimes called "drain". This messge does not discard. To
13129    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
13130    /// without first waiting for OnOutputEndOfStream of the old stream and
13131    /// without sending FlushEndOfStreamAndCloseStream.
13132    ///
13133    /// There is currently no way to cancel the flush effect of this message
13134    /// short of the client closing the StreamProcessor channel.
13135    ///
13136    /// This message is only valid after QueueInputEndOfStream() for this
13137    /// stream. The stream_lifetime_ordinal input parameter must match the
13138    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13139    /// will close the channel.
13140    ///
13141    /// A client can use this message to flush through (drain, not discard) the
13142    /// last input data of a stream so that the stream processor server
13143    /// generates corresponding output data for all the input data before the
13144    /// server moves on to the next stream, without forcing the client to wait
13145    /// for OnOutputEndOfStream() before queueing data of another stream.
13146    ///
13147    /// The difference between QueueInputEndOfStream() and
13148    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13149    /// from the client that there will not be any more input data for the
13150    /// stream (and this info is needed by some stream processors for the stream
13151    /// processor to ever emit the very last output data).  The
13152    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13153    /// later completely discarding the rest of the current stream by closing
13154    /// the current stream (with or without a stream switch).  In contrast,
13155    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13156    /// the previously-queued input data be processed including the logical
13157    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13158    /// before moving on to any newer stream - this essentially changes the
13159    /// close-stream handling from discard to flush-through for this stream
13160    /// only.
13161    ///
13162    /// A client using this message can start providing input data for a new
13163    /// stream without that causing discard of old stream data.  That's the
13164    /// purpose of this message - to allow a client to flush through (not
13165    /// discard) the old stream's last data (instead of the default when closing
13166    /// or switching streams which is discard).
13167    ///
13168    /// Because the old stream is not done processing yet and the old stream's
13169    /// data is not being discarded, the client must be prepared to continue to
13170    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13171    /// is done. The client will know the stream_lifetime_ordinal is done when
13172    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13173    /// closes.
13174    FlushEndOfStreamAndCloseStream {
13175        stream_lifetime_ordinal: u64,
13176        control_handle: StreamProcessorControlHandle,
13177    },
13178    /// This "closes" the current stream, leaving no current stream.  In
13179    /// addition, this message can optionally release (and unregister) input
13180    /// buffers or output buffers.
13181    ///
13182    /// If there has never been any active stream, the stream_lifetime_ordinal
13183    /// must be zero or the server will close the channel.  If there has been an
13184    /// active stream, the stream_lifetime_ordinal must be the most recent
13185    /// active stream whether that stream is still active or not.  Else the
13186    /// server will close the channel.
13187    ///
13188    /// Multiple of this message without any new active stream in between is not
13189    /// to be considered an error, which allows a client to use this message to
13190    /// close the current stream to stop wasting processing power on a stream
13191    /// the user no longer cares about, then later decide that buffers should be
13192    /// released and send this message again with release_input_buffers and/or
13193    /// release_output_buffers true to get the buffers released, if the client
13194    /// is interested in trying to avoid overlap in resource usage between old
13195    /// buffers and new buffers (not all clients are).
13196    ///
13197    /// See also Sync().
13198    CloseCurrentStream {
13199        stream_lifetime_ordinal: u64,
13200        release_input_buffers: bool,
13201        release_output_buffers: bool,
13202        control_handle: StreamProcessorControlHandle,
13203    },
13204    /// On completion, all previous StreamProcessor calls have done what they're
13205    /// going to do server-side, _except_ for processing of data queued using
13206    /// QueueInputPacket().
13207    ///
13208    /// The main purpose of this call is to enable the client to wait until
13209    /// CloseCurrentStream() with release_input_buffers and/or
13210    /// release_output_buffers set to true to take effect, before the client
13211    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13212    /// de-overlapping of resource usage can be worthwhile for media buffers
13213    /// which can consume resource types whose overall pools aren't necessarily
13214    /// vast in comparison to resources consumed.  Especially if a client is
13215    /// reconfiguring buffers multiple times.
13216    ///
13217    /// Note that Sync() prior to allocating new media buffers is not alone
13218    /// sufficient to achieve non-overlap of media buffer resource usage system
13219    /// wide, but it can be a useful part of achieving that.
13220    ///
13221    /// The Sync() transits the Output ordering domain and the StreamControl
13222    /// ordering domain, but not the InputData ordering domain.
13223    ///
13224    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13225    /// presently 10.  A client that stays <= 8 in-flight streams will
13226    /// comfortably stay under the limit of 10.  While the protocol permits
13227    /// repeated SetInputBufferSettings() and the like, a client that spams the
13228    /// channel can expect that the channel will just close if the server or the
13229    /// channel itself gets too far behind.
13230    Sync { responder: StreamProcessorSyncResponder },
13231    /// After the client is done with an output packet, the client needs to tell
13232    /// the stream processor that the output packet can be re-used for more
13233    /// output, using this message.
13234    ///
13235    /// It's not permitted to recycle an output packet that's already free with
13236    /// the stream processor server.
13237    ///
13238    /// If a client is using EnableOldOutputBuffers, the client must recycle all
13239    /// packets when done with them, even those of old buffer_lifetime_ordinal.
13240    /// This is also permitted behavior for all clients.
13241    ///
13242    /// If a client is not using EnableOldOutputBuffers, the client may
13243    /// optionally omit this message for packets with an old
13244    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
13245    /// or implicit output buffer de-configuration don't need to be recycled if
13246    /// the client isn't using and won't be using EnableOldOutputBuffers.
13247    RecycleOutputPacket {
13248        available_output_packet: PacketHeader,
13249        control_handle: StreamProcessorControlHandle,
13250    },
13251    /// If the input format details are still the same as specified during
13252    /// StreamProcessor creation, this message is unnecessary and does not need
13253    /// to be sent.
13254    ///
13255    /// If the stream doesn't exist yet, this message creates the stream.
13256    ///
13257    /// The server won't send OnOutputConstraints() until after the client has
13258    /// sent at least one QueueInput* message.
13259    ///
13260    /// All servers must permit QueueInputFormatDetails() at the start of a
13261    /// stream without failing, as long as the new format is supported by the
13262    /// StreamProcessor instance. Technically this allows for a server to only
13263    /// support the exact input format set during StreamProcessor creation, and
13264    /// that is by design. A client that tries to switch formats and gets a
13265    /// StreamProcessor channel failure should try again one more time with a
13266    /// fresh StreamProcessor instance created with CodecFactory using the new
13267    /// input format during creation, before giving up.
13268    ///
13269    /// These format details override the format details specified during stream
13270    /// processor creation for this stream only. The next stream will default
13271    /// back to the format details set during stream processor creation.
13272    ///
13273    /// This message is permitted at the start of the first stream (just like at
13274    /// the start of any stream). The format specified need not match what was
13275    /// specified during stream processor creation, but if it doesn't match, the
13276    /// StreamProcessor channel might close as described above.
13277    QueueInputFormatDetails {
13278        stream_lifetime_ordinal: u64,
13279        format_details: FormatDetails,
13280        control_handle: StreamProcessorControlHandle,
13281    },
13282    /// This message queues input data to the stream processor for processing.
13283    ///
13284    /// If the stream doesn't exist yet, this message creates the new stream.
13285    ///
13286    /// The server won't send OnOutputConstraints() until after the client has
13287    /// sent at least one QueueInput* message.
13288    ///
13289    /// When using dynamic buffers the server can send OnOutputConstraints,
13290    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
13291    /// the first QueueInputPacket. In the case of OnOutputPacket there must
13292    /// also be at least one output buffer that's been added but not yet fully
13293    /// removed (RemoveBuffer not yet complete).
13294    ///
13295    /// The client must continue to deliver input data via this message even if
13296    /// the stream processor has not yet generated the first
13297    /// OnOutputConstraints, and even if the StreamProcessor is generating
13298    /// OnFreeInputPacket for previously-queued input packets.  The input data
13299    /// must continue as long as there are free packets to be assured that the
13300    /// server will ever generate the first OnOutputConstraints.
13301    ///
13302    /// The server will close the channel if this packet refers to an old
13303    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
13304    /// different dimensions to a video encoder can either (a) allocate buffers
13305    /// large enough to contain the range of needed image sizes and use those to
13306    /// deliver all the input images, (b) keep their own sets of buffers used
13307    /// for different image dimensions and re-add old buffers with AddBuffer,
13308    /// moving to a new buffer_lifetime_ordinal each time image dimensions
13309    /// change, or (c) allocate new buffers each time image dimensions change.
13310    /// The (a) option is preferred, for clients that have the flexibiilty to
13311    /// store images of varying dimensions in a single set of buffers. Clients
13312    /// that require each buffer to have a single image size can use option (b)
13313    /// or (c).
13314    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
13315    /// Inform the server that all QueueInputPacket() messages for this stream
13316    /// have been sent.
13317    ///
13318    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
13319    /// or StreamProcessor channel closing), there will later be a corresponding
13320    /// OnOutputEndOfStream().
13321    ///
13322    /// The corresponding OnOutputEndOfStream() message will be generated only
13323    /// if the server finishes processing the stream before the server sees the
13324    /// client close the stream (such as by starting a new stream). A way to
13325    /// force the server to finish the stream before closing is to use
13326    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
13327    /// any new stream. Another way to force the server to finish the stream
13328    /// before closing is to wait for the OnOutputEndOfStream() before taking
13329    /// any action that closes the stream.
13330    ///
13331    /// In addition to serving as an "EndOfStream" marker to make it obvious
13332    /// client-side when all input data has been processed, if a client never
13333    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
13334    /// result in all input data getting processed through to the output. Some
13335    /// stream processors have some internally-delayed data which only gets
13336    /// drained (pushed through) by additional input data _or_ by this
13337    /// EndOfStream marker. In that sense, this message can be viewed as a drain
13338    /// at InputData domain level, but the drain only takes effect if the stream
13339    /// processor even gets that far before the stream is just closed at
13340    /// StreamControl domain level. This message is not alone sufficient to act
13341    /// as an overall drain at StreamControl level. For that, send this message
13342    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
13343    /// becomes possible to queue input data for a new stream without causing
13344    /// discard of this older stream's data). Alternately, the client can wait
13345    /// for the OnOutputEndOfStream before closing the current stream.
13346    ///
13347    /// After a client sends QueueInputEndOfStream for a stream, if the client
13348    /// then sends for the same stream any of QueueInputPacket,
13349    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
13350    /// the StreamProcessor channel.
13351    QueueInputEndOfStream {
13352        stream_lifetime_ordinal: u64,
13353        control_handle: StreamProcessorControlHandle,
13354    },
13355    /// This message results in channel closure unless supports_dynamic_buffers
13356    /// is set to true.
13357    ///
13358    /// This participates in allocation of buffers to be used with AddBuffer
13359    /// later. The client can get VMO handles for these buffers by also
13360    /// participating in the sysmem allocation, using the client's own related
13361    /// sysmem token (associated with the same logical buffer collection). It's
13362    /// up to the client to separately set any constraints needed by the client
13363    /// using the client's own related sysmem token, if any.
13364    ///
13365    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
13366    /// SetOutputBufferPartialSettings. Servers must support those messages.
13367    ///
13368    /// In handling this message, if `allow_single_buffer` is set to true, the
13369    /// server must not constrain the number of buffers allocated. The server
13370    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
13371    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
13372    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
13373    /// same value if the intent is to allocate exactly that many buffers. If
13374    /// `allow_single_buffer` is un-set or set to false, the server will
13375    /// indicate needed buffer counts to sysmem.
13376    ///
13377    /// The server's BufferCollection channel (created from the passed-in
13378    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
13379    /// particular, the server shouldn't expect the BufferCollection channel to
13380    /// remain connected to sysmem beyond the server sending SetConstraints. For
13381    /// this reason, the server may not be able to call
13382    /// WaitForAllBuffersAllocated or similar, so the server should just send
13383    /// SetConstraints, Close, then close the server's BufferCollection
13384    /// client_end. This means the server in general shouldn't attempt to get
13385    /// VMO handles for these buffers while processing this message.
13386    ///
13387    /// The server should not assume that these buffers will necessarily ever be
13388    /// added with AddBuffer to this StreamProcessor instance or any other
13389    /// StreamProcessor instance (owned by the server or not). These buffers may
13390    /// instead be dropped, or as a less-common example, possibly added to a
13391    /// different codec served by a different server implementation which also
13392    /// participated in the same sysmem buffer collection allocation.
13393    ///
13394    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
13395    /// StreamProcessor instance of the same codec (same per CodecFactory) is
13396    /// likely to work, but using the same StreamProcessor instance is
13397    /// recommended when feasible.
13398    ///
13399    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
13400    /// a different StreamProcessor instance of the same codec (same per
13401    /// CodecFactory) can't (within reason) be made work in general, especially
13402    /// for video decoders. Therefore, for output buffers, the same
13403    /// StreamProcessor instance must be used for this message and AddBuffer.
13404    /// While a client may currently be able to get away with using different
13405    /// StreamProcessor instances for this message and AddBuffer for output
13406    /// buffers for some codecs, this may break at any time without it being
13407    /// considered a server-side bug.
13408    ///
13409    /// The allocated buffers can later be added using AddBuffer (piecemeal),
13410    /// and can be removed (piecemeal) using RemoveBuffer.
13411    ///
13412    /// Multiple different ParticipateInBufferAllocation messages can have their
13413    /// buffers later added to the same StreamProcessor instance using the same
13414    /// buffer_lifetime_ordinal. This can be useful if the client wants to
13415    /// allocate buffers incrementally, or dynamically adjust the number of
13416    /// buffers, potentially while actively processing. See also the
13417    /// `buffer_lifetime_ordinal` field of this message.
13418    ///
13419    /// Server implementations may use sysmem to help verify buffer
13420    /// compatibility later when buffers are added with AddBuffer.
13421    ParticipateInBufferAllocation {
13422        payload: StreamProcessorParticipateInBufferAllocationRequest,
13423        control_handle: StreamProcessorControlHandle,
13424    },
13425    /// Add buffers previously created with the help of
13426    /// ParticipateInBufferAllocation.
13427    ///
13428    /// For input buffers, the client can send QueueInputFormatDetails or
13429    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
13430    /// buffer must be added before a valid QueueInputPacket can be sent. Most
13431    /// clients will want to continue quickly adding buffers up to at least
13432    /// buffer_count_for_server_current to avoid the codec potentially stalling,
13433    /// and typically a low number of buffers beyond that to keep the pipeline
13434    /// running smoothly. Input buffers beyond the first input buffer can be
13435    /// added after the first QueueInputPacket.
13436    ///
13437    /// Even if buffer_constraints_version_ordinal is current, the server must
13438    /// not close the channel if the buffer isn't consistent with the current
13439    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
13440    /// consistent StreamProcessor constraints). Instead, the server must send a
13441    /// new OnOutputConstraints. This simplifies some edge cases for some
13442    /// clients, particularly when a client can't reliably detect whether a
13443    /// newly-obtained buffer was actually allocated after
13444    /// buffer_constraints_version_ordinal changed, or may have been cached from
13445    /// before.
13446    ///
13447    /// The client can add additional buffers to the same port and
13448    /// buffer_lifetime_ordinal at any time using this message. If the
13449    /// buffer_lifetime_ordinal is no longer the most recent, the message will
13450    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
13451    /// message re. the same buffer will complete immediately.
13452    ///
13453    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
13454    /// by the sum of buffers added by all AddBuffer calls with the same
13455    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
13456    /// required to close the channel in this case if performance degradation or
13457    /// un-tested behavior would result from adding too many buffers.
13458    ///
13459    /// Switching to a new buffer_lifetime_ordinal starts the process of
13460    /// removing buffers associated with an old buffer_lifetime_ordinal.
13461    /// However, until the remove is complete, those buffers can still be used
13462    /// by the codec as normal. See also RemoveBuffer, which can be used to
13463    /// detect when removal is complete, regardless of whether the RemoveBuffer
13464    /// started the removal (including when not using dynamic buffers).
13465    ///
13466    /// The buffer stays added until removal later completes. The buffer remains
13467    /// added across potentially multiple buffer re-uses. Removal can be
13468    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
13469    /// The codec server can unilaterally initiate buffer removal; if the server
13470    /// does this, it must send a new buffer_constraints_version_ordinal with
13471    /// action_required true. Some other client-initiated messages can also
13472    /// begin buffer removal, such as CloseCurrentStream with
13473    /// release_input_buffers and/or release_output_buffers. The buffers are
13474    /// also automatically removed and released if the client closes the
13475    /// StreamProcessor client_end or the server closes the StreamProcessor
13476    /// server_end.
13477    ///
13478    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
13479    /// SetOutputBufferPartialSettings is not allowed while there are any
13480    /// buffers still active on the port. To successfully switch modes for a
13481    /// port, most clients will want to just start over with a new
13482    /// StreamProcessor instance. This can also be done reliably by first
13483    /// ensuring that every added buffer under the port up to "now" (including
13484    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13485    /// request. Only then is it known ok to switch modes for that port under
13486    /// the same StreamProcessor. Most clients will just use one way or the
13487    /// other to add buffers and never need to switch to the other way,
13488    /// especially within the same StreamProcessor.
13489    ///
13490    /// If a client might plausibly "spam" creation of many new
13491    /// buffer_lifetime_ordinal values without the buffers seeing any actual
13492    /// usage in between, the client should consider starting a Sync every few
13493    /// buffer_lifetime_ordinal(s) to fence cleanup of old
13494    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
13495    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
13496    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
13497    /// getting too far ahead of closing out old ones. The threshold of 16 is
13498    /// well below the enforcement threshold. Clients don't need to Sync if they
13499    /// won't be spamming new buffer_lifetime_ordinal values, or if added
13500    /// buffers will see at least some actual usage visible to the client before
13501    /// being replaced again.
13502    ///
13503    /// All buffers of the same port and buffer_lifetime_ordinal must share the
13504    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
13505    /// this in various ways. One way is to use ParticipateInBufferAllocation
13506    /// then AddBuffer for at least the first buffer, before
13507    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
13508    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
13509    /// and bump to the next odd buffer_lifetime_ordinal value for the
13510    /// AddBuffer.
13511    AddBuffer {
13512        payload: StreamProcessorAddBufferRequest,
13513        control_handle: StreamProcessorControlHandle,
13514    },
13515    /// When using dynamic buffers, this call removes a buffer as soon as the
13516    /// buffer can be removed without adversely impacting any ongoing processing
13517    /// or an in-flight output packet referring to the buffer.
13518    ///
13519    /// If a client wants to remove a buffer with an in-flight output packet
13520    /// referring to the buffer, the client must RecycleOutputPacket for that
13521    /// in-flight output packet before the RemoveBuffer will complete.
13522    ///
13523    /// When using SetInputBufferPartialSettings /
13524    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
13525    /// the buffer. This call will complete when the buffer is done removing due
13526    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
13527    ///
13528    /// Until RemoveBuffer completes, the codec is still allowed to send
13529    /// OnOutputPacket messages referencing the buffer, and the codec may still
13530    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
13531    /// codec guarantees that no subsequent output packet will reference the
13532    /// buffer, and that the server holds no VMO handles to the buffer.
13533    ///
13534    /// The client may need to recycle an output packet before the RemoveBuffer
13535    /// call can complete. Clients should take care to avoid blocking packet
13536    /// recycling while the RemoveBuffer request is in progress, since this
13537    /// would create a potential deadlock.
13538    ///
13539    /// The server closing any VMO handles to the buffer prior to completing
13540    /// this call is important for the client's ability to prevent memory usage
13541    /// spikes.
13542    ///
13543    /// If the client has "paused" processing by not providing any more input,
13544    /// the client will potentially need to send CloseCurrentStream before
13545    /// RemoveBuffer will complete. When using dynamic buffers, setting
13546    /// release_input_buffers or release_output_buffers to true is not
13547    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
13548    /// specific buffer. When not using dynamic buffers, the client will need to
13549    /// set release_input_buffers or release_output_buffers to true, since
13550    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
13551    /// buffers. A current "paused" stream needs to be stopped because frames
13552    /// can be held as reference frames, and codecs are never reqiured to copy
13553    /// their output data.
13554    ///
13555    /// For any video decoder output buffers being removed while there's an
13556    /// active stream (being fed input or not), it's typically best for the
13557    /// client to assume that removal of a video decoder output buffer may take
13558    /// a very long duration. This is because bitstreams, especially
13559    /// non-standard-compliant bitstreams, but in some cases potentially even
13560    /// standard-compliant bitstreams, can keep a video decoder output buffer in
13561    /// the set of active reference frames (aka DPB) indefinitely. The server is
13562    /// not required to notice that a stream is not conforming to a bitstream
13563    /// standard in this regard.
13564    ///
13565    /// In the case of h.264 decode, a standard-complient bitstream will limit
13566    /// the reorder delay to no longer than the max DPB occupancy. However, a
13567    /// server is not required to detect or reject non-compliant streams that
13568    /// potentially keep a frame in the DPB for longer.
13569    ///
13570    /// For HEVC, the situation is similar to h.264 (IIUC).
13571    ///
13572    /// In the case of VP9, there is nothing in the bitstream spec that limits
13573    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
13574    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
13575    /// required to detect or mitigate this.
13576    ///
13577    /// Until this call completes, the server may still be using the buffer. For
13578    /// output buffers, the server can still send OnOutputPacket message(s) that
13579    /// references this buffer, but only up until the RemoveBuffer completion
13580    /// message is sent by the server. The client must continue to
13581    /// RecycleOutputPacket for packets that reference the buffer, until
13582    /// RemoveBuffer completes.
13583    ///
13584    /// When using dynamic buffers, upon receiving this message, the server will
13585    /// stop selecting the buffer for any new usage (as in, for any usage that
13586    /// moves the buffer from "free" to "not free" within the server). This
13587    /// applies even if the server has no other buffers available for use (aka
13588    /// no other "free" buffers). Any existing usage of the buffer is not ended
13589    /// early by this call alone.
13590    ///
13591    /// When not using dynamic buffers, upon receiving this message, the server
13592    /// will just remember to complete this call shortly after the buffer has
13593    /// completed removal triggered by some other cause (removal is not
13594    /// triggered/caused by this call).
13595    ///
13596    /// For video decoders, when using dynamic buffers, typically the client
13597    /// should take care to avoid removing too many output buffers for continued
13598    /// decode to be possible. If this occurs, the decoder will wait until the
13599    /// client adds another output buffer with AddBuffer. This can be a deadlock
13600    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
13601    /// frame reordering, sending a single AddBuffer doesn't necessarily
13602    /// guarantee another OnOutputPacket, since additional output buffers can be
13603    /// needed before the server can send OnOutputPacket.
13604    ///
13605    /// The client must not call RemoveBuffer on the same buffer more than once,
13606    /// whether overlapping in time or not. The server should enforce this when
13607    /// not enforcing would require tracking additional concurrent requests. The
13608    /// server is not required to enforce this when enforcing would use more
13609    /// server memory.
13610    ///
13611    /// The server is allowed to complete this request quickly with success for
13612    /// buffer_lifetime_ordinal and buffer_index combinations that were never
13613    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
13614    /// hasn't been started by the client yet (no removing potential future
13615    /// buffers).
13616    ///
13617    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
13618    /// combination may be re-used after completion of RemoveBuffer, but only if
13619    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
13620    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
13621    ///
13622    /// Assuming a valid historical buffer is specified, successful completion
13623    /// of this call means the buffer has been fully released by the server and
13624    /// won't be referenced in any subsequent OnOutputPacket.
13625    RemoveBuffer {
13626        payload: StreamProcessorRemoveBufferRequest,
13627        responder: StreamProcessorRemoveBufferResponder,
13628    },
13629    /// This informs the StreamProcessor that the client is prepared to handle
13630    /// output packets that specify a buffer with buffer_lifetime_ordinal older
13631    /// than the most recent buffer_lifetime_ordinal.
13632    ///
13633    /// If the client doesn't send this message, the StreamProcessor will omit
13634    /// any such output, even if
13635    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
13636    /// decoders such as VP9 decoders, not sending this message can result in
13637    /// output that isn't bistream spec compliant, and the output can be
13638    /// visually different than intended by the bitstream.
13639    ///
13640    /// Such streams are only possible with some bitstream formats (such as
13641    /// VP9), and are rare, but can happen and can be valid per the bitstream
13642    /// spec. For example, this can be specified by a VP9 bitstream using
13643    /// show_existing_frame to output an old-dimensions buffer after having
13644    /// already output a new-dimensions buffer.
13645    ///
13646    /// Most clients that send this message will also want to use RemoveBuffer
13647    /// to know when it becomes safe to stop tracking an old buffer.
13648    ///
13649    /// Most of the time this makes no difference as most bitstreams don't
13650    /// actually emit old buffers, even if the bitstream spec would allow it.
13651    /// Old output buffers are especially rare for RTC streams which typically
13652    /// don't have any frame reordering in the first place.
13653    ///
13654    /// In most video streaming scenarios that use dimension switching as part
13655    /// of their bitrate control strategy (among those that I've observed), at
13656    /// the StreamProcessor layer the new dimensions are part of a new stream
13657    /// instead of being spliced together as a continuation of the old stream.
13658    /// That said, using a continuation of the old stream is also a completely
13659    /// valid way to implement dimension switching. When a stream switch occurs
13660    /// as part of dimension switching, the decoder state is not retained and
13661    /// there won't be any old buffer(s) emitted after new buffer(s), since the
13662    /// new stream doesn't know anything about old buffers filled by the old
13663    /// stream.
13664    ///
13665    /// Clients which haven't tested their ability to handle old output buffers
13666    /// should not send this message. Clients decoding bitstreams like VP9 for
13667    /// decoder compliance testing purposes should send this message (and use a
13668    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
13669    /// Clients which are required to support old output frames and/or fully
13670    /// comply with a relevant bitstream spec should/must send this message, and
13671    /// should test using a test stream that outputs packets referencing an old
13672    /// output buffer.
13673    ///
13674    /// Sending this message more than once closes the channel. If sent, this
13675    /// message must be sent prior to the client establishing the first output
13676    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
13677    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
13678    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
13679    /// client when this message was not sent by the client.
13680    ///
13681    /// This message is only permitted when
13682    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13683    /// is true.
13684    EnableOldOutputBuffers { control_handle: StreamProcessorControlHandle },
13685    /// This informs the StreamProcessor that the client is prepared to handle
13686    /// output packets that specify the same buffer as another packet that's
13687    /// also concurrently in flight to the client (not yet recycled).
13688    ///
13689    /// Most bitstream formats don't do this. In formats that can do this such
13690    /// as VP9, most actual bitstreams don't do this.
13691    ///
13692    /// As an example, in VP9, a stream can cause the same output buffer to be
13693    /// used by another emitted output packet/frame by using show_existing_frame
13694    /// on the same VP9 reference/held frame slot more than once without
13695    /// decoding a new frame into that slot in between.
13696    ///
13697    /// Clients that need to achieve full bitstream spec compliance for such a
13698    /// bitstream format must send this message.
13699    ///
13700    /// If this message is not in effect, the server will omit any such output,
13701    /// which can result in output that is not compliant to the relevant
13702    /// bitstream spec, and which can be visually different than the stream
13703    /// intended.
13704    ///
13705    /// Sending this message more than once closes the channel. If sent, this
13706    /// message must be sent prior to the client establishing the first output
13707    /// buffer_lifetime_ordinal.
13708    ///
13709    /// This message is only permitted when
13710    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13711    /// is true.
13712    EnableSameOutputBufferConcurrentlyInFlight { control_handle: StreamProcessorControlHandle },
13713    /// For video decoders, this forces the output buffers to be reallocated if
13714    /// the image size needs to change. This is wasteful as it forces extra
13715    /// buffer reallocations given typical video bitrate control strategies
13716    /// (applicable to both streaming and RTC) involving shifting the image
13717    /// dimensions up and down repeatedly as a logical video/stream plays,
13718    /// sometimes even if network conditions remain fairly stable. This extra
13719    /// buffer reallocation cost is incurred vs. baseline whether the dimension
13720    /// switching is achieved within a single StreamProcessor stream or by using
13721    /// a new StreamProcessor stream for new dimensions.
13722    ///
13723    /// A client should not send this message unless the client really must
13724    /// force the output buffers to be reallocated every time the output image
13725    /// size changes.
13726    ///
13727    /// Sending this message more than once closes the channel. If sent, this
13728    /// message must be sent prior to any SetInputBufferPartialSettings,
13729    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
13730    /// AddBuffer.
13731    ///
13732    /// This message is only permitted if this StreamProcessor is a video
13733    /// decoder.
13734    ///
13735    /// This message is only permitted when
13736    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13737    /// is true.
13738    EnableForceOutputBuffersFixedImageSize { control_handle: StreamProcessorControlHandle },
13739    /// An interaction was received which does not match any known method.
13740    #[non_exhaustive]
13741    _UnknownMethod {
13742        /// Ordinal of the method that was called.
13743        ordinal: u64,
13744        control_handle: StreamProcessorControlHandle,
13745        method_type: fidl::MethodType,
13746    },
13747}
13748
13749impl StreamProcessorRequest {
13750    #[allow(irrefutable_let_patterns)]
13751    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
13752        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
13753            Some((control_handle))
13754        } else {
13755            None
13756        }
13757    }
13758
13759    #[allow(irrefutable_let_patterns)]
13760    pub fn into_set_input_buffer_partial_settings(
13761        self,
13762    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
13763        if let StreamProcessorRequest::SetInputBufferPartialSettings {
13764            input_settings,
13765            control_handle,
13766        } = self
13767        {
13768            Some((input_settings, control_handle))
13769        } else {
13770            None
13771        }
13772    }
13773
13774    #[allow(irrefutable_let_patterns)]
13775    pub fn into_set_output_buffer_partial_settings(
13776        self,
13777    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
13778        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
13779            output_settings,
13780            control_handle,
13781        } = self
13782        {
13783            Some((output_settings, control_handle))
13784        } else {
13785            None
13786        }
13787    }
13788
13789    #[allow(irrefutable_let_patterns)]
13790    pub fn into_complete_output_buffer_partial_settings(
13791        self,
13792    ) -> Option<(u64, StreamProcessorControlHandle)> {
13793        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
13794            buffer_lifetime_ordinal,
13795            control_handle,
13796        } = self
13797        {
13798            Some((buffer_lifetime_ordinal, control_handle))
13799        } else {
13800            None
13801        }
13802    }
13803
13804    #[allow(irrefutable_let_patterns)]
13805    pub fn into_flush_end_of_stream_and_close_stream(
13806        self,
13807    ) -> Option<(u64, StreamProcessorControlHandle)> {
13808        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
13809            stream_lifetime_ordinal,
13810            control_handle,
13811        } = self
13812        {
13813            Some((stream_lifetime_ordinal, control_handle))
13814        } else {
13815            None
13816        }
13817    }
13818
13819    #[allow(irrefutable_let_patterns)]
13820    pub fn into_close_current_stream(
13821        self,
13822    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
13823        if let StreamProcessorRequest::CloseCurrentStream {
13824            stream_lifetime_ordinal,
13825            release_input_buffers,
13826            release_output_buffers,
13827            control_handle,
13828        } = self
13829        {
13830            Some((
13831                stream_lifetime_ordinal,
13832                release_input_buffers,
13833                release_output_buffers,
13834                control_handle,
13835            ))
13836        } else {
13837            None
13838        }
13839    }
13840
13841    #[allow(irrefutable_let_patterns)]
13842    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
13843        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
13844    }
13845
13846    #[allow(irrefutable_let_patterns)]
13847    pub fn into_recycle_output_packet(
13848        self,
13849    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
13850        if let StreamProcessorRequest::RecycleOutputPacket {
13851            available_output_packet,
13852            control_handle,
13853        } = self
13854        {
13855            Some((available_output_packet, control_handle))
13856        } else {
13857            None
13858        }
13859    }
13860
13861    #[allow(irrefutable_let_patterns)]
13862    pub fn into_queue_input_format_details(
13863        self,
13864    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
13865        if let StreamProcessorRequest::QueueInputFormatDetails {
13866            stream_lifetime_ordinal,
13867            format_details,
13868            control_handle,
13869        } = self
13870        {
13871            Some((stream_lifetime_ordinal, format_details, control_handle))
13872        } else {
13873            None
13874        }
13875    }
13876
13877    #[allow(irrefutable_let_patterns)]
13878    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
13879        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
13880            Some((packet, control_handle))
13881        } else {
13882            None
13883        }
13884    }
13885
13886    #[allow(irrefutable_let_patterns)]
13887    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
13888        if let StreamProcessorRequest::QueueInputEndOfStream {
13889            stream_lifetime_ordinal,
13890            control_handle,
13891        } = self
13892        {
13893            Some((stream_lifetime_ordinal, control_handle))
13894        } else {
13895            None
13896        }
13897    }
13898
13899    #[allow(irrefutable_let_patterns)]
13900    pub fn into_participate_in_buffer_allocation(
13901        self,
13902    ) -> Option<(StreamProcessorParticipateInBufferAllocationRequest, StreamProcessorControlHandle)>
13903    {
13904        if let StreamProcessorRequest::ParticipateInBufferAllocation { payload, control_handle } =
13905            self
13906        {
13907            Some((payload, control_handle))
13908        } else {
13909            None
13910        }
13911    }
13912
13913    #[allow(irrefutable_let_patterns)]
13914    pub fn into_add_buffer(
13915        self,
13916    ) -> Option<(StreamProcessorAddBufferRequest, StreamProcessorControlHandle)> {
13917        if let StreamProcessorRequest::AddBuffer { payload, control_handle } = self {
13918            Some((payload, control_handle))
13919        } else {
13920            None
13921        }
13922    }
13923
13924    #[allow(irrefutable_let_patterns)]
13925    pub fn into_remove_buffer(
13926        self,
13927    ) -> Option<(StreamProcessorRemoveBufferRequest, StreamProcessorRemoveBufferResponder)> {
13928        if let StreamProcessorRequest::RemoveBuffer { payload, responder } = self {
13929            Some((payload, responder))
13930        } else {
13931            None
13932        }
13933    }
13934
13935    #[allow(irrefutable_let_patterns)]
13936    pub fn into_enable_old_output_buffers(self) -> Option<(StreamProcessorControlHandle)> {
13937        if let StreamProcessorRequest::EnableOldOutputBuffers { control_handle } = self {
13938            Some((control_handle))
13939        } else {
13940            None
13941        }
13942    }
13943
13944    #[allow(irrefutable_let_patterns)]
13945    pub fn into_enable_same_output_buffer_concurrently_in_flight(
13946        self,
13947    ) -> Option<(StreamProcessorControlHandle)> {
13948        if let StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
13949            control_handle,
13950        } = self
13951        {
13952            Some((control_handle))
13953        } else {
13954            None
13955        }
13956    }
13957
13958    #[allow(irrefutable_let_patterns)]
13959    pub fn into_enable_force_output_buffers_fixed_image_size(
13960        self,
13961    ) -> Option<(StreamProcessorControlHandle)> {
13962        if let StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { control_handle } =
13963            self
13964        {
13965            Some((control_handle))
13966        } else {
13967            None
13968        }
13969    }
13970
13971    /// Name of the method defined in FIDL
13972    pub fn method_name(&self) -> &'static str {
13973        match *self {
13974            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
13975            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
13976                "set_input_buffer_partial_settings"
13977            }
13978            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
13979                "set_output_buffer_partial_settings"
13980            }
13981            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
13982                "complete_output_buffer_partial_settings"
13983            }
13984            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
13985                "flush_end_of_stream_and_close_stream"
13986            }
13987            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
13988            StreamProcessorRequest::Sync { .. } => "sync",
13989            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
13990            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
13991            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
13992            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
13993            StreamProcessorRequest::ParticipateInBufferAllocation { .. } => {
13994                "participate_in_buffer_allocation"
13995            }
13996            StreamProcessorRequest::AddBuffer { .. } => "add_buffer",
13997            StreamProcessorRequest::RemoveBuffer { .. } => "remove_buffer",
13998            StreamProcessorRequest::EnableOldOutputBuffers { .. } => "enable_old_output_buffers",
13999            StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight { .. } => {
14000                "enable_same_output_buffer_concurrently_in_flight"
14001            }
14002            StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { .. } => {
14003                "enable_force_output_buffers_fixed_image_size"
14004            }
14005            StreamProcessorRequest::_UnknownMethod {
14006                method_type: fidl::MethodType::OneWay,
14007                ..
14008            } => "unknown one-way method",
14009            StreamProcessorRequest::_UnknownMethod {
14010                method_type: fidl::MethodType::TwoWay,
14011                ..
14012            } => "unknown two-way method",
14013        }
14014    }
14015}
14016
14017#[derive(Debug, Clone)]
14018pub struct StreamProcessorControlHandle {
14019    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14020}
14021
14022impl fdomain_client::fidl::ControlHandle for StreamProcessorControlHandle {
14023    fn shutdown(&self) {
14024        self.inner.shutdown()
14025    }
14026
14027    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
14028        self.inner.shutdown_with_epitaph(status)
14029    }
14030
14031    fn is_closed(&self) -> bool {
14032        self.inner.channel().is_closed()
14033    }
14034    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14035        self.inner.channel().on_closed()
14036    }
14037}
14038
14039impl StreamProcessorControlHandle {
14040    pub fn send_on_stream_failed(
14041        &self,
14042        mut stream_lifetime_ordinal: u64,
14043        mut error: StreamError,
14044    ) -> Result<(), fidl::Error> {
14045        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
14046            (stream_lifetime_ordinal, error),
14047            0,
14048            0x77ccf70bb061cf8e,
14049            fidl::encoding::DynamicFlags::empty(),
14050        )
14051    }
14052
14053    pub fn send_on_input_constraints(
14054        &self,
14055        mut input_constraints: &StreamBufferConstraints,
14056    ) -> Result<(), fidl::Error> {
14057        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
14058            (input_constraints,),
14059            0,
14060            0x211da9966a8ca0,
14061            fidl::encoding::DynamicFlags::empty(),
14062        )
14063    }
14064
14065    pub fn send_on_output_constraints(
14066        &self,
14067        mut output_config: &StreamOutputConstraints,
14068    ) -> Result<(), fidl::Error> {
14069        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
14070            (output_config,),
14071            0,
14072            0x40d8234504c170f3,
14073            fidl::encoding::DynamicFlags::empty(),
14074        )
14075    }
14076
14077    pub fn send_on_output_format(
14078        &self,
14079        mut output_format: &StreamOutputFormat,
14080    ) -> Result<(), fidl::Error> {
14081        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
14082            (output_format,),
14083            0,
14084            0x131b77ae120360bc,
14085            fidl::encoding::DynamicFlags::empty(),
14086        )
14087    }
14088
14089    pub fn send_on_output_packet(
14090        &self,
14091        mut output_packet: &Packet,
14092        mut error_detected_before: bool,
14093        mut error_detected_during: bool,
14094    ) -> Result<(), fidl::Error> {
14095        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
14096            (output_packet, error_detected_before, error_detected_during),
14097            0,
14098            0x5c2029be1090ce93,
14099            fidl::encoding::DynamicFlags::empty(),
14100        )
14101    }
14102
14103    pub fn send_on_output_end_of_stream(
14104        &self,
14105        mut stream_lifetime_ordinal: u64,
14106        mut error_detected_before: bool,
14107    ) -> Result<(), fidl::Error> {
14108        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
14109            (stream_lifetime_ordinal, error_detected_before),
14110            0,
14111            0x3bb65d237cfa50e6,
14112            fidl::encoding::DynamicFlags::empty(),
14113        )
14114    }
14115
14116    pub fn send_on_free_input_packet(
14117        &self,
14118        mut free_input_packet: &PacketHeader,
14119    ) -> Result<(), fidl::Error> {
14120        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
14121            (free_input_packet,),
14122            0,
14123            0xeef799b28708bbd,
14124            fidl::encoding::DynamicFlags::empty(),
14125        )
14126    }
14127
14128    pub fn send_on_output_timestamp_has_no_output(
14129        &self,
14130        mut payload: &StreamProcessorOnOutputTimestampHasNoOutputRequest,
14131    ) -> Result<(), fidl::Error> {
14132        self.inner.send::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(
14133            payload,
14134            0,
14135            0x7436457799a25cd4,
14136            fidl::encoding::DynamicFlags::FLEXIBLE,
14137        )
14138    }
14139}
14140
14141#[must_use = "FIDL methods require a response to be sent"]
14142#[derive(Debug)]
14143pub struct StreamProcessorSyncResponder {
14144    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
14145    tx_id: u32,
14146}
14147
14148/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
14149/// if the responder is dropped without sending a response, so that the client
14150/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14151impl std::ops::Drop for StreamProcessorSyncResponder {
14152    fn drop(&mut self) {
14153        self.control_handle.shutdown();
14154        // Safety: drops once, never accessed again
14155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14156    }
14157}
14158
14159impl fdomain_client::fidl::Responder for StreamProcessorSyncResponder {
14160    type ControlHandle = StreamProcessorControlHandle;
14161
14162    fn control_handle(&self) -> &StreamProcessorControlHandle {
14163        &self.control_handle
14164    }
14165
14166    fn drop_without_shutdown(mut self) {
14167        // Safety: drops once, never accessed again due to mem::forget
14168        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14169        // Prevent Drop from running (which would shut down the channel)
14170        std::mem::forget(self);
14171    }
14172}
14173
14174impl StreamProcessorSyncResponder {
14175    /// Sends a response to the FIDL transaction.
14176    ///
14177    /// Sets the channel to shutdown if an error occurs.
14178    pub fn send(self) -> Result<(), fidl::Error> {
14179        let _result = self.send_raw();
14180        if _result.is_err() {
14181            self.control_handle.shutdown();
14182        }
14183        self.drop_without_shutdown();
14184        _result
14185    }
14186
14187    /// Similar to "send" but does not shutdown the channel if an error occurs.
14188    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14189        let _result = self.send_raw();
14190        self.drop_without_shutdown();
14191        _result
14192    }
14193
14194    fn send_raw(&self) -> Result<(), fidl::Error> {
14195        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14196            (),
14197            self.tx_id,
14198            0x4b3e44300b0ec6aa,
14199            fidl::encoding::DynamicFlags::empty(),
14200        )
14201    }
14202}
14203
14204#[must_use = "FIDL methods require a response to be sent"]
14205#[derive(Debug)]
14206pub struct StreamProcessorRemoveBufferResponder {
14207    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
14208    tx_id: u32,
14209}
14210
14211/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
14212/// if the responder is dropped without sending a response, so that the client
14213/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14214impl std::ops::Drop for StreamProcessorRemoveBufferResponder {
14215    fn drop(&mut self) {
14216        self.control_handle.shutdown();
14217        // Safety: drops once, never accessed again
14218        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14219    }
14220}
14221
14222impl fdomain_client::fidl::Responder for StreamProcessorRemoveBufferResponder {
14223    type ControlHandle = StreamProcessorControlHandle;
14224
14225    fn control_handle(&self) -> &StreamProcessorControlHandle {
14226        &self.control_handle
14227    }
14228
14229    fn drop_without_shutdown(mut self) {
14230        // Safety: drops once, never accessed again due to mem::forget
14231        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14232        // Prevent Drop from running (which would shut down the channel)
14233        std::mem::forget(self);
14234    }
14235}
14236
14237impl StreamProcessorRemoveBufferResponder {
14238    /// Sends a response to the FIDL transaction.
14239    ///
14240    /// Sets the channel to shutdown if an error occurs.
14241    pub fn send(self) -> Result<(), fidl::Error> {
14242        let _result = self.send_raw();
14243        if _result.is_err() {
14244            self.control_handle.shutdown();
14245        }
14246        self.drop_without_shutdown();
14247        _result
14248    }
14249
14250    /// Similar to "send" but does not shutdown the channel if an error occurs.
14251    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14252        let _result = self.send_raw();
14253        self.drop_without_shutdown();
14254        _result
14255    }
14256
14257    fn send_raw(&self) -> Result<(), fidl::Error> {
14258        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
14259            fidl::encoding::Flexible::new(()),
14260            self.tx_id,
14261            0x40b967ffa6b2da43,
14262            fidl::encoding::DynamicFlags::FLEXIBLE,
14263        )
14264    }
14265}
14266
14267#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14268pub struct StreamSinkMarker;
14269
14270impl fdomain_client::fidl::ProtocolMarker for StreamSinkMarker {
14271    type Proxy = StreamSinkProxy;
14272    type RequestStream = StreamSinkRequestStream;
14273
14274    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
14275}
14276
14277pub trait StreamSinkProxyInterface: Send + Sync {
14278    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14279    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
14280    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
14281    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
14282    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14283    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
14284    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
14285}
14286
14287#[derive(Debug, Clone)]
14288pub struct StreamSinkProxy {
14289    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14290}
14291
14292impl fdomain_client::fidl::Proxy for StreamSinkProxy {
14293    type Protocol = StreamSinkMarker;
14294
14295    fn from_channel(inner: fdomain_client::Channel) -> Self {
14296        Self::new(inner)
14297    }
14298
14299    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14300        self.client.into_channel().map_err(|client| Self { client })
14301    }
14302
14303    fn as_channel(&self) -> &fdomain_client::Channel {
14304        self.client.as_channel()
14305    }
14306}
14307
14308impl StreamSinkProxy {
14309    /// Create a new Proxy for fuchsia.media/StreamSink.
14310    pub fn new(channel: fdomain_client::Channel) -> Self {
14311        let protocol_name = <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14312        Self { client: fidl::client::Client::new(channel, protocol_name) }
14313    }
14314
14315    /// Get a Stream of events from the remote end of the protocol.
14316    ///
14317    /// # Panics
14318    ///
14319    /// Panics if the event stream was already taken.
14320    pub fn take_event_stream(&self) -> StreamSinkEventStream {
14321        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
14322    }
14323
14324    /// Sends a packet to the service. The response is sent when the service is
14325    /// done with the associated payload memory.
14326    ///
14327    /// `packet` must be valid for the current buffer set, otherwise the service
14328    /// will close the connection.
14329    pub fn r#send_packet(
14330        &self,
14331        mut packet: &StreamPacket,
14332    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14333        StreamSinkProxyInterface::r#send_packet(self, packet)
14334    }
14335
14336    /// Sends a packet to the service. This interface doesn't define how the
14337    /// client knows when the sink is done with the associated payload memory.
14338    /// The inheriting interface must define that.
14339    ///
14340    /// `packet` must be valid for the current buffer set, otherwise the service
14341    /// will close the connection.
14342    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14343        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
14344    }
14345
14346    /// Indicates the stream has ended. The precise semantics of this method are
14347    /// determined by the inheriting interface.
14348    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
14349        StreamSinkProxyInterface::r#end_of_stream(self)
14350    }
14351
14352    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14353    /// and not yet released. The response is sent after all packets have been
14354    /// released.
14355    pub fn r#discard_all_packets(
14356        &self,
14357    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14358        StreamSinkProxyInterface::r#discard_all_packets(self)
14359    }
14360
14361    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14362    /// and not yet released.
14363    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14364        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
14365    }
14366}
14367
14368impl StreamSinkProxyInterface for StreamSinkProxy {
14369    type SendPacketResponseFut =
14370        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14371    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
14372        fn _decode(
14373            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14374        ) -> Result<(), fidl::Error> {
14375            let _response = fidl::client::decode_transaction_body::<
14376                fidl::encoding::EmptyPayload,
14377                fdomain_client::fidl::FDomainResourceDialect,
14378                0x67cddd607442775f,
14379            >(_buf?)?;
14380            Ok(_response)
14381        }
14382        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
14383            (packet,),
14384            0x67cddd607442775f,
14385            fidl::encoding::DynamicFlags::empty(),
14386            _decode,
14387        )
14388    }
14389
14390    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14391        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
14392            (packet,),
14393            0x8d9b8b413ceba9d,
14394            fidl::encoding::DynamicFlags::empty(),
14395        )
14396    }
14397
14398    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
14399        self.client.send::<fidl::encoding::EmptyPayload>(
14400            (),
14401            0x6180fd6f7e793b71,
14402            fidl::encoding::DynamicFlags::empty(),
14403        )
14404    }
14405
14406    type DiscardAllPacketsResponseFut =
14407        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14408    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
14409        fn _decode(
14410            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14411        ) -> Result<(), fidl::Error> {
14412            let _response = fidl::client::decode_transaction_body::<
14413                fidl::encoding::EmptyPayload,
14414                fdomain_client::fidl::FDomainResourceDialect,
14415                0x6f4dad7af2917665,
14416            >(_buf?)?;
14417            Ok(_response)
14418        }
14419        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14420            (),
14421            0x6f4dad7af2917665,
14422            fidl::encoding::DynamicFlags::empty(),
14423            _decode,
14424        )
14425    }
14426
14427    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14428        self.client.send::<fidl::encoding::EmptyPayload>(
14429            (),
14430            0x50d36d0d23081bc4,
14431            fidl::encoding::DynamicFlags::empty(),
14432        )
14433    }
14434}
14435
14436pub struct StreamSinkEventStream {
14437    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
14438}
14439
14440impl std::marker::Unpin for StreamSinkEventStream {}
14441
14442impl futures::stream::FusedStream for StreamSinkEventStream {
14443    fn is_terminated(&self) -> bool {
14444        self.event_receiver.is_terminated()
14445    }
14446}
14447
14448impl futures::Stream for StreamSinkEventStream {
14449    type Item = Result<StreamSinkEvent, fidl::Error>;
14450
14451    fn poll_next(
14452        mut self: std::pin::Pin<&mut Self>,
14453        cx: &mut std::task::Context<'_>,
14454    ) -> std::task::Poll<Option<Self::Item>> {
14455        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14456            &mut self.event_receiver,
14457            cx
14458        )?) {
14459            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
14460            None => std::task::Poll::Ready(None),
14461        }
14462    }
14463}
14464
14465#[derive(Debug)]
14466pub enum StreamSinkEvent {}
14467
14468impl StreamSinkEvent {
14469    /// Decodes a message buffer as a [`StreamSinkEvent`].
14470    fn decode(
14471        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14472    ) -> Result<StreamSinkEvent, fidl::Error> {
14473        let (bytes, _handles) = buf.split_mut();
14474        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14475        debug_assert_eq!(tx_header.tx_id, 0);
14476        match tx_header.ordinal {
14477            _ => Err(fidl::Error::UnknownOrdinal {
14478                ordinal: tx_header.ordinal,
14479                protocol_name:
14480                    <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14481            }),
14482        }
14483    }
14484}
14485
14486/// A Stream of incoming requests for fuchsia.media/StreamSink.
14487pub struct StreamSinkRequestStream {
14488    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14489    is_terminated: bool,
14490}
14491
14492impl std::marker::Unpin for StreamSinkRequestStream {}
14493
14494impl futures::stream::FusedStream for StreamSinkRequestStream {
14495    fn is_terminated(&self) -> bool {
14496        self.is_terminated
14497    }
14498}
14499
14500impl fdomain_client::fidl::RequestStream for StreamSinkRequestStream {
14501    type Protocol = StreamSinkMarker;
14502    type ControlHandle = StreamSinkControlHandle;
14503
14504    fn from_channel(channel: fdomain_client::Channel) -> Self {
14505        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14506    }
14507
14508    fn control_handle(&self) -> Self::ControlHandle {
14509        StreamSinkControlHandle { inner: self.inner.clone() }
14510    }
14511
14512    fn into_inner(
14513        self,
14514    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
14515    {
14516        (self.inner, self.is_terminated)
14517    }
14518
14519    fn from_inner(
14520        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14521        is_terminated: bool,
14522    ) -> Self {
14523        Self { inner, is_terminated }
14524    }
14525}
14526
14527impl futures::Stream for StreamSinkRequestStream {
14528    type Item = Result<StreamSinkRequest, fidl::Error>;
14529
14530    fn poll_next(
14531        mut self: std::pin::Pin<&mut Self>,
14532        cx: &mut std::task::Context<'_>,
14533    ) -> std::task::Poll<Option<Self::Item>> {
14534        let this = &mut *self;
14535        if this.inner.check_shutdown(cx) {
14536            this.is_terminated = true;
14537            return std::task::Poll::Ready(None);
14538        }
14539        if this.is_terminated {
14540            panic!("polled StreamSinkRequestStream after completion");
14541        }
14542        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
14543            |bytes, handles| {
14544                match this.inner.channel().read_etc(cx, bytes, handles) {
14545                    std::task::Poll::Ready(Ok(())) => {}
14546                    std::task::Poll::Pending => return std::task::Poll::Pending,
14547                    std::task::Poll::Ready(Err(None)) => {
14548                        this.is_terminated = true;
14549                        return std::task::Poll::Ready(None);
14550                    }
14551                    std::task::Poll::Ready(Err(Some(e))) => {
14552                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14553                            e.into(),
14554                        ))));
14555                    }
14556                }
14557
14558                // A message has been received from the channel
14559                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14560
14561                std::task::Poll::Ready(Some(match header.ordinal {
14562                    0x67cddd607442775f => {
14563                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14564                        let mut req = fidl::new_empty!(
14565                            StreamSinkSendPacketRequest,
14566                            fdomain_client::fidl::FDomainResourceDialect
14567                        );
14568                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14569                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14570                        Ok(StreamSinkRequest::SendPacket {
14571                            packet: req.packet,
14572
14573                            responder: StreamSinkSendPacketResponder {
14574                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14575                                tx_id: header.tx_id,
14576                            },
14577                        })
14578                    }
14579                    0x8d9b8b413ceba9d => {
14580                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14581                        let mut req = fidl::new_empty!(
14582                            StreamSinkSendPacketNoReplyRequest,
14583                            fdomain_client::fidl::FDomainResourceDialect
14584                        );
14585                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
14586                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14587                        Ok(StreamSinkRequest::SendPacketNoReply {
14588                            packet: req.packet,
14589
14590                            control_handle,
14591                        })
14592                    }
14593                    0x6180fd6f7e793b71 => {
14594                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14595                        let mut req = fidl::new_empty!(
14596                            fidl::encoding::EmptyPayload,
14597                            fdomain_client::fidl::FDomainResourceDialect
14598                        );
14599                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14600                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14601                        Ok(StreamSinkRequest::EndOfStream { control_handle })
14602                    }
14603                    0x6f4dad7af2917665 => {
14604                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14605                        let mut req = fidl::new_empty!(
14606                            fidl::encoding::EmptyPayload,
14607                            fdomain_client::fidl::FDomainResourceDialect
14608                        );
14609                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14610                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14611                        Ok(StreamSinkRequest::DiscardAllPackets {
14612                            responder: StreamSinkDiscardAllPacketsResponder {
14613                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14614                                tx_id: header.tx_id,
14615                            },
14616                        })
14617                    }
14618                    0x50d36d0d23081bc4 => {
14619                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14620                        let mut req = fidl::new_empty!(
14621                            fidl::encoding::EmptyPayload,
14622                            fdomain_client::fidl::FDomainResourceDialect
14623                        );
14624                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14625                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14626                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
14627                    }
14628                    _ => Err(fidl::Error::UnknownOrdinal {
14629                        ordinal: header.ordinal,
14630                        protocol_name:
14631                            <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14632                    }),
14633                }))
14634            },
14635        )
14636    }
14637}
14638
14639/// Consumes a stream of packets. This interface is typically inherited along
14640/// with `StreamBufferSet` to enable the transport of elementary streams from
14641/// clients to services.
14642#[derive(Debug)]
14643pub enum StreamSinkRequest {
14644    /// Sends a packet to the service. The response is sent when the service is
14645    /// done with the associated payload memory.
14646    ///
14647    /// `packet` must be valid for the current buffer set, otherwise the service
14648    /// will close the connection.
14649    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
14650    /// Sends a packet to the service. This interface doesn't define how the
14651    /// client knows when the sink is done with the associated payload memory.
14652    /// The inheriting interface must define that.
14653    ///
14654    /// `packet` must be valid for the current buffer set, otherwise the service
14655    /// will close the connection.
14656    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
14657    /// Indicates the stream has ended. The precise semantics of this method are
14658    /// determined by the inheriting interface.
14659    EndOfStream { control_handle: StreamSinkControlHandle },
14660    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14661    /// and not yet released. The response is sent after all packets have been
14662    /// released.
14663    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
14664    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14665    /// and not yet released.
14666    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
14667}
14668
14669impl StreamSinkRequest {
14670    #[allow(irrefutable_let_patterns)]
14671    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
14672        if let StreamSinkRequest::SendPacket { packet, responder } = self {
14673            Some((packet, responder))
14674        } else {
14675            None
14676        }
14677    }
14678
14679    #[allow(irrefutable_let_patterns)]
14680    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
14681        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
14682            Some((packet, control_handle))
14683        } else {
14684            None
14685        }
14686    }
14687
14688    #[allow(irrefutable_let_patterns)]
14689    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
14690        if let StreamSinkRequest::EndOfStream { control_handle } = self {
14691            Some((control_handle))
14692        } else {
14693            None
14694        }
14695    }
14696
14697    #[allow(irrefutable_let_patterns)]
14698    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
14699        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
14700            Some((responder))
14701        } else {
14702            None
14703        }
14704    }
14705
14706    #[allow(irrefutable_let_patterns)]
14707    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
14708        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
14709            Some((control_handle))
14710        } else {
14711            None
14712        }
14713    }
14714
14715    /// Name of the method defined in FIDL
14716    pub fn method_name(&self) -> &'static str {
14717        match *self {
14718            StreamSinkRequest::SendPacket { .. } => "send_packet",
14719            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
14720            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
14721            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
14722            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
14723        }
14724    }
14725}
14726
14727#[derive(Debug, Clone)]
14728pub struct StreamSinkControlHandle {
14729    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14730}
14731
14732impl fdomain_client::fidl::ControlHandle for StreamSinkControlHandle {
14733    fn shutdown(&self) {
14734        self.inner.shutdown()
14735    }
14736
14737    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
14738        self.inner.shutdown_with_epitaph(status)
14739    }
14740
14741    fn is_closed(&self) -> bool {
14742        self.inner.channel().is_closed()
14743    }
14744    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14745        self.inner.channel().on_closed()
14746    }
14747}
14748
14749impl StreamSinkControlHandle {}
14750
14751#[must_use = "FIDL methods require a response to be sent"]
14752#[derive(Debug)]
14753pub struct StreamSinkSendPacketResponder {
14754    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
14755    tx_id: u32,
14756}
14757
14758/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
14759/// if the responder is dropped without sending a response, so that the client
14760/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14761impl std::ops::Drop for StreamSinkSendPacketResponder {
14762    fn drop(&mut self) {
14763        self.control_handle.shutdown();
14764        // Safety: drops once, never accessed again
14765        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14766    }
14767}
14768
14769impl fdomain_client::fidl::Responder for StreamSinkSendPacketResponder {
14770    type ControlHandle = StreamSinkControlHandle;
14771
14772    fn control_handle(&self) -> &StreamSinkControlHandle {
14773        &self.control_handle
14774    }
14775
14776    fn drop_without_shutdown(mut self) {
14777        // Safety: drops once, never accessed again due to mem::forget
14778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14779        // Prevent Drop from running (which would shut down the channel)
14780        std::mem::forget(self);
14781    }
14782}
14783
14784impl StreamSinkSendPacketResponder {
14785    /// Sends a response to the FIDL transaction.
14786    ///
14787    /// Sets the channel to shutdown if an error occurs.
14788    pub fn send(self) -> Result<(), fidl::Error> {
14789        let _result = self.send_raw();
14790        if _result.is_err() {
14791            self.control_handle.shutdown();
14792        }
14793        self.drop_without_shutdown();
14794        _result
14795    }
14796
14797    /// Similar to "send" but does not shutdown the channel if an error occurs.
14798    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14799        let _result = self.send_raw();
14800        self.drop_without_shutdown();
14801        _result
14802    }
14803
14804    fn send_raw(&self) -> Result<(), fidl::Error> {
14805        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14806            (),
14807            self.tx_id,
14808            0x67cddd607442775f,
14809            fidl::encoding::DynamicFlags::empty(),
14810        )
14811    }
14812}
14813
14814#[must_use = "FIDL methods require a response to be sent"]
14815#[derive(Debug)]
14816pub struct StreamSinkDiscardAllPacketsResponder {
14817    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
14818    tx_id: u32,
14819}
14820
14821/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
14822/// if the responder is dropped without sending a response, so that the client
14823/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14824impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
14825    fn drop(&mut self) {
14826        self.control_handle.shutdown();
14827        // Safety: drops once, never accessed again
14828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14829    }
14830}
14831
14832impl fdomain_client::fidl::Responder for StreamSinkDiscardAllPacketsResponder {
14833    type ControlHandle = StreamSinkControlHandle;
14834
14835    fn control_handle(&self) -> &StreamSinkControlHandle {
14836        &self.control_handle
14837    }
14838
14839    fn drop_without_shutdown(mut self) {
14840        // Safety: drops once, never accessed again due to mem::forget
14841        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14842        // Prevent Drop from running (which would shut down the channel)
14843        std::mem::forget(self);
14844    }
14845}
14846
14847impl StreamSinkDiscardAllPacketsResponder {
14848    /// Sends a response to the FIDL transaction.
14849    ///
14850    /// Sets the channel to shutdown if an error occurs.
14851    pub fn send(self) -> Result<(), fidl::Error> {
14852        let _result = self.send_raw();
14853        if _result.is_err() {
14854            self.control_handle.shutdown();
14855        }
14856        self.drop_without_shutdown();
14857        _result
14858    }
14859
14860    /// Similar to "send" but does not shutdown the channel if an error occurs.
14861    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14862        let _result = self.send_raw();
14863        self.drop_without_shutdown();
14864        _result
14865    }
14866
14867    fn send_raw(&self) -> Result<(), fidl::Error> {
14868        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14869            (),
14870            self.tx_id,
14871            0x6f4dad7af2917665,
14872            fidl::encoding::DynamicFlags::empty(),
14873        )
14874    }
14875}
14876
14877#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14878pub struct StreamSourceMarker;
14879
14880impl fdomain_client::fidl::ProtocolMarker for StreamSourceMarker {
14881    type Proxy = StreamSourceProxy;
14882    type RequestStream = StreamSourceRequestStream;
14883
14884    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
14885}
14886
14887pub trait StreamSourceProxyInterface: Send + Sync {
14888    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
14889    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14890    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
14891    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
14892}
14893
14894#[derive(Debug, Clone)]
14895pub struct StreamSourceProxy {
14896    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14897}
14898
14899impl fdomain_client::fidl::Proxy for StreamSourceProxy {
14900    type Protocol = StreamSourceMarker;
14901
14902    fn from_channel(inner: fdomain_client::Channel) -> Self {
14903        Self::new(inner)
14904    }
14905
14906    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14907        self.client.into_channel().map_err(|client| Self { client })
14908    }
14909
14910    fn as_channel(&self) -> &fdomain_client::Channel {
14911        self.client.as_channel()
14912    }
14913}
14914
14915impl StreamSourceProxy {
14916    /// Create a new Proxy for fuchsia.media/StreamSource.
14917    pub fn new(channel: fdomain_client::Channel) -> Self {
14918        let protocol_name =
14919            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14920        Self { client: fidl::client::Client::new(channel, protocol_name) }
14921    }
14922
14923    /// Get a Stream of events from the remote end of the protocol.
14924    ///
14925    /// # Panics
14926    ///
14927    /// Panics if the event stream was already taken.
14928    pub fn take_event_stream(&self) -> StreamSourceEventStream {
14929        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
14930    }
14931
14932    /// Releases payload memory associated with a packet previously delivered
14933    /// via `OnPacketProduced`.
14934    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14935        StreamSourceProxyInterface::r#release_packet(self, packet)
14936    }
14937
14938    pub fn r#discard_all_packets(
14939        &self,
14940    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14941        StreamSourceProxyInterface::r#discard_all_packets(self)
14942    }
14943
14944    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14945        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
14946    }
14947}
14948
14949impl StreamSourceProxyInterface for StreamSourceProxy {
14950    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14951        self.client.send::<StreamSourceReleasePacketRequest>(
14952            (packet,),
14953            0x7a7b57f0f7d9e4bb,
14954            fidl::encoding::DynamicFlags::empty(),
14955        )
14956    }
14957
14958    type DiscardAllPacketsResponseFut =
14959        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14960    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
14961        fn _decode(
14962            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14963        ) -> Result<(), fidl::Error> {
14964            let _response = fidl::client::decode_transaction_body::<
14965                fidl::encoding::EmptyPayload,
14966                fdomain_client::fidl::FDomainResourceDialect,
14967                0x27afd605e97b09d2,
14968            >(_buf?)?;
14969            Ok(_response)
14970        }
14971        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14972            (),
14973            0x27afd605e97b09d2,
14974            fidl::encoding::DynamicFlags::empty(),
14975            _decode,
14976        )
14977    }
14978
14979    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14980        self.client.send::<fidl::encoding::EmptyPayload>(
14981            (),
14982            0x35f9d721e905b831,
14983            fidl::encoding::DynamicFlags::empty(),
14984        )
14985    }
14986}
14987
14988pub struct StreamSourceEventStream {
14989    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
14990}
14991
14992impl std::marker::Unpin for StreamSourceEventStream {}
14993
14994impl futures::stream::FusedStream for StreamSourceEventStream {
14995    fn is_terminated(&self) -> bool {
14996        self.event_receiver.is_terminated()
14997    }
14998}
14999
15000impl futures::Stream for StreamSourceEventStream {
15001    type Item = Result<StreamSourceEvent, fidl::Error>;
15002
15003    fn poll_next(
15004        mut self: std::pin::Pin<&mut Self>,
15005        cx: &mut std::task::Context<'_>,
15006    ) -> std::task::Poll<Option<Self::Item>> {
15007        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15008            &mut self.event_receiver,
15009            cx
15010        )?) {
15011            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
15012            None => std::task::Poll::Ready(None),
15013        }
15014    }
15015}
15016
15017#[derive(Debug)]
15018pub enum StreamSourceEvent {
15019    OnPacketProduced { packet: StreamPacket },
15020    OnEndOfStream {},
15021}
15022
15023impl StreamSourceEvent {
15024    #[allow(irrefutable_let_patterns)]
15025    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
15026        if let StreamSourceEvent::OnPacketProduced { packet } = self {
15027            Some((packet))
15028        } else {
15029            None
15030        }
15031    }
15032    #[allow(irrefutable_let_patterns)]
15033    pub fn into_on_end_of_stream(self) -> Option<()> {
15034        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
15035    }
15036
15037    /// Decodes a message buffer as a [`StreamSourceEvent`].
15038    fn decode(
15039        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15040    ) -> Result<StreamSourceEvent, fidl::Error> {
15041        let (bytes, _handles) = buf.split_mut();
15042        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15043        debug_assert_eq!(tx_header.tx_id, 0);
15044        match tx_header.ordinal {
15045            0x6bbe69746a3c8bd9 => {
15046                let mut out = fidl::new_empty!(
15047                    StreamSourceOnPacketProducedRequest,
15048                    fdomain_client::fidl::FDomainResourceDialect
15049                );
15050                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
15051                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
15052            }
15053            0x550e69b41d03e2c2 => {
15054                let mut out = fidl::new_empty!(
15055                    fidl::encoding::EmptyPayload,
15056                    fdomain_client::fidl::FDomainResourceDialect
15057                );
15058                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
15059                Ok((StreamSourceEvent::OnEndOfStream {}))
15060            }
15061            _ => Err(fidl::Error::UnknownOrdinal {
15062                ordinal: tx_header.ordinal,
15063                protocol_name:
15064                    <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15065            }),
15066        }
15067    }
15068}
15069
15070/// A Stream of incoming requests for fuchsia.media/StreamSource.
15071pub struct StreamSourceRequestStream {
15072    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15073    is_terminated: bool,
15074}
15075
15076impl std::marker::Unpin for StreamSourceRequestStream {}
15077
15078impl futures::stream::FusedStream for StreamSourceRequestStream {
15079    fn is_terminated(&self) -> bool {
15080        self.is_terminated
15081    }
15082}
15083
15084impl fdomain_client::fidl::RequestStream for StreamSourceRequestStream {
15085    type Protocol = StreamSourceMarker;
15086    type ControlHandle = StreamSourceControlHandle;
15087
15088    fn from_channel(channel: fdomain_client::Channel) -> Self {
15089        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15090    }
15091
15092    fn control_handle(&self) -> Self::ControlHandle {
15093        StreamSourceControlHandle { inner: self.inner.clone() }
15094    }
15095
15096    fn into_inner(
15097        self,
15098    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15099    {
15100        (self.inner, self.is_terminated)
15101    }
15102
15103    fn from_inner(
15104        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15105        is_terminated: bool,
15106    ) -> Self {
15107        Self { inner, is_terminated }
15108    }
15109}
15110
15111impl futures::Stream for StreamSourceRequestStream {
15112    type Item = Result<StreamSourceRequest, fidl::Error>;
15113
15114    fn poll_next(
15115        mut self: std::pin::Pin<&mut Self>,
15116        cx: &mut std::task::Context<'_>,
15117    ) -> std::task::Poll<Option<Self::Item>> {
15118        let this = &mut *self;
15119        if this.inner.check_shutdown(cx) {
15120            this.is_terminated = true;
15121            return std::task::Poll::Ready(None);
15122        }
15123        if this.is_terminated {
15124            panic!("polled StreamSourceRequestStream after completion");
15125        }
15126        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15127            |bytes, handles| {
15128                match this.inner.channel().read_etc(cx, bytes, handles) {
15129                    std::task::Poll::Ready(Ok(())) => {}
15130                    std::task::Poll::Pending => return std::task::Poll::Pending,
15131                    std::task::Poll::Ready(Err(None)) => {
15132                        this.is_terminated = true;
15133                        return std::task::Poll::Ready(None);
15134                    }
15135                    std::task::Poll::Ready(Err(Some(e))) => {
15136                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15137                            e.into(),
15138                        ))));
15139                    }
15140                }
15141
15142                // A message has been received from the channel
15143                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15144
15145                std::task::Poll::Ready(Some(match header.ordinal {
15146                    0x7a7b57f0f7d9e4bb => {
15147                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15148                        let mut req = fidl::new_empty!(
15149                            StreamSourceReleasePacketRequest,
15150                            fdomain_client::fidl::FDomainResourceDialect
15151                        );
15152                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
15153                        let control_handle =
15154                            StreamSourceControlHandle { inner: this.inner.clone() };
15155                        Ok(StreamSourceRequest::ReleasePacket {
15156                            packet: req.packet,
15157
15158                            control_handle,
15159                        })
15160                    }
15161                    0x27afd605e97b09d2 => {
15162                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
15163                        let mut req = fidl::new_empty!(
15164                            fidl::encoding::EmptyPayload,
15165                            fdomain_client::fidl::FDomainResourceDialect
15166                        );
15167                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
15168                        let control_handle =
15169                            StreamSourceControlHandle { inner: this.inner.clone() };
15170                        Ok(StreamSourceRequest::DiscardAllPackets {
15171                            responder: StreamSourceDiscardAllPacketsResponder {
15172                                control_handle: std::mem::ManuallyDrop::new(control_handle),
15173                                tx_id: header.tx_id,
15174                            },
15175                        })
15176                    }
15177                    0x35f9d721e905b831 => {
15178                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15179                        let mut req = fidl::new_empty!(
15180                            fidl::encoding::EmptyPayload,
15181                            fdomain_client::fidl::FDomainResourceDialect
15182                        );
15183                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
15184                        let control_handle =
15185                            StreamSourceControlHandle { inner: this.inner.clone() };
15186                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
15187                    }
15188                    _ => Err(fidl::Error::UnknownOrdinal {
15189                        ordinal: header.ordinal,
15190                        protocol_name:
15191                            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15192                    }),
15193                }))
15194            },
15195        )
15196    }
15197}
15198
15199/// Produces a stream of packets. This interface is typically inherited along
15200/// with `StreamBufferSet` to enable the transport of elementary streams from
15201/// services to clients.
15202#[derive(Debug)]
15203pub enum StreamSourceRequest {
15204    /// Releases payload memory associated with a packet previously delivered
15205    /// via `OnPacketProduced`.
15206    ReleasePacket {
15207        packet: StreamPacket,
15208        control_handle: StreamSourceControlHandle,
15209    },
15210    DiscardAllPackets {
15211        responder: StreamSourceDiscardAllPacketsResponder,
15212    },
15213    DiscardAllPacketsNoReply {
15214        control_handle: StreamSourceControlHandle,
15215    },
15216}
15217
15218impl StreamSourceRequest {
15219    #[allow(irrefutable_let_patterns)]
15220    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
15221        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
15222            Some((packet, control_handle))
15223        } else {
15224            None
15225        }
15226    }
15227
15228    #[allow(irrefutable_let_patterns)]
15229    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
15230        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
15231            Some((responder))
15232        } else {
15233            None
15234        }
15235    }
15236
15237    #[allow(irrefutable_let_patterns)]
15238    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
15239        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
15240            Some((control_handle))
15241        } else {
15242            None
15243        }
15244    }
15245
15246    /// Name of the method defined in FIDL
15247    pub fn method_name(&self) -> &'static str {
15248        match *self {
15249            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
15250            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
15251            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
15252        }
15253    }
15254}
15255
15256#[derive(Debug, Clone)]
15257pub struct StreamSourceControlHandle {
15258    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15259}
15260
15261impl fdomain_client::fidl::ControlHandle for StreamSourceControlHandle {
15262    fn shutdown(&self) {
15263        self.inner.shutdown()
15264    }
15265
15266    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15267        self.inner.shutdown_with_epitaph(status)
15268    }
15269
15270    fn is_closed(&self) -> bool {
15271        self.inner.channel().is_closed()
15272    }
15273    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15274        self.inner.channel().on_closed()
15275    }
15276}
15277
15278impl StreamSourceControlHandle {
15279    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15280        self.inner.send::<StreamSourceOnPacketProducedRequest>(
15281            (packet,),
15282            0,
15283            0x6bbe69746a3c8bd9,
15284            fidl::encoding::DynamicFlags::empty(),
15285        )
15286    }
15287
15288    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
15289        self.inner.send::<fidl::encoding::EmptyPayload>(
15290            (),
15291            0,
15292            0x550e69b41d03e2c2,
15293            fidl::encoding::DynamicFlags::empty(),
15294        )
15295    }
15296}
15297
15298#[must_use = "FIDL methods require a response to be sent"]
15299#[derive(Debug)]
15300pub struct StreamSourceDiscardAllPacketsResponder {
15301    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
15302    tx_id: u32,
15303}
15304
15305/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
15306/// if the responder is dropped without sending a response, so that the client
15307/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15308impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
15309    fn drop(&mut self) {
15310        self.control_handle.shutdown();
15311        // Safety: drops once, never accessed again
15312        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15313    }
15314}
15315
15316impl fdomain_client::fidl::Responder for StreamSourceDiscardAllPacketsResponder {
15317    type ControlHandle = StreamSourceControlHandle;
15318
15319    fn control_handle(&self) -> &StreamSourceControlHandle {
15320        &self.control_handle
15321    }
15322
15323    fn drop_without_shutdown(mut self) {
15324        // Safety: drops once, never accessed again due to mem::forget
15325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15326        // Prevent Drop from running (which would shut down the channel)
15327        std::mem::forget(self);
15328    }
15329}
15330
15331impl StreamSourceDiscardAllPacketsResponder {
15332    /// Sends a response to the FIDL transaction.
15333    ///
15334    /// Sets the channel to shutdown if an error occurs.
15335    pub fn send(self) -> Result<(), fidl::Error> {
15336        let _result = self.send_raw();
15337        if _result.is_err() {
15338            self.control_handle.shutdown();
15339        }
15340        self.drop_without_shutdown();
15341        _result
15342    }
15343
15344    /// Similar to "send" but does not shutdown the channel if an error occurs.
15345    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15346        let _result = self.send_raw();
15347        self.drop_without_shutdown();
15348        _result
15349    }
15350
15351    fn send_raw(&self) -> Result<(), fidl::Error> {
15352        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15353            (),
15354            self.tx_id,
15355            0x27afd605e97b09d2,
15356            fidl::encoding::DynamicFlags::empty(),
15357        )
15358    }
15359}
15360
15361#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15362pub struct Usage2AudioConsumerFactoryMarker;
15363
15364impl fdomain_client::fidl::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
15365    type Proxy = Usage2AudioConsumerFactoryProxy;
15366    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
15367
15368    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
15369}
15370impl fdomain_client::fidl::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
15371
15372pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
15373    fn r#create_audio_consumer(
15374        &self,
15375        usage: AudioRenderUsage2,
15376        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15377    ) -> Result<(), fidl::Error>;
15378}
15379
15380#[derive(Debug, Clone)]
15381pub struct Usage2AudioConsumerFactoryProxy {
15382    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15383}
15384
15385impl fdomain_client::fidl::Proxy for Usage2AudioConsumerFactoryProxy {
15386    type Protocol = Usage2AudioConsumerFactoryMarker;
15387
15388    fn from_channel(inner: fdomain_client::Channel) -> Self {
15389        Self::new(inner)
15390    }
15391
15392    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15393        self.client.into_channel().map_err(|client| Self { client })
15394    }
15395
15396    fn as_channel(&self) -> &fdomain_client::Channel {
15397        self.client.as_channel()
15398    }
15399}
15400
15401impl Usage2AudioConsumerFactoryProxy {
15402    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
15403    pub fn new(channel: fdomain_client::Channel) -> Self {
15404        let protocol_name =
15405            <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15406        Self { client: fidl::client::Client::new(channel, protocol_name) }
15407    }
15408
15409    /// Get a Stream of events from the remote end of the protocol.
15410    ///
15411    /// # Panics
15412    ///
15413    /// Panics if the event stream was already taken.
15414    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
15415        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
15416    }
15417
15418    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
15419    /// Audio submitted to such a consumer is always rendered locally.
15420    pub fn r#create_audio_consumer(
15421        &self,
15422        mut usage: AudioRenderUsage2,
15423        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15424    ) -> Result<(), fidl::Error> {
15425        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
15426            self,
15427            usage,
15428            audio_consumer_request,
15429        )
15430    }
15431}
15432
15433impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
15434    fn r#create_audio_consumer(
15435        &self,
15436        mut usage: AudioRenderUsage2,
15437        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15438    ) -> Result<(), fidl::Error> {
15439        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
15440            (usage, audio_consumer_request),
15441            0x767722302a171873,
15442            fidl::encoding::DynamicFlags::FLEXIBLE,
15443        )
15444    }
15445}
15446
15447pub struct Usage2AudioConsumerFactoryEventStream {
15448    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15449}
15450
15451impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
15452
15453impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
15454    fn is_terminated(&self) -> bool {
15455        self.event_receiver.is_terminated()
15456    }
15457}
15458
15459impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
15460    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
15461
15462    fn poll_next(
15463        mut self: std::pin::Pin<&mut Self>,
15464        cx: &mut std::task::Context<'_>,
15465    ) -> std::task::Poll<Option<Self::Item>> {
15466        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15467            &mut self.event_receiver,
15468            cx
15469        )?) {
15470            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
15471            None => std::task::Poll::Ready(None),
15472        }
15473    }
15474}
15475
15476#[derive(Debug)]
15477pub enum Usage2AudioConsumerFactoryEvent {
15478    #[non_exhaustive]
15479    _UnknownEvent {
15480        /// Ordinal of the event that was sent.
15481        ordinal: u64,
15482    },
15483}
15484
15485impl Usage2AudioConsumerFactoryEvent {
15486    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
15487    fn decode(
15488        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15489    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
15490        let (bytes, _handles) = buf.split_mut();
15491        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15492        debug_assert_eq!(tx_header.tx_id, 0);
15493        match tx_header.ordinal {
15494            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15495                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
15496                    ordinal: tx_header.ordinal,
15497                })
15498            }
15499            _ => Err(fidl::Error::UnknownOrdinal {
15500                ordinal: tx_header.ordinal,
15501                protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15502            })
15503        }
15504    }
15505}
15506
15507/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
15508pub struct Usage2AudioConsumerFactoryRequestStream {
15509    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15510    is_terminated: bool,
15511}
15512
15513impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
15514
15515impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
15516    fn is_terminated(&self) -> bool {
15517        self.is_terminated
15518    }
15519}
15520
15521impl fdomain_client::fidl::RequestStream for Usage2AudioConsumerFactoryRequestStream {
15522    type Protocol = Usage2AudioConsumerFactoryMarker;
15523    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
15524
15525    fn from_channel(channel: fdomain_client::Channel) -> Self {
15526        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15527    }
15528
15529    fn control_handle(&self) -> Self::ControlHandle {
15530        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
15531    }
15532
15533    fn into_inner(
15534        self,
15535    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15536    {
15537        (self.inner, self.is_terminated)
15538    }
15539
15540    fn from_inner(
15541        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15542        is_terminated: bool,
15543    ) -> Self {
15544        Self { inner, is_terminated }
15545    }
15546}
15547
15548impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
15549    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
15550
15551    fn poll_next(
15552        mut self: std::pin::Pin<&mut Self>,
15553        cx: &mut std::task::Context<'_>,
15554    ) -> std::task::Poll<Option<Self::Item>> {
15555        let this = &mut *self;
15556        if this.inner.check_shutdown(cx) {
15557            this.is_terminated = true;
15558            return std::task::Poll::Ready(None);
15559        }
15560        if this.is_terminated {
15561            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
15562        }
15563        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15564            |bytes, handles| {
15565                match this.inner.channel().read_etc(cx, bytes, handles) {
15566                    std::task::Poll::Ready(Ok(())) => {}
15567                    std::task::Poll::Pending => return std::task::Poll::Pending,
15568                    std::task::Poll::Ready(Err(None)) => {
15569                        this.is_terminated = true;
15570                        return std::task::Poll::Ready(None);
15571                    }
15572                    std::task::Poll::Ready(Err(Some(e))) => {
15573                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15574                            e.into(),
15575                        ))));
15576                    }
15577                }
15578
15579                // A message has been received from the channel
15580                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15581
15582                std::task::Poll::Ready(Some(match header.ordinal {
15583                0x767722302a171873 => {
15584                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15585                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
15586                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
15587                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
15588                        inner: this.inner.clone(),
15589                    };
15590                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
15591audio_consumer_request: req.audio_consumer_request,
15592
15593                        control_handle,
15594                    })
15595                }
15596                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15597                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15598                        ordinal: header.ordinal,
15599                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
15600                        method_type: fidl::MethodType::OneWay,
15601                    })
15602                }
15603                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15604                    this.inner.send_framework_err(
15605                        fidl::encoding::FrameworkErr::UnknownMethod,
15606                        header.tx_id,
15607                        header.ordinal,
15608                        header.dynamic_flags(),
15609                        (bytes, handles),
15610                    )?;
15611                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15612                        ordinal: header.ordinal,
15613                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
15614                        method_type: fidl::MethodType::TwoWay,
15615                    })
15616                }
15617                _ => Err(fidl::Error::UnknownOrdinal {
15618                    ordinal: header.ordinal,
15619                    protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15620                }),
15621            }))
15622            },
15623        )
15624    }
15625}
15626
15627/// Interface for creating audio consumers for local rendering.
15628#[derive(Debug)]
15629pub enum Usage2AudioConsumerFactoryRequest {
15630    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
15631    /// Audio submitted to such a consumer is always rendered locally.
15632    CreateAudioConsumer {
15633        usage: AudioRenderUsage2,
15634        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15635        control_handle: Usage2AudioConsumerFactoryControlHandle,
15636    },
15637    /// An interaction was received which does not match any known method.
15638    #[non_exhaustive]
15639    _UnknownMethod {
15640        /// Ordinal of the method that was called.
15641        ordinal: u64,
15642        control_handle: Usage2AudioConsumerFactoryControlHandle,
15643        method_type: fidl::MethodType,
15644    },
15645}
15646
15647impl Usage2AudioConsumerFactoryRequest {
15648    #[allow(irrefutable_let_patterns)]
15649    pub fn into_create_audio_consumer(
15650        self,
15651    ) -> Option<(
15652        AudioRenderUsage2,
15653        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15654        Usage2AudioConsumerFactoryControlHandle,
15655    )> {
15656        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
15657            usage,
15658            audio_consumer_request,
15659            control_handle,
15660        } = self
15661        {
15662            Some((usage, audio_consumer_request, control_handle))
15663        } else {
15664            None
15665        }
15666    }
15667
15668    /// Name of the method defined in FIDL
15669    pub fn method_name(&self) -> &'static str {
15670        match *self {
15671            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
15672                "create_audio_consumer"
15673            }
15674            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15675                method_type: fidl::MethodType::OneWay,
15676                ..
15677            } => "unknown one-way method",
15678            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15679                method_type: fidl::MethodType::TwoWay,
15680                ..
15681            } => "unknown two-way method",
15682        }
15683    }
15684}
15685
15686#[derive(Debug, Clone)]
15687pub struct Usage2AudioConsumerFactoryControlHandle {
15688    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15689}
15690
15691impl fdomain_client::fidl::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
15692    fn shutdown(&self) {
15693        self.inner.shutdown()
15694    }
15695
15696    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15697        self.inner.shutdown_with_epitaph(status)
15698    }
15699
15700    fn is_closed(&self) -> bool {
15701        self.inner.channel().is_closed()
15702    }
15703    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15704        self.inner.channel().on_closed()
15705    }
15706}
15707
15708impl Usage2AudioConsumerFactoryControlHandle {}
15709
15710#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15711pub struct UsageAudioConsumerFactoryMarker;
15712
15713impl fdomain_client::fidl::ProtocolMarker for UsageAudioConsumerFactoryMarker {
15714    type Proxy = UsageAudioConsumerFactoryProxy;
15715    type RequestStream = UsageAudioConsumerFactoryRequestStream;
15716
15717    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
15718}
15719impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
15720
15721pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
15722    fn r#create_audio_consumer(
15723        &self,
15724        usage: AudioRenderUsage,
15725        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15726    ) -> Result<(), fidl::Error>;
15727}
15728
15729#[derive(Debug, Clone)]
15730pub struct UsageAudioConsumerFactoryProxy {
15731    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15732}
15733
15734impl fdomain_client::fidl::Proxy for UsageAudioConsumerFactoryProxy {
15735    type Protocol = UsageAudioConsumerFactoryMarker;
15736
15737    fn from_channel(inner: fdomain_client::Channel) -> Self {
15738        Self::new(inner)
15739    }
15740
15741    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15742        self.client.into_channel().map_err(|client| Self { client })
15743    }
15744
15745    fn as_channel(&self) -> &fdomain_client::Channel {
15746        self.client.as_channel()
15747    }
15748}
15749
15750impl UsageAudioConsumerFactoryProxy {
15751    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
15752    pub fn new(channel: fdomain_client::Channel) -> Self {
15753        let protocol_name =
15754            <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15755        Self { client: fidl::client::Client::new(channel, protocol_name) }
15756    }
15757
15758    /// Get a Stream of events from the remote end of the protocol.
15759    ///
15760    /// # Panics
15761    ///
15762    /// Panics if the event stream was already taken.
15763    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
15764        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
15765    }
15766
15767    pub fn r#create_audio_consumer(
15768        &self,
15769        mut usage: AudioRenderUsage,
15770        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15771    ) -> Result<(), fidl::Error> {
15772        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
15773            self,
15774            usage,
15775            audio_consumer_request,
15776        )
15777    }
15778}
15779
15780impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
15781    fn r#create_audio_consumer(
15782        &self,
15783        mut usage: AudioRenderUsage,
15784        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15785    ) -> Result<(), fidl::Error> {
15786        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
15787            (usage, audio_consumer_request),
15788            0x4d975ca9b8f625a3,
15789            fidl::encoding::DynamicFlags::empty(),
15790        )
15791    }
15792}
15793
15794pub struct UsageAudioConsumerFactoryEventStream {
15795    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15796}
15797
15798impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
15799
15800impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
15801    fn is_terminated(&self) -> bool {
15802        self.event_receiver.is_terminated()
15803    }
15804}
15805
15806impl futures::Stream for UsageAudioConsumerFactoryEventStream {
15807    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
15808
15809    fn poll_next(
15810        mut self: std::pin::Pin<&mut Self>,
15811        cx: &mut std::task::Context<'_>,
15812    ) -> std::task::Poll<Option<Self::Item>> {
15813        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15814            &mut self.event_receiver,
15815            cx
15816        )?) {
15817            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
15818            None => std::task::Poll::Ready(None),
15819        }
15820    }
15821}
15822
15823#[derive(Debug)]
15824pub enum UsageAudioConsumerFactoryEvent {}
15825
15826impl UsageAudioConsumerFactoryEvent {
15827    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
15828    fn decode(
15829        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15830    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
15831        let (bytes, _handles) = buf.split_mut();
15832        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15833        debug_assert_eq!(tx_header.tx_id, 0);
15834        match tx_header.ordinal {
15835            _ => Err(fidl::Error::UnknownOrdinal {
15836                ordinal: tx_header.ordinal,
15837                protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15838            })
15839        }
15840    }
15841}
15842
15843/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
15844pub struct UsageAudioConsumerFactoryRequestStream {
15845    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15846    is_terminated: bool,
15847}
15848
15849impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
15850
15851impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
15852    fn is_terminated(&self) -> bool {
15853        self.is_terminated
15854    }
15855}
15856
15857impl fdomain_client::fidl::RequestStream for UsageAudioConsumerFactoryRequestStream {
15858    type Protocol = UsageAudioConsumerFactoryMarker;
15859    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
15860
15861    fn from_channel(channel: fdomain_client::Channel) -> Self {
15862        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15863    }
15864
15865    fn control_handle(&self) -> Self::ControlHandle {
15866        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
15867    }
15868
15869    fn into_inner(
15870        self,
15871    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15872    {
15873        (self.inner, self.is_terminated)
15874    }
15875
15876    fn from_inner(
15877        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15878        is_terminated: bool,
15879    ) -> Self {
15880        Self { inner, is_terminated }
15881    }
15882}
15883
15884impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
15885    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
15886
15887    fn poll_next(
15888        mut self: std::pin::Pin<&mut Self>,
15889        cx: &mut std::task::Context<'_>,
15890    ) -> std::task::Poll<Option<Self::Item>> {
15891        let this = &mut *self;
15892        if this.inner.check_shutdown(cx) {
15893            this.is_terminated = true;
15894            return std::task::Poll::Ready(None);
15895        }
15896        if this.is_terminated {
15897            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
15898        }
15899        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15900            |bytes, handles| {
15901                match this.inner.channel().read_etc(cx, bytes, handles) {
15902                    std::task::Poll::Ready(Ok(())) => {}
15903                    std::task::Poll::Pending => return std::task::Poll::Pending,
15904                    std::task::Poll::Ready(Err(None)) => {
15905                        this.is_terminated = true;
15906                        return std::task::Poll::Ready(None);
15907                    }
15908                    std::task::Poll::Ready(Err(Some(e))) => {
15909                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15910                            e.into(),
15911                        ))));
15912                    }
15913                }
15914
15915                // A message has been received from the channel
15916                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15917
15918                std::task::Poll::Ready(Some(match header.ordinal {
15919                0x4d975ca9b8f625a3 => {
15920                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15921                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
15922                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
15923                    let control_handle = UsageAudioConsumerFactoryControlHandle {
15924                        inner: this.inner.clone(),
15925                    };
15926                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
15927audio_consumer_request: req.audio_consumer_request,
15928
15929                        control_handle,
15930                    })
15931                }
15932                _ => Err(fidl::Error::UnknownOrdinal {
15933                    ordinal: header.ordinal,
15934                    protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15935                }),
15936            }))
15937            },
15938        )
15939    }
15940}
15941
15942/// Interface for creating audio consumers for local rendering.
15943#[derive(Debug)]
15944pub enum UsageAudioConsumerFactoryRequest {
15945    CreateAudioConsumer {
15946        usage: AudioRenderUsage,
15947        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15948        control_handle: UsageAudioConsumerFactoryControlHandle,
15949    },
15950}
15951
15952impl UsageAudioConsumerFactoryRequest {
15953    #[allow(irrefutable_let_patterns)]
15954    pub fn into_create_audio_consumer(
15955        self,
15956    ) -> Option<(
15957        AudioRenderUsage,
15958        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15959        UsageAudioConsumerFactoryControlHandle,
15960    )> {
15961        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
15962            usage,
15963            audio_consumer_request,
15964            control_handle,
15965        } = self
15966        {
15967            Some((usage, audio_consumer_request, control_handle))
15968        } else {
15969            None
15970        }
15971    }
15972
15973    /// Name of the method defined in FIDL
15974    pub fn method_name(&self) -> &'static str {
15975        match *self {
15976            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
15977        }
15978    }
15979}
15980
15981#[derive(Debug, Clone)]
15982pub struct UsageAudioConsumerFactoryControlHandle {
15983    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15984}
15985
15986impl fdomain_client::fidl::ControlHandle for UsageAudioConsumerFactoryControlHandle {
15987    fn shutdown(&self) {
15988        self.inner.shutdown()
15989    }
15990
15991    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15992        self.inner.shutdown_with_epitaph(status)
15993    }
15994
15995    fn is_closed(&self) -> bool {
15996        self.inner.channel().is_closed()
15997    }
15998    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15999        self.inner.channel().on_closed()
16000    }
16001}
16002
16003impl UsageAudioConsumerFactoryControlHandle {}
16004
16005#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16006pub struct UsageGainListenerMarker;
16007
16008impl fdomain_client::fidl::ProtocolMarker for UsageGainListenerMarker {
16009    type Proxy = UsageGainListenerProxy;
16010    type RequestStream = UsageGainListenerRequestStream;
16011
16012    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
16013}
16014
16015pub trait UsageGainListenerProxyInterface: Send + Sync {
16016    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16017    fn r#on_gain_mute_changed(
16018        &self,
16019        muted: bool,
16020        gain_dbfs: f32,
16021    ) -> Self::OnGainMuteChangedResponseFut;
16022}
16023
16024#[derive(Debug, Clone)]
16025pub struct UsageGainListenerProxy {
16026    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16027}
16028
16029impl fdomain_client::fidl::Proxy for UsageGainListenerProxy {
16030    type Protocol = UsageGainListenerMarker;
16031
16032    fn from_channel(inner: fdomain_client::Channel) -> Self {
16033        Self::new(inner)
16034    }
16035
16036    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16037        self.client.into_channel().map_err(|client| Self { client })
16038    }
16039
16040    fn as_channel(&self) -> &fdomain_client::Channel {
16041        self.client.as_channel()
16042    }
16043}
16044
16045impl UsageGainListenerProxy {
16046    /// Create a new Proxy for fuchsia.media/UsageGainListener.
16047    pub fn new(channel: fdomain_client::Channel) -> Self {
16048        let protocol_name =
16049            <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16050        Self { client: fidl::client::Client::new(channel, protocol_name) }
16051    }
16052
16053    /// Get a Stream of events from the remote end of the protocol.
16054    ///
16055    /// # Panics
16056    ///
16057    /// Panics if the event stream was already taken.
16058    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
16059        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
16060    }
16061
16062    /// Called immediately on connection and afterward any time
16063    /// the usage gain setting changes.
16064    ///
16065    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16066    /// events will eventually be disconnected.
16067    ///
16068    /// Note: This API does not have mute reporting implemented; `muted` is always false.
16069    pub fn r#on_gain_mute_changed(
16070        &self,
16071        mut muted: bool,
16072        mut gain_dbfs: f32,
16073    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
16074        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
16075    }
16076}
16077
16078impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
16079    type OnGainMuteChangedResponseFut =
16080        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
16081    fn r#on_gain_mute_changed(
16082        &self,
16083        mut muted: bool,
16084        mut gain_dbfs: f32,
16085    ) -> Self::OnGainMuteChangedResponseFut {
16086        fn _decode(
16087            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16088        ) -> Result<(), fidl::Error> {
16089            let _response = fidl::client::decode_transaction_body::<
16090                fidl::encoding::EmptyPayload,
16091                fdomain_client::fidl::FDomainResourceDialect,
16092                0x681570258eac3a8d,
16093            >(_buf?)?;
16094            Ok(_response)
16095        }
16096        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
16097            (muted, gain_dbfs),
16098            0x681570258eac3a8d,
16099            fidl::encoding::DynamicFlags::empty(),
16100            _decode,
16101        )
16102    }
16103}
16104
16105pub struct UsageGainListenerEventStream {
16106    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16107}
16108
16109impl std::marker::Unpin for UsageGainListenerEventStream {}
16110
16111impl futures::stream::FusedStream for UsageGainListenerEventStream {
16112    fn is_terminated(&self) -> bool {
16113        self.event_receiver.is_terminated()
16114    }
16115}
16116
16117impl futures::Stream for UsageGainListenerEventStream {
16118    type Item = Result<UsageGainListenerEvent, fidl::Error>;
16119
16120    fn poll_next(
16121        mut self: std::pin::Pin<&mut Self>,
16122        cx: &mut std::task::Context<'_>,
16123    ) -> std::task::Poll<Option<Self::Item>> {
16124        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16125            &mut self.event_receiver,
16126            cx
16127        )?) {
16128            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
16129            None => std::task::Poll::Ready(None),
16130        }
16131    }
16132}
16133
16134#[derive(Debug)]
16135pub enum UsageGainListenerEvent {}
16136
16137impl UsageGainListenerEvent {
16138    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
16139    fn decode(
16140        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16141    ) -> Result<UsageGainListenerEvent, fidl::Error> {
16142        let (bytes, _handles) = buf.split_mut();
16143        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16144        debug_assert_eq!(tx_header.tx_id, 0);
16145        match tx_header.ordinal {
16146            _ => Err(fidl::Error::UnknownOrdinal {
16147                ordinal: tx_header.ordinal,
16148                protocol_name:
16149                    <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16150            }),
16151        }
16152    }
16153}
16154
16155/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
16156pub struct UsageGainListenerRequestStream {
16157    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16158    is_terminated: bool,
16159}
16160
16161impl std::marker::Unpin for UsageGainListenerRequestStream {}
16162
16163impl futures::stream::FusedStream for UsageGainListenerRequestStream {
16164    fn is_terminated(&self) -> bool {
16165        self.is_terminated
16166    }
16167}
16168
16169impl fdomain_client::fidl::RequestStream for UsageGainListenerRequestStream {
16170    type Protocol = UsageGainListenerMarker;
16171    type ControlHandle = UsageGainListenerControlHandle;
16172
16173    fn from_channel(channel: fdomain_client::Channel) -> Self {
16174        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16175    }
16176
16177    fn control_handle(&self) -> Self::ControlHandle {
16178        UsageGainListenerControlHandle { inner: self.inner.clone() }
16179    }
16180
16181    fn into_inner(
16182        self,
16183    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
16184    {
16185        (self.inner, self.is_terminated)
16186    }
16187
16188    fn from_inner(
16189        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16190        is_terminated: bool,
16191    ) -> Self {
16192        Self { inner, is_terminated }
16193    }
16194}
16195
16196impl futures::Stream for UsageGainListenerRequestStream {
16197    type Item = Result<UsageGainListenerRequest, fidl::Error>;
16198
16199    fn poll_next(
16200        mut self: std::pin::Pin<&mut Self>,
16201        cx: &mut std::task::Context<'_>,
16202    ) -> std::task::Poll<Option<Self::Item>> {
16203        let this = &mut *self;
16204        if this.inner.check_shutdown(cx) {
16205            this.is_terminated = true;
16206            return std::task::Poll::Ready(None);
16207        }
16208        if this.is_terminated {
16209            panic!("polled UsageGainListenerRequestStream after completion");
16210        }
16211        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
16212            |bytes, handles| {
16213                match this.inner.channel().read_etc(cx, bytes, handles) {
16214                    std::task::Poll::Ready(Ok(())) => {}
16215                    std::task::Poll::Pending => return std::task::Poll::Pending,
16216                    std::task::Poll::Ready(Err(None)) => {
16217                        this.is_terminated = true;
16218                        return std::task::Poll::Ready(None);
16219                    }
16220                    std::task::Poll::Ready(Err(Some(e))) => {
16221                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16222                            e.into(),
16223                        ))));
16224                    }
16225                }
16226
16227                // A message has been received from the channel
16228                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16229
16230                std::task::Poll::Ready(Some(match header.ordinal {
16231                0x681570258eac3a8d => {
16232                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16233                    let mut req = fidl::new_empty!(UsageGainListenerOnGainMuteChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
16234                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
16235                    let control_handle = UsageGainListenerControlHandle {
16236                        inner: this.inner.clone(),
16237                    };
16238                    Ok(UsageGainListenerRequest::OnGainMuteChanged {muted: req.muted,
16239gain_dbfs: req.gain_dbfs,
16240
16241                        responder: UsageGainListenerOnGainMuteChangedResponder {
16242                            control_handle: std::mem::ManuallyDrop::new(control_handle),
16243                            tx_id: header.tx_id,
16244                        },
16245                    })
16246                }
16247                _ => Err(fidl::Error::UnknownOrdinal {
16248                    ordinal: header.ordinal,
16249                    protocol_name: <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16250                }),
16251            }))
16252            },
16253        )
16254    }
16255}
16256
16257/// A protocol for watching changes to usage gain settings.
16258///
16259/// The channel will close when the device is not present.
16260#[derive(Debug)]
16261pub enum UsageGainListenerRequest {
16262    /// Called immediately on connection and afterward any time
16263    /// the usage gain setting changes.
16264    ///
16265    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16266    /// events will eventually be disconnected.
16267    ///
16268    /// Note: This API does not have mute reporting implemented; `muted` is always false.
16269    OnGainMuteChanged {
16270        muted: bool,
16271        gain_dbfs: f32,
16272        responder: UsageGainListenerOnGainMuteChangedResponder,
16273    },
16274}
16275
16276impl UsageGainListenerRequest {
16277    #[allow(irrefutable_let_patterns)]
16278    pub fn into_on_gain_mute_changed(
16279        self,
16280    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
16281        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
16282            Some((muted, gain_dbfs, responder))
16283        } else {
16284            None
16285        }
16286    }
16287
16288    /// Name of the method defined in FIDL
16289    pub fn method_name(&self) -> &'static str {
16290        match *self {
16291            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
16292        }
16293    }
16294}
16295
16296#[derive(Debug, Clone)]
16297pub struct UsageGainListenerControlHandle {
16298    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16299}
16300
16301impl fdomain_client::fidl::ControlHandle for UsageGainListenerControlHandle {
16302    fn shutdown(&self) {
16303        self.inner.shutdown()
16304    }
16305
16306    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16307        self.inner.shutdown_with_epitaph(status)
16308    }
16309
16310    fn is_closed(&self) -> bool {
16311        self.inner.channel().is_closed()
16312    }
16313    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16314        self.inner.channel().on_closed()
16315    }
16316}
16317
16318impl UsageGainListenerControlHandle {}
16319
16320#[must_use = "FIDL methods require a response to be sent"]
16321#[derive(Debug)]
16322pub struct UsageGainListenerOnGainMuteChangedResponder {
16323    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
16324    tx_id: u32,
16325}
16326
16327/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
16328/// if the responder is dropped without sending a response, so that the client
16329/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16330impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
16331    fn drop(&mut self) {
16332        self.control_handle.shutdown();
16333        // Safety: drops once, never accessed again
16334        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16335    }
16336}
16337
16338impl fdomain_client::fidl::Responder for UsageGainListenerOnGainMuteChangedResponder {
16339    type ControlHandle = UsageGainListenerControlHandle;
16340
16341    fn control_handle(&self) -> &UsageGainListenerControlHandle {
16342        &self.control_handle
16343    }
16344
16345    fn drop_without_shutdown(mut self) {
16346        // Safety: drops once, never accessed again due to mem::forget
16347        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16348        // Prevent Drop from running (which would shut down the channel)
16349        std::mem::forget(self);
16350    }
16351}
16352
16353impl UsageGainListenerOnGainMuteChangedResponder {
16354    /// Sends a response to the FIDL transaction.
16355    ///
16356    /// Sets the channel to shutdown if an error occurs.
16357    pub fn send(self) -> Result<(), fidl::Error> {
16358        let _result = self.send_raw();
16359        if _result.is_err() {
16360            self.control_handle.shutdown();
16361        }
16362        self.drop_without_shutdown();
16363        _result
16364    }
16365
16366    /// Similar to "send" but does not shutdown the channel if an error occurs.
16367    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16368        let _result = self.send_raw();
16369        self.drop_without_shutdown();
16370        _result
16371    }
16372
16373    fn send_raw(&self) -> Result<(), fidl::Error> {
16374        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16375            (),
16376            self.tx_id,
16377            0x681570258eac3a8d,
16378            fidl::encoding::DynamicFlags::empty(),
16379        )
16380    }
16381}
16382
16383#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16384pub struct UsageGainReporterMarker;
16385
16386impl fdomain_client::fidl::ProtocolMarker for UsageGainReporterMarker {
16387    type Proxy = UsageGainReporterProxy;
16388    type RequestStream = UsageGainReporterRequestStream;
16389
16390    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
16391}
16392impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageGainReporterMarker {}
16393
16394pub trait UsageGainReporterProxyInterface: Send + Sync {
16395    fn r#register_listener(
16396        &self,
16397        device_unique_id: &str,
16398        usage: &Usage,
16399        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16400    ) -> Result<(), fidl::Error>;
16401    fn r#register_listener2(
16402        &self,
16403        device_unique_id: &str,
16404        usage: &Usage2,
16405        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16406    ) -> Result<(), fidl::Error>;
16407}
16408
16409#[derive(Debug, Clone)]
16410pub struct UsageGainReporterProxy {
16411    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16412}
16413
16414impl fdomain_client::fidl::Proxy for UsageGainReporterProxy {
16415    type Protocol = UsageGainReporterMarker;
16416
16417    fn from_channel(inner: fdomain_client::Channel) -> Self {
16418        Self::new(inner)
16419    }
16420
16421    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16422        self.client.into_channel().map_err(|client| Self { client })
16423    }
16424
16425    fn as_channel(&self) -> &fdomain_client::Channel {
16426        self.client.as_channel()
16427    }
16428}
16429
16430impl UsageGainReporterProxy {
16431    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
16432    pub fn new(channel: fdomain_client::Channel) -> Self {
16433        let protocol_name =
16434            <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16435        Self { client: fidl::client::Client::new(channel, protocol_name) }
16436    }
16437
16438    /// Get a Stream of events from the remote end of the protocol.
16439    ///
16440    /// # Panics
16441    ///
16442    /// Panics if the event stream was already taken.
16443    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
16444        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
16445    }
16446
16447    /// Connects a listener to a stream of usage gain setting changes
16448    /// for `usage` on the device identified by `device_token`. Usage
16449    /// Gain is not set directly by any client; it is a translation of
16450    /// the usage volume setting for each device, summed with active
16451    /// muting/ducking gain adjustments.
16452    ///
16453    /// Devices may map the same volume level to different dbfs, so
16454    /// a `device_unique_id` is needed to identify the device.
16455    ///
16456    /// `AudioDeviceEnumerator` provides programmatic access to devices
16457    /// and their unique ids if it is necessary for a client to select
16458    /// an id at runtime.
16459    pub fn r#register_listener(
16460        &self,
16461        mut device_unique_id: &str,
16462        mut usage: &Usage,
16463        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16464    ) -> Result<(), fidl::Error> {
16465        UsageGainReporterProxyInterface::r#register_listener(
16466            self,
16467            device_unique_id,
16468            usage,
16469            usage_gain_listener,
16470        )
16471    }
16472
16473    /// Connects a listener to a stream of usage gain setting changes
16474    /// for `usage` on the device identified by `device_token`. Usage
16475    /// Gain is not set directly by any client; it is a translation of
16476    /// the usage volume setting for each device, summed with active
16477    /// muting/ducking gain adjustments.
16478    ///
16479    /// Devices may map the same volume level to different dbfs, so
16480    /// a `device_unique_id` is needed to identify the device.
16481    ///
16482    /// `AudioDeviceEnumerator` provides programmatic access to devices
16483    /// and their unique ids if it is necessary for a client to select
16484    /// an id at runtime.
16485    pub fn r#register_listener2(
16486        &self,
16487        mut device_unique_id: &str,
16488        mut usage: &Usage2,
16489        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16490    ) -> Result<(), fidl::Error> {
16491        UsageGainReporterProxyInterface::r#register_listener2(
16492            self,
16493            device_unique_id,
16494            usage,
16495            usage_gain_listener,
16496        )
16497    }
16498}
16499
16500impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
16501    fn r#register_listener(
16502        &self,
16503        mut device_unique_id: &str,
16504        mut usage: &Usage,
16505        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16506    ) -> Result<(), fidl::Error> {
16507        self.client.send::<UsageGainReporterRegisterListenerRequest>(
16508            (device_unique_id, usage, usage_gain_listener),
16509            0x767107c168c226af,
16510            fidl::encoding::DynamicFlags::empty(),
16511        )
16512    }
16513
16514    fn r#register_listener2(
16515        &self,
16516        mut device_unique_id: &str,
16517        mut usage: &Usage2,
16518        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16519    ) -> Result<(), fidl::Error> {
16520        self.client.send::<UsageGainReporterRegisterListener2Request>(
16521            (device_unique_id, usage, usage_gain_listener),
16522            0x760a8e1c5873629c,
16523            fidl::encoding::DynamicFlags::FLEXIBLE,
16524        )
16525    }
16526}
16527
16528pub struct UsageGainReporterEventStream {
16529    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16530}
16531
16532impl std::marker::Unpin for UsageGainReporterEventStream {}
16533
16534impl futures::stream::FusedStream for UsageGainReporterEventStream {
16535    fn is_terminated(&self) -> bool {
16536        self.event_receiver.is_terminated()
16537    }
16538}
16539
16540impl futures::Stream for UsageGainReporterEventStream {
16541    type Item = Result<UsageGainReporterEvent, fidl::Error>;
16542
16543    fn poll_next(
16544        mut self: std::pin::Pin<&mut Self>,
16545        cx: &mut std::task::Context<'_>,
16546    ) -> std::task::Poll<Option<Self::Item>> {
16547        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16548            &mut self.event_receiver,
16549            cx
16550        )?) {
16551            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
16552            None => std::task::Poll::Ready(None),
16553        }
16554    }
16555}
16556
16557#[derive(Debug)]
16558pub enum UsageGainReporterEvent {
16559    #[non_exhaustive]
16560    _UnknownEvent {
16561        /// Ordinal of the event that was sent.
16562        ordinal: u64,
16563    },
16564}
16565
16566impl UsageGainReporterEvent {
16567    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
16568    fn decode(
16569        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16570    ) -> Result<UsageGainReporterEvent, fidl::Error> {
16571        let (bytes, _handles) = buf.split_mut();
16572        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16573        debug_assert_eq!(tx_header.tx_id, 0);
16574        match tx_header.ordinal {
16575            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16576                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
16577            }
16578            _ => Err(fidl::Error::UnknownOrdinal {
16579                ordinal: tx_header.ordinal,
16580                protocol_name:
16581                    <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16582            }),
16583        }
16584    }
16585}
16586
16587/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
16588pub struct UsageGainReporterRequestStream {
16589    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16590    is_terminated: bool,
16591}
16592
16593impl std::marker::Unpin for UsageGainReporterRequestStream {}
16594
16595impl futures::stream::FusedStream for UsageGainReporterRequestStream {
16596    fn is_terminated(&self) -> bool {
16597        self.is_terminated
16598    }
16599}
16600
16601impl fdomain_client::fidl::RequestStream for UsageGainReporterRequestStream {
16602    type Protocol = UsageGainReporterMarker;
16603    type ControlHandle = UsageGainReporterControlHandle;
16604
16605    fn from_channel(channel: fdomain_client::Channel) -> Self {
16606        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16607    }
16608
16609    fn control_handle(&self) -> Self::ControlHandle {
16610        UsageGainReporterControlHandle { inner: self.inner.clone() }
16611    }
16612
16613    fn into_inner(
16614        self,
16615    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
16616    {
16617        (self.inner, self.is_terminated)
16618    }
16619
16620    fn from_inner(
16621        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16622        is_terminated: bool,
16623    ) -> Self {
16624        Self { inner, is_terminated }
16625    }
16626}
16627
16628impl futures::Stream for UsageGainReporterRequestStream {
16629    type Item = Result<UsageGainReporterRequest, fidl::Error>;
16630
16631    fn poll_next(
16632        mut self: std::pin::Pin<&mut Self>,
16633        cx: &mut std::task::Context<'_>,
16634    ) -> std::task::Poll<Option<Self::Item>> {
16635        let this = &mut *self;
16636        if this.inner.check_shutdown(cx) {
16637            this.is_terminated = true;
16638            return std::task::Poll::Ready(None);
16639        }
16640        if this.is_terminated {
16641            panic!("polled UsageGainReporterRequestStream after completion");
16642        }
16643        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
16644            |bytes, handles| {
16645                match this.inner.channel().read_etc(cx, bytes, handles) {
16646                    std::task::Poll::Ready(Ok(())) => {}
16647                    std::task::Poll::Pending => return std::task::Poll::Pending,
16648                    std::task::Poll::Ready(Err(None)) => {
16649                        this.is_terminated = true;
16650                        return std::task::Poll::Ready(None);
16651                    }
16652                    std::task::Poll::Ready(Err(Some(e))) => {
16653                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16654                            e.into(),
16655                        ))));
16656                    }
16657                }
16658
16659                // A message has been received from the channel
16660                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16661
16662                std::task::Poll::Ready(Some(match header.ordinal {
16663                0x767107c168c226af => {
16664                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16665                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListenerRequest, fdomain_client::fidl::FDomainResourceDialect);
16666                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
16667                    let control_handle = UsageGainReporterControlHandle {
16668                        inner: this.inner.clone(),
16669                    };
16670                    Ok(UsageGainReporterRequest::RegisterListener {device_unique_id: req.device_unique_id,
16671usage: req.usage,
16672usage_gain_listener: req.usage_gain_listener,
16673
16674                        control_handle,
16675                    })
16676                }
16677                0x760a8e1c5873629c => {
16678                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16679                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListener2Request, fdomain_client::fidl::FDomainResourceDialect);
16680                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
16681                    let control_handle = UsageGainReporterControlHandle {
16682                        inner: this.inner.clone(),
16683                    };
16684                    Ok(UsageGainReporterRequest::RegisterListener2 {device_unique_id: req.device_unique_id,
16685usage: req.usage,
16686usage_gain_listener: req.usage_gain_listener,
16687
16688                        control_handle,
16689                    })
16690                }
16691                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16692                    Ok(UsageGainReporterRequest::_UnknownMethod {
16693                        ordinal: header.ordinal,
16694                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
16695                        method_type: fidl::MethodType::OneWay,
16696                    })
16697                }
16698                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16699                    this.inner.send_framework_err(
16700                        fidl::encoding::FrameworkErr::UnknownMethod,
16701                        header.tx_id,
16702                        header.ordinal,
16703                        header.dynamic_flags(),
16704                        (bytes, handles),
16705                    )?;
16706                    Ok(UsageGainReporterRequest::_UnknownMethod {
16707                        ordinal: header.ordinal,
16708                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
16709                        method_type: fidl::MethodType::TwoWay,
16710                    })
16711                }
16712                _ => Err(fidl::Error::UnknownOrdinal {
16713                    ordinal: header.ordinal,
16714                    protocol_name: <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16715                }),
16716            }))
16717            },
16718        )
16719    }
16720}
16721
16722/// A protocol for setting up watchers of usage gain.
16723#[derive(Debug)]
16724pub enum UsageGainReporterRequest {
16725    /// Connects a listener to a stream of usage gain setting changes
16726    /// for `usage` on the device identified by `device_token`. Usage
16727    /// Gain is not set directly by any client; it is a translation of
16728    /// the usage volume setting for each device, summed with active
16729    /// muting/ducking gain adjustments.
16730    ///
16731    /// Devices may map the same volume level to different dbfs, so
16732    /// a `device_unique_id` is needed to identify the device.
16733    ///
16734    /// `AudioDeviceEnumerator` provides programmatic access to devices
16735    /// and their unique ids if it is necessary for a client to select
16736    /// an id at runtime.
16737    RegisterListener {
16738        device_unique_id: String,
16739        usage: Usage,
16740        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16741        control_handle: UsageGainReporterControlHandle,
16742    },
16743    /// Connects a listener to a stream of usage gain setting changes
16744    /// for `usage` on the device identified by `device_token`. Usage
16745    /// Gain is not set directly by any client; it is a translation of
16746    /// the usage volume setting for each device, summed with active
16747    /// muting/ducking gain adjustments.
16748    ///
16749    /// Devices may map the same volume level to different dbfs, so
16750    /// a `device_unique_id` is needed to identify the device.
16751    ///
16752    /// `AudioDeviceEnumerator` provides programmatic access to devices
16753    /// and their unique ids if it is necessary for a client to select
16754    /// an id at runtime.
16755    RegisterListener2 {
16756        device_unique_id: String,
16757        usage: Usage2,
16758        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16759        control_handle: UsageGainReporterControlHandle,
16760    },
16761    /// An interaction was received which does not match any known method.
16762    #[non_exhaustive]
16763    _UnknownMethod {
16764        /// Ordinal of the method that was called.
16765        ordinal: u64,
16766        control_handle: UsageGainReporterControlHandle,
16767        method_type: fidl::MethodType,
16768    },
16769}
16770
16771impl UsageGainReporterRequest {
16772    #[allow(irrefutable_let_patterns)]
16773    pub fn into_register_listener(
16774        self,
16775    ) -> Option<(
16776        String,
16777        Usage,
16778        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16779        UsageGainReporterControlHandle,
16780    )> {
16781        if let UsageGainReporterRequest::RegisterListener {
16782            device_unique_id,
16783            usage,
16784            usage_gain_listener,
16785            control_handle,
16786        } = self
16787        {
16788            Some((device_unique_id, usage, usage_gain_listener, control_handle))
16789        } else {
16790            None
16791        }
16792    }
16793
16794    #[allow(irrefutable_let_patterns)]
16795    pub fn into_register_listener2(
16796        self,
16797    ) -> Option<(
16798        String,
16799        Usage2,
16800        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16801        UsageGainReporterControlHandle,
16802    )> {
16803        if let UsageGainReporterRequest::RegisterListener2 {
16804            device_unique_id,
16805            usage,
16806            usage_gain_listener,
16807            control_handle,
16808        } = self
16809        {
16810            Some((device_unique_id, usage, usage_gain_listener, control_handle))
16811        } else {
16812            None
16813        }
16814    }
16815
16816    /// Name of the method defined in FIDL
16817    pub fn method_name(&self) -> &'static str {
16818        match *self {
16819            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
16820            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
16821            UsageGainReporterRequest::_UnknownMethod {
16822                method_type: fidl::MethodType::OneWay,
16823                ..
16824            } => "unknown one-way method",
16825            UsageGainReporterRequest::_UnknownMethod {
16826                method_type: fidl::MethodType::TwoWay,
16827                ..
16828            } => "unknown two-way method",
16829        }
16830    }
16831}
16832
16833#[derive(Debug, Clone)]
16834pub struct UsageGainReporterControlHandle {
16835    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16836}
16837
16838impl fdomain_client::fidl::ControlHandle for UsageGainReporterControlHandle {
16839    fn shutdown(&self) {
16840        self.inner.shutdown()
16841    }
16842
16843    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16844        self.inner.shutdown_with_epitaph(status)
16845    }
16846
16847    fn is_closed(&self) -> bool {
16848        self.inner.channel().is_closed()
16849    }
16850    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16851        self.inner.channel().on_closed()
16852    }
16853}
16854
16855impl UsageGainReporterControlHandle {}
16856
16857#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16858pub struct UsageReporterMarker;
16859
16860impl fdomain_client::fidl::ProtocolMarker for UsageReporterMarker {
16861    type Proxy = UsageReporterProxy;
16862    type RequestStream = UsageReporterRequestStream;
16863
16864    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
16865}
16866impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageReporterMarker {}
16867
16868pub trait UsageReporterProxyInterface: Send + Sync {
16869    fn r#watch(
16870        &self,
16871        usage: &Usage,
16872        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
16873    ) -> Result<(), fidl::Error>;
16874    fn r#watch2(
16875        &self,
16876        usage: &Usage2,
16877        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
16878    ) -> Result<(), fidl::Error>;
16879}
16880
16881#[derive(Debug, Clone)]
16882pub struct UsageReporterProxy {
16883    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16884}
16885
16886impl fdomain_client::fidl::Proxy for UsageReporterProxy {
16887    type Protocol = UsageReporterMarker;
16888
16889    fn from_channel(inner: fdomain_client::Channel) -> Self {
16890        Self::new(inner)
16891    }
16892
16893    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16894        self.client.into_channel().map_err(|client| Self { client })
16895    }
16896
16897    fn as_channel(&self) -> &fdomain_client::Channel {
16898        self.client.as_channel()
16899    }
16900}
16901
16902impl UsageReporterProxy {
16903    /// Create a new Proxy for fuchsia.media/UsageReporter.
16904    pub fn new(channel: fdomain_client::Channel) -> Self {
16905        let protocol_name =
16906            <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16907        Self { client: fidl::client::Client::new(channel, protocol_name) }
16908    }
16909
16910    /// Get a Stream of events from the remote end of the protocol.
16911    ///
16912    /// # Panics
16913    ///
16914    /// Panics if the event stream was already taken.
16915    pub fn take_event_stream(&self) -> UsageReporterEventStream {
16916        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
16917    }
16918
16919    pub fn r#watch(
16920        &self,
16921        mut usage: &Usage,
16922        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
16923    ) -> Result<(), fidl::Error> {
16924        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
16925    }
16926
16927    pub fn r#watch2(
16928        &self,
16929        mut usage: &Usage2,
16930        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
16931    ) -> Result<(), fidl::Error> {
16932        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
16933    }
16934}
16935
16936impl UsageReporterProxyInterface for UsageReporterProxy {
16937    fn r#watch(
16938        &self,
16939        mut usage: &Usage,
16940        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
16941    ) -> Result<(), fidl::Error> {
16942        self.client.send::<UsageReporterWatchRequest>(
16943            (usage, usage_watcher),
16944            0x769e6fb17075c959,
16945            fidl::encoding::DynamicFlags::empty(),
16946        )
16947    }
16948
16949    fn r#watch2(
16950        &self,
16951        mut usage: &Usage2,
16952        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
16953    ) -> Result<(), fidl::Error> {
16954        self.client.send::<UsageReporterWatch2Request>(
16955            (usage, usage_watcher),
16956            0x4a43c4c82f5d8ce8,
16957            fidl::encoding::DynamicFlags::FLEXIBLE,
16958        )
16959    }
16960}
16961
16962pub struct UsageReporterEventStream {
16963    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16964}
16965
16966impl std::marker::Unpin for UsageReporterEventStream {}
16967
16968impl futures::stream::FusedStream for UsageReporterEventStream {
16969    fn is_terminated(&self) -> bool {
16970        self.event_receiver.is_terminated()
16971    }
16972}
16973
16974impl futures::Stream for UsageReporterEventStream {
16975    type Item = Result<UsageReporterEvent, fidl::Error>;
16976
16977    fn poll_next(
16978        mut self: std::pin::Pin<&mut Self>,
16979        cx: &mut std::task::Context<'_>,
16980    ) -> std::task::Poll<Option<Self::Item>> {
16981        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16982            &mut self.event_receiver,
16983            cx
16984        )?) {
16985            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
16986            None => std::task::Poll::Ready(None),
16987        }
16988    }
16989}
16990
16991#[derive(Debug)]
16992pub enum UsageReporterEvent {
16993    #[non_exhaustive]
16994    _UnknownEvent {
16995        /// Ordinal of the event that was sent.
16996        ordinal: u64,
16997    },
16998}
16999
17000impl UsageReporterEvent {
17001    /// Decodes a message buffer as a [`UsageReporterEvent`].
17002    fn decode(
17003        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17004    ) -> Result<UsageReporterEvent, fidl::Error> {
17005        let (bytes, _handles) = buf.split_mut();
17006        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17007        debug_assert_eq!(tx_header.tx_id, 0);
17008        match tx_header.ordinal {
17009            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17010                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
17011            }
17012            _ => Err(fidl::Error::UnknownOrdinal {
17013                ordinal: tx_header.ordinal,
17014                protocol_name:
17015                    <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17016            }),
17017        }
17018    }
17019}
17020
17021/// A Stream of incoming requests for fuchsia.media/UsageReporter.
17022pub struct UsageReporterRequestStream {
17023    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17024    is_terminated: bool,
17025}
17026
17027impl std::marker::Unpin for UsageReporterRequestStream {}
17028
17029impl futures::stream::FusedStream for UsageReporterRequestStream {
17030    fn is_terminated(&self) -> bool {
17031        self.is_terminated
17032    }
17033}
17034
17035impl fdomain_client::fidl::RequestStream for UsageReporterRequestStream {
17036    type Protocol = UsageReporterMarker;
17037    type ControlHandle = UsageReporterControlHandle;
17038
17039    fn from_channel(channel: fdomain_client::Channel) -> Self {
17040        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17041    }
17042
17043    fn control_handle(&self) -> Self::ControlHandle {
17044        UsageReporterControlHandle { inner: self.inner.clone() }
17045    }
17046
17047    fn into_inner(
17048        self,
17049    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17050    {
17051        (self.inner, self.is_terminated)
17052    }
17053
17054    fn from_inner(
17055        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17056        is_terminated: bool,
17057    ) -> Self {
17058        Self { inner, is_terminated }
17059    }
17060}
17061
17062impl futures::Stream for UsageReporterRequestStream {
17063    type Item = Result<UsageReporterRequest, fidl::Error>;
17064
17065    fn poll_next(
17066        mut self: std::pin::Pin<&mut Self>,
17067        cx: &mut std::task::Context<'_>,
17068    ) -> std::task::Poll<Option<Self::Item>> {
17069        let this = &mut *self;
17070        if this.inner.check_shutdown(cx) {
17071            this.is_terminated = true;
17072            return std::task::Poll::Ready(None);
17073        }
17074        if this.is_terminated {
17075            panic!("polled UsageReporterRequestStream after completion");
17076        }
17077        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17078            |bytes, handles| {
17079                match this.inner.channel().read_etc(cx, bytes, handles) {
17080                    std::task::Poll::Ready(Ok(())) => {}
17081                    std::task::Poll::Pending => return std::task::Poll::Pending,
17082                    std::task::Poll::Ready(Err(None)) => {
17083                        this.is_terminated = true;
17084                        return std::task::Poll::Ready(None);
17085                    }
17086                    std::task::Poll::Ready(Err(Some(e))) => {
17087                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17088                            e.into(),
17089                        ))));
17090                    }
17091                }
17092
17093                // A message has been received from the channel
17094                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17095
17096                std::task::Poll::Ready(Some(match header.ordinal {
17097                0x769e6fb17075c959 => {
17098                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17099                    let mut req = fidl::new_empty!(UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect);
17100                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
17101                    let control_handle = UsageReporterControlHandle {
17102                        inner: this.inner.clone(),
17103                    };
17104                    Ok(UsageReporterRequest::Watch {usage: req.usage,
17105usage_watcher: req.usage_watcher,
17106
17107                        control_handle,
17108                    })
17109                }
17110                0x4a43c4c82f5d8ce8 => {
17111                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17112                    let mut req = fidl::new_empty!(UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect);
17113                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
17114                    let control_handle = UsageReporterControlHandle {
17115                        inner: this.inner.clone(),
17116                    };
17117                    Ok(UsageReporterRequest::Watch2 {usage: req.usage,
17118usage_watcher: req.usage_watcher,
17119
17120                        control_handle,
17121                    })
17122                }
17123                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17124                    Ok(UsageReporterRequest::_UnknownMethod {
17125                        ordinal: header.ordinal,
17126                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
17127                        method_type: fidl::MethodType::OneWay,
17128                    })
17129                }
17130                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17131                    this.inner.send_framework_err(
17132                        fidl::encoding::FrameworkErr::UnknownMethod,
17133                        header.tx_id,
17134                        header.ordinal,
17135                        header.dynamic_flags(),
17136                        (bytes, handles),
17137                    )?;
17138                    Ok(UsageReporterRequest::_UnknownMethod {
17139                        ordinal: header.ordinal,
17140                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
17141                        method_type: fidl::MethodType::TwoWay,
17142                    })
17143                }
17144                _ => Err(fidl::Error::UnknownOrdinal {
17145                    ordinal: header.ordinal,
17146                    protocol_name: <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17147                }),
17148            }))
17149            },
17150        )
17151    }
17152}
17153
17154/// A protocol for setting up watchers of audio usages.
17155#[derive(Debug)]
17156pub enum UsageReporterRequest {
17157    Watch {
17158        usage: Usage,
17159        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17160        control_handle: UsageReporterControlHandle,
17161    },
17162    Watch2 {
17163        usage: Usage2,
17164        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17165        control_handle: UsageReporterControlHandle,
17166    },
17167    /// An interaction was received which does not match any known method.
17168    #[non_exhaustive]
17169    _UnknownMethod {
17170        /// Ordinal of the method that was called.
17171        ordinal: u64,
17172        control_handle: UsageReporterControlHandle,
17173        method_type: fidl::MethodType,
17174    },
17175}
17176
17177impl UsageReporterRequest {
17178    #[allow(irrefutable_let_patterns)]
17179    pub fn into_watch(
17180        self,
17181    ) -> Option<(
17182        Usage,
17183        fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17184        UsageReporterControlHandle,
17185    )> {
17186        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
17187            Some((usage, usage_watcher, control_handle))
17188        } else {
17189            None
17190        }
17191    }
17192
17193    #[allow(irrefutable_let_patterns)]
17194    pub fn into_watch2(
17195        self,
17196    ) -> Option<(
17197        Usage2,
17198        fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17199        UsageReporterControlHandle,
17200    )> {
17201        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
17202            Some((usage, usage_watcher, control_handle))
17203        } else {
17204            None
17205        }
17206    }
17207
17208    /// Name of the method defined in FIDL
17209    pub fn method_name(&self) -> &'static str {
17210        match *self {
17211            UsageReporterRequest::Watch { .. } => "watch",
17212            UsageReporterRequest::Watch2 { .. } => "watch2",
17213            UsageReporterRequest::_UnknownMethod {
17214                method_type: fidl::MethodType::OneWay, ..
17215            } => "unknown one-way method",
17216            UsageReporterRequest::_UnknownMethod {
17217                method_type: fidl::MethodType::TwoWay, ..
17218            } => "unknown two-way method",
17219        }
17220    }
17221}
17222
17223#[derive(Debug, Clone)]
17224pub struct UsageReporterControlHandle {
17225    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17226}
17227
17228impl fdomain_client::fidl::ControlHandle for UsageReporterControlHandle {
17229    fn shutdown(&self) {
17230        self.inner.shutdown()
17231    }
17232
17233    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17234        self.inner.shutdown_with_epitaph(status)
17235    }
17236
17237    fn is_closed(&self) -> bool {
17238        self.inner.channel().is_closed()
17239    }
17240    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
17241        self.inner.channel().on_closed()
17242    }
17243}
17244
17245impl UsageReporterControlHandle {}
17246
17247#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17248pub struct UsageWatcherMarker;
17249
17250impl fdomain_client::fidl::ProtocolMarker for UsageWatcherMarker {
17251    type Proxy = UsageWatcherProxy;
17252    type RequestStream = UsageWatcherRequestStream;
17253
17254    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
17255}
17256
17257pub trait UsageWatcherProxyInterface: Send + Sync {
17258    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17259    fn r#on_state_changed(
17260        &self,
17261        usage: &Usage,
17262        state: &UsageState,
17263    ) -> Self::OnStateChangedResponseFut;
17264}
17265
17266#[derive(Debug, Clone)]
17267pub struct UsageWatcherProxy {
17268    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
17269}
17270
17271impl fdomain_client::fidl::Proxy for UsageWatcherProxy {
17272    type Protocol = UsageWatcherMarker;
17273
17274    fn from_channel(inner: fdomain_client::Channel) -> Self {
17275        Self::new(inner)
17276    }
17277
17278    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
17279        self.client.into_channel().map_err(|client| Self { client })
17280    }
17281
17282    fn as_channel(&self) -> &fdomain_client::Channel {
17283        self.client.as_channel()
17284    }
17285}
17286
17287impl UsageWatcherProxy {
17288    /// Create a new Proxy for fuchsia.media/UsageWatcher.
17289    pub fn new(channel: fdomain_client::Channel) -> Self {
17290        let protocol_name =
17291            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
17292        Self { client: fidl::client::Client::new(channel, protocol_name) }
17293    }
17294
17295    /// Get a Stream of events from the remote end of the protocol.
17296    ///
17297    /// # Panics
17298    ///
17299    /// Panics if the event stream was already taken.
17300    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
17301        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
17302    }
17303
17304    /// Called on first connection and whenever the watched usage changes. The provided
17305    /// usage will always be the bound usage; it is provided so that an implementation of
17306    /// this protocol may be bound to more than one usage.
17307    ///
17308    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17309    /// events will eventually be disconnected.
17310    pub fn r#on_state_changed(
17311        &self,
17312        mut usage: &Usage,
17313        mut state: &UsageState,
17314    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
17315        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
17316    }
17317}
17318
17319impl UsageWatcherProxyInterface for UsageWatcherProxy {
17320    type OnStateChangedResponseFut =
17321        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
17322    fn r#on_state_changed(
17323        &self,
17324        mut usage: &Usage,
17325        mut state: &UsageState,
17326    ) -> Self::OnStateChangedResponseFut {
17327        fn _decode(
17328            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
17329        ) -> Result<(), fidl::Error> {
17330            let _response = fidl::client::decode_transaction_body::<
17331                fidl::encoding::EmptyPayload,
17332                fdomain_client::fidl::FDomainResourceDialect,
17333                0x5b955c5768ec75c5,
17334            >(_buf?)?;
17335            Ok(_response)
17336        }
17337        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
17338            (usage, state),
17339            0x5b955c5768ec75c5,
17340            fidl::encoding::DynamicFlags::empty(),
17341            _decode,
17342        )
17343    }
17344}
17345
17346pub struct UsageWatcherEventStream {
17347    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
17348}
17349
17350impl std::marker::Unpin for UsageWatcherEventStream {}
17351
17352impl futures::stream::FusedStream for UsageWatcherEventStream {
17353    fn is_terminated(&self) -> bool {
17354        self.event_receiver.is_terminated()
17355    }
17356}
17357
17358impl futures::Stream for UsageWatcherEventStream {
17359    type Item = Result<UsageWatcherEvent, fidl::Error>;
17360
17361    fn poll_next(
17362        mut self: std::pin::Pin<&mut Self>,
17363        cx: &mut std::task::Context<'_>,
17364    ) -> std::task::Poll<Option<Self::Item>> {
17365        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17366            &mut self.event_receiver,
17367            cx
17368        )?) {
17369            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
17370            None => std::task::Poll::Ready(None),
17371        }
17372    }
17373}
17374
17375#[derive(Debug)]
17376pub enum UsageWatcherEvent {}
17377
17378impl UsageWatcherEvent {
17379    /// Decodes a message buffer as a [`UsageWatcherEvent`].
17380    fn decode(
17381        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17382    ) -> Result<UsageWatcherEvent, fidl::Error> {
17383        let (bytes, _handles) = buf.split_mut();
17384        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17385        debug_assert_eq!(tx_header.tx_id, 0);
17386        match tx_header.ordinal {
17387            _ => Err(fidl::Error::UnknownOrdinal {
17388                ordinal: tx_header.ordinal,
17389                protocol_name:
17390                    <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17391            }),
17392        }
17393    }
17394}
17395
17396/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
17397pub struct UsageWatcherRequestStream {
17398    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17399    is_terminated: bool,
17400}
17401
17402impl std::marker::Unpin for UsageWatcherRequestStream {}
17403
17404impl futures::stream::FusedStream for UsageWatcherRequestStream {
17405    fn is_terminated(&self) -> bool {
17406        self.is_terminated
17407    }
17408}
17409
17410impl fdomain_client::fidl::RequestStream for UsageWatcherRequestStream {
17411    type Protocol = UsageWatcherMarker;
17412    type ControlHandle = UsageWatcherControlHandle;
17413
17414    fn from_channel(channel: fdomain_client::Channel) -> Self {
17415        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17416    }
17417
17418    fn control_handle(&self) -> Self::ControlHandle {
17419        UsageWatcherControlHandle { inner: self.inner.clone() }
17420    }
17421
17422    fn into_inner(
17423        self,
17424    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17425    {
17426        (self.inner, self.is_terminated)
17427    }
17428
17429    fn from_inner(
17430        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17431        is_terminated: bool,
17432    ) -> Self {
17433        Self { inner, is_terminated }
17434    }
17435}
17436
17437impl futures::Stream for UsageWatcherRequestStream {
17438    type Item = Result<UsageWatcherRequest, fidl::Error>;
17439
17440    fn poll_next(
17441        mut self: std::pin::Pin<&mut Self>,
17442        cx: &mut std::task::Context<'_>,
17443    ) -> std::task::Poll<Option<Self::Item>> {
17444        let this = &mut *self;
17445        if this.inner.check_shutdown(cx) {
17446            this.is_terminated = true;
17447            return std::task::Poll::Ready(None);
17448        }
17449        if this.is_terminated {
17450            panic!("polled UsageWatcherRequestStream after completion");
17451        }
17452        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17453            |bytes, handles| {
17454                match this.inner.channel().read_etc(cx, bytes, handles) {
17455                    std::task::Poll::Ready(Ok(())) => {}
17456                    std::task::Poll::Pending => return std::task::Poll::Pending,
17457                    std::task::Poll::Ready(Err(None)) => {
17458                        this.is_terminated = true;
17459                        return std::task::Poll::Ready(None);
17460                    }
17461                    std::task::Poll::Ready(Err(Some(e))) => {
17462                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17463                            e.into(),
17464                        ))));
17465                    }
17466                }
17467
17468                // A message has been received from the channel
17469                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17470
17471                std::task::Poll::Ready(Some(match header.ordinal {
17472                    0x5b955c5768ec75c5 => {
17473                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
17474                        let mut req = fidl::new_empty!(
17475                            UsageWatcherOnStateChangedRequest,
17476                            fdomain_client::fidl::FDomainResourceDialect
17477                        );
17478                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
17479                        let control_handle =
17480                            UsageWatcherControlHandle { inner: this.inner.clone() };
17481                        Ok(UsageWatcherRequest::OnStateChanged {
17482                            usage: req.usage,
17483                            state: req.state,
17484
17485                            responder: UsageWatcherOnStateChangedResponder {
17486                                control_handle: std::mem::ManuallyDrop::new(control_handle),
17487                                tx_id: header.tx_id,
17488                            },
17489                        })
17490                    }
17491                    _ => Err(fidl::Error::UnknownOrdinal {
17492                        ordinal: header.ordinal,
17493                        protocol_name:
17494                            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17495                    }),
17496                }))
17497            },
17498        )
17499    }
17500}
17501
17502/// A protocol for listening to changes to the policy state of an audio usage.
17503///
17504/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
17505#[derive(Debug)]
17506pub enum UsageWatcherRequest {
17507    /// Called on first connection and whenever the watched usage changes. The provided
17508    /// usage will always be the bound usage; it is provided so that an implementation of
17509    /// this protocol may be bound to more than one usage.
17510    ///
17511    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17512    /// events will eventually be disconnected.
17513    OnStateChanged {
17514        usage: Usage,
17515        state: UsageState,
17516        responder: UsageWatcherOnStateChangedResponder,
17517    },
17518}
17519
17520impl UsageWatcherRequest {
17521    #[allow(irrefutable_let_patterns)]
17522    pub fn into_on_state_changed(
17523        self,
17524    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
17525        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
17526            Some((usage, state, responder))
17527        } else {
17528            None
17529        }
17530    }
17531
17532    /// Name of the method defined in FIDL
17533    pub fn method_name(&self) -> &'static str {
17534        match *self {
17535            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
17536        }
17537    }
17538}
17539
17540#[derive(Debug, Clone)]
17541pub struct UsageWatcherControlHandle {
17542    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17543}
17544
17545impl fdomain_client::fidl::ControlHandle for UsageWatcherControlHandle {
17546    fn shutdown(&self) {
17547        self.inner.shutdown()
17548    }
17549
17550    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17551        self.inner.shutdown_with_epitaph(status)
17552    }
17553
17554    fn is_closed(&self) -> bool {
17555        self.inner.channel().is_closed()
17556    }
17557    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
17558        self.inner.channel().on_closed()
17559    }
17560}
17561
17562impl UsageWatcherControlHandle {}
17563
17564#[must_use = "FIDL methods require a response to be sent"]
17565#[derive(Debug)]
17566pub struct UsageWatcherOnStateChangedResponder {
17567    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
17568    tx_id: u32,
17569}
17570
17571/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
17572/// if the responder is dropped without sending a response, so that the client
17573/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17574impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
17575    fn drop(&mut self) {
17576        self.control_handle.shutdown();
17577        // Safety: drops once, never accessed again
17578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17579    }
17580}
17581
17582impl fdomain_client::fidl::Responder for UsageWatcherOnStateChangedResponder {
17583    type ControlHandle = UsageWatcherControlHandle;
17584
17585    fn control_handle(&self) -> &UsageWatcherControlHandle {
17586        &self.control_handle
17587    }
17588
17589    fn drop_without_shutdown(mut self) {
17590        // Safety: drops once, never accessed again due to mem::forget
17591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17592        // Prevent Drop from running (which would shut down the channel)
17593        std::mem::forget(self);
17594    }
17595}
17596
17597impl UsageWatcherOnStateChangedResponder {
17598    /// Sends a response to the FIDL transaction.
17599    ///
17600    /// Sets the channel to shutdown if an error occurs.
17601    pub fn send(self) -> Result<(), fidl::Error> {
17602        let _result = self.send_raw();
17603        if _result.is_err() {
17604            self.control_handle.shutdown();
17605        }
17606        self.drop_without_shutdown();
17607        _result
17608    }
17609
17610    /// Similar to "send" but does not shutdown the channel if an error occurs.
17611    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17612        let _result = self.send_raw();
17613        self.drop_without_shutdown();
17614        _result
17615    }
17616
17617    fn send_raw(&self) -> Result<(), fidl::Error> {
17618        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17619            (),
17620            self.tx_id,
17621            0x5b955c5768ec75c5,
17622            fidl::encoding::DynamicFlags::empty(),
17623        )
17624    }
17625}
17626
17627#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17628pub struct UsageWatcher2Marker;
17629
17630impl fdomain_client::fidl::ProtocolMarker for UsageWatcher2Marker {
17631    type Proxy = UsageWatcher2Proxy;
17632    type RequestStream = UsageWatcher2RequestStream;
17633
17634    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
17635}
17636
17637pub trait UsageWatcher2ProxyInterface: Send + Sync {
17638    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17639    fn r#on_state_changed(
17640        &self,
17641        usage: &Usage2,
17642        state: &UsageState,
17643    ) -> Self::OnStateChangedResponseFut;
17644}
17645
17646#[derive(Debug, Clone)]
17647pub struct UsageWatcher2Proxy {
17648    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
17649}
17650
17651impl fdomain_client::fidl::Proxy for UsageWatcher2Proxy {
17652    type Protocol = UsageWatcher2Marker;
17653
17654    fn from_channel(inner: fdomain_client::Channel) -> Self {
17655        Self::new(inner)
17656    }
17657
17658    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
17659        self.client.into_channel().map_err(|client| Self { client })
17660    }
17661
17662    fn as_channel(&self) -> &fdomain_client::Channel {
17663        self.client.as_channel()
17664    }
17665}
17666
17667impl UsageWatcher2Proxy {
17668    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
17669    pub fn new(channel: fdomain_client::Channel) -> Self {
17670        let protocol_name =
17671            <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
17672        Self { client: fidl::client::Client::new(channel, protocol_name) }
17673    }
17674
17675    /// Get a Stream of events from the remote end of the protocol.
17676    ///
17677    /// # Panics
17678    ///
17679    /// Panics if the event stream was already taken.
17680    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
17681        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
17682    }
17683
17684    /// Called on first connection and whenever the watched usage changes. The provided
17685    /// usage will always be the bound usage; it is provided so that an implementation of
17686    /// this protocol may be bound to more than one usage.
17687    ///
17688    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17689    /// events will eventually be disconnected.
17690    pub fn r#on_state_changed(
17691        &self,
17692        mut usage: &Usage2,
17693        mut state: &UsageState,
17694    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
17695        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
17696    }
17697}
17698
17699impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
17700    type OnStateChangedResponseFut =
17701        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
17702    fn r#on_state_changed(
17703        &self,
17704        mut usage: &Usage2,
17705        mut state: &UsageState,
17706    ) -> Self::OnStateChangedResponseFut {
17707        fn _decode(
17708            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
17709        ) -> Result<(), fidl::Error> {
17710            let _response = fidl::client::decode_transaction_body::<
17711                fidl::encoding::EmptyPayload,
17712                fdomain_client::fidl::FDomainResourceDialect,
17713                0xca31a8b13c324d4,
17714            >(_buf?)?;
17715            Ok(_response)
17716        }
17717        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
17718            (usage, state),
17719            0xca31a8b13c324d4,
17720            fidl::encoding::DynamicFlags::empty(),
17721            _decode,
17722        )
17723    }
17724}
17725
17726pub struct UsageWatcher2EventStream {
17727    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
17728}
17729
17730impl std::marker::Unpin for UsageWatcher2EventStream {}
17731
17732impl futures::stream::FusedStream for UsageWatcher2EventStream {
17733    fn is_terminated(&self) -> bool {
17734        self.event_receiver.is_terminated()
17735    }
17736}
17737
17738impl futures::Stream for UsageWatcher2EventStream {
17739    type Item = Result<UsageWatcher2Event, fidl::Error>;
17740
17741    fn poll_next(
17742        mut self: std::pin::Pin<&mut Self>,
17743        cx: &mut std::task::Context<'_>,
17744    ) -> std::task::Poll<Option<Self::Item>> {
17745        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17746            &mut self.event_receiver,
17747            cx
17748        )?) {
17749            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
17750            None => std::task::Poll::Ready(None),
17751        }
17752    }
17753}
17754
17755#[derive(Debug)]
17756pub enum UsageWatcher2Event {}
17757
17758impl UsageWatcher2Event {
17759    /// Decodes a message buffer as a [`UsageWatcher2Event`].
17760    fn decode(
17761        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17762    ) -> Result<UsageWatcher2Event, fidl::Error> {
17763        let (bytes, _handles) = buf.split_mut();
17764        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17765        debug_assert_eq!(tx_header.tx_id, 0);
17766        match tx_header.ordinal {
17767            _ => Err(fidl::Error::UnknownOrdinal {
17768                ordinal: tx_header.ordinal,
17769                protocol_name:
17770                    <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17771            }),
17772        }
17773    }
17774}
17775
17776/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
17777pub struct UsageWatcher2RequestStream {
17778    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17779    is_terminated: bool,
17780}
17781
17782impl std::marker::Unpin for UsageWatcher2RequestStream {}
17783
17784impl futures::stream::FusedStream for UsageWatcher2RequestStream {
17785    fn is_terminated(&self) -> bool {
17786        self.is_terminated
17787    }
17788}
17789
17790impl fdomain_client::fidl::RequestStream for UsageWatcher2RequestStream {
17791    type Protocol = UsageWatcher2Marker;
17792    type ControlHandle = UsageWatcher2ControlHandle;
17793
17794    fn from_channel(channel: fdomain_client::Channel) -> Self {
17795        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17796    }
17797
17798    fn control_handle(&self) -> Self::ControlHandle {
17799        UsageWatcher2ControlHandle { inner: self.inner.clone() }
17800    }
17801
17802    fn into_inner(
17803        self,
17804    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17805    {
17806        (self.inner, self.is_terminated)
17807    }
17808
17809    fn from_inner(
17810        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17811        is_terminated: bool,
17812    ) -> Self {
17813        Self { inner, is_terminated }
17814    }
17815}
17816
17817impl futures::Stream for UsageWatcher2RequestStream {
17818    type Item = Result<UsageWatcher2Request, fidl::Error>;
17819
17820    fn poll_next(
17821        mut self: std::pin::Pin<&mut Self>,
17822        cx: &mut std::task::Context<'_>,
17823    ) -> std::task::Poll<Option<Self::Item>> {
17824        let this = &mut *self;
17825        if this.inner.check_shutdown(cx) {
17826            this.is_terminated = true;
17827            return std::task::Poll::Ready(None);
17828        }
17829        if this.is_terminated {
17830            panic!("polled UsageWatcher2RequestStream after completion");
17831        }
17832        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17833            |bytes, handles| {
17834                match this.inner.channel().read_etc(cx, bytes, handles) {
17835                    std::task::Poll::Ready(Ok(())) => {}
17836                    std::task::Poll::Pending => return std::task::Poll::Pending,
17837                    std::task::Poll::Ready(Err(None)) => {
17838                        this.is_terminated = true;
17839                        return std::task::Poll::Ready(None);
17840                    }
17841                    std::task::Poll::Ready(Err(Some(e))) => {
17842                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17843                            e.into(),
17844                        ))));
17845                    }
17846                }
17847
17848                // A message has been received from the channel
17849                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17850
17851                std::task::Poll::Ready(Some(match header.ordinal {
17852                0xca31a8b13c324d4 => {
17853                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
17854                    let mut req = fidl::new_empty!(UsageWatcher2OnStateChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
17855                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
17856                    let control_handle = UsageWatcher2ControlHandle {
17857                        inner: this.inner.clone(),
17858                    };
17859                    Ok(UsageWatcher2Request::OnStateChanged {usage: req.usage,
17860state: req.state,
17861
17862                        responder: UsageWatcher2OnStateChangedResponder {
17863                            control_handle: std::mem::ManuallyDrop::new(control_handle),
17864                            tx_id: header.tx_id,
17865                        },
17866                    })
17867                }
17868                _ => Err(fidl::Error::UnknownOrdinal {
17869                    ordinal: header.ordinal,
17870                    protocol_name: <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17871                }),
17872            }))
17873            },
17874        )
17875    }
17876}
17877
17878#[derive(Debug)]
17879pub enum UsageWatcher2Request {
17880    /// Called on first connection and whenever the watched usage changes. The provided
17881    /// usage will always be the bound usage; it is provided so that an implementation of
17882    /// this protocol may be bound to more than one usage.
17883    ///
17884    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17885    /// events will eventually be disconnected.
17886    OnStateChanged {
17887        usage: Usage2,
17888        state: UsageState,
17889        responder: UsageWatcher2OnStateChangedResponder,
17890    },
17891}
17892
17893impl UsageWatcher2Request {
17894    #[allow(irrefutable_let_patterns)]
17895    pub fn into_on_state_changed(
17896        self,
17897    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
17898        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
17899            Some((usage, state, responder))
17900        } else {
17901            None
17902        }
17903    }
17904
17905    /// Name of the method defined in FIDL
17906    pub fn method_name(&self) -> &'static str {
17907        match *self {
17908            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
17909        }
17910    }
17911}
17912
17913#[derive(Debug, Clone)]
17914pub struct UsageWatcher2ControlHandle {
17915    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17916}
17917
17918impl fdomain_client::fidl::ControlHandle for UsageWatcher2ControlHandle {
17919    fn shutdown(&self) {
17920        self.inner.shutdown()
17921    }
17922
17923    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17924        self.inner.shutdown_with_epitaph(status)
17925    }
17926
17927    fn is_closed(&self) -> bool {
17928        self.inner.channel().is_closed()
17929    }
17930    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
17931        self.inner.channel().on_closed()
17932    }
17933}
17934
17935impl UsageWatcher2ControlHandle {}
17936
17937#[must_use = "FIDL methods require a response to be sent"]
17938#[derive(Debug)]
17939pub struct UsageWatcher2OnStateChangedResponder {
17940    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
17941    tx_id: u32,
17942}
17943
17944/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
17945/// if the responder is dropped without sending a response, so that the client
17946/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17947impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
17948    fn drop(&mut self) {
17949        self.control_handle.shutdown();
17950        // Safety: drops once, never accessed again
17951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17952    }
17953}
17954
17955impl fdomain_client::fidl::Responder for UsageWatcher2OnStateChangedResponder {
17956    type ControlHandle = UsageWatcher2ControlHandle;
17957
17958    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
17959        &self.control_handle
17960    }
17961
17962    fn drop_without_shutdown(mut self) {
17963        // Safety: drops once, never accessed again due to mem::forget
17964        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17965        // Prevent Drop from running (which would shut down the channel)
17966        std::mem::forget(self);
17967    }
17968}
17969
17970impl UsageWatcher2OnStateChangedResponder {
17971    /// Sends a response to the FIDL transaction.
17972    ///
17973    /// Sets the channel to shutdown if an error occurs.
17974    pub fn send(self) -> Result<(), fidl::Error> {
17975        let _result = self.send_raw();
17976        if _result.is_err() {
17977            self.control_handle.shutdown();
17978        }
17979        self.drop_without_shutdown();
17980        _result
17981    }
17982
17983    /// Similar to "send" but does not shutdown the channel if an error occurs.
17984    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17985        let _result = self.send_raw();
17986        self.drop_without_shutdown();
17987        _result
17988    }
17989
17990    fn send_raw(&self) -> Result<(), fidl::Error> {
17991        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17992            (),
17993            self.tx_id,
17994            0xca31a8b13c324d4,
17995            fidl::encoding::DynamicFlags::empty(),
17996        )
17997    }
17998}
17999
18000mod internal {
18001    use super::*;
18002
18003    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
18004        type Borrowed<'a> = &'a mut Self;
18005        fn take_or_borrow<'a>(
18006            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18007        ) -> Self::Borrowed<'a> {
18008            value
18009        }
18010    }
18011
18012    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
18013        type Owned = Self;
18014
18015        #[inline(always)]
18016        fn inline_align(_context: fidl::encoding::Context) -> usize {
18017            4
18018        }
18019
18020        #[inline(always)]
18021        fn inline_size(_context: fidl::encoding::Context) -> usize {
18022            4
18023        }
18024    }
18025
18026    unsafe impl
18027        fidl::encoding::Encode<
18028            AudioCapturerBindGainControlRequest,
18029            fdomain_client::fidl::FDomainResourceDialect,
18030        > for &mut AudioCapturerBindGainControlRequest
18031    {
18032        #[inline]
18033        unsafe fn encode(
18034            self,
18035            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18036            offset: usize,
18037            _depth: fidl::encoding::Depth,
18038        ) -> fidl::Result<()> {
18039            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
18040            // Delegate to tuple encoding.
18041            fidl::encoding::Encode::<
18042                AudioCapturerBindGainControlRequest,
18043                fdomain_client::fidl::FDomainResourceDialect,
18044            >::encode(
18045                (<fidl::encoding::Endpoint<
18046                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18047                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18048                    &mut self.gain_control_request,
18049                ),),
18050                encoder,
18051                offset,
18052                _depth,
18053            )
18054        }
18055    }
18056    unsafe impl<
18057        T0: fidl::encoding::Encode<
18058                fidl::encoding::Endpoint<
18059                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18060                >,
18061                fdomain_client::fidl::FDomainResourceDialect,
18062            >,
18063    >
18064        fidl::encoding::Encode<
18065            AudioCapturerBindGainControlRequest,
18066            fdomain_client::fidl::FDomainResourceDialect,
18067        > for (T0,)
18068    {
18069        #[inline]
18070        unsafe fn encode(
18071            self,
18072            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18073            offset: usize,
18074            depth: fidl::encoding::Depth,
18075        ) -> fidl::Result<()> {
18076            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
18077            // Zero out padding regions. There's no need to apply masks
18078            // because the unmasked parts will be overwritten by fields.
18079            // Write the fields.
18080            self.0.encode(encoder, offset + 0, depth)?;
18081            Ok(())
18082        }
18083    }
18084
18085    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18086        for AudioCapturerBindGainControlRequest
18087    {
18088        #[inline(always)]
18089        fn new_empty() -> Self {
18090            Self {
18091                gain_control_request: fidl::new_empty!(
18092                    fidl::encoding::Endpoint<
18093                        fdomain_client::fidl::ServerEnd<
18094                            fdomain_fuchsia_media_audio::GainControlMarker,
18095                        >,
18096                    >,
18097                    fdomain_client::fidl::FDomainResourceDialect
18098                ),
18099            }
18100        }
18101
18102        #[inline]
18103        unsafe fn decode(
18104            &mut self,
18105            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18106            offset: usize,
18107            _depth: fidl::encoding::Depth,
18108        ) -> fidl::Result<()> {
18109            decoder.debug_check_bounds::<Self>(offset);
18110            // Verify that padding bytes are zero.
18111            fidl::decode!(
18112                fidl::encoding::Endpoint<
18113                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18114                >,
18115                fdomain_client::fidl::FDomainResourceDialect,
18116                &mut self.gain_control_request,
18117                decoder,
18118                offset + 0,
18119                _depth
18120            )?;
18121            Ok(())
18122        }
18123    }
18124
18125    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
18126        type Borrowed<'a> = &'a mut Self;
18127        fn take_or_borrow<'a>(
18128            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18129        ) -> Self::Borrowed<'a> {
18130            value
18131        }
18132    }
18133
18134    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
18135        type Owned = Self;
18136
18137        #[inline(always)]
18138        fn inline_align(_context: fidl::encoding::Context) -> usize {
18139            4
18140        }
18141
18142        #[inline(always)]
18143        fn inline_size(_context: fidl::encoding::Context) -> usize {
18144            4
18145        }
18146    }
18147
18148    unsafe impl
18149        fidl::encoding::Encode<
18150            AudioCapturerGetReferenceClockResponse,
18151            fdomain_client::fidl::FDomainResourceDialect,
18152        > for &mut AudioCapturerGetReferenceClockResponse
18153    {
18154        #[inline]
18155        unsafe fn encode(
18156            self,
18157            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18158            offset: usize,
18159            _depth: fidl::encoding::Depth,
18160        ) -> fidl::Result<()> {
18161            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
18162            // Delegate to tuple encoding.
18163            fidl::encoding::Encode::<
18164                AudioCapturerGetReferenceClockResponse,
18165                fdomain_client::fidl::FDomainResourceDialect,
18166            >::encode(
18167                (<fidl::encoding::HandleType<
18168                    fdomain_client::Clock,
18169                    { fidl::ObjectType::CLOCK.into_raw() },
18170                    2147483648,
18171                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18172                    &mut self.reference_clock,
18173                ),),
18174                encoder,
18175                offset,
18176                _depth,
18177            )
18178        }
18179    }
18180    unsafe impl<
18181        T0: fidl::encoding::Encode<
18182                fidl::encoding::HandleType<
18183                    fdomain_client::Clock,
18184                    { fidl::ObjectType::CLOCK.into_raw() },
18185                    2147483648,
18186                >,
18187                fdomain_client::fidl::FDomainResourceDialect,
18188            >,
18189    >
18190        fidl::encoding::Encode<
18191            AudioCapturerGetReferenceClockResponse,
18192            fdomain_client::fidl::FDomainResourceDialect,
18193        > for (T0,)
18194    {
18195        #[inline]
18196        unsafe fn encode(
18197            self,
18198            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18199            offset: usize,
18200            depth: fidl::encoding::Depth,
18201        ) -> fidl::Result<()> {
18202            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
18203            // Zero out padding regions. There's no need to apply masks
18204            // because the unmasked parts will be overwritten by fields.
18205            // Write the fields.
18206            self.0.encode(encoder, offset + 0, depth)?;
18207            Ok(())
18208        }
18209    }
18210
18211    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18212        for AudioCapturerGetReferenceClockResponse
18213    {
18214        #[inline(always)]
18215        fn new_empty() -> Self {
18216            Self {
18217                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
18218            }
18219        }
18220
18221        #[inline]
18222        unsafe fn decode(
18223            &mut self,
18224            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18225            offset: usize,
18226            _depth: fidl::encoding::Depth,
18227        ) -> fidl::Result<()> {
18228            decoder.debug_check_bounds::<Self>(offset);
18229            // Verify that padding bytes are zero.
18230            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
18231            Ok(())
18232        }
18233    }
18234
18235    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
18236        type Borrowed<'a> = &'a mut Self;
18237        fn take_or_borrow<'a>(
18238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18239        ) -> Self::Borrowed<'a> {
18240            value
18241        }
18242    }
18243
18244    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
18245        type Owned = Self;
18246
18247        #[inline(always)]
18248        fn inline_align(_context: fidl::encoding::Context) -> usize {
18249            4
18250        }
18251
18252        #[inline(always)]
18253        fn inline_size(_context: fidl::encoding::Context) -> usize {
18254            4
18255        }
18256    }
18257
18258    unsafe impl
18259        fidl::encoding::Encode<
18260            AudioCapturerSetReferenceClockRequest,
18261            fdomain_client::fidl::FDomainResourceDialect,
18262        > for &mut AudioCapturerSetReferenceClockRequest
18263    {
18264        #[inline]
18265        unsafe fn encode(
18266            self,
18267            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18268            offset: usize,
18269            _depth: fidl::encoding::Depth,
18270        ) -> fidl::Result<()> {
18271            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
18272            // Delegate to tuple encoding.
18273            fidl::encoding::Encode::<
18274                AudioCapturerSetReferenceClockRequest,
18275                fdomain_client::fidl::FDomainResourceDialect,
18276            >::encode(
18277                (<fidl::encoding::Optional<
18278                    fidl::encoding::HandleType<
18279                        fdomain_client::Clock,
18280                        { fidl::ObjectType::CLOCK.into_raw() },
18281                        2147483648,
18282                    >,
18283                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18284                    &mut self.reference_clock,
18285                ),),
18286                encoder,
18287                offset,
18288                _depth,
18289            )
18290        }
18291    }
18292    unsafe impl<
18293        T0: fidl::encoding::Encode<
18294                fidl::encoding::Optional<
18295                    fidl::encoding::HandleType<
18296                        fdomain_client::Clock,
18297                        { fidl::ObjectType::CLOCK.into_raw() },
18298                        2147483648,
18299                    >,
18300                >,
18301                fdomain_client::fidl::FDomainResourceDialect,
18302            >,
18303    >
18304        fidl::encoding::Encode<
18305            AudioCapturerSetReferenceClockRequest,
18306            fdomain_client::fidl::FDomainResourceDialect,
18307        > for (T0,)
18308    {
18309        #[inline]
18310        unsafe fn encode(
18311            self,
18312            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18313            offset: usize,
18314            depth: fidl::encoding::Depth,
18315        ) -> fidl::Result<()> {
18316            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
18317            // Zero out padding regions. There's no need to apply masks
18318            // because the unmasked parts will be overwritten by fields.
18319            // Write the fields.
18320            self.0.encode(encoder, offset + 0, depth)?;
18321            Ok(())
18322        }
18323    }
18324
18325    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18326        for AudioCapturerSetReferenceClockRequest
18327    {
18328        #[inline(always)]
18329        fn new_empty() -> Self {
18330            Self {
18331                reference_clock: fidl::new_empty!(
18332                    fidl::encoding::Optional<
18333                        fidl::encoding::HandleType<
18334                            fdomain_client::Clock,
18335                            { fidl::ObjectType::CLOCK.into_raw() },
18336                            2147483648,
18337                        >,
18338                    >,
18339                    fdomain_client::fidl::FDomainResourceDialect
18340                ),
18341            }
18342        }
18343
18344        #[inline]
18345        unsafe fn decode(
18346            &mut self,
18347            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18348            offset: usize,
18349            _depth: fidl::encoding::Depth,
18350        ) -> fidl::Result<()> {
18351            decoder.debug_check_bounds::<Self>(offset);
18352            // Verify that padding bytes are zero.
18353            fidl::decode!(
18354                fidl::encoding::Optional<
18355                    fidl::encoding::HandleType<
18356                        fdomain_client::Clock,
18357                        { fidl::ObjectType::CLOCK.into_raw() },
18358                        2147483648,
18359                    >,
18360                >,
18361                fdomain_client::fidl::FDomainResourceDialect,
18362                &mut self.reference_clock,
18363                decoder,
18364                offset + 0,
18365                _depth
18366            )?;
18367            Ok(())
18368        }
18369    }
18370
18371    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
18372        type Borrowed<'a> = &'a mut Self;
18373        fn take_or_borrow<'a>(
18374            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18375        ) -> Self::Borrowed<'a> {
18376            value
18377        }
18378    }
18379
18380    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
18381        type Owned = Self;
18382
18383        #[inline(always)]
18384        fn inline_align(_context: fidl::encoding::Context) -> usize {
18385            4
18386        }
18387
18388        #[inline(always)]
18389        fn inline_size(_context: fidl::encoding::Context) -> usize {
18390            4
18391        }
18392    }
18393
18394    unsafe impl
18395        fidl::encoding::Encode<
18396            AudioConsumerBindVolumeControlRequest,
18397            fdomain_client::fidl::FDomainResourceDialect,
18398        > for &mut AudioConsumerBindVolumeControlRequest
18399    {
18400        #[inline]
18401        unsafe fn encode(
18402            self,
18403            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18404            offset: usize,
18405            _depth: fidl::encoding::Depth,
18406        ) -> fidl::Result<()> {
18407            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
18408            // Delegate to tuple encoding.
18409            fidl::encoding::Encode::<
18410                AudioConsumerBindVolumeControlRequest,
18411                fdomain_client::fidl::FDomainResourceDialect,
18412            >::encode(
18413                (<fidl::encoding::Endpoint<
18414                    fdomain_client::fidl::ServerEnd<
18415                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18416                    >,
18417                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18418                    &mut self.volume_control_request,
18419                ),),
18420                encoder,
18421                offset,
18422                _depth,
18423            )
18424        }
18425    }
18426    unsafe impl<
18427        T0: fidl::encoding::Encode<
18428                fidl::encoding::Endpoint<
18429                    fdomain_client::fidl::ServerEnd<
18430                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18431                    >,
18432                >,
18433                fdomain_client::fidl::FDomainResourceDialect,
18434            >,
18435    >
18436        fidl::encoding::Encode<
18437            AudioConsumerBindVolumeControlRequest,
18438            fdomain_client::fidl::FDomainResourceDialect,
18439        > for (T0,)
18440    {
18441        #[inline]
18442        unsafe fn encode(
18443            self,
18444            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18445            offset: usize,
18446            depth: fidl::encoding::Depth,
18447        ) -> fidl::Result<()> {
18448            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
18449            // Zero out padding regions. There's no need to apply masks
18450            // because the unmasked parts will be overwritten by fields.
18451            // Write the fields.
18452            self.0.encode(encoder, offset + 0, depth)?;
18453            Ok(())
18454        }
18455    }
18456
18457    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18458        for AudioConsumerBindVolumeControlRequest
18459    {
18460        #[inline(always)]
18461        fn new_empty() -> Self {
18462            Self {
18463                volume_control_request: fidl::new_empty!(
18464                    fidl::encoding::Endpoint<
18465                        fdomain_client::fidl::ServerEnd<
18466                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18467                        >,
18468                    >,
18469                    fdomain_client::fidl::FDomainResourceDialect
18470                ),
18471            }
18472        }
18473
18474        #[inline]
18475        unsafe fn decode(
18476            &mut self,
18477            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18478            offset: usize,
18479            _depth: fidl::encoding::Depth,
18480        ) -> fidl::Result<()> {
18481            decoder.debug_check_bounds::<Self>(offset);
18482            // Verify that padding bytes are zero.
18483            fidl::decode!(
18484                fidl::encoding::Endpoint<
18485                    fdomain_client::fidl::ServerEnd<
18486                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18487                    >,
18488                >,
18489                fdomain_client::fidl::FDomainResourceDialect,
18490                &mut self.volume_control_request,
18491                decoder,
18492                offset + 0,
18493                _depth
18494            )?;
18495            Ok(())
18496        }
18497    }
18498
18499    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
18500        type Borrowed<'a> = &'a mut Self;
18501        fn take_or_borrow<'a>(
18502            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18503        ) -> Self::Borrowed<'a> {
18504            value
18505        }
18506    }
18507
18508    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
18509        type Owned = Self;
18510
18511        #[inline(always)]
18512        fn inline_align(_context: fidl::encoding::Context) -> usize {
18513            8
18514        }
18515
18516        #[inline(always)]
18517        fn inline_size(_context: fidl::encoding::Context) -> usize {
18518            48
18519        }
18520    }
18521
18522    unsafe impl
18523        fidl::encoding::Encode<
18524            AudioConsumerCreateStreamSinkRequest,
18525            fdomain_client::fidl::FDomainResourceDialect,
18526        > for &mut AudioConsumerCreateStreamSinkRequest
18527    {
18528        #[inline]
18529        unsafe fn encode(
18530            self,
18531            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18532            offset: usize,
18533            _depth: fidl::encoding::Depth,
18534        ) -> fidl::Result<()> {
18535            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
18536            // Delegate to tuple encoding.
18537            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
18538                (
18539                    <fidl::encoding::Vector<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
18540                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
18541                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
18542                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
18543                ),
18544                encoder, offset, _depth
18545            )
18546        }
18547    }
18548    unsafe impl<
18549        T0: fidl::encoding::Encode<
18550                fidl::encoding::Vector<
18551                    fidl::encoding::HandleType<
18552                        fdomain_client::Vmo,
18553                        { fidl::ObjectType::VMO.into_raw() },
18554                        2147483648,
18555                    >,
18556                    16,
18557                >,
18558                fdomain_client::fidl::FDomainResourceDialect,
18559            >,
18560        T1: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
18561        T2: fidl::encoding::Encode<
18562                fidl::encoding::Boxed<Compression>,
18563                fdomain_client::fidl::FDomainResourceDialect,
18564            >,
18565        T3: fidl::encoding::Encode<
18566                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18567                fdomain_client::fidl::FDomainResourceDialect,
18568            >,
18569    >
18570        fidl::encoding::Encode<
18571            AudioConsumerCreateStreamSinkRequest,
18572            fdomain_client::fidl::FDomainResourceDialect,
18573        > for (T0, T1, T2, T3)
18574    {
18575        #[inline]
18576        unsafe fn encode(
18577            self,
18578            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18579            offset: usize,
18580            depth: fidl::encoding::Depth,
18581        ) -> fidl::Result<()> {
18582            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
18583            // Zero out padding regions. There's no need to apply masks
18584            // because the unmasked parts will be overwritten by fields.
18585            unsafe {
18586                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
18587                (ptr as *mut u64).write_unaligned(0);
18588            }
18589            unsafe {
18590                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
18591                (ptr as *mut u64).write_unaligned(0);
18592            }
18593            // Write the fields.
18594            self.0.encode(encoder, offset + 0, depth)?;
18595            self.1.encode(encoder, offset + 16, depth)?;
18596            self.2.encode(encoder, offset + 32, depth)?;
18597            self.3.encode(encoder, offset + 40, depth)?;
18598            Ok(())
18599        }
18600    }
18601
18602    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18603        for AudioConsumerCreateStreamSinkRequest
18604    {
18605        #[inline(always)]
18606        fn new_empty() -> Self {
18607            Self {
18608                buffers: fidl::new_empty!(
18609                    fidl::encoding::Vector<
18610                        fidl::encoding::HandleType<
18611                            fdomain_client::Vmo,
18612                            { fidl::ObjectType::VMO.into_raw() },
18613                            2147483648,
18614                        >,
18615                        16,
18616                    >,
18617                    fdomain_client::fidl::FDomainResourceDialect
18618                ),
18619                stream_type: fidl::new_empty!(
18620                    AudioStreamType,
18621                    fdomain_client::fidl::FDomainResourceDialect
18622                ),
18623                compression: fidl::new_empty!(
18624                    fidl::encoding::Boxed<Compression>,
18625                    fdomain_client::fidl::FDomainResourceDialect
18626                ),
18627                stream_sink_request: fidl::new_empty!(
18628                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18629                    fdomain_client::fidl::FDomainResourceDialect
18630                ),
18631            }
18632        }
18633
18634        #[inline]
18635        unsafe fn decode(
18636            &mut self,
18637            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18638            offset: usize,
18639            _depth: fidl::encoding::Depth,
18640        ) -> fidl::Result<()> {
18641            decoder.debug_check_bounds::<Self>(offset);
18642            // Verify that padding bytes are zero.
18643            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
18644            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18645            let mask = 0xffffffff00000000u64;
18646            let maskedval = padval & mask;
18647            if maskedval != 0 {
18648                return Err(fidl::Error::NonZeroPadding {
18649                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
18650                });
18651            }
18652            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
18653            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18654            let mask = 0xffffffff00000000u64;
18655            let maskedval = padval & mask;
18656            if maskedval != 0 {
18657                return Err(fidl::Error::NonZeroPadding {
18658                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
18659                });
18660            }
18661            fidl::decode!(
18662                fidl::encoding::Vector<
18663                    fidl::encoding::HandleType<
18664                        fdomain_client::Vmo,
18665                        { fidl::ObjectType::VMO.into_raw() },
18666                        2147483648,
18667                    >,
18668                    16,
18669                >,
18670                fdomain_client::fidl::FDomainResourceDialect,
18671                &mut self.buffers,
18672                decoder,
18673                offset + 0,
18674                _depth
18675            )?;
18676            fidl::decode!(
18677                AudioStreamType,
18678                fdomain_client::fidl::FDomainResourceDialect,
18679                &mut self.stream_type,
18680                decoder,
18681                offset + 16,
18682                _depth
18683            )?;
18684            fidl::decode!(
18685                fidl::encoding::Boxed<Compression>,
18686                fdomain_client::fidl::FDomainResourceDialect,
18687                &mut self.compression,
18688                decoder,
18689                offset + 32,
18690                _depth
18691            )?;
18692            fidl::decode!(
18693                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18694                fdomain_client::fidl::FDomainResourceDialect,
18695                &mut self.stream_sink_request,
18696                decoder,
18697                offset + 40,
18698                _depth
18699            )?;
18700            Ok(())
18701        }
18702    }
18703
18704    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
18705        type Borrowed<'a> = &'a mut Self;
18706        fn take_or_borrow<'a>(
18707            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18708        ) -> Self::Borrowed<'a> {
18709            value
18710        }
18711    }
18712
18713    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
18714        type Owned = Self;
18715
18716        #[inline(always)]
18717        fn inline_align(_context: fidl::encoding::Context) -> usize {
18718            8
18719        }
18720
18721        #[inline(always)]
18722        fn inline_size(_context: fidl::encoding::Context) -> usize {
18723            24
18724        }
18725    }
18726
18727    unsafe impl
18728        fidl::encoding::Encode<
18729            AudioCoreBindUsageVolumeControl2Request,
18730            fdomain_client::fidl::FDomainResourceDialect,
18731        > for &mut AudioCoreBindUsageVolumeControl2Request
18732    {
18733        #[inline]
18734        unsafe fn encode(
18735            self,
18736            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18737            offset: usize,
18738            _depth: fidl::encoding::Depth,
18739        ) -> fidl::Result<()> {
18740            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
18741            // Delegate to tuple encoding.
18742            fidl::encoding::Encode::<
18743                AudioCoreBindUsageVolumeControl2Request,
18744                fdomain_client::fidl::FDomainResourceDialect,
18745            >::encode(
18746                (
18747                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
18748                    <fidl::encoding::Endpoint<
18749                        fdomain_client::fidl::ServerEnd<
18750                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18751                        >,
18752                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18753                        &mut self.volume_control,
18754                    ),
18755                ),
18756                encoder,
18757                offset,
18758                _depth,
18759            )
18760        }
18761    }
18762    unsafe impl<
18763        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
18764        T1: fidl::encoding::Encode<
18765                fidl::encoding::Endpoint<
18766                    fdomain_client::fidl::ServerEnd<
18767                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18768                    >,
18769                >,
18770                fdomain_client::fidl::FDomainResourceDialect,
18771            >,
18772    >
18773        fidl::encoding::Encode<
18774            AudioCoreBindUsageVolumeControl2Request,
18775            fdomain_client::fidl::FDomainResourceDialect,
18776        > for (T0, T1)
18777    {
18778        #[inline]
18779        unsafe fn encode(
18780            self,
18781            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18782            offset: usize,
18783            depth: fidl::encoding::Depth,
18784        ) -> fidl::Result<()> {
18785            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
18786            // Zero out padding regions. There's no need to apply masks
18787            // because the unmasked parts will be overwritten by fields.
18788            unsafe {
18789                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
18790                (ptr as *mut u64).write_unaligned(0);
18791            }
18792            // Write the fields.
18793            self.0.encode(encoder, offset + 0, depth)?;
18794            self.1.encode(encoder, offset + 16, depth)?;
18795            Ok(())
18796        }
18797    }
18798
18799    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18800        for AudioCoreBindUsageVolumeControl2Request
18801    {
18802        #[inline(always)]
18803        fn new_empty() -> Self {
18804            Self {
18805                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
18806                volume_control: fidl::new_empty!(
18807                    fidl::encoding::Endpoint<
18808                        fdomain_client::fidl::ServerEnd<
18809                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18810                        >,
18811                    >,
18812                    fdomain_client::fidl::FDomainResourceDialect
18813                ),
18814            }
18815        }
18816
18817        #[inline]
18818        unsafe fn decode(
18819            &mut self,
18820            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18821            offset: usize,
18822            _depth: fidl::encoding::Depth,
18823        ) -> fidl::Result<()> {
18824            decoder.debug_check_bounds::<Self>(offset);
18825            // Verify that padding bytes are zero.
18826            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
18827            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18828            let mask = 0xffffffff00000000u64;
18829            let maskedval = padval & mask;
18830            if maskedval != 0 {
18831                return Err(fidl::Error::NonZeroPadding {
18832                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
18833                });
18834            }
18835            fidl::decode!(
18836                Usage2,
18837                fdomain_client::fidl::FDomainResourceDialect,
18838                &mut self.usage,
18839                decoder,
18840                offset + 0,
18841                _depth
18842            )?;
18843            fidl::decode!(
18844                fidl::encoding::Endpoint<
18845                    fdomain_client::fidl::ServerEnd<
18846                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18847                    >,
18848                >,
18849                fdomain_client::fidl::FDomainResourceDialect,
18850                &mut self.volume_control,
18851                decoder,
18852                offset + 16,
18853                _depth
18854            )?;
18855            Ok(())
18856        }
18857    }
18858
18859    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
18860        type Borrowed<'a> = &'a mut Self;
18861        fn take_or_borrow<'a>(
18862            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18863        ) -> Self::Borrowed<'a> {
18864            value
18865        }
18866    }
18867
18868    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
18869        type Owned = Self;
18870
18871        #[inline(always)]
18872        fn inline_align(_context: fidl::encoding::Context) -> usize {
18873            8
18874        }
18875
18876        #[inline(always)]
18877        fn inline_size(_context: fidl::encoding::Context) -> usize {
18878            24
18879        }
18880    }
18881
18882    unsafe impl
18883        fidl::encoding::Encode<
18884            AudioCoreBindUsageVolumeControlRequest,
18885            fdomain_client::fidl::FDomainResourceDialect,
18886        > for &mut AudioCoreBindUsageVolumeControlRequest
18887    {
18888        #[inline]
18889        unsafe fn encode(
18890            self,
18891            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18892            offset: usize,
18893            _depth: fidl::encoding::Depth,
18894        ) -> fidl::Result<()> {
18895            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
18896            // Delegate to tuple encoding.
18897            fidl::encoding::Encode::<
18898                AudioCoreBindUsageVolumeControlRequest,
18899                fdomain_client::fidl::FDomainResourceDialect,
18900            >::encode(
18901                (
18902                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
18903                    <fidl::encoding::Endpoint<
18904                        fdomain_client::fidl::ServerEnd<
18905                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18906                        >,
18907                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18908                        &mut self.volume_control,
18909                    ),
18910                ),
18911                encoder,
18912                offset,
18913                _depth,
18914            )
18915        }
18916    }
18917    unsafe impl<
18918        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
18919        T1: fidl::encoding::Encode<
18920                fidl::encoding::Endpoint<
18921                    fdomain_client::fidl::ServerEnd<
18922                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18923                    >,
18924                >,
18925                fdomain_client::fidl::FDomainResourceDialect,
18926            >,
18927    >
18928        fidl::encoding::Encode<
18929            AudioCoreBindUsageVolumeControlRequest,
18930            fdomain_client::fidl::FDomainResourceDialect,
18931        > for (T0, T1)
18932    {
18933        #[inline]
18934        unsafe fn encode(
18935            self,
18936            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18937            offset: usize,
18938            depth: fidl::encoding::Depth,
18939        ) -> fidl::Result<()> {
18940            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
18941            // Zero out padding regions. There's no need to apply masks
18942            // because the unmasked parts will be overwritten by fields.
18943            unsafe {
18944                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
18945                (ptr as *mut u64).write_unaligned(0);
18946            }
18947            // Write the fields.
18948            self.0.encode(encoder, offset + 0, depth)?;
18949            self.1.encode(encoder, offset + 16, depth)?;
18950            Ok(())
18951        }
18952    }
18953
18954    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18955        for AudioCoreBindUsageVolumeControlRequest
18956    {
18957        #[inline(always)]
18958        fn new_empty() -> Self {
18959            Self {
18960                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
18961                volume_control: fidl::new_empty!(
18962                    fidl::encoding::Endpoint<
18963                        fdomain_client::fidl::ServerEnd<
18964                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18965                        >,
18966                    >,
18967                    fdomain_client::fidl::FDomainResourceDialect
18968                ),
18969            }
18970        }
18971
18972        #[inline]
18973        unsafe fn decode(
18974            &mut self,
18975            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18976            offset: usize,
18977            _depth: fidl::encoding::Depth,
18978        ) -> fidl::Result<()> {
18979            decoder.debug_check_bounds::<Self>(offset);
18980            // Verify that padding bytes are zero.
18981            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
18982            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18983            let mask = 0xffffffff00000000u64;
18984            let maskedval = padval & mask;
18985            if maskedval != 0 {
18986                return Err(fidl::Error::NonZeroPadding {
18987                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
18988                });
18989            }
18990            fidl::decode!(
18991                Usage,
18992                fdomain_client::fidl::FDomainResourceDialect,
18993                &mut self.usage,
18994                decoder,
18995                offset + 0,
18996                _depth
18997            )?;
18998            fidl::decode!(
18999                fidl::encoding::Endpoint<
19000                    fdomain_client::fidl::ServerEnd<
19001                        fdomain_fuchsia_media_audio::VolumeControlMarker,
19002                    >,
19003                >,
19004                fdomain_client::fidl::FDomainResourceDialect,
19005                &mut self.volume_control,
19006                decoder,
19007                offset + 16,
19008                _depth
19009            )?;
19010            Ok(())
19011        }
19012    }
19013
19014    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
19015        type Borrowed<'a> = &'a mut Self;
19016        fn take_or_borrow<'a>(
19017            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19018        ) -> Self::Borrowed<'a> {
19019            value
19020        }
19021    }
19022
19023    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
19024        type Owned = Self;
19025
19026        #[inline(always)]
19027        fn inline_align(_context: fidl::encoding::Context) -> usize {
19028            4
19029        }
19030
19031        #[inline(always)]
19032        fn inline_size(_context: fidl::encoding::Context) -> usize {
19033            8
19034        }
19035    }
19036
19037    unsafe impl
19038        fidl::encoding::Encode<
19039            AudioCoreCreateAudioCapturerRequest,
19040            fdomain_client::fidl::FDomainResourceDialect,
19041        > for &mut AudioCoreCreateAudioCapturerRequest
19042    {
19043        #[inline]
19044        unsafe fn encode(
19045            self,
19046            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19047            offset: usize,
19048            _depth: fidl::encoding::Depth,
19049        ) -> fidl::Result<()> {
19050            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
19051            // Delegate to tuple encoding.
19052            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19053                (
19054                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
19055                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
19056                ),
19057                encoder, offset, _depth
19058            )
19059        }
19060    }
19061    unsafe impl<
19062        T0: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19063        T1: fidl::encoding::Encode<
19064                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19065                fdomain_client::fidl::FDomainResourceDialect,
19066            >,
19067    >
19068        fidl::encoding::Encode<
19069            AudioCoreCreateAudioCapturerRequest,
19070            fdomain_client::fidl::FDomainResourceDialect,
19071        > for (T0, T1)
19072    {
19073        #[inline]
19074        unsafe fn encode(
19075            self,
19076            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19077            offset: usize,
19078            depth: fidl::encoding::Depth,
19079        ) -> fidl::Result<()> {
19080            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
19081            // Zero out padding regions. There's no need to apply masks
19082            // because the unmasked parts will be overwritten by fields.
19083            unsafe {
19084                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
19085                (ptr as *mut u32).write_unaligned(0);
19086            }
19087            // Write the fields.
19088            self.0.encode(encoder, offset + 0, depth)?;
19089            self.1.encode(encoder, offset + 4, depth)?;
19090            Ok(())
19091        }
19092    }
19093
19094    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19095        for AudioCoreCreateAudioCapturerRequest
19096    {
19097        #[inline(always)]
19098        fn new_empty() -> Self {
19099            Self {
19100                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19101                audio_in_request: fidl::new_empty!(
19102                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19103                    fdomain_client::fidl::FDomainResourceDialect
19104                ),
19105            }
19106        }
19107
19108        #[inline]
19109        unsafe fn decode(
19110            &mut self,
19111            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19112            offset: usize,
19113            _depth: fidl::encoding::Depth,
19114        ) -> fidl::Result<()> {
19115            decoder.debug_check_bounds::<Self>(offset);
19116            // Verify that padding bytes are zero.
19117            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
19118            let padval = unsafe { (ptr as *const u32).read_unaligned() };
19119            let mask = 0xffffff00u32;
19120            let maskedval = padval & mask;
19121            if maskedval != 0 {
19122                return Err(fidl::Error::NonZeroPadding {
19123                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
19124                });
19125            }
19126            fidl::decode!(
19127                bool,
19128                fdomain_client::fidl::FDomainResourceDialect,
19129                &mut self.loopback,
19130                decoder,
19131                offset + 0,
19132                _depth
19133            )?;
19134            fidl::decode!(
19135                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19136                fdomain_client::fidl::FDomainResourceDialect,
19137                &mut self.audio_in_request,
19138                decoder,
19139                offset + 4,
19140                _depth
19141            )?;
19142            Ok(())
19143        }
19144    }
19145
19146    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
19147        type Borrowed<'a> = &'a mut Self;
19148        fn take_or_borrow<'a>(
19149            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19150        ) -> Self::Borrowed<'a> {
19151            value
19152        }
19153    }
19154
19155    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
19156        type Owned = Self;
19157
19158        #[inline(always)]
19159        fn inline_align(_context: fidl::encoding::Context) -> usize {
19160            8
19161        }
19162
19163        #[inline(always)]
19164        fn inline_size(_context: fidl::encoding::Context) -> usize {
19165            40
19166        }
19167    }
19168
19169    unsafe impl
19170        fidl::encoding::Encode<
19171            AudioCoreCreateAudioCapturerWithConfigurationRequest,
19172            fdomain_client::fidl::FDomainResourceDialect,
19173        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
19174    {
19175        #[inline]
19176        unsafe fn encode(
19177            self,
19178            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19179            offset: usize,
19180            _depth: fidl::encoding::Depth,
19181        ) -> fidl::Result<()> {
19182            encoder
19183                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
19184            // Delegate to tuple encoding.
19185            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19186                (
19187                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
19188                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
19189                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
19190                ),
19191                encoder, offset, _depth
19192            )
19193        }
19194    }
19195    unsafe impl<
19196        T0: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
19197        T1: fidl::encoding::Encode<
19198                AudioCapturerConfiguration,
19199                fdomain_client::fidl::FDomainResourceDialect,
19200            >,
19201        T2: fidl::encoding::Encode<
19202                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19203                fdomain_client::fidl::FDomainResourceDialect,
19204            >,
19205    >
19206        fidl::encoding::Encode<
19207            AudioCoreCreateAudioCapturerWithConfigurationRequest,
19208            fdomain_client::fidl::FDomainResourceDialect,
19209        > for (T0, T1, T2)
19210    {
19211        #[inline]
19212        unsafe fn encode(
19213            self,
19214            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19215            offset: usize,
19216            depth: fidl::encoding::Depth,
19217        ) -> fidl::Result<()> {
19218            encoder
19219                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
19220            // Zero out padding regions. There's no need to apply masks
19221            // because the unmasked parts will be overwritten by fields.
19222            unsafe {
19223                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
19224                (ptr as *mut u64).write_unaligned(0);
19225            }
19226            unsafe {
19227                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
19228                (ptr as *mut u64).write_unaligned(0);
19229            }
19230            // Write the fields.
19231            self.0.encode(encoder, offset + 0, depth)?;
19232            self.1.encode(encoder, offset + 16, depth)?;
19233            self.2.encode(encoder, offset + 32, depth)?;
19234            Ok(())
19235        }
19236    }
19237
19238    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19239        for AudioCoreCreateAudioCapturerWithConfigurationRequest
19240    {
19241        #[inline(always)]
19242        fn new_empty() -> Self {
19243            Self {
19244                stream_type: fidl::new_empty!(
19245                    AudioStreamType,
19246                    fdomain_client::fidl::FDomainResourceDialect
19247                ),
19248                configuration: fidl::new_empty!(
19249                    AudioCapturerConfiguration,
19250                    fdomain_client::fidl::FDomainResourceDialect
19251                ),
19252                audio_capturer_request: fidl::new_empty!(
19253                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19254                    fdomain_client::fidl::FDomainResourceDialect
19255                ),
19256            }
19257        }
19258
19259        #[inline]
19260        unsafe fn decode(
19261            &mut self,
19262            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19263            offset: usize,
19264            _depth: fidl::encoding::Depth,
19265        ) -> fidl::Result<()> {
19266            decoder.debug_check_bounds::<Self>(offset);
19267            // Verify that padding bytes are zero.
19268            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
19269            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19270            let mask = 0xffffffff00000000u64;
19271            let maskedval = padval & mask;
19272            if maskedval != 0 {
19273                return Err(fidl::Error::NonZeroPadding {
19274                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
19275                });
19276            }
19277            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
19278            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19279            let mask = 0xffffffff00000000u64;
19280            let maskedval = padval & mask;
19281            if maskedval != 0 {
19282                return Err(fidl::Error::NonZeroPadding {
19283                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
19284                });
19285            }
19286            fidl::decode!(
19287                AudioStreamType,
19288                fdomain_client::fidl::FDomainResourceDialect,
19289                &mut self.stream_type,
19290                decoder,
19291                offset + 0,
19292                _depth
19293            )?;
19294            fidl::decode!(
19295                AudioCapturerConfiguration,
19296                fdomain_client::fidl::FDomainResourceDialect,
19297                &mut self.configuration,
19298                decoder,
19299                offset + 16,
19300                _depth
19301            )?;
19302            fidl::decode!(
19303                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19304                fdomain_client::fidl::FDomainResourceDialect,
19305                &mut self.audio_capturer_request,
19306                decoder,
19307                offset + 32,
19308                _depth
19309            )?;
19310            Ok(())
19311        }
19312    }
19313
19314    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
19315        type Borrowed<'a> = &'a mut Self;
19316        fn take_or_borrow<'a>(
19317            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19318        ) -> Self::Borrowed<'a> {
19319            value
19320        }
19321    }
19322
19323    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
19324        type Owned = Self;
19325
19326        #[inline(always)]
19327        fn inline_align(_context: fidl::encoding::Context) -> usize {
19328            4
19329        }
19330
19331        #[inline(always)]
19332        fn inline_size(_context: fidl::encoding::Context) -> usize {
19333            4
19334        }
19335    }
19336
19337    unsafe impl
19338        fidl::encoding::Encode<
19339            AudioCoreCreateAudioRendererRequest,
19340            fdomain_client::fidl::FDomainResourceDialect,
19341        > for &mut AudioCoreCreateAudioRendererRequest
19342    {
19343        #[inline]
19344        unsafe fn encode(
19345            self,
19346            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19347            offset: usize,
19348            _depth: fidl::encoding::Depth,
19349        ) -> fidl::Result<()> {
19350            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
19351            // Delegate to tuple encoding.
19352            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19353                (
19354                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
19355                ),
19356                encoder, offset, _depth
19357            )
19358        }
19359    }
19360    unsafe impl<
19361        T0: fidl::encoding::Encode<
19362                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19363                fdomain_client::fidl::FDomainResourceDialect,
19364            >,
19365    >
19366        fidl::encoding::Encode<
19367            AudioCoreCreateAudioRendererRequest,
19368            fdomain_client::fidl::FDomainResourceDialect,
19369        > for (T0,)
19370    {
19371        #[inline]
19372        unsafe fn encode(
19373            self,
19374            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19375            offset: usize,
19376            depth: fidl::encoding::Depth,
19377        ) -> fidl::Result<()> {
19378            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
19379            // Zero out padding regions. There's no need to apply masks
19380            // because the unmasked parts will be overwritten by fields.
19381            // Write the fields.
19382            self.0.encode(encoder, offset + 0, depth)?;
19383            Ok(())
19384        }
19385    }
19386
19387    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19388        for AudioCoreCreateAudioRendererRequest
19389    {
19390        #[inline(always)]
19391        fn new_empty() -> Self {
19392            Self {
19393                audio_out_request: fidl::new_empty!(
19394                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19395                    fdomain_client::fidl::FDomainResourceDialect
19396                ),
19397            }
19398        }
19399
19400        #[inline]
19401        unsafe fn decode(
19402            &mut self,
19403            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19404            offset: usize,
19405            _depth: fidl::encoding::Depth,
19406        ) -> fidl::Result<()> {
19407            decoder.debug_check_bounds::<Self>(offset);
19408            // Verify that padding bytes are zero.
19409            fidl::decode!(
19410                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19411                fdomain_client::fidl::FDomainResourceDialect,
19412                &mut self.audio_out_request,
19413                decoder,
19414                offset + 0,
19415                _depth
19416            )?;
19417            Ok(())
19418        }
19419    }
19420
19421    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
19422        type Borrowed<'a> = &'a mut Self;
19423        fn take_or_borrow<'a>(
19424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19425        ) -> Self::Borrowed<'a> {
19426            value
19427        }
19428    }
19429
19430    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
19431        type Owned = Self;
19432
19433        #[inline(always)]
19434        fn inline_align(_context: fidl::encoding::Context) -> usize {
19435            4
19436        }
19437
19438        #[inline(always)]
19439        fn inline_size(_context: fidl::encoding::Context) -> usize {
19440            8
19441        }
19442    }
19443
19444    unsafe impl
19445        fidl::encoding::Encode<
19446            AudioCreateAudioCapturerRequest,
19447            fdomain_client::fidl::FDomainResourceDialect,
19448        > for &mut AudioCreateAudioCapturerRequest
19449    {
19450        #[inline]
19451        unsafe fn encode(
19452            self,
19453            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19454            offset: usize,
19455            _depth: fidl::encoding::Depth,
19456        ) -> fidl::Result<()> {
19457            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
19458            // Delegate to tuple encoding.
19459            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19460                (
19461                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
19462                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
19463                ),
19464                encoder, offset, _depth
19465            )
19466        }
19467    }
19468    unsafe impl<
19469        T0: fidl::encoding::Encode<
19470                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19471                fdomain_client::fidl::FDomainResourceDialect,
19472            >,
19473        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19474    >
19475        fidl::encoding::Encode<
19476            AudioCreateAudioCapturerRequest,
19477            fdomain_client::fidl::FDomainResourceDialect,
19478        > for (T0, T1)
19479    {
19480        #[inline]
19481        unsafe fn encode(
19482            self,
19483            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19484            offset: usize,
19485            depth: fidl::encoding::Depth,
19486        ) -> fidl::Result<()> {
19487            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
19488            // Zero out padding regions. There's no need to apply masks
19489            // because the unmasked parts will be overwritten by fields.
19490            unsafe {
19491                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
19492                (ptr as *mut u32).write_unaligned(0);
19493            }
19494            // Write the fields.
19495            self.0.encode(encoder, offset + 0, depth)?;
19496            self.1.encode(encoder, offset + 4, depth)?;
19497            Ok(())
19498        }
19499    }
19500
19501    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19502        for AudioCreateAudioCapturerRequest
19503    {
19504        #[inline(always)]
19505        fn new_empty() -> Self {
19506            Self {
19507                audio_capturer_request: fidl::new_empty!(
19508                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19509                    fdomain_client::fidl::FDomainResourceDialect
19510                ),
19511                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19512            }
19513        }
19514
19515        #[inline]
19516        unsafe fn decode(
19517            &mut self,
19518            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19519            offset: usize,
19520            _depth: fidl::encoding::Depth,
19521        ) -> fidl::Result<()> {
19522            decoder.debug_check_bounds::<Self>(offset);
19523            // Verify that padding bytes are zero.
19524            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
19525            let padval = unsafe { (ptr as *const u32).read_unaligned() };
19526            let mask = 0xffffff00u32;
19527            let maskedval = padval & mask;
19528            if maskedval != 0 {
19529                return Err(fidl::Error::NonZeroPadding {
19530                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
19531                });
19532            }
19533            fidl::decode!(
19534                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19535                fdomain_client::fidl::FDomainResourceDialect,
19536                &mut self.audio_capturer_request,
19537                decoder,
19538                offset + 0,
19539                _depth
19540            )?;
19541            fidl::decode!(
19542                bool,
19543                fdomain_client::fidl::FDomainResourceDialect,
19544                &mut self.loopback,
19545                decoder,
19546                offset + 4,
19547                _depth
19548            )?;
19549            Ok(())
19550        }
19551    }
19552
19553    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
19554        type Borrowed<'a> = &'a mut Self;
19555        fn take_or_borrow<'a>(
19556            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19557        ) -> Self::Borrowed<'a> {
19558            value
19559        }
19560    }
19561
19562    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
19563        type Owned = Self;
19564
19565        #[inline(always)]
19566        fn inline_align(_context: fidl::encoding::Context) -> usize {
19567            4
19568        }
19569
19570        #[inline(always)]
19571        fn inline_size(_context: fidl::encoding::Context) -> usize {
19572            4
19573        }
19574    }
19575
19576    unsafe impl
19577        fidl::encoding::Encode<
19578            AudioCreateAudioRendererRequest,
19579            fdomain_client::fidl::FDomainResourceDialect,
19580        > for &mut AudioCreateAudioRendererRequest
19581    {
19582        #[inline]
19583        unsafe fn encode(
19584            self,
19585            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19586            offset: usize,
19587            _depth: fidl::encoding::Depth,
19588        ) -> fidl::Result<()> {
19589            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
19590            // Delegate to tuple encoding.
19591            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19592                (
19593                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
19594                ),
19595                encoder, offset, _depth
19596            )
19597        }
19598    }
19599    unsafe impl<
19600        T0: fidl::encoding::Encode<
19601                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19602                fdomain_client::fidl::FDomainResourceDialect,
19603            >,
19604    >
19605        fidl::encoding::Encode<
19606            AudioCreateAudioRendererRequest,
19607            fdomain_client::fidl::FDomainResourceDialect,
19608        > for (T0,)
19609    {
19610        #[inline]
19611        unsafe fn encode(
19612            self,
19613            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19614            offset: usize,
19615            depth: fidl::encoding::Depth,
19616        ) -> fidl::Result<()> {
19617            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
19618            // Zero out padding regions. There's no need to apply masks
19619            // because the unmasked parts will be overwritten by fields.
19620            // Write the fields.
19621            self.0.encode(encoder, offset + 0, depth)?;
19622            Ok(())
19623        }
19624    }
19625
19626    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19627        for AudioCreateAudioRendererRequest
19628    {
19629        #[inline(always)]
19630        fn new_empty() -> Self {
19631            Self {
19632                audio_renderer_request: fidl::new_empty!(
19633                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19634                    fdomain_client::fidl::FDomainResourceDialect
19635                ),
19636            }
19637        }
19638
19639        #[inline]
19640        unsafe fn decode(
19641            &mut self,
19642            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19643            offset: usize,
19644            _depth: fidl::encoding::Depth,
19645        ) -> fidl::Result<()> {
19646            decoder.debug_check_bounds::<Self>(offset);
19647            // Verify that padding bytes are zero.
19648            fidl::decode!(
19649                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19650                fdomain_client::fidl::FDomainResourceDialect,
19651                &mut self.audio_renderer_request,
19652                decoder,
19653                offset + 0,
19654                _depth
19655            )?;
19656            Ok(())
19657        }
19658    }
19659
19660    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
19661        type Borrowed<'a> = &'a mut Self;
19662        fn take_or_borrow<'a>(
19663            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19664        ) -> Self::Borrowed<'a> {
19665            value
19666        }
19667    }
19668
19669    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
19670        type Owned = Self;
19671
19672        #[inline(always)]
19673        fn inline_align(_context: fidl::encoding::Context) -> usize {
19674            8
19675        }
19676
19677        #[inline(always)]
19678        fn inline_size(_context: fidl::encoding::Context) -> usize {
19679            24
19680        }
19681    }
19682
19683    unsafe impl
19684        fidl::encoding::Encode<
19685            AudioDeviceEnumeratorAddDeviceByChannelRequest,
19686            fdomain_client::fidl::FDomainResourceDialect,
19687        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
19688    {
19689        #[inline]
19690        unsafe fn encode(
19691            self,
19692            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19693            offset: usize,
19694            _depth: fidl::encoding::Depth,
19695        ) -> fidl::Result<()> {
19696            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
19697            // Delegate to tuple encoding.
19698            fidl::encoding::Encode::<
19699                AudioDeviceEnumeratorAddDeviceByChannelRequest,
19700                fdomain_client::fidl::FDomainResourceDialect,
19701            >::encode(
19702                (
19703                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
19704                        &self.device_name,
19705                    ),
19706                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
19707                    <fidl::encoding::Endpoint<
19708                        fdomain_client::fidl::ClientEnd<
19709                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19710                        >,
19711                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19712                        &mut self.channel
19713                    ),
19714                ),
19715                encoder,
19716                offset,
19717                _depth,
19718            )
19719        }
19720    }
19721    unsafe impl<
19722        T0: fidl::encoding::Encode<
19723                fidl::encoding::BoundedString<256>,
19724                fdomain_client::fidl::FDomainResourceDialect,
19725            >,
19726        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19727        T2: fidl::encoding::Encode<
19728                fidl::encoding::Endpoint<
19729                    fdomain_client::fidl::ClientEnd<
19730                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19731                    >,
19732                >,
19733                fdomain_client::fidl::FDomainResourceDialect,
19734            >,
19735    >
19736        fidl::encoding::Encode<
19737            AudioDeviceEnumeratorAddDeviceByChannelRequest,
19738            fdomain_client::fidl::FDomainResourceDialect,
19739        > for (T0, T1, T2)
19740    {
19741        #[inline]
19742        unsafe fn encode(
19743            self,
19744            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19745            offset: usize,
19746            depth: fidl::encoding::Depth,
19747        ) -> fidl::Result<()> {
19748            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
19749            // Zero out padding regions. There's no need to apply masks
19750            // because the unmasked parts will be overwritten by fields.
19751            unsafe {
19752                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
19753                (ptr as *mut u64).write_unaligned(0);
19754            }
19755            // Write the fields.
19756            self.0.encode(encoder, offset + 0, depth)?;
19757            self.1.encode(encoder, offset + 16, depth)?;
19758            self.2.encode(encoder, offset + 20, depth)?;
19759            Ok(())
19760        }
19761    }
19762
19763    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19764        for AudioDeviceEnumeratorAddDeviceByChannelRequest
19765    {
19766        #[inline(always)]
19767        fn new_empty() -> Self {
19768            Self {
19769                device_name: fidl::new_empty!(
19770                    fidl::encoding::BoundedString<256>,
19771                    fdomain_client::fidl::FDomainResourceDialect
19772                ),
19773                is_input: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19774                channel: fidl::new_empty!(
19775                    fidl::encoding::Endpoint<
19776                        fdomain_client::fidl::ClientEnd<
19777                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19778                        >,
19779                    >,
19780                    fdomain_client::fidl::FDomainResourceDialect
19781                ),
19782            }
19783        }
19784
19785        #[inline]
19786        unsafe fn decode(
19787            &mut self,
19788            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19789            offset: usize,
19790            _depth: fidl::encoding::Depth,
19791        ) -> fidl::Result<()> {
19792            decoder.debug_check_bounds::<Self>(offset);
19793            // Verify that padding bytes are zero.
19794            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
19795            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19796            let mask = 0xffffff00u64;
19797            let maskedval = padval & mask;
19798            if maskedval != 0 {
19799                return Err(fidl::Error::NonZeroPadding {
19800                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
19801                });
19802            }
19803            fidl::decode!(
19804                fidl::encoding::BoundedString<256>,
19805                fdomain_client::fidl::FDomainResourceDialect,
19806                &mut self.device_name,
19807                decoder,
19808                offset + 0,
19809                _depth
19810            )?;
19811            fidl::decode!(
19812                bool,
19813                fdomain_client::fidl::FDomainResourceDialect,
19814                &mut self.is_input,
19815                decoder,
19816                offset + 16,
19817                _depth
19818            )?;
19819            fidl::decode!(
19820                fidl::encoding::Endpoint<
19821                    fdomain_client::fidl::ClientEnd<
19822                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19823                    >,
19824                >,
19825                fdomain_client::fidl::FDomainResourceDialect,
19826                &mut self.channel,
19827                decoder,
19828                offset + 20,
19829                _depth
19830            )?;
19831            Ok(())
19832        }
19833    }
19834
19835    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
19836        type Borrowed<'a> = &'a mut Self;
19837        fn take_or_borrow<'a>(
19838            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19839        ) -> Self::Borrowed<'a> {
19840            value
19841        }
19842    }
19843
19844    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
19845        type Owned = Self;
19846
19847        #[inline(always)]
19848        fn inline_align(_context: fidl::encoding::Context) -> usize {
19849            4
19850        }
19851
19852        #[inline(always)]
19853        fn inline_size(_context: fidl::encoding::Context) -> usize {
19854            4
19855        }
19856    }
19857
19858    unsafe impl
19859        fidl::encoding::Encode<
19860            AudioRendererBindGainControlRequest,
19861            fdomain_client::fidl::FDomainResourceDialect,
19862        > for &mut AudioRendererBindGainControlRequest
19863    {
19864        #[inline]
19865        unsafe fn encode(
19866            self,
19867            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19868            offset: usize,
19869            _depth: fidl::encoding::Depth,
19870        ) -> fidl::Result<()> {
19871            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
19872            // Delegate to tuple encoding.
19873            fidl::encoding::Encode::<
19874                AudioRendererBindGainControlRequest,
19875                fdomain_client::fidl::FDomainResourceDialect,
19876            >::encode(
19877                (<fidl::encoding::Endpoint<
19878                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
19879                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19880                    &mut self.gain_control_request,
19881                ),),
19882                encoder,
19883                offset,
19884                _depth,
19885            )
19886        }
19887    }
19888    unsafe impl<
19889        T0: fidl::encoding::Encode<
19890                fidl::encoding::Endpoint<
19891                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
19892                >,
19893                fdomain_client::fidl::FDomainResourceDialect,
19894            >,
19895    >
19896        fidl::encoding::Encode<
19897            AudioRendererBindGainControlRequest,
19898            fdomain_client::fidl::FDomainResourceDialect,
19899        > for (T0,)
19900    {
19901        #[inline]
19902        unsafe fn encode(
19903            self,
19904            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19905            offset: usize,
19906            depth: fidl::encoding::Depth,
19907        ) -> fidl::Result<()> {
19908            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
19909            // Zero out padding regions. There's no need to apply masks
19910            // because the unmasked parts will be overwritten by fields.
19911            // Write the fields.
19912            self.0.encode(encoder, offset + 0, depth)?;
19913            Ok(())
19914        }
19915    }
19916
19917    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19918        for AudioRendererBindGainControlRequest
19919    {
19920        #[inline(always)]
19921        fn new_empty() -> Self {
19922            Self {
19923                gain_control_request: fidl::new_empty!(
19924                    fidl::encoding::Endpoint<
19925                        fdomain_client::fidl::ServerEnd<
19926                            fdomain_fuchsia_media_audio::GainControlMarker,
19927                        >,
19928                    >,
19929                    fdomain_client::fidl::FDomainResourceDialect
19930                ),
19931            }
19932        }
19933
19934        #[inline]
19935        unsafe fn decode(
19936            &mut self,
19937            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19938            offset: usize,
19939            _depth: fidl::encoding::Depth,
19940        ) -> fidl::Result<()> {
19941            decoder.debug_check_bounds::<Self>(offset);
19942            // Verify that padding bytes are zero.
19943            fidl::decode!(
19944                fidl::encoding::Endpoint<
19945                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
19946                >,
19947                fdomain_client::fidl::FDomainResourceDialect,
19948                &mut self.gain_control_request,
19949                decoder,
19950                offset + 0,
19951                _depth
19952            )?;
19953            Ok(())
19954        }
19955    }
19956
19957    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
19958        type Borrowed<'a> = &'a mut Self;
19959        fn take_or_borrow<'a>(
19960            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19961        ) -> Self::Borrowed<'a> {
19962            value
19963        }
19964    }
19965
19966    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
19967        type Owned = Self;
19968
19969        #[inline(always)]
19970        fn inline_align(_context: fidl::encoding::Context) -> usize {
19971            4
19972        }
19973
19974        #[inline(always)]
19975        fn inline_size(_context: fidl::encoding::Context) -> usize {
19976            4
19977        }
19978    }
19979
19980    unsafe impl
19981        fidl::encoding::Encode<
19982            AudioRendererGetReferenceClockResponse,
19983            fdomain_client::fidl::FDomainResourceDialect,
19984        > for &mut AudioRendererGetReferenceClockResponse
19985    {
19986        #[inline]
19987        unsafe fn encode(
19988            self,
19989            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19990            offset: usize,
19991            _depth: fidl::encoding::Depth,
19992        ) -> fidl::Result<()> {
19993            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
19994            // Delegate to tuple encoding.
19995            fidl::encoding::Encode::<
19996                AudioRendererGetReferenceClockResponse,
19997                fdomain_client::fidl::FDomainResourceDialect,
19998            >::encode(
19999                (<fidl::encoding::HandleType<
20000                    fdomain_client::Clock,
20001                    { fidl::ObjectType::CLOCK.into_raw() },
20002                    2147483648,
20003                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20004                    &mut self.reference_clock,
20005                ),),
20006                encoder,
20007                offset,
20008                _depth,
20009            )
20010        }
20011    }
20012    unsafe impl<
20013        T0: fidl::encoding::Encode<
20014                fidl::encoding::HandleType<
20015                    fdomain_client::Clock,
20016                    { fidl::ObjectType::CLOCK.into_raw() },
20017                    2147483648,
20018                >,
20019                fdomain_client::fidl::FDomainResourceDialect,
20020            >,
20021    >
20022        fidl::encoding::Encode<
20023            AudioRendererGetReferenceClockResponse,
20024            fdomain_client::fidl::FDomainResourceDialect,
20025        > for (T0,)
20026    {
20027        #[inline]
20028        unsafe fn encode(
20029            self,
20030            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20031            offset: usize,
20032            depth: fidl::encoding::Depth,
20033        ) -> fidl::Result<()> {
20034            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
20035            // Zero out padding regions. There's no need to apply masks
20036            // because the unmasked parts will be overwritten by fields.
20037            // Write the fields.
20038            self.0.encode(encoder, offset + 0, depth)?;
20039            Ok(())
20040        }
20041    }
20042
20043    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20044        for AudioRendererGetReferenceClockResponse
20045    {
20046        #[inline(always)]
20047        fn new_empty() -> Self {
20048            Self {
20049                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20050            }
20051        }
20052
20053        #[inline]
20054        unsafe fn decode(
20055            &mut self,
20056            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20057            offset: usize,
20058            _depth: fidl::encoding::Depth,
20059        ) -> fidl::Result<()> {
20060            decoder.debug_check_bounds::<Self>(offset);
20061            // Verify that padding bytes are zero.
20062            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20063            Ok(())
20064        }
20065    }
20066
20067    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
20068        type Borrowed<'a> = &'a mut Self;
20069        fn take_or_borrow<'a>(
20070            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20071        ) -> Self::Borrowed<'a> {
20072            value
20073        }
20074    }
20075
20076    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
20077        type Owned = Self;
20078
20079        #[inline(always)]
20080        fn inline_align(_context: fidl::encoding::Context) -> usize {
20081            4
20082        }
20083
20084        #[inline(always)]
20085        fn inline_size(_context: fidl::encoding::Context) -> usize {
20086            4
20087        }
20088    }
20089
20090    unsafe impl
20091        fidl::encoding::Encode<
20092            AudioRendererSetReferenceClockRequest,
20093            fdomain_client::fidl::FDomainResourceDialect,
20094        > for &mut AudioRendererSetReferenceClockRequest
20095    {
20096        #[inline]
20097        unsafe fn encode(
20098            self,
20099            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20100            offset: usize,
20101            _depth: fidl::encoding::Depth,
20102        ) -> fidl::Result<()> {
20103            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
20104            // Delegate to tuple encoding.
20105            fidl::encoding::Encode::<
20106                AudioRendererSetReferenceClockRequest,
20107                fdomain_client::fidl::FDomainResourceDialect,
20108            >::encode(
20109                (<fidl::encoding::Optional<
20110                    fidl::encoding::HandleType<
20111                        fdomain_client::Clock,
20112                        { fidl::ObjectType::CLOCK.into_raw() },
20113                        2147483648,
20114                    >,
20115                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20116                    &mut self.reference_clock,
20117                ),),
20118                encoder,
20119                offset,
20120                _depth,
20121            )
20122        }
20123    }
20124    unsafe impl<
20125        T0: fidl::encoding::Encode<
20126                fidl::encoding::Optional<
20127                    fidl::encoding::HandleType<
20128                        fdomain_client::Clock,
20129                        { fidl::ObjectType::CLOCK.into_raw() },
20130                        2147483648,
20131                    >,
20132                >,
20133                fdomain_client::fidl::FDomainResourceDialect,
20134            >,
20135    >
20136        fidl::encoding::Encode<
20137            AudioRendererSetReferenceClockRequest,
20138            fdomain_client::fidl::FDomainResourceDialect,
20139        > for (T0,)
20140    {
20141        #[inline]
20142        unsafe fn encode(
20143            self,
20144            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20145            offset: usize,
20146            depth: fidl::encoding::Depth,
20147        ) -> fidl::Result<()> {
20148            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
20149            // Zero out padding regions. There's no need to apply masks
20150            // because the unmasked parts will be overwritten by fields.
20151            // Write the fields.
20152            self.0.encode(encoder, offset + 0, depth)?;
20153            Ok(())
20154        }
20155    }
20156
20157    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20158        for AudioRendererSetReferenceClockRequest
20159    {
20160        #[inline(always)]
20161        fn new_empty() -> Self {
20162            Self {
20163                reference_clock: fidl::new_empty!(
20164                    fidl::encoding::Optional<
20165                        fidl::encoding::HandleType<
20166                            fdomain_client::Clock,
20167                            { fidl::ObjectType::CLOCK.into_raw() },
20168                            2147483648,
20169                        >,
20170                    >,
20171                    fdomain_client::fidl::FDomainResourceDialect
20172                ),
20173            }
20174        }
20175
20176        #[inline]
20177        unsafe fn decode(
20178            &mut self,
20179            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20180            offset: usize,
20181            _depth: fidl::encoding::Depth,
20182        ) -> fidl::Result<()> {
20183            decoder.debug_check_bounds::<Self>(offset);
20184            // Verify that padding bytes are zero.
20185            fidl::decode!(
20186                fidl::encoding::Optional<
20187                    fidl::encoding::HandleType<
20188                        fdomain_client::Clock,
20189                        { fidl::ObjectType::CLOCK.into_raw() },
20190                        2147483648,
20191                    >,
20192                >,
20193                fdomain_client::fidl::FDomainResourceDialect,
20194                &mut self.reference_clock,
20195                decoder,
20196                offset + 0,
20197                _depth
20198            )?;
20199            Ok(())
20200        }
20201    }
20202
20203    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
20204        type Borrowed<'a> = &'a mut Self;
20205        fn take_or_borrow<'a>(
20206            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20207        ) -> Self::Borrowed<'a> {
20208            value
20209        }
20210    }
20211
20212    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
20213        type Owned = Self;
20214
20215        #[inline(always)]
20216        fn inline_align(_context: fidl::encoding::Context) -> usize {
20217            8
20218        }
20219
20220        #[inline(always)]
20221        fn inline_size(_context: fidl::encoding::Context) -> usize {
20222            40
20223        }
20224    }
20225
20226    unsafe impl
20227        fidl::encoding::Encode<
20228            ProfileProviderRegisterHandlerWithCapacityRequest,
20229            fdomain_client::fidl::FDomainResourceDialect,
20230        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
20231    {
20232        #[inline]
20233        unsafe fn encode(
20234            self,
20235            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20236            offset: usize,
20237            _depth: fidl::encoding::Depth,
20238        ) -> fidl::Result<()> {
20239            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
20240            // Delegate to tuple encoding.
20241            fidl::encoding::Encode::<
20242                ProfileProviderRegisterHandlerWithCapacityRequest,
20243                fdomain_client::fidl::FDomainResourceDialect,
20244            >::encode(
20245                (
20246                    <fidl::encoding::HandleType<
20247                        fdomain_client::Thread,
20248                        { fidl::ObjectType::THREAD.into_raw() },
20249                        2147483648,
20250                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20251                        &mut self.thread_handle,
20252                    ),
20253                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20254                        &self.name,
20255                    ),
20256                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
20257                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
20258                ),
20259                encoder,
20260                offset,
20261                _depth,
20262            )
20263        }
20264    }
20265    unsafe impl<
20266        T0: fidl::encoding::Encode<
20267                fidl::encoding::HandleType<
20268                    fdomain_client::Thread,
20269                    { fidl::ObjectType::THREAD.into_raw() },
20270                    2147483648,
20271                >,
20272                fdomain_client::fidl::FDomainResourceDialect,
20273            >,
20274        T1: fidl::encoding::Encode<
20275                fidl::encoding::BoundedString<64>,
20276                fdomain_client::fidl::FDomainResourceDialect,
20277            >,
20278        T2: fidl::encoding::Encode<i64, fdomain_client::fidl::FDomainResourceDialect>,
20279        T3: fidl::encoding::Encode<f32, fdomain_client::fidl::FDomainResourceDialect>,
20280    >
20281        fidl::encoding::Encode<
20282            ProfileProviderRegisterHandlerWithCapacityRequest,
20283            fdomain_client::fidl::FDomainResourceDialect,
20284        > for (T0, T1, T2, T3)
20285    {
20286        #[inline]
20287        unsafe fn encode(
20288            self,
20289            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20290            offset: usize,
20291            depth: fidl::encoding::Depth,
20292        ) -> fidl::Result<()> {
20293            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
20294            // Zero out padding regions. There's no need to apply masks
20295            // because the unmasked parts will be overwritten by fields.
20296            unsafe {
20297                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20298                (ptr as *mut u64).write_unaligned(0);
20299            }
20300            unsafe {
20301                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
20302                (ptr as *mut u64).write_unaligned(0);
20303            }
20304            // Write the fields.
20305            self.0.encode(encoder, offset + 0, depth)?;
20306            self.1.encode(encoder, offset + 8, depth)?;
20307            self.2.encode(encoder, offset + 24, depth)?;
20308            self.3.encode(encoder, offset + 32, depth)?;
20309            Ok(())
20310        }
20311    }
20312
20313    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20314        for ProfileProviderRegisterHandlerWithCapacityRequest
20315    {
20316        #[inline(always)]
20317        fn new_empty() -> Self {
20318            Self {
20319                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20320                name: fidl::new_empty!(
20321                    fidl::encoding::BoundedString<64>,
20322                    fdomain_client::fidl::FDomainResourceDialect
20323                ),
20324                period: fidl::new_empty!(i64, fdomain_client::fidl::FDomainResourceDialect),
20325                capacity: fidl::new_empty!(f32, fdomain_client::fidl::FDomainResourceDialect),
20326            }
20327        }
20328
20329        #[inline]
20330        unsafe fn decode(
20331            &mut self,
20332            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20333            offset: usize,
20334            _depth: fidl::encoding::Depth,
20335        ) -> fidl::Result<()> {
20336            decoder.debug_check_bounds::<Self>(offset);
20337            // Verify that padding bytes are zero.
20338            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20339            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20340            let mask = 0xffffffff00000000u64;
20341            let maskedval = padval & mask;
20342            if maskedval != 0 {
20343                return Err(fidl::Error::NonZeroPadding {
20344                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20345                });
20346            }
20347            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
20348            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20349            let mask = 0xffffffff00000000u64;
20350            let maskedval = padval & mask;
20351            if maskedval != 0 {
20352                return Err(fidl::Error::NonZeroPadding {
20353                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
20354                });
20355            }
20356            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
20357            fidl::decode!(
20358                fidl::encoding::BoundedString<64>,
20359                fdomain_client::fidl::FDomainResourceDialect,
20360                &mut self.name,
20361                decoder,
20362                offset + 8,
20363                _depth
20364            )?;
20365            fidl::decode!(
20366                i64,
20367                fdomain_client::fidl::FDomainResourceDialect,
20368                &mut self.period,
20369                decoder,
20370                offset + 24,
20371                _depth
20372            )?;
20373            fidl::decode!(
20374                f32,
20375                fdomain_client::fidl::FDomainResourceDialect,
20376                &mut self.capacity,
20377                decoder,
20378                offset + 32,
20379                _depth
20380            )?;
20381            Ok(())
20382        }
20383    }
20384
20385    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
20386        type Borrowed<'a> = &'a mut Self;
20387        fn take_or_borrow<'a>(
20388            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20389        ) -> Self::Borrowed<'a> {
20390            value
20391        }
20392    }
20393
20394    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
20395        type Owned = Self;
20396
20397        #[inline(always)]
20398        fn inline_align(_context: fidl::encoding::Context) -> usize {
20399            8
20400        }
20401
20402        #[inline(always)]
20403        fn inline_size(_context: fidl::encoding::Context) -> usize {
20404            24
20405        }
20406    }
20407
20408    unsafe impl
20409        fidl::encoding::Encode<
20410            ProfileProviderRegisterMemoryRangeRequest,
20411            fdomain_client::fidl::FDomainResourceDialect,
20412        > for &mut ProfileProviderRegisterMemoryRangeRequest
20413    {
20414        #[inline]
20415        unsafe fn encode(
20416            self,
20417            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20418            offset: usize,
20419            _depth: fidl::encoding::Depth,
20420        ) -> fidl::Result<()> {
20421            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
20422            // Delegate to tuple encoding.
20423            fidl::encoding::Encode::<
20424                ProfileProviderRegisterMemoryRangeRequest,
20425                fdomain_client::fidl::FDomainResourceDialect,
20426            >::encode(
20427                (
20428                    <fidl::encoding::HandleType<
20429                        fdomain_client::Vmar,
20430                        { fidl::ObjectType::VMAR.into_raw() },
20431                        2147483648,
20432                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20433                        &mut self.vmar_handle
20434                    ),
20435                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20436                        &self.name,
20437                    ),
20438                ),
20439                encoder,
20440                offset,
20441                _depth,
20442            )
20443        }
20444    }
20445    unsafe impl<
20446        T0: fidl::encoding::Encode<
20447                fidl::encoding::HandleType<
20448                    fdomain_client::Vmar,
20449                    { fidl::ObjectType::VMAR.into_raw() },
20450                    2147483648,
20451                >,
20452                fdomain_client::fidl::FDomainResourceDialect,
20453            >,
20454        T1: fidl::encoding::Encode<
20455                fidl::encoding::BoundedString<64>,
20456                fdomain_client::fidl::FDomainResourceDialect,
20457            >,
20458    >
20459        fidl::encoding::Encode<
20460            ProfileProviderRegisterMemoryRangeRequest,
20461            fdomain_client::fidl::FDomainResourceDialect,
20462        > for (T0, T1)
20463    {
20464        #[inline]
20465        unsafe fn encode(
20466            self,
20467            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20468            offset: usize,
20469            depth: fidl::encoding::Depth,
20470        ) -> fidl::Result<()> {
20471            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
20472            // Zero out padding regions. There's no need to apply masks
20473            // because the unmasked parts will be overwritten by fields.
20474            unsafe {
20475                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20476                (ptr as *mut u64).write_unaligned(0);
20477            }
20478            // Write the fields.
20479            self.0.encode(encoder, offset + 0, depth)?;
20480            self.1.encode(encoder, offset + 8, depth)?;
20481            Ok(())
20482        }
20483    }
20484
20485    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20486        for ProfileProviderRegisterMemoryRangeRequest
20487    {
20488        #[inline(always)]
20489        fn new_empty() -> Self {
20490            Self {
20491                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20492                name: fidl::new_empty!(
20493                    fidl::encoding::BoundedString<64>,
20494                    fdomain_client::fidl::FDomainResourceDialect
20495                ),
20496            }
20497        }
20498
20499        #[inline]
20500        unsafe fn decode(
20501            &mut self,
20502            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20503            offset: usize,
20504            _depth: fidl::encoding::Depth,
20505        ) -> fidl::Result<()> {
20506            decoder.debug_check_bounds::<Self>(offset);
20507            // Verify that padding bytes are zero.
20508            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20509            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20510            let mask = 0xffffffff00000000u64;
20511            let maskedval = padval & mask;
20512            if maskedval != 0 {
20513                return Err(fidl::Error::NonZeroPadding {
20514                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20515                });
20516            }
20517            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
20518            fidl::decode!(
20519                fidl::encoding::BoundedString<64>,
20520                fdomain_client::fidl::FDomainResourceDialect,
20521                &mut self.name,
20522                decoder,
20523                offset + 8,
20524                _depth
20525            )?;
20526            Ok(())
20527        }
20528    }
20529
20530    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
20531        type Borrowed<'a> = &'a mut Self;
20532        fn take_or_borrow<'a>(
20533            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20534        ) -> Self::Borrowed<'a> {
20535            value
20536        }
20537    }
20538
20539    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
20540        type Owned = Self;
20541
20542        #[inline(always)]
20543        fn inline_align(_context: fidl::encoding::Context) -> usize {
20544            8
20545        }
20546
20547        #[inline(always)]
20548        fn inline_size(_context: fidl::encoding::Context) -> usize {
20549            24
20550        }
20551    }
20552
20553    unsafe impl
20554        fidl::encoding::Encode<
20555            ProfileProviderUnregisterHandlerRequest,
20556            fdomain_client::fidl::FDomainResourceDialect,
20557        > for &mut ProfileProviderUnregisterHandlerRequest
20558    {
20559        #[inline]
20560        unsafe fn encode(
20561            self,
20562            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20563            offset: usize,
20564            _depth: fidl::encoding::Depth,
20565        ) -> fidl::Result<()> {
20566            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
20567            // Delegate to tuple encoding.
20568            fidl::encoding::Encode::<
20569                ProfileProviderUnregisterHandlerRequest,
20570                fdomain_client::fidl::FDomainResourceDialect,
20571            >::encode(
20572                (
20573                    <fidl::encoding::HandleType<
20574                        fdomain_client::Thread,
20575                        { fidl::ObjectType::THREAD.into_raw() },
20576                        2147483648,
20577                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20578                        &mut self.thread_handle,
20579                    ),
20580                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20581                        &self.name,
20582                    ),
20583                ),
20584                encoder,
20585                offset,
20586                _depth,
20587            )
20588        }
20589    }
20590    unsafe impl<
20591        T0: fidl::encoding::Encode<
20592                fidl::encoding::HandleType<
20593                    fdomain_client::Thread,
20594                    { fidl::ObjectType::THREAD.into_raw() },
20595                    2147483648,
20596                >,
20597                fdomain_client::fidl::FDomainResourceDialect,
20598            >,
20599        T1: fidl::encoding::Encode<
20600                fidl::encoding::BoundedString<64>,
20601                fdomain_client::fidl::FDomainResourceDialect,
20602            >,
20603    >
20604        fidl::encoding::Encode<
20605            ProfileProviderUnregisterHandlerRequest,
20606            fdomain_client::fidl::FDomainResourceDialect,
20607        > for (T0, T1)
20608    {
20609        #[inline]
20610        unsafe fn encode(
20611            self,
20612            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20613            offset: usize,
20614            depth: fidl::encoding::Depth,
20615        ) -> fidl::Result<()> {
20616            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
20617            // Zero out padding regions. There's no need to apply masks
20618            // because the unmasked parts will be overwritten by fields.
20619            unsafe {
20620                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20621                (ptr as *mut u64).write_unaligned(0);
20622            }
20623            // Write the fields.
20624            self.0.encode(encoder, offset + 0, depth)?;
20625            self.1.encode(encoder, offset + 8, depth)?;
20626            Ok(())
20627        }
20628    }
20629
20630    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20631        for ProfileProviderUnregisterHandlerRequest
20632    {
20633        #[inline(always)]
20634        fn new_empty() -> Self {
20635            Self {
20636                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20637                name: fidl::new_empty!(
20638                    fidl::encoding::BoundedString<64>,
20639                    fdomain_client::fidl::FDomainResourceDialect
20640                ),
20641            }
20642        }
20643
20644        #[inline]
20645        unsafe fn decode(
20646            &mut self,
20647            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20648            offset: usize,
20649            _depth: fidl::encoding::Depth,
20650        ) -> fidl::Result<()> {
20651            decoder.debug_check_bounds::<Self>(offset);
20652            // Verify that padding bytes are zero.
20653            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20654            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20655            let mask = 0xffffffff00000000u64;
20656            let maskedval = padval & mask;
20657            if maskedval != 0 {
20658                return Err(fidl::Error::NonZeroPadding {
20659                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20660                });
20661            }
20662            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
20663            fidl::decode!(
20664                fidl::encoding::BoundedString<64>,
20665                fdomain_client::fidl::FDomainResourceDialect,
20666                &mut self.name,
20667                decoder,
20668                offset + 8,
20669                _depth
20670            )?;
20671            Ok(())
20672        }
20673    }
20674
20675    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
20676        type Borrowed<'a> = &'a mut Self;
20677        fn take_or_borrow<'a>(
20678            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20679        ) -> Self::Borrowed<'a> {
20680            value
20681        }
20682    }
20683
20684    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
20685        type Owned = Self;
20686
20687        #[inline(always)]
20688        fn inline_align(_context: fidl::encoding::Context) -> usize {
20689            4
20690        }
20691
20692        #[inline(always)]
20693        fn inline_size(_context: fidl::encoding::Context) -> usize {
20694            4
20695        }
20696    }
20697
20698    unsafe impl
20699        fidl::encoding::Encode<
20700            ProfileProviderUnregisterMemoryRangeRequest,
20701            fdomain_client::fidl::FDomainResourceDialect,
20702        > for &mut ProfileProviderUnregisterMemoryRangeRequest
20703    {
20704        #[inline]
20705        unsafe fn encode(
20706            self,
20707            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20708            offset: usize,
20709            _depth: fidl::encoding::Depth,
20710        ) -> fidl::Result<()> {
20711            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
20712            // Delegate to tuple encoding.
20713            fidl::encoding::Encode::<
20714                ProfileProviderUnregisterMemoryRangeRequest,
20715                fdomain_client::fidl::FDomainResourceDialect,
20716            >::encode(
20717                (<fidl::encoding::HandleType<
20718                    fdomain_client::Vmar,
20719                    { fidl::ObjectType::VMAR.into_raw() },
20720                    2147483648,
20721                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20722                    &mut self.vmar_handle
20723                ),),
20724                encoder,
20725                offset,
20726                _depth,
20727            )
20728        }
20729    }
20730    unsafe impl<
20731        T0: fidl::encoding::Encode<
20732                fidl::encoding::HandleType<
20733                    fdomain_client::Vmar,
20734                    { fidl::ObjectType::VMAR.into_raw() },
20735                    2147483648,
20736                >,
20737                fdomain_client::fidl::FDomainResourceDialect,
20738            >,
20739    >
20740        fidl::encoding::Encode<
20741            ProfileProviderUnregisterMemoryRangeRequest,
20742            fdomain_client::fidl::FDomainResourceDialect,
20743        > for (T0,)
20744    {
20745        #[inline]
20746        unsafe fn encode(
20747            self,
20748            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20749            offset: usize,
20750            depth: fidl::encoding::Depth,
20751        ) -> fidl::Result<()> {
20752            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
20753            // Zero out padding regions. There's no need to apply masks
20754            // because the unmasked parts will be overwritten by fields.
20755            // Write the fields.
20756            self.0.encode(encoder, offset + 0, depth)?;
20757            Ok(())
20758        }
20759    }
20760
20761    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20762        for ProfileProviderUnregisterMemoryRangeRequest
20763    {
20764        #[inline(always)]
20765        fn new_empty() -> Self {
20766            Self {
20767                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20768            }
20769        }
20770
20771        #[inline]
20772        unsafe fn decode(
20773            &mut self,
20774            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20775            offset: usize,
20776            _depth: fidl::encoding::Depth,
20777        ) -> fidl::Result<()> {
20778            decoder.debug_check_bounds::<Self>(offset);
20779            // Verify that padding bytes are zero.
20780            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
20781            Ok(())
20782        }
20783    }
20784
20785    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
20786        type Borrowed<'a> = &'a mut Self;
20787        fn take_or_borrow<'a>(
20788            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20789        ) -> Self::Borrowed<'a> {
20790            value
20791        }
20792    }
20793
20794    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
20795        type Owned = Self;
20796
20797        #[inline(always)]
20798        fn inline_align(_context: fidl::encoding::Context) -> usize {
20799            8
20800        }
20801
20802        #[inline(always)]
20803        fn inline_size(_context: fidl::encoding::Context) -> usize {
20804            16
20805        }
20806    }
20807
20808    unsafe impl
20809        fidl::encoding::Encode<
20810            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
20811            fdomain_client::fidl::FDomainResourceDialect,
20812        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
20813    {
20814        #[inline]
20815        unsafe fn encode(
20816            self,
20817            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20818            offset: usize,
20819            _depth: fidl::encoding::Depth,
20820        ) -> fidl::Result<()> {
20821            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
20822                offset,
20823            );
20824            // Delegate to tuple encoding.
20825            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
20826                (
20827                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
20828                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
20829                ),
20830                encoder, offset, _depth
20831            )
20832        }
20833    }
20834    unsafe impl<
20835        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
20836        T1: fidl::encoding::Encode<
20837                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
20838                fdomain_client::fidl::FDomainResourceDialect,
20839            >,
20840    >
20841        fidl::encoding::Encode<
20842            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
20843            fdomain_client::fidl::FDomainResourceDialect,
20844        > for (T0, T1)
20845    {
20846        #[inline]
20847        unsafe fn encode(
20848            self,
20849            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20850            offset: usize,
20851            depth: fidl::encoding::Depth,
20852        ) -> fidl::Result<()> {
20853            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
20854                offset,
20855            );
20856            // Zero out padding regions. There's no need to apply masks
20857            // because the unmasked parts will be overwritten by fields.
20858            unsafe {
20859                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
20860                (ptr as *mut u64).write_unaligned(0);
20861            }
20862            // Write the fields.
20863            self.0.encode(encoder, offset + 0, depth)?;
20864            self.1.encode(encoder, offset + 8, depth)?;
20865            Ok(())
20866        }
20867    }
20868
20869    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20870        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
20871    {
20872        #[inline(always)]
20873        fn new_empty() -> Self {
20874            Self {
20875                session_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
20876                audio_consumer_request: fidl::new_empty!(
20877                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
20878                    fdomain_client::fidl::FDomainResourceDialect
20879                ),
20880            }
20881        }
20882
20883        #[inline]
20884        unsafe fn decode(
20885            &mut self,
20886            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20887            offset: usize,
20888            _depth: fidl::encoding::Depth,
20889        ) -> fidl::Result<()> {
20890            decoder.debug_check_bounds::<Self>(offset);
20891            // Verify that padding bytes are zero.
20892            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
20893            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20894            let mask = 0xffffffff00000000u64;
20895            let maskedval = padval & mask;
20896            if maskedval != 0 {
20897                return Err(fidl::Error::NonZeroPadding {
20898                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
20899                });
20900            }
20901            fidl::decode!(
20902                u64,
20903                fdomain_client::fidl::FDomainResourceDialect,
20904                &mut self.session_id,
20905                decoder,
20906                offset + 0,
20907                _depth
20908            )?;
20909            fidl::decode!(
20910                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
20911                fdomain_client::fidl::FDomainResourceDialect,
20912                &mut self.audio_consumer_request,
20913                decoder,
20914                offset + 8,
20915                _depth
20916            )?;
20917            Ok(())
20918        }
20919    }
20920
20921    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
20922        type Borrowed<'a> = &'a mut Self;
20923        fn take_or_borrow<'a>(
20924            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20925        ) -> Self::Borrowed<'a> {
20926            value
20927        }
20928    }
20929
20930    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
20931        type Owned = Self;
20932
20933        #[inline(always)]
20934        fn inline_align(_context: fidl::encoding::Context) -> usize {
20935            4
20936        }
20937
20938        #[inline(always)]
20939        fn inline_size(_context: fidl::encoding::Context) -> usize {
20940            8
20941        }
20942    }
20943
20944    unsafe impl
20945        fidl::encoding::Encode<
20946            StreamBufferSetAddPayloadBufferRequest,
20947            fdomain_client::fidl::FDomainResourceDialect,
20948        > for &mut StreamBufferSetAddPayloadBufferRequest
20949    {
20950        #[inline]
20951        unsafe fn encode(
20952            self,
20953            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20954            offset: usize,
20955            _depth: fidl::encoding::Depth,
20956        ) -> fidl::Result<()> {
20957            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
20958            // Delegate to tuple encoding.
20959            fidl::encoding::Encode::<
20960                StreamBufferSetAddPayloadBufferRequest,
20961                fdomain_client::fidl::FDomainResourceDialect,
20962            >::encode(
20963                (
20964                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
20965                    <fidl::encoding::HandleType<
20966                        fdomain_client::Vmo,
20967                        { fidl::ObjectType::VMO.into_raw() },
20968                        2147483648,
20969                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20970                        &mut self.payload_buffer,
20971                    ),
20972                ),
20973                encoder,
20974                offset,
20975                _depth,
20976            )
20977        }
20978    }
20979    unsafe impl<
20980        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
20981        T1: fidl::encoding::Encode<
20982                fidl::encoding::HandleType<
20983                    fdomain_client::Vmo,
20984                    { fidl::ObjectType::VMO.into_raw() },
20985                    2147483648,
20986                >,
20987                fdomain_client::fidl::FDomainResourceDialect,
20988            >,
20989    >
20990        fidl::encoding::Encode<
20991            StreamBufferSetAddPayloadBufferRequest,
20992            fdomain_client::fidl::FDomainResourceDialect,
20993        > for (T0, T1)
20994    {
20995        #[inline]
20996        unsafe fn encode(
20997            self,
20998            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20999            offset: usize,
21000            depth: fidl::encoding::Depth,
21001        ) -> fidl::Result<()> {
21002            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
21003            // Zero out padding regions. There's no need to apply masks
21004            // because the unmasked parts will be overwritten by fields.
21005            // Write the fields.
21006            self.0.encode(encoder, offset + 0, depth)?;
21007            self.1.encode(encoder, offset + 4, depth)?;
21008            Ok(())
21009        }
21010    }
21011
21012    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21013        for StreamBufferSetAddPayloadBufferRequest
21014    {
21015        #[inline(always)]
21016        fn new_empty() -> Self {
21017            Self {
21018                id: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
21019                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
21020            }
21021        }
21022
21023        #[inline]
21024        unsafe fn decode(
21025            &mut self,
21026            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21027            offset: usize,
21028            _depth: fidl::encoding::Depth,
21029        ) -> fidl::Result<()> {
21030            decoder.debug_check_bounds::<Self>(offset);
21031            // Verify that padding bytes are zero.
21032            fidl::decode!(
21033                u32,
21034                fdomain_client::fidl::FDomainResourceDialect,
21035                &mut self.id,
21036                decoder,
21037                offset + 0,
21038                _depth
21039            )?;
21040            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
21041            Ok(())
21042        }
21043    }
21044
21045    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
21046        type Borrowed<'a> = &'a mut Self;
21047        fn take_or_borrow<'a>(
21048            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21049        ) -> Self::Borrowed<'a> {
21050            value
21051        }
21052    }
21053
21054    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
21055        type Owned = Self;
21056
21057        #[inline(always)]
21058        fn inline_align(_context: fidl::encoding::Context) -> usize {
21059            8
21060        }
21061
21062        #[inline(always)]
21063        fn inline_size(_context: fidl::encoding::Context) -> usize {
21064            16
21065        }
21066    }
21067
21068    unsafe impl
21069        fidl::encoding::Encode<
21070            StreamProcessorSetInputBufferPartialSettingsRequest,
21071            fdomain_client::fidl::FDomainResourceDialect,
21072        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
21073    {
21074        #[inline]
21075        unsafe fn encode(
21076            self,
21077            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21078            offset: usize,
21079            _depth: fidl::encoding::Depth,
21080        ) -> fidl::Result<()> {
21081            encoder
21082                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
21083            // Delegate to tuple encoding.
21084            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21085                (
21086                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
21087                ),
21088                encoder, offset, _depth
21089            )
21090        }
21091    }
21092    unsafe impl<
21093        T0: fidl::encoding::Encode<
21094                StreamBufferPartialSettings,
21095                fdomain_client::fidl::FDomainResourceDialect,
21096            >,
21097    >
21098        fidl::encoding::Encode<
21099            StreamProcessorSetInputBufferPartialSettingsRequest,
21100            fdomain_client::fidl::FDomainResourceDialect,
21101        > for (T0,)
21102    {
21103        #[inline]
21104        unsafe fn encode(
21105            self,
21106            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21107            offset: usize,
21108            depth: fidl::encoding::Depth,
21109        ) -> fidl::Result<()> {
21110            encoder
21111                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
21112            // Zero out padding regions. There's no need to apply masks
21113            // because the unmasked parts will be overwritten by fields.
21114            // Write the fields.
21115            self.0.encode(encoder, offset + 0, depth)?;
21116            Ok(())
21117        }
21118    }
21119
21120    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21121        for StreamProcessorSetInputBufferPartialSettingsRequest
21122    {
21123        #[inline(always)]
21124        fn new_empty() -> Self {
21125            Self {
21126                input_settings: fidl::new_empty!(
21127                    StreamBufferPartialSettings,
21128                    fdomain_client::fidl::FDomainResourceDialect
21129                ),
21130            }
21131        }
21132
21133        #[inline]
21134        unsafe fn decode(
21135            &mut self,
21136            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21137            offset: usize,
21138            _depth: fidl::encoding::Depth,
21139        ) -> fidl::Result<()> {
21140            decoder.debug_check_bounds::<Self>(offset);
21141            // Verify that padding bytes are zero.
21142            fidl::decode!(
21143                StreamBufferPartialSettings,
21144                fdomain_client::fidl::FDomainResourceDialect,
21145                &mut self.input_settings,
21146                decoder,
21147                offset + 0,
21148                _depth
21149            )?;
21150            Ok(())
21151        }
21152    }
21153
21154    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
21155        type Borrowed<'a> = &'a mut Self;
21156        fn take_or_borrow<'a>(
21157            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21158        ) -> Self::Borrowed<'a> {
21159            value
21160        }
21161    }
21162
21163    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
21164        type Owned = Self;
21165
21166        #[inline(always)]
21167        fn inline_align(_context: fidl::encoding::Context) -> usize {
21168            8
21169        }
21170
21171        #[inline(always)]
21172        fn inline_size(_context: fidl::encoding::Context) -> usize {
21173            16
21174        }
21175    }
21176
21177    unsafe impl
21178        fidl::encoding::Encode<
21179            StreamProcessorSetOutputBufferPartialSettingsRequest,
21180            fdomain_client::fidl::FDomainResourceDialect,
21181        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
21182    {
21183        #[inline]
21184        unsafe fn encode(
21185            self,
21186            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21187            offset: usize,
21188            _depth: fidl::encoding::Depth,
21189        ) -> fidl::Result<()> {
21190            encoder
21191                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
21192            // Delegate to tuple encoding.
21193            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21194                (
21195                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
21196                ),
21197                encoder, offset, _depth
21198            )
21199        }
21200    }
21201    unsafe impl<
21202        T0: fidl::encoding::Encode<
21203                StreamBufferPartialSettings,
21204                fdomain_client::fidl::FDomainResourceDialect,
21205            >,
21206    >
21207        fidl::encoding::Encode<
21208            StreamProcessorSetOutputBufferPartialSettingsRequest,
21209            fdomain_client::fidl::FDomainResourceDialect,
21210        > for (T0,)
21211    {
21212        #[inline]
21213        unsafe fn encode(
21214            self,
21215            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21216            offset: usize,
21217            depth: fidl::encoding::Depth,
21218        ) -> fidl::Result<()> {
21219            encoder
21220                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
21221            // Zero out padding regions. There's no need to apply masks
21222            // because the unmasked parts will be overwritten by fields.
21223            // Write the fields.
21224            self.0.encode(encoder, offset + 0, depth)?;
21225            Ok(())
21226        }
21227    }
21228
21229    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21230        for StreamProcessorSetOutputBufferPartialSettingsRequest
21231    {
21232        #[inline(always)]
21233        fn new_empty() -> Self {
21234            Self {
21235                output_settings: fidl::new_empty!(
21236                    StreamBufferPartialSettings,
21237                    fdomain_client::fidl::FDomainResourceDialect
21238                ),
21239            }
21240        }
21241
21242        #[inline]
21243        unsafe fn decode(
21244            &mut self,
21245            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21246            offset: usize,
21247            _depth: fidl::encoding::Depth,
21248        ) -> fidl::Result<()> {
21249            decoder.debug_check_bounds::<Self>(offset);
21250            // Verify that padding bytes are zero.
21251            fidl::decode!(
21252                StreamBufferPartialSettings,
21253                fdomain_client::fidl::FDomainResourceDialect,
21254                &mut self.output_settings,
21255                decoder,
21256                offset + 0,
21257                _depth
21258            )?;
21259            Ok(())
21260        }
21261    }
21262
21263    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
21264        type Borrowed<'a> = &'a mut Self;
21265        fn take_or_borrow<'a>(
21266            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21267        ) -> Self::Borrowed<'a> {
21268            value
21269        }
21270    }
21271
21272    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
21273        type Owned = Self;
21274
21275        #[inline(always)]
21276        fn inline_align(_context: fidl::encoding::Context) -> usize {
21277            4
21278        }
21279
21280        #[inline(always)]
21281        fn inline_size(_context: fidl::encoding::Context) -> usize {
21282            8
21283        }
21284    }
21285
21286    unsafe impl
21287        fidl::encoding::Encode<
21288            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
21289            fdomain_client::fidl::FDomainResourceDialect,
21290        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
21291    {
21292        #[inline]
21293        unsafe fn encode(
21294            self,
21295            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21296            offset: usize,
21297            _depth: fidl::encoding::Depth,
21298        ) -> fidl::Result<()> {
21299            encoder
21300                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21301            // Delegate to tuple encoding.
21302            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21303                (
21304                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21305                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
21306                ),
21307                encoder, offset, _depth
21308            )
21309        }
21310    }
21311    unsafe impl<
21312        T0: fidl::encoding::Encode<AudioRenderUsage2, fdomain_client::fidl::FDomainResourceDialect>,
21313        T1: fidl::encoding::Encode<
21314                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21315                fdomain_client::fidl::FDomainResourceDialect,
21316            >,
21317    >
21318        fidl::encoding::Encode<
21319            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
21320            fdomain_client::fidl::FDomainResourceDialect,
21321        > for (T0, T1)
21322    {
21323        #[inline]
21324        unsafe fn encode(
21325            self,
21326            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21327            offset: usize,
21328            depth: fidl::encoding::Depth,
21329        ) -> fidl::Result<()> {
21330            encoder
21331                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21332            // Zero out padding regions. There's no need to apply masks
21333            // because the unmasked parts will be overwritten by fields.
21334            // Write the fields.
21335            self.0.encode(encoder, offset + 0, depth)?;
21336            self.1.encode(encoder, offset + 4, depth)?;
21337            Ok(())
21338        }
21339    }
21340
21341    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21342        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
21343    {
21344        #[inline(always)]
21345        fn new_empty() -> Self {
21346            Self {
21347                usage: fidl::new_empty!(
21348                    AudioRenderUsage2,
21349                    fdomain_client::fidl::FDomainResourceDialect
21350                ),
21351                audio_consumer_request: fidl::new_empty!(
21352                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21353                    fdomain_client::fidl::FDomainResourceDialect
21354                ),
21355            }
21356        }
21357
21358        #[inline]
21359        unsafe fn decode(
21360            &mut self,
21361            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21362            offset: usize,
21363            _depth: fidl::encoding::Depth,
21364        ) -> fidl::Result<()> {
21365            decoder.debug_check_bounds::<Self>(offset);
21366            // Verify that padding bytes are zero.
21367            fidl::decode!(
21368                AudioRenderUsage2,
21369                fdomain_client::fidl::FDomainResourceDialect,
21370                &mut self.usage,
21371                decoder,
21372                offset + 0,
21373                _depth
21374            )?;
21375            fidl::decode!(
21376                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21377                fdomain_client::fidl::FDomainResourceDialect,
21378                &mut self.audio_consumer_request,
21379                decoder,
21380                offset + 4,
21381                _depth
21382            )?;
21383            Ok(())
21384        }
21385    }
21386
21387    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
21388        type Borrowed<'a> = &'a mut Self;
21389        fn take_or_borrow<'a>(
21390            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21391        ) -> Self::Borrowed<'a> {
21392            value
21393        }
21394    }
21395
21396    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
21397        type Owned = Self;
21398
21399        #[inline(always)]
21400        fn inline_align(_context: fidl::encoding::Context) -> usize {
21401            4
21402        }
21403
21404        #[inline(always)]
21405        fn inline_size(_context: fidl::encoding::Context) -> usize {
21406            8
21407        }
21408    }
21409
21410    unsafe impl
21411        fidl::encoding::Encode<
21412            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
21413            fdomain_client::fidl::FDomainResourceDialect,
21414        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
21415    {
21416        #[inline]
21417        unsafe fn encode(
21418            self,
21419            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21420            offset: usize,
21421            _depth: fidl::encoding::Depth,
21422        ) -> fidl::Result<()> {
21423            encoder
21424                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21425            // Delegate to tuple encoding.
21426            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21427                (
21428                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21429                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
21430                ),
21431                encoder, offset, _depth
21432            )
21433        }
21434    }
21435    unsafe impl<
21436        T0: fidl::encoding::Encode<AudioRenderUsage, fdomain_client::fidl::FDomainResourceDialect>,
21437        T1: fidl::encoding::Encode<
21438                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21439                fdomain_client::fidl::FDomainResourceDialect,
21440            >,
21441    >
21442        fidl::encoding::Encode<
21443            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
21444            fdomain_client::fidl::FDomainResourceDialect,
21445        > for (T0, T1)
21446    {
21447        #[inline]
21448        unsafe fn encode(
21449            self,
21450            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21451            offset: usize,
21452            depth: fidl::encoding::Depth,
21453        ) -> fidl::Result<()> {
21454            encoder
21455                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21456            // Zero out padding regions. There's no need to apply masks
21457            // because the unmasked parts will be overwritten by fields.
21458            // Write the fields.
21459            self.0.encode(encoder, offset + 0, depth)?;
21460            self.1.encode(encoder, offset + 4, depth)?;
21461            Ok(())
21462        }
21463    }
21464
21465    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21466        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
21467    {
21468        #[inline(always)]
21469        fn new_empty() -> Self {
21470            Self {
21471                usage: fidl::new_empty!(
21472                    AudioRenderUsage,
21473                    fdomain_client::fidl::FDomainResourceDialect
21474                ),
21475                audio_consumer_request: fidl::new_empty!(
21476                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21477                    fdomain_client::fidl::FDomainResourceDialect
21478                ),
21479            }
21480        }
21481
21482        #[inline]
21483        unsafe fn decode(
21484            &mut self,
21485            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21486            offset: usize,
21487            _depth: fidl::encoding::Depth,
21488        ) -> fidl::Result<()> {
21489            decoder.debug_check_bounds::<Self>(offset);
21490            // Verify that padding bytes are zero.
21491            fidl::decode!(
21492                AudioRenderUsage,
21493                fdomain_client::fidl::FDomainResourceDialect,
21494                &mut self.usage,
21495                decoder,
21496                offset + 0,
21497                _depth
21498            )?;
21499            fidl::decode!(
21500                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21501                fdomain_client::fidl::FDomainResourceDialect,
21502                &mut self.audio_consumer_request,
21503                decoder,
21504                offset + 4,
21505                _depth
21506            )?;
21507            Ok(())
21508        }
21509    }
21510
21511    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
21512        type Borrowed<'a> = &'a mut Self;
21513        fn take_or_borrow<'a>(
21514            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21515        ) -> Self::Borrowed<'a> {
21516            value
21517        }
21518    }
21519
21520    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
21521        type Owned = Self;
21522
21523        #[inline(always)]
21524        fn inline_align(_context: fidl::encoding::Context) -> usize {
21525            8
21526        }
21527
21528        #[inline(always)]
21529        fn inline_size(_context: fidl::encoding::Context) -> usize {
21530            40
21531        }
21532    }
21533
21534    unsafe impl
21535        fidl::encoding::Encode<
21536            UsageGainReporterRegisterListener2Request,
21537            fdomain_client::fidl::FDomainResourceDialect,
21538        > for &mut UsageGainReporterRegisterListener2Request
21539    {
21540        #[inline]
21541        unsafe fn encode(
21542            self,
21543            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21544            offset: usize,
21545            _depth: fidl::encoding::Depth,
21546        ) -> fidl::Result<()> {
21547            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
21548            // Delegate to tuple encoding.
21549            fidl::encoding::Encode::<
21550                UsageGainReporterRegisterListener2Request,
21551                fdomain_client::fidl::FDomainResourceDialect,
21552            >::encode(
21553                (
21554                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
21555                        &self.device_unique_id,
21556                    ),
21557                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21558                    <fidl::encoding::Endpoint<
21559                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21560                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21561                        &mut self.usage_gain_listener,
21562                    ),
21563                ),
21564                encoder,
21565                offset,
21566                _depth,
21567            )
21568        }
21569    }
21570    unsafe impl<
21571        T0: fidl::encoding::Encode<
21572                fidl::encoding::BoundedString<36>,
21573                fdomain_client::fidl::FDomainResourceDialect,
21574            >,
21575        T1: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
21576        T2: fidl::encoding::Encode<
21577                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21578                fdomain_client::fidl::FDomainResourceDialect,
21579            >,
21580    >
21581        fidl::encoding::Encode<
21582            UsageGainReporterRegisterListener2Request,
21583            fdomain_client::fidl::FDomainResourceDialect,
21584        > for (T0, T1, T2)
21585    {
21586        #[inline]
21587        unsafe fn encode(
21588            self,
21589            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21590            offset: usize,
21591            depth: fidl::encoding::Depth,
21592        ) -> fidl::Result<()> {
21593            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
21594            // Zero out padding regions. There's no need to apply masks
21595            // because the unmasked parts will be overwritten by fields.
21596            unsafe {
21597                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21598                (ptr as *mut u64).write_unaligned(0);
21599            }
21600            // Write the fields.
21601            self.0.encode(encoder, offset + 0, depth)?;
21602            self.1.encode(encoder, offset + 16, depth)?;
21603            self.2.encode(encoder, offset + 32, depth)?;
21604            Ok(())
21605        }
21606    }
21607
21608    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21609        for UsageGainReporterRegisterListener2Request
21610    {
21611        #[inline(always)]
21612        fn new_empty() -> Self {
21613            Self {
21614                device_unique_id: fidl::new_empty!(
21615                    fidl::encoding::BoundedString<36>,
21616                    fdomain_client::fidl::FDomainResourceDialect
21617                ),
21618                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
21619                usage_gain_listener: fidl::new_empty!(
21620                    fidl::encoding::Endpoint<
21621                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21622                    >,
21623                    fdomain_client::fidl::FDomainResourceDialect
21624                ),
21625            }
21626        }
21627
21628        #[inline]
21629        unsafe fn decode(
21630            &mut self,
21631            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21632            offset: usize,
21633            _depth: fidl::encoding::Depth,
21634        ) -> fidl::Result<()> {
21635            decoder.debug_check_bounds::<Self>(offset);
21636            // Verify that padding bytes are zero.
21637            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21638            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21639            let mask = 0xffffffff00000000u64;
21640            let maskedval = padval & mask;
21641            if maskedval != 0 {
21642                return Err(fidl::Error::NonZeroPadding {
21643                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21644                });
21645            }
21646            fidl::decode!(
21647                fidl::encoding::BoundedString<36>,
21648                fdomain_client::fidl::FDomainResourceDialect,
21649                &mut self.device_unique_id,
21650                decoder,
21651                offset + 0,
21652                _depth
21653            )?;
21654            fidl::decode!(
21655                Usage2,
21656                fdomain_client::fidl::FDomainResourceDialect,
21657                &mut self.usage,
21658                decoder,
21659                offset + 16,
21660                _depth
21661            )?;
21662            fidl::decode!(
21663                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21664                fdomain_client::fidl::FDomainResourceDialect,
21665                &mut self.usage_gain_listener,
21666                decoder,
21667                offset + 32,
21668                _depth
21669            )?;
21670            Ok(())
21671        }
21672    }
21673
21674    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
21675        type Borrowed<'a> = &'a mut Self;
21676        fn take_or_borrow<'a>(
21677            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21678        ) -> Self::Borrowed<'a> {
21679            value
21680        }
21681    }
21682
21683    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
21684        type Owned = Self;
21685
21686        #[inline(always)]
21687        fn inline_align(_context: fidl::encoding::Context) -> usize {
21688            8
21689        }
21690
21691        #[inline(always)]
21692        fn inline_size(_context: fidl::encoding::Context) -> usize {
21693            40
21694        }
21695    }
21696
21697    unsafe impl
21698        fidl::encoding::Encode<
21699            UsageGainReporterRegisterListenerRequest,
21700            fdomain_client::fidl::FDomainResourceDialect,
21701        > for &mut UsageGainReporterRegisterListenerRequest
21702    {
21703        #[inline]
21704        unsafe fn encode(
21705            self,
21706            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21707            offset: usize,
21708            _depth: fidl::encoding::Depth,
21709        ) -> fidl::Result<()> {
21710            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
21711            // Delegate to tuple encoding.
21712            fidl::encoding::Encode::<
21713                UsageGainReporterRegisterListenerRequest,
21714                fdomain_client::fidl::FDomainResourceDialect,
21715            >::encode(
21716                (
21717                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
21718                        &self.device_unique_id,
21719                    ),
21720                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21721                    <fidl::encoding::Endpoint<
21722                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21723                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21724                        &mut self.usage_gain_listener,
21725                    ),
21726                ),
21727                encoder,
21728                offset,
21729                _depth,
21730            )
21731        }
21732    }
21733    unsafe impl<
21734        T0: fidl::encoding::Encode<
21735                fidl::encoding::BoundedString<36>,
21736                fdomain_client::fidl::FDomainResourceDialect,
21737            >,
21738        T1: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
21739        T2: fidl::encoding::Encode<
21740                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21741                fdomain_client::fidl::FDomainResourceDialect,
21742            >,
21743    >
21744        fidl::encoding::Encode<
21745            UsageGainReporterRegisterListenerRequest,
21746            fdomain_client::fidl::FDomainResourceDialect,
21747        > for (T0, T1, T2)
21748    {
21749        #[inline]
21750        unsafe fn encode(
21751            self,
21752            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21753            offset: usize,
21754            depth: fidl::encoding::Depth,
21755        ) -> fidl::Result<()> {
21756            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
21757            // Zero out padding regions. There's no need to apply masks
21758            // because the unmasked parts will be overwritten by fields.
21759            unsafe {
21760                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21761                (ptr as *mut u64).write_unaligned(0);
21762            }
21763            // Write the fields.
21764            self.0.encode(encoder, offset + 0, depth)?;
21765            self.1.encode(encoder, offset + 16, depth)?;
21766            self.2.encode(encoder, offset + 32, depth)?;
21767            Ok(())
21768        }
21769    }
21770
21771    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21772        for UsageGainReporterRegisterListenerRequest
21773    {
21774        #[inline(always)]
21775        fn new_empty() -> Self {
21776            Self {
21777                device_unique_id: fidl::new_empty!(
21778                    fidl::encoding::BoundedString<36>,
21779                    fdomain_client::fidl::FDomainResourceDialect
21780                ),
21781                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
21782                usage_gain_listener: fidl::new_empty!(
21783                    fidl::encoding::Endpoint<
21784                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21785                    >,
21786                    fdomain_client::fidl::FDomainResourceDialect
21787                ),
21788            }
21789        }
21790
21791        #[inline]
21792        unsafe fn decode(
21793            &mut self,
21794            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21795            offset: usize,
21796            _depth: fidl::encoding::Depth,
21797        ) -> fidl::Result<()> {
21798            decoder.debug_check_bounds::<Self>(offset);
21799            // Verify that padding bytes are zero.
21800            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21801            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21802            let mask = 0xffffffff00000000u64;
21803            let maskedval = padval & mask;
21804            if maskedval != 0 {
21805                return Err(fidl::Error::NonZeroPadding {
21806                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21807                });
21808            }
21809            fidl::decode!(
21810                fidl::encoding::BoundedString<36>,
21811                fdomain_client::fidl::FDomainResourceDialect,
21812                &mut self.device_unique_id,
21813                decoder,
21814                offset + 0,
21815                _depth
21816            )?;
21817            fidl::decode!(
21818                Usage,
21819                fdomain_client::fidl::FDomainResourceDialect,
21820                &mut self.usage,
21821                decoder,
21822                offset + 16,
21823                _depth
21824            )?;
21825            fidl::decode!(
21826                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21827                fdomain_client::fidl::FDomainResourceDialect,
21828                &mut self.usage_gain_listener,
21829                decoder,
21830                offset + 32,
21831                _depth
21832            )?;
21833            Ok(())
21834        }
21835    }
21836
21837    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
21838        type Borrowed<'a> = &'a mut Self;
21839        fn take_or_borrow<'a>(
21840            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21841        ) -> Self::Borrowed<'a> {
21842            value
21843        }
21844    }
21845
21846    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
21847        type Owned = Self;
21848
21849        #[inline(always)]
21850        fn inline_align(_context: fidl::encoding::Context) -> usize {
21851            8
21852        }
21853
21854        #[inline(always)]
21855        fn inline_size(_context: fidl::encoding::Context) -> usize {
21856            24
21857        }
21858    }
21859
21860    unsafe impl
21861        fidl::encoding::Encode<
21862            UsageReporterWatch2Request,
21863            fdomain_client::fidl::FDomainResourceDialect,
21864        > for &mut UsageReporterWatch2Request
21865    {
21866        #[inline]
21867        unsafe fn encode(
21868            self,
21869            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21870            offset: usize,
21871            _depth: fidl::encoding::Depth,
21872        ) -> fidl::Result<()> {
21873            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
21874            // Delegate to tuple encoding.
21875            fidl::encoding::Encode::<UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect>::encode(
21876                (
21877                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21878                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
21879                ),
21880                encoder, offset, _depth
21881            )
21882        }
21883    }
21884    unsafe impl<
21885        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
21886        T1: fidl::encoding::Encode<
21887                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
21888                fdomain_client::fidl::FDomainResourceDialect,
21889            >,
21890    >
21891        fidl::encoding::Encode<
21892            UsageReporterWatch2Request,
21893            fdomain_client::fidl::FDomainResourceDialect,
21894        > for (T0, T1)
21895    {
21896        #[inline]
21897        unsafe fn encode(
21898            self,
21899            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21900            offset: usize,
21901            depth: fidl::encoding::Depth,
21902        ) -> fidl::Result<()> {
21903            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
21904            // Zero out padding regions. There's no need to apply masks
21905            // because the unmasked parts will be overwritten by fields.
21906            unsafe {
21907                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21908                (ptr as *mut u64).write_unaligned(0);
21909            }
21910            // Write the fields.
21911            self.0.encode(encoder, offset + 0, depth)?;
21912            self.1.encode(encoder, offset + 16, depth)?;
21913            Ok(())
21914        }
21915    }
21916
21917    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21918        for UsageReporterWatch2Request
21919    {
21920        #[inline(always)]
21921        fn new_empty() -> Self {
21922            Self {
21923                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
21924                usage_watcher: fidl::new_empty!(
21925                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
21926                    fdomain_client::fidl::FDomainResourceDialect
21927                ),
21928            }
21929        }
21930
21931        #[inline]
21932        unsafe fn decode(
21933            &mut self,
21934            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21935            offset: usize,
21936            _depth: fidl::encoding::Depth,
21937        ) -> fidl::Result<()> {
21938            decoder.debug_check_bounds::<Self>(offset);
21939            // Verify that padding bytes are zero.
21940            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21941            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21942            let mask = 0xffffffff00000000u64;
21943            let maskedval = padval & mask;
21944            if maskedval != 0 {
21945                return Err(fidl::Error::NonZeroPadding {
21946                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21947                });
21948            }
21949            fidl::decode!(
21950                Usage2,
21951                fdomain_client::fidl::FDomainResourceDialect,
21952                &mut self.usage,
21953                decoder,
21954                offset + 0,
21955                _depth
21956            )?;
21957            fidl::decode!(
21958                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
21959                fdomain_client::fidl::FDomainResourceDialect,
21960                &mut self.usage_watcher,
21961                decoder,
21962                offset + 16,
21963                _depth
21964            )?;
21965            Ok(())
21966        }
21967    }
21968
21969    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
21970        type Borrowed<'a> = &'a mut Self;
21971        fn take_or_borrow<'a>(
21972            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21973        ) -> Self::Borrowed<'a> {
21974            value
21975        }
21976    }
21977
21978    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
21979        type Owned = Self;
21980
21981        #[inline(always)]
21982        fn inline_align(_context: fidl::encoding::Context) -> usize {
21983            8
21984        }
21985
21986        #[inline(always)]
21987        fn inline_size(_context: fidl::encoding::Context) -> usize {
21988            24
21989        }
21990    }
21991
21992    unsafe impl
21993        fidl::encoding::Encode<
21994            UsageReporterWatchRequest,
21995            fdomain_client::fidl::FDomainResourceDialect,
21996        > for &mut UsageReporterWatchRequest
21997    {
21998        #[inline]
21999        unsafe fn encode(
22000            self,
22001            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22002            offset: usize,
22003            _depth: fidl::encoding::Depth,
22004        ) -> fidl::Result<()> {
22005            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
22006            // Delegate to tuple encoding.
22007            fidl::encoding::Encode::<UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
22008                (
22009                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
22010                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
22011                ),
22012                encoder, offset, _depth
22013            )
22014        }
22015    }
22016    unsafe impl<
22017        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
22018        T1: fidl::encoding::Encode<
22019                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22020                fdomain_client::fidl::FDomainResourceDialect,
22021            >,
22022    >
22023        fidl::encoding::Encode<
22024            UsageReporterWatchRequest,
22025            fdomain_client::fidl::FDomainResourceDialect,
22026        > for (T0, T1)
22027    {
22028        #[inline]
22029        unsafe fn encode(
22030            self,
22031            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22032            offset: usize,
22033            depth: fidl::encoding::Depth,
22034        ) -> fidl::Result<()> {
22035            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
22036            // Zero out padding regions. There's no need to apply masks
22037            // because the unmasked parts will be overwritten by fields.
22038            unsafe {
22039                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22040                (ptr as *mut u64).write_unaligned(0);
22041            }
22042            // Write the fields.
22043            self.0.encode(encoder, offset + 0, depth)?;
22044            self.1.encode(encoder, offset + 16, depth)?;
22045            Ok(())
22046        }
22047    }
22048
22049    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
22050        for UsageReporterWatchRequest
22051    {
22052        #[inline(always)]
22053        fn new_empty() -> Self {
22054            Self {
22055                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
22056                usage_watcher: fidl::new_empty!(
22057                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22058                    fdomain_client::fidl::FDomainResourceDialect
22059                ),
22060            }
22061        }
22062
22063        #[inline]
22064        unsafe fn decode(
22065            &mut self,
22066            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22067            offset: usize,
22068            _depth: fidl::encoding::Depth,
22069        ) -> fidl::Result<()> {
22070            decoder.debug_check_bounds::<Self>(offset);
22071            // Verify that padding bytes are zero.
22072            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22073            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22074            let mask = 0xffffffff00000000u64;
22075            let maskedval = padval & mask;
22076            if maskedval != 0 {
22077                return Err(fidl::Error::NonZeroPadding {
22078                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22079                });
22080            }
22081            fidl::decode!(
22082                Usage,
22083                fdomain_client::fidl::FDomainResourceDialect,
22084                &mut self.usage,
22085                decoder,
22086                offset + 0,
22087                _depth
22088            )?;
22089            fidl::decode!(
22090                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22091                fdomain_client::fidl::FDomainResourceDialect,
22092                &mut self.usage_watcher,
22093                decoder,
22094                offset + 16,
22095                _depth
22096            )?;
22097            Ok(())
22098        }
22099    }
22100
22101    impl StreamBufferPartialSettings {
22102        #[inline(always)]
22103        fn max_ordinal_present(&self) -> u64 {
22104            if let Some(_) = self.sysmem2_token {
22105                return 7;
22106            }
22107            if let Some(_) = self.sysmem_token {
22108                return 6;
22109            }
22110            if let Some(_) = self.packet_count_for_client {
22111                return 5;
22112            }
22113            if let Some(_) = self.packet_count_for_server {
22114                return 4;
22115            }
22116            if let Some(_) = self.single_buffer_mode {
22117                return 3;
22118            }
22119            if let Some(_) = self.buffer_constraints_version_ordinal {
22120                return 2;
22121            }
22122            if let Some(_) = self.buffer_lifetime_ordinal {
22123                return 1;
22124            }
22125            0
22126        }
22127    }
22128
22129    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
22130        type Borrowed<'a> = &'a mut Self;
22131        fn take_or_borrow<'a>(
22132            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22133        ) -> Self::Borrowed<'a> {
22134            value
22135        }
22136    }
22137
22138    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
22139        type Owned = Self;
22140
22141        #[inline(always)]
22142        fn inline_align(_context: fidl::encoding::Context) -> usize {
22143            8
22144        }
22145
22146        #[inline(always)]
22147        fn inline_size(_context: fidl::encoding::Context) -> usize {
22148            16
22149        }
22150    }
22151
22152    unsafe impl
22153        fidl::encoding::Encode<
22154            StreamBufferPartialSettings,
22155            fdomain_client::fidl::FDomainResourceDialect,
22156        > for &mut StreamBufferPartialSettings
22157    {
22158        unsafe fn encode(
22159            self,
22160            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22161            offset: usize,
22162            mut depth: fidl::encoding::Depth,
22163        ) -> fidl::Result<()> {
22164            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
22165            // Vector header
22166            let max_ordinal: u64 = self.max_ordinal_present();
22167            encoder.write_num(max_ordinal, offset);
22168            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
22169            // Calling encoder.out_of_line_offset(0) is not allowed.
22170            if max_ordinal == 0 {
22171                return Ok(());
22172            }
22173            depth.increment()?;
22174            let envelope_size = 8;
22175            let bytes_len = max_ordinal as usize * envelope_size;
22176            #[allow(unused_variables)]
22177            let offset = encoder.out_of_line_offset(bytes_len);
22178            let mut _prev_end_offset: usize = 0;
22179            if 1 > max_ordinal {
22180                return Ok(());
22181            }
22182
22183            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22184            // are envelope_size bytes.
22185            let cur_offset: usize = (1 - 1) * envelope_size;
22186
22187            // Zero reserved fields.
22188            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22189
22190            // Safety:
22191            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22192            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22193            //   envelope_size bytes, there is always sufficient room.
22194            fidl::encoding::encode_in_envelope_optional::<
22195                u64,
22196                fdomain_client::fidl::FDomainResourceDialect,
22197            >(
22198                self.buffer_lifetime_ordinal
22199                    .as_ref()
22200                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22201                encoder,
22202                offset + cur_offset,
22203                depth,
22204            )?;
22205
22206            _prev_end_offset = cur_offset + envelope_size;
22207            if 2 > max_ordinal {
22208                return Ok(());
22209            }
22210
22211            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22212            // are envelope_size bytes.
22213            let cur_offset: usize = (2 - 1) * envelope_size;
22214
22215            // Zero reserved fields.
22216            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22217
22218            // Safety:
22219            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22220            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22221            //   envelope_size bytes, there is always sufficient room.
22222            fidl::encoding::encode_in_envelope_optional::<
22223                u64,
22224                fdomain_client::fidl::FDomainResourceDialect,
22225            >(
22226                self.buffer_constraints_version_ordinal
22227                    .as_ref()
22228                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22229                encoder,
22230                offset + cur_offset,
22231                depth,
22232            )?;
22233
22234            _prev_end_offset = cur_offset + envelope_size;
22235            if 3 > max_ordinal {
22236                return Ok(());
22237            }
22238
22239            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22240            // are envelope_size bytes.
22241            let cur_offset: usize = (3 - 1) * envelope_size;
22242
22243            // Zero reserved fields.
22244            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22245
22246            // Safety:
22247            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22248            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22249            //   envelope_size bytes, there is always sufficient room.
22250            fidl::encoding::encode_in_envelope_optional::<
22251                bool,
22252                fdomain_client::fidl::FDomainResourceDialect,
22253            >(
22254                self.single_buffer_mode
22255                    .as_ref()
22256                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
22257                encoder,
22258                offset + cur_offset,
22259                depth,
22260            )?;
22261
22262            _prev_end_offset = cur_offset + envelope_size;
22263            if 4 > max_ordinal {
22264                return Ok(());
22265            }
22266
22267            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22268            // are envelope_size bytes.
22269            let cur_offset: usize = (4 - 1) * envelope_size;
22270
22271            // Zero reserved fields.
22272            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22273
22274            // Safety:
22275            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22276            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22277            //   envelope_size bytes, there is always sufficient room.
22278            fidl::encoding::encode_in_envelope_optional::<
22279                u32,
22280                fdomain_client::fidl::FDomainResourceDialect,
22281            >(
22282                self.packet_count_for_server
22283                    .as_ref()
22284                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
22285                encoder,
22286                offset + cur_offset,
22287                depth,
22288            )?;
22289
22290            _prev_end_offset = cur_offset + envelope_size;
22291            if 5 > max_ordinal {
22292                return Ok(());
22293            }
22294
22295            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22296            // are envelope_size bytes.
22297            let cur_offset: usize = (5 - 1) * envelope_size;
22298
22299            // Zero reserved fields.
22300            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22301
22302            // Safety:
22303            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22304            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22305            //   envelope_size bytes, there is always sufficient room.
22306            fidl::encoding::encode_in_envelope_optional::<
22307                u32,
22308                fdomain_client::fidl::FDomainResourceDialect,
22309            >(
22310                self.packet_count_for_client
22311                    .as_ref()
22312                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
22313                encoder,
22314                offset + cur_offset,
22315                depth,
22316            )?;
22317
22318            _prev_end_offset = cur_offset + envelope_size;
22319            if 6 > max_ordinal {
22320                return Ok(());
22321            }
22322
22323            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22324            // are envelope_size bytes.
22325            let cur_offset: usize = (6 - 1) * envelope_size;
22326
22327            // Zero reserved fields.
22328            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22329
22330            // Safety:
22331            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22332            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22333            //   envelope_size bytes, there is always sufficient room.
22334            fidl::encoding::encode_in_envelope_optional::<
22335                fidl::encoding::Endpoint<
22336                    fdomain_client::fidl::ClientEnd<
22337                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22338                    >,
22339                >,
22340                fdomain_client::fidl::FDomainResourceDialect,
22341            >(
22342                self.sysmem_token.as_mut().map(
22343                    <fidl::encoding::Endpoint<
22344                        fdomain_client::fidl::ClientEnd<
22345                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22346                        >,
22347                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
22348                ),
22349                encoder,
22350                offset + cur_offset,
22351                depth,
22352            )?;
22353
22354            _prev_end_offset = cur_offset + envelope_size;
22355            if 7 > max_ordinal {
22356                return Ok(());
22357            }
22358
22359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22360            // are envelope_size bytes.
22361            let cur_offset: usize = (7 - 1) * envelope_size;
22362
22363            // Zero reserved fields.
22364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22365
22366            // Safety:
22367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22369            //   envelope_size bytes, there is always sufficient room.
22370            fidl::encoding::encode_in_envelope_optional::<
22371                fidl::encoding::Endpoint<
22372                    fdomain_client::fidl::ClientEnd<
22373                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22374                    >,
22375                >,
22376                fdomain_client::fidl::FDomainResourceDialect,
22377            >(
22378                self.sysmem2_token.as_mut().map(
22379                    <fidl::encoding::Endpoint<
22380                        fdomain_client::fidl::ClientEnd<
22381                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22382                        >,
22383                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
22384                ),
22385                encoder,
22386                offset + cur_offset,
22387                depth,
22388            )?;
22389
22390            _prev_end_offset = cur_offset + envelope_size;
22391
22392            Ok(())
22393        }
22394    }
22395
22396    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
22397        for StreamBufferPartialSettings
22398    {
22399        #[inline(always)]
22400        fn new_empty() -> Self {
22401            Self::default()
22402        }
22403
22404        unsafe fn decode(
22405            &mut self,
22406            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22407            offset: usize,
22408            mut depth: fidl::encoding::Depth,
22409        ) -> fidl::Result<()> {
22410            decoder.debug_check_bounds::<Self>(offset);
22411            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
22412                None => return Err(fidl::Error::NotNullable),
22413                Some(len) => len,
22414            };
22415            // Calling decoder.out_of_line_offset(0) is not allowed.
22416            if len == 0 {
22417                return Ok(());
22418            };
22419            depth.increment()?;
22420            let envelope_size = 8;
22421            let bytes_len = len * envelope_size;
22422            let offset = decoder.out_of_line_offset(bytes_len)?;
22423            // Decode the envelope for each type.
22424            let mut _next_ordinal_to_read = 0;
22425            let mut next_offset = offset;
22426            let end_offset = offset + bytes_len;
22427            _next_ordinal_to_read += 1;
22428            if next_offset >= end_offset {
22429                return Ok(());
22430            }
22431
22432            // Decode unknown envelopes for gaps in ordinals.
22433            while _next_ordinal_to_read < 1 {
22434                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22435                _next_ordinal_to_read += 1;
22436                next_offset += envelope_size;
22437            }
22438
22439            let next_out_of_line = decoder.next_out_of_line();
22440            let handles_before = decoder.remaining_handles();
22441            if let Some((inlined, num_bytes, num_handles)) =
22442                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22443            {
22444                let member_inline_size =
22445                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22446                if inlined != (member_inline_size <= 4) {
22447                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22448                }
22449                let inner_offset;
22450                let mut inner_depth = depth.clone();
22451                if inlined {
22452                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22453                    inner_offset = next_offset;
22454                } else {
22455                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22456                    inner_depth.increment()?;
22457                }
22458                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
22459                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
22460                });
22461                fidl::decode!(
22462                    u64,
22463                    fdomain_client::fidl::FDomainResourceDialect,
22464                    val_ref,
22465                    decoder,
22466                    inner_offset,
22467                    inner_depth
22468                )?;
22469                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22470                {
22471                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22472                }
22473                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22474                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22475                }
22476            }
22477
22478            next_offset += envelope_size;
22479            _next_ordinal_to_read += 1;
22480            if next_offset >= end_offset {
22481                return Ok(());
22482            }
22483
22484            // Decode unknown envelopes for gaps in ordinals.
22485            while _next_ordinal_to_read < 2 {
22486                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22487                _next_ordinal_to_read += 1;
22488                next_offset += envelope_size;
22489            }
22490
22491            let next_out_of_line = decoder.next_out_of_line();
22492            let handles_before = decoder.remaining_handles();
22493            if let Some((inlined, num_bytes, num_handles)) =
22494                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22495            {
22496                let member_inline_size =
22497                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22498                if inlined != (member_inline_size <= 4) {
22499                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22500                }
22501                let inner_offset;
22502                let mut inner_depth = depth.clone();
22503                if inlined {
22504                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22505                    inner_offset = next_offset;
22506                } else {
22507                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22508                    inner_depth.increment()?;
22509                }
22510                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
22511                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
22512                });
22513                fidl::decode!(
22514                    u64,
22515                    fdomain_client::fidl::FDomainResourceDialect,
22516                    val_ref,
22517                    decoder,
22518                    inner_offset,
22519                    inner_depth
22520                )?;
22521                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22522                {
22523                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22524                }
22525                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22526                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22527                }
22528            }
22529
22530            next_offset += envelope_size;
22531            _next_ordinal_to_read += 1;
22532            if next_offset >= end_offset {
22533                return Ok(());
22534            }
22535
22536            // Decode unknown envelopes for gaps in ordinals.
22537            while _next_ordinal_to_read < 3 {
22538                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22539                _next_ordinal_to_read += 1;
22540                next_offset += envelope_size;
22541            }
22542
22543            let next_out_of_line = decoder.next_out_of_line();
22544            let handles_before = decoder.remaining_handles();
22545            if let Some((inlined, num_bytes, num_handles)) =
22546                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22547            {
22548                let member_inline_size =
22549                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22550                if inlined != (member_inline_size <= 4) {
22551                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22552                }
22553                let inner_offset;
22554                let mut inner_depth = depth.clone();
22555                if inlined {
22556                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22557                    inner_offset = next_offset;
22558                } else {
22559                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22560                    inner_depth.increment()?;
22561                }
22562                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
22563                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
22564                });
22565                fidl::decode!(
22566                    bool,
22567                    fdomain_client::fidl::FDomainResourceDialect,
22568                    val_ref,
22569                    decoder,
22570                    inner_offset,
22571                    inner_depth
22572                )?;
22573                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22574                {
22575                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22576                }
22577                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22578                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22579                }
22580            }
22581
22582            next_offset += envelope_size;
22583            _next_ordinal_to_read += 1;
22584            if next_offset >= end_offset {
22585                return Ok(());
22586            }
22587
22588            // Decode unknown envelopes for gaps in ordinals.
22589            while _next_ordinal_to_read < 4 {
22590                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22591                _next_ordinal_to_read += 1;
22592                next_offset += envelope_size;
22593            }
22594
22595            let next_out_of_line = decoder.next_out_of_line();
22596            let handles_before = decoder.remaining_handles();
22597            if let Some((inlined, num_bytes, num_handles)) =
22598                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22599            {
22600                let member_inline_size =
22601                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22602                if inlined != (member_inline_size <= 4) {
22603                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22604                }
22605                let inner_offset;
22606                let mut inner_depth = depth.clone();
22607                if inlined {
22608                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22609                    inner_offset = next_offset;
22610                } else {
22611                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22612                    inner_depth.increment()?;
22613                }
22614                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
22615                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
22616                });
22617                fidl::decode!(
22618                    u32,
22619                    fdomain_client::fidl::FDomainResourceDialect,
22620                    val_ref,
22621                    decoder,
22622                    inner_offset,
22623                    inner_depth
22624                )?;
22625                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22626                {
22627                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22628                }
22629                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22630                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22631                }
22632            }
22633
22634            next_offset += envelope_size;
22635            _next_ordinal_to_read += 1;
22636            if next_offset >= end_offset {
22637                return Ok(());
22638            }
22639
22640            // Decode unknown envelopes for gaps in ordinals.
22641            while _next_ordinal_to_read < 5 {
22642                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22643                _next_ordinal_to_read += 1;
22644                next_offset += envelope_size;
22645            }
22646
22647            let next_out_of_line = decoder.next_out_of_line();
22648            let handles_before = decoder.remaining_handles();
22649            if let Some((inlined, num_bytes, num_handles)) =
22650                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22651            {
22652                let member_inline_size =
22653                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22654                if inlined != (member_inline_size <= 4) {
22655                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22656                }
22657                let inner_offset;
22658                let mut inner_depth = depth.clone();
22659                if inlined {
22660                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22661                    inner_offset = next_offset;
22662                } else {
22663                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22664                    inner_depth.increment()?;
22665                }
22666                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
22667                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
22668                });
22669                fidl::decode!(
22670                    u32,
22671                    fdomain_client::fidl::FDomainResourceDialect,
22672                    val_ref,
22673                    decoder,
22674                    inner_offset,
22675                    inner_depth
22676                )?;
22677                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22678                {
22679                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22680                }
22681                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22682                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22683                }
22684            }
22685
22686            next_offset += envelope_size;
22687            _next_ordinal_to_read += 1;
22688            if next_offset >= end_offset {
22689                return Ok(());
22690            }
22691
22692            // Decode unknown envelopes for gaps in ordinals.
22693            while _next_ordinal_to_read < 6 {
22694                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22695                _next_ordinal_to_read += 1;
22696                next_offset += envelope_size;
22697            }
22698
22699            let next_out_of_line = decoder.next_out_of_line();
22700            let handles_before = decoder.remaining_handles();
22701            if let Some((inlined, num_bytes, num_handles)) =
22702                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22703            {
22704                let member_inline_size = <fidl::encoding::Endpoint<
22705                    fdomain_client::fidl::ClientEnd<
22706                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22707                    >,
22708                > as fidl::encoding::TypeMarker>::inline_size(
22709                    decoder.context
22710                );
22711                if inlined != (member_inline_size <= 4) {
22712                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22713                }
22714                let inner_offset;
22715                let mut inner_depth = depth.clone();
22716                if inlined {
22717                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22718                    inner_offset = next_offset;
22719                } else {
22720                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22721                    inner_depth.increment()?;
22722                }
22723                let val_ref = self.sysmem_token.get_or_insert_with(|| {
22724                    fidl::new_empty!(
22725                        fidl::encoding::Endpoint<
22726                            fdomain_client::fidl::ClientEnd<
22727                                fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22728                            >,
22729                        >,
22730                        fdomain_client::fidl::FDomainResourceDialect
22731                    )
22732                });
22733                fidl::decode!(
22734                    fidl::encoding::Endpoint<
22735                        fdomain_client::fidl::ClientEnd<
22736                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22737                        >,
22738                    >,
22739                    fdomain_client::fidl::FDomainResourceDialect,
22740                    val_ref,
22741                    decoder,
22742                    inner_offset,
22743                    inner_depth
22744                )?;
22745                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22746                {
22747                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22748                }
22749                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22750                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22751                }
22752            }
22753
22754            next_offset += envelope_size;
22755            _next_ordinal_to_read += 1;
22756            if next_offset >= end_offset {
22757                return Ok(());
22758            }
22759
22760            // Decode unknown envelopes for gaps in ordinals.
22761            while _next_ordinal_to_read < 7 {
22762                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22763                _next_ordinal_to_read += 1;
22764                next_offset += envelope_size;
22765            }
22766
22767            let next_out_of_line = decoder.next_out_of_line();
22768            let handles_before = decoder.remaining_handles();
22769            if let Some((inlined, num_bytes, num_handles)) =
22770                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22771            {
22772                let member_inline_size = <fidl::encoding::Endpoint<
22773                    fdomain_client::fidl::ClientEnd<
22774                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22775                    >,
22776                > as fidl::encoding::TypeMarker>::inline_size(
22777                    decoder.context
22778                );
22779                if inlined != (member_inline_size <= 4) {
22780                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22781                }
22782                let inner_offset;
22783                let mut inner_depth = depth.clone();
22784                if inlined {
22785                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22786                    inner_offset = next_offset;
22787                } else {
22788                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22789                    inner_depth.increment()?;
22790                }
22791                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
22792                    fidl::new_empty!(
22793                        fidl::encoding::Endpoint<
22794                            fdomain_client::fidl::ClientEnd<
22795                                fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22796                            >,
22797                        >,
22798                        fdomain_client::fidl::FDomainResourceDialect
22799                    )
22800                });
22801                fidl::decode!(
22802                    fidl::encoding::Endpoint<
22803                        fdomain_client::fidl::ClientEnd<
22804                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22805                        >,
22806                    >,
22807                    fdomain_client::fidl::FDomainResourceDialect,
22808                    val_ref,
22809                    decoder,
22810                    inner_offset,
22811                    inner_depth
22812                )?;
22813                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22814                {
22815                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22816                }
22817                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22818                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22819                }
22820            }
22821
22822            next_offset += envelope_size;
22823
22824            // Decode the remaining unknown envelopes.
22825            while next_offset < end_offset {
22826                _next_ordinal_to_read += 1;
22827                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22828                next_offset += envelope_size;
22829            }
22830
22831            Ok(())
22832        }
22833    }
22834
22835    impl StreamProcessorAddBufferRequest {
22836        #[inline(always)]
22837        fn max_ordinal_present(&self) -> u64 {
22838            if let Some(_) = self.buffer {
22839                return 5;
22840            }
22841            if let Some(_) = self.buffer_index {
22842                return 4;
22843            }
22844            if let Some(_) = self.buffer_lifetime_ordinal {
22845                return 3;
22846            }
22847            if let Some(_) = self.buffer_constraints_version_ordinal {
22848                return 2;
22849            }
22850            if let Some(_) = self.port {
22851                return 1;
22852            }
22853            0
22854        }
22855    }
22856
22857    impl fidl::encoding::ResourceTypeMarker for StreamProcessorAddBufferRequest {
22858        type Borrowed<'a> = &'a mut Self;
22859        fn take_or_borrow<'a>(
22860            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22861        ) -> Self::Borrowed<'a> {
22862            value
22863        }
22864    }
22865
22866    unsafe impl fidl::encoding::TypeMarker for StreamProcessorAddBufferRequest {
22867        type Owned = Self;
22868
22869        #[inline(always)]
22870        fn inline_align(_context: fidl::encoding::Context) -> usize {
22871            8
22872        }
22873
22874        #[inline(always)]
22875        fn inline_size(_context: fidl::encoding::Context) -> usize {
22876            16
22877        }
22878    }
22879
22880    unsafe impl
22881        fidl::encoding::Encode<
22882            StreamProcessorAddBufferRequest,
22883            fdomain_client::fidl::FDomainResourceDialect,
22884        > for &mut StreamProcessorAddBufferRequest
22885    {
22886        unsafe fn encode(
22887            self,
22888            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22889            offset: usize,
22890            mut depth: fidl::encoding::Depth,
22891        ) -> fidl::Result<()> {
22892            encoder.debug_check_bounds::<StreamProcessorAddBufferRequest>(offset);
22893            // Vector header
22894            let max_ordinal: u64 = self.max_ordinal_present();
22895            encoder.write_num(max_ordinal, offset);
22896            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
22897            // Calling encoder.out_of_line_offset(0) is not allowed.
22898            if max_ordinal == 0 {
22899                return Ok(());
22900            }
22901            depth.increment()?;
22902            let envelope_size = 8;
22903            let bytes_len = max_ordinal as usize * envelope_size;
22904            #[allow(unused_variables)]
22905            let offset = encoder.out_of_line_offset(bytes_len);
22906            let mut _prev_end_offset: usize = 0;
22907            if 1 > max_ordinal {
22908                return Ok(());
22909            }
22910
22911            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22912            // are envelope_size bytes.
22913            let cur_offset: usize = (1 - 1) * envelope_size;
22914
22915            // Zero reserved fields.
22916            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22917
22918            // Safety:
22919            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22920            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22921            //   envelope_size bytes, there is always sufficient room.
22922            fidl::encoding::encode_in_envelope_optional::<
22923                Port,
22924                fdomain_client::fidl::FDomainResourceDialect,
22925            >(
22926                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
22927                encoder,
22928                offset + cur_offset,
22929                depth,
22930            )?;
22931
22932            _prev_end_offset = cur_offset + envelope_size;
22933            if 2 > max_ordinal {
22934                return Ok(());
22935            }
22936
22937            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22938            // are envelope_size bytes.
22939            let cur_offset: usize = (2 - 1) * envelope_size;
22940
22941            // Zero reserved fields.
22942            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22943
22944            // Safety:
22945            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22946            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22947            //   envelope_size bytes, there is always sufficient room.
22948            fidl::encoding::encode_in_envelope_optional::<
22949                u64,
22950                fdomain_client::fidl::FDomainResourceDialect,
22951            >(
22952                self.buffer_constraints_version_ordinal
22953                    .as_ref()
22954                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22955                encoder,
22956                offset + cur_offset,
22957                depth,
22958            )?;
22959
22960            _prev_end_offset = cur_offset + envelope_size;
22961            if 3 > max_ordinal {
22962                return Ok(());
22963            }
22964
22965            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22966            // are envelope_size bytes.
22967            let cur_offset: usize = (3 - 1) * envelope_size;
22968
22969            // Zero reserved fields.
22970            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22971
22972            // Safety:
22973            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22974            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22975            //   envelope_size bytes, there is always sufficient room.
22976            fidl::encoding::encode_in_envelope_optional::<
22977                u64,
22978                fdomain_client::fidl::FDomainResourceDialect,
22979            >(
22980                self.buffer_lifetime_ordinal
22981                    .as_ref()
22982                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22983                encoder,
22984                offset + cur_offset,
22985                depth,
22986            )?;
22987
22988            _prev_end_offset = cur_offset + envelope_size;
22989            if 4 > max_ordinal {
22990                return Ok(());
22991            }
22992
22993            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22994            // are envelope_size bytes.
22995            let cur_offset: usize = (4 - 1) * envelope_size;
22996
22997            // Zero reserved fields.
22998            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22999
23000            // Safety:
23001            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23002            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23003            //   envelope_size bytes, there is always sufficient room.
23004            fidl::encoding::encode_in_envelope_optional::<
23005                u32,
23006                fdomain_client::fidl::FDomainResourceDialect,
23007            >(
23008                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
23009                encoder,
23010                offset + cur_offset,
23011                depth,
23012            )?;
23013
23014            _prev_end_offset = cur_offset + envelope_size;
23015            if 5 > max_ordinal {
23016                return Ok(());
23017            }
23018
23019            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23020            // are envelope_size bytes.
23021            let cur_offset: usize = (5 - 1) * envelope_size;
23022
23023            // Zero reserved fields.
23024            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23025
23026            // Safety:
23027            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23028            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23029            //   envelope_size bytes, there is always sufficient room.
23030            fidl::encoding::encode_in_envelope_optional::<
23031                fidl::encoding::HandleType<
23032                    fdomain_client::Vmo,
23033                    { fidl::ObjectType::VMO.into_raw() },
23034                    2147483648,
23035                >,
23036                fdomain_client::fidl::FDomainResourceDialect,
23037            >(
23038                self.buffer.as_mut().map(
23039                    <fidl::encoding::HandleType<
23040                        fdomain_client::Vmo,
23041                        { fidl::ObjectType::VMO.into_raw() },
23042                        2147483648,
23043                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
23044                ),
23045                encoder,
23046                offset + cur_offset,
23047                depth,
23048            )?;
23049
23050            _prev_end_offset = cur_offset + envelope_size;
23051
23052            Ok(())
23053        }
23054    }
23055
23056    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
23057        for StreamProcessorAddBufferRequest
23058    {
23059        #[inline(always)]
23060        fn new_empty() -> Self {
23061            Self::default()
23062        }
23063
23064        unsafe fn decode(
23065            &mut self,
23066            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23067            offset: usize,
23068            mut depth: fidl::encoding::Depth,
23069        ) -> fidl::Result<()> {
23070            decoder.debug_check_bounds::<Self>(offset);
23071            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
23072                None => return Err(fidl::Error::NotNullable),
23073                Some(len) => len,
23074            };
23075            // Calling decoder.out_of_line_offset(0) is not allowed.
23076            if len == 0 {
23077                return Ok(());
23078            };
23079            depth.increment()?;
23080            let envelope_size = 8;
23081            let bytes_len = len * envelope_size;
23082            let offset = decoder.out_of_line_offset(bytes_len)?;
23083            // Decode the envelope for each type.
23084            let mut _next_ordinal_to_read = 0;
23085            let mut next_offset = offset;
23086            let end_offset = offset + bytes_len;
23087            _next_ordinal_to_read += 1;
23088            if next_offset >= end_offset {
23089                return Ok(());
23090            }
23091
23092            // Decode unknown envelopes for gaps in ordinals.
23093            while _next_ordinal_to_read < 1 {
23094                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23095                _next_ordinal_to_read += 1;
23096                next_offset += envelope_size;
23097            }
23098
23099            let next_out_of_line = decoder.next_out_of_line();
23100            let handles_before = decoder.remaining_handles();
23101            if let Some((inlined, num_bytes, num_handles)) =
23102                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23103            {
23104                let member_inline_size =
23105                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23106                if inlined != (member_inline_size <= 4) {
23107                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23108                }
23109                let inner_offset;
23110                let mut inner_depth = depth.clone();
23111                if inlined {
23112                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23113                    inner_offset = next_offset;
23114                } else {
23115                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23116                    inner_depth.increment()?;
23117                }
23118                let val_ref = self.port.get_or_insert_with(|| {
23119                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
23120                });
23121                fidl::decode!(
23122                    Port,
23123                    fdomain_client::fidl::FDomainResourceDialect,
23124                    val_ref,
23125                    decoder,
23126                    inner_offset,
23127                    inner_depth
23128                )?;
23129                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23130                {
23131                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23132                }
23133                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23134                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23135                }
23136            }
23137
23138            next_offset += envelope_size;
23139            _next_ordinal_to_read += 1;
23140            if next_offset >= end_offset {
23141                return Ok(());
23142            }
23143
23144            // Decode unknown envelopes for gaps in ordinals.
23145            while _next_ordinal_to_read < 2 {
23146                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23147                _next_ordinal_to_read += 1;
23148                next_offset += envelope_size;
23149            }
23150
23151            let next_out_of_line = decoder.next_out_of_line();
23152            let handles_before = decoder.remaining_handles();
23153            if let Some((inlined, num_bytes, num_handles)) =
23154                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23155            {
23156                let member_inline_size =
23157                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23158                if inlined != (member_inline_size <= 4) {
23159                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23160                }
23161                let inner_offset;
23162                let mut inner_depth = depth.clone();
23163                if inlined {
23164                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23165                    inner_offset = next_offset;
23166                } else {
23167                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23168                    inner_depth.increment()?;
23169                }
23170                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
23171                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23172                });
23173                fidl::decode!(
23174                    u64,
23175                    fdomain_client::fidl::FDomainResourceDialect,
23176                    val_ref,
23177                    decoder,
23178                    inner_offset,
23179                    inner_depth
23180                )?;
23181                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23182                {
23183                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23184                }
23185                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23186                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23187                }
23188            }
23189
23190            next_offset += envelope_size;
23191            _next_ordinal_to_read += 1;
23192            if next_offset >= end_offset {
23193                return Ok(());
23194            }
23195
23196            // Decode unknown envelopes for gaps in ordinals.
23197            while _next_ordinal_to_read < 3 {
23198                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23199                _next_ordinal_to_read += 1;
23200                next_offset += envelope_size;
23201            }
23202
23203            let next_out_of_line = decoder.next_out_of_line();
23204            let handles_before = decoder.remaining_handles();
23205            if let Some((inlined, num_bytes, num_handles)) =
23206                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23207            {
23208                let member_inline_size =
23209                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23210                if inlined != (member_inline_size <= 4) {
23211                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23212                }
23213                let inner_offset;
23214                let mut inner_depth = depth.clone();
23215                if inlined {
23216                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23217                    inner_offset = next_offset;
23218                } else {
23219                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23220                    inner_depth.increment()?;
23221                }
23222                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
23223                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23224                });
23225                fidl::decode!(
23226                    u64,
23227                    fdomain_client::fidl::FDomainResourceDialect,
23228                    val_ref,
23229                    decoder,
23230                    inner_offset,
23231                    inner_depth
23232                )?;
23233                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23234                {
23235                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23236                }
23237                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23238                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23239                }
23240            }
23241
23242            next_offset += envelope_size;
23243            _next_ordinal_to_read += 1;
23244            if next_offset >= end_offset {
23245                return Ok(());
23246            }
23247
23248            // Decode unknown envelopes for gaps in ordinals.
23249            while _next_ordinal_to_read < 4 {
23250                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23251                _next_ordinal_to_read += 1;
23252                next_offset += envelope_size;
23253            }
23254
23255            let next_out_of_line = decoder.next_out_of_line();
23256            let handles_before = decoder.remaining_handles();
23257            if let Some((inlined, num_bytes, num_handles)) =
23258                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23259            {
23260                let member_inline_size =
23261                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23262                if inlined != (member_inline_size <= 4) {
23263                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23264                }
23265                let inner_offset;
23266                let mut inner_depth = depth.clone();
23267                if inlined {
23268                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23269                    inner_offset = next_offset;
23270                } else {
23271                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23272                    inner_depth.increment()?;
23273                }
23274                let val_ref = self.buffer_index.get_or_insert_with(|| {
23275                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
23276                });
23277                fidl::decode!(
23278                    u32,
23279                    fdomain_client::fidl::FDomainResourceDialect,
23280                    val_ref,
23281                    decoder,
23282                    inner_offset,
23283                    inner_depth
23284                )?;
23285                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23286                {
23287                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23288                }
23289                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23290                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23291                }
23292            }
23293
23294            next_offset += envelope_size;
23295            _next_ordinal_to_read += 1;
23296            if next_offset >= end_offset {
23297                return Ok(());
23298            }
23299
23300            // Decode unknown envelopes for gaps in ordinals.
23301            while _next_ordinal_to_read < 5 {
23302                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23303                _next_ordinal_to_read += 1;
23304                next_offset += envelope_size;
23305            }
23306
23307            let next_out_of_line = decoder.next_out_of_line();
23308            let handles_before = decoder.remaining_handles();
23309            if let Some((inlined, num_bytes, num_handles)) =
23310                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23311            {
23312                let member_inline_size = <fidl::encoding::HandleType<
23313                    fdomain_client::Vmo,
23314                    { fidl::ObjectType::VMO.into_raw() },
23315                    2147483648,
23316                > as fidl::encoding::TypeMarker>::inline_size(
23317                    decoder.context
23318                );
23319                if inlined != (member_inline_size <= 4) {
23320                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23321                }
23322                let inner_offset;
23323                let mut inner_depth = depth.clone();
23324                if inlined {
23325                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23326                    inner_offset = next_offset;
23327                } else {
23328                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23329                    inner_depth.increment()?;
23330                }
23331                let val_ref =
23332                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
23333                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
23334                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23335                {
23336                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23337                }
23338                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23339                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23340                }
23341            }
23342
23343            next_offset += envelope_size;
23344
23345            // Decode the remaining unknown envelopes.
23346            while next_offset < end_offset {
23347                _next_ordinal_to_read += 1;
23348                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23349                next_offset += envelope_size;
23350            }
23351
23352            Ok(())
23353        }
23354    }
23355
23356    impl StreamProcessorParticipateInBufferAllocationRequest {
23357        #[inline(always)]
23358        fn max_ordinal_present(&self) -> u64 {
23359            if let Some(_) = self.allow_single_buffer {
23360                return 5;
23361            }
23362            if let Some(_) = self.buffer_lifetime_ordinal {
23363                return 4;
23364            }
23365            if let Some(_) = self.sysmem2_token {
23366                return 3;
23367            }
23368            if let Some(_) = self.buffer_constraints_version_ordinal {
23369                return 2;
23370            }
23371            if let Some(_) = self.port {
23372                return 1;
23373            }
23374            0
23375        }
23376    }
23377
23378    impl fidl::encoding::ResourceTypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
23379        type Borrowed<'a> = &'a mut Self;
23380        fn take_or_borrow<'a>(
23381            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23382        ) -> Self::Borrowed<'a> {
23383            value
23384        }
23385    }
23386
23387    unsafe impl fidl::encoding::TypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
23388        type Owned = Self;
23389
23390        #[inline(always)]
23391        fn inline_align(_context: fidl::encoding::Context) -> usize {
23392            8
23393        }
23394
23395        #[inline(always)]
23396        fn inline_size(_context: fidl::encoding::Context) -> usize {
23397            16
23398        }
23399    }
23400
23401    unsafe impl
23402        fidl::encoding::Encode<
23403            StreamProcessorParticipateInBufferAllocationRequest,
23404            fdomain_client::fidl::FDomainResourceDialect,
23405        > for &mut StreamProcessorParticipateInBufferAllocationRequest
23406    {
23407        unsafe fn encode(
23408            self,
23409            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23410            offset: usize,
23411            mut depth: fidl::encoding::Depth,
23412        ) -> fidl::Result<()> {
23413            encoder
23414                .debug_check_bounds::<StreamProcessorParticipateInBufferAllocationRequest>(offset);
23415            // Vector header
23416            let max_ordinal: u64 = self.max_ordinal_present();
23417            encoder.write_num(max_ordinal, offset);
23418            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
23419            // Calling encoder.out_of_line_offset(0) is not allowed.
23420            if max_ordinal == 0 {
23421                return Ok(());
23422            }
23423            depth.increment()?;
23424            let envelope_size = 8;
23425            let bytes_len = max_ordinal as usize * envelope_size;
23426            #[allow(unused_variables)]
23427            let offset = encoder.out_of_line_offset(bytes_len);
23428            let mut _prev_end_offset: usize = 0;
23429            if 1 > max_ordinal {
23430                return Ok(());
23431            }
23432
23433            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23434            // are envelope_size bytes.
23435            let cur_offset: usize = (1 - 1) * envelope_size;
23436
23437            // Zero reserved fields.
23438            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23439
23440            // Safety:
23441            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23442            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23443            //   envelope_size bytes, there is always sufficient room.
23444            fidl::encoding::encode_in_envelope_optional::<
23445                Port,
23446                fdomain_client::fidl::FDomainResourceDialect,
23447            >(
23448                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
23449                encoder,
23450                offset + cur_offset,
23451                depth,
23452            )?;
23453
23454            _prev_end_offset = cur_offset + envelope_size;
23455            if 2 > max_ordinal {
23456                return Ok(());
23457            }
23458
23459            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23460            // are envelope_size bytes.
23461            let cur_offset: usize = (2 - 1) * envelope_size;
23462
23463            // Zero reserved fields.
23464            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23465
23466            // Safety:
23467            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23468            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23469            //   envelope_size bytes, there is always sufficient room.
23470            fidl::encoding::encode_in_envelope_optional::<
23471                u64,
23472                fdomain_client::fidl::FDomainResourceDialect,
23473            >(
23474                self.buffer_constraints_version_ordinal
23475                    .as_ref()
23476                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23477                encoder,
23478                offset + cur_offset,
23479                depth,
23480            )?;
23481
23482            _prev_end_offset = cur_offset + envelope_size;
23483            if 3 > max_ordinal {
23484                return Ok(());
23485            }
23486
23487            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23488            // are envelope_size bytes.
23489            let cur_offset: usize = (3 - 1) * envelope_size;
23490
23491            // Zero reserved fields.
23492            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23493
23494            // Safety:
23495            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23496            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23497            //   envelope_size bytes, there is always sufficient room.
23498            fidl::encoding::encode_in_envelope_optional::<
23499                fidl::encoding::Endpoint<
23500                    fdomain_client::fidl::ClientEnd<
23501                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23502                    >,
23503                >,
23504                fdomain_client::fidl::FDomainResourceDialect,
23505            >(
23506                self.sysmem2_token.as_mut().map(
23507                    <fidl::encoding::Endpoint<
23508                        fdomain_client::fidl::ClientEnd<
23509                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23510                        >,
23511                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
23512                ),
23513                encoder,
23514                offset + cur_offset,
23515                depth,
23516            )?;
23517
23518            _prev_end_offset = cur_offset + envelope_size;
23519            if 4 > max_ordinal {
23520                return Ok(());
23521            }
23522
23523            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23524            // are envelope_size bytes.
23525            let cur_offset: usize = (4 - 1) * envelope_size;
23526
23527            // Zero reserved fields.
23528            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23529
23530            // Safety:
23531            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23532            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23533            //   envelope_size bytes, there is always sufficient room.
23534            fidl::encoding::encode_in_envelope_optional::<
23535                u64,
23536                fdomain_client::fidl::FDomainResourceDialect,
23537            >(
23538                self.buffer_lifetime_ordinal
23539                    .as_ref()
23540                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23541                encoder,
23542                offset + cur_offset,
23543                depth,
23544            )?;
23545
23546            _prev_end_offset = cur_offset + envelope_size;
23547            if 5 > max_ordinal {
23548                return Ok(());
23549            }
23550
23551            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23552            // are envelope_size bytes.
23553            let cur_offset: usize = (5 - 1) * envelope_size;
23554
23555            // Zero reserved fields.
23556            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23557
23558            // Safety:
23559            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23560            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23561            //   envelope_size bytes, there is always sufficient room.
23562            fidl::encoding::encode_in_envelope_optional::<
23563                bool,
23564                fdomain_client::fidl::FDomainResourceDialect,
23565            >(
23566                self.allow_single_buffer
23567                    .as_ref()
23568                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
23569                encoder,
23570                offset + cur_offset,
23571                depth,
23572            )?;
23573
23574            _prev_end_offset = cur_offset + envelope_size;
23575
23576            Ok(())
23577        }
23578    }
23579
23580    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
23581        for StreamProcessorParticipateInBufferAllocationRequest
23582    {
23583        #[inline(always)]
23584        fn new_empty() -> Self {
23585            Self::default()
23586        }
23587
23588        unsafe fn decode(
23589            &mut self,
23590            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23591            offset: usize,
23592            mut depth: fidl::encoding::Depth,
23593        ) -> fidl::Result<()> {
23594            decoder.debug_check_bounds::<Self>(offset);
23595            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
23596                None => return Err(fidl::Error::NotNullable),
23597                Some(len) => len,
23598            };
23599            // Calling decoder.out_of_line_offset(0) is not allowed.
23600            if len == 0 {
23601                return Ok(());
23602            };
23603            depth.increment()?;
23604            let envelope_size = 8;
23605            let bytes_len = len * envelope_size;
23606            let offset = decoder.out_of_line_offset(bytes_len)?;
23607            // Decode the envelope for each type.
23608            let mut _next_ordinal_to_read = 0;
23609            let mut next_offset = offset;
23610            let end_offset = offset + bytes_len;
23611            _next_ordinal_to_read += 1;
23612            if next_offset >= end_offset {
23613                return Ok(());
23614            }
23615
23616            // Decode unknown envelopes for gaps in ordinals.
23617            while _next_ordinal_to_read < 1 {
23618                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23619                _next_ordinal_to_read += 1;
23620                next_offset += envelope_size;
23621            }
23622
23623            let next_out_of_line = decoder.next_out_of_line();
23624            let handles_before = decoder.remaining_handles();
23625            if let Some((inlined, num_bytes, num_handles)) =
23626                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23627            {
23628                let member_inline_size =
23629                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23630                if inlined != (member_inline_size <= 4) {
23631                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23632                }
23633                let inner_offset;
23634                let mut inner_depth = depth.clone();
23635                if inlined {
23636                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23637                    inner_offset = next_offset;
23638                } else {
23639                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23640                    inner_depth.increment()?;
23641                }
23642                let val_ref = self.port.get_or_insert_with(|| {
23643                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
23644                });
23645                fidl::decode!(
23646                    Port,
23647                    fdomain_client::fidl::FDomainResourceDialect,
23648                    val_ref,
23649                    decoder,
23650                    inner_offset,
23651                    inner_depth
23652                )?;
23653                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23654                {
23655                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23656                }
23657                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23658                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23659                }
23660            }
23661
23662            next_offset += envelope_size;
23663            _next_ordinal_to_read += 1;
23664            if next_offset >= end_offset {
23665                return Ok(());
23666            }
23667
23668            // Decode unknown envelopes for gaps in ordinals.
23669            while _next_ordinal_to_read < 2 {
23670                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23671                _next_ordinal_to_read += 1;
23672                next_offset += envelope_size;
23673            }
23674
23675            let next_out_of_line = decoder.next_out_of_line();
23676            let handles_before = decoder.remaining_handles();
23677            if let Some((inlined, num_bytes, num_handles)) =
23678                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23679            {
23680                let member_inline_size =
23681                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23682                if inlined != (member_inline_size <= 4) {
23683                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23684                }
23685                let inner_offset;
23686                let mut inner_depth = depth.clone();
23687                if inlined {
23688                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23689                    inner_offset = next_offset;
23690                } else {
23691                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23692                    inner_depth.increment()?;
23693                }
23694                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
23695                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23696                });
23697                fidl::decode!(
23698                    u64,
23699                    fdomain_client::fidl::FDomainResourceDialect,
23700                    val_ref,
23701                    decoder,
23702                    inner_offset,
23703                    inner_depth
23704                )?;
23705                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23706                {
23707                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23708                }
23709                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23710                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23711                }
23712            }
23713
23714            next_offset += envelope_size;
23715            _next_ordinal_to_read += 1;
23716            if next_offset >= end_offset {
23717                return Ok(());
23718            }
23719
23720            // Decode unknown envelopes for gaps in ordinals.
23721            while _next_ordinal_to_read < 3 {
23722                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23723                _next_ordinal_to_read += 1;
23724                next_offset += envelope_size;
23725            }
23726
23727            let next_out_of_line = decoder.next_out_of_line();
23728            let handles_before = decoder.remaining_handles();
23729            if let Some((inlined, num_bytes, num_handles)) =
23730                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23731            {
23732                let member_inline_size = <fidl::encoding::Endpoint<
23733                    fdomain_client::fidl::ClientEnd<
23734                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23735                    >,
23736                > as fidl::encoding::TypeMarker>::inline_size(
23737                    decoder.context
23738                );
23739                if inlined != (member_inline_size <= 4) {
23740                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23741                }
23742                let inner_offset;
23743                let mut inner_depth = depth.clone();
23744                if inlined {
23745                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23746                    inner_offset = next_offset;
23747                } else {
23748                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23749                    inner_depth.increment()?;
23750                }
23751                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
23752                    fidl::new_empty!(
23753                        fidl::encoding::Endpoint<
23754                            fdomain_client::fidl::ClientEnd<
23755                                fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23756                            >,
23757                        >,
23758                        fdomain_client::fidl::FDomainResourceDialect
23759                    )
23760                });
23761                fidl::decode!(
23762                    fidl::encoding::Endpoint<
23763                        fdomain_client::fidl::ClientEnd<
23764                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23765                        >,
23766                    >,
23767                    fdomain_client::fidl::FDomainResourceDialect,
23768                    val_ref,
23769                    decoder,
23770                    inner_offset,
23771                    inner_depth
23772                )?;
23773                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23774                {
23775                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23776                }
23777                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23778                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23779                }
23780            }
23781
23782            next_offset += envelope_size;
23783            _next_ordinal_to_read += 1;
23784            if next_offset >= end_offset {
23785                return Ok(());
23786            }
23787
23788            // Decode unknown envelopes for gaps in ordinals.
23789            while _next_ordinal_to_read < 4 {
23790                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23791                _next_ordinal_to_read += 1;
23792                next_offset += envelope_size;
23793            }
23794
23795            let next_out_of_line = decoder.next_out_of_line();
23796            let handles_before = decoder.remaining_handles();
23797            if let Some((inlined, num_bytes, num_handles)) =
23798                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23799            {
23800                let member_inline_size =
23801                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23802                if inlined != (member_inline_size <= 4) {
23803                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23804                }
23805                let inner_offset;
23806                let mut inner_depth = depth.clone();
23807                if inlined {
23808                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23809                    inner_offset = next_offset;
23810                } else {
23811                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23812                    inner_depth.increment()?;
23813                }
23814                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
23815                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23816                });
23817                fidl::decode!(
23818                    u64,
23819                    fdomain_client::fidl::FDomainResourceDialect,
23820                    val_ref,
23821                    decoder,
23822                    inner_offset,
23823                    inner_depth
23824                )?;
23825                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23826                {
23827                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23828                }
23829                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23830                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23831                }
23832            }
23833
23834            next_offset += envelope_size;
23835            _next_ordinal_to_read += 1;
23836            if next_offset >= end_offset {
23837                return Ok(());
23838            }
23839
23840            // Decode unknown envelopes for gaps in ordinals.
23841            while _next_ordinal_to_read < 5 {
23842                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23843                _next_ordinal_to_read += 1;
23844                next_offset += envelope_size;
23845            }
23846
23847            let next_out_of_line = decoder.next_out_of_line();
23848            let handles_before = decoder.remaining_handles();
23849            if let Some((inlined, num_bytes, num_handles)) =
23850                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23851            {
23852                let member_inline_size =
23853                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23854                if inlined != (member_inline_size <= 4) {
23855                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23856                }
23857                let inner_offset;
23858                let mut inner_depth = depth.clone();
23859                if inlined {
23860                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23861                    inner_offset = next_offset;
23862                } else {
23863                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23864                    inner_depth.increment()?;
23865                }
23866                let val_ref = self.allow_single_buffer.get_or_insert_with(|| {
23867                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
23868                });
23869                fidl::decode!(
23870                    bool,
23871                    fdomain_client::fidl::FDomainResourceDialect,
23872                    val_ref,
23873                    decoder,
23874                    inner_offset,
23875                    inner_depth
23876                )?;
23877                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23878                {
23879                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23880                }
23881                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23882                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23883                }
23884            }
23885
23886            next_offset += envelope_size;
23887
23888            // Decode the remaining unknown envelopes.
23889            while next_offset < end_offset {
23890                _next_ordinal_to_read += 1;
23891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23892                next_offset += envelope_size;
23893            }
23894
23895            Ok(())
23896        }
23897    }
23898
23899    impl StreamProcessorRemoveBufferRequest {
23900        #[inline(always)]
23901        fn max_ordinal_present(&self) -> u64 {
23902            if let Some(_) = self.buffer_index {
23903                return 3;
23904            }
23905            if let Some(_) = self.buffer_lifetime_ordinal {
23906                return 2;
23907            }
23908            if let Some(_) = self.port {
23909                return 1;
23910            }
23911            0
23912        }
23913    }
23914
23915    impl fidl::encoding::ResourceTypeMarker for StreamProcessorRemoveBufferRequest {
23916        type Borrowed<'a> = &'a mut Self;
23917        fn take_or_borrow<'a>(
23918            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23919        ) -> Self::Borrowed<'a> {
23920            value
23921        }
23922    }
23923
23924    unsafe impl fidl::encoding::TypeMarker for StreamProcessorRemoveBufferRequest {
23925        type Owned = Self;
23926
23927        #[inline(always)]
23928        fn inline_align(_context: fidl::encoding::Context) -> usize {
23929            8
23930        }
23931
23932        #[inline(always)]
23933        fn inline_size(_context: fidl::encoding::Context) -> usize {
23934            16
23935        }
23936    }
23937
23938    unsafe impl
23939        fidl::encoding::Encode<
23940            StreamProcessorRemoveBufferRequest,
23941            fdomain_client::fidl::FDomainResourceDialect,
23942        > for &mut StreamProcessorRemoveBufferRequest
23943    {
23944        unsafe fn encode(
23945            self,
23946            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23947            offset: usize,
23948            mut depth: fidl::encoding::Depth,
23949        ) -> fidl::Result<()> {
23950            encoder.debug_check_bounds::<StreamProcessorRemoveBufferRequest>(offset);
23951            // Vector header
23952            let max_ordinal: u64 = self.max_ordinal_present();
23953            encoder.write_num(max_ordinal, offset);
23954            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
23955            // Calling encoder.out_of_line_offset(0) is not allowed.
23956            if max_ordinal == 0 {
23957                return Ok(());
23958            }
23959            depth.increment()?;
23960            let envelope_size = 8;
23961            let bytes_len = max_ordinal as usize * envelope_size;
23962            #[allow(unused_variables)]
23963            let offset = encoder.out_of_line_offset(bytes_len);
23964            let mut _prev_end_offset: usize = 0;
23965            if 1 > max_ordinal {
23966                return Ok(());
23967            }
23968
23969            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23970            // are envelope_size bytes.
23971            let cur_offset: usize = (1 - 1) * envelope_size;
23972
23973            // Zero reserved fields.
23974            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23975
23976            // Safety:
23977            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23978            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23979            //   envelope_size bytes, there is always sufficient room.
23980            fidl::encoding::encode_in_envelope_optional::<
23981                Port,
23982                fdomain_client::fidl::FDomainResourceDialect,
23983            >(
23984                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
23985                encoder,
23986                offset + cur_offset,
23987                depth,
23988            )?;
23989
23990            _prev_end_offset = cur_offset + envelope_size;
23991            if 2 > max_ordinal {
23992                return Ok(());
23993            }
23994
23995            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23996            // are envelope_size bytes.
23997            let cur_offset: usize = (2 - 1) * envelope_size;
23998
23999            // Zero reserved fields.
24000            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24001
24002            // Safety:
24003            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24004            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24005            //   envelope_size bytes, there is always sufficient room.
24006            fidl::encoding::encode_in_envelope_optional::<
24007                u64,
24008                fdomain_client::fidl::FDomainResourceDialect,
24009            >(
24010                self.buffer_lifetime_ordinal
24011                    .as_ref()
24012                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24013                encoder,
24014                offset + cur_offset,
24015                depth,
24016            )?;
24017
24018            _prev_end_offset = cur_offset + envelope_size;
24019            if 3 > max_ordinal {
24020                return Ok(());
24021            }
24022
24023            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24024            // are envelope_size bytes.
24025            let cur_offset: usize = (3 - 1) * envelope_size;
24026
24027            // Zero reserved fields.
24028            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24029
24030            // Safety:
24031            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24032            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24033            //   envelope_size bytes, there is always sufficient room.
24034            fidl::encoding::encode_in_envelope_optional::<
24035                u32,
24036                fdomain_client::fidl::FDomainResourceDialect,
24037            >(
24038                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24039                encoder,
24040                offset + cur_offset,
24041                depth,
24042            )?;
24043
24044            _prev_end_offset = cur_offset + envelope_size;
24045
24046            Ok(())
24047        }
24048    }
24049
24050    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
24051        for StreamProcessorRemoveBufferRequest
24052    {
24053        #[inline(always)]
24054        fn new_empty() -> Self {
24055            Self::default()
24056        }
24057
24058        unsafe fn decode(
24059            &mut self,
24060            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
24061            offset: usize,
24062            mut depth: fidl::encoding::Depth,
24063        ) -> fidl::Result<()> {
24064            decoder.debug_check_bounds::<Self>(offset);
24065            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
24066                None => return Err(fidl::Error::NotNullable),
24067                Some(len) => len,
24068            };
24069            // Calling decoder.out_of_line_offset(0) is not allowed.
24070            if len == 0 {
24071                return Ok(());
24072            };
24073            depth.increment()?;
24074            let envelope_size = 8;
24075            let bytes_len = len * envelope_size;
24076            let offset = decoder.out_of_line_offset(bytes_len)?;
24077            // Decode the envelope for each type.
24078            let mut _next_ordinal_to_read = 0;
24079            let mut next_offset = offset;
24080            let end_offset = offset + bytes_len;
24081            _next_ordinal_to_read += 1;
24082            if next_offset >= end_offset {
24083                return Ok(());
24084            }
24085
24086            // Decode unknown envelopes for gaps in ordinals.
24087            while _next_ordinal_to_read < 1 {
24088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24089                _next_ordinal_to_read += 1;
24090                next_offset += envelope_size;
24091            }
24092
24093            let next_out_of_line = decoder.next_out_of_line();
24094            let handles_before = decoder.remaining_handles();
24095            if let Some((inlined, num_bytes, num_handles)) =
24096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24097            {
24098                let member_inline_size =
24099                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24100                if inlined != (member_inline_size <= 4) {
24101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24102                }
24103                let inner_offset;
24104                let mut inner_depth = depth.clone();
24105                if inlined {
24106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24107                    inner_offset = next_offset;
24108                } else {
24109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24110                    inner_depth.increment()?;
24111                }
24112                let val_ref = self.port.get_or_insert_with(|| {
24113                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
24114                });
24115                fidl::decode!(
24116                    Port,
24117                    fdomain_client::fidl::FDomainResourceDialect,
24118                    val_ref,
24119                    decoder,
24120                    inner_offset,
24121                    inner_depth
24122                )?;
24123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24124                {
24125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24126                }
24127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24129                }
24130            }
24131
24132            next_offset += envelope_size;
24133            _next_ordinal_to_read += 1;
24134            if next_offset >= end_offset {
24135                return Ok(());
24136            }
24137
24138            // Decode unknown envelopes for gaps in ordinals.
24139            while _next_ordinal_to_read < 2 {
24140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24141                _next_ordinal_to_read += 1;
24142                next_offset += envelope_size;
24143            }
24144
24145            let next_out_of_line = decoder.next_out_of_line();
24146            let handles_before = decoder.remaining_handles();
24147            if let Some((inlined, num_bytes, num_handles)) =
24148                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24149            {
24150                let member_inline_size =
24151                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24152                if inlined != (member_inline_size <= 4) {
24153                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24154                }
24155                let inner_offset;
24156                let mut inner_depth = depth.clone();
24157                if inlined {
24158                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24159                    inner_offset = next_offset;
24160                } else {
24161                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24162                    inner_depth.increment()?;
24163                }
24164                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
24165                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
24166                });
24167                fidl::decode!(
24168                    u64,
24169                    fdomain_client::fidl::FDomainResourceDialect,
24170                    val_ref,
24171                    decoder,
24172                    inner_offset,
24173                    inner_depth
24174                )?;
24175                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24176                {
24177                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24178                }
24179                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24180                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24181                }
24182            }
24183
24184            next_offset += envelope_size;
24185            _next_ordinal_to_read += 1;
24186            if next_offset >= end_offset {
24187                return Ok(());
24188            }
24189
24190            // Decode unknown envelopes for gaps in ordinals.
24191            while _next_ordinal_to_read < 3 {
24192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24193                _next_ordinal_to_read += 1;
24194                next_offset += envelope_size;
24195            }
24196
24197            let next_out_of_line = decoder.next_out_of_line();
24198            let handles_before = decoder.remaining_handles();
24199            if let Some((inlined, num_bytes, num_handles)) =
24200                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24201            {
24202                let member_inline_size =
24203                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24204                if inlined != (member_inline_size <= 4) {
24205                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24206                }
24207                let inner_offset;
24208                let mut inner_depth = depth.clone();
24209                if inlined {
24210                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24211                    inner_offset = next_offset;
24212                } else {
24213                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24214                    inner_depth.increment()?;
24215                }
24216                let val_ref = self.buffer_index.get_or_insert_with(|| {
24217                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
24218                });
24219                fidl::decode!(
24220                    u32,
24221                    fdomain_client::fidl::FDomainResourceDialect,
24222                    val_ref,
24223                    decoder,
24224                    inner_offset,
24225                    inner_depth
24226                )?;
24227                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24228                {
24229                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24230                }
24231                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24232                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24233                }
24234            }
24235
24236            next_offset += envelope_size;
24237
24238            // Decode the remaining unknown envelopes.
24239            while next_offset < end_offset {
24240                _next_ordinal_to_read += 1;
24241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24242                next_offset += envelope_size;
24243            }
24244
24245            Ok(())
24246        }
24247    }
24248}