Skip to main content

fidl_fuchsia_media/
fidl_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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_media_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AudioCapturerBindGainControlRequest {
16    pub gain_control_request:
17        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AudioCapturerBindGainControlRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct AudioCapturerGetReferenceClockResponse {
27    pub reference_clock: fidl::Clock,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for AudioCapturerGetReferenceClockResponse
32{
33}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct AudioCapturerSetReferenceClockRequest {
37    pub reference_clock: Option<fidl::Clock>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for AudioCapturerSetReferenceClockRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct AudioConsumerBindVolumeControlRequest {
47    pub volume_control_request:
48        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for AudioConsumerBindVolumeControlRequest
53{
54}
55
56#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct AudioConsumerCreateStreamSinkRequest {
58    pub buffers: Vec<fidl::Vmo>,
59    pub stream_type: AudioStreamType,
60    pub compression: Option<Box<Compression>>,
61    pub stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for AudioConsumerCreateStreamSinkRequest
66{
67}
68
69#[derive(Debug, PartialEq)]
70pub struct AudioCoreBindUsageVolumeControl2Request {
71    pub usage: Usage2,
72    pub volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
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: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
87    for AudioCoreBindUsageVolumeControlRequest
88{
89}
90
91#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct AudioCoreCreateAudioCapturerRequest {
93    pub loopback: bool,
94    pub audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
98    for AudioCoreCreateAudioCapturerRequest
99{
100}
101
102#[derive(Debug, PartialEq)]
103pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
104    pub stream_type: AudioStreamType,
105    pub configuration: AudioCapturerConfiguration,
106    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
110    for AudioCoreCreateAudioCapturerWithConfigurationRequest
111{
112}
113
114#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
115pub struct AudioCoreCreateAudioRendererRequest {
116    pub audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
120    for AudioCoreCreateAudioRendererRequest
121{
122}
123
124#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
125pub struct AudioCreateAudioCapturerRequest {
126    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
127    pub loopback: bool,
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
131    for AudioCreateAudioCapturerRequest
132{
133}
134
135#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
136pub struct AudioCreateAudioRendererRequest {
137    pub audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
138}
139
140impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
141    for AudioCreateAudioRendererRequest
142{
143}
144
145#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
147    pub device_name: String,
148    pub is_input: bool,
149    pub channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
150}
151
152impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
153    for AudioDeviceEnumeratorAddDeviceByChannelRequest
154{
155}
156
157#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
158pub struct AudioRendererBindGainControlRequest {
159    pub gain_control_request:
160        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
164    for AudioRendererBindGainControlRequest
165{
166}
167
168#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
169pub struct AudioRendererGetReferenceClockResponse {
170    pub reference_clock: fidl::Clock,
171}
172
173impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
174    for AudioRendererGetReferenceClockResponse
175{
176}
177
178#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
179pub struct AudioRendererSetReferenceClockRequest {
180    pub reference_clock: Option<fidl::Clock>,
181}
182
183impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
184    for AudioRendererSetReferenceClockRequest
185{
186}
187
188#[derive(Debug, PartialEq, PartialOrd)]
189pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
190    pub thread_handle: fidl::Thread,
191    pub name: String,
192    pub period: i64,
193    pub capacity: f32,
194}
195
196impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
197    for ProfileProviderRegisterHandlerWithCapacityRequest
198{
199}
200
201#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
202pub struct ProfileProviderRegisterMemoryRangeRequest {
203    pub vmar_handle: fidl::Vmar,
204    pub name: String,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for ProfileProviderRegisterMemoryRangeRequest
209{
210}
211
212#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
213pub struct ProfileProviderUnregisterHandlerRequest {
214    pub thread_handle: fidl::Thread,
215    pub name: String,
216}
217
218impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
219    for ProfileProviderUnregisterHandlerRequest
220{
221}
222
223#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
224pub struct ProfileProviderUnregisterMemoryRangeRequest {
225    pub vmar_handle: fidl::Vmar,
226}
227
228impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
229    for ProfileProviderUnregisterMemoryRangeRequest
230{
231}
232
233#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
234pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
235    pub session_id: u64,
236    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
237}
238
239impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
240    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
241{
242}
243
244#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
245pub struct StreamBufferSetAddPayloadBufferRequest {
246    pub id: u32,
247    pub payload_buffer: fidl::Vmo,
248}
249
250impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
251    for StreamBufferSetAddPayloadBufferRequest
252{
253}
254
255#[derive(Debug, PartialEq)]
256pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
257    pub input_settings: StreamBufferPartialSettings,
258}
259
260impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
261    for StreamProcessorSetInputBufferPartialSettingsRequest
262{
263}
264
265#[derive(Debug, PartialEq)]
266pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
267    pub output_settings: StreamBufferPartialSettings,
268}
269
270impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
271    for StreamProcessorSetOutputBufferPartialSettingsRequest
272{
273}
274
275#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
276pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
277    pub usage: AudioRenderUsage2,
278    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
279}
280
281impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
282    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
283{
284}
285
286#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
287pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
288    pub usage: AudioRenderUsage,
289    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
290}
291
292impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
293    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
294{
295}
296
297#[derive(Debug, PartialEq)]
298pub struct UsageGainReporterRegisterListener2Request {
299    pub device_unique_id: String,
300    pub usage: Usage2,
301    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
302}
303
304impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
305    for UsageGainReporterRegisterListener2Request
306{
307}
308
309#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
310pub struct UsageGainReporterRegisterListenerRequest {
311    pub device_unique_id: String,
312    pub usage: Usage,
313    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
314}
315
316impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
317    for UsageGainReporterRegisterListenerRequest
318{
319}
320
321#[derive(Debug, PartialEq)]
322pub struct UsageReporterWatch2Request {
323    pub usage: Usage2,
324    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
325}
326
327impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
328    for UsageReporterWatch2Request
329{
330}
331
332#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
333pub struct UsageReporterWatchRequest {
334    pub usage: Usage,
335    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
336}
337
338impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UsageReporterWatchRequest {}
339
340#[derive(Debug, Default, PartialEq)]
341pub struct StreamBufferPartialSettings {
342    /// Each buffer is associated with a `buffer_lifetime_ordinal` value.
343    ///
344    /// There is a separate buffer_lifetime_ordinal for input vs. output.
345    ///
346    /// Values must be odd. Values must only increase (increasing by more than 2
347    /// is permitted).
348    ///
349    /// When using `SetInputBufferPartialSettings` or
350    /// `SetOutputBufferPartialSettings`, re-use of the same value (considering
351    /// input and output separately) for the new message is not allowed. Using
352    /// these messages, all the buffers of a given buffer_lifetime_ordinal value
353    /// are allocated as one sysmem buffer collection.
354    ///
355    /// When a new buffer_lifetime_ordinal starts, that also automatically
356    /// starts un-registering and releasing any buffers associated with prior
357    /// buffer_lifetime_ordinal values, but does not force them to complete
358    /// un-registration (or release) if they're still used by the codec for
359    /// reference purposes (VP9 can do this across a mid-stream dimensions
360    /// switch). A buffer can still be output by the server (as indicated by an
361    /// output packet) until un-registration completes.
362    ///
363    /// If the client wants the server to drop all buffers quickly, the client
364    /// can send `CloseCurrentStream` with `release_input_buffers` and/or
365    /// `release_output_buffers` set. This of course also stops decode of the
366    /// current stream. Closing the `StreamProcessor` client end is another
367    /// option.
368    pub buffer_lifetime_ordinal: Option<u64>,
369    /// This value indicates which version of constraints the client is/was
370    /// aware of so far.
371    ///
372    /// For input, this must always be 0 because constraints don't change for
373    /// input (settings can change, but there's no settings vs current
374    /// constraints synchronization issue on input).
375    ///
376    /// For output, this allows the server to know when the client is
377    /// sufficiently caught up before the server will generate any more output.
378    ///
379    /// When there is no active stream, a client is permitted to re-configure
380    /// buffers again using the same buffer_constraints_version_ordinal.
381    pub buffer_constraints_version_ordinal: Option<u64>,
382    pub single_buffer_mode: Option<bool>,
383    pub packet_count_for_server: Option<u32>,
384    pub packet_count_for_client: Option<u32>,
385    pub sysmem_token:
386        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>>,
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:
395        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
396    #[doc(hidden)]
397    pub __source_breaking: fidl::marker::SourceBreaking,
398}
399
400impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
401    for StreamBufferPartialSettings
402{
403}
404
405#[derive(Debug, Default, PartialEq)]
406pub struct StreamProcessorAddBufferRequest {
407    /// Must be set. Which port (input or output) the buffer is for.
408    pub port: Option<Port>,
409    /// Typically this is the latest buffer_constraints_version_ordinal
410    /// known to the client based on OnInputConstraints/OnOutputConstraints.
411    /// Older values are not harmful to correctness.
412    ///
413    /// The server will ignore this message if the server has already
414    /// created a later buffer_constraints_version_ordinal value that has
415    /// action_required true. If the server ignores this message, a later
416    /// RemoveBuffer for this buffer will complete quickly and without
417    /// creating an error.
418    ///
419    /// A client is not required to ensure that every call to AddBuffer with
420    /// the same buffer_lifetime_ordinal uses the same
421    /// buffer_constraints_version_ordinal, but the client must ensure that
422    /// all buffer_constraints_version_ordinal values which share the same
423    /// buffer_lifetime_ordinal are within the same action_required true
424    /// interval. Each such interval starts with a value that has
425    /// action_required true, and lasts until but not including the next
426    /// value with action_required true, or until the current value if there
427    /// is not yet a next value with action_required true. If this would
428    /// create a problem for a server, that server should set
429    /// action_required true instead of false.
430    pub buffer_constraints_version_ordinal: Option<u64>,
431    /// These values are scoped to input/output separately.
432    ///
433    /// The first message from the client with a new (higher)
434    /// buffer_lifetime_ordinal value begins removing all buffers on the
435    /// same port with lower buffer_lifetime_ordinal. However, until removal
436    /// is complete, the older buffers can still be used by the codec.
437    ///
438    /// The AddBuffer message adds the buffer to this
439    /// buffer_lifetime_ordinal.
440    pub buffer_lifetime_ordinal: Option<u64>,
441    /// The buffer_index values under a buffer_lifetime_ordinal must be
442    /// unique among all added but not yet fully removed buffers. This value
443    /// is initially allocated/specified by the client using this field, and
444    /// then both the client and the server will then refer to a this added
445    /// buffer uniquely using input vs output, buffer_lifetime_ordinal, and
446    /// the buffer_index (all three parts are needed to unambiguously
447    /// specify this buffer).
448    ///
449    /// See RemoveBuffer doc comments for how to safely remove a buffer and
450    /// potentially re-use a buffer_index value.
451    ///
452    /// In contrast to using
453    /// SetInputBufferPartialSettings/SetOutputBufferPartialSettings, when
454    /// using AddBuffer and RemoveBuffer, the StreamProcessor buffer_index
455    /// value has no relation to the sysmem buffer_index (under the sysmem
456    /// buffer_collection_id). Instead, the StreamProcessor buffer_index is
457    /// specified by this field, not by using sysmem's buffer_index. This
458    /// way, two buffers from two sysmem collections having the same sysmem
459    /// buffer_index (under separate buffer_collection_id(s)) can be
460    /// specified unambiguously in StreamProcessor messages.
461    pub buffer_index: Option<u32>,
462    /// This is a VMO handle that the server can use to access the sysmem
463    /// buffer.
464    ///
465    /// This VMO is required to have been provided by sysmem, and required
466    /// to be compatible with the server's sysmem constraints.
467    ///
468    /// The buffer_constraints_version_ordinal check occurs first, and
469    /// failure of that check just silently ignores the remainder of this
470    /// message without checking the buffer field (buffer is just dropped).
471    ///
472    /// If the buffer_constraints_version_ordinal check passes, but `buffer`
473    /// isn't a sysmem-provided VMO or isn't consistent with the server's
474    /// sysmem constraints, the server will close the StreamProcessor
475    /// server_end. The client can avoid triggering this failure case by
476    /// allocating the buffers per the following.
477    ///
478    /// For video decoder input buffers, the client can allocate the buffer
479    /// using sysmem, with participation of this or another instance of the
480    /// same codec implementation, using ParticipateInBufferAllocation with
481    /// Port.INPUT. The same StreamProcessor instance isn't required
482    /// in this case, only the same codec implementation. If using a
483    /// different StreamProcessor instance (but still from the same codec
484    /// implementation), the client should take care to create the two
485    /// StreamProcessor instances with the same requirements specified to
486    /// CodecFactory (for example with secure_input_mode and
487    /// secure_output_mode set the same way). Video decoder server
488    /// implementations with supports_dynamic_buffers true are required to
489    /// support allocating input buffers using one StreamProcessor instance
490    /// then using them with a different StreamProcessor instance (in
491    /// contrast, for output buffers, this is not required).
492    ///
493    /// For video decoder output buffers, this can be achieved by allocating
494    /// the buffer using sysmem, with participation of the same
495    /// StreamProcessor instance, using ParticipateInBufferAllocation with
496    /// Port.OUTPUT.
497    ///
498    /// Servers should verify that this VMO is (a) provided by sysmem, and
499    /// (b) meets the server's current sysmem constraints. The server can
500    /// verify both (a) and (b) by checking the result of sysmem's
501    /// CheckVmoConstraints before using this VMO. If that check fails, the
502    /// server can close the StreamProcessor server_end.
503    pub buffer: Option<fidl::Vmo>,
504    #[doc(hidden)]
505    pub __source_breaking: fidl::marker::SourceBreaking,
506}
507
508impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
509    for StreamProcessorAddBufferRequest
510{
511}
512
513#[derive(Debug, Default, PartialEq)]
514pub struct StreamProcessorParticipateInBufferAllocationRequest {
515    /// Which port (input or output) the buffer(s) are for.
516    ///
517    /// Must be set.
518    pub port: Option<Port>,
519    /// For input, this field must be set to 1, at least for now.
520    ///
521    /// For output, this field must set to the latest known (to the client)
522    /// buffer_constraints_version_ordinal value from the server. If the
523    /// value is less than the latest buffer_constraints_version_ordinal
524    /// created by the server which had action_reqiured true, then the
525    /// server will set generic sysmem constraints (just min_buffer_count 1)
526    /// and otherwise ignore this message. This is intended to allow
527    /// allocation to succeed (to allow simpler client error handling for
528    /// some clients); in this case a new buffer_constraints_version_ordinal
529    /// will reach the client and the client can catch up to the latest.
530    ///
531    /// If this value is a future value, the server will drop the
532    /// sysmem2_token which will cause allocation failure.
533    ///
534    /// Must be set.
535    pub buffer_constraints_version_ordinal: Option<u64>,
536    /// This sysmem token is used by the server to inform sysmem directly of
537    /// any applicable buffer constraints. These constraints are allowed to
538    /// (and in some cases must) depend on how this StreamProcessor instance
539    /// was created. For example, secure_input_mode/secure_output_mode
540    /// during StreamProcessor creation causes the server to set
541    /// secure_required for input/output respectively (as specified by
542    /// Port.INPUT or Port.OUTPUT respectively).
543    ///
544    /// Must be set.
545    pub sysmem2_token:
546        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
547    /// If set, and there's been at least one AddBuffer previously sent with
548    /// this buffer_lifetime_ordinal on the same StreamProcessor instance
549    /// which hasn't yet been removed server-side, the new buffer(s) will be
550    /// allocated with identical SingleBufferSettings, or fail allocation.
551    /// If any of the conditions in this paragraph aren't met, the effect is
552    /// the same as if this field is not set.
553    ///
554    /// If this field is not set, the sysmem constraints set by the server
555    /// will be suitable for a buffer of a new buffer_lifetime_ordinal, and
556    /// the new buffer's SingleBufferSettings might not match any previous
557    /// buffer's SingleBufferSettings.
558    ///
559    /// If the server has a current stream and `port` indicates the output
560    /// port, the constraints set will allow the stream to be correctly
561    /// processed across the switch to new buffer_lifetime_ordinal (assuming
562    /// the client is using a new buffer_lifetime_ordinal and adds the new
563    /// buffer(s) subsequently etc). If port indicates the input port, the
564    /// constraints set will be generic for the input port regardless of any
565    /// current stream.
566    ///
567    /// If this mechanism isn't used, the client must still ensure that all
568    /// AddBuffer with a given StreamProcessor instance, port, and
569    /// buffer_lifetime_ordinal have identical SingleBufferSettings. One way
570    /// to do this is to allocate all the buffers of a
571    /// buffer_lifetime_ordinal under a single sysmem buffer collection.
572    /// Another way is for the client to tell sysmem directly that a new
573    /// buffer collection must match the SingleBufferSettings of a prior
574    /// collection using
575    /// `[fuchsia.sysmem2/BufferCollectionConstraints.must_match_vmo]`
576    /// client-side.
577    ///
578    /// It's not recommended for a client to attempt to force a new
579    /// collecton's SingleBufferSettings to match an old collection's
580    /// SingleBufferSettings without sysmem's help and without
581    /// StreamProcessor's help via this field, because sysmem intentionally
582    /// allows clients participating in the same collection to be using
583    /// different versions of the sysmem interfaces, so the client may not
584    /// have enough information to successfully force the
585    /// SingleBufferSettings to match without using `must_match_vmo`, for
586    /// example if the client is unaware of a new SingleBufferSettings field
587    /// (or similar). The most common StreamProcessor server implementation
588    /// (CodecImpl) will handle this field using `must_match_vmo` on behalf
589    /// of the client as long as there's still at least one buffer of the
590    /// buffer_lifetime_ordinal active in the server. The ability to
591    /// dynamically add more buffers to an existing sysmem collection may be
592    /// added to sysmem at some point; that would give the client another
593    /// way to ensure identical SingleBufferSettings within a
594    /// buffer_lifetime_ordinal, but only if/when all sysmem collection
595    /// participants indicate support for a dynamic sysmem buffer
596    /// collection.
597    ///
598    /// For output, setting this field is strongly recommended if a client
599    /// is adding additional output buffers to an existing
600    /// buffer_lifetime_ordinal using a new/different sysmem buffer
601    /// collection, and setting this field is recommended for all output
602    /// buffer allocations.
603    ///
604    /// For input, if a client is using the same StreamProcessor instance
605    /// for this message and AddBuffer (which is itself recommended when
606    /// feasible), use of this field is recommended for those input buffers.
607    ///
608    /// If set, this value must match the buffer_lifetime_ordinal later sent
609    /// in AddBuffer.
610    ///
611    /// Clients should set this when feasible; see above.
612    pub buffer_lifetime_ordinal: Option<u64>,
613    /// If set to true, the server will leave all `buffer_count_*` fields
614    /// un-set when sending SetConstraints to sysmem, and will set
615    /// `min_buffer_count` to 1.
616    ///
617    /// If un-set or set to false, the server will fill out buffer count
618    /// fields when sending SetConstraints to sysmem based on the current
619    /// value of `buffer_count_for_server_current`, without any extra slack.
620    /// The client can add slack as desired via its own retained token.
621    ///
622    /// Regardless of whether this field is set to true, it's up to the
623    /// client to `AddBuffer` at least `buffer_count_for_server_current`
624    /// buffers so that processing can make progress.
625    pub allow_single_buffer: Option<bool>,
626    #[doc(hidden)]
627    pub __source_breaking: fidl::marker::SourceBreaking,
628}
629
630impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
631    for StreamProcessorParticipateInBufferAllocationRequest
632{
633}
634
635#[derive(Debug, Default, PartialEq)]
636pub struct StreamProcessorRemoveBufferRequest {
637    /// Must be set. Which port (input or output) the buffer is for.
638    pub port: Option<Port>,
639    /// Scoped to input or output, this is the buffer_lifetime_ordinal under
640    /// which the buffer_index is meaningful.
641    pub buffer_lifetime_ordinal: Option<u64>,
642    /// The buffer_index of the buffer previously established (and most
643    /// recently established) by AddBuffer, or by
644    /// SetInputBufferPartialSettings / SetOutputBufferPartialSettings. The
645    /// scope of this value is under input vs. output and under the
646    /// buffer_lifetime_ordinal value.
647    ///
648    /// When using dynamic buffers, the buffer_index values that are between
649    /// AddBuffer starting and RemoveBuffer completing (the active
650    /// buffer_index values) must be unique for a given Port value and
651    /// buffer_lifetime_ordinal value.
652    ///
653    /// Clients using dynamic buffers may wish to not re-use a buffer_index
654    /// value quickly upon completion of RemoveBuffer just to make
655    /// debugging/diagnosing easier, but technically re-use of buffer_index
656    /// in a subsequent AddBuffer is permitted as soon as RemoveBuffer
657    /// completes (from the StreamProcessor point of view - the client may
658    /// have its own reasons to not re-use that quickly). AddBuffer under an
659    /// old (not current) buffer_lifetime_ordinal is never allowed.
660    pub buffer_index: Option<u32>,
661    #[doc(hidden)]
662    pub __source_breaking: fidl::marker::SourceBreaking,
663}
664
665impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
666    for StreamProcessorRemoveBufferRequest
667{
668}
669
670#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
671pub struct ActivityReporterMarker;
672
673impl fidl::endpoints::ProtocolMarker for ActivityReporterMarker {
674    type Proxy = ActivityReporterProxy;
675    type RequestStream = ActivityReporterRequestStream;
676    #[cfg(target_os = "fuchsia")]
677    type SynchronousProxy = ActivityReporterSynchronousProxy;
678
679    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
680}
681impl fidl::endpoints::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#[derive(Debug)]
698#[cfg(target_os = "fuchsia")]
699pub struct ActivityReporterSynchronousProxy {
700    client: fidl::client::sync::Client,
701}
702
703#[cfg(target_os = "fuchsia")]
704impl fidl::endpoints::SynchronousProxy for ActivityReporterSynchronousProxy {
705    type Proxy = ActivityReporterProxy;
706    type Protocol = ActivityReporterMarker;
707
708    fn from_channel(inner: fidl::Channel) -> Self {
709        Self::new(inner)
710    }
711
712    fn into_channel(self) -> fidl::Channel {
713        self.client.into_channel()
714    }
715
716    fn as_channel(&self) -> &fidl::Channel {
717        self.client.as_channel()
718    }
719}
720
721#[cfg(target_os = "fuchsia")]
722impl ActivityReporterSynchronousProxy {
723    pub fn new(channel: fidl::Channel) -> Self {
724        Self { client: fidl::client::sync::Client::new(channel) }
725    }
726
727    pub fn into_channel(self) -> fidl::Channel {
728        self.client.into_channel()
729    }
730
731    /// Waits until an event arrives and returns it. It is safe for other
732    /// threads to make concurrent requests while waiting for an event.
733    pub fn wait_for_event(
734        &self,
735        deadline: zx::MonotonicInstant,
736    ) -> Result<ActivityReporterEvent, fidl::Error> {
737        ActivityReporterEvent::decode(
738            self.client.wait_for_event::<ActivityReporterMarker>(deadline)?,
739        )
740    }
741
742    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
743    /// It returns immediately the first time that it is called.
744    pub fn r#watch_render_activity(
745        &self,
746        ___deadline: zx::MonotonicInstant,
747    ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
748        let _response = self.client.send_query::<
749            fidl::encoding::EmptyPayload,
750            ActivityReporterWatchRenderActivityResponse,
751            ActivityReporterMarker,
752        >(
753            (),
754            0x2974e9f5880b2f1f,
755            fidl::encoding::DynamicFlags::empty(),
756            ___deadline,
757        )?;
758        Ok(_response.active_usages)
759    }
760
761    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
762    /// It returns immediately the first time that it is called.
763    pub fn r#watch_render_activity2(
764        &self,
765        ___deadline: zx::MonotonicInstant,
766    ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
767        let _response = self.client.send_query::<
768            fidl::encoding::EmptyPayload,
769            fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
770            ActivityReporterMarker,
771        >(
772            (),
773            0x484236fc11b363e6,
774            fidl::encoding::DynamicFlags::FLEXIBLE,
775            ___deadline,
776        )?
777        .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
778        Ok(_response.active_usages)
779    }
780
781    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
782    /// It returns immediately the first time that it is called.
783    pub fn r#watch_capture_activity(
784        &self,
785        ___deadline: zx::MonotonicInstant,
786    ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
787        let _response = self.client.send_query::<
788            fidl::encoding::EmptyPayload,
789            ActivityReporterWatchCaptureActivityResponse,
790            ActivityReporterMarker,
791        >(
792            (),
793            0x70e7038e9658e128,
794            fidl::encoding::DynamicFlags::empty(),
795            ___deadline,
796        )?;
797        Ok(_response.active_usages)
798    }
799
800    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
801    /// It returns immediately the first time that it is called.
802    pub fn r#watch_capture_activity2(
803        &self,
804        ___deadline: zx::MonotonicInstant,
805    ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
806        let _response = self.client.send_query::<
807            fidl::encoding::EmptyPayload,
808            fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
809            ActivityReporterMarker,
810        >(
811            (),
812            0x3d137e0364f9d550,
813            fidl::encoding::DynamicFlags::FLEXIBLE,
814            ___deadline,
815        )?
816        .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
817        Ok(_response.active_usages)
818    }
819}
820
821#[cfg(target_os = "fuchsia")]
822impl From<ActivityReporterSynchronousProxy> for zx::NullableHandle {
823    fn from(value: ActivityReporterSynchronousProxy) -> Self {
824        value.into_channel().into()
825    }
826}
827
828#[cfg(target_os = "fuchsia")]
829impl From<fidl::Channel> for ActivityReporterSynchronousProxy {
830    fn from(value: fidl::Channel) -> Self {
831        Self::new(value)
832    }
833}
834
835#[cfg(target_os = "fuchsia")]
836impl fidl::endpoints::FromClient for ActivityReporterSynchronousProxy {
837    type Protocol = ActivityReporterMarker;
838
839    fn from_client(value: fidl::endpoints::ClientEnd<ActivityReporterMarker>) -> Self {
840        Self::new(value.into_channel())
841    }
842}
843
844#[derive(Debug, Clone)]
845pub struct ActivityReporterProxy {
846    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
847}
848
849impl fidl::endpoints::Proxy for ActivityReporterProxy {
850    type Protocol = ActivityReporterMarker;
851
852    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
853        Self::new(inner)
854    }
855
856    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
857        self.client.into_channel().map_err(|client| Self { client })
858    }
859
860    fn as_channel(&self) -> &::fidl::AsyncChannel {
861        self.client.as_channel()
862    }
863}
864
865impl ActivityReporterProxy {
866    /// Create a new Proxy for fuchsia.media/ActivityReporter.
867    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
868        let protocol_name = <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
869        Self { client: fidl::client::Client::new(channel, protocol_name) }
870    }
871
872    /// Get a Stream of events from the remote end of the protocol.
873    ///
874    /// # Panics
875    ///
876    /// Panics if the event stream was already taken.
877    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
878        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
879    }
880
881    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
882    /// It returns immediately the first time that it is called.
883    pub fn r#watch_render_activity(
884        &self,
885    ) -> fidl::client::QueryResponseFut<
886        Vec<AudioRenderUsage>,
887        fidl::encoding::DefaultFuchsiaResourceDialect,
888    > {
889        ActivityReporterProxyInterface::r#watch_render_activity(self)
890    }
891
892    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
893    /// It returns immediately the first time that it is called.
894    pub fn r#watch_render_activity2(
895        &self,
896    ) -> fidl::client::QueryResponseFut<
897        Vec<AudioRenderUsage2>,
898        fidl::encoding::DefaultFuchsiaResourceDialect,
899    > {
900        ActivityReporterProxyInterface::r#watch_render_activity2(self)
901    }
902
903    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
904    /// It returns immediately the first time that it is called.
905    pub fn r#watch_capture_activity(
906        &self,
907    ) -> fidl::client::QueryResponseFut<
908        Vec<AudioCaptureUsage>,
909        fidl::encoding::DefaultFuchsiaResourceDialect,
910    > {
911        ActivityReporterProxyInterface::r#watch_capture_activity(self)
912    }
913
914    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
915    /// It returns immediately the first time that it is called.
916    pub fn r#watch_capture_activity2(
917        &self,
918    ) -> fidl::client::QueryResponseFut<
919        Vec<AudioCaptureUsage2>,
920        fidl::encoding::DefaultFuchsiaResourceDialect,
921    > {
922        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
923    }
924}
925
926impl ActivityReporterProxyInterface for ActivityReporterProxy {
927    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
928        Vec<AudioRenderUsage>,
929        fidl::encoding::DefaultFuchsiaResourceDialect,
930    >;
931    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
932        fn _decode(
933            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
934        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
935            let _response = fidl::client::decode_transaction_body::<
936                ActivityReporterWatchRenderActivityResponse,
937                fidl::encoding::DefaultFuchsiaResourceDialect,
938                0x2974e9f5880b2f1f,
939            >(_buf?)?;
940            Ok(_response.active_usages)
941        }
942        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
943            (),
944            0x2974e9f5880b2f1f,
945            fidl::encoding::DynamicFlags::empty(),
946            _decode,
947        )
948    }
949
950    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
951        Vec<AudioRenderUsage2>,
952        fidl::encoding::DefaultFuchsiaResourceDialect,
953    >;
954    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
955        fn _decode(
956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
957        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
958            let _response = fidl::client::decode_transaction_body::<
959                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
960                fidl::encoding::DefaultFuchsiaResourceDialect,
961                0x484236fc11b363e6,
962            >(_buf?)?
963            .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
964            Ok(_response.active_usages)
965        }
966        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
967            (),
968            0x484236fc11b363e6,
969            fidl::encoding::DynamicFlags::FLEXIBLE,
970            _decode,
971        )
972    }
973
974    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
975        Vec<AudioCaptureUsage>,
976        fidl::encoding::DefaultFuchsiaResourceDialect,
977    >;
978    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
979        fn _decode(
980            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
981        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
982            let _response = fidl::client::decode_transaction_body::<
983                ActivityReporterWatchCaptureActivityResponse,
984                fidl::encoding::DefaultFuchsiaResourceDialect,
985                0x70e7038e9658e128,
986            >(_buf?)?;
987            Ok(_response.active_usages)
988        }
989        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
990            (),
991            0x70e7038e9658e128,
992            fidl::encoding::DynamicFlags::empty(),
993            _decode,
994        )
995    }
996
997    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
998        Vec<AudioCaptureUsage2>,
999        fidl::encoding::DefaultFuchsiaResourceDialect,
1000    >;
1001    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
1002        fn _decode(
1003            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1004        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
1005            let _response = fidl::client::decode_transaction_body::<
1006                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
1007                fidl::encoding::DefaultFuchsiaResourceDialect,
1008                0x3d137e0364f9d550,
1009            >(_buf?)?
1010            .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
1011            Ok(_response.active_usages)
1012        }
1013        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
1014            (),
1015            0x3d137e0364f9d550,
1016            fidl::encoding::DynamicFlags::FLEXIBLE,
1017            _decode,
1018        )
1019    }
1020}
1021
1022pub struct ActivityReporterEventStream {
1023    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1024}
1025
1026impl std::marker::Unpin for ActivityReporterEventStream {}
1027
1028impl futures::stream::FusedStream for ActivityReporterEventStream {
1029    fn is_terminated(&self) -> bool {
1030        self.event_receiver.is_terminated()
1031    }
1032}
1033
1034impl futures::Stream for ActivityReporterEventStream {
1035    type Item = Result<ActivityReporterEvent, fidl::Error>;
1036
1037    fn poll_next(
1038        mut self: std::pin::Pin<&mut Self>,
1039        cx: &mut std::task::Context<'_>,
1040    ) -> std::task::Poll<Option<Self::Item>> {
1041        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1042            &mut self.event_receiver,
1043            cx
1044        )?) {
1045            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
1046            None => std::task::Poll::Ready(None),
1047        }
1048    }
1049}
1050
1051#[derive(Debug)]
1052pub enum ActivityReporterEvent {
1053    #[non_exhaustive]
1054    _UnknownEvent {
1055        /// Ordinal of the event that was sent.
1056        ordinal: u64,
1057    },
1058}
1059
1060impl ActivityReporterEvent {
1061    /// Decodes a message buffer as a [`ActivityReporterEvent`].
1062    fn decode(
1063        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1064    ) -> Result<ActivityReporterEvent, fidl::Error> {
1065        let (bytes, _handles) = buf.split_mut();
1066        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1067        debug_assert_eq!(tx_header.tx_id, 0);
1068        match tx_header.ordinal {
1069            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1070                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1071            }
1072            _ => Err(fidl::Error::UnknownOrdinal {
1073                ordinal: tx_header.ordinal,
1074                protocol_name:
1075                    <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1076            }),
1077        }
1078    }
1079}
1080
1081/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
1082pub struct ActivityReporterRequestStream {
1083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1084    is_terminated: bool,
1085}
1086
1087impl std::marker::Unpin for ActivityReporterRequestStream {}
1088
1089impl futures::stream::FusedStream for ActivityReporterRequestStream {
1090    fn is_terminated(&self) -> bool {
1091        self.is_terminated
1092    }
1093}
1094
1095impl fidl::endpoints::RequestStream for ActivityReporterRequestStream {
1096    type Protocol = ActivityReporterMarker;
1097    type ControlHandle = ActivityReporterControlHandle;
1098
1099    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1100        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1101    }
1102
1103    fn control_handle(&self) -> Self::ControlHandle {
1104        ActivityReporterControlHandle { inner: self.inner.clone() }
1105    }
1106
1107    fn into_inner(
1108        self,
1109    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1110    {
1111        (self.inner, self.is_terminated)
1112    }
1113
1114    fn from_inner(
1115        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1116        is_terminated: bool,
1117    ) -> Self {
1118        Self { inner, is_terminated }
1119    }
1120}
1121
1122impl futures::Stream for ActivityReporterRequestStream {
1123    type Item = Result<ActivityReporterRequest, fidl::Error>;
1124
1125    fn poll_next(
1126        mut self: std::pin::Pin<&mut Self>,
1127        cx: &mut std::task::Context<'_>,
1128    ) -> std::task::Poll<Option<Self::Item>> {
1129        let this = &mut *self;
1130        if this.inner.check_shutdown(cx) {
1131            this.is_terminated = true;
1132            return std::task::Poll::Ready(None);
1133        }
1134        if this.is_terminated {
1135            panic!("polled ActivityReporterRequestStream after completion");
1136        }
1137        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1138            |bytes, handles| {
1139                match this.inner.channel().read_etc(cx, bytes, handles) {
1140                    std::task::Poll::Ready(Ok(())) => {}
1141                    std::task::Poll::Pending => return std::task::Poll::Pending,
1142                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1143                        this.is_terminated = true;
1144                        return std::task::Poll::Ready(None);
1145                    }
1146                    std::task::Poll::Ready(Err(e)) => {
1147                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1148                            e.into(),
1149                        ))));
1150                    }
1151                }
1152
1153                // A message has been received from the channel
1154                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1155
1156                std::task::Poll::Ready(Some(match header.ordinal {
1157                    0x2974e9f5880b2f1f => {
1158                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1159                        let mut req = fidl::new_empty!(
1160                            fidl::encoding::EmptyPayload,
1161                            fidl::encoding::DefaultFuchsiaResourceDialect
1162                        );
1163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1164                        let control_handle =
1165                            ActivityReporterControlHandle { inner: this.inner.clone() };
1166                        Ok(ActivityReporterRequest::WatchRenderActivity {
1167                            responder: ActivityReporterWatchRenderActivityResponder {
1168                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1169                                tx_id: header.tx_id,
1170                            },
1171                        })
1172                    }
1173                    0x484236fc11b363e6 => {
1174                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1175                        let mut req = fidl::new_empty!(
1176                            fidl::encoding::EmptyPayload,
1177                            fidl::encoding::DefaultFuchsiaResourceDialect
1178                        );
1179                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1180                        let control_handle =
1181                            ActivityReporterControlHandle { inner: this.inner.clone() };
1182                        Ok(ActivityReporterRequest::WatchRenderActivity2 {
1183                            responder: ActivityReporterWatchRenderActivity2Responder {
1184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1185                                tx_id: header.tx_id,
1186                            },
1187                        })
1188                    }
1189                    0x70e7038e9658e128 => {
1190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1191                        let mut req = fidl::new_empty!(
1192                            fidl::encoding::EmptyPayload,
1193                            fidl::encoding::DefaultFuchsiaResourceDialect
1194                        );
1195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1196                        let control_handle =
1197                            ActivityReporterControlHandle { inner: this.inner.clone() };
1198                        Ok(ActivityReporterRequest::WatchCaptureActivity {
1199                            responder: ActivityReporterWatchCaptureActivityResponder {
1200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1201                                tx_id: header.tx_id,
1202                            },
1203                        })
1204                    }
1205                    0x3d137e0364f9d550 => {
1206                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1207                        let mut req = fidl::new_empty!(
1208                            fidl::encoding::EmptyPayload,
1209                            fidl::encoding::DefaultFuchsiaResourceDialect
1210                        );
1211                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1212                        let control_handle =
1213                            ActivityReporterControlHandle { inner: this.inner.clone() };
1214                        Ok(ActivityReporterRequest::WatchCaptureActivity2 {
1215                            responder: ActivityReporterWatchCaptureActivity2Responder {
1216                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1217                                tx_id: header.tx_id,
1218                            },
1219                        })
1220                    }
1221                    _ if header.tx_id == 0
1222                        && header
1223                            .dynamic_flags()
1224                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1225                    {
1226                        Ok(ActivityReporterRequest::_UnknownMethod {
1227                            ordinal: header.ordinal,
1228                            control_handle: ActivityReporterControlHandle {
1229                                inner: this.inner.clone(),
1230                            },
1231                            method_type: fidl::MethodType::OneWay,
1232                        })
1233                    }
1234                    _ if header
1235                        .dynamic_flags()
1236                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1237                    {
1238                        this.inner.send_framework_err(
1239                            fidl::encoding::FrameworkErr::UnknownMethod,
1240                            header.tx_id,
1241                            header.ordinal,
1242                            header.dynamic_flags(),
1243                            (bytes, handles),
1244                        )?;
1245                        Ok(ActivityReporterRequest::_UnknownMethod {
1246                            ordinal: header.ordinal,
1247                            control_handle: ActivityReporterControlHandle {
1248                                inner: this.inner.clone(),
1249                            },
1250                            method_type: fidl::MethodType::TwoWay,
1251                        })
1252                    }
1253                    _ => Err(fidl::Error::UnknownOrdinal {
1254                        ordinal: header.ordinal,
1255                        protocol_name:
1256                            <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1257                    }),
1258                }))
1259            },
1260        )
1261    }
1262}
1263
1264/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
1265#[derive(Debug)]
1266pub enum ActivityReporterRequest {
1267    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1268    /// It returns immediately the first time that it is called.
1269    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
1270    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1271    /// It returns immediately the first time that it is called.
1272    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
1273    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1274    /// It returns immediately the first time that it is called.
1275    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
1276    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1277    /// It returns immediately the first time that it is called.
1278    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
1279    /// An interaction was received which does not match any known method.
1280    #[non_exhaustive]
1281    _UnknownMethod {
1282        /// Ordinal of the method that was called.
1283        ordinal: u64,
1284        control_handle: ActivityReporterControlHandle,
1285        method_type: fidl::MethodType,
1286    },
1287}
1288
1289impl ActivityReporterRequest {
1290    #[allow(irrefutable_let_patterns)]
1291    pub fn into_watch_render_activity(
1292        self,
1293    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1294        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1295            Some((responder))
1296        } else {
1297            None
1298        }
1299    }
1300
1301    #[allow(irrefutable_let_patterns)]
1302    pub fn into_watch_render_activity2(
1303        self,
1304    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1305        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1306            Some((responder))
1307        } else {
1308            None
1309        }
1310    }
1311
1312    #[allow(irrefutable_let_patterns)]
1313    pub fn into_watch_capture_activity(
1314        self,
1315    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1316        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1317            Some((responder))
1318        } else {
1319            None
1320        }
1321    }
1322
1323    #[allow(irrefutable_let_patterns)]
1324    pub fn into_watch_capture_activity2(
1325        self,
1326    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1327        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1328            Some((responder))
1329        } else {
1330            None
1331        }
1332    }
1333
1334    /// Name of the method defined in FIDL
1335    pub fn method_name(&self) -> &'static str {
1336        match *self {
1337            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1338            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1339            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1340            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1341            ActivityReporterRequest::_UnknownMethod {
1342                method_type: fidl::MethodType::OneWay,
1343                ..
1344            } => "unknown one-way method",
1345            ActivityReporterRequest::_UnknownMethod {
1346                method_type: fidl::MethodType::TwoWay,
1347                ..
1348            } => "unknown two-way method",
1349        }
1350    }
1351}
1352
1353#[derive(Debug, Clone)]
1354pub struct ActivityReporterControlHandle {
1355    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1356}
1357
1358impl fidl::endpoints::ControlHandle for ActivityReporterControlHandle {
1359    fn shutdown(&self) {
1360        self.inner.shutdown()
1361    }
1362
1363    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1364        self.inner.shutdown_with_epitaph(status)
1365    }
1366
1367    fn is_closed(&self) -> bool {
1368        self.inner.channel().is_closed()
1369    }
1370    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1371        self.inner.channel().on_closed()
1372    }
1373
1374    #[cfg(target_os = "fuchsia")]
1375    fn signal_peer(
1376        &self,
1377        clear_mask: zx::Signals,
1378        set_mask: zx::Signals,
1379    ) -> Result<(), zx_status::Status> {
1380        use fidl::Peered;
1381        self.inner.channel().signal_peer(clear_mask, set_mask)
1382    }
1383}
1384
1385impl ActivityReporterControlHandle {}
1386
1387#[must_use = "FIDL methods require a response to be sent"]
1388#[derive(Debug)]
1389pub struct ActivityReporterWatchRenderActivityResponder {
1390    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1391    tx_id: u32,
1392}
1393
1394/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1395/// if the responder is dropped without sending a response, so that the client
1396/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1397impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1398    fn drop(&mut self) {
1399        self.control_handle.shutdown();
1400        // Safety: drops once, never accessed again
1401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1402    }
1403}
1404
1405impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivityResponder {
1406    type ControlHandle = ActivityReporterControlHandle;
1407
1408    fn control_handle(&self) -> &ActivityReporterControlHandle {
1409        &self.control_handle
1410    }
1411
1412    fn drop_without_shutdown(mut self) {
1413        // Safety: drops once, never accessed again due to mem::forget
1414        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1415        // Prevent Drop from running (which would shut down the channel)
1416        std::mem::forget(self);
1417    }
1418}
1419
1420impl ActivityReporterWatchRenderActivityResponder {
1421    /// Sends a response to the FIDL transaction.
1422    ///
1423    /// Sets the channel to shutdown if an error occurs.
1424    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1425        let _result = self.send_raw(active_usages);
1426        if _result.is_err() {
1427            self.control_handle.shutdown();
1428        }
1429        self.drop_without_shutdown();
1430        _result
1431    }
1432
1433    /// Similar to "send" but does not shutdown the channel if an error occurs.
1434    pub fn send_no_shutdown_on_err(
1435        self,
1436        mut active_usages: &[AudioRenderUsage],
1437    ) -> Result<(), fidl::Error> {
1438        let _result = self.send_raw(active_usages);
1439        self.drop_without_shutdown();
1440        _result
1441    }
1442
1443    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1444        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1445            (active_usages,),
1446            self.tx_id,
1447            0x2974e9f5880b2f1f,
1448            fidl::encoding::DynamicFlags::empty(),
1449        )
1450    }
1451}
1452
1453#[must_use = "FIDL methods require a response to be sent"]
1454#[derive(Debug)]
1455pub struct ActivityReporterWatchRenderActivity2Responder {
1456    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1457    tx_id: u32,
1458}
1459
1460/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1461/// if the responder is dropped without sending a response, so that the client
1462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1463impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1464    fn drop(&mut self) {
1465        self.control_handle.shutdown();
1466        // Safety: drops once, never accessed again
1467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468    }
1469}
1470
1471impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivity2Responder {
1472    type ControlHandle = ActivityReporterControlHandle;
1473
1474    fn control_handle(&self) -> &ActivityReporterControlHandle {
1475        &self.control_handle
1476    }
1477
1478    fn drop_without_shutdown(mut self) {
1479        // Safety: drops once, never accessed again due to mem::forget
1480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1481        // Prevent Drop from running (which would shut down the channel)
1482        std::mem::forget(self);
1483    }
1484}
1485
1486impl ActivityReporterWatchRenderActivity2Responder {
1487    /// Sends a response to the FIDL transaction.
1488    ///
1489    /// Sets the channel to shutdown if an error occurs.
1490    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(active_usages);
1492        if _result.is_err() {
1493            self.control_handle.shutdown();
1494        }
1495        self.drop_without_shutdown();
1496        _result
1497    }
1498
1499    /// Similar to "send" but does not shutdown the channel if an error occurs.
1500    pub fn send_no_shutdown_on_err(
1501        self,
1502        mut active_usages: &[AudioRenderUsage2],
1503    ) -> Result<(), fidl::Error> {
1504        let _result = self.send_raw(active_usages);
1505        self.drop_without_shutdown();
1506        _result
1507    }
1508
1509    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1510        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1511            ActivityReporterWatchRenderActivity2Response,
1512        >>(
1513            fidl::encoding::Flexible::new((active_usages,)),
1514            self.tx_id,
1515            0x484236fc11b363e6,
1516            fidl::encoding::DynamicFlags::FLEXIBLE,
1517        )
1518    }
1519}
1520
1521#[must_use = "FIDL methods require a response to be sent"]
1522#[derive(Debug)]
1523pub struct ActivityReporterWatchCaptureActivityResponder {
1524    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1525    tx_id: u32,
1526}
1527
1528/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1529/// if the responder is dropped without sending a response, so that the client
1530/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1531impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1532    fn drop(&mut self) {
1533        self.control_handle.shutdown();
1534        // Safety: drops once, never accessed again
1535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1536    }
1537}
1538
1539impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivityResponder {
1540    type ControlHandle = ActivityReporterControlHandle;
1541
1542    fn control_handle(&self) -> &ActivityReporterControlHandle {
1543        &self.control_handle
1544    }
1545
1546    fn drop_without_shutdown(mut self) {
1547        // Safety: drops once, never accessed again due to mem::forget
1548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1549        // Prevent Drop from running (which would shut down the channel)
1550        std::mem::forget(self);
1551    }
1552}
1553
1554impl ActivityReporterWatchCaptureActivityResponder {
1555    /// Sends a response to the FIDL transaction.
1556    ///
1557    /// Sets the channel to shutdown if an error occurs.
1558    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1559        let _result = self.send_raw(active_usages);
1560        if _result.is_err() {
1561            self.control_handle.shutdown();
1562        }
1563        self.drop_without_shutdown();
1564        _result
1565    }
1566
1567    /// Similar to "send" but does not shutdown the channel if an error occurs.
1568    pub fn send_no_shutdown_on_err(
1569        self,
1570        mut active_usages: &[AudioCaptureUsage],
1571    ) -> Result<(), fidl::Error> {
1572        let _result = self.send_raw(active_usages);
1573        self.drop_without_shutdown();
1574        _result
1575    }
1576
1577    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1578        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1579            (active_usages,),
1580            self.tx_id,
1581            0x70e7038e9658e128,
1582            fidl::encoding::DynamicFlags::empty(),
1583        )
1584    }
1585}
1586
1587#[must_use = "FIDL methods require a response to be sent"]
1588#[derive(Debug)]
1589pub struct ActivityReporterWatchCaptureActivity2Responder {
1590    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1591    tx_id: u32,
1592}
1593
1594/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1595/// if the responder is dropped without sending a response, so that the client
1596/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1597impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1598    fn drop(&mut self) {
1599        self.control_handle.shutdown();
1600        // Safety: drops once, never accessed again
1601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1602    }
1603}
1604
1605impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivity2Responder {
1606    type ControlHandle = ActivityReporterControlHandle;
1607
1608    fn control_handle(&self) -> &ActivityReporterControlHandle {
1609        &self.control_handle
1610    }
1611
1612    fn drop_without_shutdown(mut self) {
1613        // Safety: drops once, never accessed again due to mem::forget
1614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1615        // Prevent Drop from running (which would shut down the channel)
1616        std::mem::forget(self);
1617    }
1618}
1619
1620impl ActivityReporterWatchCaptureActivity2Responder {
1621    /// Sends a response to the FIDL transaction.
1622    ///
1623    /// Sets the channel to shutdown if an error occurs.
1624    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1625        let _result = self.send_raw(active_usages);
1626        if _result.is_err() {
1627            self.control_handle.shutdown();
1628        }
1629        self.drop_without_shutdown();
1630        _result
1631    }
1632
1633    /// Similar to "send" but does not shutdown the channel if an error occurs.
1634    pub fn send_no_shutdown_on_err(
1635        self,
1636        mut active_usages: &[AudioCaptureUsage2],
1637    ) -> Result<(), fidl::Error> {
1638        let _result = self.send_raw(active_usages);
1639        self.drop_without_shutdown();
1640        _result
1641    }
1642
1643    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1644        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1645            ActivityReporterWatchCaptureActivity2Response,
1646        >>(
1647            fidl::encoding::Flexible::new((active_usages,)),
1648            self.tx_id,
1649            0x3d137e0364f9d550,
1650            fidl::encoding::DynamicFlags::FLEXIBLE,
1651        )
1652    }
1653}
1654
1655#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1656pub struct AudioMarker;
1657
1658impl fidl::endpoints::ProtocolMarker for AudioMarker {
1659    type Proxy = AudioProxy;
1660    type RequestStream = AudioRequestStream;
1661    #[cfg(target_os = "fuchsia")]
1662    type SynchronousProxy = AudioSynchronousProxy;
1663
1664    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1665}
1666impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
1667
1668pub trait AudioProxyInterface: Send + Sync {
1669    fn r#create_audio_renderer(
1670        &self,
1671        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1672    ) -> Result<(), fidl::Error>;
1673    fn r#create_audio_capturer(
1674        &self,
1675        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1676        loopback: bool,
1677    ) -> Result<(), fidl::Error>;
1678}
1679#[derive(Debug)]
1680#[cfg(target_os = "fuchsia")]
1681pub struct AudioSynchronousProxy {
1682    client: fidl::client::sync::Client,
1683}
1684
1685#[cfg(target_os = "fuchsia")]
1686impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
1687    type Proxy = AudioProxy;
1688    type Protocol = AudioMarker;
1689
1690    fn from_channel(inner: fidl::Channel) -> Self {
1691        Self::new(inner)
1692    }
1693
1694    fn into_channel(self) -> fidl::Channel {
1695        self.client.into_channel()
1696    }
1697
1698    fn as_channel(&self) -> &fidl::Channel {
1699        self.client.as_channel()
1700    }
1701}
1702
1703#[cfg(target_os = "fuchsia")]
1704impl AudioSynchronousProxy {
1705    pub fn new(channel: fidl::Channel) -> Self {
1706        Self { client: fidl::client::sync::Client::new(channel) }
1707    }
1708
1709    pub fn into_channel(self) -> fidl::Channel {
1710        self.client.into_channel()
1711    }
1712
1713    /// Waits until an event arrives and returns it. It is safe for other
1714    /// threads to make concurrent requests while waiting for an event.
1715    pub fn wait_for_event(
1716        &self,
1717        deadline: zx::MonotonicInstant,
1718    ) -> Result<AudioEvent, fidl::Error> {
1719        AudioEvent::decode(self.client.wait_for_event::<AudioMarker>(deadline)?)
1720    }
1721
1722    pub fn r#create_audio_renderer(
1723        &self,
1724        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1725    ) -> Result<(), fidl::Error> {
1726        self.client.send::<AudioCreateAudioRendererRequest>(
1727            (audio_renderer_request,),
1728            0x572f413566fd58f1,
1729            fidl::encoding::DynamicFlags::empty(),
1730        )
1731    }
1732
1733    /// Creates an AudioCapturer which either captures from the current default
1734    /// audio input device, or loops-back from the current default audio output
1735    /// device based on value passed for the loopback flag.
1736    pub fn r#create_audio_capturer(
1737        &self,
1738        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1739        mut loopback: bool,
1740    ) -> Result<(), fidl::Error> {
1741        self.client.send::<AudioCreateAudioCapturerRequest>(
1742            (audio_capturer_request, loopback),
1743            0x44660fc63a6202f,
1744            fidl::encoding::DynamicFlags::empty(),
1745        )
1746    }
1747}
1748
1749#[cfg(target_os = "fuchsia")]
1750impl From<AudioSynchronousProxy> for zx::NullableHandle {
1751    fn from(value: AudioSynchronousProxy) -> Self {
1752        value.into_channel().into()
1753    }
1754}
1755
1756#[cfg(target_os = "fuchsia")]
1757impl From<fidl::Channel> for AudioSynchronousProxy {
1758    fn from(value: fidl::Channel) -> Self {
1759        Self::new(value)
1760    }
1761}
1762
1763#[cfg(target_os = "fuchsia")]
1764impl fidl::endpoints::FromClient for AudioSynchronousProxy {
1765    type Protocol = AudioMarker;
1766
1767    fn from_client(value: fidl::endpoints::ClientEnd<AudioMarker>) -> Self {
1768        Self::new(value.into_channel())
1769    }
1770}
1771
1772#[derive(Debug, Clone)]
1773pub struct AudioProxy {
1774    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1775}
1776
1777impl fidl::endpoints::Proxy for AudioProxy {
1778    type Protocol = AudioMarker;
1779
1780    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1781        Self::new(inner)
1782    }
1783
1784    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1785        self.client.into_channel().map_err(|client| Self { client })
1786    }
1787
1788    fn as_channel(&self) -> &::fidl::AsyncChannel {
1789        self.client.as_channel()
1790    }
1791}
1792
1793impl AudioProxy {
1794    /// Create a new Proxy for fuchsia.media/Audio.
1795    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1796        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1797        Self { client: fidl::client::Client::new(channel, protocol_name) }
1798    }
1799
1800    /// Get a Stream of events from the remote end of the protocol.
1801    ///
1802    /// # Panics
1803    ///
1804    /// Panics if the event stream was already taken.
1805    pub fn take_event_stream(&self) -> AudioEventStream {
1806        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1807    }
1808
1809    pub fn r#create_audio_renderer(
1810        &self,
1811        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1812    ) -> Result<(), fidl::Error> {
1813        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1814    }
1815
1816    /// Creates an AudioCapturer which either captures from the current default
1817    /// audio input device, or loops-back from the current default audio output
1818    /// device based on value passed for the loopback flag.
1819    pub fn r#create_audio_capturer(
1820        &self,
1821        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1822        mut loopback: bool,
1823    ) -> Result<(), fidl::Error> {
1824        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1825    }
1826}
1827
1828impl AudioProxyInterface for AudioProxy {
1829    fn r#create_audio_renderer(
1830        &self,
1831        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1832    ) -> Result<(), fidl::Error> {
1833        self.client.send::<AudioCreateAudioRendererRequest>(
1834            (audio_renderer_request,),
1835            0x572f413566fd58f1,
1836            fidl::encoding::DynamicFlags::empty(),
1837        )
1838    }
1839
1840    fn r#create_audio_capturer(
1841        &self,
1842        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1843        mut loopback: bool,
1844    ) -> Result<(), fidl::Error> {
1845        self.client.send::<AudioCreateAudioCapturerRequest>(
1846            (audio_capturer_request, loopback),
1847            0x44660fc63a6202f,
1848            fidl::encoding::DynamicFlags::empty(),
1849        )
1850    }
1851}
1852
1853pub struct AudioEventStream {
1854    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1855}
1856
1857impl std::marker::Unpin for AudioEventStream {}
1858
1859impl futures::stream::FusedStream for AudioEventStream {
1860    fn is_terminated(&self) -> bool {
1861        self.event_receiver.is_terminated()
1862    }
1863}
1864
1865impl futures::Stream for AudioEventStream {
1866    type Item = Result<AudioEvent, fidl::Error>;
1867
1868    fn poll_next(
1869        mut self: std::pin::Pin<&mut Self>,
1870        cx: &mut std::task::Context<'_>,
1871    ) -> std::task::Poll<Option<Self::Item>> {
1872        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1873            &mut self.event_receiver,
1874            cx
1875        )?) {
1876            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1877            None => std::task::Poll::Ready(None),
1878        }
1879    }
1880}
1881
1882#[derive(Debug)]
1883pub enum AudioEvent {}
1884
1885impl AudioEvent {
1886    /// Decodes a message buffer as a [`AudioEvent`].
1887    fn decode(
1888        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1889    ) -> Result<AudioEvent, fidl::Error> {
1890        let (bytes, _handles) = buf.split_mut();
1891        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1892        debug_assert_eq!(tx_header.tx_id, 0);
1893        match tx_header.ordinal {
1894            _ => Err(fidl::Error::UnknownOrdinal {
1895                ordinal: tx_header.ordinal,
1896                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1897            }),
1898        }
1899    }
1900}
1901
1902/// A Stream of incoming requests for fuchsia.media/Audio.
1903pub struct AudioRequestStream {
1904    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1905    is_terminated: bool,
1906}
1907
1908impl std::marker::Unpin for AudioRequestStream {}
1909
1910impl futures::stream::FusedStream for AudioRequestStream {
1911    fn is_terminated(&self) -> bool {
1912        self.is_terminated
1913    }
1914}
1915
1916impl fidl::endpoints::RequestStream for AudioRequestStream {
1917    type Protocol = AudioMarker;
1918    type ControlHandle = AudioControlHandle;
1919
1920    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1921        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1922    }
1923
1924    fn control_handle(&self) -> Self::ControlHandle {
1925        AudioControlHandle { inner: self.inner.clone() }
1926    }
1927
1928    fn into_inner(
1929        self,
1930    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1931    {
1932        (self.inner, self.is_terminated)
1933    }
1934
1935    fn from_inner(
1936        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1937        is_terminated: bool,
1938    ) -> Self {
1939        Self { inner, is_terminated }
1940    }
1941}
1942
1943impl futures::Stream for AudioRequestStream {
1944    type Item = Result<AudioRequest, fidl::Error>;
1945
1946    fn poll_next(
1947        mut self: std::pin::Pin<&mut Self>,
1948        cx: &mut std::task::Context<'_>,
1949    ) -> std::task::Poll<Option<Self::Item>> {
1950        let this = &mut *self;
1951        if this.inner.check_shutdown(cx) {
1952            this.is_terminated = true;
1953            return std::task::Poll::Ready(None);
1954        }
1955        if this.is_terminated {
1956            panic!("polled AudioRequestStream after completion");
1957        }
1958        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1959            |bytes, handles| {
1960                match this.inner.channel().read_etc(cx, bytes, handles) {
1961                    std::task::Poll::Ready(Ok(())) => {}
1962                    std::task::Poll::Pending => return std::task::Poll::Pending,
1963                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1964                        this.is_terminated = true;
1965                        return std::task::Poll::Ready(None);
1966                    }
1967                    std::task::Poll::Ready(Err(e)) => {
1968                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1969                            e.into(),
1970                        ))));
1971                    }
1972                }
1973
1974                // A message has been received from the channel
1975                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1976
1977                std::task::Poll::Ready(Some(match header.ordinal {
1978                    0x572f413566fd58f1 => {
1979                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1980                        let mut req = fidl::new_empty!(
1981                            AudioCreateAudioRendererRequest,
1982                            fidl::encoding::DefaultFuchsiaResourceDialect
1983                        );
1984                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1985                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1986                        Ok(AudioRequest::CreateAudioRenderer {
1987                            audio_renderer_request: req.audio_renderer_request,
1988
1989                            control_handle,
1990                        })
1991                    }
1992                    0x44660fc63a6202f => {
1993                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1994                        let mut req = fidl::new_empty!(
1995                            AudioCreateAudioCapturerRequest,
1996                            fidl::encoding::DefaultFuchsiaResourceDialect
1997                        );
1998                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1999                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
2000                        Ok(AudioRequest::CreateAudioCapturer {
2001                            audio_capturer_request: req.audio_capturer_request,
2002                            loopback: req.loopback,
2003
2004                            control_handle,
2005                        })
2006                    }
2007                    _ => Err(fidl::Error::UnknownOrdinal {
2008                        ordinal: header.ordinal,
2009                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2010                    }),
2011                }))
2012            },
2013        )
2014    }
2015}
2016
2017#[derive(Debug)]
2018pub enum AudioRequest {
2019    CreateAudioRenderer {
2020        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
2021        control_handle: AudioControlHandle,
2022    },
2023    /// Creates an AudioCapturer which either captures from the current default
2024    /// audio input device, or loops-back from the current default audio output
2025    /// device based on value passed for the loopback flag.
2026    CreateAudioCapturer {
2027        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
2028        loopback: bool,
2029        control_handle: AudioControlHandle,
2030    },
2031}
2032
2033impl AudioRequest {
2034    #[allow(irrefutable_let_patterns)]
2035    pub fn into_create_audio_renderer(
2036        self,
2037    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
2038        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
2039            Some((audio_renderer_request, control_handle))
2040        } else {
2041            None
2042        }
2043    }
2044
2045    #[allow(irrefutable_let_patterns)]
2046    pub fn into_create_audio_capturer(
2047        self,
2048    ) -> Option<(fidl::endpoints::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)> {
2049        if let AudioRequest::CreateAudioCapturer {
2050            audio_capturer_request,
2051            loopback,
2052            control_handle,
2053        } = self
2054        {
2055            Some((audio_capturer_request, loopback, control_handle))
2056        } else {
2057            None
2058        }
2059    }
2060
2061    /// Name of the method defined in FIDL
2062    pub fn method_name(&self) -> &'static str {
2063        match *self {
2064            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
2065            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
2066        }
2067    }
2068}
2069
2070#[derive(Debug, Clone)]
2071pub struct AudioControlHandle {
2072    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2073}
2074
2075impl fidl::endpoints::ControlHandle for AudioControlHandle {
2076    fn shutdown(&self) {
2077        self.inner.shutdown()
2078    }
2079
2080    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2081        self.inner.shutdown_with_epitaph(status)
2082    }
2083
2084    fn is_closed(&self) -> bool {
2085        self.inner.channel().is_closed()
2086    }
2087    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2088        self.inner.channel().on_closed()
2089    }
2090
2091    #[cfg(target_os = "fuchsia")]
2092    fn signal_peer(
2093        &self,
2094        clear_mask: zx::Signals,
2095        set_mask: zx::Signals,
2096    ) -> Result<(), zx_status::Status> {
2097        use fidl::Peered;
2098        self.inner.channel().signal_peer(clear_mask, set_mask)
2099    }
2100}
2101
2102impl AudioControlHandle {}
2103
2104#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2105pub struct AudioCapturerMarker;
2106
2107impl fidl::endpoints::ProtocolMarker for AudioCapturerMarker {
2108    type Proxy = AudioCapturerProxy;
2109    type RequestStream = AudioCapturerRequestStream;
2110    #[cfg(target_os = "fuchsia")]
2111    type SynchronousProxy = AudioCapturerSynchronousProxy;
2112
2113    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
2114}
2115impl fidl::endpoints::DiscoverableProtocolMarker for AudioCapturerMarker {}
2116
2117pub trait AudioCapturerProxyInterface: Send + Sync {
2118    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
2119    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
2120    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
2121    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2122    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
2123    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
2124    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
2125    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
2126        + Send;
2127    fn r#capture_at(
2128        &self,
2129        payload_buffer_id: u32,
2130        payload_offset: u32,
2131        frames: u32,
2132    ) -> Self::CaptureAtResponseFut;
2133    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
2134    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2135    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
2136    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
2137    fn r#bind_gain_control(
2138        &self,
2139        gain_control_request: fidl::endpoints::ServerEnd<
2140            fidl_fuchsia_media_audio::GainControlMarker,
2141        >,
2142    ) -> Result<(), fidl::Error>;
2143    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
2144        + Send;
2145    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
2146    fn r#set_reference_clock(
2147        &self,
2148        reference_clock: Option<fidl::Clock>,
2149    ) -> Result<(), fidl::Error>;
2150    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
2151    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
2152    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
2153        + Send;
2154    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
2155}
2156#[derive(Debug)]
2157#[cfg(target_os = "fuchsia")]
2158pub struct AudioCapturerSynchronousProxy {
2159    client: fidl::client::sync::Client,
2160}
2161
2162#[cfg(target_os = "fuchsia")]
2163impl fidl::endpoints::SynchronousProxy for AudioCapturerSynchronousProxy {
2164    type Proxy = AudioCapturerProxy;
2165    type Protocol = AudioCapturerMarker;
2166
2167    fn from_channel(inner: fidl::Channel) -> Self {
2168        Self::new(inner)
2169    }
2170
2171    fn into_channel(self) -> fidl::Channel {
2172        self.client.into_channel()
2173    }
2174
2175    fn as_channel(&self) -> &fidl::Channel {
2176        self.client.as_channel()
2177    }
2178}
2179
2180#[cfg(target_os = "fuchsia")]
2181impl AudioCapturerSynchronousProxy {
2182    pub fn new(channel: fidl::Channel) -> Self {
2183        Self { client: fidl::client::sync::Client::new(channel) }
2184    }
2185
2186    pub fn into_channel(self) -> fidl::Channel {
2187        self.client.into_channel()
2188    }
2189
2190    /// Waits until an event arrives and returns it. It is safe for other
2191    /// threads to make concurrent requests while waiting for an event.
2192    pub fn wait_for_event(
2193        &self,
2194        deadline: zx::MonotonicInstant,
2195    ) -> Result<AudioCapturerEvent, fidl::Error> {
2196        AudioCapturerEvent::decode(self.client.wait_for_event::<AudioCapturerMarker>(deadline)?)
2197    }
2198
2199    /// Adds a payload buffer to the current buffer set associated with the
2200    /// connection. A `StreamPacket` struct reference a payload buffer in the
2201    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2202    ///
2203    /// A buffer with ID `id` must not be in the current set when this method is
2204    /// invoked, otherwise the service will close the connection.
2205    pub fn r#add_payload_buffer(
2206        &self,
2207        mut id: u32,
2208        mut payload_buffer: fidl::Vmo,
2209    ) -> Result<(), fidl::Error> {
2210        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2211            (id, payload_buffer),
2212            0x3b3a37fc34fe5b56,
2213            fidl::encoding::DynamicFlags::empty(),
2214        )
2215    }
2216
2217    /// Removes a payload buffer from the current buffer set associated with the
2218    /// connection.
2219    ///
2220    /// A buffer with ID `id` must exist in the current set when this method is
2221    /// invoked, otherwise the service will will close the connection.
2222    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2223        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2224            (id,),
2225            0x5d1e4f74c3658262,
2226            fidl::encoding::DynamicFlags::empty(),
2227        )
2228    }
2229
2230    /// Releases payload memory associated with a packet previously delivered
2231    /// via `OnPacketProduced`.
2232    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2233        self.client.send::<StreamSourceReleasePacketRequest>(
2234            (packet,),
2235            0x7a7b57f0f7d9e4bb,
2236            fidl::encoding::DynamicFlags::empty(),
2237        )
2238    }
2239
2240    pub fn r#discard_all_packets(
2241        &self,
2242        ___deadline: zx::MonotonicInstant,
2243    ) -> Result<(), fidl::Error> {
2244        let _response = self.client.send_query::<
2245            fidl::encoding::EmptyPayload,
2246            fidl::encoding::EmptyPayload,
2247            AudioCapturerMarker,
2248        >(
2249            (),
2250            0x27afd605e97b09d2,
2251            fidl::encoding::DynamicFlags::empty(),
2252            ___deadline,
2253        )?;
2254        Ok(_response)
2255    }
2256
2257    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2258        self.client.send::<fidl::encoding::EmptyPayload>(
2259            (),
2260            0x35f9d721e905b831,
2261            fidl::encoding::DynamicFlags::empty(),
2262        )
2263    }
2264
2265    /// Sets the stream type of the stream to be delivered. Causes the source
2266    /// material to be reformatted/resampled if needed in order to produce the
2267    /// requested stream type. Must be called before the payload buffer is
2268    /// established.
2269    pub fn r#set_pcm_stream_type(
2270        &self,
2271        mut stream_type: &AudioStreamType,
2272    ) -> Result<(), fidl::Error> {
2273        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2274            (stream_type,),
2275            0x1531ea9ea2c852cd,
2276            fidl::encoding::DynamicFlags::empty(),
2277        )
2278    }
2279
2280    /// Explicitly specifies a region of the shared payload buffer for the audio
2281    /// input to capture into.
2282    pub fn r#capture_at(
2283        &self,
2284        mut payload_buffer_id: u32,
2285        mut payload_offset: u32,
2286        mut frames: u32,
2287        ___deadline: zx::MonotonicInstant,
2288    ) -> Result<StreamPacket, fidl::Error> {
2289        let _response = self.client.send_query::<
2290            AudioCapturerCaptureAtRequest,
2291            AudioCapturerCaptureAtResponse,
2292            AudioCapturerMarker,
2293        >(
2294            (payload_buffer_id, payload_offset, frames,),
2295            0x784e25df72cea780,
2296            fidl::encoding::DynamicFlags::empty(),
2297            ___deadline,
2298        )?;
2299        Ok(_response.captured_packet)
2300    }
2301
2302    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2303    /// packets of exactly 'frames_per_packet' number of frames each. The
2304    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2305    /// of produced packets.
2306    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2307        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2308            (frames_per_packet,),
2309            0x7768adbb1ccfd7a6,
2310            fidl::encoding::DynamicFlags::empty(),
2311        )
2312    }
2313
2314    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2315    /// that may be used by the client if explicit synchronization is needed.
2316    pub fn r#stop_async_capture(
2317        &self,
2318        ___deadline: zx::MonotonicInstant,
2319    ) -> Result<(), fidl::Error> {
2320        let _response = self.client.send_query::<
2321            fidl::encoding::EmptyPayload,
2322            fidl::encoding::EmptyPayload,
2323            AudioCapturerMarker,
2324        >(
2325            (),
2326            0x5bfc8790a8cef8cb,
2327            fidl::encoding::DynamicFlags::empty(),
2328            ___deadline,
2329        )?;
2330        Ok(_response)
2331    }
2332
2333    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2334        self.client.send::<fidl::encoding::EmptyPayload>(
2335            (),
2336            0x33223cb2962c95e3,
2337            fidl::encoding::DynamicFlags::empty(),
2338        )
2339    }
2340
2341    /// Binds to the gain control for this AudioCapturer.
2342    pub fn r#bind_gain_control(
2343        &self,
2344        mut gain_control_request: fidl::endpoints::ServerEnd<
2345            fidl_fuchsia_media_audio::GainControlMarker,
2346        >,
2347    ) -> Result<(), fidl::Error> {
2348        self.client.send::<AudioCapturerBindGainControlRequest>(
2349            (gain_control_request,),
2350            0x658a6a17ddb3a8e0,
2351            fidl::encoding::DynamicFlags::empty(),
2352        )
2353    }
2354
2355    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2356    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2357    pub fn r#get_reference_clock(
2358        &self,
2359        ___deadline: zx::MonotonicInstant,
2360    ) -> Result<fidl::Clock, fidl::Error> {
2361        let _response = self.client.send_query::<
2362            fidl::encoding::EmptyPayload,
2363            AudioCapturerGetReferenceClockResponse,
2364            AudioCapturerMarker,
2365        >(
2366            (),
2367            0x50d037aa5a4b4d71,
2368            fidl::encoding::DynamicFlags::empty(),
2369            ___deadline,
2370        )?;
2371        Ok(_response.reference_clock)
2372    }
2373
2374    /// Sets the reference clock that controls this capturer's playback rate. If the input
2375    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2376    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2377    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2378    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2379    ///
2380    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2381    /// added. It also cannot be called a second time (even before capture).
2382    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2383    /// diverge at some later time, they should create a clone of the monotonic clock, set
2384    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2385    pub fn r#set_reference_clock(
2386        &self,
2387        mut reference_clock: Option<fidl::Clock>,
2388    ) -> Result<(), fidl::Error> {
2389        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2390            (reference_clock,),
2391            0x732b2c496d521bcf,
2392            fidl::encoding::DynamicFlags::empty(),
2393        )
2394    }
2395
2396    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2397    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2398    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2399        self.client.send::<AudioCapturerSetUsageRequest>(
2400            (usage,),
2401            0x42a16f392bd21b25,
2402            fidl::encoding::DynamicFlags::empty(),
2403        )
2404    }
2405
2406    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2407    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2408    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2409        self.client.send::<AudioCapturerSetUsage2Request>(
2410            (usage,),
2411            0x7a73e251b8d2382b,
2412            fidl::encoding::DynamicFlags::FLEXIBLE,
2413        )
2414    }
2415
2416    /// Gets the currently configured stream type. Note: for an AudioCapturer
2417    /// which was just created and has not yet had its stream type explicitly
2418    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2419    /// was created -- of the source (input or looped-back output) to which the
2420    /// AudioCapturer is bound. Even if this matches the client's desired format,
2421    /// `SetPcmStreamType` must still be called.
2422    pub fn r#get_stream_type(
2423        &self,
2424        ___deadline: zx::MonotonicInstant,
2425    ) -> Result<StreamType, fidl::Error> {
2426        let _response = self.client.send_query::<
2427            fidl::encoding::EmptyPayload,
2428            AudioCapturerGetStreamTypeResponse,
2429            AudioCapturerMarker,
2430        >(
2431            (),
2432            0x5dcaaa670b433088,
2433            fidl::encoding::DynamicFlags::empty(),
2434            ___deadline,
2435        )?;
2436        Ok(_response.stream_type)
2437    }
2438}
2439
2440#[cfg(target_os = "fuchsia")]
2441impl From<AudioCapturerSynchronousProxy> for zx::NullableHandle {
2442    fn from(value: AudioCapturerSynchronousProxy) -> Self {
2443        value.into_channel().into()
2444    }
2445}
2446
2447#[cfg(target_os = "fuchsia")]
2448impl From<fidl::Channel> for AudioCapturerSynchronousProxy {
2449    fn from(value: fidl::Channel) -> Self {
2450        Self::new(value)
2451    }
2452}
2453
2454#[cfg(target_os = "fuchsia")]
2455impl fidl::endpoints::FromClient for AudioCapturerSynchronousProxy {
2456    type Protocol = AudioCapturerMarker;
2457
2458    fn from_client(value: fidl::endpoints::ClientEnd<AudioCapturerMarker>) -> Self {
2459        Self::new(value.into_channel())
2460    }
2461}
2462
2463#[derive(Debug, Clone)]
2464pub struct AudioCapturerProxy {
2465    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2466}
2467
2468impl fidl::endpoints::Proxy for AudioCapturerProxy {
2469    type Protocol = AudioCapturerMarker;
2470
2471    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2472        Self::new(inner)
2473    }
2474
2475    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2476        self.client.into_channel().map_err(|client| Self { client })
2477    }
2478
2479    fn as_channel(&self) -> &::fidl::AsyncChannel {
2480        self.client.as_channel()
2481    }
2482}
2483
2484impl AudioCapturerProxy {
2485    /// Create a new Proxy for fuchsia.media/AudioCapturer.
2486    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2487        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2488        Self { client: fidl::client::Client::new(channel, protocol_name) }
2489    }
2490
2491    /// Get a Stream of events from the remote end of the protocol.
2492    ///
2493    /// # Panics
2494    ///
2495    /// Panics if the event stream was already taken.
2496    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
2497        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
2498    }
2499
2500    /// Adds a payload buffer to the current buffer set associated with the
2501    /// connection. A `StreamPacket` struct reference a payload buffer in the
2502    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2503    ///
2504    /// A buffer with ID `id` must not be in the current set when this method is
2505    /// invoked, otherwise the service will close the connection.
2506    pub fn r#add_payload_buffer(
2507        &self,
2508        mut id: u32,
2509        mut payload_buffer: fidl::Vmo,
2510    ) -> Result<(), fidl::Error> {
2511        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
2512    }
2513
2514    /// Removes a payload buffer from the current buffer set associated with the
2515    /// connection.
2516    ///
2517    /// A buffer with ID `id` must exist in the current set when this method is
2518    /// invoked, otherwise the service will will close the connection.
2519    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2520        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
2521    }
2522
2523    /// Releases payload memory associated with a packet previously delivered
2524    /// via `OnPacketProduced`.
2525    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2526        AudioCapturerProxyInterface::r#release_packet(self, packet)
2527    }
2528
2529    pub fn r#discard_all_packets(
2530        &self,
2531    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2532        AudioCapturerProxyInterface::r#discard_all_packets(self)
2533    }
2534
2535    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2536        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
2537    }
2538
2539    /// Sets the stream type of the stream to be delivered. Causes the source
2540    /// material to be reformatted/resampled if needed in order to produce the
2541    /// requested stream type. Must be called before the payload buffer is
2542    /// established.
2543    pub fn r#set_pcm_stream_type(
2544        &self,
2545        mut stream_type: &AudioStreamType,
2546    ) -> Result<(), fidl::Error> {
2547        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
2548    }
2549
2550    /// Explicitly specifies a region of the shared payload buffer for the audio
2551    /// input to capture into.
2552    pub fn r#capture_at(
2553        &self,
2554        mut payload_buffer_id: u32,
2555        mut payload_offset: u32,
2556        mut frames: u32,
2557    ) -> fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>
2558    {
2559        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
2560    }
2561
2562    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2563    /// packets of exactly 'frames_per_packet' number of frames each. The
2564    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2565    /// of produced packets.
2566    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2567        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2568    }
2569
2570    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2571    /// that may be used by the client if explicit synchronization is needed.
2572    pub fn r#stop_async_capture(
2573        &self,
2574    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2575        AudioCapturerProxyInterface::r#stop_async_capture(self)
2576    }
2577
2578    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2579        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2580    }
2581
2582    /// Binds to the gain control for this AudioCapturer.
2583    pub fn r#bind_gain_control(
2584        &self,
2585        mut gain_control_request: fidl::endpoints::ServerEnd<
2586            fidl_fuchsia_media_audio::GainControlMarker,
2587        >,
2588    ) -> Result<(), fidl::Error> {
2589        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2590    }
2591
2592    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2593    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2594    pub fn r#get_reference_clock(
2595        &self,
2596    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
2597    {
2598        AudioCapturerProxyInterface::r#get_reference_clock(self)
2599    }
2600
2601    /// Sets the reference clock that controls this capturer's playback rate. If the input
2602    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2603    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2604    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2605    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2606    ///
2607    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2608    /// added. It also cannot be called a second time (even before capture).
2609    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2610    /// diverge at some later time, they should create a clone of the monotonic clock, set
2611    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2612    pub fn r#set_reference_clock(
2613        &self,
2614        mut reference_clock: Option<fidl::Clock>,
2615    ) -> Result<(), fidl::Error> {
2616        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2617    }
2618
2619    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2620    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2621    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2622        AudioCapturerProxyInterface::r#set_usage(self, usage)
2623    }
2624
2625    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2626    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2627    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2628        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2629    }
2630
2631    /// Gets the currently configured stream type. Note: for an AudioCapturer
2632    /// which was just created and has not yet had its stream type explicitly
2633    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2634    /// was created -- of the source (input or looped-back output) to which the
2635    /// AudioCapturer is bound. Even if this matches the client's desired format,
2636    /// `SetPcmStreamType` must still be called.
2637    pub fn r#get_stream_type(
2638        &self,
2639    ) -> fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>
2640    {
2641        AudioCapturerProxyInterface::r#get_stream_type(self)
2642    }
2643}
2644
2645impl AudioCapturerProxyInterface for AudioCapturerProxy {
2646    fn r#add_payload_buffer(
2647        &self,
2648        mut id: u32,
2649        mut payload_buffer: fidl::Vmo,
2650    ) -> Result<(), fidl::Error> {
2651        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2652            (id, payload_buffer),
2653            0x3b3a37fc34fe5b56,
2654            fidl::encoding::DynamicFlags::empty(),
2655        )
2656    }
2657
2658    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2659        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2660            (id,),
2661            0x5d1e4f74c3658262,
2662            fidl::encoding::DynamicFlags::empty(),
2663        )
2664    }
2665
2666    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2667        self.client.send::<StreamSourceReleasePacketRequest>(
2668            (packet,),
2669            0x7a7b57f0f7d9e4bb,
2670            fidl::encoding::DynamicFlags::empty(),
2671        )
2672    }
2673
2674    type DiscardAllPacketsResponseFut =
2675        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2676    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2677        fn _decode(
2678            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2679        ) -> Result<(), fidl::Error> {
2680            let _response = fidl::client::decode_transaction_body::<
2681                fidl::encoding::EmptyPayload,
2682                fidl::encoding::DefaultFuchsiaResourceDialect,
2683                0x27afd605e97b09d2,
2684            >(_buf?)?;
2685            Ok(_response)
2686        }
2687        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2688            (),
2689            0x27afd605e97b09d2,
2690            fidl::encoding::DynamicFlags::empty(),
2691            _decode,
2692        )
2693    }
2694
2695    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2696        self.client.send::<fidl::encoding::EmptyPayload>(
2697            (),
2698            0x35f9d721e905b831,
2699            fidl::encoding::DynamicFlags::empty(),
2700        )
2701    }
2702
2703    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2704        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2705            (stream_type,),
2706            0x1531ea9ea2c852cd,
2707            fidl::encoding::DynamicFlags::empty(),
2708        )
2709    }
2710
2711    type CaptureAtResponseFut =
2712        fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2713    fn r#capture_at(
2714        &self,
2715        mut payload_buffer_id: u32,
2716        mut payload_offset: u32,
2717        mut frames: u32,
2718    ) -> Self::CaptureAtResponseFut {
2719        fn _decode(
2720            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2721        ) -> Result<StreamPacket, fidl::Error> {
2722            let _response = fidl::client::decode_transaction_body::<
2723                AudioCapturerCaptureAtResponse,
2724                fidl::encoding::DefaultFuchsiaResourceDialect,
2725                0x784e25df72cea780,
2726            >(_buf?)?;
2727            Ok(_response.captured_packet)
2728        }
2729        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2730            (payload_buffer_id, payload_offset, frames),
2731            0x784e25df72cea780,
2732            fidl::encoding::DynamicFlags::empty(),
2733            _decode,
2734        )
2735    }
2736
2737    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2738        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2739            (frames_per_packet,),
2740            0x7768adbb1ccfd7a6,
2741            fidl::encoding::DynamicFlags::empty(),
2742        )
2743    }
2744
2745    type StopAsyncCaptureResponseFut =
2746        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2747    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2748        fn _decode(
2749            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2750        ) -> Result<(), fidl::Error> {
2751            let _response = fidl::client::decode_transaction_body::<
2752                fidl::encoding::EmptyPayload,
2753                fidl::encoding::DefaultFuchsiaResourceDialect,
2754                0x5bfc8790a8cef8cb,
2755            >(_buf?)?;
2756            Ok(_response)
2757        }
2758        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2759            (),
2760            0x5bfc8790a8cef8cb,
2761            fidl::encoding::DynamicFlags::empty(),
2762            _decode,
2763        )
2764    }
2765
2766    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2767        self.client.send::<fidl::encoding::EmptyPayload>(
2768            (),
2769            0x33223cb2962c95e3,
2770            fidl::encoding::DynamicFlags::empty(),
2771        )
2772    }
2773
2774    fn r#bind_gain_control(
2775        &self,
2776        mut gain_control_request: fidl::endpoints::ServerEnd<
2777            fidl_fuchsia_media_audio::GainControlMarker,
2778        >,
2779    ) -> Result<(), fidl::Error> {
2780        self.client.send::<AudioCapturerBindGainControlRequest>(
2781            (gain_control_request,),
2782            0x658a6a17ddb3a8e0,
2783            fidl::encoding::DynamicFlags::empty(),
2784        )
2785    }
2786
2787    type GetReferenceClockResponseFut =
2788        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
2789    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2790        fn _decode(
2791            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2792        ) -> Result<fidl::Clock, fidl::Error> {
2793            let _response = fidl::client::decode_transaction_body::<
2794                AudioCapturerGetReferenceClockResponse,
2795                fidl::encoding::DefaultFuchsiaResourceDialect,
2796                0x50d037aa5a4b4d71,
2797            >(_buf?)?;
2798            Ok(_response.reference_clock)
2799        }
2800        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
2801            (),
2802            0x50d037aa5a4b4d71,
2803            fidl::encoding::DynamicFlags::empty(),
2804            _decode,
2805        )
2806    }
2807
2808    fn r#set_reference_clock(
2809        &self,
2810        mut reference_clock: Option<fidl::Clock>,
2811    ) -> Result<(), fidl::Error> {
2812        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2813            (reference_clock,),
2814            0x732b2c496d521bcf,
2815            fidl::encoding::DynamicFlags::empty(),
2816        )
2817    }
2818
2819    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2820        self.client.send::<AudioCapturerSetUsageRequest>(
2821            (usage,),
2822            0x42a16f392bd21b25,
2823            fidl::encoding::DynamicFlags::empty(),
2824        )
2825    }
2826
2827    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2828        self.client.send::<AudioCapturerSetUsage2Request>(
2829            (usage,),
2830            0x7a73e251b8d2382b,
2831            fidl::encoding::DynamicFlags::FLEXIBLE,
2832        )
2833    }
2834
2835    type GetStreamTypeResponseFut =
2836        fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>;
2837    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2838        fn _decode(
2839            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2840        ) -> Result<StreamType, fidl::Error> {
2841            let _response = fidl::client::decode_transaction_body::<
2842                AudioCapturerGetStreamTypeResponse,
2843                fidl::encoding::DefaultFuchsiaResourceDialect,
2844                0x5dcaaa670b433088,
2845            >(_buf?)?;
2846            Ok(_response.stream_type)
2847        }
2848        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2849            (),
2850            0x5dcaaa670b433088,
2851            fidl::encoding::DynamicFlags::empty(),
2852            _decode,
2853        )
2854    }
2855}
2856
2857pub struct AudioCapturerEventStream {
2858    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2859}
2860
2861impl std::marker::Unpin for AudioCapturerEventStream {}
2862
2863impl futures::stream::FusedStream for AudioCapturerEventStream {
2864    fn is_terminated(&self) -> bool {
2865        self.event_receiver.is_terminated()
2866    }
2867}
2868
2869impl futures::Stream for AudioCapturerEventStream {
2870    type Item = Result<AudioCapturerEvent, fidl::Error>;
2871
2872    fn poll_next(
2873        mut self: std::pin::Pin<&mut Self>,
2874        cx: &mut std::task::Context<'_>,
2875    ) -> std::task::Poll<Option<Self::Item>> {
2876        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2877            &mut self.event_receiver,
2878            cx
2879        )?) {
2880            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2881            None => std::task::Poll::Ready(None),
2882        }
2883    }
2884}
2885
2886#[derive(Debug)]
2887pub enum AudioCapturerEvent {
2888    OnPacketProduced {
2889        packet: StreamPacket,
2890    },
2891    OnEndOfStream {},
2892    #[non_exhaustive]
2893    _UnknownEvent {
2894        /// Ordinal of the event that was sent.
2895        ordinal: u64,
2896    },
2897}
2898
2899impl AudioCapturerEvent {
2900    #[allow(irrefutable_let_patterns)]
2901    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2902        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2903            Some((packet))
2904        } else {
2905            None
2906        }
2907    }
2908    #[allow(irrefutable_let_patterns)]
2909    pub fn into_on_end_of_stream(self) -> Option<()> {
2910        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2911    }
2912
2913    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2914    fn decode(
2915        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2916    ) -> Result<AudioCapturerEvent, fidl::Error> {
2917        let (bytes, _handles) = buf.split_mut();
2918        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2919        debug_assert_eq!(tx_header.tx_id, 0);
2920        match tx_header.ordinal {
2921            0x6bbe69746a3c8bd9 => {
2922                let mut out = fidl::new_empty!(
2923                    StreamSourceOnPacketProducedRequest,
2924                    fidl::encoding::DefaultFuchsiaResourceDialect
2925                );
2926                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2927                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2928            }
2929            0x550e69b41d03e2c2 => {
2930                let mut out = fidl::new_empty!(
2931                    fidl::encoding::EmptyPayload,
2932                    fidl::encoding::DefaultFuchsiaResourceDialect
2933                );
2934                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2935                Ok((AudioCapturerEvent::OnEndOfStream {}))
2936            }
2937            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2938                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2939            }
2940            _ => Err(fidl::Error::UnknownOrdinal {
2941                ordinal: tx_header.ordinal,
2942                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2943            }),
2944        }
2945    }
2946}
2947
2948/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2949pub struct AudioCapturerRequestStream {
2950    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2951    is_terminated: bool,
2952}
2953
2954impl std::marker::Unpin for AudioCapturerRequestStream {}
2955
2956impl futures::stream::FusedStream for AudioCapturerRequestStream {
2957    fn is_terminated(&self) -> bool {
2958        self.is_terminated
2959    }
2960}
2961
2962impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2963    type Protocol = AudioCapturerMarker;
2964    type ControlHandle = AudioCapturerControlHandle;
2965
2966    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2967        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2968    }
2969
2970    fn control_handle(&self) -> Self::ControlHandle {
2971        AudioCapturerControlHandle { inner: self.inner.clone() }
2972    }
2973
2974    fn into_inner(
2975        self,
2976    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2977    {
2978        (self.inner, self.is_terminated)
2979    }
2980
2981    fn from_inner(
2982        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2983        is_terminated: bool,
2984    ) -> Self {
2985        Self { inner, is_terminated }
2986    }
2987}
2988
2989impl futures::Stream for AudioCapturerRequestStream {
2990    type Item = Result<AudioCapturerRequest, fidl::Error>;
2991
2992    fn poll_next(
2993        mut self: std::pin::Pin<&mut Self>,
2994        cx: &mut std::task::Context<'_>,
2995    ) -> std::task::Poll<Option<Self::Item>> {
2996        let this = &mut *self;
2997        if this.inner.check_shutdown(cx) {
2998            this.is_terminated = true;
2999            return std::task::Poll::Ready(None);
3000        }
3001        if this.is_terminated {
3002            panic!("polled AudioCapturerRequestStream after completion");
3003        }
3004        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3005            |bytes, handles| {
3006                match this.inner.channel().read_etc(cx, bytes, handles) {
3007                    std::task::Poll::Ready(Ok(())) => {}
3008                    std::task::Poll::Pending => return std::task::Poll::Pending,
3009                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3010                        this.is_terminated = true;
3011                        return std::task::Poll::Ready(None);
3012                    }
3013                    std::task::Poll::Ready(Err(e)) => {
3014                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3015                            e.into(),
3016                        ))));
3017                    }
3018                }
3019
3020                // A message has been received from the channel
3021                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3022
3023                std::task::Poll::Ready(Some(match header.ordinal {
3024                    0x3b3a37fc34fe5b56 => {
3025                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3026                        let mut req = fidl::new_empty!(
3027                            StreamBufferSetAddPayloadBufferRequest,
3028                            fidl::encoding::DefaultFuchsiaResourceDialect
3029                        );
3030                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
3031                        let control_handle =
3032                            AudioCapturerControlHandle { inner: this.inner.clone() };
3033                        Ok(AudioCapturerRequest::AddPayloadBuffer {
3034                            id: req.id,
3035                            payload_buffer: req.payload_buffer,
3036
3037                            control_handle,
3038                        })
3039                    }
3040                    0x5d1e4f74c3658262 => {
3041                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3042                        let mut req = fidl::new_empty!(
3043                            StreamBufferSetRemovePayloadBufferRequest,
3044                            fidl::encoding::DefaultFuchsiaResourceDialect
3045                        );
3046                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
3047                        let control_handle =
3048                            AudioCapturerControlHandle { inner: this.inner.clone() };
3049                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
3050                    }
3051                    0x7a7b57f0f7d9e4bb => {
3052                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3053                        let mut req = fidl::new_empty!(
3054                            StreamSourceReleasePacketRequest,
3055                            fidl::encoding::DefaultFuchsiaResourceDialect
3056                        );
3057                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
3058                        let control_handle =
3059                            AudioCapturerControlHandle { inner: this.inner.clone() };
3060                        Ok(AudioCapturerRequest::ReleasePacket {
3061                            packet: req.packet,
3062
3063                            control_handle,
3064                        })
3065                    }
3066                    0x27afd605e97b09d2 => {
3067                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3068                        let mut req = fidl::new_empty!(
3069                            fidl::encoding::EmptyPayload,
3070                            fidl::encoding::DefaultFuchsiaResourceDialect
3071                        );
3072                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3073                        let control_handle =
3074                            AudioCapturerControlHandle { inner: this.inner.clone() };
3075                        Ok(AudioCapturerRequest::DiscardAllPackets {
3076                            responder: AudioCapturerDiscardAllPacketsResponder {
3077                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3078                                tx_id: header.tx_id,
3079                            },
3080                        })
3081                    }
3082                    0x35f9d721e905b831 => {
3083                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3084                        let mut req = fidl::new_empty!(
3085                            fidl::encoding::EmptyPayload,
3086                            fidl::encoding::DefaultFuchsiaResourceDialect
3087                        );
3088                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3089                        let control_handle =
3090                            AudioCapturerControlHandle { inner: this.inner.clone() };
3091                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
3092                    }
3093                    0x1531ea9ea2c852cd => {
3094                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3095                        let mut req = fidl::new_empty!(
3096                            AudioCapturerSetPcmStreamTypeRequest,
3097                            fidl::encoding::DefaultFuchsiaResourceDialect
3098                        );
3099                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
3100                        let control_handle =
3101                            AudioCapturerControlHandle { inner: this.inner.clone() };
3102                        Ok(AudioCapturerRequest::SetPcmStreamType {
3103                            stream_type: req.stream_type,
3104
3105                            control_handle,
3106                        })
3107                    }
3108                    0x784e25df72cea780 => {
3109                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3110                        let mut req = fidl::new_empty!(
3111                            AudioCapturerCaptureAtRequest,
3112                            fidl::encoding::DefaultFuchsiaResourceDialect
3113                        );
3114                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
3115                        let control_handle =
3116                            AudioCapturerControlHandle { inner: this.inner.clone() };
3117                        Ok(AudioCapturerRequest::CaptureAt {
3118                            payload_buffer_id: req.payload_buffer_id,
3119                            payload_offset: req.payload_offset,
3120                            frames: req.frames,
3121
3122                            responder: AudioCapturerCaptureAtResponder {
3123                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3124                                tx_id: header.tx_id,
3125                            },
3126                        })
3127                    }
3128                    0x7768adbb1ccfd7a6 => {
3129                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3130                        let mut req = fidl::new_empty!(
3131                            AudioCapturerStartAsyncCaptureRequest,
3132                            fidl::encoding::DefaultFuchsiaResourceDialect
3133                        );
3134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
3135                        let control_handle =
3136                            AudioCapturerControlHandle { inner: this.inner.clone() };
3137                        Ok(AudioCapturerRequest::StartAsyncCapture {
3138                            frames_per_packet: req.frames_per_packet,
3139
3140                            control_handle,
3141                        })
3142                    }
3143                    0x5bfc8790a8cef8cb => {
3144                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3145                        let mut req = fidl::new_empty!(
3146                            fidl::encoding::EmptyPayload,
3147                            fidl::encoding::DefaultFuchsiaResourceDialect
3148                        );
3149                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3150                        let control_handle =
3151                            AudioCapturerControlHandle { inner: this.inner.clone() };
3152                        Ok(AudioCapturerRequest::StopAsyncCapture {
3153                            responder: AudioCapturerStopAsyncCaptureResponder {
3154                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3155                                tx_id: header.tx_id,
3156                            },
3157                        })
3158                    }
3159                    0x33223cb2962c95e3 => {
3160                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3161                        let mut req = fidl::new_empty!(
3162                            fidl::encoding::EmptyPayload,
3163                            fidl::encoding::DefaultFuchsiaResourceDialect
3164                        );
3165                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3166                        let control_handle =
3167                            AudioCapturerControlHandle { inner: this.inner.clone() };
3168                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
3169                    }
3170                    0x658a6a17ddb3a8e0 => {
3171                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3172                        let mut req = fidl::new_empty!(
3173                            AudioCapturerBindGainControlRequest,
3174                            fidl::encoding::DefaultFuchsiaResourceDialect
3175                        );
3176                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
3177                        let control_handle =
3178                            AudioCapturerControlHandle { inner: this.inner.clone() };
3179                        Ok(AudioCapturerRequest::BindGainControl {
3180                            gain_control_request: req.gain_control_request,
3181
3182                            control_handle,
3183                        })
3184                    }
3185                    0x50d037aa5a4b4d71 => {
3186                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3187                        let mut req = fidl::new_empty!(
3188                            fidl::encoding::EmptyPayload,
3189                            fidl::encoding::DefaultFuchsiaResourceDialect
3190                        );
3191                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3192                        let control_handle =
3193                            AudioCapturerControlHandle { inner: this.inner.clone() };
3194                        Ok(AudioCapturerRequest::GetReferenceClock {
3195                            responder: AudioCapturerGetReferenceClockResponder {
3196                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3197                                tx_id: header.tx_id,
3198                            },
3199                        })
3200                    }
3201                    0x732b2c496d521bcf => {
3202                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3203                        let mut req = fidl::new_empty!(
3204                            AudioCapturerSetReferenceClockRequest,
3205                            fidl::encoding::DefaultFuchsiaResourceDialect
3206                        );
3207                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
3208                        let control_handle =
3209                            AudioCapturerControlHandle { inner: this.inner.clone() };
3210                        Ok(AudioCapturerRequest::SetReferenceClock {
3211                            reference_clock: req.reference_clock,
3212
3213                            control_handle,
3214                        })
3215                    }
3216                    0x42a16f392bd21b25 => {
3217                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3218                        let mut req = fidl::new_empty!(
3219                            AudioCapturerSetUsageRequest,
3220                            fidl::encoding::DefaultFuchsiaResourceDialect
3221                        );
3222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
3223                        let control_handle =
3224                            AudioCapturerControlHandle { inner: this.inner.clone() };
3225                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
3226                    }
3227                    0x7a73e251b8d2382b => {
3228                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3229                        let mut req = fidl::new_empty!(
3230                            AudioCapturerSetUsage2Request,
3231                            fidl::encoding::DefaultFuchsiaResourceDialect
3232                        );
3233                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
3234                        let control_handle =
3235                            AudioCapturerControlHandle { inner: this.inner.clone() };
3236                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
3237                    }
3238                    0x5dcaaa670b433088 => {
3239                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3240                        let mut req = fidl::new_empty!(
3241                            fidl::encoding::EmptyPayload,
3242                            fidl::encoding::DefaultFuchsiaResourceDialect
3243                        );
3244                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3245                        let control_handle =
3246                            AudioCapturerControlHandle { inner: this.inner.clone() };
3247                        Ok(AudioCapturerRequest::GetStreamType {
3248                            responder: AudioCapturerGetStreamTypeResponder {
3249                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3250                                tx_id: header.tx_id,
3251                            },
3252                        })
3253                    }
3254                    _ if header.tx_id == 0
3255                        && header
3256                            .dynamic_flags()
3257                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3258                    {
3259                        Ok(AudioCapturerRequest::_UnknownMethod {
3260                            ordinal: header.ordinal,
3261                            control_handle: AudioCapturerControlHandle {
3262                                inner: this.inner.clone(),
3263                            },
3264                            method_type: fidl::MethodType::OneWay,
3265                        })
3266                    }
3267                    _ if header
3268                        .dynamic_flags()
3269                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3270                    {
3271                        this.inner.send_framework_err(
3272                            fidl::encoding::FrameworkErr::UnknownMethod,
3273                            header.tx_id,
3274                            header.ordinal,
3275                            header.dynamic_flags(),
3276                            (bytes, handles),
3277                        )?;
3278                        Ok(AudioCapturerRequest::_UnknownMethod {
3279                            ordinal: header.ordinal,
3280                            control_handle: AudioCapturerControlHandle {
3281                                inner: this.inner.clone(),
3282                            },
3283                            method_type: fidl::MethodType::TwoWay,
3284                        })
3285                    }
3286                    _ => Err(fidl::Error::UnknownOrdinal {
3287                        ordinal: header.ordinal,
3288                        protocol_name:
3289                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3290                    }),
3291                }))
3292            },
3293        )
3294    }
3295}
3296
3297/// AudioCapturer
3298///
3299/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3300/// CreateAudioCapturer method, which may be used by clients to capture audio
3301/// from either the current default audio input device, or the current default
3302/// audio output device depending on the flags passed during creation.
3303///
3304/// **Format support**
3305///
3306/// See (Get|Set)StreamType below. By default, the captured stream type will be
3307/// initially determined by the currently configured stream type of the source
3308/// that the AudioCapturer was bound to at creation time. Users may either fetch
3309/// this type using GetStreamType, or they may choose to have the media
3310/// resampled or converted to a type of their choosing by calling SetStreamType.
3311/// Note: the stream type may only be set while the system is not running,
3312/// meaning that there are no pending capture regions (specified using CaptureAt)
3313/// and that the system is not currently running in 'async' capture mode.
3314///
3315/// **Buffers and memory management**
3316///
3317/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3318/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3319/// following requirements related to the management of the payload buffer.
3320///
3321/// + The payload buffer must be supplied before any capture operation may
3322///   start. Any attempt to start capture (via either CaptureAt or
3323///   StartAsyncCapture) before a payload buffer has been established is an
3324///   error.
3325/// + The payload buffer may not be changed while there are any capture
3326///   operations pending.
3327/// + The stream type may not be changed after the payload buffer has been set.
3328/// + The payload buffer must be an integral number of audio frame sizes (in
3329///   bytes)
3330/// + When running in 'async' mode (see below), the payload buffer must be at
3331///   least as large as twice the frames_per_packet size specified during
3332///   StartAsyncCapture.
3333/// + The handle to the payload buffer supplied by the user must be readable,
3334///   writable, mappable and transferable.
3335/// + Users should always treat the payload buffer as read-only.
3336///
3337/// **Synchronous vs. Asynchronous capture mode**
3338///
3339/// The AudioCapturer interface can be used in one of two mutually exclusive
3340/// modes: Synchronous and Asynchronous. A description of each mode and their
3341/// tradeoffs is given below.
3342///
3343/// **Synchronous mode**
3344///
3345/// By default, AudioCapturer instances are running in 'sync' mode. They will
3346/// only capture data when a user supplies at least one region to capture into
3347/// using the CaptureAt method. Regions supplied in this way will be filled in
3348/// the order that they are received and returned to the client as StreamPackets
3349/// via the return value of the CaptureAt method. If an AudioCapturer instance
3350/// has data to capture, but no place to put it (because there are no more
3351/// pending regions to fill), the next payload generated will indicate that their
3352/// has been an overflow by setting the Discontinuity flag on the next produced
3353/// StreamPacket. Synchronous mode may not be used in conjunction with
3354/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3355/// the system still regions supplied by CaptureAt waiting to be filled.
3356///
3357/// If a user has supplied regions to be filled by the AudioCapturer instance in
3358/// the past, but wishes to reclaim those regions, they may do so using the
3359/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3360/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3361/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3362/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3363/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3364/// overwrite any region of the payload buffer after a completed region is
3365/// returned, it may overwrite the unfilled portions of a partially filled
3366/// buffer which has been returned as a result of a DiscardAllPackets operation.
3367///
3368/// **Asynchronous mode**
3369///
3370/// While running in 'async' mode, clients do not need to explicitly supply
3371/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3372/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3373/// callback interface and the number of frames to capture per-callback. Once
3374/// running in async mode, the AudioCapturer instance will identify which
3375/// payload buffer regions to capture into, capture the specified number of
3376/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3377/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3378/// 'sync' mode using the StopAsyncCapture method.
3379///
3380/// It is considered an error to attempt any of the following operations.
3381///
3382/// + To attempt to enter 'async' capture mode when no payload buffer has been
3383///   established.
3384/// + To specify a number of frames to capture per payload which does not permit
3385///   at least two contiguous capture payloads to exist in the established
3386///   shared payload buffer simultaneously.
3387/// + To send a region to capture into using the CaptureAt method while the
3388///   AudioCapturer instance is running in 'async' mode.
3389/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3390///   running in 'async' mode.
3391/// + To attempt to re-start 'async' mode capturing without having first
3392///   stopped.
3393/// + To attempt any operation except for SetGain while in the process of
3394///   stopping.
3395///
3396/// **Synchronizing with a StopAsyncCapture operation**
3397///
3398/// Stopping asynchronous capture mode and returning to synchronous capture mode
3399/// is an operation which takes time. Aside from SetGain, users may not call any
3400/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3401/// (including calling StopAsyncCapture again) until after the stop operation has
3402/// completed. Because of this, it is important for users to be able to
3403/// synchronize with the stop operation. Two mechanisms are provided for doing
3404/// so.
3405///
3406/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3407/// callback has been called, they can be certain that stop operation is complete
3408/// and that the AudioCapturer instance has returned to synchronous operation
3409/// mode.
3410///
3411/// The second way to determine that a stop operation has completed is to use the
3412/// flags on the packets which get delivered via the user-supplied
3413/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3414/// asked to stop, any partially filled packet will be returned to the user, and
3415/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3416/// set on it to indicate that this is the final frame in the sequence. If
3417/// there is no partially filled packet to return, the AudioCapturer will
3418/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3419/// in order to deliver a packet with the end-of-stream flag set on it. Once
3420/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3421/// has finished the stop operation and returned to synchronous operating mode.
3422///
3423/// **Timing and Overflows**
3424///
3425/// All media packets produced by an AudioCapturer instance will have their PTS
3426/// field filled out with the capture time of the audio expressed as a timestamp
3427/// given by the reference clock timeline. Note: this timestamp is actually a
3428/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3429/// PTS) and is meant to represent the underlying system's best estimate of the
3430/// capture time of the first frame of audio, including all outboard and hardware
3431/// introduced buffering delay. As a result, all timestamps produced by an
3432/// AudioCapturer should be expected to be in the past relative to 'now' on the
3433/// stream's reference clock timeline.
3434///
3435/// The one exception to the "everything has an explicit timestamp" rule is when
3436/// discarding submitted regions while operating in synchronous mode. Discarded
3437/// packets have no data in them, but FIDL demands that all pending
3438/// method-return-value callbacks be executed. Because of this, the regions will
3439/// be returned to the user, but their timestamps will be set to
3440/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3441/// partially filled payload will have a valid timestamp, but a payload size
3442/// smaller than originally requested. The final discarded payload (if there
3443/// were any to discard) will be followed by an OnEndOfStream event.
3444///
3445/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3446/// the first frame of audio contained in the second packet was captured exactly
3447/// one nominal frame time after the final frame of audio in the first packet.
3448/// If this relationship does not hold, the second StreamPacket will have the
3449/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3450///
3451/// Even though explicit timestamps are provided on every StreamPacket produced,
3452/// users who have very precise timing requirements are encouraged to always
3453/// reason about time by counting frames delivered since the last discontinuity,
3454/// rather than simply using the raw capture timestamps. This is because the
3455/// explicit timestamps written on continuous packets may have a small amount of
3456/// rounding error based on whether or not the units of the capture timeline
3457/// reference clock are divisible by the chosen audio frame rate.
3458///
3459/// Users should always expect the first StreamPacket produced by an
3460/// AudioCapturer to have the discontinuous flag set on it (as there is no
3461/// previous packet to be continuous with). Similarly, the first StreamPacket
3462/// after a DiscardAllPackets or a Stop/Start cycle will always be
3463/// discontinuous. After that, there are only two reasons that a StreamPacket
3464/// will ever be discontinuous:
3465///
3466/// 1. The user is operating in synchronous mode and does not supply regions to
3467///    be filled quickly enough. If the next continuous frame of data has not
3468///    been captured by the time it needs to be purged from the source buffers,
3469///    an overflow has occurred and the AudioCapturer will flag the next captured
3470///    region as discontinuous.
3471/// 2. The user is operating in asynchronous mode and some internal error
3472///    prevents the AudioCapturer instance from capturing the next frame of audio
3473///    in a continuous fashion. This might be high system load or a hardware
3474///    error, but in general it is something which should never normally happen.
3475///    In practice, however, if it does, the next produced packet will be flagged
3476///    as being discontinuous.
3477///
3478/// **Synchronous vs. Asynchronous Trade-offs**
3479///
3480/// The choice of operating in synchronous vs. asynchronous mode is up to the
3481/// user, and depending on the user's requirements, there are some advantages and
3482/// disadvantages to each choice.
3483///
3484/// Synchronous mode requires only a single Zircon channel under the hood and can
3485/// achieve some small savings because of this. In addition, the user has
3486/// complete control over the buffer management. Users specify exactly where
3487/// audio will be captured to and in what order. Because of this, if users do
3488/// not need to always be capturing, it is simple to stop and restart the capture
3489/// later (just by ceasing to supply packets, then resuming later on). Payloads
3490/// do not need to be uniform in size either, clients may specify payloads of
3491/// whatever granularity is appropriate.
3492///
3493/// The primary downside of operating in synchronous mode is that two messages
3494/// will need to be sent for every packet to be captured. One to inform the
3495/// AudioCapturer of the instance to capture into, and one to inform the user
3496/// that the packet has been captured. This may end up increasing overhead and
3497/// potentially complicating client designs.
3498///
3499/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3500/// however, when operating in 'async' mode, AudioCapturer instances have no way
3501/// of knowing if a user is processing the StreamPackets being sent in a timely
3502/// fashion, and no way of automatically detecting an overflow condition. Users
3503/// of 'async' mode should be careful to use a buffer large enough to ensure that
3504/// they will be able to process their data before an AudioCapturer will be
3505/// forced to overwrite it.
3506#[derive(Debug)]
3507pub enum AudioCapturerRequest {
3508    /// Adds a payload buffer to the current buffer set associated with the
3509    /// connection. A `StreamPacket` struct reference a payload buffer in the
3510    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3511    ///
3512    /// A buffer with ID `id` must not be in the current set when this method is
3513    /// invoked, otherwise the service will close the connection.
3514    AddPayloadBuffer {
3515        id: u32,
3516        payload_buffer: fidl::Vmo,
3517        control_handle: AudioCapturerControlHandle,
3518    },
3519    /// Removes a payload buffer from the current buffer set associated with the
3520    /// connection.
3521    ///
3522    /// A buffer with ID `id` must exist in the current set when this method is
3523    /// invoked, otherwise the service will will close the connection.
3524    RemovePayloadBuffer {
3525        id: u32,
3526        control_handle: AudioCapturerControlHandle,
3527    },
3528    /// Releases payload memory associated with a packet previously delivered
3529    /// via `OnPacketProduced`.
3530    ReleasePacket {
3531        packet: StreamPacket,
3532        control_handle: AudioCapturerControlHandle,
3533    },
3534    DiscardAllPackets {
3535        responder: AudioCapturerDiscardAllPacketsResponder,
3536    },
3537    DiscardAllPacketsNoReply {
3538        control_handle: AudioCapturerControlHandle,
3539    },
3540    /// Sets the stream type of the stream to be delivered. Causes the source
3541    /// material to be reformatted/resampled if needed in order to produce the
3542    /// requested stream type. Must be called before the payload buffer is
3543    /// established.
3544    SetPcmStreamType {
3545        stream_type: AudioStreamType,
3546        control_handle: AudioCapturerControlHandle,
3547    },
3548    /// Explicitly specifies a region of the shared payload buffer for the audio
3549    /// input to capture into.
3550    CaptureAt {
3551        payload_buffer_id: u32,
3552        payload_offset: u32,
3553        frames: u32,
3554        responder: AudioCapturerCaptureAtResponder,
3555    },
3556    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3557    /// packets of exactly 'frames_per_packet' number of frames each. The
3558    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3559    /// of produced packets.
3560    StartAsyncCapture {
3561        frames_per_packet: u32,
3562        control_handle: AudioCapturerControlHandle,
3563    },
3564    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3565    /// that may be used by the client if explicit synchronization is needed.
3566    StopAsyncCapture {
3567        responder: AudioCapturerStopAsyncCaptureResponder,
3568    },
3569    StopAsyncCaptureNoReply {
3570        control_handle: AudioCapturerControlHandle,
3571    },
3572    /// Binds to the gain control for this AudioCapturer.
3573    BindGainControl {
3574        gain_control_request:
3575            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3576        control_handle: AudioCapturerControlHandle,
3577    },
3578    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3579    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3580    GetReferenceClock {
3581        responder: AudioCapturerGetReferenceClockResponder,
3582    },
3583    /// Sets the reference clock that controls this capturer's playback rate. If the input
3584    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3585    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3586    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3587    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3588    ///
3589    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3590    /// added. It also cannot be called a second time (even before capture).
3591    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3592    /// diverge at some later time, they should create a clone of the monotonic clock, set
3593    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3594    SetReferenceClock {
3595        reference_clock: Option<fidl::Clock>,
3596        control_handle: AudioCapturerControlHandle,
3597    },
3598    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3599    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3600    SetUsage {
3601        usage: AudioCaptureUsage,
3602        control_handle: AudioCapturerControlHandle,
3603    },
3604    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3605    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3606    SetUsage2 {
3607        usage: AudioCaptureUsage2,
3608        control_handle: AudioCapturerControlHandle,
3609    },
3610    /// Gets the currently configured stream type. Note: for an AudioCapturer
3611    /// which was just created and has not yet had its stream type explicitly
3612    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3613    /// was created -- of the source (input or looped-back output) to which the
3614    /// AudioCapturer is bound. Even if this matches the client's desired format,
3615    /// `SetPcmStreamType` must still be called.
3616    GetStreamType {
3617        responder: AudioCapturerGetStreamTypeResponder,
3618    },
3619    /// An interaction was received which does not match any known method.
3620    #[non_exhaustive]
3621    _UnknownMethod {
3622        /// Ordinal of the method that was called.
3623        ordinal: u64,
3624        control_handle: AudioCapturerControlHandle,
3625        method_type: fidl::MethodType,
3626    },
3627}
3628
3629impl AudioCapturerRequest {
3630    #[allow(irrefutable_let_patterns)]
3631    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3632        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3633        {
3634            Some((id, payload_buffer, control_handle))
3635        } else {
3636            None
3637        }
3638    }
3639
3640    #[allow(irrefutable_let_patterns)]
3641    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3642        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3643            Some((id, control_handle))
3644        } else {
3645            None
3646        }
3647    }
3648
3649    #[allow(irrefutable_let_patterns)]
3650    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3651        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3652            Some((packet, control_handle))
3653        } else {
3654            None
3655        }
3656    }
3657
3658    #[allow(irrefutable_let_patterns)]
3659    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3660        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3661            Some((responder))
3662        } else {
3663            None
3664        }
3665    }
3666
3667    #[allow(irrefutable_let_patterns)]
3668    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3669        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3670            Some((control_handle))
3671        } else {
3672            None
3673        }
3674    }
3675
3676    #[allow(irrefutable_let_patterns)]
3677    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3678        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3679            Some((stream_type, control_handle))
3680        } else {
3681            None
3682        }
3683    }
3684
3685    #[allow(irrefutable_let_patterns)]
3686    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3687        if let AudioCapturerRequest::CaptureAt {
3688            payload_buffer_id,
3689            payload_offset,
3690            frames,
3691            responder,
3692        } = self
3693        {
3694            Some((payload_buffer_id, payload_offset, frames, responder))
3695        } else {
3696            None
3697        }
3698    }
3699
3700    #[allow(irrefutable_let_patterns)]
3701    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3702        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3703        {
3704            Some((frames_per_packet, control_handle))
3705        } else {
3706            None
3707        }
3708    }
3709
3710    #[allow(irrefutable_let_patterns)]
3711    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3712        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3713            Some((responder))
3714        } else {
3715            None
3716        }
3717    }
3718
3719    #[allow(irrefutable_let_patterns)]
3720    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3721        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3722            Some((control_handle))
3723        } else {
3724            None
3725        }
3726    }
3727
3728    #[allow(irrefutable_let_patterns)]
3729    pub fn into_bind_gain_control(
3730        self,
3731    ) -> Option<(
3732        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3733        AudioCapturerControlHandle,
3734    )> {
3735        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3736        {
3737            Some((gain_control_request, control_handle))
3738        } else {
3739            None
3740        }
3741    }
3742
3743    #[allow(irrefutable_let_patterns)]
3744    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3745        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3746            Some((responder))
3747        } else {
3748            None
3749        }
3750    }
3751
3752    #[allow(irrefutable_let_patterns)]
3753    pub fn into_set_reference_clock(
3754        self,
3755    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3756        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3757            Some((reference_clock, control_handle))
3758        } else {
3759            None
3760        }
3761    }
3762
3763    #[allow(irrefutable_let_patterns)]
3764    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3765        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3766            Some((usage, control_handle))
3767        } else {
3768            None
3769        }
3770    }
3771
3772    #[allow(irrefutable_let_patterns)]
3773    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3774        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3775            Some((usage, control_handle))
3776        } else {
3777            None
3778        }
3779    }
3780
3781    #[allow(irrefutable_let_patterns)]
3782    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3783        if let AudioCapturerRequest::GetStreamType { responder } = self {
3784            Some((responder))
3785        } else {
3786            None
3787        }
3788    }
3789
3790    /// Name of the method defined in FIDL
3791    pub fn method_name(&self) -> &'static str {
3792        match *self {
3793            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3794            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3795            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3796            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3797            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3798            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3799            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3800            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3801            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3802            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3803            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3804            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3805            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3806            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3807            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3808            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3809            AudioCapturerRequest::_UnknownMethod {
3810                method_type: fidl::MethodType::OneWay, ..
3811            } => "unknown one-way method",
3812            AudioCapturerRequest::_UnknownMethod {
3813                method_type: fidl::MethodType::TwoWay, ..
3814            } => "unknown two-way method",
3815        }
3816    }
3817}
3818
3819#[derive(Debug, Clone)]
3820pub struct AudioCapturerControlHandle {
3821    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3822}
3823
3824impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3825    fn shutdown(&self) {
3826        self.inner.shutdown()
3827    }
3828
3829    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3830        self.inner.shutdown_with_epitaph(status)
3831    }
3832
3833    fn is_closed(&self) -> bool {
3834        self.inner.channel().is_closed()
3835    }
3836    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3837        self.inner.channel().on_closed()
3838    }
3839
3840    #[cfg(target_os = "fuchsia")]
3841    fn signal_peer(
3842        &self,
3843        clear_mask: zx::Signals,
3844        set_mask: zx::Signals,
3845    ) -> Result<(), zx_status::Status> {
3846        use fidl::Peered;
3847        self.inner.channel().signal_peer(clear_mask, set_mask)
3848    }
3849}
3850
3851impl AudioCapturerControlHandle {
3852    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3853        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3854            (packet,),
3855            0,
3856            0x6bbe69746a3c8bd9,
3857            fidl::encoding::DynamicFlags::empty(),
3858        )
3859    }
3860
3861    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3862        self.inner.send::<fidl::encoding::EmptyPayload>(
3863            (),
3864            0,
3865            0x550e69b41d03e2c2,
3866            fidl::encoding::DynamicFlags::empty(),
3867        )
3868    }
3869}
3870
3871#[must_use = "FIDL methods require a response to be sent"]
3872#[derive(Debug)]
3873pub struct AudioCapturerDiscardAllPacketsResponder {
3874    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3875    tx_id: u32,
3876}
3877
3878/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3879/// if the responder is dropped without sending a response, so that the client
3880/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3881impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3882    fn drop(&mut self) {
3883        self.control_handle.shutdown();
3884        // Safety: drops once, never accessed again
3885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3886    }
3887}
3888
3889impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3890    type ControlHandle = AudioCapturerControlHandle;
3891
3892    fn control_handle(&self) -> &AudioCapturerControlHandle {
3893        &self.control_handle
3894    }
3895
3896    fn drop_without_shutdown(mut self) {
3897        // Safety: drops once, never accessed again due to mem::forget
3898        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3899        // Prevent Drop from running (which would shut down the channel)
3900        std::mem::forget(self);
3901    }
3902}
3903
3904impl AudioCapturerDiscardAllPacketsResponder {
3905    /// Sends a response to the FIDL transaction.
3906    ///
3907    /// Sets the channel to shutdown if an error occurs.
3908    pub fn send(self) -> Result<(), fidl::Error> {
3909        let _result = self.send_raw();
3910        if _result.is_err() {
3911            self.control_handle.shutdown();
3912        }
3913        self.drop_without_shutdown();
3914        _result
3915    }
3916
3917    /// Similar to "send" but does not shutdown the channel if an error occurs.
3918    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3919        let _result = self.send_raw();
3920        self.drop_without_shutdown();
3921        _result
3922    }
3923
3924    fn send_raw(&self) -> Result<(), fidl::Error> {
3925        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3926            (),
3927            self.tx_id,
3928            0x27afd605e97b09d2,
3929            fidl::encoding::DynamicFlags::empty(),
3930        )
3931    }
3932}
3933
3934#[must_use = "FIDL methods require a response to be sent"]
3935#[derive(Debug)]
3936pub struct AudioCapturerCaptureAtResponder {
3937    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3938    tx_id: u32,
3939}
3940
3941/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3942/// if the responder is dropped without sending a response, so that the client
3943/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3944impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3945    fn drop(&mut self) {
3946        self.control_handle.shutdown();
3947        // Safety: drops once, never accessed again
3948        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3949    }
3950}
3951
3952impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3953    type ControlHandle = AudioCapturerControlHandle;
3954
3955    fn control_handle(&self) -> &AudioCapturerControlHandle {
3956        &self.control_handle
3957    }
3958
3959    fn drop_without_shutdown(mut self) {
3960        // Safety: drops once, never accessed again due to mem::forget
3961        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3962        // Prevent Drop from running (which would shut down the channel)
3963        std::mem::forget(self);
3964    }
3965}
3966
3967impl AudioCapturerCaptureAtResponder {
3968    /// Sends a response to the FIDL transaction.
3969    ///
3970    /// Sets the channel to shutdown if an error occurs.
3971    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3972        let _result = self.send_raw(captured_packet);
3973        if _result.is_err() {
3974            self.control_handle.shutdown();
3975        }
3976        self.drop_without_shutdown();
3977        _result
3978    }
3979
3980    /// Similar to "send" but does not shutdown the channel if an error occurs.
3981    pub fn send_no_shutdown_on_err(
3982        self,
3983        mut captured_packet: &StreamPacket,
3984    ) -> Result<(), fidl::Error> {
3985        let _result = self.send_raw(captured_packet);
3986        self.drop_without_shutdown();
3987        _result
3988    }
3989
3990    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3991        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3992            (captured_packet,),
3993            self.tx_id,
3994            0x784e25df72cea780,
3995            fidl::encoding::DynamicFlags::empty(),
3996        )
3997    }
3998}
3999
4000#[must_use = "FIDL methods require a response to be sent"]
4001#[derive(Debug)]
4002pub struct AudioCapturerStopAsyncCaptureResponder {
4003    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4004    tx_id: u32,
4005}
4006
4007/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4008/// if the responder is dropped without sending a response, so that the client
4009/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4010impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
4011    fn drop(&mut self) {
4012        self.control_handle.shutdown();
4013        // Safety: drops once, never accessed again
4014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4015    }
4016}
4017
4018impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
4019    type ControlHandle = AudioCapturerControlHandle;
4020
4021    fn control_handle(&self) -> &AudioCapturerControlHandle {
4022        &self.control_handle
4023    }
4024
4025    fn drop_without_shutdown(mut self) {
4026        // Safety: drops once, never accessed again due to mem::forget
4027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4028        // Prevent Drop from running (which would shut down the channel)
4029        std::mem::forget(self);
4030    }
4031}
4032
4033impl AudioCapturerStopAsyncCaptureResponder {
4034    /// Sends a response to the FIDL transaction.
4035    ///
4036    /// Sets the channel to shutdown if an error occurs.
4037    pub fn send(self) -> Result<(), fidl::Error> {
4038        let _result = self.send_raw();
4039        if _result.is_err() {
4040            self.control_handle.shutdown();
4041        }
4042        self.drop_without_shutdown();
4043        _result
4044    }
4045
4046    /// Similar to "send" but does not shutdown the channel if an error occurs.
4047    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4048        let _result = self.send_raw();
4049        self.drop_without_shutdown();
4050        _result
4051    }
4052
4053    fn send_raw(&self) -> Result<(), fidl::Error> {
4054        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4055            (),
4056            self.tx_id,
4057            0x5bfc8790a8cef8cb,
4058            fidl::encoding::DynamicFlags::empty(),
4059        )
4060    }
4061}
4062
4063#[must_use = "FIDL methods require a response to be sent"]
4064#[derive(Debug)]
4065pub struct AudioCapturerGetReferenceClockResponder {
4066    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4067    tx_id: u32,
4068}
4069
4070/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4071/// if the responder is dropped without sending a response, so that the client
4072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4073impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
4074    fn drop(&mut self) {
4075        self.control_handle.shutdown();
4076        // Safety: drops once, never accessed again
4077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4078    }
4079}
4080
4081impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
4082    type ControlHandle = AudioCapturerControlHandle;
4083
4084    fn control_handle(&self) -> &AudioCapturerControlHandle {
4085        &self.control_handle
4086    }
4087
4088    fn drop_without_shutdown(mut self) {
4089        // Safety: drops once, never accessed again due to mem::forget
4090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4091        // Prevent Drop from running (which would shut down the channel)
4092        std::mem::forget(self);
4093    }
4094}
4095
4096impl AudioCapturerGetReferenceClockResponder {
4097    /// Sends a response to the FIDL transaction.
4098    ///
4099    /// Sets the channel to shutdown if an error occurs.
4100    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
4101        let _result = self.send_raw(reference_clock);
4102        if _result.is_err() {
4103            self.control_handle.shutdown();
4104        }
4105        self.drop_without_shutdown();
4106        _result
4107    }
4108
4109    /// Similar to "send" but does not shutdown the channel if an error occurs.
4110    pub fn send_no_shutdown_on_err(
4111        self,
4112        mut reference_clock: fidl::Clock,
4113    ) -> Result<(), fidl::Error> {
4114        let _result = self.send_raw(reference_clock);
4115        self.drop_without_shutdown();
4116        _result
4117    }
4118
4119    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
4120        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
4121            (reference_clock,),
4122            self.tx_id,
4123            0x50d037aa5a4b4d71,
4124            fidl::encoding::DynamicFlags::empty(),
4125        )
4126    }
4127}
4128
4129#[must_use = "FIDL methods require a response to be sent"]
4130#[derive(Debug)]
4131pub struct AudioCapturerGetStreamTypeResponder {
4132    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4133    tx_id: u32,
4134}
4135
4136/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4137/// if the responder is dropped without sending a response, so that the client
4138/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4139impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
4140    fn drop(&mut self) {
4141        self.control_handle.shutdown();
4142        // Safety: drops once, never accessed again
4143        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4144    }
4145}
4146
4147impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
4148    type ControlHandle = AudioCapturerControlHandle;
4149
4150    fn control_handle(&self) -> &AudioCapturerControlHandle {
4151        &self.control_handle
4152    }
4153
4154    fn drop_without_shutdown(mut self) {
4155        // Safety: drops once, never accessed again due to mem::forget
4156        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4157        // Prevent Drop from running (which would shut down the channel)
4158        std::mem::forget(self);
4159    }
4160}
4161
4162impl AudioCapturerGetStreamTypeResponder {
4163    /// Sends a response to the FIDL transaction.
4164    ///
4165    /// Sets the channel to shutdown if an error occurs.
4166    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4167        let _result = self.send_raw(stream_type);
4168        if _result.is_err() {
4169            self.control_handle.shutdown();
4170        }
4171        self.drop_without_shutdown();
4172        _result
4173    }
4174
4175    /// Similar to "send" but does not shutdown the channel if an error occurs.
4176    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4177        let _result = self.send_raw(stream_type);
4178        self.drop_without_shutdown();
4179        _result
4180    }
4181
4182    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4183        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
4184            (stream_type,),
4185            self.tx_id,
4186            0x5dcaaa670b433088,
4187            fidl::encoding::DynamicFlags::empty(),
4188        )
4189    }
4190}
4191
4192#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4193pub struct AudioConsumerMarker;
4194
4195impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
4196    type Proxy = AudioConsumerProxy;
4197    type RequestStream = AudioConsumerRequestStream;
4198    #[cfg(target_os = "fuchsia")]
4199    type SynchronousProxy = AudioConsumerSynchronousProxy;
4200
4201    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
4202}
4203
4204pub trait AudioConsumerProxyInterface: Send + Sync {
4205    fn r#create_stream_sink(
4206        &self,
4207        buffers: Vec<fidl::Vmo>,
4208        stream_type: &AudioStreamType,
4209        compression: Option<&Compression>,
4210        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4211    ) -> Result<(), fidl::Error>;
4212    fn r#start(
4213        &self,
4214        flags: AudioConsumerStartFlags,
4215        reference_time: i64,
4216        media_time: i64,
4217    ) -> Result<(), fidl::Error>;
4218    fn r#stop(&self) -> Result<(), fidl::Error>;
4219    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
4220    fn r#bind_volume_control(
4221        &self,
4222        volume_control_request: fidl::endpoints::ServerEnd<
4223            fidl_fuchsia_media_audio::VolumeControlMarker,
4224        >,
4225    ) -> Result<(), fidl::Error>;
4226    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
4227        + Send;
4228    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
4229}
4230#[derive(Debug)]
4231#[cfg(target_os = "fuchsia")]
4232pub struct AudioConsumerSynchronousProxy {
4233    client: fidl::client::sync::Client,
4234}
4235
4236#[cfg(target_os = "fuchsia")]
4237impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
4238    type Proxy = AudioConsumerProxy;
4239    type Protocol = AudioConsumerMarker;
4240
4241    fn from_channel(inner: fidl::Channel) -> Self {
4242        Self::new(inner)
4243    }
4244
4245    fn into_channel(self) -> fidl::Channel {
4246        self.client.into_channel()
4247    }
4248
4249    fn as_channel(&self) -> &fidl::Channel {
4250        self.client.as_channel()
4251    }
4252}
4253
4254#[cfg(target_os = "fuchsia")]
4255impl AudioConsumerSynchronousProxy {
4256    pub fn new(channel: fidl::Channel) -> Self {
4257        Self { client: fidl::client::sync::Client::new(channel) }
4258    }
4259
4260    pub fn into_channel(self) -> fidl::Channel {
4261        self.client.into_channel()
4262    }
4263
4264    /// Waits until an event arrives and returns it. It is safe for other
4265    /// threads to make concurrent requests while waiting for an event.
4266    pub fn wait_for_event(
4267        &self,
4268        deadline: zx::MonotonicInstant,
4269    ) -> Result<AudioConsumerEvent, fidl::Error> {
4270        AudioConsumerEvent::decode(self.client.wait_for_event::<AudioConsumerMarker>(deadline)?)
4271    }
4272
4273    /// Creates a `StreamSink` for the consumer with the indicated properties.
4274    ///
4275    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4276    /// sequentially rather than concurrently. The first stream sink that's created using this
4277    /// method is used as the sole source of packets incoming to the logical consumer until that
4278    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4279    /// the second stream sink is used, and so on.
4280    ///
4281    /// If an unsupported compression type is supplied, the
4282    /// `stream_sink_request` request will be closed with an epitaph value of
4283    /// `ZX_ERR_INVALID_ARGS`.
4284    pub fn r#create_stream_sink(
4285        &self,
4286        mut buffers: Vec<fidl::Vmo>,
4287        mut stream_type: &AudioStreamType,
4288        mut compression: Option<&Compression>,
4289        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4290    ) -> Result<(), fidl::Error> {
4291        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4292            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4293            0x525b3b97fdf7d884,
4294            fidl::encoding::DynamicFlags::empty(),
4295        )
4296    }
4297
4298    /// Starts rendering as indicated by `flags`.
4299    ///
4300    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4301    /// Typically, this is the timestamp of the first packet that will be
4302    /// rendered. If packets will be supplied with no timestamps, this value
4303    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4304    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4305    ///     1. When starting for the first time, the default media time is the
4306    ///        timestamp on the first packet sent to the stream sink.
4307    ///     2. When resuming after stop, the default media time is the media
4308    ///        time at which the stream stopped.
4309    ///
4310    /// `reference_time` is the monotonic system time at which rendering should
4311    /// be started. For supply-driven sources, this must be the time at which
4312    /// the first packet was (or will be) sent plus a lead time, which must be
4313    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4314    /// sources, the client must ensure that the lead time requirement is met at
4315    /// the start time.  Passing the default value of 0 for `reference_time`
4316    /// causes the consumer to choose a start time based on the availability of
4317    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4318    /// specified.
4319    ///
4320    /// The actual start time will be reflected in the updated status.
4321    pub fn r#start(
4322        &self,
4323        mut flags: AudioConsumerStartFlags,
4324        mut reference_time: i64,
4325        mut media_time: i64,
4326    ) -> Result<(), fidl::Error> {
4327        self.client.send::<AudioConsumerStartRequest>(
4328            (flags, reference_time, media_time),
4329            0x4fdbd44b3f2a3a3c,
4330            fidl::encoding::DynamicFlags::empty(),
4331        )
4332    }
4333
4334    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4335    /// be reflected in the updated status.
4336    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4337        self.client.send::<fidl::encoding::EmptyPayload>(
4338            (),
4339            0x3d46c3741686c40d,
4340            fidl::encoding::DynamicFlags::empty(),
4341        )
4342    }
4343
4344    /// Requests to change the playback rate of the renderer. 1.0 means normal
4345    /// playback. Negative rates are not supported. The new rate will be
4346    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4347    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4348        self.client.send::<AudioConsumerSetRateRequest>(
4349            (rate,),
4350            0x45342b73968bfafe,
4351            fidl::encoding::DynamicFlags::empty(),
4352        )
4353    }
4354
4355    /// Binds to this `AudioConsumer` volume control for control and notifications.
4356    pub fn r#bind_volume_control(
4357        &self,
4358        mut volume_control_request: fidl::endpoints::ServerEnd<
4359            fidl_fuchsia_media_audio::VolumeControlMarker,
4360        >,
4361    ) -> Result<(), fidl::Error> {
4362        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4363            (volume_control_request,),
4364            0x6f1b01fd887f5748,
4365            fidl::encoding::DynamicFlags::empty(),
4366        )
4367    }
4368
4369    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4370    /// to this method when the status changes - initially with respect to the initial status value
4371    /// and thereafter with respect to the previously-reported status value.
4372    pub fn r#watch_status(
4373        &self,
4374        ___deadline: zx::MonotonicInstant,
4375    ) -> Result<AudioConsumerStatus, fidl::Error> {
4376        let _response = self.client.send_query::<
4377            fidl::encoding::EmptyPayload,
4378            AudioConsumerWatchStatusResponse,
4379            AudioConsumerMarker,
4380        >(
4381            (),
4382            0x35cf702c721e2cc6,
4383            fidl::encoding::DynamicFlags::empty(),
4384            ___deadline,
4385        )?;
4386        Ok(_response.status)
4387    }
4388}
4389
4390#[cfg(target_os = "fuchsia")]
4391impl From<AudioConsumerSynchronousProxy> for zx::NullableHandle {
4392    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4393        value.into_channel().into()
4394    }
4395}
4396
4397#[cfg(target_os = "fuchsia")]
4398impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4399    fn from(value: fidl::Channel) -> Self {
4400        Self::new(value)
4401    }
4402}
4403
4404#[cfg(target_os = "fuchsia")]
4405impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4406    type Protocol = AudioConsumerMarker;
4407
4408    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4409        Self::new(value.into_channel())
4410    }
4411}
4412
4413#[derive(Debug, Clone)]
4414pub struct AudioConsumerProxy {
4415    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4416}
4417
4418impl fidl::endpoints::Proxy for AudioConsumerProxy {
4419    type Protocol = AudioConsumerMarker;
4420
4421    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4422        Self::new(inner)
4423    }
4424
4425    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4426        self.client.into_channel().map_err(|client| Self { client })
4427    }
4428
4429    fn as_channel(&self) -> &::fidl::AsyncChannel {
4430        self.client.as_channel()
4431    }
4432}
4433
4434impl AudioConsumerProxy {
4435    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4436    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4437        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4438        Self { client: fidl::client::Client::new(channel, protocol_name) }
4439    }
4440
4441    /// Get a Stream of events from the remote end of the protocol.
4442    ///
4443    /// # Panics
4444    ///
4445    /// Panics if the event stream was already taken.
4446    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
4447        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4448    }
4449
4450    /// Creates a `StreamSink` for the consumer with the indicated properties.
4451    ///
4452    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4453    /// sequentially rather than concurrently. The first stream sink that's created using this
4454    /// method is used as the sole source of packets incoming to the logical consumer until that
4455    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4456    /// the second stream sink is used, and so on.
4457    ///
4458    /// If an unsupported compression type is supplied, the
4459    /// `stream_sink_request` request will be closed with an epitaph value of
4460    /// `ZX_ERR_INVALID_ARGS`.
4461    pub fn r#create_stream_sink(
4462        &self,
4463        mut buffers: Vec<fidl::Vmo>,
4464        mut stream_type: &AudioStreamType,
4465        mut compression: Option<&Compression>,
4466        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4467    ) -> Result<(), fidl::Error> {
4468        AudioConsumerProxyInterface::r#create_stream_sink(
4469            self,
4470            buffers,
4471            stream_type,
4472            compression,
4473            stream_sink_request,
4474        )
4475    }
4476
4477    /// Starts rendering as indicated by `flags`.
4478    ///
4479    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4480    /// Typically, this is the timestamp of the first packet that will be
4481    /// rendered. If packets will be supplied with no timestamps, this value
4482    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4483    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4484    ///     1. When starting for the first time, the default media time is the
4485    ///        timestamp on the first packet sent to the stream sink.
4486    ///     2. When resuming after stop, the default media time is the media
4487    ///        time at which the stream stopped.
4488    ///
4489    /// `reference_time` is the monotonic system time at which rendering should
4490    /// be started. For supply-driven sources, this must be the time at which
4491    /// the first packet was (or will be) sent plus a lead time, which must be
4492    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4493    /// sources, the client must ensure that the lead time requirement is met at
4494    /// the start time.  Passing the default value of 0 for `reference_time`
4495    /// causes the consumer to choose a start time based on the availability of
4496    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4497    /// specified.
4498    ///
4499    /// The actual start time will be reflected in the updated status.
4500    pub fn r#start(
4501        &self,
4502        mut flags: AudioConsumerStartFlags,
4503        mut reference_time: i64,
4504        mut media_time: i64,
4505    ) -> Result<(), fidl::Error> {
4506        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4507    }
4508
4509    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4510    /// be reflected in the updated status.
4511    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4512        AudioConsumerProxyInterface::r#stop(self)
4513    }
4514
4515    /// Requests to change the playback rate of the renderer. 1.0 means normal
4516    /// playback. Negative rates are not supported. The new rate will be
4517    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4518    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4519        AudioConsumerProxyInterface::r#set_rate(self, rate)
4520    }
4521
4522    /// Binds to this `AudioConsumer` volume control for control and notifications.
4523    pub fn r#bind_volume_control(
4524        &self,
4525        mut volume_control_request: fidl::endpoints::ServerEnd<
4526            fidl_fuchsia_media_audio::VolumeControlMarker,
4527        >,
4528    ) -> Result<(), fidl::Error> {
4529        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4530    }
4531
4532    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4533    /// to this method when the status changes - initially with respect to the initial status value
4534    /// and thereafter with respect to the previously-reported status value.
4535    pub fn r#watch_status(
4536        &self,
4537    ) -> fidl::client::QueryResponseFut<
4538        AudioConsumerStatus,
4539        fidl::encoding::DefaultFuchsiaResourceDialect,
4540    > {
4541        AudioConsumerProxyInterface::r#watch_status(self)
4542    }
4543}
4544
4545impl AudioConsumerProxyInterface for AudioConsumerProxy {
4546    fn r#create_stream_sink(
4547        &self,
4548        mut buffers: Vec<fidl::Vmo>,
4549        mut stream_type: &AudioStreamType,
4550        mut compression: Option<&Compression>,
4551        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4552    ) -> Result<(), fidl::Error> {
4553        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4554            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4555            0x525b3b97fdf7d884,
4556            fidl::encoding::DynamicFlags::empty(),
4557        )
4558    }
4559
4560    fn r#start(
4561        &self,
4562        mut flags: AudioConsumerStartFlags,
4563        mut reference_time: i64,
4564        mut media_time: i64,
4565    ) -> Result<(), fidl::Error> {
4566        self.client.send::<AudioConsumerStartRequest>(
4567            (flags, reference_time, media_time),
4568            0x4fdbd44b3f2a3a3c,
4569            fidl::encoding::DynamicFlags::empty(),
4570        )
4571    }
4572
4573    fn r#stop(&self) -> Result<(), fidl::Error> {
4574        self.client.send::<fidl::encoding::EmptyPayload>(
4575            (),
4576            0x3d46c3741686c40d,
4577            fidl::encoding::DynamicFlags::empty(),
4578        )
4579    }
4580
4581    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4582        self.client.send::<AudioConsumerSetRateRequest>(
4583            (rate,),
4584            0x45342b73968bfafe,
4585            fidl::encoding::DynamicFlags::empty(),
4586        )
4587    }
4588
4589    fn r#bind_volume_control(
4590        &self,
4591        mut volume_control_request: fidl::endpoints::ServerEnd<
4592            fidl_fuchsia_media_audio::VolumeControlMarker,
4593        >,
4594    ) -> Result<(), fidl::Error> {
4595        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4596            (volume_control_request,),
4597            0x6f1b01fd887f5748,
4598            fidl::encoding::DynamicFlags::empty(),
4599        )
4600    }
4601
4602    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4603        AudioConsumerStatus,
4604        fidl::encoding::DefaultFuchsiaResourceDialect,
4605    >;
4606    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4607        fn _decode(
4608            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4609        ) -> Result<AudioConsumerStatus, fidl::Error> {
4610            let _response = fidl::client::decode_transaction_body::<
4611                AudioConsumerWatchStatusResponse,
4612                fidl::encoding::DefaultFuchsiaResourceDialect,
4613                0x35cf702c721e2cc6,
4614            >(_buf?)?;
4615            Ok(_response.status)
4616        }
4617        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4618            (),
4619            0x35cf702c721e2cc6,
4620            fidl::encoding::DynamicFlags::empty(),
4621            _decode,
4622        )
4623    }
4624}
4625
4626pub struct AudioConsumerEventStream {
4627    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4628}
4629
4630impl std::marker::Unpin for AudioConsumerEventStream {}
4631
4632impl futures::stream::FusedStream for AudioConsumerEventStream {
4633    fn is_terminated(&self) -> bool {
4634        self.event_receiver.is_terminated()
4635    }
4636}
4637
4638impl futures::Stream for AudioConsumerEventStream {
4639    type Item = Result<AudioConsumerEvent, fidl::Error>;
4640
4641    fn poll_next(
4642        mut self: std::pin::Pin<&mut Self>,
4643        cx: &mut std::task::Context<'_>,
4644    ) -> std::task::Poll<Option<Self::Item>> {
4645        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4646            &mut self.event_receiver,
4647            cx
4648        )?) {
4649            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4650            None => std::task::Poll::Ready(None),
4651        }
4652    }
4653}
4654
4655#[derive(Debug)]
4656pub enum AudioConsumerEvent {
4657    OnEndOfStream {},
4658}
4659
4660impl AudioConsumerEvent {
4661    #[allow(irrefutable_let_patterns)]
4662    pub fn into_on_end_of_stream(self) -> Option<()> {
4663        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
4664    }
4665
4666    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4667    fn decode(
4668        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4669    ) -> Result<AudioConsumerEvent, fidl::Error> {
4670        let (bytes, _handles) = buf.split_mut();
4671        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4672        debug_assert_eq!(tx_header.tx_id, 0);
4673        match tx_header.ordinal {
4674            0x53a64e6d0e8f8a20 => {
4675                let mut out = fidl::new_empty!(
4676                    fidl::encoding::EmptyPayload,
4677                    fidl::encoding::DefaultFuchsiaResourceDialect
4678                );
4679                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4680                Ok((AudioConsumerEvent::OnEndOfStream {}))
4681            }
4682            _ => Err(fidl::Error::UnknownOrdinal {
4683                ordinal: tx_header.ordinal,
4684                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4685            }),
4686        }
4687    }
4688}
4689
4690/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4691pub struct AudioConsumerRequestStream {
4692    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4693    is_terminated: bool,
4694}
4695
4696impl std::marker::Unpin for AudioConsumerRequestStream {}
4697
4698impl futures::stream::FusedStream for AudioConsumerRequestStream {
4699    fn is_terminated(&self) -> bool {
4700        self.is_terminated
4701    }
4702}
4703
4704impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4705    type Protocol = AudioConsumerMarker;
4706    type ControlHandle = AudioConsumerControlHandle;
4707
4708    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4709        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4710    }
4711
4712    fn control_handle(&self) -> Self::ControlHandle {
4713        AudioConsumerControlHandle { inner: self.inner.clone() }
4714    }
4715
4716    fn into_inner(
4717        self,
4718    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4719    {
4720        (self.inner, self.is_terminated)
4721    }
4722
4723    fn from_inner(
4724        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4725        is_terminated: bool,
4726    ) -> Self {
4727        Self { inner, is_terminated }
4728    }
4729}
4730
4731impl futures::Stream for AudioConsumerRequestStream {
4732    type Item = Result<AudioConsumerRequest, fidl::Error>;
4733
4734    fn poll_next(
4735        mut self: std::pin::Pin<&mut Self>,
4736        cx: &mut std::task::Context<'_>,
4737    ) -> std::task::Poll<Option<Self::Item>> {
4738        let this = &mut *self;
4739        if this.inner.check_shutdown(cx) {
4740            this.is_terminated = true;
4741            return std::task::Poll::Ready(None);
4742        }
4743        if this.is_terminated {
4744            panic!("polled AudioConsumerRequestStream after completion");
4745        }
4746        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4747            |bytes, handles| {
4748                match this.inner.channel().read_etc(cx, bytes, handles) {
4749                    std::task::Poll::Ready(Ok(())) => {}
4750                    std::task::Poll::Pending => return std::task::Poll::Pending,
4751                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4752                        this.is_terminated = true;
4753                        return std::task::Poll::Ready(None);
4754                    }
4755                    std::task::Poll::Ready(Err(e)) => {
4756                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4757                            e.into(),
4758                        ))));
4759                    }
4760                }
4761
4762                // A message has been received from the channel
4763                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4764
4765                std::task::Poll::Ready(Some(match header.ordinal {
4766                    0x525b3b97fdf7d884 => {
4767                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4768                        let mut req = fidl::new_empty!(
4769                            AudioConsumerCreateStreamSinkRequest,
4770                            fidl::encoding::DefaultFuchsiaResourceDialect
4771                        );
4772                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4773                        let control_handle =
4774                            AudioConsumerControlHandle { inner: this.inner.clone() };
4775                        Ok(AudioConsumerRequest::CreateStreamSink {
4776                            buffers: req.buffers,
4777                            stream_type: req.stream_type,
4778                            compression: req.compression,
4779                            stream_sink_request: req.stream_sink_request,
4780
4781                            control_handle,
4782                        })
4783                    }
4784                    0x4fdbd44b3f2a3a3c => {
4785                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4786                        let mut req = fidl::new_empty!(
4787                            AudioConsumerStartRequest,
4788                            fidl::encoding::DefaultFuchsiaResourceDialect
4789                        );
4790                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4791                        let control_handle =
4792                            AudioConsumerControlHandle { inner: this.inner.clone() };
4793                        Ok(AudioConsumerRequest::Start {
4794                            flags: req.flags,
4795                            reference_time: req.reference_time,
4796                            media_time: req.media_time,
4797
4798                            control_handle,
4799                        })
4800                    }
4801                    0x3d46c3741686c40d => {
4802                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4803                        let mut req = fidl::new_empty!(
4804                            fidl::encoding::EmptyPayload,
4805                            fidl::encoding::DefaultFuchsiaResourceDialect
4806                        );
4807                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4808                        let control_handle =
4809                            AudioConsumerControlHandle { inner: this.inner.clone() };
4810                        Ok(AudioConsumerRequest::Stop { control_handle })
4811                    }
4812                    0x45342b73968bfafe => {
4813                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4814                        let mut req = fidl::new_empty!(
4815                            AudioConsumerSetRateRequest,
4816                            fidl::encoding::DefaultFuchsiaResourceDialect
4817                        );
4818                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4819                        let control_handle =
4820                            AudioConsumerControlHandle { inner: this.inner.clone() };
4821                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4822                    }
4823                    0x6f1b01fd887f5748 => {
4824                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4825                        let mut req = fidl::new_empty!(
4826                            AudioConsumerBindVolumeControlRequest,
4827                            fidl::encoding::DefaultFuchsiaResourceDialect
4828                        );
4829                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4830                        let control_handle =
4831                            AudioConsumerControlHandle { inner: this.inner.clone() };
4832                        Ok(AudioConsumerRequest::BindVolumeControl {
4833                            volume_control_request: req.volume_control_request,
4834
4835                            control_handle,
4836                        })
4837                    }
4838                    0x35cf702c721e2cc6 => {
4839                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4840                        let mut req = fidl::new_empty!(
4841                            fidl::encoding::EmptyPayload,
4842                            fidl::encoding::DefaultFuchsiaResourceDialect
4843                        );
4844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4845                        let control_handle =
4846                            AudioConsumerControlHandle { inner: this.inner.clone() };
4847                        Ok(AudioConsumerRequest::WatchStatus {
4848                            responder: AudioConsumerWatchStatusResponder {
4849                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4850                                tx_id: header.tx_id,
4851                            },
4852                        })
4853                    }
4854                    _ => Err(fidl::Error::UnknownOrdinal {
4855                        ordinal: header.ordinal,
4856                        protocol_name:
4857                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4858                    }),
4859                }))
4860            },
4861        )
4862    }
4863}
4864
4865/// Interface for playing and controlling audio.
4866#[derive(Debug)]
4867pub enum AudioConsumerRequest {
4868    /// Creates a `StreamSink` for the consumer with the indicated properties.
4869    ///
4870    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4871    /// sequentially rather than concurrently. The first stream sink that's created using this
4872    /// method is used as the sole source of packets incoming to the logical consumer until that
4873    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4874    /// the second stream sink is used, and so on.
4875    ///
4876    /// If an unsupported compression type is supplied, the
4877    /// `stream_sink_request` request will be closed with an epitaph value of
4878    /// `ZX_ERR_INVALID_ARGS`.
4879    CreateStreamSink {
4880        buffers: Vec<fidl::Vmo>,
4881        stream_type: AudioStreamType,
4882        compression: Option<Box<Compression>>,
4883        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4884        control_handle: AudioConsumerControlHandle,
4885    },
4886    /// Starts rendering as indicated by `flags`.
4887    ///
4888    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4889    /// Typically, this is the timestamp of the first packet that will be
4890    /// rendered. If packets will be supplied with no timestamps, this value
4891    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4892    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4893    ///     1. When starting for the first time, the default media time is the
4894    ///        timestamp on the first packet sent to the stream sink.
4895    ///     2. When resuming after stop, the default media time is the media
4896    ///        time at which the stream stopped.
4897    ///
4898    /// `reference_time` is the monotonic system time at which rendering should
4899    /// be started. For supply-driven sources, this must be the time at which
4900    /// the first packet was (or will be) sent plus a lead time, which must be
4901    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4902    /// sources, the client must ensure that the lead time requirement is met at
4903    /// the start time.  Passing the default value of 0 for `reference_time`
4904    /// causes the consumer to choose a start time based on the availability of
4905    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4906    /// specified.
4907    ///
4908    /// The actual start time will be reflected in the updated status.
4909    Start {
4910        flags: AudioConsumerStartFlags,
4911        reference_time: i64,
4912        media_time: i64,
4913        control_handle: AudioConsumerControlHandle,
4914    },
4915    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4916    /// be reflected in the updated status.
4917    Stop { control_handle: AudioConsumerControlHandle },
4918    /// Requests to change the playback rate of the renderer. 1.0 means normal
4919    /// playback. Negative rates are not supported. The new rate will be
4920    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4921    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4922    /// Binds to this `AudioConsumer` volume control for control and notifications.
4923    BindVolumeControl {
4924        volume_control_request:
4925            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4926        control_handle: AudioConsumerControlHandle,
4927    },
4928    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4929    /// to this method when the status changes - initially with respect to the initial status value
4930    /// and thereafter with respect to the previously-reported status value.
4931    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4932}
4933
4934impl AudioConsumerRequest {
4935    #[allow(irrefutable_let_patterns)]
4936    pub fn into_create_stream_sink(
4937        self,
4938    ) -> Option<(
4939        Vec<fidl::Vmo>,
4940        AudioStreamType,
4941        Option<Box<Compression>>,
4942        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4943        AudioConsumerControlHandle,
4944    )> {
4945        if let AudioConsumerRequest::CreateStreamSink {
4946            buffers,
4947            stream_type,
4948            compression,
4949            stream_sink_request,
4950            control_handle,
4951        } = self
4952        {
4953            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4954        } else {
4955            None
4956        }
4957    }
4958
4959    #[allow(irrefutable_let_patterns)]
4960    pub fn into_start(
4961        self,
4962    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4963        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4964            self
4965        {
4966            Some((flags, reference_time, media_time, control_handle))
4967        } else {
4968            None
4969        }
4970    }
4971
4972    #[allow(irrefutable_let_patterns)]
4973    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4974        if let AudioConsumerRequest::Stop { control_handle } = self {
4975            Some((control_handle))
4976        } else {
4977            None
4978        }
4979    }
4980
4981    #[allow(irrefutable_let_patterns)]
4982    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4983        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4984            Some((rate, control_handle))
4985        } else {
4986            None
4987        }
4988    }
4989
4990    #[allow(irrefutable_let_patterns)]
4991    pub fn into_bind_volume_control(
4992        self,
4993    ) -> Option<(
4994        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4995        AudioConsumerControlHandle,
4996    )> {
4997        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4998            self
4999        {
5000            Some((volume_control_request, control_handle))
5001        } else {
5002            None
5003        }
5004    }
5005
5006    #[allow(irrefutable_let_patterns)]
5007    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
5008        if let AudioConsumerRequest::WatchStatus { responder } = self {
5009            Some((responder))
5010        } else {
5011            None
5012        }
5013    }
5014
5015    /// Name of the method defined in FIDL
5016    pub fn method_name(&self) -> &'static str {
5017        match *self {
5018            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
5019            AudioConsumerRequest::Start { .. } => "start",
5020            AudioConsumerRequest::Stop { .. } => "stop",
5021            AudioConsumerRequest::SetRate { .. } => "set_rate",
5022            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
5023            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
5024        }
5025    }
5026}
5027
5028#[derive(Debug, Clone)]
5029pub struct AudioConsumerControlHandle {
5030    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5031}
5032
5033impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
5034    fn shutdown(&self) {
5035        self.inner.shutdown()
5036    }
5037
5038    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5039        self.inner.shutdown_with_epitaph(status)
5040    }
5041
5042    fn is_closed(&self) -> bool {
5043        self.inner.channel().is_closed()
5044    }
5045    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5046        self.inner.channel().on_closed()
5047    }
5048
5049    #[cfg(target_os = "fuchsia")]
5050    fn signal_peer(
5051        &self,
5052        clear_mask: zx::Signals,
5053        set_mask: zx::Signals,
5054    ) -> Result<(), zx_status::Status> {
5055        use fidl::Peered;
5056        self.inner.channel().signal_peer(clear_mask, set_mask)
5057    }
5058}
5059
5060impl AudioConsumerControlHandle {
5061    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
5062        self.inner.send::<fidl::encoding::EmptyPayload>(
5063            (),
5064            0,
5065            0x53a64e6d0e8f8a20,
5066            fidl::encoding::DynamicFlags::empty(),
5067        )
5068    }
5069}
5070
5071#[must_use = "FIDL methods require a response to be sent"]
5072#[derive(Debug)]
5073pub struct AudioConsumerWatchStatusResponder {
5074    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
5075    tx_id: u32,
5076}
5077
5078/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
5079/// if the responder is dropped without sending a response, so that the client
5080/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5081impl std::ops::Drop for AudioConsumerWatchStatusResponder {
5082    fn drop(&mut self) {
5083        self.control_handle.shutdown();
5084        // Safety: drops once, never accessed again
5085        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5086    }
5087}
5088
5089impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
5090    type ControlHandle = AudioConsumerControlHandle;
5091
5092    fn control_handle(&self) -> &AudioConsumerControlHandle {
5093        &self.control_handle
5094    }
5095
5096    fn drop_without_shutdown(mut self) {
5097        // Safety: drops once, never accessed again due to mem::forget
5098        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5099        // Prevent Drop from running (which would shut down the channel)
5100        std::mem::forget(self);
5101    }
5102}
5103
5104impl AudioConsumerWatchStatusResponder {
5105    /// Sends a response to the FIDL transaction.
5106    ///
5107    /// Sets the channel to shutdown if an error occurs.
5108    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
5109        let _result = self.send_raw(status);
5110        if _result.is_err() {
5111            self.control_handle.shutdown();
5112        }
5113        self.drop_without_shutdown();
5114        _result
5115    }
5116
5117    /// Similar to "send" but does not shutdown the channel if an error occurs.
5118    pub fn send_no_shutdown_on_err(
5119        self,
5120        mut status: &AudioConsumerStatus,
5121    ) -> Result<(), fidl::Error> {
5122        let _result = self.send_raw(status);
5123        self.drop_without_shutdown();
5124        _result
5125    }
5126
5127    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
5128        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
5129            (status,),
5130            self.tx_id,
5131            0x35cf702c721e2cc6,
5132            fidl::encoding::DynamicFlags::empty(),
5133        )
5134    }
5135}
5136
5137#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5138pub struct AudioCoreMarker;
5139
5140impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
5141    type Proxy = AudioCoreProxy;
5142    type RequestStream = AudioCoreRequestStream;
5143    #[cfg(target_os = "fuchsia")]
5144    type SynchronousProxy = AudioCoreSynchronousProxy;
5145
5146    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
5147}
5148impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
5149
5150pub trait AudioCoreProxyInterface: Send + Sync {
5151    fn r#create_audio_renderer(
5152        &self,
5153        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5154    ) -> Result<(), fidl::Error>;
5155    fn r#create_audio_capturer_with_configuration(
5156        &self,
5157        stream_type: &AudioStreamType,
5158        configuration: &AudioCapturerConfiguration,
5159        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5160    ) -> Result<(), fidl::Error>;
5161    fn r#create_audio_capturer(
5162        &self,
5163        loopback: bool,
5164        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5165    ) -> Result<(), fidl::Error>;
5166    fn r#set_render_usage_gain(
5167        &self,
5168        usage: AudioRenderUsage,
5169        gain_db: f32,
5170    ) -> Result<(), fidl::Error>;
5171    fn r#set_render_usage_gain2(
5172        &self,
5173        usage: AudioRenderUsage2,
5174        gain_db: f32,
5175    ) -> Result<(), fidl::Error>;
5176    fn r#set_capture_usage_gain(
5177        &self,
5178        usage: AudioCaptureUsage,
5179        gain_db: f32,
5180    ) -> Result<(), fidl::Error>;
5181    fn r#set_capture_usage_gain2(
5182        &self,
5183        usage: AudioCaptureUsage2,
5184        gain_db: f32,
5185    ) -> Result<(), fidl::Error>;
5186    fn r#bind_usage_volume_control(
5187        &self,
5188        usage: &Usage,
5189        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
5190    ) -> Result<(), fidl::Error>;
5191    fn r#bind_usage_volume_control2(
5192        &self,
5193        usage: &Usage2,
5194        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
5195    ) -> Result<(), fidl::Error>;
5196    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5197    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
5198    -> Self::GetVolumeFromDbResponseFut;
5199    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5200    fn r#get_volume_from_db2(
5201        &self,
5202        usage: &Usage2,
5203        gain_db: f32,
5204    ) -> Self::GetVolumeFromDb2ResponseFut;
5205    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5206    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
5207    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5208    fn r#get_db_from_volume2(
5209        &self,
5210        usage: &Usage2,
5211        volume: f32,
5212    ) -> Self::GetDbFromVolume2ResponseFut;
5213    fn r#set_interaction(
5214        &self,
5215        active: &Usage,
5216        affected: &Usage,
5217        behavior: Behavior,
5218    ) -> Result<(), fidl::Error>;
5219    fn r#set_interaction2(
5220        &self,
5221        active: &Usage2,
5222        affected: &Usage2,
5223        behavior: Behavior,
5224    ) -> Result<(), fidl::Error>;
5225    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
5226    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
5227}
5228#[derive(Debug)]
5229#[cfg(target_os = "fuchsia")]
5230pub struct AudioCoreSynchronousProxy {
5231    client: fidl::client::sync::Client,
5232}
5233
5234#[cfg(target_os = "fuchsia")]
5235impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
5236    type Proxy = AudioCoreProxy;
5237    type Protocol = AudioCoreMarker;
5238
5239    fn from_channel(inner: fidl::Channel) -> Self {
5240        Self::new(inner)
5241    }
5242
5243    fn into_channel(self) -> fidl::Channel {
5244        self.client.into_channel()
5245    }
5246
5247    fn as_channel(&self) -> &fidl::Channel {
5248        self.client.as_channel()
5249    }
5250}
5251
5252#[cfg(target_os = "fuchsia")]
5253impl AudioCoreSynchronousProxy {
5254    pub fn new(channel: fidl::Channel) -> Self {
5255        Self { client: fidl::client::sync::Client::new(channel) }
5256    }
5257
5258    pub fn into_channel(self) -> fidl::Channel {
5259        self.client.into_channel()
5260    }
5261
5262    /// Waits until an event arrives and returns it. It is safe for other
5263    /// threads to make concurrent requests while waiting for an event.
5264    pub fn wait_for_event(
5265        &self,
5266        deadline: zx::MonotonicInstant,
5267    ) -> Result<AudioCoreEvent, fidl::Error> {
5268        AudioCoreEvent::decode(self.client.wait_for_event::<AudioCoreMarker>(deadline)?)
5269    }
5270
5271    /// Creates an AudioRenderer which outputs audio to the default device.
5272    pub fn r#create_audio_renderer(
5273        &self,
5274        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5275    ) -> Result<(), fidl::Error> {
5276        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5277            (audio_out_request,),
5278            0x2ac9beba47f83435,
5279            fidl::encoding::DynamicFlags::empty(),
5280        )
5281    }
5282
5283    /// Creates an AudioCapturer according to the given requirements.
5284    ///
5285    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5286    /// It causes the source material to be reformatted/resampled if needed
5287    /// in order to produce the requested stream type.
5288    ///
5289    /// `usage` is used by Fuchsia to make decisions about user experience.
5290    /// See `AudioCaptureUsage` for more details.
5291    ///
5292    /// `configuration` must be initialized to a variant, or no capturer
5293    /// can be created.
5294    pub fn r#create_audio_capturer_with_configuration(
5295        &self,
5296        mut stream_type: &AudioStreamType,
5297        mut configuration: &AudioCapturerConfiguration,
5298        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5299    ) -> Result<(), fidl::Error> {
5300        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5301            (stream_type, configuration, audio_capturer_request),
5302            0x459de383b0d76d97,
5303            fidl::encoding::DynamicFlags::empty(),
5304        )
5305    }
5306
5307    /// Creates an AudioCapturer which either captures from the current default
5308    /// audio input device, or loops-back from the current default audio output
5309    /// device based on value passed for the loopback flag.
5310    pub fn r#create_audio_capturer(
5311        &self,
5312        mut loopback: bool,
5313        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5314    ) -> Result<(), fidl::Error> {
5315        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5316            (loopback, audio_in_request),
5317            0x787db169df99aed0,
5318            fidl::encoding::DynamicFlags::empty(),
5319        )
5320    }
5321
5322    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5323    pub fn r#set_render_usage_gain(
5324        &self,
5325        mut usage: AudioRenderUsage,
5326        mut gain_db: f32,
5327    ) -> Result<(), fidl::Error> {
5328        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5329            (usage, gain_db),
5330            0x48097f45f6e2b8e7,
5331            fidl::encoding::DynamicFlags::empty(),
5332        )
5333    }
5334
5335    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5336    pub fn r#set_render_usage_gain2(
5337        &self,
5338        mut usage: AudioRenderUsage2,
5339        mut gain_db: f32,
5340    ) -> Result<(), fidl::Error> {
5341        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5342            (usage, gain_db),
5343            0x779b1531dc9e64f4,
5344            fidl::encoding::DynamicFlags::FLEXIBLE,
5345        )
5346    }
5347
5348    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5349    pub fn r#set_capture_usage_gain(
5350        &self,
5351        mut usage: AudioCaptureUsage,
5352        mut gain_db: f32,
5353    ) -> Result<(), fidl::Error> {
5354        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5355            (usage, gain_db),
5356            0x457d29217d4ea248,
5357            fidl::encoding::DynamicFlags::empty(),
5358        )
5359    }
5360
5361    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5362    pub fn r#set_capture_usage_gain2(
5363        &self,
5364        mut usage: AudioCaptureUsage2,
5365        mut gain_db: f32,
5366    ) -> Result<(), fidl::Error> {
5367        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5368            (usage, gain_db),
5369            0x15065ee308f44af0,
5370            fidl::encoding::DynamicFlags::FLEXIBLE,
5371        )
5372    }
5373
5374    /// Binds to a volume control protocol for the given usage.
5375    pub fn r#bind_usage_volume_control(
5376        &self,
5377        mut usage: &Usage,
5378        mut volume_control: fidl::endpoints::ServerEnd<
5379            fidl_fuchsia_media_audio::VolumeControlMarker,
5380        >,
5381    ) -> Result<(), fidl::Error> {
5382        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5383            (usage, volume_control),
5384            0x7225be116aadc137,
5385            fidl::encoding::DynamicFlags::empty(),
5386        )
5387    }
5388
5389    /// Binds to a volume control protocol for the given usage.
5390    pub fn r#bind_usage_volume_control2(
5391        &self,
5392        mut usage: &Usage2,
5393        mut volume_control: fidl::endpoints::ServerEnd<
5394            fidl_fuchsia_media_audio::VolumeControlMarker,
5395        >,
5396    ) -> Result<(), fidl::Error> {
5397        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5398            (usage, volume_control),
5399            0x729dff93019d055,
5400            fidl::encoding::DynamicFlags::FLEXIBLE,
5401        )
5402    }
5403
5404    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5405    /// `usage`. This is the same mapping as used by the VolumeControl from
5406    /// `BindUsageVolumeControl`.
5407    pub fn r#get_volume_from_db(
5408        &self,
5409        mut usage: &Usage,
5410        mut gain_db: f32,
5411        ___deadline: zx::MonotonicInstant,
5412    ) -> Result<f32, fidl::Error> {
5413        let _response = self.client.send_query::<
5414            AudioCoreGetVolumeFromDbRequest,
5415            AudioCoreGetVolumeFromDbResponse,
5416            AudioCoreMarker,
5417        >(
5418            (usage, gain_db,),
5419            0x50e3ca45509770bf,
5420            fidl::encoding::DynamicFlags::empty(),
5421            ___deadline,
5422        )?;
5423        Ok(_response.volume)
5424    }
5425
5426    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5427    /// `usage`. This is the same mapping as used by the VolumeControl from
5428    /// `BindUsageVolumeControl`.
5429    pub fn r#get_volume_from_db2(
5430        &self,
5431        mut usage: &Usage2,
5432        mut gain_db: f32,
5433        ___deadline: zx::MonotonicInstant,
5434    ) -> Result<f32, fidl::Error> {
5435        let _response = self.client.send_query::<
5436            AudioCoreGetVolumeFromDb2Request,
5437            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5438            AudioCoreMarker,
5439        >(
5440            (usage, gain_db,),
5441            0x165c811091ef99da,
5442            fidl::encoding::DynamicFlags::FLEXIBLE,
5443            ___deadline,
5444        )?
5445        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5446        Ok(_response.volume)
5447    }
5448
5449    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5450    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5451    pub fn r#get_db_from_volume(
5452        &self,
5453        mut usage: &Usage,
5454        mut volume: f32,
5455        ___deadline: zx::MonotonicInstant,
5456    ) -> Result<f32, fidl::Error> {
5457        let _response = self.client.send_query::<
5458            AudioCoreGetDbFromVolumeRequest,
5459            AudioCoreGetDbFromVolumeResponse,
5460            AudioCoreMarker,
5461        >(
5462            (usage, volume,),
5463            0x3e8eec27dd5a8bda,
5464            fidl::encoding::DynamicFlags::empty(),
5465            ___deadline,
5466        )?;
5467        Ok(_response.gain_db)
5468    }
5469
5470    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5471    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5472    pub fn r#get_db_from_volume2(
5473        &self,
5474        mut usage: &Usage2,
5475        mut volume: f32,
5476        ___deadline: zx::MonotonicInstant,
5477    ) -> Result<f32, fidl::Error> {
5478        let _response = self.client.send_query::<
5479            AudioCoreGetDbFromVolume2Request,
5480            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5481            AudioCoreMarker,
5482        >(
5483            (usage, volume,),
5484            0x5f421a8ebf265bf3,
5485            fidl::encoding::DynamicFlags::FLEXIBLE,
5486            ___deadline,
5487        )?
5488        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5489        Ok(_response.gain_db)
5490    }
5491
5492    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5493    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5494    /// the Behavior specified will be applied to the streams of Usage `affected`.
5495    pub fn r#set_interaction(
5496        &self,
5497        mut active: &Usage,
5498        mut affected: &Usage,
5499        mut behavior: Behavior,
5500    ) -> Result<(), fidl::Error> {
5501        self.client.send::<AudioCoreSetInteractionRequest>(
5502            (active, affected, behavior),
5503            0x7bfed14345ece7b7,
5504            fidl::encoding::DynamicFlags::empty(),
5505        )
5506    }
5507
5508    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5509    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5510    /// the Behavior specified will be applied to the streams of Usage `affected`.
5511    pub fn r#set_interaction2(
5512        &self,
5513        mut active: &Usage2,
5514        mut affected: &Usage2,
5515        mut behavior: Behavior,
5516    ) -> Result<(), fidl::Error> {
5517        self.client.send::<AudioCoreSetInteraction2Request>(
5518            (active, affected, behavior),
5519            0x7226c7c6e6edc62f,
5520            fidl::encoding::DynamicFlags::FLEXIBLE,
5521        )
5522    }
5523
5524    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5525    /// audio_core. The default behavior is 'NONE'.
5526    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5527        self.client.send::<fidl::encoding::EmptyPayload>(
5528            (),
5529            0x65bd94d9d0a28b5e,
5530            fidl::encoding::DynamicFlags::empty(),
5531        )
5532    }
5533
5534    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5535    /// does not provide a config.
5536    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5537        self.client.send::<fidl::encoding::EmptyPayload>(
5538            (),
5539            0x54a0bebca85f6b31,
5540            fidl::encoding::DynamicFlags::empty(),
5541        )
5542    }
5543}
5544
5545#[cfg(target_os = "fuchsia")]
5546impl From<AudioCoreSynchronousProxy> for zx::NullableHandle {
5547    fn from(value: AudioCoreSynchronousProxy) -> Self {
5548        value.into_channel().into()
5549    }
5550}
5551
5552#[cfg(target_os = "fuchsia")]
5553impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5554    fn from(value: fidl::Channel) -> Self {
5555        Self::new(value)
5556    }
5557}
5558
5559#[cfg(target_os = "fuchsia")]
5560impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5561    type Protocol = AudioCoreMarker;
5562
5563    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5564        Self::new(value.into_channel())
5565    }
5566}
5567
5568#[derive(Debug, Clone)]
5569pub struct AudioCoreProxy {
5570    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5571}
5572
5573impl fidl::endpoints::Proxy for AudioCoreProxy {
5574    type Protocol = AudioCoreMarker;
5575
5576    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5577        Self::new(inner)
5578    }
5579
5580    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5581        self.client.into_channel().map_err(|client| Self { client })
5582    }
5583
5584    fn as_channel(&self) -> &::fidl::AsyncChannel {
5585        self.client.as_channel()
5586    }
5587}
5588
5589impl AudioCoreProxy {
5590    /// Create a new Proxy for fuchsia.media/AudioCore.
5591    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5592        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5593        Self { client: fidl::client::Client::new(channel, protocol_name) }
5594    }
5595
5596    /// Get a Stream of events from the remote end of the protocol.
5597    ///
5598    /// # Panics
5599    ///
5600    /// Panics if the event stream was already taken.
5601    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5602        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5603    }
5604
5605    /// Creates an AudioRenderer which outputs audio to the default device.
5606    pub fn r#create_audio_renderer(
5607        &self,
5608        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5609    ) -> Result<(), fidl::Error> {
5610        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5611    }
5612
5613    /// Creates an AudioCapturer according to the given requirements.
5614    ///
5615    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5616    /// It causes the source material to be reformatted/resampled if needed
5617    /// in order to produce the requested stream type.
5618    ///
5619    /// `usage` is used by Fuchsia to make decisions about user experience.
5620    /// See `AudioCaptureUsage` for more details.
5621    ///
5622    /// `configuration` must be initialized to a variant, or no capturer
5623    /// can be created.
5624    pub fn r#create_audio_capturer_with_configuration(
5625        &self,
5626        mut stream_type: &AudioStreamType,
5627        mut configuration: &AudioCapturerConfiguration,
5628        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5629    ) -> Result<(), fidl::Error> {
5630        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5631            self,
5632            stream_type,
5633            configuration,
5634            audio_capturer_request,
5635        )
5636    }
5637
5638    /// Creates an AudioCapturer which either captures from the current default
5639    /// audio input device, or loops-back from the current default audio output
5640    /// device based on value passed for the loopback flag.
5641    pub fn r#create_audio_capturer(
5642        &self,
5643        mut loopback: bool,
5644        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5645    ) -> Result<(), fidl::Error> {
5646        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5647    }
5648
5649    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5650    pub fn r#set_render_usage_gain(
5651        &self,
5652        mut usage: AudioRenderUsage,
5653        mut gain_db: f32,
5654    ) -> Result<(), fidl::Error> {
5655        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5656    }
5657
5658    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5659    pub fn r#set_render_usage_gain2(
5660        &self,
5661        mut usage: AudioRenderUsage2,
5662        mut gain_db: f32,
5663    ) -> Result<(), fidl::Error> {
5664        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5665    }
5666
5667    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5668    pub fn r#set_capture_usage_gain(
5669        &self,
5670        mut usage: AudioCaptureUsage,
5671        mut gain_db: f32,
5672    ) -> Result<(), fidl::Error> {
5673        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5674    }
5675
5676    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5677    pub fn r#set_capture_usage_gain2(
5678        &self,
5679        mut usage: AudioCaptureUsage2,
5680        mut gain_db: f32,
5681    ) -> Result<(), fidl::Error> {
5682        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5683    }
5684
5685    /// Binds to a volume control protocol for the given usage.
5686    pub fn r#bind_usage_volume_control(
5687        &self,
5688        mut usage: &Usage,
5689        mut volume_control: fidl::endpoints::ServerEnd<
5690            fidl_fuchsia_media_audio::VolumeControlMarker,
5691        >,
5692    ) -> Result<(), fidl::Error> {
5693        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5694    }
5695
5696    /// Binds to a volume control protocol for the given usage.
5697    pub fn r#bind_usage_volume_control2(
5698        &self,
5699        mut usage: &Usage2,
5700        mut volume_control: fidl::endpoints::ServerEnd<
5701            fidl_fuchsia_media_audio::VolumeControlMarker,
5702        >,
5703    ) -> Result<(), fidl::Error> {
5704        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5705    }
5706
5707    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5708    /// `usage`. This is the same mapping as used by the VolumeControl from
5709    /// `BindUsageVolumeControl`.
5710    pub fn r#get_volume_from_db(
5711        &self,
5712        mut usage: &Usage,
5713        mut gain_db: f32,
5714    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5715        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5716    }
5717
5718    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5719    /// `usage`. This is the same mapping as used by the VolumeControl from
5720    /// `BindUsageVolumeControl`.
5721    pub fn r#get_volume_from_db2(
5722        &self,
5723        mut usage: &Usage2,
5724        mut gain_db: f32,
5725    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5726        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5727    }
5728
5729    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5730    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5731    pub fn r#get_db_from_volume(
5732        &self,
5733        mut usage: &Usage,
5734        mut volume: f32,
5735    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5736        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5737    }
5738
5739    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5740    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5741    pub fn r#get_db_from_volume2(
5742        &self,
5743        mut usage: &Usage2,
5744        mut volume: f32,
5745    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5746        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5747    }
5748
5749    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5750    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5751    /// the Behavior specified will be applied to the streams of Usage `affected`.
5752    pub fn r#set_interaction(
5753        &self,
5754        mut active: &Usage,
5755        mut affected: &Usage,
5756        mut behavior: Behavior,
5757    ) -> Result<(), fidl::Error> {
5758        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5759    }
5760
5761    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5762    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5763    /// the Behavior specified will be applied to the streams of Usage `affected`.
5764    pub fn r#set_interaction2(
5765        &self,
5766        mut active: &Usage2,
5767        mut affected: &Usage2,
5768        mut behavior: Behavior,
5769    ) -> Result<(), fidl::Error> {
5770        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5771    }
5772
5773    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5774    /// audio_core. The default behavior is 'NONE'.
5775    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5776        AudioCoreProxyInterface::r#reset_interactions(self)
5777    }
5778
5779    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5780    /// does not provide a config.
5781    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5782        AudioCoreProxyInterface::r#load_defaults(self)
5783    }
5784}
5785
5786impl AudioCoreProxyInterface for AudioCoreProxy {
5787    fn r#create_audio_renderer(
5788        &self,
5789        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5790    ) -> Result<(), fidl::Error> {
5791        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5792            (audio_out_request,),
5793            0x2ac9beba47f83435,
5794            fidl::encoding::DynamicFlags::empty(),
5795        )
5796    }
5797
5798    fn r#create_audio_capturer_with_configuration(
5799        &self,
5800        mut stream_type: &AudioStreamType,
5801        mut configuration: &AudioCapturerConfiguration,
5802        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5803    ) -> Result<(), fidl::Error> {
5804        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5805            (stream_type, configuration, audio_capturer_request),
5806            0x459de383b0d76d97,
5807            fidl::encoding::DynamicFlags::empty(),
5808        )
5809    }
5810
5811    fn r#create_audio_capturer(
5812        &self,
5813        mut loopback: bool,
5814        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5815    ) -> Result<(), fidl::Error> {
5816        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5817            (loopback, audio_in_request),
5818            0x787db169df99aed0,
5819            fidl::encoding::DynamicFlags::empty(),
5820        )
5821    }
5822
5823    fn r#set_render_usage_gain(
5824        &self,
5825        mut usage: AudioRenderUsage,
5826        mut gain_db: f32,
5827    ) -> Result<(), fidl::Error> {
5828        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5829            (usage, gain_db),
5830            0x48097f45f6e2b8e7,
5831            fidl::encoding::DynamicFlags::empty(),
5832        )
5833    }
5834
5835    fn r#set_render_usage_gain2(
5836        &self,
5837        mut usage: AudioRenderUsage2,
5838        mut gain_db: f32,
5839    ) -> Result<(), fidl::Error> {
5840        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5841            (usage, gain_db),
5842            0x779b1531dc9e64f4,
5843            fidl::encoding::DynamicFlags::FLEXIBLE,
5844        )
5845    }
5846
5847    fn r#set_capture_usage_gain(
5848        &self,
5849        mut usage: AudioCaptureUsage,
5850        mut gain_db: f32,
5851    ) -> Result<(), fidl::Error> {
5852        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5853            (usage, gain_db),
5854            0x457d29217d4ea248,
5855            fidl::encoding::DynamicFlags::empty(),
5856        )
5857    }
5858
5859    fn r#set_capture_usage_gain2(
5860        &self,
5861        mut usage: AudioCaptureUsage2,
5862        mut gain_db: f32,
5863    ) -> Result<(), fidl::Error> {
5864        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5865            (usage, gain_db),
5866            0x15065ee308f44af0,
5867            fidl::encoding::DynamicFlags::FLEXIBLE,
5868        )
5869    }
5870
5871    fn r#bind_usage_volume_control(
5872        &self,
5873        mut usage: &Usage,
5874        mut volume_control: fidl::endpoints::ServerEnd<
5875            fidl_fuchsia_media_audio::VolumeControlMarker,
5876        >,
5877    ) -> Result<(), fidl::Error> {
5878        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5879            (usage, volume_control),
5880            0x7225be116aadc137,
5881            fidl::encoding::DynamicFlags::empty(),
5882        )
5883    }
5884
5885    fn r#bind_usage_volume_control2(
5886        &self,
5887        mut usage: &Usage2,
5888        mut volume_control: fidl::endpoints::ServerEnd<
5889            fidl_fuchsia_media_audio::VolumeControlMarker,
5890        >,
5891    ) -> Result<(), fidl::Error> {
5892        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5893            (usage, volume_control),
5894            0x729dff93019d055,
5895            fidl::encoding::DynamicFlags::FLEXIBLE,
5896        )
5897    }
5898
5899    type GetVolumeFromDbResponseFut =
5900        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5901    fn r#get_volume_from_db(
5902        &self,
5903        mut usage: &Usage,
5904        mut gain_db: f32,
5905    ) -> Self::GetVolumeFromDbResponseFut {
5906        fn _decode(
5907            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5908        ) -> Result<f32, fidl::Error> {
5909            let _response = fidl::client::decode_transaction_body::<
5910                AudioCoreGetVolumeFromDbResponse,
5911                fidl::encoding::DefaultFuchsiaResourceDialect,
5912                0x50e3ca45509770bf,
5913            >(_buf?)?;
5914            Ok(_response.volume)
5915        }
5916        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5917            (usage, gain_db),
5918            0x50e3ca45509770bf,
5919            fidl::encoding::DynamicFlags::empty(),
5920            _decode,
5921        )
5922    }
5923
5924    type GetVolumeFromDb2ResponseFut =
5925        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5926    fn r#get_volume_from_db2(
5927        &self,
5928        mut usage: &Usage2,
5929        mut gain_db: f32,
5930    ) -> Self::GetVolumeFromDb2ResponseFut {
5931        fn _decode(
5932            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5933        ) -> Result<f32, fidl::Error> {
5934            let _response = fidl::client::decode_transaction_body::<
5935                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5936                fidl::encoding::DefaultFuchsiaResourceDialect,
5937                0x165c811091ef99da,
5938            >(_buf?)?
5939            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5940            Ok(_response.volume)
5941        }
5942        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5943            (usage, gain_db),
5944            0x165c811091ef99da,
5945            fidl::encoding::DynamicFlags::FLEXIBLE,
5946            _decode,
5947        )
5948    }
5949
5950    type GetDbFromVolumeResponseFut =
5951        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5952    fn r#get_db_from_volume(
5953        &self,
5954        mut usage: &Usage,
5955        mut volume: f32,
5956    ) -> Self::GetDbFromVolumeResponseFut {
5957        fn _decode(
5958            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5959        ) -> Result<f32, fidl::Error> {
5960            let _response = fidl::client::decode_transaction_body::<
5961                AudioCoreGetDbFromVolumeResponse,
5962                fidl::encoding::DefaultFuchsiaResourceDialect,
5963                0x3e8eec27dd5a8bda,
5964            >(_buf?)?;
5965            Ok(_response.gain_db)
5966        }
5967        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5968            (usage, volume),
5969            0x3e8eec27dd5a8bda,
5970            fidl::encoding::DynamicFlags::empty(),
5971            _decode,
5972        )
5973    }
5974
5975    type GetDbFromVolume2ResponseFut =
5976        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5977    fn r#get_db_from_volume2(
5978        &self,
5979        mut usage: &Usage2,
5980        mut volume: f32,
5981    ) -> Self::GetDbFromVolume2ResponseFut {
5982        fn _decode(
5983            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5984        ) -> Result<f32, fidl::Error> {
5985            let _response = fidl::client::decode_transaction_body::<
5986                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5987                fidl::encoding::DefaultFuchsiaResourceDialect,
5988                0x5f421a8ebf265bf3,
5989            >(_buf?)?
5990            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5991            Ok(_response.gain_db)
5992        }
5993        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
5994            (usage, volume),
5995            0x5f421a8ebf265bf3,
5996            fidl::encoding::DynamicFlags::FLEXIBLE,
5997            _decode,
5998        )
5999    }
6000
6001    fn r#set_interaction(
6002        &self,
6003        mut active: &Usage,
6004        mut affected: &Usage,
6005        mut behavior: Behavior,
6006    ) -> Result<(), fidl::Error> {
6007        self.client.send::<AudioCoreSetInteractionRequest>(
6008            (active, affected, behavior),
6009            0x7bfed14345ece7b7,
6010            fidl::encoding::DynamicFlags::empty(),
6011        )
6012    }
6013
6014    fn r#set_interaction2(
6015        &self,
6016        mut active: &Usage2,
6017        mut affected: &Usage2,
6018        mut behavior: Behavior,
6019    ) -> Result<(), fidl::Error> {
6020        self.client.send::<AudioCoreSetInteraction2Request>(
6021            (active, affected, behavior),
6022            0x7226c7c6e6edc62f,
6023            fidl::encoding::DynamicFlags::FLEXIBLE,
6024        )
6025    }
6026
6027    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
6028        self.client.send::<fidl::encoding::EmptyPayload>(
6029            (),
6030            0x65bd94d9d0a28b5e,
6031            fidl::encoding::DynamicFlags::empty(),
6032        )
6033    }
6034
6035    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
6036        self.client.send::<fidl::encoding::EmptyPayload>(
6037            (),
6038            0x54a0bebca85f6b31,
6039            fidl::encoding::DynamicFlags::empty(),
6040        )
6041    }
6042}
6043
6044pub struct AudioCoreEventStream {
6045    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6046}
6047
6048impl std::marker::Unpin for AudioCoreEventStream {}
6049
6050impl futures::stream::FusedStream for AudioCoreEventStream {
6051    fn is_terminated(&self) -> bool {
6052        self.event_receiver.is_terminated()
6053    }
6054}
6055
6056impl futures::Stream for AudioCoreEventStream {
6057    type Item = Result<AudioCoreEvent, fidl::Error>;
6058
6059    fn poll_next(
6060        mut self: std::pin::Pin<&mut Self>,
6061        cx: &mut std::task::Context<'_>,
6062    ) -> std::task::Poll<Option<Self::Item>> {
6063        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6064            &mut self.event_receiver,
6065            cx
6066        )?) {
6067            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
6068            None => std::task::Poll::Ready(None),
6069        }
6070    }
6071}
6072
6073#[derive(Debug)]
6074pub enum AudioCoreEvent {
6075    #[non_exhaustive]
6076    _UnknownEvent {
6077        /// Ordinal of the event that was sent.
6078        ordinal: u64,
6079    },
6080}
6081
6082impl AudioCoreEvent {
6083    /// Decodes a message buffer as a [`AudioCoreEvent`].
6084    fn decode(
6085        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6086    ) -> Result<AudioCoreEvent, fidl::Error> {
6087        let (bytes, _handles) = buf.split_mut();
6088        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6089        debug_assert_eq!(tx_header.tx_id, 0);
6090        match tx_header.ordinal {
6091            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6092                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6093            }
6094            _ => Err(fidl::Error::UnknownOrdinal {
6095                ordinal: tx_header.ordinal,
6096                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6097            }),
6098        }
6099    }
6100}
6101
6102/// A Stream of incoming requests for fuchsia.media/AudioCore.
6103pub struct AudioCoreRequestStream {
6104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6105    is_terminated: bool,
6106}
6107
6108impl std::marker::Unpin for AudioCoreRequestStream {}
6109
6110impl futures::stream::FusedStream for AudioCoreRequestStream {
6111    fn is_terminated(&self) -> bool {
6112        self.is_terminated
6113    }
6114}
6115
6116impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
6117    type Protocol = AudioCoreMarker;
6118    type ControlHandle = AudioCoreControlHandle;
6119
6120    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6121        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6122    }
6123
6124    fn control_handle(&self) -> Self::ControlHandle {
6125        AudioCoreControlHandle { inner: self.inner.clone() }
6126    }
6127
6128    fn into_inner(
6129        self,
6130    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6131    {
6132        (self.inner, self.is_terminated)
6133    }
6134
6135    fn from_inner(
6136        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6137        is_terminated: bool,
6138    ) -> Self {
6139        Self { inner, is_terminated }
6140    }
6141}
6142
6143impl futures::Stream for AudioCoreRequestStream {
6144    type Item = Result<AudioCoreRequest, fidl::Error>;
6145
6146    fn poll_next(
6147        mut self: std::pin::Pin<&mut Self>,
6148        cx: &mut std::task::Context<'_>,
6149    ) -> std::task::Poll<Option<Self::Item>> {
6150        let this = &mut *self;
6151        if this.inner.check_shutdown(cx) {
6152            this.is_terminated = true;
6153            return std::task::Poll::Ready(None);
6154        }
6155        if this.is_terminated {
6156            panic!("polled AudioCoreRequestStream after completion");
6157        }
6158        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6159            |bytes, handles| {
6160                match this.inner.channel().read_etc(cx, bytes, handles) {
6161                    std::task::Poll::Ready(Ok(())) => {}
6162                    std::task::Poll::Pending => return std::task::Poll::Pending,
6163                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6164                        this.is_terminated = true;
6165                        return std::task::Poll::Ready(None);
6166                    }
6167                    std::task::Poll::Ready(Err(e)) => {
6168                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6169                            e.into(),
6170                        ))));
6171                    }
6172                }
6173
6174                // A message has been received from the channel
6175                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6176
6177                std::task::Poll::Ready(Some(match header.ordinal {
6178                    0x2ac9beba47f83435 => {
6179                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6180                        let mut req = fidl::new_empty!(
6181                            AudioCoreCreateAudioRendererRequest,
6182                            fidl::encoding::DefaultFuchsiaResourceDialect
6183                        );
6184                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
6185                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6186                        Ok(AudioCoreRequest::CreateAudioRenderer {
6187                            audio_out_request: req.audio_out_request,
6188
6189                            control_handle,
6190                        })
6191                    }
6192                    0x459de383b0d76d97 => {
6193                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6194                        let mut req = fidl::new_empty!(
6195                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
6196                            fidl::encoding::DefaultFuchsiaResourceDialect
6197                        );
6198                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
6199                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6200                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6201                            stream_type: req.stream_type,
6202                            configuration: req.configuration,
6203                            audio_capturer_request: req.audio_capturer_request,
6204
6205                            control_handle,
6206                        })
6207                    }
6208                    0x787db169df99aed0 => {
6209                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6210                        let mut req = fidl::new_empty!(
6211                            AudioCoreCreateAudioCapturerRequest,
6212                            fidl::encoding::DefaultFuchsiaResourceDialect
6213                        );
6214                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
6215                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6216                        Ok(AudioCoreRequest::CreateAudioCapturer {
6217                            loopback: req.loopback,
6218                            audio_in_request: req.audio_in_request,
6219
6220                            control_handle,
6221                        })
6222                    }
6223                    0x48097f45f6e2b8e7 => {
6224                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6225                        let mut req = fidl::new_empty!(
6226                            AudioCoreSetRenderUsageGainRequest,
6227                            fidl::encoding::DefaultFuchsiaResourceDialect
6228                        );
6229                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
6230                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6231                        Ok(AudioCoreRequest::SetRenderUsageGain {
6232                            usage: req.usage,
6233                            gain_db: req.gain_db,
6234
6235                            control_handle,
6236                        })
6237                    }
6238                    0x779b1531dc9e64f4 => {
6239                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6240                        let mut req = fidl::new_empty!(
6241                            AudioCoreSetRenderUsageGain2Request,
6242                            fidl::encoding::DefaultFuchsiaResourceDialect
6243                        );
6244                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
6245                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6246                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
6247                            usage: req.usage,
6248                            gain_db: req.gain_db,
6249
6250                            control_handle,
6251                        })
6252                    }
6253                    0x457d29217d4ea248 => {
6254                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6255                        let mut req = fidl::new_empty!(
6256                            AudioCoreSetCaptureUsageGainRequest,
6257                            fidl::encoding::DefaultFuchsiaResourceDialect
6258                        );
6259                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
6260                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6261                        Ok(AudioCoreRequest::SetCaptureUsageGain {
6262                            usage: req.usage,
6263                            gain_db: req.gain_db,
6264
6265                            control_handle,
6266                        })
6267                    }
6268                    0x15065ee308f44af0 => {
6269                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6270                        let mut req = fidl::new_empty!(
6271                            AudioCoreSetCaptureUsageGain2Request,
6272                            fidl::encoding::DefaultFuchsiaResourceDialect
6273                        );
6274                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
6275                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6276                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
6277                            usage: req.usage,
6278                            gain_db: req.gain_db,
6279
6280                            control_handle,
6281                        })
6282                    }
6283                    0x7225be116aadc137 => {
6284                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6285                        let mut req = fidl::new_empty!(
6286                            AudioCoreBindUsageVolumeControlRequest,
6287                            fidl::encoding::DefaultFuchsiaResourceDialect
6288                        );
6289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
6290                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6291                        Ok(AudioCoreRequest::BindUsageVolumeControl {
6292                            usage: req.usage,
6293                            volume_control: req.volume_control,
6294
6295                            control_handle,
6296                        })
6297                    }
6298                    0x729dff93019d055 => {
6299                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6300                        let mut req = fidl::new_empty!(
6301                            AudioCoreBindUsageVolumeControl2Request,
6302                            fidl::encoding::DefaultFuchsiaResourceDialect
6303                        );
6304                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6305                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6306                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6307                            usage: req.usage,
6308                            volume_control: req.volume_control,
6309
6310                            control_handle,
6311                        })
6312                    }
6313                    0x50e3ca45509770bf => {
6314                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6315                        let mut req = fidl::new_empty!(
6316                            AudioCoreGetVolumeFromDbRequest,
6317                            fidl::encoding::DefaultFuchsiaResourceDialect
6318                        );
6319                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6320                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6321                        Ok(AudioCoreRequest::GetVolumeFromDb {
6322                            usage: req.usage,
6323                            gain_db: req.gain_db,
6324
6325                            responder: AudioCoreGetVolumeFromDbResponder {
6326                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6327                                tx_id: header.tx_id,
6328                            },
6329                        })
6330                    }
6331                    0x165c811091ef99da => {
6332                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6333                        let mut req = fidl::new_empty!(
6334                            AudioCoreGetVolumeFromDb2Request,
6335                            fidl::encoding::DefaultFuchsiaResourceDialect
6336                        );
6337                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6338                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6339                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6340                            usage: req.usage,
6341                            gain_db: req.gain_db,
6342
6343                            responder: AudioCoreGetVolumeFromDb2Responder {
6344                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6345                                tx_id: header.tx_id,
6346                            },
6347                        })
6348                    }
6349                    0x3e8eec27dd5a8bda => {
6350                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6351                        let mut req = fidl::new_empty!(
6352                            AudioCoreGetDbFromVolumeRequest,
6353                            fidl::encoding::DefaultFuchsiaResourceDialect
6354                        );
6355                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6356                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6357                        Ok(AudioCoreRequest::GetDbFromVolume {
6358                            usage: req.usage,
6359                            volume: req.volume,
6360
6361                            responder: AudioCoreGetDbFromVolumeResponder {
6362                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6363                                tx_id: header.tx_id,
6364                            },
6365                        })
6366                    }
6367                    0x5f421a8ebf265bf3 => {
6368                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6369                        let mut req = fidl::new_empty!(
6370                            AudioCoreGetDbFromVolume2Request,
6371                            fidl::encoding::DefaultFuchsiaResourceDialect
6372                        );
6373                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6374                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6375                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6376                            usage: req.usage,
6377                            volume: req.volume,
6378
6379                            responder: AudioCoreGetDbFromVolume2Responder {
6380                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6381                                tx_id: header.tx_id,
6382                            },
6383                        })
6384                    }
6385                    0x7bfed14345ece7b7 => {
6386                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6387                        let mut req = fidl::new_empty!(
6388                            AudioCoreSetInteractionRequest,
6389                            fidl::encoding::DefaultFuchsiaResourceDialect
6390                        );
6391                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6392                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6393                        Ok(AudioCoreRequest::SetInteraction {
6394                            active: req.active,
6395                            affected: req.affected,
6396                            behavior: req.behavior,
6397
6398                            control_handle,
6399                        })
6400                    }
6401                    0x7226c7c6e6edc62f => {
6402                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6403                        let mut req = fidl::new_empty!(
6404                            AudioCoreSetInteraction2Request,
6405                            fidl::encoding::DefaultFuchsiaResourceDialect
6406                        );
6407                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6408                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6409                        Ok(AudioCoreRequest::SetInteraction2 {
6410                            active: req.active,
6411                            affected: req.affected,
6412                            behavior: req.behavior,
6413
6414                            control_handle,
6415                        })
6416                    }
6417                    0x65bd94d9d0a28b5e => {
6418                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6419                        let mut req = fidl::new_empty!(
6420                            fidl::encoding::EmptyPayload,
6421                            fidl::encoding::DefaultFuchsiaResourceDialect
6422                        );
6423                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6424                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6425                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6426                    }
6427                    0x54a0bebca85f6b31 => {
6428                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6429                        let mut req = fidl::new_empty!(
6430                            fidl::encoding::EmptyPayload,
6431                            fidl::encoding::DefaultFuchsiaResourceDialect
6432                        );
6433                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6434                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6435                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6436                    }
6437                    _ if header.tx_id == 0
6438                        && header
6439                            .dynamic_flags()
6440                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6441                    {
6442                        Ok(AudioCoreRequest::_UnknownMethod {
6443                            ordinal: header.ordinal,
6444                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6445                            method_type: fidl::MethodType::OneWay,
6446                        })
6447                    }
6448                    _ if header
6449                        .dynamic_flags()
6450                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6451                    {
6452                        this.inner.send_framework_err(
6453                            fidl::encoding::FrameworkErr::UnknownMethod,
6454                            header.tx_id,
6455                            header.ordinal,
6456                            header.dynamic_flags(),
6457                            (bytes, handles),
6458                        )?;
6459                        Ok(AudioCoreRequest::_UnknownMethod {
6460                            ordinal: header.ordinal,
6461                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6462                            method_type: fidl::MethodType::TwoWay,
6463                        })
6464                    }
6465                    _ => Err(fidl::Error::UnknownOrdinal {
6466                        ordinal: header.ordinal,
6467                        protocol_name:
6468                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6469                    }),
6470                }))
6471            },
6472        )
6473    }
6474}
6475
6476#[derive(Debug)]
6477pub enum AudioCoreRequest {
6478    /// Creates an AudioRenderer which outputs audio to the default device.
6479    CreateAudioRenderer {
6480        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6481        control_handle: AudioCoreControlHandle,
6482    },
6483    /// Creates an AudioCapturer according to the given requirements.
6484    ///
6485    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6486    /// It causes the source material to be reformatted/resampled if needed
6487    /// in order to produce the requested stream type.
6488    ///
6489    /// `usage` is used by Fuchsia to make decisions about user experience.
6490    /// See `AudioCaptureUsage` for more details.
6491    ///
6492    /// `configuration` must be initialized to a variant, or no capturer
6493    /// can be created.
6494    CreateAudioCapturerWithConfiguration {
6495        stream_type: AudioStreamType,
6496        configuration: AudioCapturerConfiguration,
6497        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6498        control_handle: AudioCoreControlHandle,
6499    },
6500    /// Creates an AudioCapturer which either captures from the current default
6501    /// audio input device, or loops-back from the current default audio output
6502    /// device based on value passed for the loopback flag.
6503    CreateAudioCapturer {
6504        loopback: bool,
6505        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6506        control_handle: AudioCoreControlHandle,
6507    },
6508    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6509    SetRenderUsageGain {
6510        usage: AudioRenderUsage,
6511        gain_db: f32,
6512        control_handle: AudioCoreControlHandle,
6513    },
6514    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6515    SetRenderUsageGain2 {
6516        usage: AudioRenderUsage2,
6517        gain_db: f32,
6518        control_handle: AudioCoreControlHandle,
6519    },
6520    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6521    SetCaptureUsageGain {
6522        usage: AudioCaptureUsage,
6523        gain_db: f32,
6524        control_handle: AudioCoreControlHandle,
6525    },
6526    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6527    SetCaptureUsageGain2 {
6528        usage: AudioCaptureUsage2,
6529        gain_db: f32,
6530        control_handle: AudioCoreControlHandle,
6531    },
6532    /// Binds to a volume control protocol for the given usage.
6533    BindUsageVolumeControl {
6534        usage: Usage,
6535        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6536        control_handle: AudioCoreControlHandle,
6537    },
6538    /// Binds to a volume control protocol for the given usage.
6539    BindUsageVolumeControl2 {
6540        usage: Usage2,
6541        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6542        control_handle: AudioCoreControlHandle,
6543    },
6544    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6545    /// `usage`. This is the same mapping as used by the VolumeControl from
6546    /// `BindUsageVolumeControl`.
6547    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
6548    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6549    /// `usage`. This is the same mapping as used by the VolumeControl from
6550    /// `BindUsageVolumeControl`.
6551    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
6552    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6553    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6554    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
6555    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6556    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6557    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
6558    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6559    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6560    /// the Behavior specified will be applied to the streams of Usage `affected`.
6561    SetInteraction {
6562        active: Usage,
6563        affected: Usage,
6564        behavior: Behavior,
6565        control_handle: AudioCoreControlHandle,
6566    },
6567    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6568    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6569    /// the Behavior specified will be applied to the streams of Usage `affected`.
6570    SetInteraction2 {
6571        active: Usage2,
6572        affected: Usage2,
6573        behavior: Behavior,
6574        control_handle: AudioCoreControlHandle,
6575    },
6576    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6577    /// audio_core. The default behavior is 'NONE'.
6578    ResetInteractions { control_handle: AudioCoreControlHandle },
6579    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6580    /// does not provide a config.
6581    LoadDefaults { control_handle: AudioCoreControlHandle },
6582    /// An interaction was received which does not match any known method.
6583    #[non_exhaustive]
6584    _UnknownMethod {
6585        /// Ordinal of the method that was called.
6586        ordinal: u64,
6587        control_handle: AudioCoreControlHandle,
6588        method_type: fidl::MethodType,
6589    },
6590}
6591
6592impl AudioCoreRequest {
6593    #[allow(irrefutable_let_patterns)]
6594    pub fn into_create_audio_renderer(
6595        self,
6596    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6597        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6598            Some((audio_out_request, control_handle))
6599        } else {
6600            None
6601        }
6602    }
6603
6604    #[allow(irrefutable_let_patterns)]
6605    pub fn into_create_audio_capturer_with_configuration(
6606        self,
6607    ) -> Option<(
6608        AudioStreamType,
6609        AudioCapturerConfiguration,
6610        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6611        AudioCoreControlHandle,
6612    )> {
6613        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6614            stream_type,
6615            configuration,
6616            audio_capturer_request,
6617            control_handle,
6618        } = self
6619        {
6620            Some((stream_type, configuration, audio_capturer_request, control_handle))
6621        } else {
6622            None
6623        }
6624    }
6625
6626    #[allow(irrefutable_let_patterns)]
6627    pub fn into_create_audio_capturer(
6628        self,
6629    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6630    {
6631        if let AudioCoreRequest::CreateAudioCapturer {
6632            loopback,
6633            audio_in_request,
6634            control_handle,
6635        } = self
6636        {
6637            Some((loopback, audio_in_request, control_handle))
6638        } else {
6639            None
6640        }
6641    }
6642
6643    #[allow(irrefutable_let_patterns)]
6644    pub fn into_set_render_usage_gain(
6645        self,
6646    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6647        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6648            Some((usage, gain_db, control_handle))
6649        } else {
6650            None
6651        }
6652    }
6653
6654    #[allow(irrefutable_let_patterns)]
6655    pub fn into_set_render_usage_gain2(
6656        self,
6657    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6658        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6659            Some((usage, gain_db, control_handle))
6660        } else {
6661            None
6662        }
6663    }
6664
6665    #[allow(irrefutable_let_patterns)]
6666    pub fn into_set_capture_usage_gain(
6667        self,
6668    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6669        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6670            Some((usage, gain_db, control_handle))
6671        } else {
6672            None
6673        }
6674    }
6675
6676    #[allow(irrefutable_let_patterns)]
6677    pub fn into_set_capture_usage_gain2(
6678        self,
6679    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6680        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6681            Some((usage, gain_db, control_handle))
6682        } else {
6683            None
6684        }
6685    }
6686
6687    #[allow(irrefutable_let_patterns)]
6688    pub fn into_bind_usage_volume_control(
6689        self,
6690    ) -> Option<(
6691        Usage,
6692        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6693        AudioCoreControlHandle,
6694    )> {
6695        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6696            self
6697        {
6698            Some((usage, volume_control, control_handle))
6699        } else {
6700            None
6701        }
6702    }
6703
6704    #[allow(irrefutable_let_patterns)]
6705    pub fn into_bind_usage_volume_control2(
6706        self,
6707    ) -> Option<(
6708        Usage2,
6709        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6710        AudioCoreControlHandle,
6711    )> {
6712        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6713            self
6714        {
6715            Some((usage, volume_control, control_handle))
6716        } else {
6717            None
6718        }
6719    }
6720
6721    #[allow(irrefutable_let_patterns)]
6722    pub fn into_get_volume_from_db(
6723        self,
6724    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6725        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6726            Some((usage, gain_db, responder))
6727        } else {
6728            None
6729        }
6730    }
6731
6732    #[allow(irrefutable_let_patterns)]
6733    pub fn into_get_volume_from_db2(
6734        self,
6735    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6736        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6737            Some((usage, gain_db, responder))
6738        } else {
6739            None
6740        }
6741    }
6742
6743    #[allow(irrefutable_let_patterns)]
6744    pub fn into_get_db_from_volume(
6745        self,
6746    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6747        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6748            Some((usage, volume, responder))
6749        } else {
6750            None
6751        }
6752    }
6753
6754    #[allow(irrefutable_let_patterns)]
6755    pub fn into_get_db_from_volume2(
6756        self,
6757    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6758        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6759            Some((usage, volume, responder))
6760        } else {
6761            None
6762        }
6763    }
6764
6765    #[allow(irrefutable_let_patterns)]
6766    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6767        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6768            self
6769        {
6770            Some((active, affected, behavior, control_handle))
6771        } else {
6772            None
6773        }
6774    }
6775
6776    #[allow(irrefutable_let_patterns)]
6777    pub fn into_set_interaction2(
6778        self,
6779    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6780        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6781            self
6782        {
6783            Some((active, affected, behavior, control_handle))
6784        } else {
6785            None
6786        }
6787    }
6788
6789    #[allow(irrefutable_let_patterns)]
6790    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6791        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6792            Some((control_handle))
6793        } else {
6794            None
6795        }
6796    }
6797
6798    #[allow(irrefutable_let_patterns)]
6799    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6800        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6801            Some((control_handle))
6802        } else {
6803            None
6804        }
6805    }
6806
6807    /// Name of the method defined in FIDL
6808    pub fn method_name(&self) -> &'static str {
6809        match *self {
6810            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6811            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6812                "create_audio_capturer_with_configuration"
6813            }
6814            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6815            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6816            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6817            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6818            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6819            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6820            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6821            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6822            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6823            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6824            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6825            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6826            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6827            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6828            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6829            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6830                "unknown one-way method"
6831            }
6832            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6833                "unknown two-way method"
6834            }
6835        }
6836    }
6837}
6838
6839#[derive(Debug, Clone)]
6840pub struct AudioCoreControlHandle {
6841    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6842}
6843
6844impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6845    fn shutdown(&self) {
6846        self.inner.shutdown()
6847    }
6848
6849    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6850        self.inner.shutdown_with_epitaph(status)
6851    }
6852
6853    fn is_closed(&self) -> bool {
6854        self.inner.channel().is_closed()
6855    }
6856    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6857        self.inner.channel().on_closed()
6858    }
6859
6860    #[cfg(target_os = "fuchsia")]
6861    fn signal_peer(
6862        &self,
6863        clear_mask: zx::Signals,
6864        set_mask: zx::Signals,
6865    ) -> Result<(), zx_status::Status> {
6866        use fidl::Peered;
6867        self.inner.channel().signal_peer(clear_mask, set_mask)
6868    }
6869}
6870
6871impl AudioCoreControlHandle {}
6872
6873#[must_use = "FIDL methods require a response to be sent"]
6874#[derive(Debug)]
6875pub struct AudioCoreGetVolumeFromDbResponder {
6876    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6877    tx_id: u32,
6878}
6879
6880/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6881/// if the responder is dropped without sending a response, so that the client
6882/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6883impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6884    fn drop(&mut self) {
6885        self.control_handle.shutdown();
6886        // Safety: drops once, never accessed again
6887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6888    }
6889}
6890
6891impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6892    type ControlHandle = AudioCoreControlHandle;
6893
6894    fn control_handle(&self) -> &AudioCoreControlHandle {
6895        &self.control_handle
6896    }
6897
6898    fn drop_without_shutdown(mut self) {
6899        // Safety: drops once, never accessed again due to mem::forget
6900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6901        // Prevent Drop from running (which would shut down the channel)
6902        std::mem::forget(self);
6903    }
6904}
6905
6906impl AudioCoreGetVolumeFromDbResponder {
6907    /// Sends a response to the FIDL transaction.
6908    ///
6909    /// Sets the channel to shutdown if an error occurs.
6910    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6911        let _result = self.send_raw(volume);
6912        if _result.is_err() {
6913            self.control_handle.shutdown();
6914        }
6915        self.drop_without_shutdown();
6916        _result
6917    }
6918
6919    /// Similar to "send" but does not shutdown the channel if an error occurs.
6920    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6921        let _result = self.send_raw(volume);
6922        self.drop_without_shutdown();
6923        _result
6924    }
6925
6926    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6927        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6928            (volume,),
6929            self.tx_id,
6930            0x50e3ca45509770bf,
6931            fidl::encoding::DynamicFlags::empty(),
6932        )
6933    }
6934}
6935
6936#[must_use = "FIDL methods require a response to be sent"]
6937#[derive(Debug)]
6938pub struct AudioCoreGetVolumeFromDb2Responder {
6939    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6940    tx_id: u32,
6941}
6942
6943/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6944/// if the responder is dropped without sending a response, so that the client
6945/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6946impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6947    fn drop(&mut self) {
6948        self.control_handle.shutdown();
6949        // Safety: drops once, never accessed again
6950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6951    }
6952}
6953
6954impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6955    type ControlHandle = AudioCoreControlHandle;
6956
6957    fn control_handle(&self) -> &AudioCoreControlHandle {
6958        &self.control_handle
6959    }
6960
6961    fn drop_without_shutdown(mut self) {
6962        // Safety: drops once, never accessed again due to mem::forget
6963        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6964        // Prevent Drop from running (which would shut down the channel)
6965        std::mem::forget(self);
6966    }
6967}
6968
6969impl AudioCoreGetVolumeFromDb2Responder {
6970    /// Sends a response to the FIDL transaction.
6971    ///
6972    /// Sets the channel to shutdown if an error occurs.
6973    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6974        let _result = self.send_raw(volume);
6975        if _result.is_err() {
6976            self.control_handle.shutdown();
6977        }
6978        self.drop_without_shutdown();
6979        _result
6980    }
6981
6982    /// Similar to "send" but does not shutdown the channel if an error occurs.
6983    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6984        let _result = self.send_raw(volume);
6985        self.drop_without_shutdown();
6986        _result
6987    }
6988
6989    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6990        self.control_handle
6991            .inner
6992            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
6993                fidl::encoding::Flexible::new((volume,)),
6994                self.tx_id,
6995                0x165c811091ef99da,
6996                fidl::encoding::DynamicFlags::FLEXIBLE,
6997            )
6998    }
6999}
7000
7001#[must_use = "FIDL methods require a response to be sent"]
7002#[derive(Debug)]
7003pub struct AudioCoreGetDbFromVolumeResponder {
7004    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
7005    tx_id: u32,
7006}
7007
7008/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
7009/// if the responder is dropped without sending a response, so that the client
7010/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7011impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
7012    fn drop(&mut self) {
7013        self.control_handle.shutdown();
7014        // Safety: drops once, never accessed again
7015        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7016    }
7017}
7018
7019impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
7020    type ControlHandle = AudioCoreControlHandle;
7021
7022    fn control_handle(&self) -> &AudioCoreControlHandle {
7023        &self.control_handle
7024    }
7025
7026    fn drop_without_shutdown(mut self) {
7027        // Safety: drops once, never accessed again due to mem::forget
7028        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7029        // Prevent Drop from running (which would shut down the channel)
7030        std::mem::forget(self);
7031    }
7032}
7033
7034impl AudioCoreGetDbFromVolumeResponder {
7035    /// Sends a response to the FIDL transaction.
7036    ///
7037    /// Sets the channel to shutdown if an error occurs.
7038    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7039        let _result = self.send_raw(gain_db);
7040        if _result.is_err() {
7041            self.control_handle.shutdown();
7042        }
7043        self.drop_without_shutdown();
7044        _result
7045    }
7046
7047    /// Similar to "send" but does not shutdown the channel if an error occurs.
7048    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7049        let _result = self.send_raw(gain_db);
7050        self.drop_without_shutdown();
7051        _result
7052    }
7053
7054    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
7055        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
7056            (gain_db,),
7057            self.tx_id,
7058            0x3e8eec27dd5a8bda,
7059            fidl::encoding::DynamicFlags::empty(),
7060        )
7061    }
7062}
7063
7064#[must_use = "FIDL methods require a response to be sent"]
7065#[derive(Debug)]
7066pub struct AudioCoreGetDbFromVolume2Responder {
7067    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
7068    tx_id: u32,
7069}
7070
7071/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
7072/// if the responder is dropped without sending a response, so that the client
7073/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7074impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
7075    fn drop(&mut self) {
7076        self.control_handle.shutdown();
7077        // Safety: drops once, never accessed again
7078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7079    }
7080}
7081
7082impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
7083    type ControlHandle = AudioCoreControlHandle;
7084
7085    fn control_handle(&self) -> &AudioCoreControlHandle {
7086        &self.control_handle
7087    }
7088
7089    fn drop_without_shutdown(mut self) {
7090        // Safety: drops once, never accessed again due to mem::forget
7091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7092        // Prevent Drop from running (which would shut down the channel)
7093        std::mem::forget(self);
7094    }
7095}
7096
7097impl AudioCoreGetDbFromVolume2Responder {
7098    /// Sends a response to the FIDL transaction.
7099    ///
7100    /// Sets the channel to shutdown if an error occurs.
7101    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7102        let _result = self.send_raw(gain_db);
7103        if _result.is_err() {
7104            self.control_handle.shutdown();
7105        }
7106        self.drop_without_shutdown();
7107        _result
7108    }
7109
7110    /// Similar to "send" but does not shutdown the channel if an error occurs.
7111    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7112        let _result = self.send_raw(gain_db);
7113        self.drop_without_shutdown();
7114        _result
7115    }
7116
7117    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
7118        self.control_handle
7119            .inner
7120            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
7121                fidl::encoding::Flexible::new((gain_db,)),
7122                self.tx_id,
7123                0x5f421a8ebf265bf3,
7124                fidl::encoding::DynamicFlags::FLEXIBLE,
7125            )
7126    }
7127}
7128
7129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7130pub struct AudioDeviceEnumeratorMarker;
7131
7132impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
7133    type Proxy = AudioDeviceEnumeratorProxy;
7134    type RequestStream = AudioDeviceEnumeratorRequestStream;
7135    #[cfg(target_os = "fuchsia")]
7136    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
7137
7138    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
7139}
7140impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
7141
7142pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
7143    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
7144        + Send;
7145    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
7146    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
7147        + Send;
7148    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
7149    fn r#set_device_gain(
7150        &self,
7151        device_token: u64,
7152        gain_info: &AudioGainInfo,
7153        valid_flags: AudioGainValidFlags,
7154    ) -> Result<(), fidl::Error>;
7155    fn r#add_device_by_channel(
7156        &self,
7157        device_name: &str,
7158        is_input: bool,
7159        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7160    ) -> Result<(), fidl::Error>;
7161}
7162#[derive(Debug)]
7163#[cfg(target_os = "fuchsia")]
7164pub struct AudioDeviceEnumeratorSynchronousProxy {
7165    client: fidl::client::sync::Client,
7166}
7167
7168#[cfg(target_os = "fuchsia")]
7169impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
7170    type Proxy = AudioDeviceEnumeratorProxy;
7171    type Protocol = AudioDeviceEnumeratorMarker;
7172
7173    fn from_channel(inner: fidl::Channel) -> Self {
7174        Self::new(inner)
7175    }
7176
7177    fn into_channel(self) -> fidl::Channel {
7178        self.client.into_channel()
7179    }
7180
7181    fn as_channel(&self) -> &fidl::Channel {
7182        self.client.as_channel()
7183    }
7184}
7185
7186#[cfg(target_os = "fuchsia")]
7187impl AudioDeviceEnumeratorSynchronousProxy {
7188    pub fn new(channel: fidl::Channel) -> Self {
7189        Self { client: fidl::client::sync::Client::new(channel) }
7190    }
7191
7192    pub fn into_channel(self) -> fidl::Channel {
7193        self.client.into_channel()
7194    }
7195
7196    /// Waits until an event arrives and returns it. It is safe for other
7197    /// threads to make concurrent requests while waiting for an event.
7198    pub fn wait_for_event(
7199        &self,
7200        deadline: zx::MonotonicInstant,
7201    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7202        AudioDeviceEnumeratorEvent::decode(
7203            self.client.wait_for_event::<AudioDeviceEnumeratorMarker>(deadline)?,
7204        )
7205    }
7206
7207    /// Obtain the list of currently active audio devices.
7208    pub fn r#get_devices(
7209        &self,
7210        ___deadline: zx::MonotonicInstant,
7211    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7212        let _response = self.client.send_query::<
7213            fidl::encoding::EmptyPayload,
7214            AudioDeviceEnumeratorGetDevicesResponse,
7215            AudioDeviceEnumeratorMarker,
7216        >(
7217            (),
7218            0x4ce1aa218aeb12a6,
7219            fidl::encoding::DynamicFlags::empty(),
7220            ___deadline,
7221        )?;
7222        Ok(_response.devices)
7223    }
7224
7225    /// Gain/Mute/AGC control
7226    ///
7227    /// Note that each of these operations requires a device_token in order to
7228    /// target the proper input/output.
7229    ///
7230    /// The Get command returns the device_token of the device whose gain is
7231    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7232    /// device_token was invalid or the device had been removed from the system
7233    /// before the Get command could be processed.
7234    ///
7235    /// Set commands which are given an invalid device token are ignored and
7236    /// have no effect on the system. In addition, users do not need to control
7237    /// all of the gain settings for an audio device with each call. Only the
7238    /// settings with a corresponding flag set in the set_flags parameter will
7239    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7240    /// a SetDeviceGain call to care only about the mute setting in the
7241    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7242    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7243    /// status to be changed simultaneously.
7244    pub fn r#get_device_gain(
7245        &self,
7246        mut device_token: u64,
7247        ___deadline: zx::MonotonicInstant,
7248    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7249        let _response = self.client.send_query::<
7250            AudioDeviceEnumeratorGetDeviceGainRequest,
7251            AudioDeviceEnumeratorGetDeviceGainResponse,
7252            AudioDeviceEnumeratorMarker,
7253        >(
7254            (device_token,),
7255            0x25dd4723403c414b,
7256            fidl::encoding::DynamicFlags::empty(),
7257            ___deadline,
7258        )?;
7259        Ok((_response.device_token, _response.gain_info))
7260    }
7261
7262    pub fn r#set_device_gain(
7263        &self,
7264        mut device_token: u64,
7265        mut gain_info: &AudioGainInfo,
7266        mut valid_flags: AudioGainValidFlags,
7267    ) -> Result<(), fidl::Error> {
7268        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7269            (device_token, gain_info, valid_flags),
7270            0x5bdabc8ebe83591,
7271            fidl::encoding::DynamicFlags::empty(),
7272        )
7273    }
7274
7275    /// # Deprecation
7276    ///
7277    /// StreamConfig is not supported anymore, instead use an
7278    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7279    /// , see
7280    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7281    pub fn r#add_device_by_channel(
7282        &self,
7283        mut device_name: &str,
7284        mut is_input: bool,
7285        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7286    ) -> Result<(), fidl::Error> {
7287        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7288            (device_name, is_input, channel),
7289            0x72cdbada4d70ed67,
7290            fidl::encoding::DynamicFlags::empty(),
7291        )
7292    }
7293}
7294
7295#[cfg(target_os = "fuchsia")]
7296impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::NullableHandle {
7297    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
7298        value.into_channel().into()
7299    }
7300}
7301
7302#[cfg(target_os = "fuchsia")]
7303impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
7304    fn from(value: fidl::Channel) -> Self {
7305        Self::new(value)
7306    }
7307}
7308
7309#[cfg(target_os = "fuchsia")]
7310impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7311    type Protocol = AudioDeviceEnumeratorMarker;
7312
7313    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7314        Self::new(value.into_channel())
7315    }
7316}
7317
7318#[derive(Debug, Clone)]
7319pub struct AudioDeviceEnumeratorProxy {
7320    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7321}
7322
7323impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7324    type Protocol = AudioDeviceEnumeratorMarker;
7325
7326    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7327        Self::new(inner)
7328    }
7329
7330    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7331        self.client.into_channel().map_err(|client| Self { client })
7332    }
7333
7334    fn as_channel(&self) -> &::fidl::AsyncChannel {
7335        self.client.as_channel()
7336    }
7337}
7338
7339impl AudioDeviceEnumeratorProxy {
7340    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7341    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7342        let protocol_name =
7343            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7344        Self { client: fidl::client::Client::new(channel, protocol_name) }
7345    }
7346
7347    /// Get a Stream of events from the remote end of the protocol.
7348    ///
7349    /// # Panics
7350    ///
7351    /// Panics if the event stream was already taken.
7352    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7353        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7354    }
7355
7356    /// Obtain the list of currently active audio devices.
7357    pub fn r#get_devices(
7358        &self,
7359    ) -> fidl::client::QueryResponseFut<
7360        Vec<AudioDeviceInfo>,
7361        fidl::encoding::DefaultFuchsiaResourceDialect,
7362    > {
7363        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7364    }
7365
7366    /// Gain/Mute/AGC control
7367    ///
7368    /// Note that each of these operations requires a device_token in order to
7369    /// target the proper input/output.
7370    ///
7371    /// The Get command returns the device_token of the device whose gain is
7372    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7373    /// device_token was invalid or the device had been removed from the system
7374    /// before the Get command could be processed.
7375    ///
7376    /// Set commands which are given an invalid device token are ignored and
7377    /// have no effect on the system. In addition, users do not need to control
7378    /// all of the gain settings for an audio device with each call. Only the
7379    /// settings with a corresponding flag set in the set_flags parameter will
7380    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7381    /// a SetDeviceGain call to care only about the mute setting in the
7382    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7383    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7384    /// status to be changed simultaneously.
7385    pub fn r#get_device_gain(
7386        &self,
7387        mut device_token: u64,
7388    ) -> fidl::client::QueryResponseFut<
7389        (u64, AudioGainInfo),
7390        fidl::encoding::DefaultFuchsiaResourceDialect,
7391    > {
7392        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7393    }
7394
7395    pub fn r#set_device_gain(
7396        &self,
7397        mut device_token: u64,
7398        mut gain_info: &AudioGainInfo,
7399        mut valid_flags: AudioGainValidFlags,
7400    ) -> Result<(), fidl::Error> {
7401        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7402            self,
7403            device_token,
7404            gain_info,
7405            valid_flags,
7406        )
7407    }
7408
7409    /// # Deprecation
7410    ///
7411    /// StreamConfig is not supported anymore, instead use an
7412    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7413    /// , see
7414    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7415    pub fn r#add_device_by_channel(
7416        &self,
7417        mut device_name: &str,
7418        mut is_input: bool,
7419        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7420    ) -> Result<(), fidl::Error> {
7421        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7422            self,
7423            device_name,
7424            is_input,
7425            channel,
7426        )
7427    }
7428}
7429
7430impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7431    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7432        Vec<AudioDeviceInfo>,
7433        fidl::encoding::DefaultFuchsiaResourceDialect,
7434    >;
7435    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7436        fn _decode(
7437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7438        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7439            let _response = fidl::client::decode_transaction_body::<
7440                AudioDeviceEnumeratorGetDevicesResponse,
7441                fidl::encoding::DefaultFuchsiaResourceDialect,
7442                0x4ce1aa218aeb12a6,
7443            >(_buf?)?;
7444            Ok(_response.devices)
7445        }
7446        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7447            (),
7448            0x4ce1aa218aeb12a6,
7449            fidl::encoding::DynamicFlags::empty(),
7450            _decode,
7451        )
7452    }
7453
7454    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7455        (u64, AudioGainInfo),
7456        fidl::encoding::DefaultFuchsiaResourceDialect,
7457    >;
7458    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7459        fn _decode(
7460            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7461        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7462            let _response = fidl::client::decode_transaction_body::<
7463                AudioDeviceEnumeratorGetDeviceGainResponse,
7464                fidl::encoding::DefaultFuchsiaResourceDialect,
7465                0x25dd4723403c414b,
7466            >(_buf?)?;
7467            Ok((_response.device_token, _response.gain_info))
7468        }
7469        self.client.send_query_and_decode::<
7470            AudioDeviceEnumeratorGetDeviceGainRequest,
7471            (u64, AudioGainInfo),
7472        >(
7473            (device_token,),
7474            0x25dd4723403c414b,
7475            fidl::encoding::DynamicFlags::empty(),
7476            _decode,
7477        )
7478    }
7479
7480    fn r#set_device_gain(
7481        &self,
7482        mut device_token: u64,
7483        mut gain_info: &AudioGainInfo,
7484        mut valid_flags: AudioGainValidFlags,
7485    ) -> Result<(), fidl::Error> {
7486        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7487            (device_token, gain_info, valid_flags),
7488            0x5bdabc8ebe83591,
7489            fidl::encoding::DynamicFlags::empty(),
7490        )
7491    }
7492
7493    fn r#add_device_by_channel(
7494        &self,
7495        mut device_name: &str,
7496        mut is_input: bool,
7497        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7498    ) -> Result<(), fidl::Error> {
7499        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7500            (device_name, is_input, channel),
7501            0x72cdbada4d70ed67,
7502            fidl::encoding::DynamicFlags::empty(),
7503        )
7504    }
7505}
7506
7507pub struct AudioDeviceEnumeratorEventStream {
7508    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7509}
7510
7511impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7512
7513impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7514    fn is_terminated(&self) -> bool {
7515        self.event_receiver.is_terminated()
7516    }
7517}
7518
7519impl futures::Stream for AudioDeviceEnumeratorEventStream {
7520    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7521
7522    fn poll_next(
7523        mut self: std::pin::Pin<&mut Self>,
7524        cx: &mut std::task::Context<'_>,
7525    ) -> std::task::Poll<Option<Self::Item>> {
7526        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7527            &mut self.event_receiver,
7528            cx
7529        )?) {
7530            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7531            None => std::task::Poll::Ready(None),
7532        }
7533    }
7534}
7535
7536#[derive(Debug)]
7537pub enum AudioDeviceEnumeratorEvent {
7538    OnDeviceAdded { device: AudioDeviceInfo },
7539    OnDeviceRemoved { device_token: u64 },
7540    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7541    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7542}
7543
7544impl AudioDeviceEnumeratorEvent {
7545    #[allow(irrefutable_let_patterns)]
7546    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7547        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7548            Some((device))
7549        } else {
7550            None
7551        }
7552    }
7553    #[allow(irrefutable_let_patterns)]
7554    pub fn into_on_device_removed(self) -> Option<u64> {
7555        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7556            Some((device_token))
7557        } else {
7558            None
7559        }
7560    }
7561    #[allow(irrefutable_let_patterns)]
7562    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7563        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7564            Some((device_token, gain_info))
7565        } else {
7566            None
7567        }
7568    }
7569    #[allow(irrefutable_let_patterns)]
7570    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7571        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7572            old_default_token,
7573            new_default_token,
7574        } = self
7575        {
7576            Some((old_default_token, new_default_token))
7577        } else {
7578            None
7579        }
7580    }
7581
7582    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7583    fn decode(
7584        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7585    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7586        let (bytes, _handles) = buf.split_mut();
7587        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7588        debug_assert_eq!(tx_header.tx_id, 0);
7589        match tx_header.ordinal {
7590            0xe0fbe40057c4b44 => {
7591                let mut out = fidl::new_empty!(
7592                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7593                    fidl::encoding::DefaultFuchsiaResourceDialect
7594                );
7595                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7596                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7597            }
7598            0x6f3b7574463d9ff8 => {
7599                let mut out = fidl::new_empty!(
7600                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7601                    fidl::encoding::DefaultFuchsiaResourceDialect
7602                );
7603                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7604                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7605            }
7606            0x14aefcbbb076b0e9 => {
7607                let mut out = fidl::new_empty!(
7608                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7609                    fidl::encoding::DefaultFuchsiaResourceDialect
7610                );
7611                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7612                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7613                    device_token: out.device_token,
7614                    gain_info: out.gain_info,
7615                }))
7616            }
7617            0x16357b42d4c16e11 => {
7618                let mut out = fidl::new_empty!(
7619                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7620                    fidl::encoding::DefaultFuchsiaResourceDialect
7621                );
7622                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7623                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7624                    old_default_token: out.old_default_token,
7625                    new_default_token: out.new_default_token,
7626                }))
7627            }
7628            _ => Err(fidl::Error::UnknownOrdinal {
7629                ordinal: tx_header.ordinal,
7630                protocol_name:
7631                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7632            }),
7633        }
7634    }
7635}
7636
7637/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7638pub struct AudioDeviceEnumeratorRequestStream {
7639    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7640    is_terminated: bool,
7641}
7642
7643impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7644
7645impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7646    fn is_terminated(&self) -> bool {
7647        self.is_terminated
7648    }
7649}
7650
7651impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7652    type Protocol = AudioDeviceEnumeratorMarker;
7653    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7654
7655    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7656        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7657    }
7658
7659    fn control_handle(&self) -> Self::ControlHandle {
7660        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7661    }
7662
7663    fn into_inner(
7664        self,
7665    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7666    {
7667        (self.inner, self.is_terminated)
7668    }
7669
7670    fn from_inner(
7671        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7672        is_terminated: bool,
7673    ) -> Self {
7674        Self { inner, is_terminated }
7675    }
7676}
7677
7678impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7679    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7680
7681    fn poll_next(
7682        mut self: std::pin::Pin<&mut Self>,
7683        cx: &mut std::task::Context<'_>,
7684    ) -> std::task::Poll<Option<Self::Item>> {
7685        let this = &mut *self;
7686        if this.inner.check_shutdown(cx) {
7687            this.is_terminated = true;
7688            return std::task::Poll::Ready(None);
7689        }
7690        if this.is_terminated {
7691            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7692        }
7693        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7694            |bytes, handles| {
7695                match this.inner.channel().read_etc(cx, bytes, handles) {
7696                    std::task::Poll::Ready(Ok(())) => {}
7697                    std::task::Poll::Pending => return std::task::Poll::Pending,
7698                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7699                        this.is_terminated = true;
7700                        return std::task::Poll::Ready(None);
7701                    }
7702                    std::task::Poll::Ready(Err(e)) => {
7703                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7704                            e.into(),
7705                        ))));
7706                    }
7707                }
7708
7709                // A message has been received from the channel
7710                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7711
7712                std::task::Poll::Ready(Some(match header.ordinal {
7713                0x4ce1aa218aeb12a6 => {
7714                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7715                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7716                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7717                    let control_handle = AudioDeviceEnumeratorControlHandle {
7718                        inner: this.inner.clone(),
7719                    };
7720                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7721                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7722                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7723                            tx_id: header.tx_id,
7724                        },
7725                    })
7726                }
7727                0x25dd4723403c414b => {
7728                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7729                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7730                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7731                    let control_handle = AudioDeviceEnumeratorControlHandle {
7732                        inner: this.inner.clone(),
7733                    };
7734                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7735
7736                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7737                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7738                            tx_id: header.tx_id,
7739                        },
7740                    })
7741                }
7742                0x5bdabc8ebe83591 => {
7743                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7744                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7745                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7746                    let control_handle = AudioDeviceEnumeratorControlHandle {
7747                        inner: this.inner.clone(),
7748                    };
7749                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7750gain_info: req.gain_info,
7751valid_flags: req.valid_flags,
7752
7753                        control_handle,
7754                    })
7755                }
7756                0x72cdbada4d70ed67 => {
7757                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7758                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7759                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7760                    let control_handle = AudioDeviceEnumeratorControlHandle {
7761                        inner: this.inner.clone(),
7762                    };
7763                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7764is_input: req.is_input,
7765channel: req.channel,
7766
7767                        control_handle,
7768                    })
7769                }
7770                _ => Err(fidl::Error::UnknownOrdinal {
7771                    ordinal: header.ordinal,
7772                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7773                }),
7774            }))
7775            },
7776        )
7777    }
7778}
7779
7780#[derive(Debug)]
7781pub enum AudioDeviceEnumeratorRequest {
7782    /// Obtain the list of currently active audio devices.
7783    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7784    /// Gain/Mute/AGC control
7785    ///
7786    /// Note that each of these operations requires a device_token in order to
7787    /// target the proper input/output.
7788    ///
7789    /// The Get command returns the device_token of the device whose gain is
7790    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7791    /// device_token was invalid or the device had been removed from the system
7792    /// before the Get command could be processed.
7793    ///
7794    /// Set commands which are given an invalid device token are ignored and
7795    /// have no effect on the system. In addition, users do not need to control
7796    /// all of the gain settings for an audio device with each call. Only the
7797    /// settings with a corresponding flag set in the set_flags parameter will
7798    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7799    /// a SetDeviceGain call to care only about the mute setting in the
7800    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7801    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7802    /// status to be changed simultaneously.
7803    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7804    SetDeviceGain {
7805        device_token: u64,
7806        gain_info: AudioGainInfo,
7807        valid_flags: AudioGainValidFlags,
7808        control_handle: AudioDeviceEnumeratorControlHandle,
7809    },
7810    /// # Deprecation
7811    ///
7812    /// StreamConfig is not supported anymore, instead use an
7813    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7814    /// , see
7815    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7816    AddDeviceByChannel {
7817        device_name: String,
7818        is_input: bool,
7819        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7820        control_handle: AudioDeviceEnumeratorControlHandle,
7821    },
7822}
7823
7824impl AudioDeviceEnumeratorRequest {
7825    #[allow(irrefutable_let_patterns)]
7826    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7827        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7828            Some((responder))
7829        } else {
7830            None
7831        }
7832    }
7833
7834    #[allow(irrefutable_let_patterns)]
7835    pub fn into_get_device_gain(
7836        self,
7837    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7838        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7839            Some((device_token, responder))
7840        } else {
7841            None
7842        }
7843    }
7844
7845    #[allow(irrefutable_let_patterns)]
7846    pub fn into_set_device_gain(
7847        self,
7848    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7849        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7850            device_token,
7851            gain_info,
7852            valid_flags,
7853            control_handle,
7854        } = self
7855        {
7856            Some((device_token, gain_info, valid_flags, control_handle))
7857        } else {
7858            None
7859        }
7860    }
7861
7862    #[allow(irrefutable_let_patterns)]
7863    pub fn into_add_device_by_channel(
7864        self,
7865    ) -> Option<(
7866        String,
7867        bool,
7868        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7869        AudioDeviceEnumeratorControlHandle,
7870    )> {
7871        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7872            device_name,
7873            is_input,
7874            channel,
7875            control_handle,
7876        } = self
7877        {
7878            Some((device_name, is_input, channel, control_handle))
7879        } else {
7880            None
7881        }
7882    }
7883
7884    /// Name of the method defined in FIDL
7885    pub fn method_name(&self) -> &'static str {
7886        match *self {
7887            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7888            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7889            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7890            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7891        }
7892    }
7893}
7894
7895#[derive(Debug, Clone)]
7896pub struct AudioDeviceEnumeratorControlHandle {
7897    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7898}
7899
7900impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7901    fn shutdown(&self) {
7902        self.inner.shutdown()
7903    }
7904
7905    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7906        self.inner.shutdown_with_epitaph(status)
7907    }
7908
7909    fn is_closed(&self) -> bool {
7910        self.inner.channel().is_closed()
7911    }
7912    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7913        self.inner.channel().on_closed()
7914    }
7915
7916    #[cfg(target_os = "fuchsia")]
7917    fn signal_peer(
7918        &self,
7919        clear_mask: zx::Signals,
7920        set_mask: zx::Signals,
7921    ) -> Result<(), zx_status::Status> {
7922        use fidl::Peered;
7923        self.inner.channel().signal_peer(clear_mask, set_mask)
7924    }
7925}
7926
7927impl AudioDeviceEnumeratorControlHandle {
7928    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7929        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7930            (device,),
7931            0,
7932            0xe0fbe40057c4b44,
7933            fidl::encoding::DynamicFlags::empty(),
7934        )
7935    }
7936
7937    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7938        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7939            (device_token,),
7940            0,
7941            0x6f3b7574463d9ff8,
7942            fidl::encoding::DynamicFlags::empty(),
7943        )
7944    }
7945
7946    pub fn send_on_device_gain_changed(
7947        &self,
7948        mut device_token: u64,
7949        mut gain_info: &AudioGainInfo,
7950    ) -> Result<(), fidl::Error> {
7951        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7952            (device_token, gain_info),
7953            0,
7954            0x14aefcbbb076b0e9,
7955            fidl::encoding::DynamicFlags::empty(),
7956        )
7957    }
7958
7959    pub fn send_on_default_device_changed(
7960        &self,
7961        mut old_default_token: u64,
7962        mut new_default_token: u64,
7963    ) -> Result<(), fidl::Error> {
7964        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
7965            (old_default_token, new_default_token),
7966            0,
7967            0x16357b42d4c16e11,
7968            fidl::encoding::DynamicFlags::empty(),
7969        )
7970    }
7971}
7972
7973#[must_use = "FIDL methods require a response to be sent"]
7974#[derive(Debug)]
7975pub struct AudioDeviceEnumeratorGetDevicesResponder {
7976    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7977    tx_id: u32,
7978}
7979
7980/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7981/// if the responder is dropped without sending a response, so that the client
7982/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7983impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
7984    fn drop(&mut self) {
7985        self.control_handle.shutdown();
7986        // Safety: drops once, never accessed again
7987        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7988    }
7989}
7990
7991impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
7992    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7993
7994    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7995        &self.control_handle
7996    }
7997
7998    fn drop_without_shutdown(mut self) {
7999        // Safety: drops once, never accessed again due to mem::forget
8000        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8001        // Prevent Drop from running (which would shut down the channel)
8002        std::mem::forget(self);
8003    }
8004}
8005
8006impl AudioDeviceEnumeratorGetDevicesResponder {
8007    /// Sends a response to the FIDL transaction.
8008    ///
8009    /// Sets the channel to shutdown if an error occurs.
8010    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
8011        let _result = self.send_raw(devices);
8012        if _result.is_err() {
8013            self.control_handle.shutdown();
8014        }
8015        self.drop_without_shutdown();
8016        _result
8017    }
8018
8019    /// Similar to "send" but does not shutdown the channel if an error occurs.
8020    pub fn send_no_shutdown_on_err(
8021        self,
8022        mut devices: &[AudioDeviceInfo],
8023    ) -> Result<(), fidl::Error> {
8024        let _result = self.send_raw(devices);
8025        self.drop_without_shutdown();
8026        _result
8027    }
8028
8029    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
8030        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
8031            (devices,),
8032            self.tx_id,
8033            0x4ce1aa218aeb12a6,
8034            fidl::encoding::DynamicFlags::empty(),
8035        )
8036    }
8037}
8038
8039#[must_use = "FIDL methods require a response to be sent"]
8040#[derive(Debug)]
8041pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
8042    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
8043    tx_id: u32,
8044}
8045
8046/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
8047/// if the responder is dropped without sending a response, so that the client
8048/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8049impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
8050    fn drop(&mut self) {
8051        self.control_handle.shutdown();
8052        // Safety: drops once, never accessed again
8053        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8054    }
8055}
8056
8057impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
8058    type ControlHandle = AudioDeviceEnumeratorControlHandle;
8059
8060    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
8061        &self.control_handle
8062    }
8063
8064    fn drop_without_shutdown(mut self) {
8065        // Safety: drops once, never accessed again due to mem::forget
8066        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8067        // Prevent Drop from running (which would shut down the channel)
8068        std::mem::forget(self);
8069    }
8070}
8071
8072impl AudioDeviceEnumeratorGetDeviceGainResponder {
8073    /// Sends a response to the FIDL transaction.
8074    ///
8075    /// Sets the channel to shutdown if an error occurs.
8076    pub fn send(
8077        self,
8078        mut device_token: u64,
8079        mut gain_info: &AudioGainInfo,
8080    ) -> Result<(), fidl::Error> {
8081        let _result = self.send_raw(device_token, gain_info);
8082        if _result.is_err() {
8083            self.control_handle.shutdown();
8084        }
8085        self.drop_without_shutdown();
8086        _result
8087    }
8088
8089    /// Similar to "send" but does not shutdown the channel if an error occurs.
8090    pub fn send_no_shutdown_on_err(
8091        self,
8092        mut device_token: u64,
8093        mut gain_info: &AudioGainInfo,
8094    ) -> Result<(), fidl::Error> {
8095        let _result = self.send_raw(device_token, gain_info);
8096        self.drop_without_shutdown();
8097        _result
8098    }
8099
8100    fn send_raw(
8101        &self,
8102        mut device_token: u64,
8103        mut gain_info: &AudioGainInfo,
8104    ) -> Result<(), fidl::Error> {
8105        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
8106            (device_token, gain_info),
8107            self.tx_id,
8108            0x25dd4723403c414b,
8109            fidl::encoding::DynamicFlags::empty(),
8110        )
8111    }
8112}
8113
8114#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8115pub struct AudioRendererMarker;
8116
8117impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
8118    type Proxy = AudioRendererProxy;
8119    type RequestStream = AudioRendererRequestStream;
8120    #[cfg(target_os = "fuchsia")]
8121    type SynchronousProxy = AudioRendererSynchronousProxy;
8122
8123    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
8124}
8125impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
8126
8127pub trait AudioRendererProxyInterface: Send + Sync {
8128    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
8129    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
8130    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8131    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
8132    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
8133    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
8134    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8135    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
8136    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
8137    fn r#bind_gain_control(
8138        &self,
8139        gain_control_request: fidl::endpoints::ServerEnd<
8140            fidl_fuchsia_media_audio::GainControlMarker,
8141        >,
8142    ) -> Result<(), fidl::Error>;
8143    fn r#set_pts_units(
8144        &self,
8145        tick_per_second_numerator: u32,
8146        tick_per_second_denominator: u32,
8147    ) -> Result<(), fidl::Error>;
8148    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
8149    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
8150        + Send;
8151    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
8152    fn r#set_reference_clock(
8153        &self,
8154        reference_clock: Option<fidl::Clock>,
8155    ) -> Result<(), fidl::Error>;
8156    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
8157    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
8158    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
8159    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
8160    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
8161    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
8162    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
8163    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
8164    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
8165    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
8166    fn r#pause(&self) -> Self::PauseResponseFut;
8167    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
8168}
8169#[derive(Debug)]
8170#[cfg(target_os = "fuchsia")]
8171pub struct AudioRendererSynchronousProxy {
8172    client: fidl::client::sync::Client,
8173}
8174
8175#[cfg(target_os = "fuchsia")]
8176impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
8177    type Proxy = AudioRendererProxy;
8178    type Protocol = AudioRendererMarker;
8179
8180    fn from_channel(inner: fidl::Channel) -> Self {
8181        Self::new(inner)
8182    }
8183
8184    fn into_channel(self) -> fidl::Channel {
8185        self.client.into_channel()
8186    }
8187
8188    fn as_channel(&self) -> &fidl::Channel {
8189        self.client.as_channel()
8190    }
8191}
8192
8193#[cfg(target_os = "fuchsia")]
8194impl AudioRendererSynchronousProxy {
8195    pub fn new(channel: fidl::Channel) -> Self {
8196        Self { client: fidl::client::sync::Client::new(channel) }
8197    }
8198
8199    pub fn into_channel(self) -> fidl::Channel {
8200        self.client.into_channel()
8201    }
8202
8203    /// Waits until an event arrives and returns it. It is safe for other
8204    /// threads to make concurrent requests while waiting for an event.
8205    pub fn wait_for_event(
8206        &self,
8207        deadline: zx::MonotonicInstant,
8208    ) -> Result<AudioRendererEvent, fidl::Error> {
8209        AudioRendererEvent::decode(self.client.wait_for_event::<AudioRendererMarker>(deadline)?)
8210    }
8211
8212    /// Adds a payload buffer to the current buffer set associated with the
8213    /// connection. A `StreamPacket` struct reference a payload buffer in the
8214    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8215    ///
8216    /// A buffer with ID `id` must not be in the current set when this method is
8217    /// invoked, otherwise the service will close the connection.
8218    pub fn r#add_payload_buffer(
8219        &self,
8220        mut id: u32,
8221        mut payload_buffer: fidl::Vmo,
8222    ) -> Result<(), fidl::Error> {
8223        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8224            (id, payload_buffer),
8225            0x3b3a37fc34fe5b56,
8226            fidl::encoding::DynamicFlags::empty(),
8227        )
8228    }
8229
8230    /// Removes a payload buffer from the current buffer set associated with the
8231    /// connection.
8232    ///
8233    /// A buffer with ID `id` must exist in the current set when this method is
8234    /// invoked, otherwise the service will will close the connection.
8235    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8236        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8237            (id,),
8238            0x5d1e4f74c3658262,
8239            fidl::encoding::DynamicFlags::empty(),
8240        )
8241    }
8242
8243    /// Sends a packet to the service. The response is sent when the service is
8244    /// done with the associated payload memory.
8245    ///
8246    /// `packet` must be valid for the current buffer set, otherwise the service
8247    /// will close the connection.
8248    pub fn r#send_packet(
8249        &self,
8250        mut packet: &StreamPacket,
8251        ___deadline: zx::MonotonicInstant,
8252    ) -> Result<(), fidl::Error> {
8253        let _response = self.client.send_query::<
8254            StreamSinkSendPacketRequest,
8255            fidl::encoding::EmptyPayload,
8256            AudioRendererMarker,
8257        >(
8258            (packet,),
8259            0x67cddd607442775f,
8260            fidl::encoding::DynamicFlags::empty(),
8261            ___deadline,
8262        )?;
8263        Ok(_response)
8264    }
8265
8266    /// Sends a packet to the service. This interface doesn't define how the
8267    /// client knows when the sink is done with the associated payload memory.
8268    /// The inheriting interface must define that.
8269    ///
8270    /// `packet` must be valid for the current buffer set, otherwise the service
8271    /// will close the connection.
8272    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8273        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8274            (packet,),
8275            0x8d9b8b413ceba9d,
8276            fidl::encoding::DynamicFlags::empty(),
8277        )
8278    }
8279
8280    /// Indicates the stream has ended. The precise semantics of this method are
8281    /// determined by the inheriting interface.
8282    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8283        self.client.send::<fidl::encoding::EmptyPayload>(
8284            (),
8285            0x6180fd6f7e793b71,
8286            fidl::encoding::DynamicFlags::empty(),
8287        )
8288    }
8289
8290    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8291    /// and not yet released. The response is sent after all packets have been
8292    /// released.
8293    pub fn r#discard_all_packets(
8294        &self,
8295        ___deadline: zx::MonotonicInstant,
8296    ) -> Result<(), fidl::Error> {
8297        let _response = self.client.send_query::<
8298            fidl::encoding::EmptyPayload,
8299            fidl::encoding::EmptyPayload,
8300            AudioRendererMarker,
8301        >(
8302            (),
8303            0x6f4dad7af2917665,
8304            fidl::encoding::DynamicFlags::empty(),
8305            ___deadline,
8306        )?;
8307        Ok(_response)
8308    }
8309
8310    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8311    /// and not yet released.
8312    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8313        self.client.send::<fidl::encoding::EmptyPayload>(
8314            (),
8315            0x50d36d0d23081bc4,
8316            fidl::encoding::DynamicFlags::empty(),
8317        )
8318    }
8319
8320    /// Binds to the gain control for this AudioRenderer.
8321    pub fn r#bind_gain_control(
8322        &self,
8323        mut gain_control_request: fidl::endpoints::ServerEnd<
8324            fidl_fuchsia_media_audio::GainControlMarker,
8325        >,
8326    ) -> Result<(), fidl::Error> {
8327        self.client.send::<AudioRendererBindGainControlRequest>(
8328            (gain_control_request,),
8329            0x293f5c7f8fba2bdc,
8330            fidl::encoding::DynamicFlags::empty(),
8331        )
8332    }
8333
8334    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8335    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8336    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8337    pub fn r#set_pts_units(
8338        &self,
8339        mut tick_per_second_numerator: u32,
8340        mut tick_per_second_denominator: u32,
8341    ) -> Result<(), fidl::Error> {
8342        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8343            (tick_per_second_numerator, tick_per_second_denominator),
8344            0xf68cd108785a27c,
8345            fidl::encoding::DynamicFlags::empty(),
8346        )
8347    }
8348
8349    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8350    /// and expected PTS (determined using interpolation). Beyond this threshold,
8351    /// a stream is no longer considered 'continuous' by the renderer.
8352    ///
8353    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8354    /// Most users should not need to change this value from its default.
8355    ///
8356    /// Example:
8357    /// A user is playing back 48KHz audio from a container, which also contains
8358    /// video and needs to be synchronized with the audio. The timestamps are
8359    /// provided explicitly per packet by the container, and expressed in mSec
8360    /// units. This means that a single tick of the media timeline (1 mSec)
8361    /// represents exactly 48 frames of audio. The application in this scenario
8362    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8363    /// frames of audio, and each with an explicit timestamp set to the best
8364    /// possible representation of the presentation time (given this media
8365    /// clock's resolution). So, starting from zero, the timestamps would be..
8366    ///
8367    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8368    ///
8369    /// In this example, attempting to use the presentation time to compute the
8370    /// starting frame number of the audio in the packet would be wrong the
8371    /// majority of the time. The first timestamp is correct (by definition), but
8372    /// it will be 24 packets before the timestamps and frame numbers come back
8373    /// into alignment (the 24th packet would start with the 11280th audio frame
8374    /// and have a PTS of exactly 235).
8375    ///
8376    /// One way to fix this situation is to set the PTS continuity threshold
8377    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8378    /// the number of frames contained within a single tick of the media clock,
8379    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8380    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8381    /// explicitly provided PTS would be considered to be a continuation of the
8382    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8383    /// would work well.
8384    ///
8385    /// Other possible uses:
8386    /// Users who are scheduling audio explicitly, relative to a clock which has
8387    /// not been configured as the reference clock, can use this value to control
8388    /// the maximum acceptable synchronization error before a discontinuity is
8389    /// introduced. E.g., if a user is scheduling audio based on a recovered
8390    /// common media clock, and has not published that clock as the reference
8391    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8392    /// can accumulate before the AudioRenderer deliberately inserts a
8393    /// presentation discontinuity to account for the error.
8394    ///
8395    /// Users whose need to deal with a container where their timestamps may be
8396    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8397    /// something larger. This should be the maximum level of inaccuracy present
8398    /// in the container timestamps, if known. Failing that, it could be set to
8399    /// the maximum tolerable level of drift error before absolute timestamps are
8400    /// explicitly obeyed. Finally, a user could set this number to a very large
8401    /// value (86400.0 seconds, for example) to effectively cause *all*
8402    /// timestamps to be ignored after the first, thus treating all audio as
8403    /// continuous with previously delivered packets. Conversely, users who wish
8404    /// to *always* explicitly schedule their audio packets exactly may specify
8405    /// a CT of 0.
8406    ///
8407    /// Note: explicitly specifying high-frequency PTS units reduces the default
8408    /// continuity threshold accordingly. Internally, this threshold is stored as an
8409    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8410    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8411    /// For this reason, specifying PTS units with a frequency greater than 8192x
8412    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8413    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8414    pub fn r#set_pts_continuity_threshold(
8415        &self,
8416        mut threshold_seconds: f32,
8417    ) -> Result<(), fidl::Error> {
8418        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8419            (threshold_seconds,),
8420            0x2849ba571d1971ba,
8421            fidl::encoding::DynamicFlags::empty(),
8422        )
8423    }
8424
8425    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8426    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8427    pub fn r#get_reference_clock(
8428        &self,
8429        ___deadline: zx::MonotonicInstant,
8430    ) -> Result<fidl::Clock, fidl::Error> {
8431        let _response = self.client.send_query::<
8432            fidl::encoding::EmptyPayload,
8433            AudioRendererGetReferenceClockResponse,
8434            AudioRendererMarker,
8435        >(
8436            (),
8437            0x2f7a7f011a172f7e,
8438            fidl::encoding::DynamicFlags::empty(),
8439            ___deadline,
8440        )?;
8441        Ok(_response.reference_clock)
8442    }
8443
8444    /// Sets the reference clock that controls this renderer's playback rate. If the input
8445    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8446    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8447    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8448    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8449    ///
8450    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8451    /// cannot be called a second time (even if the renderer format has not yet been set).
8452    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8453    /// diverge at some later time, they should create a clone of the monotonic clock, set
8454    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8455    pub fn r#set_reference_clock(
8456        &self,
8457        mut reference_clock: Option<fidl::Clock>,
8458    ) -> Result<(), fidl::Error> {
8459        self.client.send::<AudioRendererSetReferenceClockRequest>(
8460            (reference_clock,),
8461            0x39acd05d832b5fed,
8462            fidl::encoding::DynamicFlags::empty(),
8463        )
8464    }
8465
8466    /// Sets the usage of the render stream. This method may not be called after
8467    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8468    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8469        self.client.send::<AudioRendererSetUsageRequest>(
8470            (usage,),
8471            0x3994bd23b55a733e,
8472            fidl::encoding::DynamicFlags::empty(),
8473        )
8474    }
8475
8476    /// Sets the usage of the render stream. This method may not be called after
8477    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8478    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8479        self.client.send::<AudioRendererSetUsage2Request>(
8480            (usage2,),
8481            0x2904035c7132b103,
8482            fidl::encoding::DynamicFlags::FLEXIBLE,
8483        )
8484    }
8485
8486    /// Sets the type of the stream to be delivered by the client. Using this method implies
8487    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8488    ///
8489    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8490    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8491    /// methods such as `SendPacket`/`SendPacketNoReply`.
8492    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8493        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8494            (type_,),
8495            0x27aa715d8901fa19,
8496            fidl::encoding::DynamicFlags::empty(),
8497        )
8498    }
8499
8500    /// Enables or disables notifications about changes to the minimum clock lead
8501    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8502    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8503    /// event with the current minimum lead time for the AudioRenderer. If the
8504    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8505    /// new value. This behavior will continue until the user calls
8506    /// `EnableMinLeadTimeEvents(false)`.
8507    ///
8508    /// The minimum clock lead time is the amount of time ahead of the reference
8509    /// clock's understanding of "now" that packets needs to arrive (relative to
8510    /// the playback clock transformation) in order for the mixer to be able to
8511    /// mix packet. For example...
8512    ///
8513    /// + Let the PTS of packet X be P(X)
8514    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8515    ///   function is determined by the call to Play(...)
8516    /// + Let the minimum lead time be MLT
8517    ///
8518    /// If R(P(X)) < RefClock.Now() + MLT
8519    /// Then the packet is late, and some (or all) of the packet's payload will
8520    /// need to be skipped in order to present the packet at the scheduled time.
8521    ///
8522    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8523    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8524    /// is called before the AudioRenderer is routed, any played packets will be
8525    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8526    /// calling `Play`.
8527    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8528        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8529            (enabled,),
8530            0x62808dfad72bf890,
8531            fidl::encoding::DynamicFlags::empty(),
8532        )
8533    }
8534
8535    ///
8536    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8537    /// there's little reason to do so. This is because lead time is a function
8538    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8539    /// If min lead time events are enabled before `SetPcmStreamType` (with
8540    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8541    /// response to `SetPcmStreamType`.
8542    pub fn r#get_min_lead_time(
8543        &self,
8544        ___deadline: zx::MonotonicInstant,
8545    ) -> Result<i64, fidl::Error> {
8546        let _response = self.client.send_query::<
8547            fidl::encoding::EmptyPayload,
8548            AudioRendererGetMinLeadTimeResponse,
8549            AudioRendererMarker,
8550        >(
8551            (),
8552            0x1cf3c3ecd8fec26b,
8553            fidl::encoding::DynamicFlags::empty(),
8554            ___deadline,
8555        )?;
8556        Ok(_response.min_lead_time_nsec)
8557    }
8558
8559    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8560    /// of the media timeline, using specific values provided by the caller (or
8561    /// default values if not specified). In an optional callback, returns the
8562    /// timestamp values ultimately used -- these set the ongoing relationship
8563    /// between the media and reference timelines (i.e., how to translate between
8564    /// the domain of presentation timestamps, and the realm of local system
8565    /// time).
8566    ///
8567    /// Local system time is specified in units of nanoseconds; media_time is
8568    /// specified in the units defined by the user in the `SetPtsUnits` function,
8569    /// or nanoseconds if `SetPtsUnits` is not called.
8570    ///
8571    /// The act of placing an AudioRenderer into the playback state establishes a
8572    /// relationship between 1) the user-defined media (or presentation) timeline
8573    /// for this particular AudioRenderer, and 2) the real-world system reference
8574    /// timeline. To communicate how to translate between timelines, the Play()
8575    /// callback provides an equivalent timestamp in each time domain. The first
8576    /// value ('reference_time') is given in terms of this renderer's reference
8577    /// clock; the second value ('media_time') is what media instant exactly
8578    /// corresponds to that local time. Restated, the frame at 'media_time' in
8579    /// the audio stream should be presented at 'reference_time' according to
8580    /// the reference clock.
8581    ///
8582    /// Note: on calling this API, media_time immediately starts advancing. It is
8583    /// possible (if uncommon) for a caller to specify a system time that is
8584    /// far in the past, or far into the future. This, along with the specified
8585    /// media time, is simply used to determine what media time corresponds to
8586    /// 'now', and THAT media time is then intersected with presentation
8587    /// timestamps of packets already submitted, to determine which media frames
8588    /// should be presented next.
8589    ///
8590    /// With the corresponding reference_time and media_time values, a user can
8591    /// translate arbitrary time values from one timeline into the other. After
8592    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8593    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8594    /// any 'ref_time':
8595    ///
8596    /// media_time = ( (ref_time - ref_start) / 1e9
8597    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8598    ///              + media_start
8599    ///
8600    /// Conversely, for any presentation timestamp 'media_time':
8601    ///
8602    /// ref_time = ( (media_time - media_start)
8603    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8604    ///              * 1e9 )
8605    ///            + ref_start
8606    ///
8607    /// Users, depending on their use case, may optionally choose not to specify
8608    /// one or both of these timestamps. A timestamp may be omitted by supplying
8609    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8610    /// any omitted timestamp value using the following rules:
8611    ///
8612    /// Reference Time
8613    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8614    /// reference time to begin presentation, based on the minimum lead times for
8615    /// the output devices that are currently bound to this AudioRenderer. For
8616    /// example, if an AudioRenderer is bound to an internal audio output
8617    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8618    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8619    /// is omitted) select a reference time 80 mSec from now.
8620    ///
8621    /// Media Time
8622    /// If media_time is omitted, the AudioRenderer will select one of two
8623    /// values.
8624    /// - If the AudioRenderer is resuming from the paused state, and packets
8625    /// have not been discarded since being paused, then the AudioRenderer will
8626    /// use a media_time corresponding to the instant at which the presentation
8627    /// became paused.
8628    /// - If the AudioRenderer is being placed into a playing state for the first
8629    /// time following startup or a 'discard packets' operation, the initial
8630    /// media_time will be set to the PTS of the first payload in the pending
8631    /// packet queue. If the pending queue is empty, initial media_time will be
8632    /// set to zero.
8633    ///
8634    /// Return Value
8635    /// When requested, the AudioRenderer will return the 'reference_time' and
8636    /// 'media_time' which were selected and used (whether they were explicitly
8637    /// specified or not) in the return value of the play call.
8638    ///
8639    /// Examples
8640    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8641    /// to start playing as soon as possible. The user may call Play without
8642    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8643    ///
8644    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8645    /// playback at a specified 'reference_time', in sync with some other media
8646    /// stream, either initially or after discarding packets. The user would call
8647    /// `Play(reference_time, NO_TIMESTAMP)`.
8648    ///
8649    /// 3. A user has queued some audio using `SendPacket`. The first of these
8650    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8651    /// as possible, but wishes to skip all of the audio content between PTS 0
8652    /// and PTS 'media_time'. The user would call
8653    /// `Play(NO_TIMESTAMP, media_time)`.
8654    ///
8655    /// 4. A user has queued some audio using `SendPacket` and want to present
8656    /// this media in synch with another player in a different device. The
8657    /// coordinator of the group of distributed players sends an explicit
8658    /// message to each player telling them to begin presentation of audio at
8659    /// PTS 'media_time', at the time (based on the group's shared reference
8660    /// clock) 'reference_time'. Here the user would call
8661    /// `Play(reference_time, media_time)`.
8662    pub fn r#play(
8663        &self,
8664        mut reference_time: i64,
8665        mut media_time: i64,
8666        ___deadline: zx::MonotonicInstant,
8667    ) -> Result<(i64, i64), fidl::Error> {
8668        let _response = self
8669            .client
8670            .send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse, AudioRendererMarker>(
8671                (reference_time, media_time),
8672                0x3c0162db084f74a3,
8673                fidl::encoding::DynamicFlags::empty(),
8674                ___deadline,
8675            )?;
8676        Ok((_response.reference_time, _response.media_time))
8677    }
8678
8679    pub fn r#play_no_reply(
8680        &self,
8681        mut reference_time: i64,
8682        mut media_time: i64,
8683    ) -> Result<(), fidl::Error> {
8684        self.client.send::<AudioRendererPlayNoReplyRequest>(
8685            (reference_time, media_time),
8686            0x1b7fe832b68c22ef,
8687            fidl::encoding::DynamicFlags::empty(),
8688        )
8689    }
8690
8691    /// Immediately puts the AudioRenderer into the paused state and then report
8692    /// the relationship between the media and reference timelines which was
8693    /// established (if requested).
8694    ///
8695    /// If the AudioRenderer is already in the paused state when this called,
8696    /// the previously-established timeline values are returned (if requested).
8697    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8698        let _response = self.client.send_query::<
8699            fidl::encoding::EmptyPayload,
8700            AudioRendererPauseResponse,
8701            AudioRendererMarker,
8702        >(
8703            (),
8704            0x41d557588d93d153,
8705            fidl::encoding::DynamicFlags::empty(),
8706            ___deadline,
8707        )?;
8708        Ok((_response.reference_time, _response.media_time))
8709    }
8710
8711    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8712        self.client.send::<fidl::encoding::EmptyPayload>(
8713            (),
8714            0x24cc45d4f3855ab,
8715            fidl::encoding::DynamicFlags::empty(),
8716        )
8717    }
8718}
8719
8720#[cfg(target_os = "fuchsia")]
8721impl From<AudioRendererSynchronousProxy> for zx::NullableHandle {
8722    fn from(value: AudioRendererSynchronousProxy) -> Self {
8723        value.into_channel().into()
8724    }
8725}
8726
8727#[cfg(target_os = "fuchsia")]
8728impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8729    fn from(value: fidl::Channel) -> Self {
8730        Self::new(value)
8731    }
8732}
8733
8734#[cfg(target_os = "fuchsia")]
8735impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8736    type Protocol = AudioRendererMarker;
8737
8738    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8739        Self::new(value.into_channel())
8740    }
8741}
8742
8743#[derive(Debug, Clone)]
8744pub struct AudioRendererProxy {
8745    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8746}
8747
8748impl fidl::endpoints::Proxy for AudioRendererProxy {
8749    type Protocol = AudioRendererMarker;
8750
8751    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8752        Self::new(inner)
8753    }
8754
8755    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8756        self.client.into_channel().map_err(|client| Self { client })
8757    }
8758
8759    fn as_channel(&self) -> &::fidl::AsyncChannel {
8760        self.client.as_channel()
8761    }
8762}
8763
8764impl AudioRendererProxy {
8765    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8766    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8767        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8768        Self { client: fidl::client::Client::new(channel, protocol_name) }
8769    }
8770
8771    /// Get a Stream of events from the remote end of the protocol.
8772    ///
8773    /// # Panics
8774    ///
8775    /// Panics if the event stream was already taken.
8776    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8777        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8778    }
8779
8780    /// Adds a payload buffer to the current buffer set associated with the
8781    /// connection. A `StreamPacket` struct reference a payload buffer in the
8782    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8783    ///
8784    /// A buffer with ID `id` must not be in the current set when this method is
8785    /// invoked, otherwise the service will close the connection.
8786    pub fn r#add_payload_buffer(
8787        &self,
8788        mut id: u32,
8789        mut payload_buffer: fidl::Vmo,
8790    ) -> Result<(), fidl::Error> {
8791        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8792    }
8793
8794    /// Removes a payload buffer from the current buffer set associated with the
8795    /// connection.
8796    ///
8797    /// A buffer with ID `id` must exist in the current set when this method is
8798    /// invoked, otherwise the service will will close the connection.
8799    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8800        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8801    }
8802
8803    /// Sends a packet to the service. The response is sent when the service is
8804    /// done with the associated payload memory.
8805    ///
8806    /// `packet` must be valid for the current buffer set, otherwise the service
8807    /// will close the connection.
8808    pub fn r#send_packet(
8809        &self,
8810        mut packet: &StreamPacket,
8811    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8812        AudioRendererProxyInterface::r#send_packet(self, packet)
8813    }
8814
8815    /// Sends a packet to the service. This interface doesn't define how the
8816    /// client knows when the sink is done with the associated payload memory.
8817    /// The inheriting interface must define that.
8818    ///
8819    /// `packet` must be valid for the current buffer set, otherwise the service
8820    /// will close the connection.
8821    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8822        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8823    }
8824
8825    /// Indicates the stream has ended. The precise semantics of this method are
8826    /// determined by the inheriting interface.
8827    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8828        AudioRendererProxyInterface::r#end_of_stream(self)
8829    }
8830
8831    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8832    /// and not yet released. The response is sent after all packets have been
8833    /// released.
8834    pub fn r#discard_all_packets(
8835        &self,
8836    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8837        AudioRendererProxyInterface::r#discard_all_packets(self)
8838    }
8839
8840    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8841    /// and not yet released.
8842    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8843        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8844    }
8845
8846    /// Binds to the gain control for this AudioRenderer.
8847    pub fn r#bind_gain_control(
8848        &self,
8849        mut gain_control_request: fidl::endpoints::ServerEnd<
8850            fidl_fuchsia_media_audio::GainControlMarker,
8851        >,
8852    ) -> Result<(), fidl::Error> {
8853        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8854    }
8855
8856    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8857    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8858    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8859    pub fn r#set_pts_units(
8860        &self,
8861        mut tick_per_second_numerator: u32,
8862        mut tick_per_second_denominator: u32,
8863    ) -> Result<(), fidl::Error> {
8864        AudioRendererProxyInterface::r#set_pts_units(
8865            self,
8866            tick_per_second_numerator,
8867            tick_per_second_denominator,
8868        )
8869    }
8870
8871    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8872    /// and expected PTS (determined using interpolation). Beyond this threshold,
8873    /// a stream is no longer considered 'continuous' by the renderer.
8874    ///
8875    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8876    /// Most users should not need to change this value from its default.
8877    ///
8878    /// Example:
8879    /// A user is playing back 48KHz audio from a container, which also contains
8880    /// video and needs to be synchronized with the audio. The timestamps are
8881    /// provided explicitly per packet by the container, and expressed in mSec
8882    /// units. This means that a single tick of the media timeline (1 mSec)
8883    /// represents exactly 48 frames of audio. The application in this scenario
8884    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8885    /// frames of audio, and each with an explicit timestamp set to the best
8886    /// possible representation of the presentation time (given this media
8887    /// clock's resolution). So, starting from zero, the timestamps would be..
8888    ///
8889    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8890    ///
8891    /// In this example, attempting to use the presentation time to compute the
8892    /// starting frame number of the audio in the packet would be wrong the
8893    /// majority of the time. The first timestamp is correct (by definition), but
8894    /// it will be 24 packets before the timestamps and frame numbers come back
8895    /// into alignment (the 24th packet would start with the 11280th audio frame
8896    /// and have a PTS of exactly 235).
8897    ///
8898    /// One way to fix this situation is to set the PTS continuity threshold
8899    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8900    /// the number of frames contained within a single tick of the media clock,
8901    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8902    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8903    /// explicitly provided PTS would be considered to be a continuation of the
8904    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8905    /// would work well.
8906    ///
8907    /// Other possible uses:
8908    /// Users who are scheduling audio explicitly, relative to a clock which has
8909    /// not been configured as the reference clock, can use this value to control
8910    /// the maximum acceptable synchronization error before a discontinuity is
8911    /// introduced. E.g., if a user is scheduling audio based on a recovered
8912    /// common media clock, and has not published that clock as the reference
8913    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8914    /// can accumulate before the AudioRenderer deliberately inserts a
8915    /// presentation discontinuity to account for the error.
8916    ///
8917    /// Users whose need to deal with a container where their timestamps may be
8918    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8919    /// something larger. This should be the maximum level of inaccuracy present
8920    /// in the container timestamps, if known. Failing that, it could be set to
8921    /// the maximum tolerable level of drift error before absolute timestamps are
8922    /// explicitly obeyed. Finally, a user could set this number to a very large
8923    /// value (86400.0 seconds, for example) to effectively cause *all*
8924    /// timestamps to be ignored after the first, thus treating all audio as
8925    /// continuous with previously delivered packets. Conversely, users who wish
8926    /// to *always* explicitly schedule their audio packets exactly may specify
8927    /// a CT of 0.
8928    ///
8929    /// Note: explicitly specifying high-frequency PTS units reduces the default
8930    /// continuity threshold accordingly. Internally, this threshold is stored as an
8931    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8932    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8933    /// For this reason, specifying PTS units with a frequency greater than 8192x
8934    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8935    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8936    pub fn r#set_pts_continuity_threshold(
8937        &self,
8938        mut threshold_seconds: f32,
8939    ) -> Result<(), fidl::Error> {
8940        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8941    }
8942
8943    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8944    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8945    pub fn r#get_reference_clock(
8946        &self,
8947    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8948    {
8949        AudioRendererProxyInterface::r#get_reference_clock(self)
8950    }
8951
8952    /// Sets the reference clock that controls this renderer's playback rate. If the input
8953    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8954    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8955    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8956    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8957    ///
8958    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8959    /// cannot be called a second time (even if the renderer format has not yet been set).
8960    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8961    /// diverge at some later time, they should create a clone of the monotonic clock, set
8962    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8963    pub fn r#set_reference_clock(
8964        &self,
8965        mut reference_clock: Option<fidl::Clock>,
8966    ) -> Result<(), fidl::Error> {
8967        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
8968    }
8969
8970    /// Sets the usage of the render stream. This method may not be called after
8971    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8972    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8973        AudioRendererProxyInterface::r#set_usage(self, usage)
8974    }
8975
8976    /// Sets the usage of the render stream. This method may not be called after
8977    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8978    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8979        AudioRendererProxyInterface::r#set_usage2(self, usage2)
8980    }
8981
8982    /// Sets the type of the stream to be delivered by the client. Using this method implies
8983    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8984    ///
8985    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8986    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8987    /// methods such as `SendPacket`/`SendPacketNoReply`.
8988    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8989        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
8990    }
8991
8992    /// Enables or disables notifications about changes to the minimum clock lead
8993    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8994    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8995    /// event with the current minimum lead time for the AudioRenderer. If the
8996    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8997    /// new value. This behavior will continue until the user calls
8998    /// `EnableMinLeadTimeEvents(false)`.
8999    ///
9000    /// The minimum clock lead time is the amount of time ahead of the reference
9001    /// clock's understanding of "now" that packets needs to arrive (relative to
9002    /// the playback clock transformation) in order for the mixer to be able to
9003    /// mix packet. For example...
9004    ///
9005    /// + Let the PTS of packet X be P(X)
9006    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9007    ///   function is determined by the call to Play(...)
9008    /// + Let the minimum lead time be MLT
9009    ///
9010    /// If R(P(X)) < RefClock.Now() + MLT
9011    /// Then the packet is late, and some (or all) of the packet's payload will
9012    /// need to be skipped in order to present the packet at the scheduled time.
9013    ///
9014    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9015    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9016    /// is called before the AudioRenderer is routed, any played packets will be
9017    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9018    /// calling `Play`.
9019    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9020        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
9021    }
9022
9023    ///
9024    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9025    /// there's little reason to do so. This is because lead time is a function
9026    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9027    /// If min lead time events are enabled before `SetPcmStreamType` (with
9028    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9029    /// response to `SetPcmStreamType`.
9030    pub fn r#get_min_lead_time(
9031        &self,
9032    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
9033        AudioRendererProxyInterface::r#get_min_lead_time(self)
9034    }
9035
9036    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9037    /// of the media timeline, using specific values provided by the caller (or
9038    /// default values if not specified). In an optional callback, returns the
9039    /// timestamp values ultimately used -- these set the ongoing relationship
9040    /// between the media and reference timelines (i.e., how to translate between
9041    /// the domain of presentation timestamps, and the realm of local system
9042    /// time).
9043    ///
9044    /// Local system time is specified in units of nanoseconds; media_time is
9045    /// specified in the units defined by the user in the `SetPtsUnits` function,
9046    /// or nanoseconds if `SetPtsUnits` is not called.
9047    ///
9048    /// The act of placing an AudioRenderer into the playback state establishes a
9049    /// relationship between 1) the user-defined media (or presentation) timeline
9050    /// for this particular AudioRenderer, and 2) the real-world system reference
9051    /// timeline. To communicate how to translate between timelines, the Play()
9052    /// callback provides an equivalent timestamp in each time domain. The first
9053    /// value ('reference_time') is given in terms of this renderer's reference
9054    /// clock; the second value ('media_time') is what media instant exactly
9055    /// corresponds to that local time. Restated, the frame at 'media_time' in
9056    /// the audio stream should be presented at 'reference_time' according to
9057    /// the reference clock.
9058    ///
9059    /// Note: on calling this API, media_time immediately starts advancing. It is
9060    /// possible (if uncommon) for a caller to specify a system time that is
9061    /// far in the past, or far into the future. This, along with the specified
9062    /// media time, is simply used to determine what media time corresponds to
9063    /// 'now', and THAT media time is then intersected with presentation
9064    /// timestamps of packets already submitted, to determine which media frames
9065    /// should be presented next.
9066    ///
9067    /// With the corresponding reference_time and media_time values, a user can
9068    /// translate arbitrary time values from one timeline into the other. After
9069    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9070    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9071    /// any 'ref_time':
9072    ///
9073    /// media_time = ( (ref_time - ref_start) / 1e9
9074    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9075    ///              + media_start
9076    ///
9077    /// Conversely, for any presentation timestamp 'media_time':
9078    ///
9079    /// ref_time = ( (media_time - media_start)
9080    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9081    ///              * 1e9 )
9082    ///            + ref_start
9083    ///
9084    /// Users, depending on their use case, may optionally choose not to specify
9085    /// one or both of these timestamps. A timestamp may be omitted by supplying
9086    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9087    /// any omitted timestamp value using the following rules:
9088    ///
9089    /// Reference Time
9090    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9091    /// reference time to begin presentation, based on the minimum lead times for
9092    /// the output devices that are currently bound to this AudioRenderer. For
9093    /// example, if an AudioRenderer is bound to an internal audio output
9094    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9095    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9096    /// is omitted) select a reference time 80 mSec from now.
9097    ///
9098    /// Media Time
9099    /// If media_time is omitted, the AudioRenderer will select one of two
9100    /// values.
9101    /// - If the AudioRenderer is resuming from the paused state, and packets
9102    /// have not been discarded since being paused, then the AudioRenderer will
9103    /// use a media_time corresponding to the instant at which the presentation
9104    /// became paused.
9105    /// - If the AudioRenderer is being placed into a playing state for the first
9106    /// time following startup or a 'discard packets' operation, the initial
9107    /// media_time will be set to the PTS of the first payload in the pending
9108    /// packet queue. If the pending queue is empty, initial media_time will be
9109    /// set to zero.
9110    ///
9111    /// Return Value
9112    /// When requested, the AudioRenderer will return the 'reference_time' and
9113    /// 'media_time' which were selected and used (whether they were explicitly
9114    /// specified or not) in the return value of the play call.
9115    ///
9116    /// Examples
9117    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
9118    /// to start playing as soon as possible. The user may call Play without
9119    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
9120    ///
9121    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
9122    /// playback at a specified 'reference_time', in sync with some other media
9123    /// stream, either initially or after discarding packets. The user would call
9124    /// `Play(reference_time, NO_TIMESTAMP)`.
9125    ///
9126    /// 3. A user has queued some audio using `SendPacket`. The first of these
9127    /// packets has a PTS of zero, and the user wishes playback to begin as soon
9128    /// as possible, but wishes to skip all of the audio content between PTS 0
9129    /// and PTS 'media_time'. The user would call
9130    /// `Play(NO_TIMESTAMP, media_time)`.
9131    ///
9132    /// 4. A user has queued some audio using `SendPacket` and want to present
9133    /// this media in synch with another player in a different device. The
9134    /// coordinator of the group of distributed players sends an explicit
9135    /// message to each player telling them to begin presentation of audio at
9136    /// PTS 'media_time', at the time (based on the group's shared reference
9137    /// clock) 'reference_time'. Here the user would call
9138    /// `Play(reference_time, media_time)`.
9139    pub fn r#play(
9140        &self,
9141        mut reference_time: i64,
9142        mut media_time: i64,
9143    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
9144    {
9145        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
9146    }
9147
9148    pub fn r#play_no_reply(
9149        &self,
9150        mut reference_time: i64,
9151        mut media_time: i64,
9152    ) -> Result<(), fidl::Error> {
9153        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
9154    }
9155
9156    /// Immediately puts the AudioRenderer into the paused state and then report
9157    /// the relationship between the media and reference timelines which was
9158    /// established (if requested).
9159    ///
9160    /// If the AudioRenderer is already in the paused state when this called,
9161    /// the previously-established timeline values are returned (if requested).
9162    pub fn r#pause(
9163        &self,
9164    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
9165    {
9166        AudioRendererProxyInterface::r#pause(self)
9167    }
9168
9169    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9170        AudioRendererProxyInterface::r#pause_no_reply(self)
9171    }
9172}
9173
9174impl AudioRendererProxyInterface for AudioRendererProxy {
9175    fn r#add_payload_buffer(
9176        &self,
9177        mut id: u32,
9178        mut payload_buffer: fidl::Vmo,
9179    ) -> Result<(), fidl::Error> {
9180        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
9181            (id, payload_buffer),
9182            0x3b3a37fc34fe5b56,
9183            fidl::encoding::DynamicFlags::empty(),
9184        )
9185    }
9186
9187    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
9188        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
9189            (id,),
9190            0x5d1e4f74c3658262,
9191            fidl::encoding::DynamicFlags::empty(),
9192        )
9193    }
9194
9195    type SendPacketResponseFut =
9196        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9197    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
9198        fn _decode(
9199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9200        ) -> Result<(), fidl::Error> {
9201            let _response = fidl::client::decode_transaction_body::<
9202                fidl::encoding::EmptyPayload,
9203                fidl::encoding::DefaultFuchsiaResourceDialect,
9204                0x67cddd607442775f,
9205            >(_buf?)?;
9206            Ok(_response)
9207        }
9208        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
9209            (packet,),
9210            0x67cddd607442775f,
9211            fidl::encoding::DynamicFlags::empty(),
9212            _decode,
9213        )
9214    }
9215
9216    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
9217        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
9218            (packet,),
9219            0x8d9b8b413ceba9d,
9220            fidl::encoding::DynamicFlags::empty(),
9221        )
9222    }
9223
9224    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
9225        self.client.send::<fidl::encoding::EmptyPayload>(
9226            (),
9227            0x6180fd6f7e793b71,
9228            fidl::encoding::DynamicFlags::empty(),
9229        )
9230    }
9231
9232    type DiscardAllPacketsResponseFut =
9233        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9234    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
9235        fn _decode(
9236            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9237        ) -> Result<(), fidl::Error> {
9238            let _response = fidl::client::decode_transaction_body::<
9239                fidl::encoding::EmptyPayload,
9240                fidl::encoding::DefaultFuchsiaResourceDialect,
9241                0x6f4dad7af2917665,
9242            >(_buf?)?;
9243            Ok(_response)
9244        }
9245        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9246            (),
9247            0x6f4dad7af2917665,
9248            fidl::encoding::DynamicFlags::empty(),
9249            _decode,
9250        )
9251    }
9252
9253    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
9254        self.client.send::<fidl::encoding::EmptyPayload>(
9255            (),
9256            0x50d36d0d23081bc4,
9257            fidl::encoding::DynamicFlags::empty(),
9258        )
9259    }
9260
9261    fn r#bind_gain_control(
9262        &self,
9263        mut gain_control_request: fidl::endpoints::ServerEnd<
9264            fidl_fuchsia_media_audio::GainControlMarker,
9265        >,
9266    ) -> Result<(), fidl::Error> {
9267        self.client.send::<AudioRendererBindGainControlRequest>(
9268            (gain_control_request,),
9269            0x293f5c7f8fba2bdc,
9270            fidl::encoding::DynamicFlags::empty(),
9271        )
9272    }
9273
9274    fn r#set_pts_units(
9275        &self,
9276        mut tick_per_second_numerator: u32,
9277        mut tick_per_second_denominator: u32,
9278    ) -> Result<(), fidl::Error> {
9279        self.client.send::<AudioRendererSetPtsUnitsRequest>(
9280            (tick_per_second_numerator, tick_per_second_denominator),
9281            0xf68cd108785a27c,
9282            fidl::encoding::DynamicFlags::empty(),
9283        )
9284    }
9285
9286    fn r#set_pts_continuity_threshold(
9287        &self,
9288        mut threshold_seconds: f32,
9289    ) -> Result<(), fidl::Error> {
9290        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
9291            (threshold_seconds,),
9292            0x2849ba571d1971ba,
9293            fidl::encoding::DynamicFlags::empty(),
9294        )
9295    }
9296
9297    type GetReferenceClockResponseFut =
9298        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
9299    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
9300        fn _decode(
9301            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9302        ) -> Result<fidl::Clock, fidl::Error> {
9303            let _response = fidl::client::decode_transaction_body::<
9304                AudioRendererGetReferenceClockResponse,
9305                fidl::encoding::DefaultFuchsiaResourceDialect,
9306                0x2f7a7f011a172f7e,
9307            >(_buf?)?;
9308            Ok(_response.reference_clock)
9309        }
9310        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
9311            (),
9312            0x2f7a7f011a172f7e,
9313            fidl::encoding::DynamicFlags::empty(),
9314            _decode,
9315        )
9316    }
9317
9318    fn r#set_reference_clock(
9319        &self,
9320        mut reference_clock: Option<fidl::Clock>,
9321    ) -> Result<(), fidl::Error> {
9322        self.client.send::<AudioRendererSetReferenceClockRequest>(
9323            (reference_clock,),
9324            0x39acd05d832b5fed,
9325            fidl::encoding::DynamicFlags::empty(),
9326        )
9327    }
9328
9329    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9330        self.client.send::<AudioRendererSetUsageRequest>(
9331            (usage,),
9332            0x3994bd23b55a733e,
9333            fidl::encoding::DynamicFlags::empty(),
9334        )
9335    }
9336
9337    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9338        self.client.send::<AudioRendererSetUsage2Request>(
9339            (usage2,),
9340            0x2904035c7132b103,
9341            fidl::encoding::DynamicFlags::FLEXIBLE,
9342        )
9343    }
9344
9345    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9346        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9347            (type_,),
9348            0x27aa715d8901fa19,
9349            fidl::encoding::DynamicFlags::empty(),
9350        )
9351    }
9352
9353    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9354        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9355            (enabled,),
9356            0x62808dfad72bf890,
9357            fidl::encoding::DynamicFlags::empty(),
9358        )
9359    }
9360
9361    type GetMinLeadTimeResponseFut =
9362        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9363    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9364        fn _decode(
9365            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9366        ) -> Result<i64, fidl::Error> {
9367            let _response = fidl::client::decode_transaction_body::<
9368                AudioRendererGetMinLeadTimeResponse,
9369                fidl::encoding::DefaultFuchsiaResourceDialect,
9370                0x1cf3c3ecd8fec26b,
9371            >(_buf?)?;
9372            Ok(_response.min_lead_time_nsec)
9373        }
9374        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9375            (),
9376            0x1cf3c3ecd8fec26b,
9377            fidl::encoding::DynamicFlags::empty(),
9378            _decode,
9379        )
9380    }
9381
9382    type PlayResponseFut =
9383        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9384    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9385        fn _decode(
9386            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9387        ) -> Result<(i64, i64), fidl::Error> {
9388            let _response = fidl::client::decode_transaction_body::<
9389                AudioRendererPlayResponse,
9390                fidl::encoding::DefaultFuchsiaResourceDialect,
9391                0x3c0162db084f74a3,
9392            >(_buf?)?;
9393            Ok((_response.reference_time, _response.media_time))
9394        }
9395        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9396            (reference_time, media_time),
9397            0x3c0162db084f74a3,
9398            fidl::encoding::DynamicFlags::empty(),
9399            _decode,
9400        )
9401    }
9402
9403    fn r#play_no_reply(
9404        &self,
9405        mut reference_time: i64,
9406        mut media_time: i64,
9407    ) -> Result<(), fidl::Error> {
9408        self.client.send::<AudioRendererPlayNoReplyRequest>(
9409            (reference_time, media_time),
9410            0x1b7fe832b68c22ef,
9411            fidl::encoding::DynamicFlags::empty(),
9412        )
9413    }
9414
9415    type PauseResponseFut =
9416        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9417    fn r#pause(&self) -> Self::PauseResponseFut {
9418        fn _decode(
9419            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9420        ) -> Result<(i64, i64), fidl::Error> {
9421            let _response = fidl::client::decode_transaction_body::<
9422                AudioRendererPauseResponse,
9423                fidl::encoding::DefaultFuchsiaResourceDialect,
9424                0x41d557588d93d153,
9425            >(_buf?)?;
9426            Ok((_response.reference_time, _response.media_time))
9427        }
9428        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9429            (),
9430            0x41d557588d93d153,
9431            fidl::encoding::DynamicFlags::empty(),
9432            _decode,
9433        )
9434    }
9435
9436    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9437        self.client.send::<fidl::encoding::EmptyPayload>(
9438            (),
9439            0x24cc45d4f3855ab,
9440            fidl::encoding::DynamicFlags::empty(),
9441        )
9442    }
9443}
9444
9445pub struct AudioRendererEventStream {
9446    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9447}
9448
9449impl std::marker::Unpin for AudioRendererEventStream {}
9450
9451impl futures::stream::FusedStream for AudioRendererEventStream {
9452    fn is_terminated(&self) -> bool {
9453        self.event_receiver.is_terminated()
9454    }
9455}
9456
9457impl futures::Stream for AudioRendererEventStream {
9458    type Item = Result<AudioRendererEvent, fidl::Error>;
9459
9460    fn poll_next(
9461        mut self: std::pin::Pin<&mut Self>,
9462        cx: &mut std::task::Context<'_>,
9463    ) -> std::task::Poll<Option<Self::Item>> {
9464        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9465            &mut self.event_receiver,
9466            cx
9467        )?) {
9468            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9469            None => std::task::Poll::Ready(None),
9470        }
9471    }
9472}
9473
9474#[derive(Debug)]
9475pub enum AudioRendererEvent {
9476    OnMinLeadTimeChanged {
9477        min_lead_time_nsec: i64,
9478    },
9479    #[non_exhaustive]
9480    _UnknownEvent {
9481        /// Ordinal of the event that was sent.
9482        ordinal: u64,
9483    },
9484}
9485
9486impl AudioRendererEvent {
9487    #[allow(irrefutable_let_patterns)]
9488    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9489        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9490            Some((min_lead_time_nsec))
9491        } else {
9492            None
9493        }
9494    }
9495
9496    /// Decodes a message buffer as a [`AudioRendererEvent`].
9497    fn decode(
9498        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9499    ) -> Result<AudioRendererEvent, fidl::Error> {
9500        let (bytes, _handles) = buf.split_mut();
9501        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9502        debug_assert_eq!(tx_header.tx_id, 0);
9503        match tx_header.ordinal {
9504            0x4feff7d278978c4e => {
9505                let mut out = fidl::new_empty!(
9506                    AudioRendererOnMinLeadTimeChangedRequest,
9507                    fidl::encoding::DefaultFuchsiaResourceDialect
9508                );
9509                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9510                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9511                    min_lead_time_nsec: out.min_lead_time_nsec,
9512                }))
9513            }
9514            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9515                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9516            }
9517            _ => Err(fidl::Error::UnknownOrdinal {
9518                ordinal: tx_header.ordinal,
9519                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9520            }),
9521        }
9522    }
9523}
9524
9525/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9526pub struct AudioRendererRequestStream {
9527    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9528    is_terminated: bool,
9529}
9530
9531impl std::marker::Unpin for AudioRendererRequestStream {}
9532
9533impl futures::stream::FusedStream for AudioRendererRequestStream {
9534    fn is_terminated(&self) -> bool {
9535        self.is_terminated
9536    }
9537}
9538
9539impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9540    type Protocol = AudioRendererMarker;
9541    type ControlHandle = AudioRendererControlHandle;
9542
9543    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9544        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9545    }
9546
9547    fn control_handle(&self) -> Self::ControlHandle {
9548        AudioRendererControlHandle { inner: self.inner.clone() }
9549    }
9550
9551    fn into_inner(
9552        self,
9553    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9554    {
9555        (self.inner, self.is_terminated)
9556    }
9557
9558    fn from_inner(
9559        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9560        is_terminated: bool,
9561    ) -> Self {
9562        Self { inner, is_terminated }
9563    }
9564}
9565
9566impl futures::Stream for AudioRendererRequestStream {
9567    type Item = Result<AudioRendererRequest, fidl::Error>;
9568
9569    fn poll_next(
9570        mut self: std::pin::Pin<&mut Self>,
9571        cx: &mut std::task::Context<'_>,
9572    ) -> std::task::Poll<Option<Self::Item>> {
9573        let this = &mut *self;
9574        if this.inner.check_shutdown(cx) {
9575            this.is_terminated = true;
9576            return std::task::Poll::Ready(None);
9577        }
9578        if this.is_terminated {
9579            panic!("polled AudioRendererRequestStream after completion");
9580        }
9581        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9582            |bytes, handles| {
9583                match this.inner.channel().read_etc(cx, bytes, handles) {
9584                    std::task::Poll::Ready(Ok(())) => {}
9585                    std::task::Poll::Pending => return std::task::Poll::Pending,
9586                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9587                        this.is_terminated = true;
9588                        return std::task::Poll::Ready(None);
9589                    }
9590                    std::task::Poll::Ready(Err(e)) => {
9591                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9592                            e.into(),
9593                        ))));
9594                    }
9595                }
9596
9597                // A message has been received from the channel
9598                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9599
9600                std::task::Poll::Ready(Some(match header.ordinal {
9601                    0x3b3a37fc34fe5b56 => {
9602                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9603                        let mut req = fidl::new_empty!(
9604                            StreamBufferSetAddPayloadBufferRequest,
9605                            fidl::encoding::DefaultFuchsiaResourceDialect
9606                        );
9607                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9608                        let control_handle =
9609                            AudioRendererControlHandle { inner: this.inner.clone() };
9610                        Ok(AudioRendererRequest::AddPayloadBuffer {
9611                            id: req.id,
9612                            payload_buffer: req.payload_buffer,
9613
9614                            control_handle,
9615                        })
9616                    }
9617                    0x5d1e4f74c3658262 => {
9618                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9619                        let mut req = fidl::new_empty!(
9620                            StreamBufferSetRemovePayloadBufferRequest,
9621                            fidl::encoding::DefaultFuchsiaResourceDialect
9622                        );
9623                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9624                        let control_handle =
9625                            AudioRendererControlHandle { inner: this.inner.clone() };
9626                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9627                    }
9628                    0x67cddd607442775f => {
9629                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9630                        let mut req = fidl::new_empty!(
9631                            StreamSinkSendPacketRequest,
9632                            fidl::encoding::DefaultFuchsiaResourceDialect
9633                        );
9634                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9635                        let control_handle =
9636                            AudioRendererControlHandle { inner: this.inner.clone() };
9637                        Ok(AudioRendererRequest::SendPacket {
9638                            packet: req.packet,
9639
9640                            responder: AudioRendererSendPacketResponder {
9641                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9642                                tx_id: header.tx_id,
9643                            },
9644                        })
9645                    }
9646                    0x8d9b8b413ceba9d => {
9647                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9648                        let mut req = fidl::new_empty!(
9649                            StreamSinkSendPacketNoReplyRequest,
9650                            fidl::encoding::DefaultFuchsiaResourceDialect
9651                        );
9652                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9653                        let control_handle =
9654                            AudioRendererControlHandle { inner: this.inner.clone() };
9655                        Ok(AudioRendererRequest::SendPacketNoReply {
9656                            packet: req.packet,
9657
9658                            control_handle,
9659                        })
9660                    }
9661                    0x6180fd6f7e793b71 => {
9662                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9663                        let mut req = fidl::new_empty!(
9664                            fidl::encoding::EmptyPayload,
9665                            fidl::encoding::DefaultFuchsiaResourceDialect
9666                        );
9667                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9668                        let control_handle =
9669                            AudioRendererControlHandle { inner: this.inner.clone() };
9670                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9671                    }
9672                    0x6f4dad7af2917665 => {
9673                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9674                        let mut req = fidl::new_empty!(
9675                            fidl::encoding::EmptyPayload,
9676                            fidl::encoding::DefaultFuchsiaResourceDialect
9677                        );
9678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9679                        let control_handle =
9680                            AudioRendererControlHandle { inner: this.inner.clone() };
9681                        Ok(AudioRendererRequest::DiscardAllPackets {
9682                            responder: AudioRendererDiscardAllPacketsResponder {
9683                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9684                                tx_id: header.tx_id,
9685                            },
9686                        })
9687                    }
9688                    0x50d36d0d23081bc4 => {
9689                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9690                        let mut req = fidl::new_empty!(
9691                            fidl::encoding::EmptyPayload,
9692                            fidl::encoding::DefaultFuchsiaResourceDialect
9693                        );
9694                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9695                        let control_handle =
9696                            AudioRendererControlHandle { inner: this.inner.clone() };
9697                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9698                    }
9699                    0x293f5c7f8fba2bdc => {
9700                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9701                        let mut req = fidl::new_empty!(
9702                            AudioRendererBindGainControlRequest,
9703                            fidl::encoding::DefaultFuchsiaResourceDialect
9704                        );
9705                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9706                        let control_handle =
9707                            AudioRendererControlHandle { inner: this.inner.clone() };
9708                        Ok(AudioRendererRequest::BindGainControl {
9709                            gain_control_request: req.gain_control_request,
9710
9711                            control_handle,
9712                        })
9713                    }
9714                    0xf68cd108785a27c => {
9715                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9716                        let mut req = fidl::new_empty!(
9717                            AudioRendererSetPtsUnitsRequest,
9718                            fidl::encoding::DefaultFuchsiaResourceDialect
9719                        );
9720                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9721                        let control_handle =
9722                            AudioRendererControlHandle { inner: this.inner.clone() };
9723                        Ok(AudioRendererRequest::SetPtsUnits {
9724                            tick_per_second_numerator: req.tick_per_second_numerator,
9725                            tick_per_second_denominator: req.tick_per_second_denominator,
9726
9727                            control_handle,
9728                        })
9729                    }
9730                    0x2849ba571d1971ba => {
9731                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9732                        let mut req = fidl::new_empty!(
9733                            AudioRendererSetPtsContinuityThresholdRequest,
9734                            fidl::encoding::DefaultFuchsiaResourceDialect
9735                        );
9736                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9737                        let control_handle =
9738                            AudioRendererControlHandle { inner: this.inner.clone() };
9739                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9740                            threshold_seconds: req.threshold_seconds,
9741
9742                            control_handle,
9743                        })
9744                    }
9745                    0x2f7a7f011a172f7e => {
9746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9747                        let mut req = fidl::new_empty!(
9748                            fidl::encoding::EmptyPayload,
9749                            fidl::encoding::DefaultFuchsiaResourceDialect
9750                        );
9751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9752                        let control_handle =
9753                            AudioRendererControlHandle { inner: this.inner.clone() };
9754                        Ok(AudioRendererRequest::GetReferenceClock {
9755                            responder: AudioRendererGetReferenceClockResponder {
9756                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9757                                tx_id: header.tx_id,
9758                            },
9759                        })
9760                    }
9761                    0x39acd05d832b5fed => {
9762                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9763                        let mut req = fidl::new_empty!(
9764                            AudioRendererSetReferenceClockRequest,
9765                            fidl::encoding::DefaultFuchsiaResourceDialect
9766                        );
9767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9768                        let control_handle =
9769                            AudioRendererControlHandle { inner: this.inner.clone() };
9770                        Ok(AudioRendererRequest::SetReferenceClock {
9771                            reference_clock: req.reference_clock,
9772
9773                            control_handle,
9774                        })
9775                    }
9776                    0x3994bd23b55a733e => {
9777                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9778                        let mut req = fidl::new_empty!(
9779                            AudioRendererSetUsageRequest,
9780                            fidl::encoding::DefaultFuchsiaResourceDialect
9781                        );
9782                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9783                        let control_handle =
9784                            AudioRendererControlHandle { inner: this.inner.clone() };
9785                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9786                    }
9787                    0x2904035c7132b103 => {
9788                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9789                        let mut req = fidl::new_empty!(
9790                            AudioRendererSetUsage2Request,
9791                            fidl::encoding::DefaultFuchsiaResourceDialect
9792                        );
9793                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9794                        let control_handle =
9795                            AudioRendererControlHandle { inner: this.inner.clone() };
9796                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9797                    }
9798                    0x27aa715d8901fa19 => {
9799                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9800                        let mut req = fidl::new_empty!(
9801                            AudioRendererSetPcmStreamTypeRequest,
9802                            fidl::encoding::DefaultFuchsiaResourceDialect
9803                        );
9804                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9805                        let control_handle =
9806                            AudioRendererControlHandle { inner: this.inner.clone() };
9807                        Ok(AudioRendererRequest::SetPcmStreamType {
9808                            type_: req.type_,
9809
9810                            control_handle,
9811                        })
9812                    }
9813                    0x62808dfad72bf890 => {
9814                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9815                        let mut req = fidl::new_empty!(
9816                            AudioRendererEnableMinLeadTimeEventsRequest,
9817                            fidl::encoding::DefaultFuchsiaResourceDialect
9818                        );
9819                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9820                        let control_handle =
9821                            AudioRendererControlHandle { inner: this.inner.clone() };
9822                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9823                            enabled: req.enabled,
9824
9825                            control_handle,
9826                        })
9827                    }
9828                    0x1cf3c3ecd8fec26b => {
9829                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9830                        let mut req = fidl::new_empty!(
9831                            fidl::encoding::EmptyPayload,
9832                            fidl::encoding::DefaultFuchsiaResourceDialect
9833                        );
9834                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9835                        let control_handle =
9836                            AudioRendererControlHandle { inner: this.inner.clone() };
9837                        Ok(AudioRendererRequest::GetMinLeadTime {
9838                            responder: AudioRendererGetMinLeadTimeResponder {
9839                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9840                                tx_id: header.tx_id,
9841                            },
9842                        })
9843                    }
9844                    0x3c0162db084f74a3 => {
9845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9846                        let mut req = fidl::new_empty!(
9847                            AudioRendererPlayRequest,
9848                            fidl::encoding::DefaultFuchsiaResourceDialect
9849                        );
9850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9851                        let control_handle =
9852                            AudioRendererControlHandle { inner: this.inner.clone() };
9853                        Ok(AudioRendererRequest::Play {
9854                            reference_time: req.reference_time,
9855                            media_time: req.media_time,
9856
9857                            responder: AudioRendererPlayResponder {
9858                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9859                                tx_id: header.tx_id,
9860                            },
9861                        })
9862                    }
9863                    0x1b7fe832b68c22ef => {
9864                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9865                        let mut req = fidl::new_empty!(
9866                            AudioRendererPlayNoReplyRequest,
9867                            fidl::encoding::DefaultFuchsiaResourceDialect
9868                        );
9869                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9870                        let control_handle =
9871                            AudioRendererControlHandle { inner: this.inner.clone() };
9872                        Ok(AudioRendererRequest::PlayNoReply {
9873                            reference_time: req.reference_time,
9874                            media_time: req.media_time,
9875
9876                            control_handle,
9877                        })
9878                    }
9879                    0x41d557588d93d153 => {
9880                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9881                        let mut req = fidl::new_empty!(
9882                            fidl::encoding::EmptyPayload,
9883                            fidl::encoding::DefaultFuchsiaResourceDialect
9884                        );
9885                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9886                        let control_handle =
9887                            AudioRendererControlHandle { inner: this.inner.clone() };
9888                        Ok(AudioRendererRequest::Pause {
9889                            responder: AudioRendererPauseResponder {
9890                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9891                                tx_id: header.tx_id,
9892                            },
9893                        })
9894                    }
9895                    0x24cc45d4f3855ab => {
9896                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9897                        let mut req = fidl::new_empty!(
9898                            fidl::encoding::EmptyPayload,
9899                            fidl::encoding::DefaultFuchsiaResourceDialect
9900                        );
9901                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9902                        let control_handle =
9903                            AudioRendererControlHandle { inner: this.inner.clone() };
9904                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9905                    }
9906                    _ if header.tx_id == 0
9907                        && header
9908                            .dynamic_flags()
9909                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9910                    {
9911                        Ok(AudioRendererRequest::_UnknownMethod {
9912                            ordinal: header.ordinal,
9913                            control_handle: AudioRendererControlHandle {
9914                                inner: this.inner.clone(),
9915                            },
9916                            method_type: fidl::MethodType::OneWay,
9917                        })
9918                    }
9919                    _ if header
9920                        .dynamic_flags()
9921                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9922                    {
9923                        this.inner.send_framework_err(
9924                            fidl::encoding::FrameworkErr::UnknownMethod,
9925                            header.tx_id,
9926                            header.ordinal,
9927                            header.dynamic_flags(),
9928                            (bytes, handles),
9929                        )?;
9930                        Ok(AudioRendererRequest::_UnknownMethod {
9931                            ordinal: header.ordinal,
9932                            control_handle: AudioRendererControlHandle {
9933                                inner: this.inner.clone(),
9934                            },
9935                            method_type: fidl::MethodType::TwoWay,
9936                        })
9937                    }
9938                    _ => Err(fidl::Error::UnknownOrdinal {
9939                        ordinal: header.ordinal,
9940                        protocol_name:
9941                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9942                    }),
9943                }))
9944            },
9945        )
9946    }
9947}
9948
9949/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9950/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9951/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9952/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9953/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9954/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9955///
9956/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9957/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9958/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9959/// to reconfiguring the renderer.
9960#[derive(Debug)]
9961pub enum AudioRendererRequest {
9962    /// Adds a payload buffer to the current buffer set associated with the
9963    /// connection. A `StreamPacket` struct reference a payload buffer in the
9964    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
9965    ///
9966    /// A buffer with ID `id` must not be in the current set when this method is
9967    /// invoked, otherwise the service will close the connection.
9968    AddPayloadBuffer {
9969        id: u32,
9970        payload_buffer: fidl::Vmo,
9971        control_handle: AudioRendererControlHandle,
9972    },
9973    /// Removes a payload buffer from the current buffer set associated with the
9974    /// connection.
9975    ///
9976    /// A buffer with ID `id` must exist in the current set when this method is
9977    /// invoked, otherwise the service will will close the connection.
9978    RemovePayloadBuffer {
9979        id: u32,
9980        control_handle: AudioRendererControlHandle,
9981    },
9982    /// Sends a packet to the service. The response is sent when the service is
9983    /// done with the associated payload memory.
9984    ///
9985    /// `packet` must be valid for the current buffer set, otherwise the service
9986    /// will close the connection.
9987    SendPacket {
9988        packet: StreamPacket,
9989        responder: AudioRendererSendPacketResponder,
9990    },
9991    /// Sends a packet to the service. This interface doesn't define how the
9992    /// client knows when the sink is done with the associated payload memory.
9993    /// The inheriting interface must define that.
9994    ///
9995    /// `packet` must be valid for the current buffer set, otherwise the service
9996    /// will close the connection.
9997    SendPacketNoReply {
9998        packet: StreamPacket,
9999        control_handle: AudioRendererControlHandle,
10000    },
10001    /// Indicates the stream has ended. The precise semantics of this method are
10002    /// determined by the inheriting interface.
10003    EndOfStream {
10004        control_handle: AudioRendererControlHandle,
10005    },
10006    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10007    /// and not yet released. The response is sent after all packets have been
10008    /// released.
10009    DiscardAllPackets {
10010        responder: AudioRendererDiscardAllPacketsResponder,
10011    },
10012    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10013    /// and not yet released.
10014    DiscardAllPacketsNoReply {
10015        control_handle: AudioRendererControlHandle,
10016    },
10017    /// Binds to the gain control for this AudioRenderer.
10018    BindGainControl {
10019        gain_control_request:
10020            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10021        control_handle: AudioRendererControlHandle,
10022    },
10023    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
10024    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
10025    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
10026    SetPtsUnits {
10027        tick_per_second_numerator: u32,
10028        tick_per_second_denominator: u32,
10029        control_handle: AudioRendererControlHandle,
10030    },
10031    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
10032    /// and expected PTS (determined using interpolation). Beyond this threshold,
10033    /// a stream is no longer considered 'continuous' by the renderer.
10034    ///
10035    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
10036    /// Most users should not need to change this value from its default.
10037    ///
10038    /// Example:
10039    /// A user is playing back 48KHz audio from a container, which also contains
10040    /// video and needs to be synchronized with the audio. The timestamps are
10041    /// provided explicitly per packet by the container, and expressed in mSec
10042    /// units. This means that a single tick of the media timeline (1 mSec)
10043    /// represents exactly 48 frames of audio. The application in this scenario
10044    /// delivers packets of audio to the AudioRenderer, each with exactly 470
10045    /// frames of audio, and each with an explicit timestamp set to the best
10046    /// possible representation of the presentation time (given this media
10047    /// clock's resolution). So, starting from zero, the timestamps would be..
10048    ///
10049    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
10050    ///
10051    /// In this example, attempting to use the presentation time to compute the
10052    /// starting frame number of the audio in the packet would be wrong the
10053    /// majority of the time. The first timestamp is correct (by definition), but
10054    /// it will be 24 packets before the timestamps and frame numbers come back
10055    /// into alignment (the 24th packet would start with the 11280th audio frame
10056    /// and have a PTS of exactly 235).
10057    ///
10058    /// One way to fix this situation is to set the PTS continuity threshold
10059    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
10060    /// the number of frames contained within a single tick of the media clock,
10061    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
10062    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
10063    /// explicitly provided PTS would be considered to be a continuation of the
10064    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
10065    /// would work well.
10066    ///
10067    /// Other possible uses:
10068    /// Users who are scheduling audio explicitly, relative to a clock which has
10069    /// not been configured as the reference clock, can use this value to control
10070    /// the maximum acceptable synchronization error before a discontinuity is
10071    /// introduced. E.g., if a user is scheduling audio based on a recovered
10072    /// common media clock, and has not published that clock as the reference
10073    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
10074    /// can accumulate before the AudioRenderer deliberately inserts a
10075    /// presentation discontinuity to account for the error.
10076    ///
10077    /// Users whose need to deal with a container where their timestamps may be
10078    /// even less correct than +/- 1/2 of a PTS tick may set this value to
10079    /// something larger. This should be the maximum level of inaccuracy present
10080    /// in the container timestamps, if known. Failing that, it could be set to
10081    /// the maximum tolerable level of drift error before absolute timestamps are
10082    /// explicitly obeyed. Finally, a user could set this number to a very large
10083    /// value (86400.0 seconds, for example) to effectively cause *all*
10084    /// timestamps to be ignored after the first, thus treating all audio as
10085    /// continuous with previously delivered packets. Conversely, users who wish
10086    /// to *always* explicitly schedule their audio packets exactly may specify
10087    /// a CT of 0.
10088    ///
10089    /// Note: explicitly specifying high-frequency PTS units reduces the default
10090    /// continuity threshold accordingly. Internally, this threshold is stored as an
10091    /// integer of 1/8192 subframes. The default threshold is computed as follows:
10092    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
10093    /// For this reason, specifying PTS units with a frequency greater than 8192x
10094    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
10095    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
10096    SetPtsContinuityThreshold {
10097        threshold_seconds: f32,
10098        control_handle: AudioRendererControlHandle,
10099    },
10100    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
10101    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
10102    GetReferenceClock {
10103        responder: AudioRendererGetReferenceClockResponder,
10104    },
10105    /// Sets the reference clock that controls this renderer's playback rate. If the input
10106    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
10107    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
10108    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
10109    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
10110    ///
10111    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
10112    /// cannot be called a second time (even if the renderer format has not yet been set).
10113    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
10114    /// diverge at some later time, they should create a clone of the monotonic clock, set
10115    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
10116    SetReferenceClock {
10117        reference_clock: Option<fidl::Clock>,
10118        control_handle: AudioRendererControlHandle,
10119    },
10120    /// Sets the usage of the render stream. This method may not be called after
10121    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
10122    SetUsage {
10123        usage: AudioRenderUsage,
10124        control_handle: AudioRendererControlHandle,
10125    },
10126    /// Sets the usage of the render stream. This method may not be called after
10127    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
10128    SetUsage2 {
10129        usage2: AudioRenderUsage2,
10130        control_handle: AudioRendererControlHandle,
10131    },
10132    /// Sets the type of the stream to be delivered by the client. Using this method implies
10133    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
10134    ///
10135    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
10136    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
10137    /// methods such as `SendPacket`/`SendPacketNoReply`.
10138    SetPcmStreamType {
10139        type_: AudioStreamType,
10140        control_handle: AudioRendererControlHandle,
10141    },
10142    /// Enables or disables notifications about changes to the minimum clock lead
10143    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
10144    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
10145    /// event with the current minimum lead time for the AudioRenderer. If the
10146    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
10147    /// new value. This behavior will continue until the user calls
10148    /// `EnableMinLeadTimeEvents(false)`.
10149    ///
10150    /// The minimum clock lead time is the amount of time ahead of the reference
10151    /// clock's understanding of "now" that packets needs to arrive (relative to
10152    /// the playback clock transformation) in order for the mixer to be able to
10153    /// mix packet. For example...
10154    ///
10155    /// + Let the PTS of packet X be P(X)
10156    /// + Let the function which transforms PTS -> RefClock be R(p) (this
10157    ///   function is determined by the call to Play(...)
10158    /// + Let the minimum lead time be MLT
10159    ///
10160    /// If R(P(X)) < RefClock.Now() + MLT
10161    /// Then the packet is late, and some (or all) of the packet's payload will
10162    /// need to be skipped in order to present the packet at the scheduled time.
10163    ///
10164    /// The value `min_lead_time_nsec = 0` is a special value which indicates
10165    /// that the AudioRenderer is not yet routed to an output device. If `Play`
10166    /// is called before the AudioRenderer is routed, any played packets will be
10167    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
10168    /// calling `Play`.
10169    EnableMinLeadTimeEvents {
10170        enabled: bool,
10171        control_handle: AudioRendererControlHandle,
10172    },
10173    ///
10174    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
10175    /// there's little reason to do so. This is because lead time is a function
10176    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
10177    /// If min lead time events are enabled before `SetPcmStreamType` (with
10178    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
10179    /// response to `SetPcmStreamType`.
10180    GetMinLeadTime {
10181        responder: AudioRendererGetMinLeadTimeResponder,
10182    },
10183    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
10184    /// of the media timeline, using specific values provided by the caller (or
10185    /// default values if not specified). In an optional callback, returns the
10186    /// timestamp values ultimately used -- these set the ongoing relationship
10187    /// between the media and reference timelines (i.e., how to translate between
10188    /// the domain of presentation timestamps, and the realm of local system
10189    /// time).
10190    ///
10191    /// Local system time is specified in units of nanoseconds; media_time is
10192    /// specified in the units defined by the user in the `SetPtsUnits` function,
10193    /// or nanoseconds if `SetPtsUnits` is not called.
10194    ///
10195    /// The act of placing an AudioRenderer into the playback state establishes a
10196    /// relationship between 1) the user-defined media (or presentation) timeline
10197    /// for this particular AudioRenderer, and 2) the real-world system reference
10198    /// timeline. To communicate how to translate between timelines, the Play()
10199    /// callback provides an equivalent timestamp in each time domain. The first
10200    /// value ('reference_time') is given in terms of this renderer's reference
10201    /// clock; the second value ('media_time') is what media instant exactly
10202    /// corresponds to that local time. Restated, the frame at 'media_time' in
10203    /// the audio stream should be presented at 'reference_time' according to
10204    /// the reference clock.
10205    ///
10206    /// Note: on calling this API, media_time immediately starts advancing. It is
10207    /// possible (if uncommon) for a caller to specify a system time that is
10208    /// far in the past, or far into the future. This, along with the specified
10209    /// media time, is simply used to determine what media time corresponds to
10210    /// 'now', and THAT media time is then intersected with presentation
10211    /// timestamps of packets already submitted, to determine which media frames
10212    /// should be presented next.
10213    ///
10214    /// With the corresponding reference_time and media_time values, a user can
10215    /// translate arbitrary time values from one timeline into the other. After
10216    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
10217    /// given the 'ref_start' and 'media_start' values from `Play`, then for
10218    /// any 'ref_time':
10219    ///
10220    /// media_time = ( (ref_time - ref_start) / 1e9
10221    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
10222    ///              + media_start
10223    ///
10224    /// Conversely, for any presentation timestamp 'media_time':
10225    ///
10226    /// ref_time = ( (media_time - media_start)
10227    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
10228    ///              * 1e9 )
10229    ///            + ref_start
10230    ///
10231    /// Users, depending on their use case, may optionally choose not to specify
10232    /// one or both of these timestamps. A timestamp may be omitted by supplying
10233    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
10234    /// any omitted timestamp value using the following rules:
10235    ///
10236    /// Reference Time
10237    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
10238    /// reference time to begin presentation, based on the minimum lead times for
10239    /// the output devices that are currently bound to this AudioRenderer. For
10240    /// example, if an AudioRenderer is bound to an internal audio output
10241    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
10242    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
10243    /// is omitted) select a reference time 80 mSec from now.
10244    ///
10245    /// Media Time
10246    /// If media_time is omitted, the AudioRenderer will select one of two
10247    /// values.
10248    /// - If the AudioRenderer is resuming from the paused state, and packets
10249    /// have not been discarded since being paused, then the AudioRenderer will
10250    /// use a media_time corresponding to the instant at which the presentation
10251    /// became paused.
10252    /// - If the AudioRenderer is being placed into a playing state for the first
10253    /// time following startup or a 'discard packets' operation, the initial
10254    /// media_time will be set to the PTS of the first payload in the pending
10255    /// packet queue. If the pending queue is empty, initial media_time will be
10256    /// set to zero.
10257    ///
10258    /// Return Value
10259    /// When requested, the AudioRenderer will return the 'reference_time' and
10260    /// 'media_time' which were selected and used (whether they were explicitly
10261    /// specified or not) in the return value of the play call.
10262    ///
10263    /// Examples
10264    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
10265    /// to start playing as soon as possible. The user may call Play without
10266    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
10267    ///
10268    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
10269    /// playback at a specified 'reference_time', in sync with some other media
10270    /// stream, either initially or after discarding packets. The user would call
10271    /// `Play(reference_time, NO_TIMESTAMP)`.
10272    ///
10273    /// 3. A user has queued some audio using `SendPacket`. The first of these
10274    /// packets has a PTS of zero, and the user wishes playback to begin as soon
10275    /// as possible, but wishes to skip all of the audio content between PTS 0
10276    /// and PTS 'media_time'. The user would call
10277    /// `Play(NO_TIMESTAMP, media_time)`.
10278    ///
10279    /// 4. A user has queued some audio using `SendPacket` and want to present
10280    /// this media in synch with another player in a different device. The
10281    /// coordinator of the group of distributed players sends an explicit
10282    /// message to each player telling them to begin presentation of audio at
10283    /// PTS 'media_time', at the time (based on the group's shared reference
10284    /// clock) 'reference_time'. Here the user would call
10285    /// `Play(reference_time, media_time)`.
10286    Play {
10287        reference_time: i64,
10288        media_time: i64,
10289        responder: AudioRendererPlayResponder,
10290    },
10291    PlayNoReply {
10292        reference_time: i64,
10293        media_time: i64,
10294        control_handle: AudioRendererControlHandle,
10295    },
10296    /// Immediately puts the AudioRenderer into the paused state and then report
10297    /// the relationship between the media and reference timelines which was
10298    /// established (if requested).
10299    ///
10300    /// If the AudioRenderer is already in the paused state when this called,
10301    /// the previously-established timeline values are returned (if requested).
10302    Pause {
10303        responder: AudioRendererPauseResponder,
10304    },
10305    PauseNoReply {
10306        control_handle: AudioRendererControlHandle,
10307    },
10308    /// An interaction was received which does not match any known method.
10309    #[non_exhaustive]
10310    _UnknownMethod {
10311        /// Ordinal of the method that was called.
10312        ordinal: u64,
10313        control_handle: AudioRendererControlHandle,
10314        method_type: fidl::MethodType,
10315    },
10316}
10317
10318impl AudioRendererRequest {
10319    #[allow(irrefutable_let_patterns)]
10320    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
10321        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10322        {
10323            Some((id, payload_buffer, control_handle))
10324        } else {
10325            None
10326        }
10327    }
10328
10329    #[allow(irrefutable_let_patterns)]
10330    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10331        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10332            Some((id, control_handle))
10333        } else {
10334            None
10335        }
10336    }
10337
10338    #[allow(irrefutable_let_patterns)]
10339    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10340        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10341            Some((packet, responder))
10342        } else {
10343            None
10344        }
10345    }
10346
10347    #[allow(irrefutable_let_patterns)]
10348    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10349        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10350            Some((packet, control_handle))
10351        } else {
10352            None
10353        }
10354    }
10355
10356    #[allow(irrefutable_let_patterns)]
10357    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10358        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10359            Some((control_handle))
10360        } else {
10361            None
10362        }
10363    }
10364
10365    #[allow(irrefutable_let_patterns)]
10366    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10367        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10368            Some((responder))
10369        } else {
10370            None
10371        }
10372    }
10373
10374    #[allow(irrefutable_let_patterns)]
10375    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10376        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10377            Some((control_handle))
10378        } else {
10379            None
10380        }
10381    }
10382
10383    #[allow(irrefutable_let_patterns)]
10384    pub fn into_bind_gain_control(
10385        self,
10386    ) -> Option<(
10387        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10388        AudioRendererControlHandle,
10389    )> {
10390        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10391        {
10392            Some((gain_control_request, control_handle))
10393        } else {
10394            None
10395        }
10396    }
10397
10398    #[allow(irrefutable_let_patterns)]
10399    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10400        if let AudioRendererRequest::SetPtsUnits {
10401            tick_per_second_numerator,
10402            tick_per_second_denominator,
10403            control_handle,
10404        } = self
10405        {
10406            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10407        } else {
10408            None
10409        }
10410    }
10411
10412    #[allow(irrefutable_let_patterns)]
10413    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10414        if let AudioRendererRequest::SetPtsContinuityThreshold {
10415            threshold_seconds,
10416            control_handle,
10417        } = self
10418        {
10419            Some((threshold_seconds, control_handle))
10420        } else {
10421            None
10422        }
10423    }
10424
10425    #[allow(irrefutable_let_patterns)]
10426    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10427        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10428            Some((responder))
10429        } else {
10430            None
10431        }
10432    }
10433
10434    #[allow(irrefutable_let_patterns)]
10435    pub fn into_set_reference_clock(
10436        self,
10437    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10438        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10439            Some((reference_clock, control_handle))
10440        } else {
10441            None
10442        }
10443    }
10444
10445    #[allow(irrefutable_let_patterns)]
10446    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10447        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10448            Some((usage, control_handle))
10449        } else {
10450            None
10451        }
10452    }
10453
10454    #[allow(irrefutable_let_patterns)]
10455    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10456        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10457            Some((usage2, control_handle))
10458        } else {
10459            None
10460        }
10461    }
10462
10463    #[allow(irrefutable_let_patterns)]
10464    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10465        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10466            Some((type_, control_handle))
10467        } else {
10468            None
10469        }
10470    }
10471
10472    #[allow(irrefutable_let_patterns)]
10473    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10474        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10475            Some((enabled, control_handle))
10476        } else {
10477            None
10478        }
10479    }
10480
10481    #[allow(irrefutable_let_patterns)]
10482    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10483        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10484            Some((responder))
10485        } else {
10486            None
10487        }
10488    }
10489
10490    #[allow(irrefutable_let_patterns)]
10491    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10492        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10493            Some((reference_time, media_time, responder))
10494        } else {
10495            None
10496        }
10497    }
10498
10499    #[allow(irrefutable_let_patterns)]
10500    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10501        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10502            self
10503        {
10504            Some((reference_time, media_time, control_handle))
10505        } else {
10506            None
10507        }
10508    }
10509
10510    #[allow(irrefutable_let_patterns)]
10511    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10512        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
10513    }
10514
10515    #[allow(irrefutable_let_patterns)]
10516    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10517        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10518            Some((control_handle))
10519        } else {
10520            None
10521        }
10522    }
10523
10524    /// Name of the method defined in FIDL
10525    pub fn method_name(&self) -> &'static str {
10526        match *self {
10527            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10528            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10529            AudioRendererRequest::SendPacket { .. } => "send_packet",
10530            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10531            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10532            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10533            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10534            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10535            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10536            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10537                "set_pts_continuity_threshold"
10538            }
10539            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10540            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10541            AudioRendererRequest::SetUsage { .. } => "set_usage",
10542            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10543            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10544            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10545            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10546            AudioRendererRequest::Play { .. } => "play",
10547            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10548            AudioRendererRequest::Pause { .. } => "pause",
10549            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10550            AudioRendererRequest::_UnknownMethod {
10551                method_type: fidl::MethodType::OneWay, ..
10552            } => "unknown one-way method",
10553            AudioRendererRequest::_UnknownMethod {
10554                method_type: fidl::MethodType::TwoWay, ..
10555            } => "unknown two-way method",
10556        }
10557    }
10558}
10559
10560#[derive(Debug, Clone)]
10561pub struct AudioRendererControlHandle {
10562    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10563}
10564
10565impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10566    fn shutdown(&self) {
10567        self.inner.shutdown()
10568    }
10569
10570    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10571        self.inner.shutdown_with_epitaph(status)
10572    }
10573
10574    fn is_closed(&self) -> bool {
10575        self.inner.channel().is_closed()
10576    }
10577    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10578        self.inner.channel().on_closed()
10579    }
10580
10581    #[cfg(target_os = "fuchsia")]
10582    fn signal_peer(
10583        &self,
10584        clear_mask: zx::Signals,
10585        set_mask: zx::Signals,
10586    ) -> Result<(), zx_status::Status> {
10587        use fidl::Peered;
10588        self.inner.channel().signal_peer(clear_mask, set_mask)
10589    }
10590}
10591
10592impl AudioRendererControlHandle {
10593    pub fn send_on_min_lead_time_changed(
10594        &self,
10595        mut min_lead_time_nsec: i64,
10596    ) -> Result<(), fidl::Error> {
10597        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10598            (min_lead_time_nsec,),
10599            0,
10600            0x4feff7d278978c4e,
10601            fidl::encoding::DynamicFlags::empty(),
10602        )
10603    }
10604}
10605
10606#[must_use = "FIDL methods require a response to be sent"]
10607#[derive(Debug)]
10608pub struct AudioRendererSendPacketResponder {
10609    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10610    tx_id: u32,
10611}
10612
10613/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10614/// if the responder is dropped without sending a response, so that the client
10615/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10616impl std::ops::Drop for AudioRendererSendPacketResponder {
10617    fn drop(&mut self) {
10618        self.control_handle.shutdown();
10619        // Safety: drops once, never accessed again
10620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10621    }
10622}
10623
10624impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10625    type ControlHandle = AudioRendererControlHandle;
10626
10627    fn control_handle(&self) -> &AudioRendererControlHandle {
10628        &self.control_handle
10629    }
10630
10631    fn drop_without_shutdown(mut self) {
10632        // Safety: drops once, never accessed again due to mem::forget
10633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10634        // Prevent Drop from running (which would shut down the channel)
10635        std::mem::forget(self);
10636    }
10637}
10638
10639impl AudioRendererSendPacketResponder {
10640    /// Sends a response to the FIDL transaction.
10641    ///
10642    /// Sets the channel to shutdown if an error occurs.
10643    pub fn send(self) -> Result<(), fidl::Error> {
10644        let _result = self.send_raw();
10645        if _result.is_err() {
10646            self.control_handle.shutdown();
10647        }
10648        self.drop_without_shutdown();
10649        _result
10650    }
10651
10652    /// Similar to "send" but does not shutdown the channel if an error occurs.
10653    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10654        let _result = self.send_raw();
10655        self.drop_without_shutdown();
10656        _result
10657    }
10658
10659    fn send_raw(&self) -> Result<(), fidl::Error> {
10660        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10661            (),
10662            self.tx_id,
10663            0x67cddd607442775f,
10664            fidl::encoding::DynamicFlags::empty(),
10665        )
10666    }
10667}
10668
10669#[must_use = "FIDL methods require a response to be sent"]
10670#[derive(Debug)]
10671pub struct AudioRendererDiscardAllPacketsResponder {
10672    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10673    tx_id: u32,
10674}
10675
10676/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10677/// if the responder is dropped without sending a response, so that the client
10678/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10679impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10680    fn drop(&mut self) {
10681        self.control_handle.shutdown();
10682        // Safety: drops once, never accessed again
10683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10684    }
10685}
10686
10687impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10688    type ControlHandle = AudioRendererControlHandle;
10689
10690    fn control_handle(&self) -> &AudioRendererControlHandle {
10691        &self.control_handle
10692    }
10693
10694    fn drop_without_shutdown(mut self) {
10695        // Safety: drops once, never accessed again due to mem::forget
10696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10697        // Prevent Drop from running (which would shut down the channel)
10698        std::mem::forget(self);
10699    }
10700}
10701
10702impl AudioRendererDiscardAllPacketsResponder {
10703    /// Sends a response to the FIDL transaction.
10704    ///
10705    /// Sets the channel to shutdown if an error occurs.
10706    pub fn send(self) -> Result<(), fidl::Error> {
10707        let _result = self.send_raw();
10708        if _result.is_err() {
10709            self.control_handle.shutdown();
10710        }
10711        self.drop_without_shutdown();
10712        _result
10713    }
10714
10715    /// Similar to "send" but does not shutdown the channel if an error occurs.
10716    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10717        let _result = self.send_raw();
10718        self.drop_without_shutdown();
10719        _result
10720    }
10721
10722    fn send_raw(&self) -> Result<(), fidl::Error> {
10723        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10724            (),
10725            self.tx_id,
10726            0x6f4dad7af2917665,
10727            fidl::encoding::DynamicFlags::empty(),
10728        )
10729    }
10730}
10731
10732#[must_use = "FIDL methods require a response to be sent"]
10733#[derive(Debug)]
10734pub struct AudioRendererGetReferenceClockResponder {
10735    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10736    tx_id: u32,
10737}
10738
10739/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10740/// if the responder is dropped without sending a response, so that the client
10741/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10742impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10743    fn drop(&mut self) {
10744        self.control_handle.shutdown();
10745        // Safety: drops once, never accessed again
10746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10747    }
10748}
10749
10750impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10751    type ControlHandle = AudioRendererControlHandle;
10752
10753    fn control_handle(&self) -> &AudioRendererControlHandle {
10754        &self.control_handle
10755    }
10756
10757    fn drop_without_shutdown(mut self) {
10758        // Safety: drops once, never accessed again due to mem::forget
10759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10760        // Prevent Drop from running (which would shut down the channel)
10761        std::mem::forget(self);
10762    }
10763}
10764
10765impl AudioRendererGetReferenceClockResponder {
10766    /// Sends a response to the FIDL transaction.
10767    ///
10768    /// Sets the channel to shutdown if an error occurs.
10769    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10770        let _result = self.send_raw(reference_clock);
10771        if _result.is_err() {
10772            self.control_handle.shutdown();
10773        }
10774        self.drop_without_shutdown();
10775        _result
10776    }
10777
10778    /// Similar to "send" but does not shutdown the channel if an error occurs.
10779    pub fn send_no_shutdown_on_err(
10780        self,
10781        mut reference_clock: fidl::Clock,
10782    ) -> Result<(), fidl::Error> {
10783        let _result = self.send_raw(reference_clock);
10784        self.drop_without_shutdown();
10785        _result
10786    }
10787
10788    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10789        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10790            (reference_clock,),
10791            self.tx_id,
10792            0x2f7a7f011a172f7e,
10793            fidl::encoding::DynamicFlags::empty(),
10794        )
10795    }
10796}
10797
10798#[must_use = "FIDL methods require a response to be sent"]
10799#[derive(Debug)]
10800pub struct AudioRendererGetMinLeadTimeResponder {
10801    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10802    tx_id: u32,
10803}
10804
10805/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10806/// if the responder is dropped without sending a response, so that the client
10807/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10808impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10809    fn drop(&mut self) {
10810        self.control_handle.shutdown();
10811        // Safety: drops once, never accessed again
10812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10813    }
10814}
10815
10816impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10817    type ControlHandle = AudioRendererControlHandle;
10818
10819    fn control_handle(&self) -> &AudioRendererControlHandle {
10820        &self.control_handle
10821    }
10822
10823    fn drop_without_shutdown(mut self) {
10824        // Safety: drops once, never accessed again due to mem::forget
10825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10826        // Prevent Drop from running (which would shut down the channel)
10827        std::mem::forget(self);
10828    }
10829}
10830
10831impl AudioRendererGetMinLeadTimeResponder {
10832    /// Sends a response to the FIDL transaction.
10833    ///
10834    /// Sets the channel to shutdown if an error occurs.
10835    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10836        let _result = self.send_raw(min_lead_time_nsec);
10837        if _result.is_err() {
10838            self.control_handle.shutdown();
10839        }
10840        self.drop_without_shutdown();
10841        _result
10842    }
10843
10844    /// Similar to "send" but does not shutdown the channel if an error occurs.
10845    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10846        let _result = self.send_raw(min_lead_time_nsec);
10847        self.drop_without_shutdown();
10848        _result
10849    }
10850
10851    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10852        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10853            (min_lead_time_nsec,),
10854            self.tx_id,
10855            0x1cf3c3ecd8fec26b,
10856            fidl::encoding::DynamicFlags::empty(),
10857        )
10858    }
10859}
10860
10861#[must_use = "FIDL methods require a response to be sent"]
10862#[derive(Debug)]
10863pub struct AudioRendererPlayResponder {
10864    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10865    tx_id: u32,
10866}
10867
10868/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10869/// if the responder is dropped without sending a response, so that the client
10870/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10871impl std::ops::Drop for AudioRendererPlayResponder {
10872    fn drop(&mut self) {
10873        self.control_handle.shutdown();
10874        // Safety: drops once, never accessed again
10875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10876    }
10877}
10878
10879impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10880    type ControlHandle = AudioRendererControlHandle;
10881
10882    fn control_handle(&self) -> &AudioRendererControlHandle {
10883        &self.control_handle
10884    }
10885
10886    fn drop_without_shutdown(mut self) {
10887        // Safety: drops once, never accessed again due to mem::forget
10888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10889        // Prevent Drop from running (which would shut down the channel)
10890        std::mem::forget(self);
10891    }
10892}
10893
10894impl AudioRendererPlayResponder {
10895    /// Sends a response to the FIDL transaction.
10896    ///
10897    /// Sets the channel to shutdown if an error occurs.
10898    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10899        let _result = self.send_raw(reference_time, media_time);
10900        if _result.is_err() {
10901            self.control_handle.shutdown();
10902        }
10903        self.drop_without_shutdown();
10904        _result
10905    }
10906
10907    /// Similar to "send" but does not shutdown the channel if an error occurs.
10908    pub fn send_no_shutdown_on_err(
10909        self,
10910        mut reference_time: i64,
10911        mut media_time: i64,
10912    ) -> Result<(), fidl::Error> {
10913        let _result = self.send_raw(reference_time, media_time);
10914        self.drop_without_shutdown();
10915        _result
10916    }
10917
10918    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10919        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10920            (reference_time, media_time),
10921            self.tx_id,
10922            0x3c0162db084f74a3,
10923            fidl::encoding::DynamicFlags::empty(),
10924        )
10925    }
10926}
10927
10928#[must_use = "FIDL methods require a response to be sent"]
10929#[derive(Debug)]
10930pub struct AudioRendererPauseResponder {
10931    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10932    tx_id: u32,
10933}
10934
10935/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10936/// if the responder is dropped without sending a response, so that the client
10937/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10938impl std::ops::Drop for AudioRendererPauseResponder {
10939    fn drop(&mut self) {
10940        self.control_handle.shutdown();
10941        // Safety: drops once, never accessed again
10942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10943    }
10944}
10945
10946impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10947    type ControlHandle = AudioRendererControlHandle;
10948
10949    fn control_handle(&self) -> &AudioRendererControlHandle {
10950        &self.control_handle
10951    }
10952
10953    fn drop_without_shutdown(mut self) {
10954        // Safety: drops once, never accessed again due to mem::forget
10955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10956        // Prevent Drop from running (which would shut down the channel)
10957        std::mem::forget(self);
10958    }
10959}
10960
10961impl AudioRendererPauseResponder {
10962    /// Sends a response to the FIDL transaction.
10963    ///
10964    /// Sets the channel to shutdown if an error occurs.
10965    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10966        let _result = self.send_raw(reference_time, media_time);
10967        if _result.is_err() {
10968            self.control_handle.shutdown();
10969        }
10970        self.drop_without_shutdown();
10971        _result
10972    }
10973
10974    /// Similar to "send" but does not shutdown the channel if an error occurs.
10975    pub fn send_no_shutdown_on_err(
10976        self,
10977        mut reference_time: i64,
10978        mut media_time: i64,
10979    ) -> Result<(), fidl::Error> {
10980        let _result = self.send_raw(reference_time, media_time);
10981        self.drop_without_shutdown();
10982        _result
10983    }
10984
10985    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10986        self.control_handle.inner.send::<AudioRendererPauseResponse>(
10987            (reference_time, media_time),
10988            self.tx_id,
10989            0x41d557588d93d153,
10990            fidl::encoding::DynamicFlags::empty(),
10991        )
10992    }
10993}
10994
10995#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10996pub struct ProfileProviderMarker;
10997
10998impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
10999    type Proxy = ProfileProviderProxy;
11000    type RequestStream = ProfileProviderRequestStream;
11001    #[cfg(target_os = "fuchsia")]
11002    type SynchronousProxy = ProfileProviderSynchronousProxy;
11003
11004    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
11005}
11006impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
11007
11008pub trait ProfileProviderProxyInterface: Send + Sync {
11009    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
11010        + Send;
11011    fn r#register_handler_with_capacity(
11012        &self,
11013        thread_handle: fidl::Thread,
11014        name: &str,
11015        period: i64,
11016        capacity: f32,
11017    ) -> Self::RegisterHandlerWithCapacityResponseFut;
11018    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11019    fn r#unregister_handler(
11020        &self,
11021        thread_handle: fidl::Thread,
11022        name: &str,
11023    ) -> Self::UnregisterHandlerResponseFut;
11024    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
11025        + Send;
11026    fn r#register_memory_range(
11027        &self,
11028        vmar_handle: fidl::Vmar,
11029        name: &str,
11030    ) -> Self::RegisterMemoryRangeResponseFut;
11031    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
11032        + Send;
11033    fn r#unregister_memory_range(
11034        &self,
11035        vmar_handle: fidl::Vmar,
11036    ) -> Self::UnregisterMemoryRangeResponseFut;
11037}
11038#[derive(Debug)]
11039#[cfg(target_os = "fuchsia")]
11040pub struct ProfileProviderSynchronousProxy {
11041    client: fidl::client::sync::Client,
11042}
11043
11044#[cfg(target_os = "fuchsia")]
11045impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
11046    type Proxy = ProfileProviderProxy;
11047    type Protocol = ProfileProviderMarker;
11048
11049    fn from_channel(inner: fidl::Channel) -> Self {
11050        Self::new(inner)
11051    }
11052
11053    fn into_channel(self) -> fidl::Channel {
11054        self.client.into_channel()
11055    }
11056
11057    fn as_channel(&self) -> &fidl::Channel {
11058        self.client.as_channel()
11059    }
11060}
11061
11062#[cfg(target_os = "fuchsia")]
11063impl ProfileProviderSynchronousProxy {
11064    pub fn new(channel: fidl::Channel) -> Self {
11065        Self { client: fidl::client::sync::Client::new(channel) }
11066    }
11067
11068    pub fn into_channel(self) -> fidl::Channel {
11069        self.client.into_channel()
11070    }
11071
11072    /// Waits until an event arrives and returns it. It is safe for other
11073    /// threads to make concurrent requests while waiting for an event.
11074    pub fn wait_for_event(
11075        &self,
11076        deadline: zx::MonotonicInstant,
11077    ) -> Result<ProfileProviderEvent, fidl::Error> {
11078        ProfileProviderEvent::decode(self.client.wait_for_event::<ProfileProviderMarker>(deadline)?)
11079    }
11080
11081    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11082    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11083    /// deadlines.
11084    ///
11085    /// `name` is the name of a system scheduling role to apply to the thread given by
11086    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11087    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11088    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11089    /// the scheduling interval the thread needs to be running to achieve good performance or to
11090    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11091    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11092    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11093    /// be rejected or result in scaling back the performance of other threads to fit resource
11094    /// limits.
11095    ///
11096    /// Capacity, max runtime, and period have the following relationship:
11097    ///
11098    ///   capacity = max runtime / period
11099    ///
11100    /// Where:
11101    ///
11102    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11103    ///
11104    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11105    /// performance processor(s) in the system. The system will automatically adjust the effective
11106    /// capacity to account for slower processors and operating points and will avoid processors and
11107    /// operating points that are too slow to meet the requested scheduling parameters (provided
11108    /// they are reasonable).
11109    ///
11110    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11111    /// may be zero to indicate not applicable.
11112    pub fn r#register_handler_with_capacity(
11113        &self,
11114        mut thread_handle: fidl::Thread,
11115        mut name: &str,
11116        mut period: i64,
11117        mut capacity: f32,
11118        ___deadline: zx::MonotonicInstant,
11119    ) -> Result<(i64, i64), fidl::Error> {
11120        let _response = self.client.send_query::<
11121            ProfileProviderRegisterHandlerWithCapacityRequest,
11122            ProfileProviderRegisterHandlerWithCapacityResponse,
11123            ProfileProviderMarker,
11124        >(
11125            (thread_handle, name, period, capacity,),
11126            0x60459ecef7458176,
11127            fidl::encoding::DynamicFlags::empty(),
11128            ___deadline,
11129        )?;
11130        Ok((_response.period, _response.capacity))
11131    }
11132
11133    /// Reset a thread's scheduling profile to the default.
11134    pub fn r#unregister_handler(
11135        &self,
11136        mut thread_handle: fidl::Thread,
11137        mut name: &str,
11138        ___deadline: zx::MonotonicInstant,
11139    ) -> Result<(), fidl::Error> {
11140        let _response = self.client.send_query::<
11141            ProfileProviderUnregisterHandlerRequest,
11142            fidl::encoding::EmptyPayload,
11143            ProfileProviderMarker,
11144        >(
11145            (thread_handle, name,),
11146            0x724d9d5fd8ef544c,
11147            fidl::encoding::DynamicFlags::empty(),
11148            ___deadline,
11149        )?;
11150        Ok(_response)
11151    }
11152
11153    /// Register a memory range as being used for media processing. This notifies the media
11154    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11155    /// meet audio or video deadlines.
11156    ///
11157    /// `name` is the name of a system memory role to apply to the memory given by
11158    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11159    /// on the requested role.
11160    pub fn r#register_memory_range(
11161        &self,
11162        mut vmar_handle: fidl::Vmar,
11163        mut name: &str,
11164        ___deadline: zx::MonotonicInstant,
11165    ) -> Result<(), fidl::Error> {
11166        let _response = self.client.send_query::<
11167            ProfileProviderRegisterMemoryRangeRequest,
11168            fidl::encoding::EmptyPayload,
11169            ProfileProviderMarker,
11170        >(
11171            (vmar_handle, name,),
11172            0x2f509d3523e9562d,
11173            fidl::encoding::DynamicFlags::empty(),
11174            ___deadline,
11175        )?;
11176        Ok(_response)
11177    }
11178
11179    /// Reset a memory range's memory profile.
11180    pub fn r#unregister_memory_range(
11181        &self,
11182        mut vmar_handle: fidl::Vmar,
11183        ___deadline: zx::MonotonicInstant,
11184    ) -> Result<(), fidl::Error> {
11185        let _response = self.client.send_query::<
11186            ProfileProviderUnregisterMemoryRangeRequest,
11187            fidl::encoding::EmptyPayload,
11188            ProfileProviderMarker,
11189        >(
11190            (vmar_handle,),
11191            0x2dc313d6aa81ad27,
11192            fidl::encoding::DynamicFlags::empty(),
11193            ___deadline,
11194        )?;
11195        Ok(_response)
11196    }
11197}
11198
11199#[cfg(target_os = "fuchsia")]
11200impl From<ProfileProviderSynchronousProxy> for zx::NullableHandle {
11201    fn from(value: ProfileProviderSynchronousProxy) -> Self {
11202        value.into_channel().into()
11203    }
11204}
11205
11206#[cfg(target_os = "fuchsia")]
11207impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
11208    fn from(value: fidl::Channel) -> Self {
11209        Self::new(value)
11210    }
11211}
11212
11213#[cfg(target_os = "fuchsia")]
11214impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
11215    type Protocol = ProfileProviderMarker;
11216
11217    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
11218        Self::new(value.into_channel())
11219    }
11220}
11221
11222#[derive(Debug, Clone)]
11223pub struct ProfileProviderProxy {
11224    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11225}
11226
11227impl fidl::endpoints::Proxy for ProfileProviderProxy {
11228    type Protocol = ProfileProviderMarker;
11229
11230    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11231        Self::new(inner)
11232    }
11233
11234    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11235        self.client.into_channel().map_err(|client| Self { client })
11236    }
11237
11238    fn as_channel(&self) -> &::fidl::AsyncChannel {
11239        self.client.as_channel()
11240    }
11241}
11242
11243impl ProfileProviderProxy {
11244    /// Create a new Proxy for fuchsia.media/ProfileProvider.
11245    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11246        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11247        Self { client: fidl::client::Client::new(channel, protocol_name) }
11248    }
11249
11250    /// Get a Stream of events from the remote end of the protocol.
11251    ///
11252    /// # Panics
11253    ///
11254    /// Panics if the event stream was already taken.
11255    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
11256        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
11257    }
11258
11259    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11260    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11261    /// deadlines.
11262    ///
11263    /// `name` is the name of a system scheduling role to apply to the thread given by
11264    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11265    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11266    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11267    /// the scheduling interval the thread needs to be running to achieve good performance or to
11268    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11269    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11270    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11271    /// be rejected or result in scaling back the performance of other threads to fit resource
11272    /// limits.
11273    ///
11274    /// Capacity, max runtime, and period have the following relationship:
11275    ///
11276    ///   capacity = max runtime / period
11277    ///
11278    /// Where:
11279    ///
11280    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11281    ///
11282    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11283    /// performance processor(s) in the system. The system will automatically adjust the effective
11284    /// capacity to account for slower processors and operating points and will avoid processors and
11285    /// operating points that are too slow to meet the requested scheduling parameters (provided
11286    /// they are reasonable).
11287    ///
11288    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11289    /// may be zero to indicate not applicable.
11290    pub fn r#register_handler_with_capacity(
11291        &self,
11292        mut thread_handle: fidl::Thread,
11293        mut name: &str,
11294        mut period: i64,
11295        mut capacity: f32,
11296    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
11297    {
11298        ProfileProviderProxyInterface::r#register_handler_with_capacity(
11299            self,
11300            thread_handle,
11301            name,
11302            period,
11303            capacity,
11304        )
11305    }
11306
11307    /// Reset a thread's scheduling profile to the default.
11308    pub fn r#unregister_handler(
11309        &self,
11310        mut thread_handle: fidl::Thread,
11311        mut name: &str,
11312    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11313        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
11314    }
11315
11316    /// Register a memory range as being used for media processing. This notifies the media
11317    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11318    /// meet audio or video deadlines.
11319    ///
11320    /// `name` is the name of a system memory role to apply to the memory given by
11321    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11322    /// on the requested role.
11323    pub fn r#register_memory_range(
11324        &self,
11325        mut vmar_handle: fidl::Vmar,
11326        mut name: &str,
11327    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11328        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11329    }
11330
11331    /// Reset a memory range's memory profile.
11332    pub fn r#unregister_memory_range(
11333        &self,
11334        mut vmar_handle: fidl::Vmar,
11335    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11336        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11337    }
11338}
11339
11340impl ProfileProviderProxyInterface for ProfileProviderProxy {
11341    type RegisterHandlerWithCapacityResponseFut =
11342        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11343    fn r#register_handler_with_capacity(
11344        &self,
11345        mut thread_handle: fidl::Thread,
11346        mut name: &str,
11347        mut period: i64,
11348        mut capacity: f32,
11349    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11350        fn _decode(
11351            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11352        ) -> Result<(i64, i64), fidl::Error> {
11353            let _response = fidl::client::decode_transaction_body::<
11354                ProfileProviderRegisterHandlerWithCapacityResponse,
11355                fidl::encoding::DefaultFuchsiaResourceDialect,
11356                0x60459ecef7458176,
11357            >(_buf?)?;
11358            Ok((_response.period, _response.capacity))
11359        }
11360        self.client
11361            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11362                (thread_handle, name, period, capacity),
11363                0x60459ecef7458176,
11364                fidl::encoding::DynamicFlags::empty(),
11365                _decode,
11366            )
11367    }
11368
11369    type UnregisterHandlerResponseFut =
11370        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11371    fn r#unregister_handler(
11372        &self,
11373        mut thread_handle: fidl::Thread,
11374        mut name: &str,
11375    ) -> Self::UnregisterHandlerResponseFut {
11376        fn _decode(
11377            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11378        ) -> Result<(), fidl::Error> {
11379            let _response = fidl::client::decode_transaction_body::<
11380                fidl::encoding::EmptyPayload,
11381                fidl::encoding::DefaultFuchsiaResourceDialect,
11382                0x724d9d5fd8ef544c,
11383            >(_buf?)?;
11384            Ok(_response)
11385        }
11386        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11387            (thread_handle, name),
11388            0x724d9d5fd8ef544c,
11389            fidl::encoding::DynamicFlags::empty(),
11390            _decode,
11391        )
11392    }
11393
11394    type RegisterMemoryRangeResponseFut =
11395        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11396    fn r#register_memory_range(
11397        &self,
11398        mut vmar_handle: fidl::Vmar,
11399        mut name: &str,
11400    ) -> Self::RegisterMemoryRangeResponseFut {
11401        fn _decode(
11402            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11403        ) -> Result<(), fidl::Error> {
11404            let _response = fidl::client::decode_transaction_body::<
11405                fidl::encoding::EmptyPayload,
11406                fidl::encoding::DefaultFuchsiaResourceDialect,
11407                0x2f509d3523e9562d,
11408            >(_buf?)?;
11409            Ok(_response)
11410        }
11411        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11412            (vmar_handle, name),
11413            0x2f509d3523e9562d,
11414            fidl::encoding::DynamicFlags::empty(),
11415            _decode,
11416        )
11417    }
11418
11419    type UnregisterMemoryRangeResponseFut =
11420        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11421    fn r#unregister_memory_range(
11422        &self,
11423        mut vmar_handle: fidl::Vmar,
11424    ) -> Self::UnregisterMemoryRangeResponseFut {
11425        fn _decode(
11426            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11427        ) -> Result<(), fidl::Error> {
11428            let _response = fidl::client::decode_transaction_body::<
11429                fidl::encoding::EmptyPayload,
11430                fidl::encoding::DefaultFuchsiaResourceDialect,
11431                0x2dc313d6aa81ad27,
11432            >(_buf?)?;
11433            Ok(_response)
11434        }
11435        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11436            (vmar_handle,),
11437            0x2dc313d6aa81ad27,
11438            fidl::encoding::DynamicFlags::empty(),
11439            _decode,
11440        )
11441    }
11442}
11443
11444pub struct ProfileProviderEventStream {
11445    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11446}
11447
11448impl std::marker::Unpin for ProfileProviderEventStream {}
11449
11450impl futures::stream::FusedStream for ProfileProviderEventStream {
11451    fn is_terminated(&self) -> bool {
11452        self.event_receiver.is_terminated()
11453    }
11454}
11455
11456impl futures::Stream for ProfileProviderEventStream {
11457    type Item = Result<ProfileProviderEvent, fidl::Error>;
11458
11459    fn poll_next(
11460        mut self: std::pin::Pin<&mut Self>,
11461        cx: &mut std::task::Context<'_>,
11462    ) -> std::task::Poll<Option<Self::Item>> {
11463        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11464            &mut self.event_receiver,
11465            cx
11466        )?) {
11467            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11468            None => std::task::Poll::Ready(None),
11469        }
11470    }
11471}
11472
11473#[derive(Debug)]
11474pub enum ProfileProviderEvent {}
11475
11476impl ProfileProviderEvent {
11477    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11478    fn decode(
11479        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11480    ) -> Result<ProfileProviderEvent, fidl::Error> {
11481        let (bytes, _handles) = buf.split_mut();
11482        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11483        debug_assert_eq!(tx_header.tx_id, 0);
11484        match tx_header.ordinal {
11485            _ => Err(fidl::Error::UnknownOrdinal {
11486                ordinal: tx_header.ordinal,
11487                protocol_name:
11488                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11489            }),
11490        }
11491    }
11492}
11493
11494/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11495pub struct ProfileProviderRequestStream {
11496    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11497    is_terminated: bool,
11498}
11499
11500impl std::marker::Unpin for ProfileProviderRequestStream {}
11501
11502impl futures::stream::FusedStream for ProfileProviderRequestStream {
11503    fn is_terminated(&self) -> bool {
11504        self.is_terminated
11505    }
11506}
11507
11508impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11509    type Protocol = ProfileProviderMarker;
11510    type ControlHandle = ProfileProviderControlHandle;
11511
11512    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11513        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11514    }
11515
11516    fn control_handle(&self) -> Self::ControlHandle {
11517        ProfileProviderControlHandle { inner: self.inner.clone() }
11518    }
11519
11520    fn into_inner(
11521        self,
11522    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11523    {
11524        (self.inner, self.is_terminated)
11525    }
11526
11527    fn from_inner(
11528        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11529        is_terminated: bool,
11530    ) -> Self {
11531        Self { inner, is_terminated }
11532    }
11533}
11534
11535impl futures::Stream for ProfileProviderRequestStream {
11536    type Item = Result<ProfileProviderRequest, fidl::Error>;
11537
11538    fn poll_next(
11539        mut self: std::pin::Pin<&mut Self>,
11540        cx: &mut std::task::Context<'_>,
11541    ) -> std::task::Poll<Option<Self::Item>> {
11542        let this = &mut *self;
11543        if this.inner.check_shutdown(cx) {
11544            this.is_terminated = true;
11545            return std::task::Poll::Ready(None);
11546        }
11547        if this.is_terminated {
11548            panic!("polled ProfileProviderRequestStream after completion");
11549        }
11550        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11551            |bytes, handles| {
11552                match this.inner.channel().read_etc(cx, bytes, handles) {
11553                    std::task::Poll::Ready(Ok(())) => {}
11554                    std::task::Poll::Pending => return std::task::Poll::Pending,
11555                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11556                        this.is_terminated = true;
11557                        return std::task::Poll::Ready(None);
11558                    }
11559                    std::task::Poll::Ready(Err(e)) => {
11560                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11561                            e.into(),
11562                        ))));
11563                    }
11564                }
11565
11566                // A message has been received from the channel
11567                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11568
11569                std::task::Poll::Ready(Some(match header.ordinal {
11570                    0x60459ecef7458176 => {
11571                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11572                        let mut req = fidl::new_empty!(
11573                            ProfileProviderRegisterHandlerWithCapacityRequest,
11574                            fidl::encoding::DefaultFuchsiaResourceDialect
11575                        );
11576                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11577                        let control_handle =
11578                            ProfileProviderControlHandle { inner: this.inner.clone() };
11579                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11580                            thread_handle: req.thread_handle,
11581                            name: req.name,
11582                            period: req.period,
11583                            capacity: req.capacity,
11584
11585                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11586                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11587                                tx_id: header.tx_id,
11588                            },
11589                        })
11590                    }
11591                    0x724d9d5fd8ef544c => {
11592                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11593                        let mut req = fidl::new_empty!(
11594                            ProfileProviderUnregisterHandlerRequest,
11595                            fidl::encoding::DefaultFuchsiaResourceDialect
11596                        );
11597                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11598                        let control_handle =
11599                            ProfileProviderControlHandle { inner: this.inner.clone() };
11600                        Ok(ProfileProviderRequest::UnregisterHandler {
11601                            thread_handle: req.thread_handle,
11602                            name: req.name,
11603
11604                            responder: ProfileProviderUnregisterHandlerResponder {
11605                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11606                                tx_id: header.tx_id,
11607                            },
11608                        })
11609                    }
11610                    0x2f509d3523e9562d => {
11611                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11612                        let mut req = fidl::new_empty!(
11613                            ProfileProviderRegisterMemoryRangeRequest,
11614                            fidl::encoding::DefaultFuchsiaResourceDialect
11615                        );
11616                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11617                        let control_handle =
11618                            ProfileProviderControlHandle { inner: this.inner.clone() };
11619                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11620                            vmar_handle: req.vmar_handle,
11621                            name: req.name,
11622
11623                            responder: ProfileProviderRegisterMemoryRangeResponder {
11624                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11625                                tx_id: header.tx_id,
11626                            },
11627                        })
11628                    }
11629                    0x2dc313d6aa81ad27 => {
11630                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11631                        let mut req = fidl::new_empty!(
11632                            ProfileProviderUnregisterMemoryRangeRequest,
11633                            fidl::encoding::DefaultFuchsiaResourceDialect
11634                        );
11635                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11636                        let control_handle =
11637                            ProfileProviderControlHandle { inner: this.inner.clone() };
11638                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11639                            vmar_handle: req.vmar_handle,
11640
11641                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11642                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11643                                tx_id: header.tx_id,
11644                            },
11645                        })
11646                    }
11647                    _ => Err(fidl::Error::UnknownOrdinal {
11648                        ordinal: header.ordinal,
11649                        protocol_name:
11650                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11651                    }),
11652                }))
11653            },
11654        )
11655    }
11656}
11657
11658#[derive(Debug)]
11659pub enum ProfileProviderRequest {
11660    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11661    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11662    /// deadlines.
11663    ///
11664    /// `name` is the name of a system scheduling role to apply to the thread given by
11665    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11666    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11667    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11668    /// the scheduling interval the thread needs to be running to achieve good performance or to
11669    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11670    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11671    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11672    /// be rejected or result in scaling back the performance of other threads to fit resource
11673    /// limits.
11674    ///
11675    /// Capacity, max runtime, and period have the following relationship:
11676    ///
11677    ///   capacity = max runtime / period
11678    ///
11679    /// Where:
11680    ///
11681    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11682    ///
11683    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11684    /// performance processor(s) in the system. The system will automatically adjust the effective
11685    /// capacity to account for slower processors and operating points and will avoid processors and
11686    /// operating points that are too slow to meet the requested scheduling parameters (provided
11687    /// they are reasonable).
11688    ///
11689    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11690    /// may be zero to indicate not applicable.
11691    RegisterHandlerWithCapacity {
11692        thread_handle: fidl::Thread,
11693        name: String,
11694        period: i64,
11695        capacity: f32,
11696        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11697    },
11698    /// Reset a thread's scheduling profile to the default.
11699    UnregisterHandler {
11700        thread_handle: fidl::Thread,
11701        name: String,
11702        responder: ProfileProviderUnregisterHandlerResponder,
11703    },
11704    /// Register a memory range as being used for media processing. This notifies the media
11705    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11706    /// meet audio or video deadlines.
11707    ///
11708    /// `name` is the name of a system memory role to apply to the memory given by
11709    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11710    /// on the requested role.
11711    RegisterMemoryRange {
11712        vmar_handle: fidl::Vmar,
11713        name: String,
11714        responder: ProfileProviderRegisterMemoryRangeResponder,
11715    },
11716    /// Reset a memory range's memory profile.
11717    UnregisterMemoryRange {
11718        vmar_handle: fidl::Vmar,
11719        responder: ProfileProviderUnregisterMemoryRangeResponder,
11720    },
11721}
11722
11723impl ProfileProviderRequest {
11724    #[allow(irrefutable_let_patterns)]
11725    pub fn into_register_handler_with_capacity(
11726        self,
11727    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11728    {
11729        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11730            thread_handle,
11731            name,
11732            period,
11733            capacity,
11734            responder,
11735        } = self
11736        {
11737            Some((thread_handle, name, period, capacity, responder))
11738        } else {
11739            None
11740        }
11741    }
11742
11743    #[allow(irrefutable_let_patterns)]
11744    pub fn into_unregister_handler(
11745        self,
11746    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11747        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11748            Some((thread_handle, name, responder))
11749        } else {
11750            None
11751        }
11752    }
11753
11754    #[allow(irrefutable_let_patterns)]
11755    pub fn into_register_memory_range(
11756        self,
11757    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11758        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11759            Some((vmar_handle, name, responder))
11760        } else {
11761            None
11762        }
11763    }
11764
11765    #[allow(irrefutable_let_patterns)]
11766    pub fn into_unregister_memory_range(
11767        self,
11768    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11769        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11770            Some((vmar_handle, responder))
11771        } else {
11772            None
11773        }
11774    }
11775
11776    /// Name of the method defined in FIDL
11777    pub fn method_name(&self) -> &'static str {
11778        match *self {
11779            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11780                "register_handler_with_capacity"
11781            }
11782            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11783            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11784            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11785        }
11786    }
11787}
11788
11789#[derive(Debug, Clone)]
11790pub struct ProfileProviderControlHandle {
11791    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11792}
11793
11794impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11795    fn shutdown(&self) {
11796        self.inner.shutdown()
11797    }
11798
11799    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11800        self.inner.shutdown_with_epitaph(status)
11801    }
11802
11803    fn is_closed(&self) -> bool {
11804        self.inner.channel().is_closed()
11805    }
11806    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11807        self.inner.channel().on_closed()
11808    }
11809
11810    #[cfg(target_os = "fuchsia")]
11811    fn signal_peer(
11812        &self,
11813        clear_mask: zx::Signals,
11814        set_mask: zx::Signals,
11815    ) -> Result<(), zx_status::Status> {
11816        use fidl::Peered;
11817        self.inner.channel().signal_peer(clear_mask, set_mask)
11818    }
11819}
11820
11821impl ProfileProviderControlHandle {}
11822
11823#[must_use = "FIDL methods require a response to be sent"]
11824#[derive(Debug)]
11825pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11826    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11827    tx_id: u32,
11828}
11829
11830/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11831/// if the responder is dropped without sending a response, so that the client
11832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11833impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11834    fn drop(&mut self) {
11835        self.control_handle.shutdown();
11836        // Safety: drops once, never accessed again
11837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11838    }
11839}
11840
11841impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11842    type ControlHandle = ProfileProviderControlHandle;
11843
11844    fn control_handle(&self) -> &ProfileProviderControlHandle {
11845        &self.control_handle
11846    }
11847
11848    fn drop_without_shutdown(mut self) {
11849        // Safety: drops once, never accessed again due to mem::forget
11850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11851        // Prevent Drop from running (which would shut down the channel)
11852        std::mem::forget(self);
11853    }
11854}
11855
11856impl ProfileProviderRegisterHandlerWithCapacityResponder {
11857    /// Sends a response to the FIDL transaction.
11858    ///
11859    /// Sets the channel to shutdown if an error occurs.
11860    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11861        let _result = self.send_raw(period, capacity);
11862        if _result.is_err() {
11863            self.control_handle.shutdown();
11864        }
11865        self.drop_without_shutdown();
11866        _result
11867    }
11868
11869    /// Similar to "send" but does not shutdown the channel if an error occurs.
11870    pub fn send_no_shutdown_on_err(
11871        self,
11872        mut period: i64,
11873        mut capacity: i64,
11874    ) -> Result<(), fidl::Error> {
11875        let _result = self.send_raw(period, capacity);
11876        self.drop_without_shutdown();
11877        _result
11878    }
11879
11880    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11881        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11882            (period, capacity),
11883            self.tx_id,
11884            0x60459ecef7458176,
11885            fidl::encoding::DynamicFlags::empty(),
11886        )
11887    }
11888}
11889
11890#[must_use = "FIDL methods require a response to be sent"]
11891#[derive(Debug)]
11892pub struct ProfileProviderUnregisterHandlerResponder {
11893    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11894    tx_id: u32,
11895}
11896
11897/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11898/// if the responder is dropped without sending a response, so that the client
11899/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11900impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11901    fn drop(&mut self) {
11902        self.control_handle.shutdown();
11903        // Safety: drops once, never accessed again
11904        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11905    }
11906}
11907
11908impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11909    type ControlHandle = ProfileProviderControlHandle;
11910
11911    fn control_handle(&self) -> &ProfileProviderControlHandle {
11912        &self.control_handle
11913    }
11914
11915    fn drop_without_shutdown(mut self) {
11916        // Safety: drops once, never accessed again due to mem::forget
11917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11918        // Prevent Drop from running (which would shut down the channel)
11919        std::mem::forget(self);
11920    }
11921}
11922
11923impl ProfileProviderUnregisterHandlerResponder {
11924    /// Sends a response to the FIDL transaction.
11925    ///
11926    /// Sets the channel to shutdown if an error occurs.
11927    pub fn send(self) -> Result<(), fidl::Error> {
11928        let _result = self.send_raw();
11929        if _result.is_err() {
11930            self.control_handle.shutdown();
11931        }
11932        self.drop_without_shutdown();
11933        _result
11934    }
11935
11936    /// Similar to "send" but does not shutdown the channel if an error occurs.
11937    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11938        let _result = self.send_raw();
11939        self.drop_without_shutdown();
11940        _result
11941    }
11942
11943    fn send_raw(&self) -> Result<(), fidl::Error> {
11944        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11945            (),
11946            self.tx_id,
11947            0x724d9d5fd8ef544c,
11948            fidl::encoding::DynamicFlags::empty(),
11949        )
11950    }
11951}
11952
11953#[must_use = "FIDL methods require a response to be sent"]
11954#[derive(Debug)]
11955pub struct ProfileProviderRegisterMemoryRangeResponder {
11956    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11957    tx_id: u32,
11958}
11959
11960/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11961/// if the responder is dropped without sending a response, so that the client
11962/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11963impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
11964    fn drop(&mut self) {
11965        self.control_handle.shutdown();
11966        // Safety: drops once, never accessed again
11967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11968    }
11969}
11970
11971impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
11972    type ControlHandle = ProfileProviderControlHandle;
11973
11974    fn control_handle(&self) -> &ProfileProviderControlHandle {
11975        &self.control_handle
11976    }
11977
11978    fn drop_without_shutdown(mut self) {
11979        // Safety: drops once, never accessed again due to mem::forget
11980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11981        // Prevent Drop from running (which would shut down the channel)
11982        std::mem::forget(self);
11983    }
11984}
11985
11986impl ProfileProviderRegisterMemoryRangeResponder {
11987    /// Sends a response to the FIDL transaction.
11988    ///
11989    /// Sets the channel to shutdown if an error occurs.
11990    pub fn send(self) -> Result<(), fidl::Error> {
11991        let _result = self.send_raw();
11992        if _result.is_err() {
11993            self.control_handle.shutdown();
11994        }
11995        self.drop_without_shutdown();
11996        _result
11997    }
11998
11999    /// Similar to "send" but does not shutdown the channel if an error occurs.
12000    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12001        let _result = self.send_raw();
12002        self.drop_without_shutdown();
12003        _result
12004    }
12005
12006    fn send_raw(&self) -> Result<(), fidl::Error> {
12007        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12008            (),
12009            self.tx_id,
12010            0x2f509d3523e9562d,
12011            fidl::encoding::DynamicFlags::empty(),
12012        )
12013    }
12014}
12015
12016#[must_use = "FIDL methods require a response to be sent"]
12017#[derive(Debug)]
12018pub struct ProfileProviderUnregisterMemoryRangeResponder {
12019    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
12020    tx_id: u32,
12021}
12022
12023/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
12024/// if the responder is dropped without sending a response, so that the client
12025/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12026impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
12027    fn drop(&mut self) {
12028        self.control_handle.shutdown();
12029        // Safety: drops once, never accessed again
12030        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12031    }
12032}
12033
12034impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
12035    type ControlHandle = ProfileProviderControlHandle;
12036
12037    fn control_handle(&self) -> &ProfileProviderControlHandle {
12038        &self.control_handle
12039    }
12040
12041    fn drop_without_shutdown(mut self) {
12042        // Safety: drops once, never accessed again due to mem::forget
12043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12044        // Prevent Drop from running (which would shut down the channel)
12045        std::mem::forget(self);
12046    }
12047}
12048
12049impl ProfileProviderUnregisterMemoryRangeResponder {
12050    /// Sends a response to the FIDL transaction.
12051    ///
12052    /// Sets the channel to shutdown if an error occurs.
12053    pub fn send(self) -> Result<(), fidl::Error> {
12054        let _result = self.send_raw();
12055        if _result.is_err() {
12056            self.control_handle.shutdown();
12057        }
12058        self.drop_without_shutdown();
12059        _result
12060    }
12061
12062    /// Similar to "send" but does not shutdown the channel if an error occurs.
12063    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12064        let _result = self.send_raw();
12065        self.drop_without_shutdown();
12066        _result
12067    }
12068
12069    fn send_raw(&self) -> Result<(), fidl::Error> {
12070        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12071            (),
12072            self.tx_id,
12073            0x2dc313d6aa81ad27,
12074            fidl::encoding::DynamicFlags::empty(),
12075        )
12076    }
12077}
12078
12079#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12080pub struct SessionAudioConsumerFactoryMarker;
12081
12082impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
12083    type Proxy = SessionAudioConsumerFactoryProxy;
12084    type RequestStream = SessionAudioConsumerFactoryRequestStream;
12085    #[cfg(target_os = "fuchsia")]
12086    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
12087
12088    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
12089}
12090impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
12091
12092pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
12093    fn r#create_audio_consumer(
12094        &self,
12095        session_id: u64,
12096        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12097    ) -> Result<(), fidl::Error>;
12098}
12099#[derive(Debug)]
12100#[cfg(target_os = "fuchsia")]
12101pub struct SessionAudioConsumerFactorySynchronousProxy {
12102    client: fidl::client::sync::Client,
12103}
12104
12105#[cfg(target_os = "fuchsia")]
12106impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
12107    type Proxy = SessionAudioConsumerFactoryProxy;
12108    type Protocol = SessionAudioConsumerFactoryMarker;
12109
12110    fn from_channel(inner: fidl::Channel) -> Self {
12111        Self::new(inner)
12112    }
12113
12114    fn into_channel(self) -> fidl::Channel {
12115        self.client.into_channel()
12116    }
12117
12118    fn as_channel(&self) -> &fidl::Channel {
12119        self.client.as_channel()
12120    }
12121}
12122
12123#[cfg(target_os = "fuchsia")]
12124impl SessionAudioConsumerFactorySynchronousProxy {
12125    pub fn new(channel: fidl::Channel) -> Self {
12126        Self { client: fidl::client::sync::Client::new(channel) }
12127    }
12128
12129    pub fn into_channel(self) -> fidl::Channel {
12130        self.client.into_channel()
12131    }
12132
12133    /// Waits until an event arrives and returns it. It is safe for other
12134    /// threads to make concurrent requests while waiting for an event.
12135    pub fn wait_for_event(
12136        &self,
12137        deadline: zx::MonotonicInstant,
12138    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12139        SessionAudioConsumerFactoryEvent::decode(
12140            self.client.wait_for_event::<SessionAudioConsumerFactoryMarker>(deadline)?,
12141        )
12142    }
12143
12144    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12145    /// to a particular session. `session_id` is the identifier of the media session
12146    /// for which audio is to be rendered.
12147    pub fn r#create_audio_consumer(
12148        &self,
12149        mut session_id: u64,
12150        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12151    ) -> Result<(), fidl::Error> {
12152        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
12153            (session_id, audio_consumer_request),
12154            0x6fab96f988e7d7fb,
12155            fidl::encoding::DynamicFlags::empty(),
12156        )
12157    }
12158}
12159
12160#[cfg(target_os = "fuchsia")]
12161impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
12162    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
12163        value.into_channel().into()
12164    }
12165}
12166
12167#[cfg(target_os = "fuchsia")]
12168impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
12169    fn from(value: fidl::Channel) -> Self {
12170        Self::new(value)
12171    }
12172}
12173
12174#[cfg(target_os = "fuchsia")]
12175impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
12176    type Protocol = SessionAudioConsumerFactoryMarker;
12177
12178    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
12179        Self::new(value.into_channel())
12180    }
12181}
12182
12183#[derive(Debug, Clone)]
12184pub struct SessionAudioConsumerFactoryProxy {
12185    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12186}
12187
12188impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
12189    type Protocol = SessionAudioConsumerFactoryMarker;
12190
12191    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12192        Self::new(inner)
12193    }
12194
12195    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12196        self.client.into_channel().map_err(|client| Self { client })
12197    }
12198
12199    fn as_channel(&self) -> &::fidl::AsyncChannel {
12200        self.client.as_channel()
12201    }
12202}
12203
12204impl SessionAudioConsumerFactoryProxy {
12205    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
12206    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12207        let protocol_name =
12208            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12209        Self { client: fidl::client::Client::new(channel, protocol_name) }
12210    }
12211
12212    /// Get a Stream of events from the remote end of the protocol.
12213    ///
12214    /// # Panics
12215    ///
12216    /// Panics if the event stream was already taken.
12217    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
12218        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
12219    }
12220
12221    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12222    /// to a particular session. `session_id` is the identifier of the media session
12223    /// for which audio is to be rendered.
12224    pub fn r#create_audio_consumer(
12225        &self,
12226        mut session_id: u64,
12227        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12228    ) -> Result<(), fidl::Error> {
12229        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
12230            self,
12231            session_id,
12232            audio_consumer_request,
12233        )
12234    }
12235}
12236
12237impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
12238    fn r#create_audio_consumer(
12239        &self,
12240        mut session_id: u64,
12241        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12242    ) -> Result<(), fidl::Error> {
12243        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
12244            (session_id, audio_consumer_request),
12245            0x6fab96f988e7d7fb,
12246            fidl::encoding::DynamicFlags::empty(),
12247        )
12248    }
12249}
12250
12251pub struct SessionAudioConsumerFactoryEventStream {
12252    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12253}
12254
12255impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
12256
12257impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
12258    fn is_terminated(&self) -> bool {
12259        self.event_receiver.is_terminated()
12260    }
12261}
12262
12263impl futures::Stream for SessionAudioConsumerFactoryEventStream {
12264    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
12265
12266    fn poll_next(
12267        mut self: std::pin::Pin<&mut Self>,
12268        cx: &mut std::task::Context<'_>,
12269    ) -> std::task::Poll<Option<Self::Item>> {
12270        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12271            &mut self.event_receiver,
12272            cx
12273        )?) {
12274            Some(buf) => {
12275                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
12276            }
12277            None => std::task::Poll::Ready(None),
12278        }
12279    }
12280}
12281
12282#[derive(Debug)]
12283pub enum SessionAudioConsumerFactoryEvent {}
12284
12285impl SessionAudioConsumerFactoryEvent {
12286    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
12287    fn decode(
12288        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12289    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12290        let (bytes, _handles) = buf.split_mut();
12291        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12292        debug_assert_eq!(tx_header.tx_id, 0);
12293        match tx_header.ordinal {
12294            _ => Err(fidl::Error::UnknownOrdinal {
12295                ordinal: tx_header.ordinal,
12296                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12297            })
12298        }
12299    }
12300}
12301
12302/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
12303pub struct SessionAudioConsumerFactoryRequestStream {
12304    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12305    is_terminated: bool,
12306}
12307
12308impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
12309
12310impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
12311    fn is_terminated(&self) -> bool {
12312        self.is_terminated
12313    }
12314}
12315
12316impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
12317    type Protocol = SessionAudioConsumerFactoryMarker;
12318    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
12319
12320    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12321        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12322    }
12323
12324    fn control_handle(&self) -> Self::ControlHandle {
12325        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
12326    }
12327
12328    fn into_inner(
12329        self,
12330    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12331    {
12332        (self.inner, self.is_terminated)
12333    }
12334
12335    fn from_inner(
12336        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12337        is_terminated: bool,
12338    ) -> Self {
12339        Self { inner, is_terminated }
12340    }
12341}
12342
12343impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12344    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12345
12346    fn poll_next(
12347        mut self: std::pin::Pin<&mut Self>,
12348        cx: &mut std::task::Context<'_>,
12349    ) -> std::task::Poll<Option<Self::Item>> {
12350        let this = &mut *self;
12351        if this.inner.check_shutdown(cx) {
12352            this.is_terminated = true;
12353            return std::task::Poll::Ready(None);
12354        }
12355        if this.is_terminated {
12356            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12357        }
12358        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12359            |bytes, handles| {
12360                match this.inner.channel().read_etc(cx, bytes, handles) {
12361                    std::task::Poll::Ready(Ok(())) => {}
12362                    std::task::Poll::Pending => return std::task::Poll::Pending,
12363                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12364                        this.is_terminated = true;
12365                        return std::task::Poll::Ready(None);
12366                    }
12367                    std::task::Poll::Ready(Err(e)) => {
12368                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12369                            e.into(),
12370                        ))));
12371                    }
12372                }
12373
12374                // A message has been received from the channel
12375                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12376
12377                std::task::Poll::Ready(Some(match header.ordinal {
12378                0x6fab96f988e7d7fb => {
12379                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12380                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12381                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12382                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12383                        inner: this.inner.clone(),
12384                    };
12385                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12386audio_consumer_request: req.audio_consumer_request,
12387
12388                        control_handle,
12389                    })
12390                }
12391                _ => Err(fidl::Error::UnknownOrdinal {
12392                    ordinal: header.ordinal,
12393                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12394                }),
12395            }))
12396            },
12397        )
12398    }
12399}
12400
12401/// Interface for creating audio consumers bound to a session.
12402#[derive(Debug)]
12403pub enum SessionAudioConsumerFactoryRequest {
12404    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12405    /// to a particular session. `session_id` is the identifier of the media session
12406    /// for which audio is to be rendered.
12407    CreateAudioConsumer {
12408        session_id: u64,
12409        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12410        control_handle: SessionAudioConsumerFactoryControlHandle,
12411    },
12412}
12413
12414impl SessionAudioConsumerFactoryRequest {
12415    #[allow(irrefutable_let_patterns)]
12416    pub fn into_create_audio_consumer(
12417        self,
12418    ) -> Option<(
12419        u64,
12420        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12421        SessionAudioConsumerFactoryControlHandle,
12422    )> {
12423        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12424            session_id,
12425            audio_consumer_request,
12426            control_handle,
12427        } = self
12428        {
12429            Some((session_id, audio_consumer_request, control_handle))
12430        } else {
12431            None
12432        }
12433    }
12434
12435    /// Name of the method defined in FIDL
12436    pub fn method_name(&self) -> &'static str {
12437        match *self {
12438            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12439                "create_audio_consumer"
12440            }
12441        }
12442    }
12443}
12444
12445#[derive(Debug, Clone)]
12446pub struct SessionAudioConsumerFactoryControlHandle {
12447    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12448}
12449
12450impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12451    fn shutdown(&self) {
12452        self.inner.shutdown()
12453    }
12454
12455    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12456        self.inner.shutdown_with_epitaph(status)
12457    }
12458
12459    fn is_closed(&self) -> bool {
12460        self.inner.channel().is_closed()
12461    }
12462    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12463        self.inner.channel().on_closed()
12464    }
12465
12466    #[cfg(target_os = "fuchsia")]
12467    fn signal_peer(
12468        &self,
12469        clear_mask: zx::Signals,
12470        set_mask: zx::Signals,
12471    ) -> Result<(), zx_status::Status> {
12472        use fidl::Peered;
12473        self.inner.channel().signal_peer(clear_mask, set_mask)
12474    }
12475}
12476
12477impl SessionAudioConsumerFactoryControlHandle {}
12478
12479#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12480pub struct SimpleStreamSinkMarker;
12481
12482impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12483    type Proxy = SimpleStreamSinkProxy;
12484    type RequestStream = SimpleStreamSinkRequestStream;
12485    #[cfg(target_os = "fuchsia")]
12486    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12487
12488    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12489}
12490
12491pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12492    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12493    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12494    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12495    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12496    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12497    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12498    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12499    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12500    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12501}
12502#[derive(Debug)]
12503#[cfg(target_os = "fuchsia")]
12504pub struct SimpleStreamSinkSynchronousProxy {
12505    client: fidl::client::sync::Client,
12506}
12507
12508#[cfg(target_os = "fuchsia")]
12509impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12510    type Proxy = SimpleStreamSinkProxy;
12511    type Protocol = SimpleStreamSinkMarker;
12512
12513    fn from_channel(inner: fidl::Channel) -> Self {
12514        Self::new(inner)
12515    }
12516
12517    fn into_channel(self) -> fidl::Channel {
12518        self.client.into_channel()
12519    }
12520
12521    fn as_channel(&self) -> &fidl::Channel {
12522        self.client.as_channel()
12523    }
12524}
12525
12526#[cfg(target_os = "fuchsia")]
12527impl SimpleStreamSinkSynchronousProxy {
12528    pub fn new(channel: fidl::Channel) -> Self {
12529        Self { client: fidl::client::sync::Client::new(channel) }
12530    }
12531
12532    pub fn into_channel(self) -> fidl::Channel {
12533        self.client.into_channel()
12534    }
12535
12536    /// Waits until an event arrives and returns it. It is safe for other
12537    /// threads to make concurrent requests while waiting for an event.
12538    pub fn wait_for_event(
12539        &self,
12540        deadline: zx::MonotonicInstant,
12541    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12542        SimpleStreamSinkEvent::decode(
12543            self.client.wait_for_event::<SimpleStreamSinkMarker>(deadline)?,
12544        )
12545    }
12546
12547    /// Adds a payload buffer to the current buffer set associated with the
12548    /// connection. A `StreamPacket` struct reference a payload buffer in the
12549    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12550    ///
12551    /// A buffer with ID `id` must not be in the current set when this method is
12552    /// invoked, otherwise the service will close the connection.
12553    pub fn r#add_payload_buffer(
12554        &self,
12555        mut id: u32,
12556        mut payload_buffer: fidl::Vmo,
12557    ) -> Result<(), fidl::Error> {
12558        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12559            (id, payload_buffer),
12560            0x3b3a37fc34fe5b56,
12561            fidl::encoding::DynamicFlags::empty(),
12562        )
12563    }
12564
12565    /// Removes a payload buffer from the current buffer set associated with the
12566    /// connection.
12567    ///
12568    /// A buffer with ID `id` must exist in the current set when this method is
12569    /// invoked, otherwise the service will will close the connection.
12570    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12571        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12572            (id,),
12573            0x5d1e4f74c3658262,
12574            fidl::encoding::DynamicFlags::empty(),
12575        )
12576    }
12577
12578    /// Sends a packet to the service. The response is sent when the service is
12579    /// done with the associated payload memory.
12580    ///
12581    /// `packet` must be valid for the current buffer set, otherwise the service
12582    /// will close the connection.
12583    pub fn r#send_packet(
12584        &self,
12585        mut packet: &StreamPacket,
12586        ___deadline: zx::MonotonicInstant,
12587    ) -> Result<(), fidl::Error> {
12588        let _response = self.client.send_query::<
12589            StreamSinkSendPacketRequest,
12590            fidl::encoding::EmptyPayload,
12591            SimpleStreamSinkMarker,
12592        >(
12593            (packet,),
12594            0x67cddd607442775f,
12595            fidl::encoding::DynamicFlags::empty(),
12596            ___deadline,
12597        )?;
12598        Ok(_response)
12599    }
12600
12601    /// Sends a packet to the service. This interface doesn't define how the
12602    /// client knows when the sink is done with the associated payload memory.
12603    /// The inheriting interface must define that.
12604    ///
12605    /// `packet` must be valid for the current buffer set, otherwise the service
12606    /// will close the connection.
12607    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12608        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12609            (packet,),
12610            0x8d9b8b413ceba9d,
12611            fidl::encoding::DynamicFlags::empty(),
12612        )
12613    }
12614
12615    /// Indicates the stream has ended. The precise semantics of this method are
12616    /// determined by the inheriting interface.
12617    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12618        self.client.send::<fidl::encoding::EmptyPayload>(
12619            (),
12620            0x6180fd6f7e793b71,
12621            fidl::encoding::DynamicFlags::empty(),
12622        )
12623    }
12624
12625    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12626    /// and not yet released. The response is sent after all packets have been
12627    /// released.
12628    pub fn r#discard_all_packets(
12629        &self,
12630        ___deadline: zx::MonotonicInstant,
12631    ) -> Result<(), fidl::Error> {
12632        let _response = self.client.send_query::<
12633            fidl::encoding::EmptyPayload,
12634            fidl::encoding::EmptyPayload,
12635            SimpleStreamSinkMarker,
12636        >(
12637            (),
12638            0x6f4dad7af2917665,
12639            fidl::encoding::DynamicFlags::empty(),
12640            ___deadline,
12641        )?;
12642        Ok(_response)
12643    }
12644
12645    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12646    /// and not yet released.
12647    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12648        self.client.send::<fidl::encoding::EmptyPayload>(
12649            (),
12650            0x50d36d0d23081bc4,
12651            fidl::encoding::DynamicFlags::empty(),
12652        )
12653    }
12654}
12655
12656#[cfg(target_os = "fuchsia")]
12657impl From<SimpleStreamSinkSynchronousProxy> for zx::NullableHandle {
12658    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12659        value.into_channel().into()
12660    }
12661}
12662
12663#[cfg(target_os = "fuchsia")]
12664impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12665    fn from(value: fidl::Channel) -> Self {
12666        Self::new(value)
12667    }
12668}
12669
12670#[cfg(target_os = "fuchsia")]
12671impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12672    type Protocol = SimpleStreamSinkMarker;
12673
12674    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12675        Self::new(value.into_channel())
12676    }
12677}
12678
12679#[derive(Debug, Clone)]
12680pub struct SimpleStreamSinkProxy {
12681    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12682}
12683
12684impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12685    type Protocol = SimpleStreamSinkMarker;
12686
12687    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12688        Self::new(inner)
12689    }
12690
12691    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12692        self.client.into_channel().map_err(|client| Self { client })
12693    }
12694
12695    fn as_channel(&self) -> &::fidl::AsyncChannel {
12696        self.client.as_channel()
12697    }
12698}
12699
12700impl SimpleStreamSinkProxy {
12701    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12702    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12703        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12704        Self { client: fidl::client::Client::new(channel, protocol_name) }
12705    }
12706
12707    /// Get a Stream of events from the remote end of the protocol.
12708    ///
12709    /// # Panics
12710    ///
12711    /// Panics if the event stream was already taken.
12712    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12713        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12714    }
12715
12716    /// Adds a payload buffer to the current buffer set associated with the
12717    /// connection. A `StreamPacket` struct reference a payload buffer in the
12718    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12719    ///
12720    /// A buffer with ID `id` must not be in the current set when this method is
12721    /// invoked, otherwise the service will close the connection.
12722    pub fn r#add_payload_buffer(
12723        &self,
12724        mut id: u32,
12725        mut payload_buffer: fidl::Vmo,
12726    ) -> Result<(), fidl::Error> {
12727        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12728    }
12729
12730    /// Removes a payload buffer from the current buffer set associated with the
12731    /// connection.
12732    ///
12733    /// A buffer with ID `id` must exist in the current set when this method is
12734    /// invoked, otherwise the service will will close the connection.
12735    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12736        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12737    }
12738
12739    /// Sends a packet to the service. The response is sent when the service is
12740    /// done with the associated payload memory.
12741    ///
12742    /// `packet` must be valid for the current buffer set, otherwise the service
12743    /// will close the connection.
12744    pub fn r#send_packet(
12745        &self,
12746        mut packet: &StreamPacket,
12747    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12748        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12749    }
12750
12751    /// Sends a packet to the service. This interface doesn't define how the
12752    /// client knows when the sink is done with the associated payload memory.
12753    /// The inheriting interface must define that.
12754    ///
12755    /// `packet` must be valid for the current buffer set, otherwise the service
12756    /// will close the connection.
12757    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12758        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12759    }
12760
12761    /// Indicates the stream has ended. The precise semantics of this method are
12762    /// determined by the inheriting interface.
12763    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12764        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12765    }
12766
12767    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12768    /// and not yet released. The response is sent after all packets have been
12769    /// released.
12770    pub fn r#discard_all_packets(
12771        &self,
12772    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12773        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12774    }
12775
12776    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12777    /// and not yet released.
12778    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12779        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12780    }
12781}
12782
12783impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12784    fn r#add_payload_buffer(
12785        &self,
12786        mut id: u32,
12787        mut payload_buffer: fidl::Vmo,
12788    ) -> Result<(), fidl::Error> {
12789        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12790            (id, payload_buffer),
12791            0x3b3a37fc34fe5b56,
12792            fidl::encoding::DynamicFlags::empty(),
12793        )
12794    }
12795
12796    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12797        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12798            (id,),
12799            0x5d1e4f74c3658262,
12800            fidl::encoding::DynamicFlags::empty(),
12801        )
12802    }
12803
12804    type SendPacketResponseFut =
12805        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12806    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12807        fn _decode(
12808            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12809        ) -> Result<(), fidl::Error> {
12810            let _response = fidl::client::decode_transaction_body::<
12811                fidl::encoding::EmptyPayload,
12812                fidl::encoding::DefaultFuchsiaResourceDialect,
12813                0x67cddd607442775f,
12814            >(_buf?)?;
12815            Ok(_response)
12816        }
12817        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12818            (packet,),
12819            0x67cddd607442775f,
12820            fidl::encoding::DynamicFlags::empty(),
12821            _decode,
12822        )
12823    }
12824
12825    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12826        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12827            (packet,),
12828            0x8d9b8b413ceba9d,
12829            fidl::encoding::DynamicFlags::empty(),
12830        )
12831    }
12832
12833    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12834        self.client.send::<fidl::encoding::EmptyPayload>(
12835            (),
12836            0x6180fd6f7e793b71,
12837            fidl::encoding::DynamicFlags::empty(),
12838        )
12839    }
12840
12841    type DiscardAllPacketsResponseFut =
12842        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12843    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12844        fn _decode(
12845            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12846        ) -> Result<(), fidl::Error> {
12847            let _response = fidl::client::decode_transaction_body::<
12848                fidl::encoding::EmptyPayload,
12849                fidl::encoding::DefaultFuchsiaResourceDialect,
12850                0x6f4dad7af2917665,
12851            >(_buf?)?;
12852            Ok(_response)
12853        }
12854        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12855            (),
12856            0x6f4dad7af2917665,
12857            fidl::encoding::DynamicFlags::empty(),
12858            _decode,
12859        )
12860    }
12861
12862    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12863        self.client.send::<fidl::encoding::EmptyPayload>(
12864            (),
12865            0x50d36d0d23081bc4,
12866            fidl::encoding::DynamicFlags::empty(),
12867        )
12868    }
12869}
12870
12871pub struct SimpleStreamSinkEventStream {
12872    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12873}
12874
12875impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12876
12877impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12878    fn is_terminated(&self) -> bool {
12879        self.event_receiver.is_terminated()
12880    }
12881}
12882
12883impl futures::Stream for SimpleStreamSinkEventStream {
12884    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12885
12886    fn poll_next(
12887        mut self: std::pin::Pin<&mut Self>,
12888        cx: &mut std::task::Context<'_>,
12889    ) -> std::task::Poll<Option<Self::Item>> {
12890        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12891            &mut self.event_receiver,
12892            cx
12893        )?) {
12894            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12895            None => std::task::Poll::Ready(None),
12896        }
12897    }
12898}
12899
12900#[derive(Debug)]
12901pub enum SimpleStreamSinkEvent {}
12902
12903impl SimpleStreamSinkEvent {
12904    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12905    fn decode(
12906        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12907    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12908        let (bytes, _handles) = buf.split_mut();
12909        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12910        debug_assert_eq!(tx_header.tx_id, 0);
12911        match tx_header.ordinal {
12912            _ => Err(fidl::Error::UnknownOrdinal {
12913                ordinal: tx_header.ordinal,
12914                protocol_name:
12915                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12916            }),
12917        }
12918    }
12919}
12920
12921/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12922pub struct SimpleStreamSinkRequestStream {
12923    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12924    is_terminated: bool,
12925}
12926
12927impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12928
12929impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12930    fn is_terminated(&self) -> bool {
12931        self.is_terminated
12932    }
12933}
12934
12935impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12936    type Protocol = SimpleStreamSinkMarker;
12937    type ControlHandle = SimpleStreamSinkControlHandle;
12938
12939    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12940        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12941    }
12942
12943    fn control_handle(&self) -> Self::ControlHandle {
12944        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12945    }
12946
12947    fn into_inner(
12948        self,
12949    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12950    {
12951        (self.inner, self.is_terminated)
12952    }
12953
12954    fn from_inner(
12955        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12956        is_terminated: bool,
12957    ) -> Self {
12958        Self { inner, is_terminated }
12959    }
12960}
12961
12962impl futures::Stream for SimpleStreamSinkRequestStream {
12963    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
12964
12965    fn poll_next(
12966        mut self: std::pin::Pin<&mut Self>,
12967        cx: &mut std::task::Context<'_>,
12968    ) -> std::task::Poll<Option<Self::Item>> {
12969        let this = &mut *self;
12970        if this.inner.check_shutdown(cx) {
12971            this.is_terminated = true;
12972            return std::task::Poll::Ready(None);
12973        }
12974        if this.is_terminated {
12975            panic!("polled SimpleStreamSinkRequestStream after completion");
12976        }
12977        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12978            |bytes, handles| {
12979                match this.inner.channel().read_etc(cx, bytes, handles) {
12980                    std::task::Poll::Ready(Ok(())) => {}
12981                    std::task::Poll::Pending => return std::task::Poll::Pending,
12982                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12983                        this.is_terminated = true;
12984                        return std::task::Poll::Ready(None);
12985                    }
12986                    std::task::Poll::Ready(Err(e)) => {
12987                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12988                            e.into(),
12989                        ))));
12990                    }
12991                }
12992
12993                // A message has been received from the channel
12994                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12995
12996                std::task::Poll::Ready(Some(match header.ordinal {
12997                    0x3b3a37fc34fe5b56 => {
12998                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12999                        let mut req = fidl::new_empty!(
13000                            StreamBufferSetAddPayloadBufferRequest,
13001                            fidl::encoding::DefaultFuchsiaResourceDialect
13002                        );
13003                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13004                        let control_handle =
13005                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13006                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
13007                            id: req.id,
13008                            payload_buffer: req.payload_buffer,
13009
13010                            control_handle,
13011                        })
13012                    }
13013                    0x5d1e4f74c3658262 => {
13014                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13015                        let mut req = fidl::new_empty!(
13016                            StreamBufferSetRemovePayloadBufferRequest,
13017                            fidl::encoding::DefaultFuchsiaResourceDialect
13018                        );
13019                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13020                        let control_handle =
13021                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13022                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
13023                            id: req.id,
13024
13025                            control_handle,
13026                        })
13027                    }
13028                    0x67cddd607442775f => {
13029                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13030                        let mut req = fidl::new_empty!(
13031                            StreamSinkSendPacketRequest,
13032                            fidl::encoding::DefaultFuchsiaResourceDialect
13033                        );
13034                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
13035                        let control_handle =
13036                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13037                        Ok(SimpleStreamSinkRequest::SendPacket {
13038                            packet: req.packet,
13039
13040                            responder: SimpleStreamSinkSendPacketResponder {
13041                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13042                                tx_id: header.tx_id,
13043                            },
13044                        })
13045                    }
13046                    0x8d9b8b413ceba9d => {
13047                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13048                        let mut req = fidl::new_empty!(
13049                            StreamSinkSendPacketNoReplyRequest,
13050                            fidl::encoding::DefaultFuchsiaResourceDialect
13051                        );
13052                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
13053                        let control_handle =
13054                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13055                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
13056                            packet: req.packet,
13057
13058                            control_handle,
13059                        })
13060                    }
13061                    0x6180fd6f7e793b71 => {
13062                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13063                        let mut req = fidl::new_empty!(
13064                            fidl::encoding::EmptyPayload,
13065                            fidl::encoding::DefaultFuchsiaResourceDialect
13066                        );
13067                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13068                        let control_handle =
13069                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13070                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
13071                    }
13072                    0x6f4dad7af2917665 => {
13073                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13074                        let mut req = fidl::new_empty!(
13075                            fidl::encoding::EmptyPayload,
13076                            fidl::encoding::DefaultFuchsiaResourceDialect
13077                        );
13078                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13079                        let control_handle =
13080                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13081                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
13082                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
13083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13084                                tx_id: header.tx_id,
13085                            },
13086                        })
13087                    }
13088                    0x50d36d0d23081bc4 => {
13089                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13090                        let mut req = fidl::new_empty!(
13091                            fidl::encoding::EmptyPayload,
13092                            fidl::encoding::DefaultFuchsiaResourceDialect
13093                        );
13094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13095                        let control_handle =
13096                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13097                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
13098                    }
13099                    _ => Err(fidl::Error::UnknownOrdinal {
13100                        ordinal: header.ordinal,
13101                        protocol_name:
13102                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13103                    }),
13104                }))
13105            },
13106        )
13107    }
13108}
13109
13110/// A StreamSink that uses StreamBufferSet for buffer management.
13111#[derive(Debug)]
13112pub enum SimpleStreamSinkRequest {
13113    /// Adds a payload buffer to the current buffer set associated with the
13114    /// connection. A `StreamPacket` struct reference a payload buffer in the
13115    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13116    ///
13117    /// A buffer with ID `id` must not be in the current set when this method is
13118    /// invoked, otherwise the service will close the connection.
13119    AddPayloadBuffer {
13120        id: u32,
13121        payload_buffer: fidl::Vmo,
13122        control_handle: SimpleStreamSinkControlHandle,
13123    },
13124    /// Removes a payload buffer from the current buffer set associated with the
13125    /// connection.
13126    ///
13127    /// A buffer with ID `id` must exist in the current set when this method is
13128    /// invoked, otherwise the service will will close the connection.
13129    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
13130    /// Sends a packet to the service. The response is sent when the service is
13131    /// done with the associated payload memory.
13132    ///
13133    /// `packet` must be valid for the current buffer set, otherwise the service
13134    /// will close the connection.
13135    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
13136    /// Sends a packet to the service. This interface doesn't define how the
13137    /// client knows when the sink is done with the associated payload memory.
13138    /// The inheriting interface must define that.
13139    ///
13140    /// `packet` must be valid for the current buffer set, otherwise the service
13141    /// will close the connection.
13142    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
13143    /// Indicates the stream has ended. The precise semantics of this method are
13144    /// determined by the inheriting interface.
13145    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
13146    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13147    /// and not yet released. The response is sent after all packets have been
13148    /// released.
13149    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
13150    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13151    /// and not yet released.
13152    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
13153}
13154
13155impl SimpleStreamSinkRequest {
13156    #[allow(irrefutable_let_patterns)]
13157    pub fn into_add_payload_buffer(
13158        self,
13159    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
13160        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13161            self
13162        {
13163            Some((id, payload_buffer, control_handle))
13164        } else {
13165            None
13166        }
13167    }
13168
13169    #[allow(irrefutable_let_patterns)]
13170    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
13171        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
13172            Some((id, control_handle))
13173        } else {
13174            None
13175        }
13176    }
13177
13178    #[allow(irrefutable_let_patterns)]
13179    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
13180        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
13181            Some((packet, responder))
13182        } else {
13183            None
13184        }
13185    }
13186
13187    #[allow(irrefutable_let_patterns)]
13188    pub fn into_send_packet_no_reply(
13189        self,
13190    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
13191        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
13192            Some((packet, control_handle))
13193        } else {
13194            None
13195        }
13196    }
13197
13198    #[allow(irrefutable_let_patterns)]
13199    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
13200        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
13201            Some((control_handle))
13202        } else {
13203            None
13204        }
13205    }
13206
13207    #[allow(irrefutable_let_patterns)]
13208    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
13209        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
13210            Some((responder))
13211        } else {
13212            None
13213        }
13214    }
13215
13216    #[allow(irrefutable_let_patterns)]
13217    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
13218        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
13219            Some((control_handle))
13220        } else {
13221            None
13222        }
13223    }
13224
13225    /// Name of the method defined in FIDL
13226    pub fn method_name(&self) -> &'static str {
13227        match *self {
13228            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13229            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13230            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
13231            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
13232            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
13233            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
13234            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
13235                "discard_all_packets_no_reply"
13236            }
13237        }
13238    }
13239}
13240
13241#[derive(Debug, Clone)]
13242pub struct SimpleStreamSinkControlHandle {
13243    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13244}
13245
13246impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
13247    fn shutdown(&self) {
13248        self.inner.shutdown()
13249    }
13250
13251    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13252        self.inner.shutdown_with_epitaph(status)
13253    }
13254
13255    fn is_closed(&self) -> bool {
13256        self.inner.channel().is_closed()
13257    }
13258    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13259        self.inner.channel().on_closed()
13260    }
13261
13262    #[cfg(target_os = "fuchsia")]
13263    fn signal_peer(
13264        &self,
13265        clear_mask: zx::Signals,
13266        set_mask: zx::Signals,
13267    ) -> Result<(), zx_status::Status> {
13268        use fidl::Peered;
13269        self.inner.channel().signal_peer(clear_mask, set_mask)
13270    }
13271}
13272
13273impl SimpleStreamSinkControlHandle {}
13274
13275#[must_use = "FIDL methods require a response to be sent"]
13276#[derive(Debug)]
13277pub struct SimpleStreamSinkSendPacketResponder {
13278    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13279    tx_id: u32,
13280}
13281
13282/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13283/// if the responder is dropped without sending a response, so that the client
13284/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13285impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
13286    fn drop(&mut self) {
13287        self.control_handle.shutdown();
13288        // Safety: drops once, never accessed again
13289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13290    }
13291}
13292
13293impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
13294    type ControlHandle = SimpleStreamSinkControlHandle;
13295
13296    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13297        &self.control_handle
13298    }
13299
13300    fn drop_without_shutdown(mut self) {
13301        // Safety: drops once, never accessed again due to mem::forget
13302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13303        // Prevent Drop from running (which would shut down the channel)
13304        std::mem::forget(self);
13305    }
13306}
13307
13308impl SimpleStreamSinkSendPacketResponder {
13309    /// Sends a response to the FIDL transaction.
13310    ///
13311    /// Sets the channel to shutdown if an error occurs.
13312    pub fn send(self) -> Result<(), fidl::Error> {
13313        let _result = self.send_raw();
13314        if _result.is_err() {
13315            self.control_handle.shutdown();
13316        }
13317        self.drop_without_shutdown();
13318        _result
13319    }
13320
13321    /// Similar to "send" but does not shutdown the channel if an error occurs.
13322    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13323        let _result = self.send_raw();
13324        self.drop_without_shutdown();
13325        _result
13326    }
13327
13328    fn send_raw(&self) -> Result<(), fidl::Error> {
13329        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13330            (),
13331            self.tx_id,
13332            0x67cddd607442775f,
13333            fidl::encoding::DynamicFlags::empty(),
13334        )
13335    }
13336}
13337
13338#[must_use = "FIDL methods require a response to be sent"]
13339#[derive(Debug)]
13340pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13341    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13342    tx_id: u32,
13343}
13344
13345/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13346/// if the responder is dropped without sending a response, so that the client
13347/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13348impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13349    fn drop(&mut self) {
13350        self.control_handle.shutdown();
13351        // Safety: drops once, never accessed again
13352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13353    }
13354}
13355
13356impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13357    type ControlHandle = SimpleStreamSinkControlHandle;
13358
13359    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13360        &self.control_handle
13361    }
13362
13363    fn drop_without_shutdown(mut self) {
13364        // Safety: drops once, never accessed again due to mem::forget
13365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13366        // Prevent Drop from running (which would shut down the channel)
13367        std::mem::forget(self);
13368    }
13369}
13370
13371impl SimpleStreamSinkDiscardAllPacketsResponder {
13372    /// Sends a response to the FIDL transaction.
13373    ///
13374    /// Sets the channel to shutdown if an error occurs.
13375    pub fn send(self) -> Result<(), fidl::Error> {
13376        let _result = self.send_raw();
13377        if _result.is_err() {
13378            self.control_handle.shutdown();
13379        }
13380        self.drop_without_shutdown();
13381        _result
13382    }
13383
13384    /// Similar to "send" but does not shutdown the channel if an error occurs.
13385    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13386        let _result = self.send_raw();
13387        self.drop_without_shutdown();
13388        _result
13389    }
13390
13391    fn send_raw(&self) -> Result<(), fidl::Error> {
13392        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13393            (),
13394            self.tx_id,
13395            0x6f4dad7af2917665,
13396            fidl::encoding::DynamicFlags::empty(),
13397        )
13398    }
13399}
13400
13401#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13402pub struct StreamBufferSetMarker;
13403
13404impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13405    type Proxy = StreamBufferSetProxy;
13406    type RequestStream = StreamBufferSetRequestStream;
13407    #[cfg(target_os = "fuchsia")]
13408    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13409
13410    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13411}
13412
13413pub trait StreamBufferSetProxyInterface: Send + Sync {
13414    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13415    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13416}
13417#[derive(Debug)]
13418#[cfg(target_os = "fuchsia")]
13419pub struct StreamBufferSetSynchronousProxy {
13420    client: fidl::client::sync::Client,
13421}
13422
13423#[cfg(target_os = "fuchsia")]
13424impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13425    type Proxy = StreamBufferSetProxy;
13426    type Protocol = StreamBufferSetMarker;
13427
13428    fn from_channel(inner: fidl::Channel) -> Self {
13429        Self::new(inner)
13430    }
13431
13432    fn into_channel(self) -> fidl::Channel {
13433        self.client.into_channel()
13434    }
13435
13436    fn as_channel(&self) -> &fidl::Channel {
13437        self.client.as_channel()
13438    }
13439}
13440
13441#[cfg(target_os = "fuchsia")]
13442impl StreamBufferSetSynchronousProxy {
13443    pub fn new(channel: fidl::Channel) -> Self {
13444        Self { client: fidl::client::sync::Client::new(channel) }
13445    }
13446
13447    pub fn into_channel(self) -> fidl::Channel {
13448        self.client.into_channel()
13449    }
13450
13451    /// Waits until an event arrives and returns it. It is safe for other
13452    /// threads to make concurrent requests while waiting for an event.
13453    pub fn wait_for_event(
13454        &self,
13455        deadline: zx::MonotonicInstant,
13456    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13457        StreamBufferSetEvent::decode(self.client.wait_for_event::<StreamBufferSetMarker>(deadline)?)
13458    }
13459
13460    /// Adds a payload buffer to the current buffer set associated with the
13461    /// connection. A `StreamPacket` struct reference a payload buffer in the
13462    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13463    ///
13464    /// A buffer with ID `id` must not be in the current set when this method is
13465    /// invoked, otherwise the service will close the connection.
13466    pub fn r#add_payload_buffer(
13467        &self,
13468        mut id: u32,
13469        mut payload_buffer: fidl::Vmo,
13470    ) -> Result<(), fidl::Error> {
13471        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13472            (id, payload_buffer),
13473            0x3b3a37fc34fe5b56,
13474            fidl::encoding::DynamicFlags::empty(),
13475        )
13476    }
13477
13478    /// Removes a payload buffer from the current buffer set associated with the
13479    /// connection.
13480    ///
13481    /// A buffer with ID `id` must exist in the current set when this method is
13482    /// invoked, otherwise the service will will close the connection.
13483    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13484        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13485            (id,),
13486            0x5d1e4f74c3658262,
13487            fidl::encoding::DynamicFlags::empty(),
13488        )
13489    }
13490}
13491
13492#[cfg(target_os = "fuchsia")]
13493impl From<StreamBufferSetSynchronousProxy> for zx::NullableHandle {
13494    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13495        value.into_channel().into()
13496    }
13497}
13498
13499#[cfg(target_os = "fuchsia")]
13500impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13501    fn from(value: fidl::Channel) -> Self {
13502        Self::new(value)
13503    }
13504}
13505
13506#[cfg(target_os = "fuchsia")]
13507impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13508    type Protocol = StreamBufferSetMarker;
13509
13510    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13511        Self::new(value.into_channel())
13512    }
13513}
13514
13515#[derive(Debug, Clone)]
13516pub struct StreamBufferSetProxy {
13517    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13518}
13519
13520impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13521    type Protocol = StreamBufferSetMarker;
13522
13523    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13524        Self::new(inner)
13525    }
13526
13527    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13528        self.client.into_channel().map_err(|client| Self { client })
13529    }
13530
13531    fn as_channel(&self) -> &::fidl::AsyncChannel {
13532        self.client.as_channel()
13533    }
13534}
13535
13536impl StreamBufferSetProxy {
13537    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13538    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13539        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13540        Self { client: fidl::client::Client::new(channel, protocol_name) }
13541    }
13542
13543    /// Get a Stream of events from the remote end of the protocol.
13544    ///
13545    /// # Panics
13546    ///
13547    /// Panics if the event stream was already taken.
13548    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13549        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13550    }
13551
13552    /// Adds a payload buffer to the current buffer set associated with the
13553    /// connection. A `StreamPacket` struct reference a payload buffer in the
13554    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13555    ///
13556    /// A buffer with ID `id` must not be in the current set when this method is
13557    /// invoked, otherwise the service will close the connection.
13558    pub fn r#add_payload_buffer(
13559        &self,
13560        mut id: u32,
13561        mut payload_buffer: fidl::Vmo,
13562    ) -> Result<(), fidl::Error> {
13563        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13564    }
13565
13566    /// Removes a payload buffer from the current buffer set associated with the
13567    /// connection.
13568    ///
13569    /// A buffer with ID `id` must exist in the current set when this method is
13570    /// invoked, otherwise the service will will close the connection.
13571    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13572        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13573    }
13574}
13575
13576impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13577    fn r#add_payload_buffer(
13578        &self,
13579        mut id: u32,
13580        mut payload_buffer: fidl::Vmo,
13581    ) -> Result<(), fidl::Error> {
13582        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13583            (id, payload_buffer),
13584            0x3b3a37fc34fe5b56,
13585            fidl::encoding::DynamicFlags::empty(),
13586        )
13587    }
13588
13589    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13590        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13591            (id,),
13592            0x5d1e4f74c3658262,
13593            fidl::encoding::DynamicFlags::empty(),
13594        )
13595    }
13596}
13597
13598pub struct StreamBufferSetEventStream {
13599    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13600}
13601
13602impl std::marker::Unpin for StreamBufferSetEventStream {}
13603
13604impl futures::stream::FusedStream for StreamBufferSetEventStream {
13605    fn is_terminated(&self) -> bool {
13606        self.event_receiver.is_terminated()
13607    }
13608}
13609
13610impl futures::Stream for StreamBufferSetEventStream {
13611    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13612
13613    fn poll_next(
13614        mut self: std::pin::Pin<&mut Self>,
13615        cx: &mut std::task::Context<'_>,
13616    ) -> std::task::Poll<Option<Self::Item>> {
13617        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13618            &mut self.event_receiver,
13619            cx
13620        )?) {
13621            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13622            None => std::task::Poll::Ready(None),
13623        }
13624    }
13625}
13626
13627#[derive(Debug)]
13628pub enum StreamBufferSetEvent {}
13629
13630impl StreamBufferSetEvent {
13631    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13632    fn decode(
13633        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13634    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13635        let (bytes, _handles) = buf.split_mut();
13636        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13637        debug_assert_eq!(tx_header.tx_id, 0);
13638        match tx_header.ordinal {
13639            _ => Err(fidl::Error::UnknownOrdinal {
13640                ordinal: tx_header.ordinal,
13641                protocol_name:
13642                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13643            }),
13644        }
13645    }
13646}
13647
13648/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13649pub struct StreamBufferSetRequestStream {
13650    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13651    is_terminated: bool,
13652}
13653
13654impl std::marker::Unpin for StreamBufferSetRequestStream {}
13655
13656impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13657    fn is_terminated(&self) -> bool {
13658        self.is_terminated
13659    }
13660}
13661
13662impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13663    type Protocol = StreamBufferSetMarker;
13664    type ControlHandle = StreamBufferSetControlHandle;
13665
13666    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13667        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13668    }
13669
13670    fn control_handle(&self) -> Self::ControlHandle {
13671        StreamBufferSetControlHandle { inner: self.inner.clone() }
13672    }
13673
13674    fn into_inner(
13675        self,
13676    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13677    {
13678        (self.inner, self.is_terminated)
13679    }
13680
13681    fn from_inner(
13682        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13683        is_terminated: bool,
13684    ) -> Self {
13685        Self { inner, is_terminated }
13686    }
13687}
13688
13689impl futures::Stream for StreamBufferSetRequestStream {
13690    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13691
13692    fn poll_next(
13693        mut self: std::pin::Pin<&mut Self>,
13694        cx: &mut std::task::Context<'_>,
13695    ) -> std::task::Poll<Option<Self::Item>> {
13696        let this = &mut *self;
13697        if this.inner.check_shutdown(cx) {
13698            this.is_terminated = true;
13699            return std::task::Poll::Ready(None);
13700        }
13701        if this.is_terminated {
13702            panic!("polled StreamBufferSetRequestStream after completion");
13703        }
13704        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13705            |bytes, handles| {
13706                match this.inner.channel().read_etc(cx, bytes, handles) {
13707                    std::task::Poll::Ready(Ok(())) => {}
13708                    std::task::Poll::Pending => return std::task::Poll::Pending,
13709                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13710                        this.is_terminated = true;
13711                        return std::task::Poll::Ready(None);
13712                    }
13713                    std::task::Poll::Ready(Err(e)) => {
13714                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13715                            e.into(),
13716                        ))));
13717                    }
13718                }
13719
13720                // A message has been received from the channel
13721                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13722
13723                std::task::Poll::Ready(Some(match header.ordinal {
13724                    0x3b3a37fc34fe5b56 => {
13725                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13726                        let mut req = fidl::new_empty!(
13727                            StreamBufferSetAddPayloadBufferRequest,
13728                            fidl::encoding::DefaultFuchsiaResourceDialect
13729                        );
13730                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13731                        let control_handle =
13732                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13733                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13734                            id: req.id,
13735                            payload_buffer: req.payload_buffer,
13736
13737                            control_handle,
13738                        })
13739                    }
13740                    0x5d1e4f74c3658262 => {
13741                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13742                        let mut req = fidl::new_empty!(
13743                            StreamBufferSetRemovePayloadBufferRequest,
13744                            fidl::encoding::DefaultFuchsiaResourceDialect
13745                        );
13746                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13747                        let control_handle =
13748                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13749                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13750                            id: req.id,
13751
13752                            control_handle,
13753                        })
13754                    }
13755                    _ => Err(fidl::Error::UnknownOrdinal {
13756                        ordinal: header.ordinal,
13757                        protocol_name:
13758                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13759                    }),
13760                }))
13761            },
13762        )
13763    }
13764}
13765
13766/// Manages a set of payload buffers for a stream. This interface is typically
13767/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13768/// of elementary streams between clients and services.
13769#[derive(Debug)]
13770pub enum StreamBufferSetRequest {
13771    /// Adds a payload buffer to the current buffer set associated with the
13772    /// connection. A `StreamPacket` struct reference a payload buffer in the
13773    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13774    ///
13775    /// A buffer with ID `id` must not be in the current set when this method is
13776    /// invoked, otherwise the service will close the connection.
13777    AddPayloadBuffer {
13778        id: u32,
13779        payload_buffer: fidl::Vmo,
13780        control_handle: StreamBufferSetControlHandle,
13781    },
13782    /// Removes a payload buffer from the current buffer set associated with the
13783    /// connection.
13784    ///
13785    /// A buffer with ID `id` must exist in the current set when this method is
13786    /// invoked, otherwise the service will will close the connection.
13787    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13788}
13789
13790impl StreamBufferSetRequest {
13791    #[allow(irrefutable_let_patterns)]
13792    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13793        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13794            self
13795        {
13796            Some((id, payload_buffer, control_handle))
13797        } else {
13798            None
13799        }
13800    }
13801
13802    #[allow(irrefutable_let_patterns)]
13803    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13804        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13805            Some((id, control_handle))
13806        } else {
13807            None
13808        }
13809    }
13810
13811    /// Name of the method defined in FIDL
13812    pub fn method_name(&self) -> &'static str {
13813        match *self {
13814            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13815            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13816        }
13817    }
13818}
13819
13820#[derive(Debug, Clone)]
13821pub struct StreamBufferSetControlHandle {
13822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13823}
13824
13825impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13826    fn shutdown(&self) {
13827        self.inner.shutdown()
13828    }
13829
13830    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13831        self.inner.shutdown_with_epitaph(status)
13832    }
13833
13834    fn is_closed(&self) -> bool {
13835        self.inner.channel().is_closed()
13836    }
13837    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13838        self.inner.channel().on_closed()
13839    }
13840
13841    #[cfg(target_os = "fuchsia")]
13842    fn signal_peer(
13843        &self,
13844        clear_mask: zx::Signals,
13845        set_mask: zx::Signals,
13846    ) -> Result<(), zx_status::Status> {
13847        use fidl::Peered;
13848        self.inner.channel().signal_peer(clear_mask, set_mask)
13849    }
13850}
13851
13852impl StreamBufferSetControlHandle {}
13853
13854#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13855pub struct StreamProcessorMarker;
13856
13857impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13858    type Proxy = StreamProcessorProxy;
13859    type RequestStream = StreamProcessorRequestStream;
13860    #[cfg(target_os = "fuchsia")]
13861    type SynchronousProxy = StreamProcessorSynchronousProxy;
13862
13863    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13864}
13865
13866pub trait StreamProcessorProxyInterface: Send + Sync {
13867    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13868    fn r#set_input_buffer_partial_settings(
13869        &self,
13870        input_settings: StreamBufferPartialSettings,
13871    ) -> Result<(), fidl::Error>;
13872    fn r#set_output_buffer_partial_settings(
13873        &self,
13874        output_settings: StreamBufferPartialSettings,
13875    ) -> Result<(), fidl::Error>;
13876    fn r#complete_output_buffer_partial_settings(
13877        &self,
13878        buffer_lifetime_ordinal: u64,
13879    ) -> Result<(), fidl::Error>;
13880    fn r#flush_end_of_stream_and_close_stream(
13881        &self,
13882        stream_lifetime_ordinal: u64,
13883    ) -> Result<(), fidl::Error>;
13884    fn r#close_current_stream(
13885        &self,
13886        stream_lifetime_ordinal: u64,
13887        release_input_buffers: bool,
13888        release_output_buffers: bool,
13889    ) -> Result<(), fidl::Error>;
13890    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13891    fn r#sync(&self) -> Self::SyncResponseFut;
13892    fn r#recycle_output_packet(
13893        &self,
13894        available_output_packet: &PacketHeader,
13895    ) -> Result<(), fidl::Error>;
13896    fn r#queue_input_format_details(
13897        &self,
13898        stream_lifetime_ordinal: u64,
13899        format_details: &FormatDetails,
13900    ) -> Result<(), fidl::Error>;
13901    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13902    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13903    fn r#participate_in_buffer_allocation(
13904        &self,
13905        payload: StreamProcessorParticipateInBufferAllocationRequest,
13906    ) -> Result<(), fidl::Error>;
13907    fn r#add_buffer(&self, payload: StreamProcessorAddBufferRequest) -> Result<(), fidl::Error>;
13908    type RemoveBufferResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13909    fn r#remove_buffer(
13910        &self,
13911        payload: StreamProcessorRemoveBufferRequest,
13912    ) -> Self::RemoveBufferResponseFut;
13913    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error>;
13914    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error>;
13915    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error>;
13916}
13917#[derive(Debug)]
13918#[cfg(target_os = "fuchsia")]
13919pub struct StreamProcessorSynchronousProxy {
13920    client: fidl::client::sync::Client,
13921}
13922
13923#[cfg(target_os = "fuchsia")]
13924impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13925    type Proxy = StreamProcessorProxy;
13926    type Protocol = StreamProcessorMarker;
13927
13928    fn from_channel(inner: fidl::Channel) -> Self {
13929        Self::new(inner)
13930    }
13931
13932    fn into_channel(self) -> fidl::Channel {
13933        self.client.into_channel()
13934    }
13935
13936    fn as_channel(&self) -> &fidl::Channel {
13937        self.client.as_channel()
13938    }
13939}
13940
13941#[cfg(target_os = "fuchsia")]
13942impl StreamProcessorSynchronousProxy {
13943    pub fn new(channel: fidl::Channel) -> Self {
13944        Self { client: fidl::client::sync::Client::new(channel) }
13945    }
13946
13947    pub fn into_channel(self) -> fidl::Channel {
13948        self.client.into_channel()
13949    }
13950
13951    /// Waits until an event arrives and returns it. It is safe for other
13952    /// threads to make concurrent requests while waiting for an event.
13953    pub fn wait_for_event(
13954        &self,
13955        deadline: zx::MonotonicInstant,
13956    ) -> Result<StreamProcessorEvent, fidl::Error> {
13957        StreamProcessorEvent::decode(self.client.wait_for_event::<StreamProcessorMarker>(deadline)?)
13958    }
13959
13960    /// Permit the server to use OnStreamFailed() instead of the server just
13961    /// closing the whole StreamProcessor channel on stream failure.
13962    ///
13963    /// If the server hasn't seen this message by the time a stream fails, the
13964    /// server will close the StreamProcessor channel instead of sending
13965    /// OnStreamFailed().
13966    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
13967        self.client.send::<fidl::encoding::EmptyPayload>(
13968            (),
13969            0x3940929617dbf02b,
13970            fidl::encoding::DynamicFlags::empty(),
13971        )
13972    }
13973
13974    /// When the client is not using dynamic buffers, a single
13975    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
13976    /// client-specified input settings and a BufferCollectionToken which the
13977    /// StreamProcessor will use to convey constraints to sysmem.  Both the
13978    /// client and the StreamProcessor will be informed of the allocated buffers
13979    /// directly by sysmem via their BufferCollection channel (not via the
13980    /// StreamProcessor channel).
13981    ///
13982    /// The client must not QueueInput...() until after sysmem informs the
13983    /// client that buffer allocation has completed and was successful.
13984    ///
13985    /// The server should be prepared to see QueueInput...() before the server
13986    /// has necessarily heard from sysmem that the buffers are allocated - the
13987    /// server must tolerate either ordering, as the QueueInput...() and
13988    /// notification of sysmem allocation completion arrive on different
13989    /// channels, so the client having heard that allocation is complete doesn't
13990    /// mean the server knows that allocation is complete yet.  However, the
13991    /// server can expect that allocation is in fact complete and can expect to
13992    /// get the allocation information from sysmem immediately upon requesting
13993    /// the information from sysmem.
13994    ///
13995    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
13996    /// while there are any buffers still active on the port. To successfully
13997    /// switch modes for a port, most clients will want to just start over with
13998    /// a new StreamProcessor instance. This can also be done reliably by first
13999    /// ensuring that every added buffer under the port up to "now" (including
14000    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14001    /// request. Only then is it known ok to switch modes for that port under
14002    /// the same StreamProcessor. Most clients will just use one way or the
14003    /// other to add buffers and never need to switch to the other way,
14004    /// especially within the same StreamProcessor.
14005    pub fn r#set_input_buffer_partial_settings(
14006        &self,
14007        mut input_settings: StreamBufferPartialSettings,
14008    ) -> Result<(), fidl::Error> {
14009        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14010            (&mut input_settings,),
14011            0xb02e0663a40e4c4,
14012            fidl::encoding::DynamicFlags::empty(),
14013        )
14014    }
14015
14016    /// This is the replacement for SetOutputBufferSettings().
14017    ///
14018    /// When the client is using sysmem to allocate buffers, this message is
14019    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14020    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14021    /// with the client-specified output settings and a BufferCollectionToken
14022    /// which the StreamProcessor will use to convey constraints to sysmem. Both
14023    /// the client and the StreamProcessor will be informed of the allocated
14024    /// buffers directly by sysmem via their BufferCollection channel (not via
14025    /// the StreamProcessor channel).
14026    ///
14027    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14028    /// received by the client with buffer_constraints_action_required true and
14029    /// stream_lifetime_ordinal equal to the client's current
14030    /// stream_lifetime_ordinal (even if there is an active stream), and is
14031    /// _permitted_ any time there is no current stream.
14032    ///
14033    /// Closing the current stream occurs on the StreamControl ordering domain,
14034    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14035    /// subsequent Sync() completion must be received by the client before the
14036    /// client knows that there's no longer a current stream.
14037    ///
14038    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
14039    /// while there are any buffers still active on the port. To successfully
14040    /// switch modes for a port, most clients will want to just start over with
14041    /// a new StreamProcessor instance. This can also be done reliably by first
14042    /// ensuring that every added buffer under the port up to "now" (including
14043    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14044    /// request. Only then is it known ok to switch modes for that port under
14045    /// the same StreamProcessor. Most clients will just use one way or the
14046    /// other to add buffers and never need to switch to the other way,
14047    /// especially not within the same StreamProcessor instance.
14048    ///
14049    /// See also CompleteOutputBufferPartialSettings().
14050    pub fn r#set_output_buffer_partial_settings(
14051        &self,
14052        mut output_settings: StreamBufferPartialSettings,
14053    ) -> Result<(), fidl::Error> {
14054        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14055            (&mut output_settings,),
14056            0x118bb8c819a7bbbb,
14057            fidl::encoding::DynamicFlags::empty(),
14058        )
14059    }
14060
14061    /// After SetOutputBufferPartialSettings(), the server won't send
14062    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14063    /// OnOutputEndOfStream() until after the client sends
14064    /// CompleteOutputBufferPartialSettings().
14065    ///
14066    /// This message isn't permitted after AddBuffer. When using dynamic buffers
14067    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
14068    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
14069    /// the case of OnOutputPacket there must also be at least one output buffer
14070    /// that's been added but not yet fully removed (RemoveBuffer not yet
14071    /// complete).
14072    ///
14073    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
14074    /// immediately after SetOutputBufferPartialSettings() - in that case the
14075    /// client needs to be prepared to receive output without knowing the buffer
14076    /// count or packet count yet - such clients may internally delay processing
14077    /// the received output until the client has heard from sysmem (which is
14078    /// when the client will learn the buffer count and packet count).
14079    ///
14080    /// Other clients may first wait for sysmem to allocate, prepare to receive
14081    /// output, and then send CompleteOutputBufferPartialSettings().
14082    pub fn r#complete_output_buffer_partial_settings(
14083        &self,
14084        mut buffer_lifetime_ordinal: u64,
14085    ) -> Result<(), fidl::Error> {
14086        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14087            (buffer_lifetime_ordinal,),
14088            0x50529e5c680ae3ab,
14089            fidl::encoding::DynamicFlags::empty(),
14090        )
14091    }
14092
14093    /// This message is optional; a client isn't required to send this ever.
14094    ///
14095    /// Terminology note: In the name of this message, "flush" means flush
14096    /// through, sometimes called "drain". This messge does not discard. To
14097    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
14098    /// without first waiting for OnOutputEndOfStream of the old stream and
14099    /// without sending FlushEndOfStreamAndCloseStream.
14100    ///
14101    /// There is currently no way to cancel the flush effect of this message
14102    /// short of the client closing the StreamProcessor channel.
14103    ///
14104    /// This message is only valid after QueueInputEndOfStream() for this
14105    /// stream. The stream_lifetime_ordinal input parameter must match the
14106    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14107    /// will close the channel.
14108    ///
14109    /// A client can use this message to flush through (drain, not discard) the
14110    /// last input data of a stream so that the stream processor server
14111    /// generates corresponding output data for all the input data before the
14112    /// server moves on to the next stream, without forcing the client to wait
14113    /// for OnOutputEndOfStream() before queueing data of another stream.
14114    ///
14115    /// The difference between QueueInputEndOfStream() and
14116    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14117    /// from the client that there will not be any more input data for the
14118    /// stream (and this info is needed by some stream processors for the stream
14119    /// processor to ever emit the very last output data).  The
14120    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14121    /// later completely discarding the rest of the current stream by closing
14122    /// the current stream (with or without a stream switch).  In contrast,
14123    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14124    /// the previously-queued input data be processed including the logical
14125    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14126    /// before moving on to any newer stream - this essentially changes the
14127    /// close-stream handling from discard to flush-through for this stream
14128    /// only.
14129    ///
14130    /// A client using this message can start providing input data for a new
14131    /// stream without that causing discard of old stream data.  That's the
14132    /// purpose of this message - to allow a client to flush through (not
14133    /// discard) the old stream's last data (instead of the default when closing
14134    /// or switching streams which is discard).
14135    ///
14136    /// Because the old stream is not done processing yet and the old stream's
14137    /// data is not being discarded, the client must be prepared to continue to
14138    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14139    /// is done. The client will know the stream_lifetime_ordinal is done when
14140    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14141    /// closes.
14142    pub fn r#flush_end_of_stream_and_close_stream(
14143        &self,
14144        mut stream_lifetime_ordinal: u64,
14145    ) -> Result<(), fidl::Error> {
14146        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14147            (stream_lifetime_ordinal,),
14148            0x2b62c3e26d0667e6,
14149            fidl::encoding::DynamicFlags::empty(),
14150        )
14151    }
14152
14153    /// This "closes" the current stream, leaving no current stream.  In
14154    /// addition, this message can optionally release (and unregister) input
14155    /// buffers or output buffers.
14156    ///
14157    /// If there has never been any active stream, the stream_lifetime_ordinal
14158    /// must be zero or the server will close the channel.  If there has been an
14159    /// active stream, the stream_lifetime_ordinal must be the most recent
14160    /// active stream whether that stream is still active or not.  Else the
14161    /// server will close the channel.
14162    ///
14163    /// Multiple of this message without any new active stream in between is not
14164    /// to be considered an error, which allows a client to use this message to
14165    /// close the current stream to stop wasting processing power on a stream
14166    /// the user no longer cares about, then later decide that buffers should be
14167    /// released and send this message again with release_input_buffers and/or
14168    /// release_output_buffers true to get the buffers released, if the client
14169    /// is interested in trying to avoid overlap in resource usage between old
14170    /// buffers and new buffers (not all clients are).
14171    ///
14172    /// See also Sync().
14173    pub fn r#close_current_stream(
14174        &self,
14175        mut stream_lifetime_ordinal: u64,
14176        mut release_input_buffers: bool,
14177        mut release_output_buffers: bool,
14178    ) -> Result<(), fidl::Error> {
14179        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14180            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14181            0x1d8a67522170ca07,
14182            fidl::encoding::DynamicFlags::empty(),
14183        )
14184    }
14185
14186    /// On completion, all previous StreamProcessor calls have done what they're
14187    /// going to do server-side, _except_ for processing of data queued using
14188    /// QueueInputPacket().
14189    ///
14190    /// The main purpose of this call is to enable the client to wait until
14191    /// CloseCurrentStream() with release_input_buffers and/or
14192    /// release_output_buffers set to true to take effect, before the client
14193    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14194    /// de-overlapping of resource usage can be worthwhile for media buffers
14195    /// which can consume resource types whose overall pools aren't necessarily
14196    /// vast in comparison to resources consumed.  Especially if a client is
14197    /// reconfiguring buffers multiple times.
14198    ///
14199    /// Note that Sync() prior to allocating new media buffers is not alone
14200    /// sufficient to achieve non-overlap of media buffer resource usage system
14201    /// wide, but it can be a useful part of achieving that.
14202    ///
14203    /// The Sync() transits the Output ordering domain and the StreamControl
14204    /// ordering domain, but not the InputData ordering domain.
14205    ///
14206    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14207    /// presently 10.  A client that stays <= 8 in-flight streams will
14208    /// comfortably stay under the limit of 10.  While the protocol permits
14209    /// repeated SetInputBufferSettings() and the like, a client that spams the
14210    /// channel can expect that the channel will just close if the server or the
14211    /// channel itself gets too far behind.
14212    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
14213        let _response = self.client.send_query::<
14214            fidl::encoding::EmptyPayload,
14215            fidl::encoding::EmptyPayload,
14216            StreamProcessorMarker,
14217        >(
14218            (),
14219            0x4b3e44300b0ec6aa,
14220            fidl::encoding::DynamicFlags::empty(),
14221            ___deadline,
14222        )?;
14223        Ok(_response)
14224    }
14225
14226    /// After the client is done with an output packet, the client needs to tell
14227    /// the stream processor that the output packet can be re-used for more
14228    /// output, using this message.
14229    ///
14230    /// It's not permitted to recycle an output packet that's already free with
14231    /// the stream processor server.
14232    ///
14233    /// If a client is using EnableOldOutputBuffers, the client must recycle all
14234    /// packets when done with them, even those of old buffer_lifetime_ordinal.
14235    /// This is also permitted behavior for all clients.
14236    ///
14237    /// If a client is not using EnableOldOutputBuffers, the client may
14238    /// optionally omit this message for packets with an old
14239    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
14240    /// or implicit output buffer de-configuration don't need to be recycled if
14241    /// the client isn't using and won't be using EnableOldOutputBuffers.
14242    pub fn r#recycle_output_packet(
14243        &self,
14244        mut available_output_packet: &PacketHeader,
14245    ) -> Result<(), fidl::Error> {
14246        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14247            (available_output_packet,),
14248            0x32763632b94e0bd5,
14249            fidl::encoding::DynamicFlags::empty(),
14250        )
14251    }
14252
14253    /// If the input format details are still the same as specified during
14254    /// StreamProcessor creation, this message is unnecessary and does not need
14255    /// to be sent.
14256    ///
14257    /// If the stream doesn't exist yet, this message creates the stream.
14258    ///
14259    /// The server won't send OnOutputConstraints() until after the client has
14260    /// sent at least one QueueInput* message.
14261    ///
14262    /// All servers must permit QueueInputFormatDetails() at the start of a
14263    /// stream without failing, as long as the new format is supported by the
14264    /// StreamProcessor instance. Technically this allows for a server to only
14265    /// support the exact input format set during StreamProcessor creation, and
14266    /// that is by design. A client that tries to switch formats and gets a
14267    /// StreamProcessor channel failure should try again one more time with a
14268    /// fresh StreamProcessor instance created with CodecFactory using the new
14269    /// input format during creation, before giving up.
14270    ///
14271    /// These format details override the format details specified during stream
14272    /// processor creation for this stream only. The next stream will default
14273    /// back to the format details set during stream processor creation.
14274    ///
14275    /// This message is permitted at the start of the first stream (just like at
14276    /// the start of any stream). The format specified need not match what was
14277    /// specified during stream processor creation, but if it doesn't match, the
14278    /// StreamProcessor channel might close as described above.
14279    pub fn r#queue_input_format_details(
14280        &self,
14281        mut stream_lifetime_ordinal: u64,
14282        mut format_details: &FormatDetails,
14283    ) -> Result<(), fidl::Error> {
14284        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14285            (stream_lifetime_ordinal, format_details),
14286            0x170dc0979d52231,
14287            fidl::encoding::DynamicFlags::empty(),
14288        )
14289    }
14290
14291    /// This message queues input data to the stream processor for processing.
14292    ///
14293    /// If the stream doesn't exist yet, this message creates the new stream.
14294    ///
14295    /// The server won't send OnOutputConstraints() until after the client has
14296    /// sent at least one QueueInput* message.
14297    ///
14298    /// When using dynamic buffers the server can send OnOutputConstraints,
14299    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
14300    /// the first QueueInputPacket. In the case of OnOutputPacket there must
14301    /// also be at least one output buffer that's been added but not yet fully
14302    /// removed (RemoveBuffer not yet complete).
14303    ///
14304    /// The client must continue to deliver input data via this message even if
14305    /// the stream processor has not yet generated the first
14306    /// OnOutputConstraints, and even if the StreamProcessor is generating
14307    /// OnFreeInputPacket for previously-queued input packets.  The input data
14308    /// must continue as long as there are free packets to be assured that the
14309    /// server will ever generate the first OnOutputConstraints.
14310    ///
14311    /// The server will close the channel if this packet refers to an old
14312    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
14313    /// different dimensions to a video encoder can either (a) allocate buffers
14314    /// large enough to contain the range of needed image sizes and use those to
14315    /// deliver all the input images, (b) keep their own sets of buffers used
14316    /// for different image dimensions and re-add old buffers with AddBuffer,
14317    /// moving to a new buffer_lifetime_ordinal each time image dimensions
14318    /// change, or (c) allocate new buffers each time image dimensions change.
14319    /// The (a) option is preferred, for clients that have the flexibiilty to
14320    /// store images of varying dimensions in a single set of buffers. Clients
14321    /// that require each buffer to have a single image size can use option (b)
14322    /// or (c).
14323    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14324        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14325            (packet,),
14326            0x47173d2652d9df3b,
14327            fidl::encoding::DynamicFlags::empty(),
14328        )
14329    }
14330
14331    /// Inform the server that all QueueInputPacket() messages for this stream
14332    /// have been sent.
14333    ///
14334    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14335    /// or StreamProcessor channel closing), there will later be a corresponding
14336    /// OnOutputEndOfStream().
14337    ///
14338    /// The corresponding OnOutputEndOfStream() message will be generated only
14339    /// if the server finishes processing the stream before the server sees the
14340    /// client close the stream (such as by starting a new stream). A way to
14341    /// force the server to finish the stream before closing is to use
14342    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
14343    /// any new stream. Another way to force the server to finish the stream
14344    /// before closing is to wait for the OnOutputEndOfStream() before taking
14345    /// any action that closes the stream.
14346    ///
14347    /// In addition to serving as an "EndOfStream" marker to make it obvious
14348    /// client-side when all input data has been processed, if a client never
14349    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
14350    /// result in all input data getting processed through to the output. Some
14351    /// stream processors have some internally-delayed data which only gets
14352    /// drained (pushed through) by additional input data _or_ by this
14353    /// EndOfStream marker. In that sense, this message can be viewed as a drain
14354    /// at InputData domain level, but the drain only takes effect if the stream
14355    /// processor even gets that far before the stream is just closed at
14356    /// StreamControl domain level. This message is not alone sufficient to act
14357    /// as an overall drain at StreamControl level. For that, send this message
14358    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
14359    /// becomes possible to queue input data for a new stream without causing
14360    /// discard of this older stream's data). Alternately, the client can wait
14361    /// for the OnOutputEndOfStream before closing the current stream.
14362    ///
14363    /// After a client sends QueueInputEndOfStream for a stream, if the client
14364    /// then sends for the same stream any of QueueInputPacket,
14365    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
14366    /// the StreamProcessor channel.
14367    pub fn r#queue_input_end_of_stream(
14368        &self,
14369        mut stream_lifetime_ordinal: u64,
14370    ) -> Result<(), fidl::Error> {
14371        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14372            (stream_lifetime_ordinal,),
14373            0x2051b6ad00f20b37,
14374            fidl::encoding::DynamicFlags::empty(),
14375        )
14376    }
14377
14378    /// This message results in channel closure unless supports_dynamic_buffers
14379    /// is set to true.
14380    ///
14381    /// This participates in allocation of buffers to be used with AddBuffer
14382    /// later. The client can get VMO handles for these buffers by also
14383    /// participating in the sysmem allocation, using the client's own related
14384    /// sysmem token (associated with the same logical buffer collection). It's
14385    /// up to the client to separately set any constraints needed by the client
14386    /// using the client's own related sysmem token, if any.
14387    ///
14388    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
14389    /// SetOutputBufferPartialSettings. Servers must support those messages.
14390    ///
14391    /// In handling this message, if `allow_single_buffer` is set to true, the
14392    /// server must not constrain the number of buffers allocated. The server
14393    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
14394    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
14395    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
14396    /// same value if the intent is to allocate exactly that many buffers. If
14397    /// `allow_single_buffer` is un-set or set to false, the server will
14398    /// indicate needed buffer counts to sysmem.
14399    ///
14400    /// The server's BufferCollection channel (created from the passed-in
14401    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
14402    /// particular, the server shouldn't expect the BufferCollection channel to
14403    /// remain connected to sysmem beyond the server sending SetConstraints. For
14404    /// this reason, the server may not be able to call
14405    /// WaitForAllBuffersAllocated or similar, so the server should just send
14406    /// SetConstraints, Close, then close the server's BufferCollection
14407    /// client_end. This means the server in general shouldn't attempt to get
14408    /// VMO handles for these buffers while processing this message.
14409    ///
14410    /// The server should not assume that these buffers will necessarily ever be
14411    /// added with AddBuffer to this StreamProcessor instance or any other
14412    /// StreamProcessor instance (owned by the server or not). These buffers may
14413    /// instead be dropped, or as a less-common example, possibly added to a
14414    /// different codec served by a different server implementation which also
14415    /// participated in the same sysmem buffer collection allocation.
14416    ///
14417    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
14418    /// StreamProcessor instance of the same codec (same per CodecFactory) is
14419    /// likely to work, but using the same StreamProcessor instance is
14420    /// recommended when feasible.
14421    ///
14422    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
14423    /// a different StreamProcessor instance of the same codec (same per
14424    /// CodecFactory) can't (within reason) be made work in general, especially
14425    /// for video decoders. Therefore, for output buffers, the same
14426    /// StreamProcessor instance must be used for this message and AddBuffer.
14427    /// While a client may currently be able to get away with using different
14428    /// StreamProcessor instances for this message and AddBuffer for output
14429    /// buffers for some codecs, this may break at any time without it being
14430    /// considered a server-side bug.
14431    ///
14432    /// The allocated buffers can later be added using AddBuffer (piecemeal),
14433    /// and can be removed (piecemeal) using RemoveBuffer.
14434    ///
14435    /// Multiple different ParticipateInBufferAllocation messages can have their
14436    /// buffers later added to the same StreamProcessor instance using the same
14437    /// buffer_lifetime_ordinal. This can be useful if the client wants to
14438    /// allocate buffers incrementally, or dynamically adjust the number of
14439    /// buffers, potentially while actively processing. See also the
14440    /// `buffer_lifetime_ordinal` field of this message.
14441    ///
14442    /// Server implementations may use sysmem to help verify buffer
14443    /// compatibility later when buffers are added with AddBuffer.
14444    pub fn r#participate_in_buffer_allocation(
14445        &self,
14446        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
14447    ) -> Result<(), fidl::Error> {
14448        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
14449            &mut payload,
14450            0x122be3b0096183cb,
14451            fidl::encoding::DynamicFlags::FLEXIBLE,
14452        )
14453    }
14454
14455    /// Add buffers previously created with the help of
14456    /// ParticipateInBufferAllocation.
14457    ///
14458    /// For input buffers, the client can send QueueInputFormatDetails or
14459    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
14460    /// buffer must be added before a valid QueueInputPacket can be sent. Most
14461    /// clients will want to continue quickly adding buffers up to at least
14462    /// buffer_count_for_server_current to avoid the codec potentially stalling,
14463    /// and typically a low number of buffers beyond that to keep the pipeline
14464    /// running smoothly. Input buffers beyond the first input buffer can be
14465    /// added after the first QueueInputPacket.
14466    ///
14467    /// Even if buffer_constraints_version_ordinal is current, the server must
14468    /// not close the channel if the buffer isn't consistent with the current
14469    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
14470    /// consistent StreamProcessor constraints). Instead, the server must send a
14471    /// new OnOutputConstraints. This simplifies some edge cases for some
14472    /// clients, particularly when a client can't reliably detect whether a
14473    /// newly-obtained buffer was actually allocated after
14474    /// buffer_constraints_version_ordinal changed, or may have been cached from
14475    /// before.
14476    ///
14477    /// The client can add additional buffers to the same port and
14478    /// buffer_lifetime_ordinal at any time using this message. If the
14479    /// buffer_lifetime_ordinal is no longer the most recent, the message will
14480    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
14481    /// message re. the same buffer will complete immediately.
14482    ///
14483    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
14484    /// by the sum of buffers added by all AddBuffer calls with the same
14485    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
14486    /// required to close the channel in this case if performance degradation or
14487    /// un-tested behavior would result from adding too many buffers.
14488    ///
14489    /// Switching to a new buffer_lifetime_ordinal starts the process of
14490    /// removing buffers associated with an old buffer_lifetime_ordinal.
14491    /// However, until the remove is complete, those buffers can still be used
14492    /// by the codec as normal. See also RemoveBuffer, which can be used to
14493    /// detect when removal is complete, regardless of whether the RemoveBuffer
14494    /// started the removal (including when not using dynamic buffers).
14495    ///
14496    /// The buffer stays added until removal later completes. The buffer remains
14497    /// added across potentially multiple buffer re-uses. Removal can be
14498    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
14499    /// The codec server can unilaterally initiate buffer removal; if the server
14500    /// does this, it must send a new buffer_constraints_version_ordinal with
14501    /// action_required true. Some other client-initiated messages can also
14502    /// begin buffer removal, such as CloseCurrentStream with
14503    /// release_input_buffers and/or release_output_buffers. The buffers are
14504    /// also automatically removed and released if the client closes the
14505    /// StreamProcessor client_end or the server closes the StreamProcessor
14506    /// server_end.
14507    ///
14508    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
14509    /// SetOutputBufferPartialSettings is not allowed while there are any
14510    /// buffers still active on the port. To successfully switch modes for a
14511    /// port, most clients will want to just start over with a new
14512    /// StreamProcessor instance. This can also be done reliably by first
14513    /// ensuring that every added buffer under the port up to "now" (including
14514    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14515    /// request. Only then is it known ok to switch modes for that port under
14516    /// the same StreamProcessor. Most clients will just use one way or the
14517    /// other to add buffers and never need to switch to the other way,
14518    /// especially within the same StreamProcessor.
14519    ///
14520    /// If a client might plausibly "spam" creation of many new
14521    /// buffer_lifetime_ordinal values without the buffers seeing any actual
14522    /// usage in between, the client should consider starting a Sync every few
14523    /// buffer_lifetime_ordinal(s) to fence cleanup of old
14524    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
14525    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
14526    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
14527    /// getting too far ahead of closing out old ones. The threshold of 16 is
14528    /// well below the enforcement threshold. Clients don't need to Sync if they
14529    /// won't be spamming new buffer_lifetime_ordinal values, or if added
14530    /// buffers will see at least some actual usage visible to the client before
14531    /// being replaced again.
14532    ///
14533    /// All buffers of the same port and buffer_lifetime_ordinal must share the
14534    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
14535    /// this in various ways. One way is to use ParticipateInBufferAllocation
14536    /// then AddBuffer for at least the first buffer, before
14537    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
14538    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
14539    /// and bump to the next odd buffer_lifetime_ordinal value for the
14540    /// AddBuffer.
14541    pub fn r#add_buffer(
14542        &self,
14543        mut payload: StreamProcessorAddBufferRequest,
14544    ) -> Result<(), fidl::Error> {
14545        self.client.send::<StreamProcessorAddBufferRequest>(
14546            &mut payload,
14547            0x6eca773e923e0ada,
14548            fidl::encoding::DynamicFlags::FLEXIBLE,
14549        )
14550    }
14551
14552    /// When using dynamic buffers, this call removes a buffer as soon as the
14553    /// buffer can be removed without adversely impacting any ongoing processing
14554    /// or an in-flight output packet referring to the buffer.
14555    ///
14556    /// If a client wants to remove a buffer with an in-flight output packet
14557    /// referring to the buffer, the client must RecycleOutputPacket for that
14558    /// in-flight output packet before the RemoveBuffer will complete.
14559    ///
14560    /// When using SetInputBufferPartialSettings /
14561    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
14562    /// the buffer. This call will complete when the buffer is done removing due
14563    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
14564    ///
14565    /// Until RemoveBuffer completes, the codec is still allowed to send
14566    /// OnOutputPacket messages referencing the buffer, and the codec may still
14567    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
14568    /// codec guarantees that no subsequent output packet will reference the
14569    /// buffer, and that the server holds no VMO handles to the buffer.
14570    ///
14571    /// The client may need to recycle an output packet before the RemoveBuffer
14572    /// call can complete. Clients should take care to avoid blocking packet
14573    /// recycling while the RemoveBuffer request is in progress, since this
14574    /// would create a potential deadlock.
14575    ///
14576    /// The server closing any VMO handles to the buffer prior to completing
14577    /// this call is important for the client's ability to prevent memory usage
14578    /// spikes.
14579    ///
14580    /// If the client has "paused" processing by not providing any more input,
14581    /// the client will potentially need to send CloseCurrentStream before
14582    /// RemoveBuffer will complete. When using dynamic buffers, setting
14583    /// release_input_buffers or release_output_buffers to true is not
14584    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
14585    /// specific buffer. When not using dynamic buffers, the client will need to
14586    /// set release_input_buffers or release_output_buffers to true, since
14587    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
14588    /// buffers. A current "paused" stream needs to be stopped because frames
14589    /// can be held as reference frames, and codecs are never reqiured to copy
14590    /// their output data.
14591    ///
14592    /// For any video decoder output buffers being removed while there's an
14593    /// active stream (being fed input or not), it's typically best for the
14594    /// client to assume that removal of a video decoder output buffer may take
14595    /// a very long duration. This is because bitstreams, especially
14596    /// non-standard-compliant bitstreams, but in some cases potentially even
14597    /// standard-compliant bitstreams, can keep a video decoder output buffer in
14598    /// the set of active reference frames (aka DPB) indefinitely. The server is
14599    /// not required to notice that a stream is not conforming to a bitstream
14600    /// standard in this regard.
14601    ///
14602    /// In the case of h.264 decode, a standard-complient bitstream will limit
14603    /// the reorder delay to no longer than the max DPB occupancy. However, a
14604    /// server is not required to detect or reject non-compliant streams that
14605    /// potentially keep a frame in the DPB for longer.
14606    ///
14607    /// For HEVC, the situation is similar to h.264 (IIUC).
14608    ///
14609    /// In the case of VP9, there is nothing in the bitstream spec that limits
14610    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
14611    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
14612    /// required to detect or mitigate this.
14613    ///
14614    /// Until this call completes, the server may still be using the buffer. For
14615    /// output buffers, the server can still send OnOutputPacket message(s) that
14616    /// references this buffer, but only up until the RemoveBuffer completion
14617    /// message is sent by the server. The client must continue to
14618    /// RecycleOutputPacket for packets that reference the buffer, until
14619    /// RemoveBuffer completes.
14620    ///
14621    /// When using dynamic buffers, upon receiving this message, the server will
14622    /// stop selecting the buffer for any new usage (as in, for any usage that
14623    /// moves the buffer from "free" to "not free" within the server). This
14624    /// applies even if the server has no other buffers available for use (aka
14625    /// no other "free" buffers). Any existing usage of the buffer is not ended
14626    /// early by this call alone.
14627    ///
14628    /// When not using dynamic buffers, upon receiving this message, the server
14629    /// will just remember to complete this call shortly after the buffer has
14630    /// completed removal triggered by some other cause (removal is not
14631    /// triggered/caused by this call).
14632    ///
14633    /// For video decoders, when using dynamic buffers, typically the client
14634    /// should take care to avoid removing too many output buffers for continued
14635    /// decode to be possible. If this occurs, the decoder will wait until the
14636    /// client adds another output buffer with AddBuffer. This can be a deadlock
14637    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
14638    /// frame reordering, sending a single AddBuffer doesn't necessarily
14639    /// guarantee another OnOutputPacket, since additional output buffers can be
14640    /// needed before the server can send OnOutputPacket.
14641    ///
14642    /// The client must not call RemoveBuffer on the same buffer more than once,
14643    /// whether overlapping in time or not. The server should enforce this when
14644    /// not enforcing would require tracking additional concurrent requests. The
14645    /// server is not required to enforce this when enforcing would use more
14646    /// server memory.
14647    ///
14648    /// The server is allowed to complete this request quickly with success for
14649    /// buffer_lifetime_ordinal and buffer_index combinations that were never
14650    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
14651    /// hasn't been started by the client yet (no removing potential future
14652    /// buffers).
14653    ///
14654    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
14655    /// combination may be re-used after completion of RemoveBuffer, but only if
14656    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
14657    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
14658    ///
14659    /// Assuming a valid historical buffer is specified, successful completion
14660    /// of this call means the buffer has been fully released by the server and
14661    /// won't be referenced in any subsequent OnOutputPacket.
14662    pub fn r#remove_buffer(
14663        &self,
14664        mut payload: StreamProcessorRemoveBufferRequest,
14665        ___deadline: zx::MonotonicInstant,
14666    ) -> Result<(), fidl::Error> {
14667        let _response = self.client.send_query::<
14668            StreamProcessorRemoveBufferRequest,
14669            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
14670            StreamProcessorMarker,
14671        >(
14672            &mut payload,
14673            0x40b967ffa6b2da43,
14674            fidl::encoding::DynamicFlags::FLEXIBLE,
14675            ___deadline,
14676        )?
14677        .into_result::<StreamProcessorMarker>("remove_buffer")?;
14678        Ok(_response)
14679    }
14680
14681    /// This informs the StreamProcessor that the client is prepared to handle
14682    /// output packets that specify a buffer with buffer_lifetime_ordinal older
14683    /// than the most recent buffer_lifetime_ordinal.
14684    ///
14685    /// If the client doesn't send this message, the StreamProcessor will omit
14686    /// any such output, even if
14687    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
14688    /// decoders such as VP9 decoders, not sending this message can result in
14689    /// output that isn't bistream spec compliant, and the output can be
14690    /// visually different than intended by the bitstream.
14691    ///
14692    /// Such streams are only possible with some bitstream formats (such as
14693    /// VP9), and are rare, but can happen and can be valid per the bitstream
14694    /// spec. For example, this can be specified by a VP9 bitstream using
14695    /// show_existing_frame to output an old-dimensions buffer after having
14696    /// already output a new-dimensions buffer.
14697    ///
14698    /// Most clients that send this message will also want to use RemoveBuffer
14699    /// to know when it becomes safe to stop tracking an old buffer.
14700    ///
14701    /// Most of the time this makes no difference as most bitstreams don't
14702    /// actually emit old buffers, even if the bitstream spec would allow it.
14703    /// Old output buffers are especially rare for RTC streams which typically
14704    /// don't have any frame reordering in the first place.
14705    ///
14706    /// In most video streaming scenarios that use dimension switching as part
14707    /// of their bitrate control strategy (among those that I've observed), at
14708    /// the StreamProcessor layer the new dimensions are part of a new stream
14709    /// instead of being spliced together as a continuation of the old stream.
14710    /// That said, using a continuation of the old stream is also a completely
14711    /// valid way to implement dimension switching. When a stream switch occurs
14712    /// as part of dimension switching, the decoder state is not retained and
14713    /// there won't be any old buffer(s) emitted after new buffer(s), since the
14714    /// new stream doesn't know anything about old buffers filled by the old
14715    /// stream.
14716    ///
14717    /// Clients which haven't tested their ability to handle old output buffers
14718    /// should not send this message. Clients decoding bitstreams like VP9 for
14719    /// decoder compliance testing purposes should send this message (and use a
14720    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
14721    /// Clients which are required to support old output frames and/or fully
14722    /// comply with a relevant bitstream spec should/must send this message, and
14723    /// should test using a test stream that outputs packets referencing an old
14724    /// output buffer.
14725    ///
14726    /// Sending this message more than once closes the channel. If sent, this
14727    /// message must be sent prior to the client establishing the first output
14728    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
14729    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
14730    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
14731    /// client when this message was not sent by the client.
14732    ///
14733    /// This message is only permitted when
14734    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14735    /// is true.
14736    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
14737        self.client.send::<fidl::encoding::EmptyPayload>(
14738            (),
14739            0x3aedefeedf3898b0,
14740            fidl::encoding::DynamicFlags::FLEXIBLE,
14741        )
14742    }
14743
14744    /// This informs the StreamProcessor that the client is prepared to handle
14745    /// output packets that specify the same buffer as another packet that's
14746    /// also concurrently in flight to the client (not yet recycled).
14747    ///
14748    /// Most bitstream formats don't do this. In formats that can do this such
14749    /// as VP9, most actual bitstreams don't do this.
14750    ///
14751    /// As an example, in VP9, a stream can cause the same output buffer to be
14752    /// used by another emitted output packet/frame by using show_existing_frame
14753    /// on the same VP9 reference/held frame slot more than once without
14754    /// decoding a new frame into that slot in between.
14755    ///
14756    /// Clients that need to achieve full bitstream spec compliance for such a
14757    /// bitstream format must send this message.
14758    ///
14759    /// If this message is not in effect, the server will omit any such output,
14760    /// which can result in output that is not compliant to the relevant
14761    /// bitstream spec, and which can be visually different than the stream
14762    /// intended.
14763    ///
14764    /// Sending this message more than once closes the channel. If sent, this
14765    /// message must be sent prior to the client establishing the first output
14766    /// buffer_lifetime_ordinal.
14767    ///
14768    /// This message is only permitted when
14769    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14770    /// is true.
14771    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
14772        self.client.send::<fidl::encoding::EmptyPayload>(
14773            (),
14774            0x244e9f43b29709e7,
14775            fidl::encoding::DynamicFlags::FLEXIBLE,
14776        )
14777    }
14778
14779    /// For video decoders, this forces the output buffers to be reallocated if
14780    /// the image size needs to change. This is wasteful as it forces extra
14781    /// buffer reallocations given typical video bitrate control strategies
14782    /// (applicable to both streaming and RTC) involving shifting the image
14783    /// dimensions up and down repeatedly as a logical video/stream plays,
14784    /// sometimes even if network conditions remain fairly stable. This extra
14785    /// buffer reallocation cost is incurred vs. baseline whether the dimension
14786    /// switching is achieved within a single StreamProcessor stream or by using
14787    /// a new StreamProcessor stream for new dimensions.
14788    ///
14789    /// A client should not send this message unless the client really must
14790    /// force the output buffers to be reallocated every time the output image
14791    /// size changes.
14792    ///
14793    /// Sending this message more than once closes the channel. If sent, this
14794    /// message must be sent prior to any SetInputBufferPartialSettings,
14795    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
14796    /// AddBuffer.
14797    ///
14798    /// This message is only permitted if this StreamProcessor is a video
14799    /// decoder.
14800    ///
14801    /// This message is only permitted when
14802    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14803    /// is true.
14804    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
14805        self.client.send::<fidl::encoding::EmptyPayload>(
14806            (),
14807            0x3994b040f91dc1e9,
14808            fidl::encoding::DynamicFlags::FLEXIBLE,
14809        )
14810    }
14811}
14812
14813#[cfg(target_os = "fuchsia")]
14814impl From<StreamProcessorSynchronousProxy> for zx::NullableHandle {
14815    fn from(value: StreamProcessorSynchronousProxy) -> Self {
14816        value.into_channel().into()
14817    }
14818}
14819
14820#[cfg(target_os = "fuchsia")]
14821impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
14822    fn from(value: fidl::Channel) -> Self {
14823        Self::new(value)
14824    }
14825}
14826
14827#[cfg(target_os = "fuchsia")]
14828impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
14829    type Protocol = StreamProcessorMarker;
14830
14831    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
14832        Self::new(value.into_channel())
14833    }
14834}
14835
14836#[derive(Debug, Clone)]
14837pub struct StreamProcessorProxy {
14838    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
14839}
14840
14841impl fidl::endpoints::Proxy for StreamProcessorProxy {
14842    type Protocol = StreamProcessorMarker;
14843
14844    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
14845        Self::new(inner)
14846    }
14847
14848    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14849        self.client.into_channel().map_err(|client| Self { client })
14850    }
14851
14852    fn as_channel(&self) -> &::fidl::AsyncChannel {
14853        self.client.as_channel()
14854    }
14855}
14856
14857impl StreamProcessorProxy {
14858    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14859    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14860        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14861        Self { client: fidl::client::Client::new(channel, protocol_name) }
14862    }
14863
14864    /// Get a Stream of events from the remote end of the protocol.
14865    ///
14866    /// # Panics
14867    ///
14868    /// Panics if the event stream was already taken.
14869    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14870        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14871    }
14872
14873    /// Permit the server to use OnStreamFailed() instead of the server just
14874    /// closing the whole StreamProcessor channel on stream failure.
14875    ///
14876    /// If the server hasn't seen this message by the time a stream fails, the
14877    /// server will close the StreamProcessor channel instead of sending
14878    /// OnStreamFailed().
14879    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14880        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14881    }
14882
14883    /// When the client is not using dynamic buffers, a single
14884    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
14885    /// client-specified input settings and a BufferCollectionToken which the
14886    /// StreamProcessor will use to convey constraints to sysmem.  Both the
14887    /// client and the StreamProcessor will be informed of the allocated buffers
14888    /// directly by sysmem via their BufferCollection channel (not via the
14889    /// StreamProcessor channel).
14890    ///
14891    /// The client must not QueueInput...() until after sysmem informs the
14892    /// client that buffer allocation has completed and was successful.
14893    ///
14894    /// The server should be prepared to see QueueInput...() before the server
14895    /// has necessarily heard from sysmem that the buffers are allocated - the
14896    /// server must tolerate either ordering, as the QueueInput...() and
14897    /// notification of sysmem allocation completion arrive on different
14898    /// channels, so the client having heard that allocation is complete doesn't
14899    /// mean the server knows that allocation is complete yet.  However, the
14900    /// server can expect that allocation is in fact complete and can expect to
14901    /// get the allocation information from sysmem immediately upon requesting
14902    /// the information from sysmem.
14903    ///
14904    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
14905    /// while there are any buffers still active on the port. To successfully
14906    /// switch modes for a port, most clients will want to just start over with
14907    /// a new StreamProcessor instance. This can also be done reliably by first
14908    /// ensuring that every added buffer under the port up to "now" (including
14909    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14910    /// request. Only then is it known ok to switch modes for that port under
14911    /// the same StreamProcessor. Most clients will just use one way or the
14912    /// other to add buffers and never need to switch to the other way,
14913    /// especially within the same StreamProcessor.
14914    pub fn r#set_input_buffer_partial_settings(
14915        &self,
14916        mut input_settings: StreamBufferPartialSettings,
14917    ) -> Result<(), fidl::Error> {
14918        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14919    }
14920
14921    /// This is the replacement for SetOutputBufferSettings().
14922    ///
14923    /// When the client is using sysmem to allocate buffers, this message is
14924    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14925    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14926    /// with the client-specified output settings and a BufferCollectionToken
14927    /// which the StreamProcessor will use to convey constraints to sysmem. Both
14928    /// the client and the StreamProcessor will be informed of the allocated
14929    /// buffers directly by sysmem via their BufferCollection channel (not via
14930    /// the StreamProcessor channel).
14931    ///
14932    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14933    /// received by the client with buffer_constraints_action_required true and
14934    /// stream_lifetime_ordinal equal to the client's current
14935    /// stream_lifetime_ordinal (even if there is an active stream), and is
14936    /// _permitted_ any time there is no current stream.
14937    ///
14938    /// Closing the current stream occurs on the StreamControl ordering domain,
14939    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14940    /// subsequent Sync() completion must be received by the client before the
14941    /// client knows that there's no longer a current stream.
14942    ///
14943    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
14944    /// while there are any buffers still active on the port. To successfully
14945    /// switch modes for a port, most clients will want to just start over with
14946    /// a new StreamProcessor instance. This can also be done reliably by first
14947    /// ensuring that every added buffer under the port up to "now" (including
14948    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14949    /// request. Only then is it known ok to switch modes for that port under
14950    /// the same StreamProcessor. Most clients will just use one way or the
14951    /// other to add buffers and never need to switch to the other way,
14952    /// especially not within the same StreamProcessor instance.
14953    ///
14954    /// See also CompleteOutputBufferPartialSettings().
14955    pub fn r#set_output_buffer_partial_settings(
14956        &self,
14957        mut output_settings: StreamBufferPartialSettings,
14958    ) -> Result<(), fidl::Error> {
14959        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
14960    }
14961
14962    /// After SetOutputBufferPartialSettings(), the server won't send
14963    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14964    /// OnOutputEndOfStream() until after the client sends
14965    /// CompleteOutputBufferPartialSettings().
14966    ///
14967    /// This message isn't permitted after AddBuffer. When using dynamic buffers
14968    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
14969    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
14970    /// the case of OnOutputPacket there must also be at least one output buffer
14971    /// that's been added but not yet fully removed (RemoveBuffer not yet
14972    /// complete).
14973    ///
14974    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
14975    /// immediately after SetOutputBufferPartialSettings() - in that case the
14976    /// client needs to be prepared to receive output without knowing the buffer
14977    /// count or packet count yet - such clients may internally delay processing
14978    /// the received output until the client has heard from sysmem (which is
14979    /// when the client will learn the buffer count and packet count).
14980    ///
14981    /// Other clients may first wait for sysmem to allocate, prepare to receive
14982    /// output, and then send CompleteOutputBufferPartialSettings().
14983    pub fn r#complete_output_buffer_partial_settings(
14984        &self,
14985        mut buffer_lifetime_ordinal: u64,
14986    ) -> Result<(), fidl::Error> {
14987        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
14988            self,
14989            buffer_lifetime_ordinal,
14990        )
14991    }
14992
14993    /// This message is optional; a client isn't required to send this ever.
14994    ///
14995    /// Terminology note: In the name of this message, "flush" means flush
14996    /// through, sometimes called "drain". This messge does not discard. To
14997    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
14998    /// without first waiting for OnOutputEndOfStream of the old stream and
14999    /// without sending FlushEndOfStreamAndCloseStream.
15000    ///
15001    /// There is currently no way to cancel the flush effect of this message
15002    /// short of the client closing the StreamProcessor channel.
15003    ///
15004    /// This message is only valid after QueueInputEndOfStream() for this
15005    /// stream. The stream_lifetime_ordinal input parameter must match the
15006    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15007    /// will close the channel.
15008    ///
15009    /// A client can use this message to flush through (drain, not discard) the
15010    /// last input data of a stream so that the stream processor server
15011    /// generates corresponding output data for all the input data before the
15012    /// server moves on to the next stream, without forcing the client to wait
15013    /// for OnOutputEndOfStream() before queueing data of another stream.
15014    ///
15015    /// The difference between QueueInputEndOfStream() and
15016    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15017    /// from the client that there will not be any more input data for the
15018    /// stream (and this info is needed by some stream processors for the stream
15019    /// processor to ever emit the very last output data).  The
15020    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15021    /// later completely discarding the rest of the current stream by closing
15022    /// the current stream (with or without a stream switch).  In contrast,
15023    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15024    /// the previously-queued input data be processed including the logical
15025    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15026    /// before moving on to any newer stream - this essentially changes the
15027    /// close-stream handling from discard to flush-through for this stream
15028    /// only.
15029    ///
15030    /// A client using this message can start providing input data for a new
15031    /// stream without that causing discard of old stream data.  That's the
15032    /// purpose of this message - to allow a client to flush through (not
15033    /// discard) the old stream's last data (instead of the default when closing
15034    /// or switching streams which is discard).
15035    ///
15036    /// Because the old stream is not done processing yet and the old stream's
15037    /// data is not being discarded, the client must be prepared to continue to
15038    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15039    /// is done. The client will know the stream_lifetime_ordinal is done when
15040    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15041    /// closes.
15042    pub fn r#flush_end_of_stream_and_close_stream(
15043        &self,
15044        mut stream_lifetime_ordinal: u64,
15045    ) -> Result<(), fidl::Error> {
15046        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
15047            self,
15048            stream_lifetime_ordinal,
15049        )
15050    }
15051
15052    /// This "closes" the current stream, leaving no current stream.  In
15053    /// addition, this message can optionally release (and unregister) input
15054    /// buffers or output buffers.
15055    ///
15056    /// If there has never been any active stream, the stream_lifetime_ordinal
15057    /// must be zero or the server will close the channel.  If there has been an
15058    /// active stream, the stream_lifetime_ordinal must be the most recent
15059    /// active stream whether that stream is still active or not.  Else the
15060    /// server will close the channel.
15061    ///
15062    /// Multiple of this message without any new active stream in between is not
15063    /// to be considered an error, which allows a client to use this message to
15064    /// close the current stream to stop wasting processing power on a stream
15065    /// the user no longer cares about, then later decide that buffers should be
15066    /// released and send this message again with release_input_buffers and/or
15067    /// release_output_buffers true to get the buffers released, if the client
15068    /// is interested in trying to avoid overlap in resource usage between old
15069    /// buffers and new buffers (not all clients are).
15070    ///
15071    /// See also Sync().
15072    pub fn r#close_current_stream(
15073        &self,
15074        mut stream_lifetime_ordinal: u64,
15075        mut release_input_buffers: bool,
15076        mut release_output_buffers: bool,
15077    ) -> Result<(), fidl::Error> {
15078        StreamProcessorProxyInterface::r#close_current_stream(
15079            self,
15080            stream_lifetime_ordinal,
15081            release_input_buffers,
15082            release_output_buffers,
15083        )
15084    }
15085
15086    /// On completion, all previous StreamProcessor calls have done what they're
15087    /// going to do server-side, _except_ for processing of data queued using
15088    /// QueueInputPacket().
15089    ///
15090    /// The main purpose of this call is to enable the client to wait until
15091    /// CloseCurrentStream() with release_input_buffers and/or
15092    /// release_output_buffers set to true to take effect, before the client
15093    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15094    /// de-overlapping of resource usage can be worthwhile for media buffers
15095    /// which can consume resource types whose overall pools aren't necessarily
15096    /// vast in comparison to resources consumed.  Especially if a client is
15097    /// reconfiguring buffers multiple times.
15098    ///
15099    /// Note that Sync() prior to allocating new media buffers is not alone
15100    /// sufficient to achieve non-overlap of media buffer resource usage system
15101    /// wide, but it can be a useful part of achieving that.
15102    ///
15103    /// The Sync() transits the Output ordering domain and the StreamControl
15104    /// ordering domain, but not the InputData ordering domain.
15105    ///
15106    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15107    /// presently 10.  A client that stays <= 8 in-flight streams will
15108    /// comfortably stay under the limit of 10.  While the protocol permits
15109    /// repeated SetInputBufferSettings() and the like, a client that spams the
15110    /// channel can expect that the channel will just close if the server or the
15111    /// channel itself gets too far behind.
15112    pub fn r#sync(
15113        &self,
15114    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15115        StreamProcessorProxyInterface::r#sync(self)
15116    }
15117
15118    /// After the client is done with an output packet, the client needs to tell
15119    /// the stream processor that the output packet can be re-used for more
15120    /// output, using this message.
15121    ///
15122    /// It's not permitted to recycle an output packet that's already free with
15123    /// the stream processor server.
15124    ///
15125    /// If a client is using EnableOldOutputBuffers, the client must recycle all
15126    /// packets when done with them, even those of old buffer_lifetime_ordinal.
15127    /// This is also permitted behavior for all clients.
15128    ///
15129    /// If a client is not using EnableOldOutputBuffers, the client may
15130    /// optionally omit this message for packets with an old
15131    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
15132    /// or implicit output buffer de-configuration don't need to be recycled if
15133    /// the client isn't using and won't be using EnableOldOutputBuffers.
15134    pub fn r#recycle_output_packet(
15135        &self,
15136        mut available_output_packet: &PacketHeader,
15137    ) -> Result<(), fidl::Error> {
15138        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
15139    }
15140
15141    /// If the input format details are still the same as specified during
15142    /// StreamProcessor creation, this message is unnecessary and does not need
15143    /// to be sent.
15144    ///
15145    /// If the stream doesn't exist yet, this message creates the stream.
15146    ///
15147    /// The server won't send OnOutputConstraints() until after the client has
15148    /// sent at least one QueueInput* message.
15149    ///
15150    /// All servers must permit QueueInputFormatDetails() at the start of a
15151    /// stream without failing, as long as the new format is supported by the
15152    /// StreamProcessor instance. Technically this allows for a server to only
15153    /// support the exact input format set during StreamProcessor creation, and
15154    /// that is by design. A client that tries to switch formats and gets a
15155    /// StreamProcessor channel failure should try again one more time with a
15156    /// fresh StreamProcessor instance created with CodecFactory using the new
15157    /// input format during creation, before giving up.
15158    ///
15159    /// These format details override the format details specified during stream
15160    /// processor creation for this stream only. The next stream will default
15161    /// back to the format details set during stream processor creation.
15162    ///
15163    /// This message is permitted at the start of the first stream (just like at
15164    /// the start of any stream). The format specified need not match what was
15165    /// specified during stream processor creation, but if it doesn't match, the
15166    /// StreamProcessor channel might close as described above.
15167    pub fn r#queue_input_format_details(
15168        &self,
15169        mut stream_lifetime_ordinal: u64,
15170        mut format_details: &FormatDetails,
15171    ) -> Result<(), fidl::Error> {
15172        StreamProcessorProxyInterface::r#queue_input_format_details(
15173            self,
15174            stream_lifetime_ordinal,
15175            format_details,
15176        )
15177    }
15178
15179    /// This message queues input data to the stream processor for processing.
15180    ///
15181    /// If the stream doesn't exist yet, this message creates the new stream.
15182    ///
15183    /// The server won't send OnOutputConstraints() until after the client has
15184    /// sent at least one QueueInput* message.
15185    ///
15186    /// When using dynamic buffers the server can send OnOutputConstraints,
15187    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
15188    /// the first QueueInputPacket. In the case of OnOutputPacket there must
15189    /// also be at least one output buffer that's been added but not yet fully
15190    /// removed (RemoveBuffer not yet complete).
15191    ///
15192    /// The client must continue to deliver input data via this message even if
15193    /// the stream processor has not yet generated the first
15194    /// OnOutputConstraints, and even if the StreamProcessor is generating
15195    /// OnFreeInputPacket for previously-queued input packets.  The input data
15196    /// must continue as long as there are free packets to be assured that the
15197    /// server will ever generate the first OnOutputConstraints.
15198    ///
15199    /// The server will close the channel if this packet refers to an old
15200    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
15201    /// different dimensions to a video encoder can either (a) allocate buffers
15202    /// large enough to contain the range of needed image sizes and use those to
15203    /// deliver all the input images, (b) keep their own sets of buffers used
15204    /// for different image dimensions and re-add old buffers with AddBuffer,
15205    /// moving to a new buffer_lifetime_ordinal each time image dimensions
15206    /// change, or (c) allocate new buffers each time image dimensions change.
15207    /// The (a) option is preferred, for clients that have the flexibiilty to
15208    /// store images of varying dimensions in a single set of buffers. Clients
15209    /// that require each buffer to have a single image size can use option (b)
15210    /// or (c).
15211    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
15212        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
15213    }
15214
15215    /// Inform the server that all QueueInputPacket() messages for this stream
15216    /// have been sent.
15217    ///
15218    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15219    /// or StreamProcessor channel closing), there will later be a corresponding
15220    /// OnOutputEndOfStream().
15221    ///
15222    /// The corresponding OnOutputEndOfStream() message will be generated only
15223    /// if the server finishes processing the stream before the server sees the
15224    /// client close the stream (such as by starting a new stream). A way to
15225    /// force the server to finish the stream before closing is to use
15226    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
15227    /// any new stream. Another way to force the server to finish the stream
15228    /// before closing is to wait for the OnOutputEndOfStream() before taking
15229    /// any action that closes the stream.
15230    ///
15231    /// In addition to serving as an "EndOfStream" marker to make it obvious
15232    /// client-side when all input data has been processed, if a client never
15233    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
15234    /// result in all input data getting processed through to the output. Some
15235    /// stream processors have some internally-delayed data which only gets
15236    /// drained (pushed through) by additional input data _or_ by this
15237    /// EndOfStream marker. In that sense, this message can be viewed as a drain
15238    /// at InputData domain level, but the drain only takes effect if the stream
15239    /// processor even gets that far before the stream is just closed at
15240    /// StreamControl domain level. This message is not alone sufficient to act
15241    /// as an overall drain at StreamControl level. For that, send this message
15242    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
15243    /// becomes possible to queue input data for a new stream without causing
15244    /// discard of this older stream's data). Alternately, the client can wait
15245    /// for the OnOutputEndOfStream before closing the current stream.
15246    ///
15247    /// After a client sends QueueInputEndOfStream for a stream, if the client
15248    /// then sends for the same stream any of QueueInputPacket,
15249    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
15250    /// the StreamProcessor channel.
15251    pub fn r#queue_input_end_of_stream(
15252        &self,
15253        mut stream_lifetime_ordinal: u64,
15254    ) -> Result<(), fidl::Error> {
15255        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
15256    }
15257
15258    /// This message results in channel closure unless supports_dynamic_buffers
15259    /// is set to true.
15260    ///
15261    /// This participates in allocation of buffers to be used with AddBuffer
15262    /// later. The client can get VMO handles for these buffers by also
15263    /// participating in the sysmem allocation, using the client's own related
15264    /// sysmem token (associated with the same logical buffer collection). It's
15265    /// up to the client to separately set any constraints needed by the client
15266    /// using the client's own related sysmem token, if any.
15267    ///
15268    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
15269    /// SetOutputBufferPartialSettings. Servers must support those messages.
15270    ///
15271    /// In handling this message, if `allow_single_buffer` is set to true, the
15272    /// server must not constrain the number of buffers allocated. The server
15273    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
15274    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
15275    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
15276    /// same value if the intent is to allocate exactly that many buffers. If
15277    /// `allow_single_buffer` is un-set or set to false, the server will
15278    /// indicate needed buffer counts to sysmem.
15279    ///
15280    /// The server's BufferCollection channel (created from the passed-in
15281    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
15282    /// particular, the server shouldn't expect the BufferCollection channel to
15283    /// remain connected to sysmem beyond the server sending SetConstraints. For
15284    /// this reason, the server may not be able to call
15285    /// WaitForAllBuffersAllocated or similar, so the server should just send
15286    /// SetConstraints, Close, then close the server's BufferCollection
15287    /// client_end. This means the server in general shouldn't attempt to get
15288    /// VMO handles for these buffers while processing this message.
15289    ///
15290    /// The server should not assume that these buffers will necessarily ever be
15291    /// added with AddBuffer to this StreamProcessor instance or any other
15292    /// StreamProcessor instance (owned by the server or not). These buffers may
15293    /// instead be dropped, or as a less-common example, possibly added to a
15294    /// different codec served by a different server implementation which also
15295    /// participated in the same sysmem buffer collection allocation.
15296    ///
15297    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
15298    /// StreamProcessor instance of the same codec (same per CodecFactory) is
15299    /// likely to work, but using the same StreamProcessor instance is
15300    /// recommended when feasible.
15301    ///
15302    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
15303    /// a different StreamProcessor instance of the same codec (same per
15304    /// CodecFactory) can't (within reason) be made work in general, especially
15305    /// for video decoders. Therefore, for output buffers, the same
15306    /// StreamProcessor instance must be used for this message and AddBuffer.
15307    /// While a client may currently be able to get away with using different
15308    /// StreamProcessor instances for this message and AddBuffer for output
15309    /// buffers for some codecs, this may break at any time without it being
15310    /// considered a server-side bug.
15311    ///
15312    /// The allocated buffers can later be added using AddBuffer (piecemeal),
15313    /// and can be removed (piecemeal) using RemoveBuffer.
15314    ///
15315    /// Multiple different ParticipateInBufferAllocation messages can have their
15316    /// buffers later added to the same StreamProcessor instance using the same
15317    /// buffer_lifetime_ordinal. This can be useful if the client wants to
15318    /// allocate buffers incrementally, or dynamically adjust the number of
15319    /// buffers, potentially while actively processing. See also the
15320    /// `buffer_lifetime_ordinal` field of this message.
15321    ///
15322    /// Server implementations may use sysmem to help verify buffer
15323    /// compatibility later when buffers are added with AddBuffer.
15324    pub fn r#participate_in_buffer_allocation(
15325        &self,
15326        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
15327    ) -> Result<(), fidl::Error> {
15328        StreamProcessorProxyInterface::r#participate_in_buffer_allocation(self, payload)
15329    }
15330
15331    /// Add buffers previously created with the help of
15332    /// ParticipateInBufferAllocation.
15333    ///
15334    /// For input buffers, the client can send QueueInputFormatDetails or
15335    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
15336    /// buffer must be added before a valid QueueInputPacket can be sent. Most
15337    /// clients will want to continue quickly adding buffers up to at least
15338    /// buffer_count_for_server_current to avoid the codec potentially stalling,
15339    /// and typically a low number of buffers beyond that to keep the pipeline
15340    /// running smoothly. Input buffers beyond the first input buffer can be
15341    /// added after the first QueueInputPacket.
15342    ///
15343    /// Even if buffer_constraints_version_ordinal is current, the server must
15344    /// not close the channel if the buffer isn't consistent with the current
15345    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
15346    /// consistent StreamProcessor constraints). Instead, the server must send a
15347    /// new OnOutputConstraints. This simplifies some edge cases for some
15348    /// clients, particularly when a client can't reliably detect whether a
15349    /// newly-obtained buffer was actually allocated after
15350    /// buffer_constraints_version_ordinal changed, or may have been cached from
15351    /// before.
15352    ///
15353    /// The client can add additional buffers to the same port and
15354    /// buffer_lifetime_ordinal at any time using this message. If the
15355    /// buffer_lifetime_ordinal is no longer the most recent, the message will
15356    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
15357    /// message re. the same buffer will complete immediately.
15358    ///
15359    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
15360    /// by the sum of buffers added by all AddBuffer calls with the same
15361    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
15362    /// required to close the channel in this case if performance degradation or
15363    /// un-tested behavior would result from adding too many buffers.
15364    ///
15365    /// Switching to a new buffer_lifetime_ordinal starts the process of
15366    /// removing buffers associated with an old buffer_lifetime_ordinal.
15367    /// However, until the remove is complete, those buffers can still be used
15368    /// by the codec as normal. See also RemoveBuffer, which can be used to
15369    /// detect when removal is complete, regardless of whether the RemoveBuffer
15370    /// started the removal (including when not using dynamic buffers).
15371    ///
15372    /// The buffer stays added until removal later completes. The buffer remains
15373    /// added across potentially multiple buffer re-uses. Removal can be
15374    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
15375    /// The codec server can unilaterally initiate buffer removal; if the server
15376    /// does this, it must send a new buffer_constraints_version_ordinal with
15377    /// action_required true. Some other client-initiated messages can also
15378    /// begin buffer removal, such as CloseCurrentStream with
15379    /// release_input_buffers and/or release_output_buffers. The buffers are
15380    /// also automatically removed and released if the client closes the
15381    /// StreamProcessor client_end or the server closes the StreamProcessor
15382    /// server_end.
15383    ///
15384    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
15385    /// SetOutputBufferPartialSettings is not allowed while there are any
15386    /// buffers still active on the port. To successfully switch modes for a
15387    /// port, most clients will want to just start over with a new
15388    /// StreamProcessor instance. This can also be done reliably by first
15389    /// ensuring that every added buffer under the port up to "now" (including
15390    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
15391    /// request. Only then is it known ok to switch modes for that port under
15392    /// the same StreamProcessor. Most clients will just use one way or the
15393    /// other to add buffers and never need to switch to the other way,
15394    /// especially within the same StreamProcessor.
15395    ///
15396    /// If a client might plausibly "spam" creation of many new
15397    /// buffer_lifetime_ordinal values without the buffers seeing any actual
15398    /// usage in between, the client should consider starting a Sync every few
15399    /// buffer_lifetime_ordinal(s) to fence cleanup of old
15400    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
15401    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
15402    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
15403    /// getting too far ahead of closing out old ones. The threshold of 16 is
15404    /// well below the enforcement threshold. Clients don't need to Sync if they
15405    /// won't be spamming new buffer_lifetime_ordinal values, or if added
15406    /// buffers will see at least some actual usage visible to the client before
15407    /// being replaced again.
15408    ///
15409    /// All buffers of the same port and buffer_lifetime_ordinal must share the
15410    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
15411    /// this in various ways. One way is to use ParticipateInBufferAllocation
15412    /// then AddBuffer for at least the first buffer, before
15413    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
15414    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
15415    /// and bump to the next odd buffer_lifetime_ordinal value for the
15416    /// AddBuffer.
15417    pub fn r#add_buffer(
15418        &self,
15419        mut payload: StreamProcessorAddBufferRequest,
15420    ) -> Result<(), fidl::Error> {
15421        StreamProcessorProxyInterface::r#add_buffer(self, payload)
15422    }
15423
15424    /// When using dynamic buffers, this call removes a buffer as soon as the
15425    /// buffer can be removed without adversely impacting any ongoing processing
15426    /// or an in-flight output packet referring to the buffer.
15427    ///
15428    /// If a client wants to remove a buffer with an in-flight output packet
15429    /// referring to the buffer, the client must RecycleOutputPacket for that
15430    /// in-flight output packet before the RemoveBuffer will complete.
15431    ///
15432    /// When using SetInputBufferPartialSettings /
15433    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
15434    /// the buffer. This call will complete when the buffer is done removing due
15435    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
15436    ///
15437    /// Until RemoveBuffer completes, the codec is still allowed to send
15438    /// OnOutputPacket messages referencing the buffer, and the codec may still
15439    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
15440    /// codec guarantees that no subsequent output packet will reference the
15441    /// buffer, and that the server holds no VMO handles to the buffer.
15442    ///
15443    /// The client may need to recycle an output packet before the RemoveBuffer
15444    /// call can complete. Clients should take care to avoid blocking packet
15445    /// recycling while the RemoveBuffer request is in progress, since this
15446    /// would create a potential deadlock.
15447    ///
15448    /// The server closing any VMO handles to the buffer prior to completing
15449    /// this call is important for the client's ability to prevent memory usage
15450    /// spikes.
15451    ///
15452    /// If the client has "paused" processing by not providing any more input,
15453    /// the client will potentially need to send CloseCurrentStream before
15454    /// RemoveBuffer will complete. When using dynamic buffers, setting
15455    /// release_input_buffers or release_output_buffers to true is not
15456    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
15457    /// specific buffer. When not using dynamic buffers, the client will need to
15458    /// set release_input_buffers or release_output_buffers to true, since
15459    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
15460    /// buffers. A current "paused" stream needs to be stopped because frames
15461    /// can be held as reference frames, and codecs are never reqiured to copy
15462    /// their output data.
15463    ///
15464    /// For any video decoder output buffers being removed while there's an
15465    /// active stream (being fed input or not), it's typically best for the
15466    /// client to assume that removal of a video decoder output buffer may take
15467    /// a very long duration. This is because bitstreams, especially
15468    /// non-standard-compliant bitstreams, but in some cases potentially even
15469    /// standard-compliant bitstreams, can keep a video decoder output buffer in
15470    /// the set of active reference frames (aka DPB) indefinitely. The server is
15471    /// not required to notice that a stream is not conforming to a bitstream
15472    /// standard in this regard.
15473    ///
15474    /// In the case of h.264 decode, a standard-complient bitstream will limit
15475    /// the reorder delay to no longer than the max DPB occupancy. However, a
15476    /// server is not required to detect or reject non-compliant streams that
15477    /// potentially keep a frame in the DPB for longer.
15478    ///
15479    /// For HEVC, the situation is similar to h.264 (IIUC).
15480    ///
15481    /// In the case of VP9, there is nothing in the bitstream spec that limits
15482    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
15483    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
15484    /// required to detect or mitigate this.
15485    ///
15486    /// Until this call completes, the server may still be using the buffer. For
15487    /// output buffers, the server can still send OnOutputPacket message(s) that
15488    /// references this buffer, but only up until the RemoveBuffer completion
15489    /// message is sent by the server. The client must continue to
15490    /// RecycleOutputPacket for packets that reference the buffer, until
15491    /// RemoveBuffer completes.
15492    ///
15493    /// When using dynamic buffers, upon receiving this message, the server will
15494    /// stop selecting the buffer for any new usage (as in, for any usage that
15495    /// moves the buffer from "free" to "not free" within the server). This
15496    /// applies even if the server has no other buffers available for use (aka
15497    /// no other "free" buffers). Any existing usage of the buffer is not ended
15498    /// early by this call alone.
15499    ///
15500    /// When not using dynamic buffers, upon receiving this message, the server
15501    /// will just remember to complete this call shortly after the buffer has
15502    /// completed removal triggered by some other cause (removal is not
15503    /// triggered/caused by this call).
15504    ///
15505    /// For video decoders, when using dynamic buffers, typically the client
15506    /// should take care to avoid removing too many output buffers for continued
15507    /// decode to be possible. If this occurs, the decoder will wait until the
15508    /// client adds another output buffer with AddBuffer. This can be a deadlock
15509    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
15510    /// frame reordering, sending a single AddBuffer doesn't necessarily
15511    /// guarantee another OnOutputPacket, since additional output buffers can be
15512    /// needed before the server can send OnOutputPacket.
15513    ///
15514    /// The client must not call RemoveBuffer on the same buffer more than once,
15515    /// whether overlapping in time or not. The server should enforce this when
15516    /// not enforcing would require tracking additional concurrent requests. The
15517    /// server is not required to enforce this when enforcing would use more
15518    /// server memory.
15519    ///
15520    /// The server is allowed to complete this request quickly with success for
15521    /// buffer_lifetime_ordinal and buffer_index combinations that were never
15522    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
15523    /// hasn't been started by the client yet (no removing potential future
15524    /// buffers).
15525    ///
15526    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
15527    /// combination may be re-used after completion of RemoveBuffer, but only if
15528    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
15529    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
15530    ///
15531    /// Assuming a valid historical buffer is specified, successful completion
15532    /// of this call means the buffer has been fully released by the server and
15533    /// won't be referenced in any subsequent OnOutputPacket.
15534    pub fn r#remove_buffer(
15535        &self,
15536        mut payload: StreamProcessorRemoveBufferRequest,
15537    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15538        StreamProcessorProxyInterface::r#remove_buffer(self, payload)
15539    }
15540
15541    /// This informs the StreamProcessor that the client is prepared to handle
15542    /// output packets that specify a buffer with buffer_lifetime_ordinal older
15543    /// than the most recent buffer_lifetime_ordinal.
15544    ///
15545    /// If the client doesn't send this message, the StreamProcessor will omit
15546    /// any such output, even if
15547    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
15548    /// decoders such as VP9 decoders, not sending this message can result in
15549    /// output that isn't bistream spec compliant, and the output can be
15550    /// visually different than intended by the bitstream.
15551    ///
15552    /// Such streams are only possible with some bitstream formats (such as
15553    /// VP9), and are rare, but can happen and can be valid per the bitstream
15554    /// spec. For example, this can be specified by a VP9 bitstream using
15555    /// show_existing_frame to output an old-dimensions buffer after having
15556    /// already output a new-dimensions buffer.
15557    ///
15558    /// Most clients that send this message will also want to use RemoveBuffer
15559    /// to know when it becomes safe to stop tracking an old buffer.
15560    ///
15561    /// Most of the time this makes no difference as most bitstreams don't
15562    /// actually emit old buffers, even if the bitstream spec would allow it.
15563    /// Old output buffers are especially rare for RTC streams which typically
15564    /// don't have any frame reordering in the first place.
15565    ///
15566    /// In most video streaming scenarios that use dimension switching as part
15567    /// of their bitrate control strategy (among those that I've observed), at
15568    /// the StreamProcessor layer the new dimensions are part of a new stream
15569    /// instead of being spliced together as a continuation of the old stream.
15570    /// That said, using a continuation of the old stream is also a completely
15571    /// valid way to implement dimension switching. When a stream switch occurs
15572    /// as part of dimension switching, the decoder state is not retained and
15573    /// there won't be any old buffer(s) emitted after new buffer(s), since the
15574    /// new stream doesn't know anything about old buffers filled by the old
15575    /// stream.
15576    ///
15577    /// Clients which haven't tested their ability to handle old output buffers
15578    /// should not send this message. Clients decoding bitstreams like VP9 for
15579    /// decoder compliance testing purposes should send this message (and use a
15580    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
15581    /// Clients which are required to support old output frames and/or fully
15582    /// comply with a relevant bitstream spec should/must send this message, and
15583    /// should test using a test stream that outputs packets referencing an old
15584    /// output buffer.
15585    ///
15586    /// Sending this message more than once closes the channel. If sent, this
15587    /// message must be sent prior to the client establishing the first output
15588    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
15589    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
15590    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
15591    /// client when this message was not sent by the client.
15592    ///
15593    /// This message is only permitted when
15594    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15595    /// is true.
15596    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
15597        StreamProcessorProxyInterface::r#enable_old_output_buffers(self)
15598    }
15599
15600    /// This informs the StreamProcessor that the client is prepared to handle
15601    /// output packets that specify the same buffer as another packet that's
15602    /// also concurrently in flight to the client (not yet recycled).
15603    ///
15604    /// Most bitstream formats don't do this. In formats that can do this such
15605    /// as VP9, most actual bitstreams don't do this.
15606    ///
15607    /// As an example, in VP9, a stream can cause the same output buffer to be
15608    /// used by another emitted output packet/frame by using show_existing_frame
15609    /// on the same VP9 reference/held frame slot more than once without
15610    /// decoding a new frame into that slot in between.
15611    ///
15612    /// Clients that need to achieve full bitstream spec compliance for such a
15613    /// bitstream format must send this message.
15614    ///
15615    /// If this message is not in effect, the server will omit any such output,
15616    /// which can result in output that is not compliant to the relevant
15617    /// bitstream spec, and which can be visually different than the stream
15618    /// intended.
15619    ///
15620    /// Sending this message more than once closes the channel. If sent, this
15621    /// message must be sent prior to the client establishing the first output
15622    /// buffer_lifetime_ordinal.
15623    ///
15624    /// This message is only permitted when
15625    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15626    /// is true.
15627    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
15628        StreamProcessorProxyInterface::r#enable_same_output_buffer_concurrently_in_flight(self)
15629    }
15630
15631    /// For video decoders, this forces the output buffers to be reallocated if
15632    /// the image size needs to change. This is wasteful as it forces extra
15633    /// buffer reallocations given typical video bitrate control strategies
15634    /// (applicable to both streaming and RTC) involving shifting the image
15635    /// dimensions up and down repeatedly as a logical video/stream plays,
15636    /// sometimes even if network conditions remain fairly stable. This extra
15637    /// buffer reallocation cost is incurred vs. baseline whether the dimension
15638    /// switching is achieved within a single StreamProcessor stream or by using
15639    /// a new StreamProcessor stream for new dimensions.
15640    ///
15641    /// A client should not send this message unless the client really must
15642    /// force the output buffers to be reallocated every time the output image
15643    /// size changes.
15644    ///
15645    /// Sending this message more than once closes the channel. If sent, this
15646    /// message must be sent prior to any SetInputBufferPartialSettings,
15647    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
15648    /// AddBuffer.
15649    ///
15650    /// This message is only permitted if this StreamProcessor is a video
15651    /// decoder.
15652    ///
15653    /// This message is only permitted when
15654    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15655    /// is true.
15656    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
15657        StreamProcessorProxyInterface::r#enable_force_output_buffers_fixed_image_size(self)
15658    }
15659}
15660
15661impl StreamProcessorProxyInterface for StreamProcessorProxy {
15662    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
15663        self.client.send::<fidl::encoding::EmptyPayload>(
15664            (),
15665            0x3940929617dbf02b,
15666            fidl::encoding::DynamicFlags::empty(),
15667        )
15668    }
15669
15670    fn r#set_input_buffer_partial_settings(
15671        &self,
15672        mut input_settings: StreamBufferPartialSettings,
15673    ) -> Result<(), fidl::Error> {
15674        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
15675            (&mut input_settings,),
15676            0xb02e0663a40e4c4,
15677            fidl::encoding::DynamicFlags::empty(),
15678        )
15679    }
15680
15681    fn r#set_output_buffer_partial_settings(
15682        &self,
15683        mut output_settings: StreamBufferPartialSettings,
15684    ) -> Result<(), fidl::Error> {
15685        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
15686            (&mut output_settings,),
15687            0x118bb8c819a7bbbb,
15688            fidl::encoding::DynamicFlags::empty(),
15689        )
15690    }
15691
15692    fn r#complete_output_buffer_partial_settings(
15693        &self,
15694        mut buffer_lifetime_ordinal: u64,
15695    ) -> Result<(), fidl::Error> {
15696        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
15697            (buffer_lifetime_ordinal,),
15698            0x50529e5c680ae3ab,
15699            fidl::encoding::DynamicFlags::empty(),
15700        )
15701    }
15702
15703    fn r#flush_end_of_stream_and_close_stream(
15704        &self,
15705        mut stream_lifetime_ordinal: u64,
15706    ) -> Result<(), fidl::Error> {
15707        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
15708            (stream_lifetime_ordinal,),
15709            0x2b62c3e26d0667e6,
15710            fidl::encoding::DynamicFlags::empty(),
15711        )
15712    }
15713
15714    fn r#close_current_stream(
15715        &self,
15716        mut stream_lifetime_ordinal: u64,
15717        mut release_input_buffers: bool,
15718        mut release_output_buffers: bool,
15719    ) -> Result<(), fidl::Error> {
15720        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
15721            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
15722            0x1d8a67522170ca07,
15723            fidl::encoding::DynamicFlags::empty(),
15724        )
15725    }
15726
15727    type SyncResponseFut =
15728        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15729    fn r#sync(&self) -> Self::SyncResponseFut {
15730        fn _decode(
15731            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15732        ) -> Result<(), fidl::Error> {
15733            let _response = fidl::client::decode_transaction_body::<
15734                fidl::encoding::EmptyPayload,
15735                fidl::encoding::DefaultFuchsiaResourceDialect,
15736                0x4b3e44300b0ec6aa,
15737            >(_buf?)?;
15738            Ok(_response)
15739        }
15740        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
15741            (),
15742            0x4b3e44300b0ec6aa,
15743            fidl::encoding::DynamicFlags::empty(),
15744            _decode,
15745        )
15746    }
15747
15748    fn r#recycle_output_packet(
15749        &self,
15750        mut available_output_packet: &PacketHeader,
15751    ) -> Result<(), fidl::Error> {
15752        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
15753            (available_output_packet,),
15754            0x32763632b94e0bd5,
15755            fidl::encoding::DynamicFlags::empty(),
15756        )
15757    }
15758
15759    fn r#queue_input_format_details(
15760        &self,
15761        mut stream_lifetime_ordinal: u64,
15762        mut format_details: &FormatDetails,
15763    ) -> Result<(), fidl::Error> {
15764        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
15765            (stream_lifetime_ordinal, format_details),
15766            0x170dc0979d52231,
15767            fidl::encoding::DynamicFlags::empty(),
15768        )
15769    }
15770
15771    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
15772        self.client.send::<StreamProcessorQueueInputPacketRequest>(
15773            (packet,),
15774            0x47173d2652d9df3b,
15775            fidl::encoding::DynamicFlags::empty(),
15776        )
15777    }
15778
15779    fn r#queue_input_end_of_stream(
15780        &self,
15781        mut stream_lifetime_ordinal: u64,
15782    ) -> Result<(), fidl::Error> {
15783        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
15784            (stream_lifetime_ordinal,),
15785            0x2051b6ad00f20b37,
15786            fidl::encoding::DynamicFlags::empty(),
15787        )
15788    }
15789
15790    fn r#participate_in_buffer_allocation(
15791        &self,
15792        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
15793    ) -> Result<(), fidl::Error> {
15794        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
15795            &mut payload,
15796            0x122be3b0096183cb,
15797            fidl::encoding::DynamicFlags::FLEXIBLE,
15798        )
15799    }
15800
15801    fn r#add_buffer(
15802        &self,
15803        mut payload: StreamProcessorAddBufferRequest,
15804    ) -> Result<(), fidl::Error> {
15805        self.client.send::<StreamProcessorAddBufferRequest>(
15806            &mut payload,
15807            0x6eca773e923e0ada,
15808            fidl::encoding::DynamicFlags::FLEXIBLE,
15809        )
15810    }
15811
15812    type RemoveBufferResponseFut =
15813        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15814    fn r#remove_buffer(
15815        &self,
15816        mut payload: StreamProcessorRemoveBufferRequest,
15817    ) -> Self::RemoveBufferResponseFut {
15818        fn _decode(
15819            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15820        ) -> Result<(), fidl::Error> {
15821            let _response = fidl::client::decode_transaction_body::<
15822                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
15823                fidl::encoding::DefaultFuchsiaResourceDialect,
15824                0x40b967ffa6b2da43,
15825            >(_buf?)?
15826            .into_result::<StreamProcessorMarker>("remove_buffer")?;
15827            Ok(_response)
15828        }
15829        self.client.send_query_and_decode::<StreamProcessorRemoveBufferRequest, ()>(
15830            &mut payload,
15831            0x40b967ffa6b2da43,
15832            fidl::encoding::DynamicFlags::FLEXIBLE,
15833            _decode,
15834        )
15835    }
15836
15837    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
15838        self.client.send::<fidl::encoding::EmptyPayload>(
15839            (),
15840            0x3aedefeedf3898b0,
15841            fidl::encoding::DynamicFlags::FLEXIBLE,
15842        )
15843    }
15844
15845    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
15846        self.client.send::<fidl::encoding::EmptyPayload>(
15847            (),
15848            0x244e9f43b29709e7,
15849            fidl::encoding::DynamicFlags::FLEXIBLE,
15850        )
15851    }
15852
15853    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
15854        self.client.send::<fidl::encoding::EmptyPayload>(
15855            (),
15856            0x3994b040f91dc1e9,
15857            fidl::encoding::DynamicFlags::FLEXIBLE,
15858        )
15859    }
15860}
15861
15862pub struct StreamProcessorEventStream {
15863    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
15864}
15865
15866impl std::marker::Unpin for StreamProcessorEventStream {}
15867
15868impl futures::stream::FusedStream for StreamProcessorEventStream {
15869    fn is_terminated(&self) -> bool {
15870        self.event_receiver.is_terminated()
15871    }
15872}
15873
15874impl futures::Stream for StreamProcessorEventStream {
15875    type Item = Result<StreamProcessorEvent, fidl::Error>;
15876
15877    fn poll_next(
15878        mut self: std::pin::Pin<&mut Self>,
15879        cx: &mut std::task::Context<'_>,
15880    ) -> std::task::Poll<Option<Self::Item>> {
15881        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15882            &mut self.event_receiver,
15883            cx
15884        )?) {
15885            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
15886            None => std::task::Poll::Ready(None),
15887        }
15888    }
15889}
15890
15891#[derive(Debug)]
15892pub enum StreamProcessorEvent {
15893    OnStreamFailed {
15894        stream_lifetime_ordinal: u64,
15895        error: StreamError,
15896    },
15897    OnInputConstraints {
15898        input_constraints: StreamBufferConstraints,
15899    },
15900    OnOutputConstraints {
15901        output_config: StreamOutputConstraints,
15902    },
15903    OnOutputFormat {
15904        output_format: StreamOutputFormat,
15905    },
15906    OnOutputPacket {
15907        output_packet: Packet,
15908        error_detected_before: bool,
15909        error_detected_during: bool,
15910    },
15911    OnOutputEndOfStream {
15912        stream_lifetime_ordinal: u64,
15913        error_detected_before: bool,
15914    },
15915    OnFreeInputPacket {
15916        free_input_packet: PacketHeader,
15917    },
15918    OnOutputTimestampHasNoOutput {
15919        payload: StreamProcessorOnOutputTimestampHasNoOutputRequest,
15920    },
15921    #[non_exhaustive]
15922    _UnknownEvent {
15923        /// Ordinal of the event that was sent.
15924        ordinal: u64,
15925    },
15926}
15927
15928impl StreamProcessorEvent {
15929    #[allow(irrefutable_let_patterns)]
15930    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
15931        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
15932            Some((stream_lifetime_ordinal, error))
15933        } else {
15934            None
15935        }
15936    }
15937    #[allow(irrefutable_let_patterns)]
15938    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
15939        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
15940            Some((input_constraints))
15941        } else {
15942            None
15943        }
15944    }
15945    #[allow(irrefutable_let_patterns)]
15946    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
15947        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
15948            Some((output_config))
15949        } else {
15950            None
15951        }
15952    }
15953    #[allow(irrefutable_let_patterns)]
15954    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
15955        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
15956            Some((output_format))
15957        } else {
15958            None
15959        }
15960    }
15961    #[allow(irrefutable_let_patterns)]
15962    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
15963        if let StreamProcessorEvent::OnOutputPacket {
15964            output_packet,
15965            error_detected_before,
15966            error_detected_during,
15967        } = self
15968        {
15969            Some((output_packet, error_detected_before, error_detected_during))
15970        } else {
15971            None
15972        }
15973    }
15974    #[allow(irrefutable_let_patterns)]
15975    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
15976        if let StreamProcessorEvent::OnOutputEndOfStream {
15977            stream_lifetime_ordinal,
15978            error_detected_before,
15979        } = self
15980        {
15981            Some((stream_lifetime_ordinal, error_detected_before))
15982        } else {
15983            None
15984        }
15985    }
15986    #[allow(irrefutable_let_patterns)]
15987    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
15988        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
15989            Some((free_input_packet))
15990        } else {
15991            None
15992        }
15993    }
15994    #[allow(irrefutable_let_patterns)]
15995    pub fn into_on_output_timestamp_has_no_output(
15996        self,
15997    ) -> Option<StreamProcessorOnOutputTimestampHasNoOutputRequest> {
15998        if let StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload } = self {
15999            Some((payload))
16000        } else {
16001            None
16002        }
16003    }
16004
16005    /// Decodes a message buffer as a [`StreamProcessorEvent`].
16006    fn decode(
16007        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16008    ) -> Result<StreamProcessorEvent, fidl::Error> {
16009        let (bytes, _handles) = buf.split_mut();
16010        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16011        debug_assert_eq!(tx_header.tx_id, 0);
16012        match tx_header.ordinal {
16013            0x77ccf70bb061cf8e => {
16014                let mut out = fidl::new_empty!(
16015                    StreamProcessorOnStreamFailedRequest,
16016                    fidl::encoding::DefaultFuchsiaResourceDialect
16017                );
16018                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16019                Ok((StreamProcessorEvent::OnStreamFailed {
16020                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
16021                    error: out.error,
16022                }))
16023            }
16024            0x211da9966a8ca0 => {
16025                let mut out = fidl::new_empty!(
16026                    StreamProcessorOnInputConstraintsRequest,
16027                    fidl::encoding::DefaultFuchsiaResourceDialect
16028                );
16029                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16030                Ok((StreamProcessorEvent::OnInputConstraints {
16031                    input_constraints: out.input_constraints,
16032                }))
16033            }
16034            0x40d8234504c170f3 => {
16035                let mut out = fidl::new_empty!(
16036                    StreamProcessorOnOutputConstraintsRequest,
16037                    fidl::encoding::DefaultFuchsiaResourceDialect
16038                );
16039                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16040                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
16041            }
16042            0x131b77ae120360bc => {
16043                let mut out = fidl::new_empty!(
16044                    StreamProcessorOnOutputFormatRequest,
16045                    fidl::encoding::DefaultFuchsiaResourceDialect
16046                );
16047                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16048                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
16049            }
16050            0x5c2029be1090ce93 => {
16051                let mut out = fidl::new_empty!(
16052                    StreamProcessorOnOutputPacketRequest,
16053                    fidl::encoding::DefaultFuchsiaResourceDialect
16054                );
16055                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16056                Ok((StreamProcessorEvent::OnOutputPacket {
16057                    output_packet: out.output_packet,
16058                    error_detected_before: out.error_detected_before,
16059                    error_detected_during: out.error_detected_during,
16060                }))
16061            }
16062            0x3bb65d237cfa50e6 => {
16063                let mut out = fidl::new_empty!(
16064                    StreamProcessorOnOutputEndOfStreamRequest,
16065                    fidl::encoding::DefaultFuchsiaResourceDialect
16066                );
16067                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16068                Ok((StreamProcessorEvent::OnOutputEndOfStream {
16069                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
16070                    error_detected_before: out.error_detected_before,
16071                }))
16072            }
16073            0xeef799b28708bbd => {
16074                let mut out = fidl::new_empty!(
16075                    StreamProcessorOnFreeInputPacketRequest,
16076                    fidl::encoding::DefaultFuchsiaResourceDialect
16077                );
16078                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16079                Ok((StreamProcessorEvent::OnFreeInputPacket {
16080                    free_input_packet: out.free_input_packet,
16081                }))
16082            }
16083            0x7436457799a25cd4 => {
16084                let mut out = fidl::new_empty!(
16085                    StreamProcessorOnOutputTimestampHasNoOutputRequest,
16086                    fidl::encoding::DefaultFuchsiaResourceDialect
16087                );
16088                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16089                Ok((StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload: out }))
16090            }
16091            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16092                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
16093            }
16094            _ => Err(fidl::Error::UnknownOrdinal {
16095                ordinal: tx_header.ordinal,
16096                protocol_name:
16097                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16098            }),
16099        }
16100    }
16101}
16102
16103/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
16104pub struct StreamProcessorRequestStream {
16105    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16106    is_terminated: bool,
16107}
16108
16109impl std::marker::Unpin for StreamProcessorRequestStream {}
16110
16111impl futures::stream::FusedStream for StreamProcessorRequestStream {
16112    fn is_terminated(&self) -> bool {
16113        self.is_terminated
16114    }
16115}
16116
16117impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
16118    type Protocol = StreamProcessorMarker;
16119    type ControlHandle = StreamProcessorControlHandle;
16120
16121    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16122        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16123    }
16124
16125    fn control_handle(&self) -> Self::ControlHandle {
16126        StreamProcessorControlHandle { inner: self.inner.clone() }
16127    }
16128
16129    fn into_inner(
16130        self,
16131    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16132    {
16133        (self.inner, self.is_terminated)
16134    }
16135
16136    fn from_inner(
16137        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16138        is_terminated: bool,
16139    ) -> Self {
16140        Self { inner, is_terminated }
16141    }
16142}
16143
16144impl futures::Stream for StreamProcessorRequestStream {
16145    type Item = Result<StreamProcessorRequest, fidl::Error>;
16146
16147    fn poll_next(
16148        mut self: std::pin::Pin<&mut Self>,
16149        cx: &mut std::task::Context<'_>,
16150    ) -> std::task::Poll<Option<Self::Item>> {
16151        let this = &mut *self;
16152        if this.inner.check_shutdown(cx) {
16153            this.is_terminated = true;
16154            return std::task::Poll::Ready(None);
16155        }
16156        if this.is_terminated {
16157            panic!("polled StreamProcessorRequestStream after completion");
16158        }
16159        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16160            |bytes, handles| {
16161                match this.inner.channel().read_etc(cx, bytes, handles) {
16162                    std::task::Poll::Ready(Ok(())) => {}
16163                    std::task::Poll::Pending => return std::task::Poll::Pending,
16164                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16165                        this.is_terminated = true;
16166                        return std::task::Poll::Ready(None);
16167                    }
16168                    std::task::Poll::Ready(Err(e)) => {
16169                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16170                            e.into(),
16171                        ))));
16172                    }
16173                }
16174
16175                // A message has been received from the channel
16176                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16177
16178                std::task::Poll::Ready(Some(match header.ordinal {
16179                    0x3940929617dbf02b => {
16180                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16181                        let mut req = fidl::new_empty!(
16182                            fidl::encoding::EmptyPayload,
16183                            fidl::encoding::DefaultFuchsiaResourceDialect
16184                        );
16185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16186                        let control_handle =
16187                            StreamProcessorControlHandle { inner: this.inner.clone() };
16188                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
16189                    }
16190                    0xb02e0663a40e4c4 => {
16191                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16192                        let mut req = fidl::new_empty!(
16193                            StreamProcessorSetInputBufferPartialSettingsRequest,
16194                            fidl::encoding::DefaultFuchsiaResourceDialect
16195                        );
16196                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16197                        let control_handle =
16198                            StreamProcessorControlHandle { inner: this.inner.clone() };
16199                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
16200                            input_settings: req.input_settings,
16201
16202                            control_handle,
16203                        })
16204                    }
16205                    0x118bb8c819a7bbbb => {
16206                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16207                        let mut req = fidl::new_empty!(
16208                            StreamProcessorSetOutputBufferPartialSettingsRequest,
16209                            fidl::encoding::DefaultFuchsiaResourceDialect
16210                        );
16211                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16212                        let control_handle =
16213                            StreamProcessorControlHandle { inner: this.inner.clone() };
16214                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
16215                            output_settings: req.output_settings,
16216
16217                            control_handle,
16218                        })
16219                    }
16220                    0x50529e5c680ae3ab => {
16221                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16222                        let mut req = fidl::new_empty!(
16223                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
16224                            fidl::encoding::DefaultFuchsiaResourceDialect
16225                        );
16226                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16227                        let control_handle =
16228                            StreamProcessorControlHandle { inner: this.inner.clone() };
16229                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
16230                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
16231
16232                            control_handle,
16233                        })
16234                    }
16235                    0x2b62c3e26d0667e6 => {
16236                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16237                        let mut req = fidl::new_empty!(
16238                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
16239                            fidl::encoding::DefaultFuchsiaResourceDialect
16240                        );
16241                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16242                        let control_handle =
16243                            StreamProcessorControlHandle { inner: this.inner.clone() };
16244                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
16245                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16246
16247                            control_handle,
16248                        })
16249                    }
16250                    0x1d8a67522170ca07 => {
16251                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16252                        let mut req = fidl::new_empty!(
16253                            StreamProcessorCloseCurrentStreamRequest,
16254                            fidl::encoding::DefaultFuchsiaResourceDialect
16255                        );
16256                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16257                        let control_handle =
16258                            StreamProcessorControlHandle { inner: this.inner.clone() };
16259                        Ok(StreamProcessorRequest::CloseCurrentStream {
16260                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16261                            release_input_buffers: req.release_input_buffers,
16262                            release_output_buffers: req.release_output_buffers,
16263
16264                            control_handle,
16265                        })
16266                    }
16267                    0x4b3e44300b0ec6aa => {
16268                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16269                        let mut req = fidl::new_empty!(
16270                            fidl::encoding::EmptyPayload,
16271                            fidl::encoding::DefaultFuchsiaResourceDialect
16272                        );
16273                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16274                        let control_handle =
16275                            StreamProcessorControlHandle { inner: this.inner.clone() };
16276                        Ok(StreamProcessorRequest::Sync {
16277                            responder: StreamProcessorSyncResponder {
16278                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16279                                tx_id: header.tx_id,
16280                            },
16281                        })
16282                    }
16283                    0x32763632b94e0bd5 => {
16284                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16285                        let mut req = fidl::new_empty!(
16286                            StreamProcessorRecycleOutputPacketRequest,
16287                            fidl::encoding::DefaultFuchsiaResourceDialect
16288                        );
16289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16290                        let control_handle =
16291                            StreamProcessorControlHandle { inner: this.inner.clone() };
16292                        Ok(StreamProcessorRequest::RecycleOutputPacket {
16293                            available_output_packet: req.available_output_packet,
16294
16295                            control_handle,
16296                        })
16297                    }
16298                    0x170dc0979d52231 => {
16299                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16300                        let mut req = fidl::new_empty!(
16301                            StreamProcessorQueueInputFormatDetailsRequest,
16302                            fidl::encoding::DefaultFuchsiaResourceDialect
16303                        );
16304                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
16305                        let control_handle =
16306                            StreamProcessorControlHandle { inner: this.inner.clone() };
16307                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
16308                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16309                            format_details: req.format_details,
16310
16311                            control_handle,
16312                        })
16313                    }
16314                    0x47173d2652d9df3b => {
16315                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16316                        let mut req = fidl::new_empty!(
16317                            StreamProcessorQueueInputPacketRequest,
16318                            fidl::encoding::DefaultFuchsiaResourceDialect
16319                        );
16320                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16321                        let control_handle =
16322                            StreamProcessorControlHandle { inner: this.inner.clone() };
16323                        Ok(StreamProcessorRequest::QueueInputPacket {
16324                            packet: req.packet,
16325
16326                            control_handle,
16327                        })
16328                    }
16329                    0x2051b6ad00f20b37 => {
16330                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16331                        let mut req = fidl::new_empty!(
16332                            StreamProcessorQueueInputEndOfStreamRequest,
16333                            fidl::encoding::DefaultFuchsiaResourceDialect
16334                        );
16335                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16336                        let control_handle =
16337                            StreamProcessorControlHandle { inner: this.inner.clone() };
16338                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
16339                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16340
16341                            control_handle,
16342                        })
16343                    }
16344                    0x122be3b0096183cb => {
16345                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16346                        let mut req = fidl::new_empty!(
16347                            StreamProcessorParticipateInBufferAllocationRequest,
16348                            fidl::encoding::DefaultFuchsiaResourceDialect
16349                        );
16350                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorParticipateInBufferAllocationRequest>(&header, _body_bytes, handles, &mut req)?;
16351                        let control_handle =
16352                            StreamProcessorControlHandle { inner: this.inner.clone() };
16353                        Ok(StreamProcessorRequest::ParticipateInBufferAllocation {
16354                            payload: req,
16355                            control_handle,
16356                        })
16357                    }
16358                    0x6eca773e923e0ada => {
16359                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16360                        let mut req = fidl::new_empty!(
16361                            StreamProcessorAddBufferRequest,
16362                            fidl::encoding::DefaultFuchsiaResourceDialect
16363                        );
16364                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorAddBufferRequest>(&header, _body_bytes, handles, &mut req)?;
16365                        let control_handle =
16366                            StreamProcessorControlHandle { inner: this.inner.clone() };
16367                        Ok(StreamProcessorRequest::AddBuffer { payload: req, control_handle })
16368                    }
16369                    0x40b967ffa6b2da43 => {
16370                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16371                        let mut req = fidl::new_empty!(
16372                            StreamProcessorRemoveBufferRequest,
16373                            fidl::encoding::DefaultFuchsiaResourceDialect
16374                        );
16375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRemoveBufferRequest>(&header, _body_bytes, handles, &mut req)?;
16376                        let control_handle =
16377                            StreamProcessorControlHandle { inner: this.inner.clone() };
16378                        Ok(StreamProcessorRequest::RemoveBuffer {
16379                            payload: req,
16380                            responder: StreamProcessorRemoveBufferResponder {
16381                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16382                                tx_id: header.tx_id,
16383                            },
16384                        })
16385                    }
16386                    0x3aedefeedf3898b0 => {
16387                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16388                        let mut req = fidl::new_empty!(
16389                            fidl::encoding::EmptyPayload,
16390                            fidl::encoding::DefaultFuchsiaResourceDialect
16391                        );
16392                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16393                        let control_handle =
16394                            StreamProcessorControlHandle { inner: this.inner.clone() };
16395                        Ok(StreamProcessorRequest::EnableOldOutputBuffers { control_handle })
16396                    }
16397                    0x244e9f43b29709e7 => {
16398                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16399                        let mut req = fidl::new_empty!(
16400                            fidl::encoding::EmptyPayload,
16401                            fidl::encoding::DefaultFuchsiaResourceDialect
16402                        );
16403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16404                        let control_handle =
16405                            StreamProcessorControlHandle { inner: this.inner.clone() };
16406                        Ok(StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
16407                            control_handle,
16408                        })
16409                    }
16410                    0x3994b040f91dc1e9 => {
16411                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16412                        let mut req = fidl::new_empty!(
16413                            fidl::encoding::EmptyPayload,
16414                            fidl::encoding::DefaultFuchsiaResourceDialect
16415                        );
16416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16417                        let control_handle =
16418                            StreamProcessorControlHandle { inner: this.inner.clone() };
16419                        Ok(StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize {
16420                            control_handle,
16421                        })
16422                    }
16423                    _ if header.tx_id == 0
16424                        && header
16425                            .dynamic_flags()
16426                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
16427                    {
16428                        Ok(StreamProcessorRequest::_UnknownMethod {
16429                            ordinal: header.ordinal,
16430                            control_handle: StreamProcessorControlHandle {
16431                                inner: this.inner.clone(),
16432                            },
16433                            method_type: fidl::MethodType::OneWay,
16434                        })
16435                    }
16436                    _ if header
16437                        .dynamic_flags()
16438                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
16439                    {
16440                        this.inner.send_framework_err(
16441                            fidl::encoding::FrameworkErr::UnknownMethod,
16442                            header.tx_id,
16443                            header.ordinal,
16444                            header.dynamic_flags(),
16445                            (bytes, handles),
16446                        )?;
16447                        Ok(StreamProcessorRequest::_UnknownMethod {
16448                            ordinal: header.ordinal,
16449                            control_handle: StreamProcessorControlHandle {
16450                                inner: this.inner.clone(),
16451                            },
16452                            method_type: fidl::MethodType::TwoWay,
16453                        })
16454                    }
16455                    _ => Err(fidl::Error::UnknownOrdinal {
16456                        ordinal: header.ordinal,
16457                        protocol_name:
16458                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16459                    }),
16460                }))
16461            },
16462        )
16463    }
16464}
16465
16466/// Overview of operation:
16467///
16468/// 1. Create
16469///   * create via CodecFactory - see CodecFactory
16470///   * create via LicenseSession - see LicenseSession
16471/// 2. Get input constraints
16472///   * OnInputConstraints() - sent unsolicited by stream processor shortly
16473///     after stream processor creation.
16474/// 3. Provide input buffers ()
16475///   * SetInputBufferPartialSettings()
16476///   * or AddBuffer, if StreamProcessor reported support for dynamic buffers
16477///     via CodecFactory - in this case, QueueInputFormatDetails and
16478///     QueueInputEndOfStream do not require a prior AddBuffer, but
16479///     QueueInputPacket still does.
16480/// 4. Deliver input data
16481///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
16482///     possibly working through all input packets repeatedly before...
16483/// 5. Get output constraints and format
16484///   * OnOutputConstraints()
16485///   * This is not sent until after at least one QueueInput* message is sent by
16486///     the client, even if the underlying processor behind the StreamProcessor
16487///     doesn't fundamentally need any input data to determine its output
16488///     constraints.  This server behavior prevents clients taking an incorrect
16489///     dependency on the output constraints showing up before input is
16490///     delivered.
16491///   * A client must tolerate this arriving as late as after substantial input
16492///     data has been delivered, including lots of input packet recycling via
16493///     OnFreeInputPacket().
16494///   * This message can arrive more than once before the first output data.
16495/// 6. Provide output buffers
16496///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
16497/// 7. Data flows, with optional EndOfStream
16498///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
16499///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
16500///
16501/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
16502/// very few capabilities) just in case the decoding SW has a vulnerability
16503/// which could be used to take over the StreamProcessor server.  Clients of the
16504/// stream processor interface using decoders and processing streams of separate
16505/// security contexts, to a greater extent than some other interfaces, need to
16506/// protect themselves against invalid server behavior, such as double-free of a
16507/// packet_index and any other invalid server behavior.  Having fed in
16508/// compressed data of one security context, don't place too much trust in a
16509/// single StreamProcessor instance to not mix data among any buffers that
16510/// StreamProcessor server has ever been told about.  Instead, create separate
16511/// StreamProcessor instances for use by security-separate client-side contexts.
16512/// While the picture for HW-based decoders looks somewhat different and is out
16513/// of scope of this paragraph, the client should always use separate
16514/// StreamProcessor instances for security-separate client-side contexts.
16515///
16516/// Descriptions of actions taken by methods of this protocol and the states of
16517/// things are given as if the methods are synchronously executed by the stream
16518/// processor server, but in reality, as is typical of FIDL interfaces, the
16519/// message processing is async.  The states described are to be read as the
16520/// state from the client's point of view unless otherwise stated.  Events
16521/// coming back from the server are of course delivered async, and a client that
16522/// processes more than one stream per StreamProcessor instance needs to care
16523/// whether a given event is from the current stream vs. some older
16524/// soon-to-be-gone stream.
16525///
16526/// The Sync() method's main purpose is to enable the client to robustly prevent
16527/// having both old and new buffers allocated in the system at the same time,
16528/// since media buffers can be significantly large, depending. The Sync() method
16529/// achieves this by only delivering it's response when all previous calls to
16530/// the StreamProcessor protocol have actually taken effect in the
16531/// StreamControl ordering domain. Sync() can also be used to wait for the
16532/// stream processor server to catch up if there's a possibility that a client
16533/// might otherwise get too far ahead of the StreamProcessor server, by for
16534/// example requesting creation of a large number of streams in a row.  It can
16535/// also be used during debugging to ensure that a stream processor server
16536/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
16537/// for correctness - only potentially required to de-overlap resource usage.
16538///
16539/// It's possible to re-use a StreamProcessor instance for another stream, and
16540/// doing so can sometimes skip over re-allocation of buffers. This can be a
16541/// useful thing to do for cases like seeking to a new location - at the
16542/// StreamProcessor interface that can look like switching to a new stream.
16543#[derive(Debug)]
16544pub enum StreamProcessorRequest {
16545    /// Permit the server to use OnStreamFailed() instead of the server just
16546    /// closing the whole StreamProcessor channel on stream failure.
16547    ///
16548    /// If the server hasn't seen this message by the time a stream fails, the
16549    /// server will close the StreamProcessor channel instead of sending
16550    /// OnStreamFailed().
16551    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
16552    /// When the client is not using dynamic buffers, a single
16553    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
16554    /// client-specified input settings and a BufferCollectionToken which the
16555    /// StreamProcessor will use to convey constraints to sysmem.  Both the
16556    /// client and the StreamProcessor will be informed of the allocated buffers
16557    /// directly by sysmem via their BufferCollection channel (not via the
16558    /// StreamProcessor channel).
16559    ///
16560    /// The client must not QueueInput...() until after sysmem informs the
16561    /// client that buffer allocation has completed and was successful.
16562    ///
16563    /// The server should be prepared to see QueueInput...() before the server
16564    /// has necessarily heard from sysmem that the buffers are allocated - the
16565    /// server must tolerate either ordering, as the QueueInput...() and
16566    /// notification of sysmem allocation completion arrive on different
16567    /// channels, so the client having heard that allocation is complete doesn't
16568    /// mean the server knows that allocation is complete yet.  However, the
16569    /// server can expect that allocation is in fact complete and can expect to
16570    /// get the allocation information from sysmem immediately upon requesting
16571    /// the information from sysmem.
16572    ///
16573    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
16574    /// while there are any buffers still active on the port. To successfully
16575    /// switch modes for a port, most clients will want to just start over with
16576    /// a new StreamProcessor instance. This can also be done reliably by first
16577    /// ensuring that every added buffer under the port up to "now" (including
16578    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
16579    /// request. Only then is it known ok to switch modes for that port under
16580    /// the same StreamProcessor. Most clients will just use one way or the
16581    /// other to add buffers and never need to switch to the other way,
16582    /// especially within the same StreamProcessor.
16583    SetInputBufferPartialSettings {
16584        input_settings: StreamBufferPartialSettings,
16585        control_handle: StreamProcessorControlHandle,
16586    },
16587    /// This is the replacement for SetOutputBufferSettings().
16588    ///
16589    /// When the client is using sysmem to allocate buffers, this message is
16590    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
16591    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
16592    /// with the client-specified output settings and a BufferCollectionToken
16593    /// which the StreamProcessor will use to convey constraints to sysmem. Both
16594    /// the client and the StreamProcessor will be informed of the allocated
16595    /// buffers directly by sysmem via their BufferCollection channel (not via
16596    /// the StreamProcessor channel).
16597    ///
16598    /// Configuring output buffers is _required_ after OnOutputConstraints() is
16599    /// received by the client with buffer_constraints_action_required true and
16600    /// stream_lifetime_ordinal equal to the client's current
16601    /// stream_lifetime_ordinal (even if there is an active stream), and is
16602    /// _permitted_ any time there is no current stream.
16603    ///
16604    /// Closing the current stream occurs on the StreamControl ordering domain,
16605    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
16606    /// subsequent Sync() completion must be received by the client before the
16607    /// client knows that there's no longer a current stream.
16608    ///
16609    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
16610    /// while there are any buffers still active on the port. To successfully
16611    /// switch modes for a port, most clients will want to just start over with
16612    /// a new StreamProcessor instance. This can also be done reliably by first
16613    /// ensuring that every added buffer under the port up to "now" (including
16614    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
16615    /// request. Only then is it known ok to switch modes for that port under
16616    /// the same StreamProcessor. Most clients will just use one way or the
16617    /// other to add buffers and never need to switch to the other way,
16618    /// especially not within the same StreamProcessor instance.
16619    ///
16620    /// See also CompleteOutputBufferPartialSettings().
16621    SetOutputBufferPartialSettings {
16622        output_settings: StreamBufferPartialSettings,
16623        control_handle: StreamProcessorControlHandle,
16624    },
16625    /// After SetOutputBufferPartialSettings(), the server won't send
16626    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
16627    /// OnOutputEndOfStream() until after the client sends
16628    /// CompleteOutputBufferPartialSettings().
16629    ///
16630    /// This message isn't permitted after AddBuffer. When using dynamic buffers
16631    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
16632    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
16633    /// the case of OnOutputPacket there must also be at least one output buffer
16634    /// that's been added but not yet fully removed (RemoveBuffer not yet
16635    /// complete).
16636    ///
16637    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
16638    /// immediately after SetOutputBufferPartialSettings() - in that case the
16639    /// client needs to be prepared to receive output without knowing the buffer
16640    /// count or packet count yet - such clients may internally delay processing
16641    /// the received output until the client has heard from sysmem (which is
16642    /// when the client will learn the buffer count and packet count).
16643    ///
16644    /// Other clients may first wait for sysmem to allocate, prepare to receive
16645    /// output, and then send CompleteOutputBufferPartialSettings().
16646    CompleteOutputBufferPartialSettings {
16647        buffer_lifetime_ordinal: u64,
16648        control_handle: StreamProcessorControlHandle,
16649    },
16650    /// This message is optional; a client isn't required to send this ever.
16651    ///
16652    /// Terminology note: In the name of this message, "flush" means flush
16653    /// through, sometimes called "drain". This messge does not discard. To
16654    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
16655    /// without first waiting for OnOutputEndOfStream of the old stream and
16656    /// without sending FlushEndOfStreamAndCloseStream.
16657    ///
16658    /// There is currently no way to cancel the flush effect of this message
16659    /// short of the client closing the StreamProcessor channel.
16660    ///
16661    /// This message is only valid after QueueInputEndOfStream() for this
16662    /// stream. The stream_lifetime_ordinal input parameter must match the
16663    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
16664    /// will close the channel.
16665    ///
16666    /// A client can use this message to flush through (drain, not discard) the
16667    /// last input data of a stream so that the stream processor server
16668    /// generates corresponding output data for all the input data before the
16669    /// server moves on to the next stream, without forcing the client to wait
16670    /// for OnOutputEndOfStream() before queueing data of another stream.
16671    ///
16672    /// The difference between QueueInputEndOfStream() and
16673    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
16674    /// from the client that there will not be any more input data for the
16675    /// stream (and this info is needed by some stream processors for the stream
16676    /// processor to ever emit the very last output data).  The
16677    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
16678    /// later completely discarding the rest of the current stream by closing
16679    /// the current stream (with or without a stream switch).  In contrast,
16680    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
16681    /// the previously-queued input data be processed including the logical
16682    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
16683    /// before moving on to any newer stream - this essentially changes the
16684    /// close-stream handling from discard to flush-through for this stream
16685    /// only.
16686    ///
16687    /// A client using this message can start providing input data for a new
16688    /// stream without that causing discard of old stream data.  That's the
16689    /// purpose of this message - to allow a client to flush through (not
16690    /// discard) the old stream's last data (instead of the default when closing
16691    /// or switching streams which is discard).
16692    ///
16693    /// Because the old stream is not done processing yet and the old stream's
16694    /// data is not being discarded, the client must be prepared to continue to
16695    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
16696    /// is done. The client will know the stream_lifetime_ordinal is done when
16697    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
16698    /// closes.
16699    FlushEndOfStreamAndCloseStream {
16700        stream_lifetime_ordinal: u64,
16701        control_handle: StreamProcessorControlHandle,
16702    },
16703    /// This "closes" the current stream, leaving no current stream.  In
16704    /// addition, this message can optionally release (and unregister) input
16705    /// buffers or output buffers.
16706    ///
16707    /// If there has never been any active stream, the stream_lifetime_ordinal
16708    /// must be zero or the server will close the channel.  If there has been an
16709    /// active stream, the stream_lifetime_ordinal must be the most recent
16710    /// active stream whether that stream is still active or not.  Else the
16711    /// server will close the channel.
16712    ///
16713    /// Multiple of this message without any new active stream in between is not
16714    /// to be considered an error, which allows a client to use this message to
16715    /// close the current stream to stop wasting processing power on a stream
16716    /// the user no longer cares about, then later decide that buffers should be
16717    /// released and send this message again with release_input_buffers and/or
16718    /// release_output_buffers true to get the buffers released, if the client
16719    /// is interested in trying to avoid overlap in resource usage between old
16720    /// buffers and new buffers (not all clients are).
16721    ///
16722    /// See also Sync().
16723    CloseCurrentStream {
16724        stream_lifetime_ordinal: u64,
16725        release_input_buffers: bool,
16726        release_output_buffers: bool,
16727        control_handle: StreamProcessorControlHandle,
16728    },
16729    /// On completion, all previous StreamProcessor calls have done what they're
16730    /// going to do server-side, _except_ for processing of data queued using
16731    /// QueueInputPacket().
16732    ///
16733    /// The main purpose of this call is to enable the client to wait until
16734    /// CloseCurrentStream() with release_input_buffers and/or
16735    /// release_output_buffers set to true to take effect, before the client
16736    /// allocates new buffers and re-sets-up input and/or output buffers.  This
16737    /// de-overlapping of resource usage can be worthwhile for media buffers
16738    /// which can consume resource types whose overall pools aren't necessarily
16739    /// vast in comparison to resources consumed.  Especially if a client is
16740    /// reconfiguring buffers multiple times.
16741    ///
16742    /// Note that Sync() prior to allocating new media buffers is not alone
16743    /// sufficient to achieve non-overlap of media buffer resource usage system
16744    /// wide, but it can be a useful part of achieving that.
16745    ///
16746    /// The Sync() transits the Output ordering domain and the StreamControl
16747    /// ordering domain, but not the InputData ordering domain.
16748    ///
16749    /// This request can be used to avoid hitting kMaxInFlightStreams which is
16750    /// presently 10.  A client that stays <= 8 in-flight streams will
16751    /// comfortably stay under the limit of 10.  While the protocol permits
16752    /// repeated SetInputBufferSettings() and the like, a client that spams the
16753    /// channel can expect that the channel will just close if the server or the
16754    /// channel itself gets too far behind.
16755    Sync { responder: StreamProcessorSyncResponder },
16756    /// After the client is done with an output packet, the client needs to tell
16757    /// the stream processor that the output packet can be re-used for more
16758    /// output, using this message.
16759    ///
16760    /// It's not permitted to recycle an output packet that's already free with
16761    /// the stream processor server.
16762    ///
16763    /// If a client is using EnableOldOutputBuffers, the client must recycle all
16764    /// packets when done with them, even those of old buffer_lifetime_ordinal.
16765    /// This is also permitted behavior for all clients.
16766    ///
16767    /// If a client is not using EnableOldOutputBuffers, the client may
16768    /// optionally omit this message for packets with an old
16769    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
16770    /// or implicit output buffer de-configuration don't need to be recycled if
16771    /// the client isn't using and won't be using EnableOldOutputBuffers.
16772    RecycleOutputPacket {
16773        available_output_packet: PacketHeader,
16774        control_handle: StreamProcessorControlHandle,
16775    },
16776    /// If the input format details are still the same as specified during
16777    /// StreamProcessor creation, this message is unnecessary and does not need
16778    /// to be sent.
16779    ///
16780    /// If the stream doesn't exist yet, this message creates the stream.
16781    ///
16782    /// The server won't send OnOutputConstraints() until after the client has
16783    /// sent at least one QueueInput* message.
16784    ///
16785    /// All servers must permit QueueInputFormatDetails() at the start of a
16786    /// stream without failing, as long as the new format is supported by the
16787    /// StreamProcessor instance. Technically this allows for a server to only
16788    /// support the exact input format set during StreamProcessor creation, and
16789    /// that is by design. A client that tries to switch formats and gets a
16790    /// StreamProcessor channel failure should try again one more time with a
16791    /// fresh StreamProcessor instance created with CodecFactory using the new
16792    /// input format during creation, before giving up.
16793    ///
16794    /// These format details override the format details specified during stream
16795    /// processor creation for this stream only. The next stream will default
16796    /// back to the format details set during stream processor creation.
16797    ///
16798    /// This message is permitted at the start of the first stream (just like at
16799    /// the start of any stream). The format specified need not match what was
16800    /// specified during stream processor creation, but if it doesn't match, the
16801    /// StreamProcessor channel might close as described above.
16802    QueueInputFormatDetails {
16803        stream_lifetime_ordinal: u64,
16804        format_details: FormatDetails,
16805        control_handle: StreamProcessorControlHandle,
16806    },
16807    /// This message queues input data to the stream processor for processing.
16808    ///
16809    /// If the stream doesn't exist yet, this message creates the new stream.
16810    ///
16811    /// The server won't send OnOutputConstraints() until after the client has
16812    /// sent at least one QueueInput* message.
16813    ///
16814    /// When using dynamic buffers the server can send OnOutputConstraints,
16815    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
16816    /// the first QueueInputPacket. In the case of OnOutputPacket there must
16817    /// also be at least one output buffer that's been added but not yet fully
16818    /// removed (RemoveBuffer not yet complete).
16819    ///
16820    /// The client must continue to deliver input data via this message even if
16821    /// the stream processor has not yet generated the first
16822    /// OnOutputConstraints, and even if the StreamProcessor is generating
16823    /// OnFreeInputPacket for previously-queued input packets.  The input data
16824    /// must continue as long as there are free packets to be assured that the
16825    /// server will ever generate the first OnOutputConstraints.
16826    ///
16827    /// The server will close the channel if this packet refers to an old
16828    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
16829    /// different dimensions to a video encoder can either (a) allocate buffers
16830    /// large enough to contain the range of needed image sizes and use those to
16831    /// deliver all the input images, (b) keep their own sets of buffers used
16832    /// for different image dimensions and re-add old buffers with AddBuffer,
16833    /// moving to a new buffer_lifetime_ordinal each time image dimensions
16834    /// change, or (c) allocate new buffers each time image dimensions change.
16835    /// The (a) option is preferred, for clients that have the flexibiilty to
16836    /// store images of varying dimensions in a single set of buffers. Clients
16837    /// that require each buffer to have a single image size can use option (b)
16838    /// or (c).
16839    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
16840    /// Inform the server that all QueueInputPacket() messages for this stream
16841    /// have been sent.
16842    ///
16843    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
16844    /// or StreamProcessor channel closing), there will later be a corresponding
16845    /// OnOutputEndOfStream().
16846    ///
16847    /// The corresponding OnOutputEndOfStream() message will be generated only
16848    /// if the server finishes processing the stream before the server sees the
16849    /// client close the stream (such as by starting a new stream). A way to
16850    /// force the server to finish the stream before closing is to use
16851    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
16852    /// any new stream. Another way to force the server to finish the stream
16853    /// before closing is to wait for the OnOutputEndOfStream() before taking
16854    /// any action that closes the stream.
16855    ///
16856    /// In addition to serving as an "EndOfStream" marker to make it obvious
16857    /// client-side when all input data has been processed, if a client never
16858    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
16859    /// result in all input data getting processed through to the output. Some
16860    /// stream processors have some internally-delayed data which only gets
16861    /// drained (pushed through) by additional input data _or_ by this
16862    /// EndOfStream marker. In that sense, this message can be viewed as a drain
16863    /// at InputData domain level, but the drain only takes effect if the stream
16864    /// processor even gets that far before the stream is just closed at
16865    /// StreamControl domain level. This message is not alone sufficient to act
16866    /// as an overall drain at StreamControl level. For that, send this message
16867    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
16868    /// becomes possible to queue input data for a new stream without causing
16869    /// discard of this older stream's data). Alternately, the client can wait
16870    /// for the OnOutputEndOfStream before closing the current stream.
16871    ///
16872    /// After a client sends QueueInputEndOfStream for a stream, if the client
16873    /// then sends for the same stream any of QueueInputPacket,
16874    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
16875    /// the StreamProcessor channel.
16876    QueueInputEndOfStream {
16877        stream_lifetime_ordinal: u64,
16878        control_handle: StreamProcessorControlHandle,
16879    },
16880    /// This message results in channel closure unless supports_dynamic_buffers
16881    /// is set to true.
16882    ///
16883    /// This participates in allocation of buffers to be used with AddBuffer
16884    /// later. The client can get VMO handles for these buffers by also
16885    /// participating in the sysmem allocation, using the client's own related
16886    /// sysmem token (associated with the same logical buffer collection). It's
16887    /// up to the client to separately set any constraints needed by the client
16888    /// using the client's own related sysmem token, if any.
16889    ///
16890    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
16891    /// SetOutputBufferPartialSettings. Servers must support those messages.
16892    ///
16893    /// In handling this message, if `allow_single_buffer` is set to true, the
16894    /// server must not constrain the number of buffers allocated. The server
16895    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
16896    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
16897    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
16898    /// same value if the intent is to allocate exactly that many buffers. If
16899    /// `allow_single_buffer` is un-set or set to false, the server will
16900    /// indicate needed buffer counts to sysmem.
16901    ///
16902    /// The server's BufferCollection channel (created from the passed-in
16903    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
16904    /// particular, the server shouldn't expect the BufferCollection channel to
16905    /// remain connected to sysmem beyond the server sending SetConstraints. For
16906    /// this reason, the server may not be able to call
16907    /// WaitForAllBuffersAllocated or similar, so the server should just send
16908    /// SetConstraints, Close, then close the server's BufferCollection
16909    /// client_end. This means the server in general shouldn't attempt to get
16910    /// VMO handles for these buffers while processing this message.
16911    ///
16912    /// The server should not assume that these buffers will necessarily ever be
16913    /// added with AddBuffer to this StreamProcessor instance or any other
16914    /// StreamProcessor instance (owned by the server or not). These buffers may
16915    /// instead be dropped, or as a less-common example, possibly added to a
16916    /// different codec served by a different server implementation which also
16917    /// participated in the same sysmem buffer collection allocation.
16918    ///
16919    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
16920    /// StreamProcessor instance of the same codec (same per CodecFactory) is
16921    /// likely to work, but using the same StreamProcessor instance is
16922    /// recommended when feasible.
16923    ///
16924    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
16925    /// a different StreamProcessor instance of the same codec (same per
16926    /// CodecFactory) can't (within reason) be made work in general, especially
16927    /// for video decoders. Therefore, for output buffers, the same
16928    /// StreamProcessor instance must be used for this message and AddBuffer.
16929    /// While a client may currently be able to get away with using different
16930    /// StreamProcessor instances for this message and AddBuffer for output
16931    /// buffers for some codecs, this may break at any time without it being
16932    /// considered a server-side bug.
16933    ///
16934    /// The allocated buffers can later be added using AddBuffer (piecemeal),
16935    /// and can be removed (piecemeal) using RemoveBuffer.
16936    ///
16937    /// Multiple different ParticipateInBufferAllocation messages can have their
16938    /// buffers later added to the same StreamProcessor instance using the same
16939    /// buffer_lifetime_ordinal. This can be useful if the client wants to
16940    /// allocate buffers incrementally, or dynamically adjust the number of
16941    /// buffers, potentially while actively processing. See also the
16942    /// `buffer_lifetime_ordinal` field of this message.
16943    ///
16944    /// Server implementations may use sysmem to help verify buffer
16945    /// compatibility later when buffers are added with AddBuffer.
16946    ParticipateInBufferAllocation {
16947        payload: StreamProcessorParticipateInBufferAllocationRequest,
16948        control_handle: StreamProcessorControlHandle,
16949    },
16950    /// Add buffers previously created with the help of
16951    /// ParticipateInBufferAllocation.
16952    ///
16953    /// For input buffers, the client can send QueueInputFormatDetails or
16954    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
16955    /// buffer must be added before a valid QueueInputPacket can be sent. Most
16956    /// clients will want to continue quickly adding buffers up to at least
16957    /// buffer_count_for_server_current to avoid the codec potentially stalling,
16958    /// and typically a low number of buffers beyond that to keep the pipeline
16959    /// running smoothly. Input buffers beyond the first input buffer can be
16960    /// added after the first QueueInputPacket.
16961    ///
16962    /// Even if buffer_constraints_version_ordinal is current, the server must
16963    /// not close the channel if the buffer isn't consistent with the current
16964    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
16965    /// consistent StreamProcessor constraints). Instead, the server must send a
16966    /// new OnOutputConstraints. This simplifies some edge cases for some
16967    /// clients, particularly when a client can't reliably detect whether a
16968    /// newly-obtained buffer was actually allocated after
16969    /// buffer_constraints_version_ordinal changed, or may have been cached from
16970    /// before.
16971    ///
16972    /// The client can add additional buffers to the same port and
16973    /// buffer_lifetime_ordinal at any time using this message. If the
16974    /// buffer_lifetime_ordinal is no longer the most recent, the message will
16975    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
16976    /// message re. the same buffer will complete immediately.
16977    ///
16978    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
16979    /// by the sum of buffers added by all AddBuffer calls with the same
16980    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
16981    /// required to close the channel in this case if performance degradation or
16982    /// un-tested behavior would result from adding too many buffers.
16983    ///
16984    /// Switching to a new buffer_lifetime_ordinal starts the process of
16985    /// removing buffers associated with an old buffer_lifetime_ordinal.
16986    /// However, until the remove is complete, those buffers can still be used
16987    /// by the codec as normal. See also RemoveBuffer, which can be used to
16988    /// detect when removal is complete, regardless of whether the RemoveBuffer
16989    /// started the removal (including when not using dynamic buffers).
16990    ///
16991    /// The buffer stays added until removal later completes. The buffer remains
16992    /// added across potentially multiple buffer re-uses. Removal can be
16993    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
16994    /// The codec server can unilaterally initiate buffer removal; if the server
16995    /// does this, it must send a new buffer_constraints_version_ordinal with
16996    /// action_required true. Some other client-initiated messages can also
16997    /// begin buffer removal, such as CloseCurrentStream with
16998    /// release_input_buffers and/or release_output_buffers. The buffers are
16999    /// also automatically removed and released if the client closes the
17000    /// StreamProcessor client_end or the server closes the StreamProcessor
17001    /// server_end.
17002    ///
17003    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
17004    /// SetOutputBufferPartialSettings is not allowed while there are any
17005    /// buffers still active on the port. To successfully switch modes for a
17006    /// port, most clients will want to just start over with a new
17007    /// StreamProcessor instance. This can also be done reliably by first
17008    /// ensuring that every added buffer under the port up to "now" (including
17009    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
17010    /// request. Only then is it known ok to switch modes for that port under
17011    /// the same StreamProcessor. Most clients will just use one way or the
17012    /// other to add buffers and never need to switch to the other way,
17013    /// especially within the same StreamProcessor.
17014    ///
17015    /// If a client might plausibly "spam" creation of many new
17016    /// buffer_lifetime_ordinal values without the buffers seeing any actual
17017    /// usage in between, the client should consider starting a Sync every few
17018    /// buffer_lifetime_ordinal(s) to fence cleanup of old
17019    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
17020    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
17021    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
17022    /// getting too far ahead of closing out old ones. The threshold of 16 is
17023    /// well below the enforcement threshold. Clients don't need to Sync if they
17024    /// won't be spamming new buffer_lifetime_ordinal values, or if added
17025    /// buffers will see at least some actual usage visible to the client before
17026    /// being replaced again.
17027    ///
17028    /// All buffers of the same port and buffer_lifetime_ordinal must share the
17029    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
17030    /// this in various ways. One way is to use ParticipateInBufferAllocation
17031    /// then AddBuffer for at least the first buffer, before
17032    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
17033    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
17034    /// and bump to the next odd buffer_lifetime_ordinal value for the
17035    /// AddBuffer.
17036    AddBuffer {
17037        payload: StreamProcessorAddBufferRequest,
17038        control_handle: StreamProcessorControlHandle,
17039    },
17040    /// When using dynamic buffers, this call removes a buffer as soon as the
17041    /// buffer can be removed without adversely impacting any ongoing processing
17042    /// or an in-flight output packet referring to the buffer.
17043    ///
17044    /// If a client wants to remove a buffer with an in-flight output packet
17045    /// referring to the buffer, the client must RecycleOutputPacket for that
17046    /// in-flight output packet before the RemoveBuffer will complete.
17047    ///
17048    /// When using SetInputBufferPartialSettings /
17049    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
17050    /// the buffer. This call will complete when the buffer is done removing due
17051    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
17052    ///
17053    /// Until RemoveBuffer completes, the codec is still allowed to send
17054    /// OnOutputPacket messages referencing the buffer, and the codec may still
17055    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
17056    /// codec guarantees that no subsequent output packet will reference the
17057    /// buffer, and that the server holds no VMO handles to the buffer.
17058    ///
17059    /// The client may need to recycle an output packet before the RemoveBuffer
17060    /// call can complete. Clients should take care to avoid blocking packet
17061    /// recycling while the RemoveBuffer request is in progress, since this
17062    /// would create a potential deadlock.
17063    ///
17064    /// The server closing any VMO handles to the buffer prior to completing
17065    /// this call is important for the client's ability to prevent memory usage
17066    /// spikes.
17067    ///
17068    /// If the client has "paused" processing by not providing any more input,
17069    /// the client will potentially need to send CloseCurrentStream before
17070    /// RemoveBuffer will complete. When using dynamic buffers, setting
17071    /// release_input_buffers or release_output_buffers to true is not
17072    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
17073    /// specific buffer. When not using dynamic buffers, the client will need to
17074    /// set release_input_buffers or release_output_buffers to true, since
17075    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
17076    /// buffers. A current "paused" stream needs to be stopped because frames
17077    /// can be held as reference frames, and codecs are never reqiured to copy
17078    /// their output data.
17079    ///
17080    /// For any video decoder output buffers being removed while there's an
17081    /// active stream (being fed input or not), it's typically best for the
17082    /// client to assume that removal of a video decoder output buffer may take
17083    /// a very long duration. This is because bitstreams, especially
17084    /// non-standard-compliant bitstreams, but in some cases potentially even
17085    /// standard-compliant bitstreams, can keep a video decoder output buffer in
17086    /// the set of active reference frames (aka DPB) indefinitely. The server is
17087    /// not required to notice that a stream is not conforming to a bitstream
17088    /// standard in this regard.
17089    ///
17090    /// In the case of h.264 decode, a standard-complient bitstream will limit
17091    /// the reorder delay to no longer than the max DPB occupancy. However, a
17092    /// server is not required to detect or reject non-compliant streams that
17093    /// potentially keep a frame in the DPB for longer.
17094    ///
17095    /// For HEVC, the situation is similar to h.264 (IIUC).
17096    ///
17097    /// In the case of VP9, there is nothing in the bitstream spec that limits
17098    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
17099    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
17100    /// required to detect or mitigate this.
17101    ///
17102    /// Until this call completes, the server may still be using the buffer. For
17103    /// output buffers, the server can still send OnOutputPacket message(s) that
17104    /// references this buffer, but only up until the RemoveBuffer completion
17105    /// message is sent by the server. The client must continue to
17106    /// RecycleOutputPacket for packets that reference the buffer, until
17107    /// RemoveBuffer completes.
17108    ///
17109    /// When using dynamic buffers, upon receiving this message, the server will
17110    /// stop selecting the buffer for any new usage (as in, for any usage that
17111    /// moves the buffer from "free" to "not free" within the server). This
17112    /// applies even if the server has no other buffers available for use (aka
17113    /// no other "free" buffers). Any existing usage of the buffer is not ended
17114    /// early by this call alone.
17115    ///
17116    /// When not using dynamic buffers, upon receiving this message, the server
17117    /// will just remember to complete this call shortly after the buffer has
17118    /// completed removal triggered by some other cause (removal is not
17119    /// triggered/caused by this call).
17120    ///
17121    /// For video decoders, when using dynamic buffers, typically the client
17122    /// should take care to avoid removing too many output buffers for continued
17123    /// decode to be possible. If this occurs, the decoder will wait until the
17124    /// client adds another output buffer with AddBuffer. This can be a deadlock
17125    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
17126    /// frame reordering, sending a single AddBuffer doesn't necessarily
17127    /// guarantee another OnOutputPacket, since additional output buffers can be
17128    /// needed before the server can send OnOutputPacket.
17129    ///
17130    /// The client must not call RemoveBuffer on the same buffer more than once,
17131    /// whether overlapping in time or not. The server should enforce this when
17132    /// not enforcing would require tracking additional concurrent requests. The
17133    /// server is not required to enforce this when enforcing would use more
17134    /// server memory.
17135    ///
17136    /// The server is allowed to complete this request quickly with success for
17137    /// buffer_lifetime_ordinal and buffer_index combinations that were never
17138    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
17139    /// hasn't been started by the client yet (no removing potential future
17140    /// buffers).
17141    ///
17142    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
17143    /// combination may be re-used after completion of RemoveBuffer, but only if
17144    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
17145    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
17146    ///
17147    /// Assuming a valid historical buffer is specified, successful completion
17148    /// of this call means the buffer has been fully released by the server and
17149    /// won't be referenced in any subsequent OnOutputPacket.
17150    RemoveBuffer {
17151        payload: StreamProcessorRemoveBufferRequest,
17152        responder: StreamProcessorRemoveBufferResponder,
17153    },
17154    /// This informs the StreamProcessor that the client is prepared to handle
17155    /// output packets that specify a buffer with buffer_lifetime_ordinal older
17156    /// than the most recent buffer_lifetime_ordinal.
17157    ///
17158    /// If the client doesn't send this message, the StreamProcessor will omit
17159    /// any such output, even if
17160    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
17161    /// decoders such as VP9 decoders, not sending this message can result in
17162    /// output that isn't bistream spec compliant, and the output can be
17163    /// visually different than intended by the bitstream.
17164    ///
17165    /// Such streams are only possible with some bitstream formats (such as
17166    /// VP9), and are rare, but can happen and can be valid per the bitstream
17167    /// spec. For example, this can be specified by a VP9 bitstream using
17168    /// show_existing_frame to output an old-dimensions buffer after having
17169    /// already output a new-dimensions buffer.
17170    ///
17171    /// Most clients that send this message will also want to use RemoveBuffer
17172    /// to know when it becomes safe to stop tracking an old buffer.
17173    ///
17174    /// Most of the time this makes no difference as most bitstreams don't
17175    /// actually emit old buffers, even if the bitstream spec would allow it.
17176    /// Old output buffers are especially rare for RTC streams which typically
17177    /// don't have any frame reordering in the first place.
17178    ///
17179    /// In most video streaming scenarios that use dimension switching as part
17180    /// of their bitrate control strategy (among those that I've observed), at
17181    /// the StreamProcessor layer the new dimensions are part of a new stream
17182    /// instead of being spliced together as a continuation of the old stream.
17183    /// That said, using a continuation of the old stream is also a completely
17184    /// valid way to implement dimension switching. When a stream switch occurs
17185    /// as part of dimension switching, the decoder state is not retained and
17186    /// there won't be any old buffer(s) emitted after new buffer(s), since the
17187    /// new stream doesn't know anything about old buffers filled by the old
17188    /// stream.
17189    ///
17190    /// Clients which haven't tested their ability to handle old output buffers
17191    /// should not send this message. Clients decoding bitstreams like VP9 for
17192    /// decoder compliance testing purposes should send this message (and use a
17193    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
17194    /// Clients which are required to support old output frames and/or fully
17195    /// comply with a relevant bitstream spec should/must send this message, and
17196    /// should test using a test stream that outputs packets referencing an old
17197    /// output buffer.
17198    ///
17199    /// Sending this message more than once closes the channel. If sent, this
17200    /// message must be sent prior to the client establishing the first output
17201    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
17202    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
17203    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
17204    /// client when this message was not sent by the client.
17205    ///
17206    /// This message is only permitted when
17207    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17208    /// is true.
17209    EnableOldOutputBuffers { control_handle: StreamProcessorControlHandle },
17210    /// This informs the StreamProcessor that the client is prepared to handle
17211    /// output packets that specify the same buffer as another packet that's
17212    /// also concurrently in flight to the client (not yet recycled).
17213    ///
17214    /// Most bitstream formats don't do this. In formats that can do this such
17215    /// as VP9, most actual bitstreams don't do this.
17216    ///
17217    /// As an example, in VP9, a stream can cause the same output buffer to be
17218    /// used by another emitted output packet/frame by using show_existing_frame
17219    /// on the same VP9 reference/held frame slot more than once without
17220    /// decoding a new frame into that slot in between.
17221    ///
17222    /// Clients that need to achieve full bitstream spec compliance for such a
17223    /// bitstream format must send this message.
17224    ///
17225    /// If this message is not in effect, the server will omit any such output,
17226    /// which can result in output that is not compliant to the relevant
17227    /// bitstream spec, and which can be visually different than the stream
17228    /// intended.
17229    ///
17230    /// Sending this message more than once closes the channel. If sent, this
17231    /// message must be sent prior to the client establishing the first output
17232    /// buffer_lifetime_ordinal.
17233    ///
17234    /// This message is only permitted when
17235    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17236    /// is true.
17237    EnableSameOutputBufferConcurrentlyInFlight { control_handle: StreamProcessorControlHandle },
17238    /// For video decoders, this forces the output buffers to be reallocated if
17239    /// the image size needs to change. This is wasteful as it forces extra
17240    /// buffer reallocations given typical video bitrate control strategies
17241    /// (applicable to both streaming and RTC) involving shifting the image
17242    /// dimensions up and down repeatedly as a logical video/stream plays,
17243    /// sometimes even if network conditions remain fairly stable. This extra
17244    /// buffer reallocation cost is incurred vs. baseline whether the dimension
17245    /// switching is achieved within a single StreamProcessor stream or by using
17246    /// a new StreamProcessor stream for new dimensions.
17247    ///
17248    /// A client should not send this message unless the client really must
17249    /// force the output buffers to be reallocated every time the output image
17250    /// size changes.
17251    ///
17252    /// Sending this message more than once closes the channel. If sent, this
17253    /// message must be sent prior to any SetInputBufferPartialSettings,
17254    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
17255    /// AddBuffer.
17256    ///
17257    /// This message is only permitted if this StreamProcessor is a video
17258    /// decoder.
17259    ///
17260    /// This message is only permitted when
17261    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17262    /// is true.
17263    EnableForceOutputBuffersFixedImageSize { control_handle: StreamProcessorControlHandle },
17264    /// An interaction was received which does not match any known method.
17265    #[non_exhaustive]
17266    _UnknownMethod {
17267        /// Ordinal of the method that was called.
17268        ordinal: u64,
17269        control_handle: StreamProcessorControlHandle,
17270        method_type: fidl::MethodType,
17271    },
17272}
17273
17274impl StreamProcessorRequest {
17275    #[allow(irrefutable_let_patterns)]
17276    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
17277        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
17278            Some((control_handle))
17279        } else {
17280            None
17281        }
17282    }
17283
17284    #[allow(irrefutable_let_patterns)]
17285    pub fn into_set_input_buffer_partial_settings(
17286        self,
17287    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
17288        if let StreamProcessorRequest::SetInputBufferPartialSettings {
17289            input_settings,
17290            control_handle,
17291        } = self
17292        {
17293            Some((input_settings, control_handle))
17294        } else {
17295            None
17296        }
17297    }
17298
17299    #[allow(irrefutable_let_patterns)]
17300    pub fn into_set_output_buffer_partial_settings(
17301        self,
17302    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
17303        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
17304            output_settings,
17305            control_handle,
17306        } = self
17307        {
17308            Some((output_settings, control_handle))
17309        } else {
17310            None
17311        }
17312    }
17313
17314    #[allow(irrefutable_let_patterns)]
17315    pub fn into_complete_output_buffer_partial_settings(
17316        self,
17317    ) -> Option<(u64, StreamProcessorControlHandle)> {
17318        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
17319            buffer_lifetime_ordinal,
17320            control_handle,
17321        } = self
17322        {
17323            Some((buffer_lifetime_ordinal, control_handle))
17324        } else {
17325            None
17326        }
17327    }
17328
17329    #[allow(irrefutable_let_patterns)]
17330    pub fn into_flush_end_of_stream_and_close_stream(
17331        self,
17332    ) -> Option<(u64, StreamProcessorControlHandle)> {
17333        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
17334            stream_lifetime_ordinal,
17335            control_handle,
17336        } = self
17337        {
17338            Some((stream_lifetime_ordinal, control_handle))
17339        } else {
17340            None
17341        }
17342    }
17343
17344    #[allow(irrefutable_let_patterns)]
17345    pub fn into_close_current_stream(
17346        self,
17347    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
17348        if let StreamProcessorRequest::CloseCurrentStream {
17349            stream_lifetime_ordinal,
17350            release_input_buffers,
17351            release_output_buffers,
17352            control_handle,
17353        } = self
17354        {
17355            Some((
17356                stream_lifetime_ordinal,
17357                release_input_buffers,
17358                release_output_buffers,
17359                control_handle,
17360            ))
17361        } else {
17362            None
17363        }
17364    }
17365
17366    #[allow(irrefutable_let_patterns)]
17367    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
17368        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
17369    }
17370
17371    #[allow(irrefutable_let_patterns)]
17372    pub fn into_recycle_output_packet(
17373        self,
17374    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
17375        if let StreamProcessorRequest::RecycleOutputPacket {
17376            available_output_packet,
17377            control_handle,
17378        } = self
17379        {
17380            Some((available_output_packet, control_handle))
17381        } else {
17382            None
17383        }
17384    }
17385
17386    #[allow(irrefutable_let_patterns)]
17387    pub fn into_queue_input_format_details(
17388        self,
17389    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
17390        if let StreamProcessorRequest::QueueInputFormatDetails {
17391            stream_lifetime_ordinal,
17392            format_details,
17393            control_handle,
17394        } = self
17395        {
17396            Some((stream_lifetime_ordinal, format_details, control_handle))
17397        } else {
17398            None
17399        }
17400    }
17401
17402    #[allow(irrefutable_let_patterns)]
17403    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
17404        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
17405            Some((packet, control_handle))
17406        } else {
17407            None
17408        }
17409    }
17410
17411    #[allow(irrefutable_let_patterns)]
17412    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
17413        if let StreamProcessorRequest::QueueInputEndOfStream {
17414            stream_lifetime_ordinal,
17415            control_handle,
17416        } = self
17417        {
17418            Some((stream_lifetime_ordinal, control_handle))
17419        } else {
17420            None
17421        }
17422    }
17423
17424    #[allow(irrefutable_let_patterns)]
17425    pub fn into_participate_in_buffer_allocation(
17426        self,
17427    ) -> Option<(StreamProcessorParticipateInBufferAllocationRequest, StreamProcessorControlHandle)>
17428    {
17429        if let StreamProcessorRequest::ParticipateInBufferAllocation { payload, control_handle } =
17430            self
17431        {
17432            Some((payload, control_handle))
17433        } else {
17434            None
17435        }
17436    }
17437
17438    #[allow(irrefutable_let_patterns)]
17439    pub fn into_add_buffer(
17440        self,
17441    ) -> Option<(StreamProcessorAddBufferRequest, StreamProcessorControlHandle)> {
17442        if let StreamProcessorRequest::AddBuffer { payload, control_handle } = self {
17443            Some((payload, control_handle))
17444        } else {
17445            None
17446        }
17447    }
17448
17449    #[allow(irrefutable_let_patterns)]
17450    pub fn into_remove_buffer(
17451        self,
17452    ) -> Option<(StreamProcessorRemoveBufferRequest, StreamProcessorRemoveBufferResponder)> {
17453        if let StreamProcessorRequest::RemoveBuffer { payload, responder } = self {
17454            Some((payload, responder))
17455        } else {
17456            None
17457        }
17458    }
17459
17460    #[allow(irrefutable_let_patterns)]
17461    pub fn into_enable_old_output_buffers(self) -> Option<(StreamProcessorControlHandle)> {
17462        if let StreamProcessorRequest::EnableOldOutputBuffers { control_handle } = self {
17463            Some((control_handle))
17464        } else {
17465            None
17466        }
17467    }
17468
17469    #[allow(irrefutable_let_patterns)]
17470    pub fn into_enable_same_output_buffer_concurrently_in_flight(
17471        self,
17472    ) -> Option<(StreamProcessorControlHandle)> {
17473        if let StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
17474            control_handle,
17475        } = self
17476        {
17477            Some((control_handle))
17478        } else {
17479            None
17480        }
17481    }
17482
17483    #[allow(irrefutable_let_patterns)]
17484    pub fn into_enable_force_output_buffers_fixed_image_size(
17485        self,
17486    ) -> Option<(StreamProcessorControlHandle)> {
17487        if let StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { control_handle } =
17488            self
17489        {
17490            Some((control_handle))
17491        } else {
17492            None
17493        }
17494    }
17495
17496    /// Name of the method defined in FIDL
17497    pub fn method_name(&self) -> &'static str {
17498        match *self {
17499            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
17500            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
17501                "set_input_buffer_partial_settings"
17502            }
17503            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
17504                "set_output_buffer_partial_settings"
17505            }
17506            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
17507                "complete_output_buffer_partial_settings"
17508            }
17509            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
17510                "flush_end_of_stream_and_close_stream"
17511            }
17512            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
17513            StreamProcessorRequest::Sync { .. } => "sync",
17514            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
17515            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
17516            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
17517            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
17518            StreamProcessorRequest::ParticipateInBufferAllocation { .. } => {
17519                "participate_in_buffer_allocation"
17520            }
17521            StreamProcessorRequest::AddBuffer { .. } => "add_buffer",
17522            StreamProcessorRequest::RemoveBuffer { .. } => "remove_buffer",
17523            StreamProcessorRequest::EnableOldOutputBuffers { .. } => "enable_old_output_buffers",
17524            StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight { .. } => {
17525                "enable_same_output_buffer_concurrently_in_flight"
17526            }
17527            StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { .. } => {
17528                "enable_force_output_buffers_fixed_image_size"
17529            }
17530            StreamProcessorRequest::_UnknownMethod {
17531                method_type: fidl::MethodType::OneWay,
17532                ..
17533            } => "unknown one-way method",
17534            StreamProcessorRequest::_UnknownMethod {
17535                method_type: fidl::MethodType::TwoWay,
17536                ..
17537            } => "unknown two-way method",
17538        }
17539    }
17540}
17541
17542#[derive(Debug, Clone)]
17543pub struct StreamProcessorControlHandle {
17544    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17545}
17546
17547impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
17548    fn shutdown(&self) {
17549        self.inner.shutdown()
17550    }
17551
17552    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17553        self.inner.shutdown_with_epitaph(status)
17554    }
17555
17556    fn is_closed(&self) -> bool {
17557        self.inner.channel().is_closed()
17558    }
17559    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17560        self.inner.channel().on_closed()
17561    }
17562
17563    #[cfg(target_os = "fuchsia")]
17564    fn signal_peer(
17565        &self,
17566        clear_mask: zx::Signals,
17567        set_mask: zx::Signals,
17568    ) -> Result<(), zx_status::Status> {
17569        use fidl::Peered;
17570        self.inner.channel().signal_peer(clear_mask, set_mask)
17571    }
17572}
17573
17574impl StreamProcessorControlHandle {
17575    pub fn send_on_stream_failed(
17576        &self,
17577        mut stream_lifetime_ordinal: u64,
17578        mut error: StreamError,
17579    ) -> Result<(), fidl::Error> {
17580        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
17581            (stream_lifetime_ordinal, error),
17582            0,
17583            0x77ccf70bb061cf8e,
17584            fidl::encoding::DynamicFlags::empty(),
17585        )
17586    }
17587
17588    pub fn send_on_input_constraints(
17589        &self,
17590        mut input_constraints: &StreamBufferConstraints,
17591    ) -> Result<(), fidl::Error> {
17592        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
17593            (input_constraints,),
17594            0,
17595            0x211da9966a8ca0,
17596            fidl::encoding::DynamicFlags::empty(),
17597        )
17598    }
17599
17600    pub fn send_on_output_constraints(
17601        &self,
17602        mut output_config: &StreamOutputConstraints,
17603    ) -> Result<(), fidl::Error> {
17604        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
17605            (output_config,),
17606            0,
17607            0x40d8234504c170f3,
17608            fidl::encoding::DynamicFlags::empty(),
17609        )
17610    }
17611
17612    pub fn send_on_output_format(
17613        &self,
17614        mut output_format: &StreamOutputFormat,
17615    ) -> Result<(), fidl::Error> {
17616        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
17617            (output_format,),
17618            0,
17619            0x131b77ae120360bc,
17620            fidl::encoding::DynamicFlags::empty(),
17621        )
17622    }
17623
17624    pub fn send_on_output_packet(
17625        &self,
17626        mut output_packet: &Packet,
17627        mut error_detected_before: bool,
17628        mut error_detected_during: bool,
17629    ) -> Result<(), fidl::Error> {
17630        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
17631            (output_packet, error_detected_before, error_detected_during),
17632            0,
17633            0x5c2029be1090ce93,
17634            fidl::encoding::DynamicFlags::empty(),
17635        )
17636    }
17637
17638    pub fn send_on_output_end_of_stream(
17639        &self,
17640        mut stream_lifetime_ordinal: u64,
17641        mut error_detected_before: bool,
17642    ) -> Result<(), fidl::Error> {
17643        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
17644            (stream_lifetime_ordinal, error_detected_before),
17645            0,
17646            0x3bb65d237cfa50e6,
17647            fidl::encoding::DynamicFlags::empty(),
17648        )
17649    }
17650
17651    pub fn send_on_free_input_packet(
17652        &self,
17653        mut free_input_packet: &PacketHeader,
17654    ) -> Result<(), fidl::Error> {
17655        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
17656            (free_input_packet,),
17657            0,
17658            0xeef799b28708bbd,
17659            fidl::encoding::DynamicFlags::empty(),
17660        )
17661    }
17662
17663    pub fn send_on_output_timestamp_has_no_output(
17664        &self,
17665        mut payload: &StreamProcessorOnOutputTimestampHasNoOutputRequest,
17666    ) -> Result<(), fidl::Error> {
17667        self.inner.send::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(
17668            payload,
17669            0,
17670            0x7436457799a25cd4,
17671            fidl::encoding::DynamicFlags::FLEXIBLE,
17672        )
17673    }
17674}
17675
17676#[must_use = "FIDL methods require a response to be sent"]
17677#[derive(Debug)]
17678pub struct StreamProcessorSyncResponder {
17679    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
17680    tx_id: u32,
17681}
17682
17683/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
17684/// if the responder is dropped without sending a response, so that the client
17685/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17686impl std::ops::Drop for StreamProcessorSyncResponder {
17687    fn drop(&mut self) {
17688        self.control_handle.shutdown();
17689        // Safety: drops once, never accessed again
17690        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17691    }
17692}
17693
17694impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
17695    type ControlHandle = StreamProcessorControlHandle;
17696
17697    fn control_handle(&self) -> &StreamProcessorControlHandle {
17698        &self.control_handle
17699    }
17700
17701    fn drop_without_shutdown(mut self) {
17702        // Safety: drops once, never accessed again due to mem::forget
17703        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17704        // Prevent Drop from running (which would shut down the channel)
17705        std::mem::forget(self);
17706    }
17707}
17708
17709impl StreamProcessorSyncResponder {
17710    /// Sends a response to the FIDL transaction.
17711    ///
17712    /// Sets the channel to shutdown if an error occurs.
17713    pub fn send(self) -> Result<(), fidl::Error> {
17714        let _result = self.send_raw();
17715        if _result.is_err() {
17716            self.control_handle.shutdown();
17717        }
17718        self.drop_without_shutdown();
17719        _result
17720    }
17721
17722    /// Similar to "send" but does not shutdown the channel if an error occurs.
17723    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17724        let _result = self.send_raw();
17725        self.drop_without_shutdown();
17726        _result
17727    }
17728
17729    fn send_raw(&self) -> Result<(), fidl::Error> {
17730        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17731            (),
17732            self.tx_id,
17733            0x4b3e44300b0ec6aa,
17734            fidl::encoding::DynamicFlags::empty(),
17735        )
17736    }
17737}
17738
17739#[must_use = "FIDL methods require a response to be sent"]
17740#[derive(Debug)]
17741pub struct StreamProcessorRemoveBufferResponder {
17742    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
17743    tx_id: u32,
17744}
17745
17746/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
17747/// if the responder is dropped without sending a response, so that the client
17748/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17749impl std::ops::Drop for StreamProcessorRemoveBufferResponder {
17750    fn drop(&mut self) {
17751        self.control_handle.shutdown();
17752        // Safety: drops once, never accessed again
17753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17754    }
17755}
17756
17757impl fidl::endpoints::Responder for StreamProcessorRemoveBufferResponder {
17758    type ControlHandle = StreamProcessorControlHandle;
17759
17760    fn control_handle(&self) -> &StreamProcessorControlHandle {
17761        &self.control_handle
17762    }
17763
17764    fn drop_without_shutdown(mut self) {
17765        // Safety: drops once, never accessed again due to mem::forget
17766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17767        // Prevent Drop from running (which would shut down the channel)
17768        std::mem::forget(self);
17769    }
17770}
17771
17772impl StreamProcessorRemoveBufferResponder {
17773    /// Sends a response to the FIDL transaction.
17774    ///
17775    /// Sets the channel to shutdown if an error occurs.
17776    pub fn send(self) -> Result<(), fidl::Error> {
17777        let _result = self.send_raw();
17778        if _result.is_err() {
17779            self.control_handle.shutdown();
17780        }
17781        self.drop_without_shutdown();
17782        _result
17783    }
17784
17785    /// Similar to "send" but does not shutdown the channel if an error occurs.
17786    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17787        let _result = self.send_raw();
17788        self.drop_without_shutdown();
17789        _result
17790    }
17791
17792    fn send_raw(&self) -> Result<(), fidl::Error> {
17793        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
17794            fidl::encoding::Flexible::new(()),
17795            self.tx_id,
17796            0x40b967ffa6b2da43,
17797            fidl::encoding::DynamicFlags::FLEXIBLE,
17798        )
17799    }
17800}
17801
17802#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17803pub struct StreamSinkMarker;
17804
17805impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
17806    type Proxy = StreamSinkProxy;
17807    type RequestStream = StreamSinkRequestStream;
17808    #[cfg(target_os = "fuchsia")]
17809    type SynchronousProxy = StreamSinkSynchronousProxy;
17810
17811    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
17812}
17813
17814pub trait StreamSinkProxyInterface: Send + Sync {
17815    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17816    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
17817    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
17818    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
17819    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17820    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
17821    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
17822}
17823#[derive(Debug)]
17824#[cfg(target_os = "fuchsia")]
17825pub struct StreamSinkSynchronousProxy {
17826    client: fidl::client::sync::Client,
17827}
17828
17829#[cfg(target_os = "fuchsia")]
17830impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
17831    type Proxy = StreamSinkProxy;
17832    type Protocol = StreamSinkMarker;
17833
17834    fn from_channel(inner: fidl::Channel) -> Self {
17835        Self::new(inner)
17836    }
17837
17838    fn into_channel(self) -> fidl::Channel {
17839        self.client.into_channel()
17840    }
17841
17842    fn as_channel(&self) -> &fidl::Channel {
17843        self.client.as_channel()
17844    }
17845}
17846
17847#[cfg(target_os = "fuchsia")]
17848impl StreamSinkSynchronousProxy {
17849    pub fn new(channel: fidl::Channel) -> Self {
17850        Self { client: fidl::client::sync::Client::new(channel) }
17851    }
17852
17853    pub fn into_channel(self) -> fidl::Channel {
17854        self.client.into_channel()
17855    }
17856
17857    /// Waits until an event arrives and returns it. It is safe for other
17858    /// threads to make concurrent requests while waiting for an event.
17859    pub fn wait_for_event(
17860        &self,
17861        deadline: zx::MonotonicInstant,
17862    ) -> Result<StreamSinkEvent, fidl::Error> {
17863        StreamSinkEvent::decode(self.client.wait_for_event::<StreamSinkMarker>(deadline)?)
17864    }
17865
17866    /// Sends a packet to the service. The response is sent when the service is
17867    /// done with the associated payload memory.
17868    ///
17869    /// `packet` must be valid for the current buffer set, otherwise the service
17870    /// will close the connection.
17871    pub fn r#send_packet(
17872        &self,
17873        mut packet: &StreamPacket,
17874        ___deadline: zx::MonotonicInstant,
17875    ) -> Result<(), fidl::Error> {
17876        let _response = self.client.send_query::<
17877            StreamSinkSendPacketRequest,
17878            fidl::encoding::EmptyPayload,
17879            StreamSinkMarker,
17880        >(
17881            (packet,),
17882            0x67cddd607442775f,
17883            fidl::encoding::DynamicFlags::empty(),
17884            ___deadline,
17885        )?;
17886        Ok(_response)
17887    }
17888
17889    /// Sends a packet to the service. This interface doesn't define how the
17890    /// client knows when the sink is done with the associated payload memory.
17891    /// The inheriting interface must define that.
17892    ///
17893    /// `packet` must be valid for the current buffer set, otherwise the service
17894    /// will close the connection.
17895    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
17896        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
17897            (packet,),
17898            0x8d9b8b413ceba9d,
17899            fidl::encoding::DynamicFlags::empty(),
17900        )
17901    }
17902
17903    /// Indicates the stream has ended. The precise semantics of this method are
17904    /// determined by the inheriting interface.
17905    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
17906        self.client.send::<fidl::encoding::EmptyPayload>(
17907            (),
17908            0x6180fd6f7e793b71,
17909            fidl::encoding::DynamicFlags::empty(),
17910        )
17911    }
17912
17913    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
17914    /// and not yet released. The response is sent after all packets have been
17915    /// released.
17916    pub fn r#discard_all_packets(
17917        &self,
17918        ___deadline: zx::MonotonicInstant,
17919    ) -> Result<(), fidl::Error> {
17920        let _response = self.client.send_query::<
17921            fidl::encoding::EmptyPayload,
17922            fidl::encoding::EmptyPayload,
17923            StreamSinkMarker,
17924        >(
17925            (),
17926            0x6f4dad7af2917665,
17927            fidl::encoding::DynamicFlags::empty(),
17928            ___deadline,
17929        )?;
17930        Ok(_response)
17931    }
17932
17933    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
17934    /// and not yet released.
17935    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
17936        self.client.send::<fidl::encoding::EmptyPayload>(
17937            (),
17938            0x50d36d0d23081bc4,
17939            fidl::encoding::DynamicFlags::empty(),
17940        )
17941    }
17942}
17943
17944#[cfg(target_os = "fuchsia")]
17945impl From<StreamSinkSynchronousProxy> for zx::NullableHandle {
17946    fn from(value: StreamSinkSynchronousProxy) -> Self {
17947        value.into_channel().into()
17948    }
17949}
17950
17951#[cfg(target_os = "fuchsia")]
17952impl From<fidl::Channel> for StreamSinkSynchronousProxy {
17953    fn from(value: fidl::Channel) -> Self {
17954        Self::new(value)
17955    }
17956}
17957
17958#[cfg(target_os = "fuchsia")]
17959impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
17960    type Protocol = StreamSinkMarker;
17961
17962    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
17963        Self::new(value.into_channel())
17964    }
17965}
17966
17967#[derive(Debug, Clone)]
17968pub struct StreamSinkProxy {
17969    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17970}
17971
17972impl fidl::endpoints::Proxy for StreamSinkProxy {
17973    type Protocol = StreamSinkMarker;
17974
17975    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17976        Self::new(inner)
17977    }
17978
17979    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17980        self.client.into_channel().map_err(|client| Self { client })
17981    }
17982
17983    fn as_channel(&self) -> &::fidl::AsyncChannel {
17984        self.client.as_channel()
17985    }
17986}
17987
17988impl StreamSinkProxy {
17989    /// Create a new Proxy for fuchsia.media/StreamSink.
17990    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17991        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17992        Self { client: fidl::client::Client::new(channel, protocol_name) }
17993    }
17994
17995    /// Get a Stream of events from the remote end of the protocol.
17996    ///
17997    /// # Panics
17998    ///
17999    /// Panics if the event stream was already taken.
18000    pub fn take_event_stream(&self) -> StreamSinkEventStream {
18001        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
18002    }
18003
18004    /// Sends a packet to the service. The response is sent when the service is
18005    /// done with the associated payload memory.
18006    ///
18007    /// `packet` must be valid for the current buffer set, otherwise the service
18008    /// will close the connection.
18009    pub fn r#send_packet(
18010        &self,
18011        mut packet: &StreamPacket,
18012    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18013        StreamSinkProxyInterface::r#send_packet(self, packet)
18014    }
18015
18016    /// Sends a packet to the service. This interface doesn't define how the
18017    /// client knows when the sink is done with the associated payload memory.
18018    /// The inheriting interface must define that.
18019    ///
18020    /// `packet` must be valid for the current buffer set, otherwise the service
18021    /// will close the connection.
18022    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18023        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
18024    }
18025
18026    /// Indicates the stream has ended. The precise semantics of this method are
18027    /// determined by the inheriting interface.
18028    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
18029        StreamSinkProxyInterface::r#end_of_stream(self)
18030    }
18031
18032    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18033    /// and not yet released. The response is sent after all packets have been
18034    /// released.
18035    pub fn r#discard_all_packets(
18036        &self,
18037    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18038        StreamSinkProxyInterface::r#discard_all_packets(self)
18039    }
18040
18041    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18042    /// and not yet released.
18043    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18044        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
18045    }
18046}
18047
18048impl StreamSinkProxyInterface for StreamSinkProxy {
18049    type SendPacketResponseFut =
18050        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18051    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
18052        fn _decode(
18053            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18054        ) -> Result<(), fidl::Error> {
18055            let _response = fidl::client::decode_transaction_body::<
18056                fidl::encoding::EmptyPayload,
18057                fidl::encoding::DefaultFuchsiaResourceDialect,
18058                0x67cddd607442775f,
18059            >(_buf?)?;
18060            Ok(_response)
18061        }
18062        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
18063            (packet,),
18064            0x67cddd607442775f,
18065            fidl::encoding::DynamicFlags::empty(),
18066            _decode,
18067        )
18068    }
18069
18070    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18071        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
18072            (packet,),
18073            0x8d9b8b413ceba9d,
18074            fidl::encoding::DynamicFlags::empty(),
18075        )
18076    }
18077
18078    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
18079        self.client.send::<fidl::encoding::EmptyPayload>(
18080            (),
18081            0x6180fd6f7e793b71,
18082            fidl::encoding::DynamicFlags::empty(),
18083        )
18084    }
18085
18086    type DiscardAllPacketsResponseFut =
18087        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18088    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
18089        fn _decode(
18090            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18091        ) -> Result<(), fidl::Error> {
18092            let _response = fidl::client::decode_transaction_body::<
18093                fidl::encoding::EmptyPayload,
18094                fidl::encoding::DefaultFuchsiaResourceDialect,
18095                0x6f4dad7af2917665,
18096            >(_buf?)?;
18097            Ok(_response)
18098        }
18099        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
18100            (),
18101            0x6f4dad7af2917665,
18102            fidl::encoding::DynamicFlags::empty(),
18103            _decode,
18104        )
18105    }
18106
18107    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18108        self.client.send::<fidl::encoding::EmptyPayload>(
18109            (),
18110            0x50d36d0d23081bc4,
18111            fidl::encoding::DynamicFlags::empty(),
18112        )
18113    }
18114}
18115
18116pub struct StreamSinkEventStream {
18117    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18118}
18119
18120impl std::marker::Unpin for StreamSinkEventStream {}
18121
18122impl futures::stream::FusedStream for StreamSinkEventStream {
18123    fn is_terminated(&self) -> bool {
18124        self.event_receiver.is_terminated()
18125    }
18126}
18127
18128impl futures::Stream for StreamSinkEventStream {
18129    type Item = Result<StreamSinkEvent, fidl::Error>;
18130
18131    fn poll_next(
18132        mut self: std::pin::Pin<&mut Self>,
18133        cx: &mut std::task::Context<'_>,
18134    ) -> std::task::Poll<Option<Self::Item>> {
18135        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18136            &mut self.event_receiver,
18137            cx
18138        )?) {
18139            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
18140            None => std::task::Poll::Ready(None),
18141        }
18142    }
18143}
18144
18145#[derive(Debug)]
18146pub enum StreamSinkEvent {}
18147
18148impl StreamSinkEvent {
18149    /// Decodes a message buffer as a [`StreamSinkEvent`].
18150    fn decode(
18151        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18152    ) -> Result<StreamSinkEvent, fidl::Error> {
18153        let (bytes, _handles) = buf.split_mut();
18154        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18155        debug_assert_eq!(tx_header.tx_id, 0);
18156        match tx_header.ordinal {
18157            _ => Err(fidl::Error::UnknownOrdinal {
18158                ordinal: tx_header.ordinal,
18159                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18160            }),
18161        }
18162    }
18163}
18164
18165/// A Stream of incoming requests for fuchsia.media/StreamSink.
18166pub struct StreamSinkRequestStream {
18167    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18168    is_terminated: bool,
18169}
18170
18171impl std::marker::Unpin for StreamSinkRequestStream {}
18172
18173impl futures::stream::FusedStream for StreamSinkRequestStream {
18174    fn is_terminated(&self) -> bool {
18175        self.is_terminated
18176    }
18177}
18178
18179impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
18180    type Protocol = StreamSinkMarker;
18181    type ControlHandle = StreamSinkControlHandle;
18182
18183    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18184        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18185    }
18186
18187    fn control_handle(&self) -> Self::ControlHandle {
18188        StreamSinkControlHandle { inner: self.inner.clone() }
18189    }
18190
18191    fn into_inner(
18192        self,
18193    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18194    {
18195        (self.inner, self.is_terminated)
18196    }
18197
18198    fn from_inner(
18199        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18200        is_terminated: bool,
18201    ) -> Self {
18202        Self { inner, is_terminated }
18203    }
18204}
18205
18206impl futures::Stream for StreamSinkRequestStream {
18207    type Item = Result<StreamSinkRequest, fidl::Error>;
18208
18209    fn poll_next(
18210        mut self: std::pin::Pin<&mut Self>,
18211        cx: &mut std::task::Context<'_>,
18212    ) -> std::task::Poll<Option<Self::Item>> {
18213        let this = &mut *self;
18214        if this.inner.check_shutdown(cx) {
18215            this.is_terminated = true;
18216            return std::task::Poll::Ready(None);
18217        }
18218        if this.is_terminated {
18219            panic!("polled StreamSinkRequestStream after completion");
18220        }
18221        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18222            |bytes, handles| {
18223                match this.inner.channel().read_etc(cx, bytes, handles) {
18224                    std::task::Poll::Ready(Ok(())) => {}
18225                    std::task::Poll::Pending => return std::task::Poll::Pending,
18226                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18227                        this.is_terminated = true;
18228                        return std::task::Poll::Ready(None);
18229                    }
18230                    std::task::Poll::Ready(Err(e)) => {
18231                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18232                            e.into(),
18233                        ))));
18234                    }
18235                }
18236
18237                // A message has been received from the channel
18238                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18239
18240                std::task::Poll::Ready(Some(match header.ordinal {
18241                    0x67cddd607442775f => {
18242                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18243                        let mut req = fidl::new_empty!(
18244                            StreamSinkSendPacketRequest,
18245                            fidl::encoding::DefaultFuchsiaResourceDialect
18246                        );
18247                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
18248                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18249                        Ok(StreamSinkRequest::SendPacket {
18250                            packet: req.packet,
18251
18252                            responder: StreamSinkSendPacketResponder {
18253                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18254                                tx_id: header.tx_id,
18255                            },
18256                        })
18257                    }
18258                    0x8d9b8b413ceba9d => {
18259                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18260                        let mut req = fidl::new_empty!(
18261                            StreamSinkSendPacketNoReplyRequest,
18262                            fidl::encoding::DefaultFuchsiaResourceDialect
18263                        );
18264                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
18265                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18266                        Ok(StreamSinkRequest::SendPacketNoReply {
18267                            packet: req.packet,
18268
18269                            control_handle,
18270                        })
18271                    }
18272                    0x6180fd6f7e793b71 => {
18273                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18274                        let mut req = fidl::new_empty!(
18275                            fidl::encoding::EmptyPayload,
18276                            fidl::encoding::DefaultFuchsiaResourceDialect
18277                        );
18278                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18279                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18280                        Ok(StreamSinkRequest::EndOfStream { control_handle })
18281                    }
18282                    0x6f4dad7af2917665 => {
18283                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18284                        let mut req = fidl::new_empty!(
18285                            fidl::encoding::EmptyPayload,
18286                            fidl::encoding::DefaultFuchsiaResourceDialect
18287                        );
18288                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18289                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18290                        Ok(StreamSinkRequest::DiscardAllPackets {
18291                            responder: StreamSinkDiscardAllPacketsResponder {
18292                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18293                                tx_id: header.tx_id,
18294                            },
18295                        })
18296                    }
18297                    0x50d36d0d23081bc4 => {
18298                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18299                        let mut req = fidl::new_empty!(
18300                            fidl::encoding::EmptyPayload,
18301                            fidl::encoding::DefaultFuchsiaResourceDialect
18302                        );
18303                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18304                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18305                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
18306                    }
18307                    _ => Err(fidl::Error::UnknownOrdinal {
18308                        ordinal: header.ordinal,
18309                        protocol_name:
18310                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18311                    }),
18312                }))
18313            },
18314        )
18315    }
18316}
18317
18318/// Consumes a stream of packets. This interface is typically inherited along
18319/// with `StreamBufferSet` to enable the transport of elementary streams from
18320/// clients to services.
18321#[derive(Debug)]
18322pub enum StreamSinkRequest {
18323    /// Sends a packet to the service. The response is sent when the service is
18324    /// done with the associated payload memory.
18325    ///
18326    /// `packet` must be valid for the current buffer set, otherwise the service
18327    /// will close the connection.
18328    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
18329    /// Sends a packet to the service. This interface doesn't define how the
18330    /// client knows when the sink is done with the associated payload memory.
18331    /// The inheriting interface must define that.
18332    ///
18333    /// `packet` must be valid for the current buffer set, otherwise the service
18334    /// will close the connection.
18335    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
18336    /// Indicates the stream has ended. The precise semantics of this method are
18337    /// determined by the inheriting interface.
18338    EndOfStream { control_handle: StreamSinkControlHandle },
18339    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18340    /// and not yet released. The response is sent after all packets have been
18341    /// released.
18342    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
18343    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18344    /// and not yet released.
18345    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
18346}
18347
18348impl StreamSinkRequest {
18349    #[allow(irrefutable_let_patterns)]
18350    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
18351        if let StreamSinkRequest::SendPacket { packet, responder } = self {
18352            Some((packet, responder))
18353        } else {
18354            None
18355        }
18356    }
18357
18358    #[allow(irrefutable_let_patterns)]
18359    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
18360        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
18361            Some((packet, control_handle))
18362        } else {
18363            None
18364        }
18365    }
18366
18367    #[allow(irrefutable_let_patterns)]
18368    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
18369        if let StreamSinkRequest::EndOfStream { control_handle } = self {
18370            Some((control_handle))
18371        } else {
18372            None
18373        }
18374    }
18375
18376    #[allow(irrefutable_let_patterns)]
18377    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
18378        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
18379            Some((responder))
18380        } else {
18381            None
18382        }
18383    }
18384
18385    #[allow(irrefutable_let_patterns)]
18386    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
18387        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
18388            Some((control_handle))
18389        } else {
18390            None
18391        }
18392    }
18393
18394    /// Name of the method defined in FIDL
18395    pub fn method_name(&self) -> &'static str {
18396        match *self {
18397            StreamSinkRequest::SendPacket { .. } => "send_packet",
18398            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
18399            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
18400            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
18401            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
18402        }
18403    }
18404}
18405
18406#[derive(Debug, Clone)]
18407pub struct StreamSinkControlHandle {
18408    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18409}
18410
18411impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
18412    fn shutdown(&self) {
18413        self.inner.shutdown()
18414    }
18415
18416    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18417        self.inner.shutdown_with_epitaph(status)
18418    }
18419
18420    fn is_closed(&self) -> bool {
18421        self.inner.channel().is_closed()
18422    }
18423    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18424        self.inner.channel().on_closed()
18425    }
18426
18427    #[cfg(target_os = "fuchsia")]
18428    fn signal_peer(
18429        &self,
18430        clear_mask: zx::Signals,
18431        set_mask: zx::Signals,
18432    ) -> Result<(), zx_status::Status> {
18433        use fidl::Peered;
18434        self.inner.channel().signal_peer(clear_mask, set_mask)
18435    }
18436}
18437
18438impl StreamSinkControlHandle {}
18439
18440#[must_use = "FIDL methods require a response to be sent"]
18441#[derive(Debug)]
18442pub struct StreamSinkSendPacketResponder {
18443    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
18444    tx_id: u32,
18445}
18446
18447/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
18448/// if the responder is dropped without sending a response, so that the client
18449/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18450impl std::ops::Drop for StreamSinkSendPacketResponder {
18451    fn drop(&mut self) {
18452        self.control_handle.shutdown();
18453        // Safety: drops once, never accessed again
18454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18455    }
18456}
18457
18458impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
18459    type ControlHandle = StreamSinkControlHandle;
18460
18461    fn control_handle(&self) -> &StreamSinkControlHandle {
18462        &self.control_handle
18463    }
18464
18465    fn drop_without_shutdown(mut self) {
18466        // Safety: drops once, never accessed again due to mem::forget
18467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18468        // Prevent Drop from running (which would shut down the channel)
18469        std::mem::forget(self);
18470    }
18471}
18472
18473impl StreamSinkSendPacketResponder {
18474    /// Sends a response to the FIDL transaction.
18475    ///
18476    /// Sets the channel to shutdown if an error occurs.
18477    pub fn send(self) -> Result<(), fidl::Error> {
18478        let _result = self.send_raw();
18479        if _result.is_err() {
18480            self.control_handle.shutdown();
18481        }
18482        self.drop_without_shutdown();
18483        _result
18484    }
18485
18486    /// Similar to "send" but does not shutdown the channel if an error occurs.
18487    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18488        let _result = self.send_raw();
18489        self.drop_without_shutdown();
18490        _result
18491    }
18492
18493    fn send_raw(&self) -> Result<(), fidl::Error> {
18494        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18495            (),
18496            self.tx_id,
18497            0x67cddd607442775f,
18498            fidl::encoding::DynamicFlags::empty(),
18499        )
18500    }
18501}
18502
18503#[must_use = "FIDL methods require a response to be sent"]
18504#[derive(Debug)]
18505pub struct StreamSinkDiscardAllPacketsResponder {
18506    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
18507    tx_id: u32,
18508}
18509
18510/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
18511/// if the responder is dropped without sending a response, so that the client
18512/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18513impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
18514    fn drop(&mut self) {
18515        self.control_handle.shutdown();
18516        // Safety: drops once, never accessed again
18517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18518    }
18519}
18520
18521impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
18522    type ControlHandle = StreamSinkControlHandle;
18523
18524    fn control_handle(&self) -> &StreamSinkControlHandle {
18525        &self.control_handle
18526    }
18527
18528    fn drop_without_shutdown(mut self) {
18529        // Safety: drops once, never accessed again due to mem::forget
18530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18531        // Prevent Drop from running (which would shut down the channel)
18532        std::mem::forget(self);
18533    }
18534}
18535
18536impl StreamSinkDiscardAllPacketsResponder {
18537    /// Sends a response to the FIDL transaction.
18538    ///
18539    /// Sets the channel to shutdown if an error occurs.
18540    pub fn send(self) -> Result<(), fidl::Error> {
18541        let _result = self.send_raw();
18542        if _result.is_err() {
18543            self.control_handle.shutdown();
18544        }
18545        self.drop_without_shutdown();
18546        _result
18547    }
18548
18549    /// Similar to "send" but does not shutdown the channel if an error occurs.
18550    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18551        let _result = self.send_raw();
18552        self.drop_without_shutdown();
18553        _result
18554    }
18555
18556    fn send_raw(&self) -> Result<(), fidl::Error> {
18557        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18558            (),
18559            self.tx_id,
18560            0x6f4dad7af2917665,
18561            fidl::encoding::DynamicFlags::empty(),
18562        )
18563    }
18564}
18565
18566#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18567pub struct StreamSourceMarker;
18568
18569impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
18570    type Proxy = StreamSourceProxy;
18571    type RequestStream = StreamSourceRequestStream;
18572    #[cfg(target_os = "fuchsia")]
18573    type SynchronousProxy = StreamSourceSynchronousProxy;
18574
18575    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
18576}
18577
18578pub trait StreamSourceProxyInterface: Send + Sync {
18579    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
18580    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
18581    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
18582    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
18583}
18584#[derive(Debug)]
18585#[cfg(target_os = "fuchsia")]
18586pub struct StreamSourceSynchronousProxy {
18587    client: fidl::client::sync::Client,
18588}
18589
18590#[cfg(target_os = "fuchsia")]
18591impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
18592    type Proxy = StreamSourceProxy;
18593    type Protocol = StreamSourceMarker;
18594
18595    fn from_channel(inner: fidl::Channel) -> Self {
18596        Self::new(inner)
18597    }
18598
18599    fn into_channel(self) -> fidl::Channel {
18600        self.client.into_channel()
18601    }
18602
18603    fn as_channel(&self) -> &fidl::Channel {
18604        self.client.as_channel()
18605    }
18606}
18607
18608#[cfg(target_os = "fuchsia")]
18609impl StreamSourceSynchronousProxy {
18610    pub fn new(channel: fidl::Channel) -> Self {
18611        Self { client: fidl::client::sync::Client::new(channel) }
18612    }
18613
18614    pub fn into_channel(self) -> fidl::Channel {
18615        self.client.into_channel()
18616    }
18617
18618    /// Waits until an event arrives and returns it. It is safe for other
18619    /// threads to make concurrent requests while waiting for an event.
18620    pub fn wait_for_event(
18621        &self,
18622        deadline: zx::MonotonicInstant,
18623    ) -> Result<StreamSourceEvent, fidl::Error> {
18624        StreamSourceEvent::decode(self.client.wait_for_event::<StreamSourceMarker>(deadline)?)
18625    }
18626
18627    /// Releases payload memory associated with a packet previously delivered
18628    /// via `OnPacketProduced`.
18629    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18630        self.client.send::<StreamSourceReleasePacketRequest>(
18631            (packet,),
18632            0x7a7b57f0f7d9e4bb,
18633            fidl::encoding::DynamicFlags::empty(),
18634        )
18635    }
18636
18637    pub fn r#discard_all_packets(
18638        &self,
18639        ___deadline: zx::MonotonicInstant,
18640    ) -> Result<(), fidl::Error> {
18641        let _response = self.client.send_query::<
18642            fidl::encoding::EmptyPayload,
18643            fidl::encoding::EmptyPayload,
18644            StreamSourceMarker,
18645        >(
18646            (),
18647            0x27afd605e97b09d2,
18648            fidl::encoding::DynamicFlags::empty(),
18649            ___deadline,
18650        )?;
18651        Ok(_response)
18652    }
18653
18654    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18655        self.client.send::<fidl::encoding::EmptyPayload>(
18656            (),
18657            0x35f9d721e905b831,
18658            fidl::encoding::DynamicFlags::empty(),
18659        )
18660    }
18661}
18662
18663#[cfg(target_os = "fuchsia")]
18664impl From<StreamSourceSynchronousProxy> for zx::NullableHandle {
18665    fn from(value: StreamSourceSynchronousProxy) -> Self {
18666        value.into_channel().into()
18667    }
18668}
18669
18670#[cfg(target_os = "fuchsia")]
18671impl From<fidl::Channel> for StreamSourceSynchronousProxy {
18672    fn from(value: fidl::Channel) -> Self {
18673        Self::new(value)
18674    }
18675}
18676
18677#[cfg(target_os = "fuchsia")]
18678impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
18679    type Protocol = StreamSourceMarker;
18680
18681    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
18682        Self::new(value.into_channel())
18683    }
18684}
18685
18686#[derive(Debug, Clone)]
18687pub struct StreamSourceProxy {
18688    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18689}
18690
18691impl fidl::endpoints::Proxy for StreamSourceProxy {
18692    type Protocol = StreamSourceMarker;
18693
18694    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18695        Self::new(inner)
18696    }
18697
18698    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18699        self.client.into_channel().map_err(|client| Self { client })
18700    }
18701
18702    fn as_channel(&self) -> &::fidl::AsyncChannel {
18703        self.client.as_channel()
18704    }
18705}
18706
18707impl StreamSourceProxy {
18708    /// Create a new Proxy for fuchsia.media/StreamSource.
18709    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18710        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18711        Self { client: fidl::client::Client::new(channel, protocol_name) }
18712    }
18713
18714    /// Get a Stream of events from the remote end of the protocol.
18715    ///
18716    /// # Panics
18717    ///
18718    /// Panics if the event stream was already taken.
18719    pub fn take_event_stream(&self) -> StreamSourceEventStream {
18720        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
18721    }
18722
18723    /// Releases payload memory associated with a packet previously delivered
18724    /// via `OnPacketProduced`.
18725    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18726        StreamSourceProxyInterface::r#release_packet(self, packet)
18727    }
18728
18729    pub fn r#discard_all_packets(
18730        &self,
18731    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18732        StreamSourceProxyInterface::r#discard_all_packets(self)
18733    }
18734
18735    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18736        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
18737    }
18738}
18739
18740impl StreamSourceProxyInterface for StreamSourceProxy {
18741    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18742        self.client.send::<StreamSourceReleasePacketRequest>(
18743            (packet,),
18744            0x7a7b57f0f7d9e4bb,
18745            fidl::encoding::DynamicFlags::empty(),
18746        )
18747    }
18748
18749    type DiscardAllPacketsResponseFut =
18750        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18751    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
18752        fn _decode(
18753            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18754        ) -> Result<(), fidl::Error> {
18755            let _response = fidl::client::decode_transaction_body::<
18756                fidl::encoding::EmptyPayload,
18757                fidl::encoding::DefaultFuchsiaResourceDialect,
18758                0x27afd605e97b09d2,
18759            >(_buf?)?;
18760            Ok(_response)
18761        }
18762        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
18763            (),
18764            0x27afd605e97b09d2,
18765            fidl::encoding::DynamicFlags::empty(),
18766            _decode,
18767        )
18768    }
18769
18770    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18771        self.client.send::<fidl::encoding::EmptyPayload>(
18772            (),
18773            0x35f9d721e905b831,
18774            fidl::encoding::DynamicFlags::empty(),
18775        )
18776    }
18777}
18778
18779pub struct StreamSourceEventStream {
18780    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18781}
18782
18783impl std::marker::Unpin for StreamSourceEventStream {}
18784
18785impl futures::stream::FusedStream for StreamSourceEventStream {
18786    fn is_terminated(&self) -> bool {
18787        self.event_receiver.is_terminated()
18788    }
18789}
18790
18791impl futures::Stream for StreamSourceEventStream {
18792    type Item = Result<StreamSourceEvent, fidl::Error>;
18793
18794    fn poll_next(
18795        mut self: std::pin::Pin<&mut Self>,
18796        cx: &mut std::task::Context<'_>,
18797    ) -> std::task::Poll<Option<Self::Item>> {
18798        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18799            &mut self.event_receiver,
18800            cx
18801        )?) {
18802            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
18803            None => std::task::Poll::Ready(None),
18804        }
18805    }
18806}
18807
18808#[derive(Debug)]
18809pub enum StreamSourceEvent {
18810    OnPacketProduced { packet: StreamPacket },
18811    OnEndOfStream {},
18812}
18813
18814impl StreamSourceEvent {
18815    #[allow(irrefutable_let_patterns)]
18816    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
18817        if let StreamSourceEvent::OnPacketProduced { packet } = self {
18818            Some((packet))
18819        } else {
18820            None
18821        }
18822    }
18823    #[allow(irrefutable_let_patterns)]
18824    pub fn into_on_end_of_stream(self) -> Option<()> {
18825        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
18826    }
18827
18828    /// Decodes a message buffer as a [`StreamSourceEvent`].
18829    fn decode(
18830        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18831    ) -> Result<StreamSourceEvent, fidl::Error> {
18832        let (bytes, _handles) = buf.split_mut();
18833        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18834        debug_assert_eq!(tx_header.tx_id, 0);
18835        match tx_header.ordinal {
18836            0x6bbe69746a3c8bd9 => {
18837                let mut out = fidl::new_empty!(
18838                    StreamSourceOnPacketProducedRequest,
18839                    fidl::encoding::DefaultFuchsiaResourceDialect
18840                );
18841                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
18842                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
18843            }
18844            0x550e69b41d03e2c2 => {
18845                let mut out = fidl::new_empty!(
18846                    fidl::encoding::EmptyPayload,
18847                    fidl::encoding::DefaultFuchsiaResourceDialect
18848                );
18849                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
18850                Ok((StreamSourceEvent::OnEndOfStream {}))
18851            }
18852            _ => Err(fidl::Error::UnknownOrdinal {
18853                ordinal: tx_header.ordinal,
18854                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18855            }),
18856        }
18857    }
18858}
18859
18860/// A Stream of incoming requests for fuchsia.media/StreamSource.
18861pub struct StreamSourceRequestStream {
18862    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18863    is_terminated: bool,
18864}
18865
18866impl std::marker::Unpin for StreamSourceRequestStream {}
18867
18868impl futures::stream::FusedStream for StreamSourceRequestStream {
18869    fn is_terminated(&self) -> bool {
18870        self.is_terminated
18871    }
18872}
18873
18874impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
18875    type Protocol = StreamSourceMarker;
18876    type ControlHandle = StreamSourceControlHandle;
18877
18878    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18879        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18880    }
18881
18882    fn control_handle(&self) -> Self::ControlHandle {
18883        StreamSourceControlHandle { inner: self.inner.clone() }
18884    }
18885
18886    fn into_inner(
18887        self,
18888    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18889    {
18890        (self.inner, self.is_terminated)
18891    }
18892
18893    fn from_inner(
18894        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18895        is_terminated: bool,
18896    ) -> Self {
18897        Self { inner, is_terminated }
18898    }
18899}
18900
18901impl futures::Stream for StreamSourceRequestStream {
18902    type Item = Result<StreamSourceRequest, fidl::Error>;
18903
18904    fn poll_next(
18905        mut self: std::pin::Pin<&mut Self>,
18906        cx: &mut std::task::Context<'_>,
18907    ) -> std::task::Poll<Option<Self::Item>> {
18908        let this = &mut *self;
18909        if this.inner.check_shutdown(cx) {
18910            this.is_terminated = true;
18911            return std::task::Poll::Ready(None);
18912        }
18913        if this.is_terminated {
18914            panic!("polled StreamSourceRequestStream after completion");
18915        }
18916        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18917            |bytes, handles| {
18918                match this.inner.channel().read_etc(cx, bytes, handles) {
18919                    std::task::Poll::Ready(Ok(())) => {}
18920                    std::task::Poll::Pending => return std::task::Poll::Pending,
18921                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18922                        this.is_terminated = true;
18923                        return std::task::Poll::Ready(None);
18924                    }
18925                    std::task::Poll::Ready(Err(e)) => {
18926                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18927                            e.into(),
18928                        ))));
18929                    }
18930                }
18931
18932                // A message has been received from the channel
18933                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18934
18935                std::task::Poll::Ready(Some(match header.ordinal {
18936                    0x7a7b57f0f7d9e4bb => {
18937                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18938                        let mut req = fidl::new_empty!(
18939                            StreamSourceReleasePacketRequest,
18940                            fidl::encoding::DefaultFuchsiaResourceDialect
18941                        );
18942                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
18943                        let control_handle =
18944                            StreamSourceControlHandle { inner: this.inner.clone() };
18945                        Ok(StreamSourceRequest::ReleasePacket {
18946                            packet: req.packet,
18947
18948                            control_handle,
18949                        })
18950                    }
18951                    0x27afd605e97b09d2 => {
18952                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18953                        let mut req = fidl::new_empty!(
18954                            fidl::encoding::EmptyPayload,
18955                            fidl::encoding::DefaultFuchsiaResourceDialect
18956                        );
18957                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18958                        let control_handle =
18959                            StreamSourceControlHandle { inner: this.inner.clone() };
18960                        Ok(StreamSourceRequest::DiscardAllPackets {
18961                            responder: StreamSourceDiscardAllPacketsResponder {
18962                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18963                                tx_id: header.tx_id,
18964                            },
18965                        })
18966                    }
18967                    0x35f9d721e905b831 => {
18968                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18969                        let mut req = fidl::new_empty!(
18970                            fidl::encoding::EmptyPayload,
18971                            fidl::encoding::DefaultFuchsiaResourceDialect
18972                        );
18973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18974                        let control_handle =
18975                            StreamSourceControlHandle { inner: this.inner.clone() };
18976                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
18977                    }
18978                    _ => Err(fidl::Error::UnknownOrdinal {
18979                        ordinal: header.ordinal,
18980                        protocol_name:
18981                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18982                    }),
18983                }))
18984            },
18985        )
18986    }
18987}
18988
18989/// Produces a stream of packets. This interface is typically inherited along
18990/// with `StreamBufferSet` to enable the transport of elementary streams from
18991/// services to clients.
18992#[derive(Debug)]
18993pub enum StreamSourceRequest {
18994    /// Releases payload memory associated with a packet previously delivered
18995    /// via `OnPacketProduced`.
18996    ReleasePacket {
18997        packet: StreamPacket,
18998        control_handle: StreamSourceControlHandle,
18999    },
19000    DiscardAllPackets {
19001        responder: StreamSourceDiscardAllPacketsResponder,
19002    },
19003    DiscardAllPacketsNoReply {
19004        control_handle: StreamSourceControlHandle,
19005    },
19006}
19007
19008impl StreamSourceRequest {
19009    #[allow(irrefutable_let_patterns)]
19010    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
19011        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
19012            Some((packet, control_handle))
19013        } else {
19014            None
19015        }
19016    }
19017
19018    #[allow(irrefutable_let_patterns)]
19019    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
19020        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
19021            Some((responder))
19022        } else {
19023            None
19024        }
19025    }
19026
19027    #[allow(irrefutable_let_patterns)]
19028    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
19029        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
19030            Some((control_handle))
19031        } else {
19032            None
19033        }
19034    }
19035
19036    /// Name of the method defined in FIDL
19037    pub fn method_name(&self) -> &'static str {
19038        match *self {
19039            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
19040            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
19041            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
19042        }
19043    }
19044}
19045
19046#[derive(Debug, Clone)]
19047pub struct StreamSourceControlHandle {
19048    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19049}
19050
19051impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
19052    fn shutdown(&self) {
19053        self.inner.shutdown()
19054    }
19055
19056    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19057        self.inner.shutdown_with_epitaph(status)
19058    }
19059
19060    fn is_closed(&self) -> bool {
19061        self.inner.channel().is_closed()
19062    }
19063    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19064        self.inner.channel().on_closed()
19065    }
19066
19067    #[cfg(target_os = "fuchsia")]
19068    fn signal_peer(
19069        &self,
19070        clear_mask: zx::Signals,
19071        set_mask: zx::Signals,
19072    ) -> Result<(), zx_status::Status> {
19073        use fidl::Peered;
19074        self.inner.channel().signal_peer(clear_mask, set_mask)
19075    }
19076}
19077
19078impl StreamSourceControlHandle {
19079    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
19080        self.inner.send::<StreamSourceOnPacketProducedRequest>(
19081            (packet,),
19082            0,
19083            0x6bbe69746a3c8bd9,
19084            fidl::encoding::DynamicFlags::empty(),
19085        )
19086    }
19087
19088    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
19089        self.inner.send::<fidl::encoding::EmptyPayload>(
19090            (),
19091            0,
19092            0x550e69b41d03e2c2,
19093            fidl::encoding::DynamicFlags::empty(),
19094        )
19095    }
19096}
19097
19098#[must_use = "FIDL methods require a response to be sent"]
19099#[derive(Debug)]
19100pub struct StreamSourceDiscardAllPacketsResponder {
19101    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
19102    tx_id: u32,
19103}
19104
19105/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
19106/// if the responder is dropped without sending a response, so that the client
19107/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19108impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
19109    fn drop(&mut self) {
19110        self.control_handle.shutdown();
19111        // Safety: drops once, never accessed again
19112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19113    }
19114}
19115
19116impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
19117    type ControlHandle = StreamSourceControlHandle;
19118
19119    fn control_handle(&self) -> &StreamSourceControlHandle {
19120        &self.control_handle
19121    }
19122
19123    fn drop_without_shutdown(mut self) {
19124        // Safety: drops once, never accessed again due to mem::forget
19125        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19126        // Prevent Drop from running (which would shut down the channel)
19127        std::mem::forget(self);
19128    }
19129}
19130
19131impl StreamSourceDiscardAllPacketsResponder {
19132    /// Sends a response to the FIDL transaction.
19133    ///
19134    /// Sets the channel to shutdown if an error occurs.
19135    pub fn send(self) -> Result<(), fidl::Error> {
19136        let _result = self.send_raw();
19137        if _result.is_err() {
19138            self.control_handle.shutdown();
19139        }
19140        self.drop_without_shutdown();
19141        _result
19142    }
19143
19144    /// Similar to "send" but does not shutdown the channel if an error occurs.
19145    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
19146        let _result = self.send_raw();
19147        self.drop_without_shutdown();
19148        _result
19149    }
19150
19151    fn send_raw(&self) -> Result<(), fidl::Error> {
19152        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
19153            (),
19154            self.tx_id,
19155            0x27afd605e97b09d2,
19156            fidl::encoding::DynamicFlags::empty(),
19157        )
19158    }
19159}
19160
19161#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19162pub struct Usage2AudioConsumerFactoryMarker;
19163
19164impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
19165    type Proxy = Usage2AudioConsumerFactoryProxy;
19166    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
19167    #[cfg(target_os = "fuchsia")]
19168    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
19169
19170    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
19171}
19172impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
19173
19174pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
19175    fn r#create_audio_consumer(
19176        &self,
19177        usage: AudioRenderUsage2,
19178        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19179    ) -> Result<(), fidl::Error>;
19180}
19181#[derive(Debug)]
19182#[cfg(target_os = "fuchsia")]
19183pub struct Usage2AudioConsumerFactorySynchronousProxy {
19184    client: fidl::client::sync::Client,
19185}
19186
19187#[cfg(target_os = "fuchsia")]
19188impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
19189    type Proxy = Usage2AudioConsumerFactoryProxy;
19190    type Protocol = Usage2AudioConsumerFactoryMarker;
19191
19192    fn from_channel(inner: fidl::Channel) -> Self {
19193        Self::new(inner)
19194    }
19195
19196    fn into_channel(self) -> fidl::Channel {
19197        self.client.into_channel()
19198    }
19199
19200    fn as_channel(&self) -> &fidl::Channel {
19201        self.client.as_channel()
19202    }
19203}
19204
19205#[cfg(target_os = "fuchsia")]
19206impl Usage2AudioConsumerFactorySynchronousProxy {
19207    pub fn new(channel: fidl::Channel) -> Self {
19208        Self { client: fidl::client::sync::Client::new(channel) }
19209    }
19210
19211    pub fn into_channel(self) -> fidl::Channel {
19212        self.client.into_channel()
19213    }
19214
19215    /// Waits until an event arrives and returns it. It is safe for other
19216    /// threads to make concurrent requests while waiting for an event.
19217    pub fn wait_for_event(
19218        &self,
19219        deadline: zx::MonotonicInstant,
19220    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
19221        Usage2AudioConsumerFactoryEvent::decode(
19222            self.client.wait_for_event::<Usage2AudioConsumerFactoryMarker>(deadline)?,
19223        )
19224    }
19225
19226    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19227    /// Audio submitted to such a consumer is always rendered locally.
19228    pub fn r#create_audio_consumer(
19229        &self,
19230        mut usage: AudioRenderUsage2,
19231        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19232    ) -> Result<(), fidl::Error> {
19233        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
19234            (usage, audio_consumer_request),
19235            0x767722302a171873,
19236            fidl::encoding::DynamicFlags::FLEXIBLE,
19237        )
19238    }
19239}
19240
19241#[cfg(target_os = "fuchsia")]
19242impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
19243    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
19244        value.into_channel().into()
19245    }
19246}
19247
19248#[cfg(target_os = "fuchsia")]
19249impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
19250    fn from(value: fidl::Channel) -> Self {
19251        Self::new(value)
19252    }
19253}
19254
19255#[cfg(target_os = "fuchsia")]
19256impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
19257    type Protocol = Usage2AudioConsumerFactoryMarker;
19258
19259    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
19260        Self::new(value.into_channel())
19261    }
19262}
19263
19264#[derive(Debug, Clone)]
19265pub struct Usage2AudioConsumerFactoryProxy {
19266    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19267}
19268
19269impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
19270    type Protocol = Usage2AudioConsumerFactoryMarker;
19271
19272    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19273        Self::new(inner)
19274    }
19275
19276    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19277        self.client.into_channel().map_err(|client| Self { client })
19278    }
19279
19280    fn as_channel(&self) -> &::fidl::AsyncChannel {
19281        self.client.as_channel()
19282    }
19283}
19284
19285impl Usage2AudioConsumerFactoryProxy {
19286    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
19287    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19288        let protocol_name =
19289            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19290        Self { client: fidl::client::Client::new(channel, protocol_name) }
19291    }
19292
19293    /// Get a Stream of events from the remote end of the protocol.
19294    ///
19295    /// # Panics
19296    ///
19297    /// Panics if the event stream was already taken.
19298    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
19299        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
19300    }
19301
19302    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19303    /// Audio submitted to such a consumer is always rendered locally.
19304    pub fn r#create_audio_consumer(
19305        &self,
19306        mut usage: AudioRenderUsage2,
19307        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19308    ) -> Result<(), fidl::Error> {
19309        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
19310            self,
19311            usage,
19312            audio_consumer_request,
19313        )
19314    }
19315}
19316
19317impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
19318    fn r#create_audio_consumer(
19319        &self,
19320        mut usage: AudioRenderUsage2,
19321        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19322    ) -> Result<(), fidl::Error> {
19323        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
19324            (usage, audio_consumer_request),
19325            0x767722302a171873,
19326            fidl::encoding::DynamicFlags::FLEXIBLE,
19327        )
19328    }
19329}
19330
19331pub struct Usage2AudioConsumerFactoryEventStream {
19332    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19333}
19334
19335impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
19336
19337impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
19338    fn is_terminated(&self) -> bool {
19339        self.event_receiver.is_terminated()
19340    }
19341}
19342
19343impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
19344    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
19345
19346    fn poll_next(
19347        mut self: std::pin::Pin<&mut Self>,
19348        cx: &mut std::task::Context<'_>,
19349    ) -> std::task::Poll<Option<Self::Item>> {
19350        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19351            &mut self.event_receiver,
19352            cx
19353        )?) {
19354            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
19355            None => std::task::Poll::Ready(None),
19356        }
19357    }
19358}
19359
19360#[derive(Debug)]
19361pub enum Usage2AudioConsumerFactoryEvent {
19362    #[non_exhaustive]
19363    _UnknownEvent {
19364        /// Ordinal of the event that was sent.
19365        ordinal: u64,
19366    },
19367}
19368
19369impl Usage2AudioConsumerFactoryEvent {
19370    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
19371    fn decode(
19372        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19373    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
19374        let (bytes, _handles) = buf.split_mut();
19375        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19376        debug_assert_eq!(tx_header.tx_id, 0);
19377        match tx_header.ordinal {
19378            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19379                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
19380                    ordinal: tx_header.ordinal,
19381                })
19382            }
19383            _ => Err(fidl::Error::UnknownOrdinal {
19384                ordinal: tx_header.ordinal,
19385                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19386            })
19387        }
19388    }
19389}
19390
19391/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
19392pub struct Usage2AudioConsumerFactoryRequestStream {
19393    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19394    is_terminated: bool,
19395}
19396
19397impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
19398
19399impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
19400    fn is_terminated(&self) -> bool {
19401        self.is_terminated
19402    }
19403}
19404
19405impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
19406    type Protocol = Usage2AudioConsumerFactoryMarker;
19407    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
19408
19409    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19410        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19411    }
19412
19413    fn control_handle(&self) -> Self::ControlHandle {
19414        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
19415    }
19416
19417    fn into_inner(
19418        self,
19419    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19420    {
19421        (self.inner, self.is_terminated)
19422    }
19423
19424    fn from_inner(
19425        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19426        is_terminated: bool,
19427    ) -> Self {
19428        Self { inner, is_terminated }
19429    }
19430}
19431
19432impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
19433    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
19434
19435    fn poll_next(
19436        mut self: std::pin::Pin<&mut Self>,
19437        cx: &mut std::task::Context<'_>,
19438    ) -> std::task::Poll<Option<Self::Item>> {
19439        let this = &mut *self;
19440        if this.inner.check_shutdown(cx) {
19441            this.is_terminated = true;
19442            return std::task::Poll::Ready(None);
19443        }
19444        if this.is_terminated {
19445            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
19446        }
19447        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19448            |bytes, handles| {
19449                match this.inner.channel().read_etc(cx, bytes, handles) {
19450                    std::task::Poll::Ready(Ok(())) => {}
19451                    std::task::Poll::Pending => return std::task::Poll::Pending,
19452                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19453                        this.is_terminated = true;
19454                        return std::task::Poll::Ready(None);
19455                    }
19456                    std::task::Poll::Ready(Err(e)) => {
19457                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19458                            e.into(),
19459                        ))));
19460                    }
19461                }
19462
19463                // A message has been received from the channel
19464                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19465
19466                std::task::Poll::Ready(Some(match header.ordinal {
19467                0x767722302a171873 => {
19468                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19469                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
19470                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
19471                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
19472                        inner: this.inner.clone(),
19473                    };
19474                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
19475audio_consumer_request: req.audio_consumer_request,
19476
19477                        control_handle,
19478                    })
19479                }
19480                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19481                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19482                        ordinal: header.ordinal,
19483                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
19484                        method_type: fidl::MethodType::OneWay,
19485                    })
19486                }
19487                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19488                    this.inner.send_framework_err(
19489                        fidl::encoding::FrameworkErr::UnknownMethod,
19490                        header.tx_id,
19491                        header.ordinal,
19492                        header.dynamic_flags(),
19493                        (bytes, handles),
19494                    )?;
19495                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19496                        ordinal: header.ordinal,
19497                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
19498                        method_type: fidl::MethodType::TwoWay,
19499                    })
19500                }
19501                _ => Err(fidl::Error::UnknownOrdinal {
19502                    ordinal: header.ordinal,
19503                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19504                }),
19505            }))
19506            },
19507        )
19508    }
19509}
19510
19511/// Interface for creating audio consumers for local rendering.
19512#[derive(Debug)]
19513pub enum Usage2AudioConsumerFactoryRequest {
19514    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19515    /// Audio submitted to such a consumer is always rendered locally.
19516    CreateAudioConsumer {
19517        usage: AudioRenderUsage2,
19518        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19519        control_handle: Usage2AudioConsumerFactoryControlHandle,
19520    },
19521    /// An interaction was received which does not match any known method.
19522    #[non_exhaustive]
19523    _UnknownMethod {
19524        /// Ordinal of the method that was called.
19525        ordinal: u64,
19526        control_handle: Usage2AudioConsumerFactoryControlHandle,
19527        method_type: fidl::MethodType,
19528    },
19529}
19530
19531impl Usage2AudioConsumerFactoryRequest {
19532    #[allow(irrefutable_let_patterns)]
19533    pub fn into_create_audio_consumer(
19534        self,
19535    ) -> Option<(
19536        AudioRenderUsage2,
19537        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19538        Usage2AudioConsumerFactoryControlHandle,
19539    )> {
19540        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
19541            usage,
19542            audio_consumer_request,
19543            control_handle,
19544        } = self
19545        {
19546            Some((usage, audio_consumer_request, control_handle))
19547        } else {
19548            None
19549        }
19550    }
19551
19552    /// Name of the method defined in FIDL
19553    pub fn method_name(&self) -> &'static str {
19554        match *self {
19555            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
19556                "create_audio_consumer"
19557            }
19558            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19559                method_type: fidl::MethodType::OneWay,
19560                ..
19561            } => "unknown one-way method",
19562            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19563                method_type: fidl::MethodType::TwoWay,
19564                ..
19565            } => "unknown two-way method",
19566        }
19567    }
19568}
19569
19570#[derive(Debug, Clone)]
19571pub struct Usage2AudioConsumerFactoryControlHandle {
19572    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19573}
19574
19575impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
19576    fn shutdown(&self) {
19577        self.inner.shutdown()
19578    }
19579
19580    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19581        self.inner.shutdown_with_epitaph(status)
19582    }
19583
19584    fn is_closed(&self) -> bool {
19585        self.inner.channel().is_closed()
19586    }
19587    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19588        self.inner.channel().on_closed()
19589    }
19590
19591    #[cfg(target_os = "fuchsia")]
19592    fn signal_peer(
19593        &self,
19594        clear_mask: zx::Signals,
19595        set_mask: zx::Signals,
19596    ) -> Result<(), zx_status::Status> {
19597        use fidl::Peered;
19598        self.inner.channel().signal_peer(clear_mask, set_mask)
19599    }
19600}
19601
19602impl Usage2AudioConsumerFactoryControlHandle {}
19603
19604#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19605pub struct UsageAudioConsumerFactoryMarker;
19606
19607impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
19608    type Proxy = UsageAudioConsumerFactoryProxy;
19609    type RequestStream = UsageAudioConsumerFactoryRequestStream;
19610    #[cfg(target_os = "fuchsia")]
19611    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
19612
19613    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
19614}
19615impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
19616
19617pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
19618    fn r#create_audio_consumer(
19619        &self,
19620        usage: AudioRenderUsage,
19621        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19622    ) -> Result<(), fidl::Error>;
19623}
19624#[derive(Debug)]
19625#[cfg(target_os = "fuchsia")]
19626pub struct UsageAudioConsumerFactorySynchronousProxy {
19627    client: fidl::client::sync::Client,
19628}
19629
19630#[cfg(target_os = "fuchsia")]
19631impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
19632    type Proxy = UsageAudioConsumerFactoryProxy;
19633    type Protocol = UsageAudioConsumerFactoryMarker;
19634
19635    fn from_channel(inner: fidl::Channel) -> Self {
19636        Self::new(inner)
19637    }
19638
19639    fn into_channel(self) -> fidl::Channel {
19640        self.client.into_channel()
19641    }
19642
19643    fn as_channel(&self) -> &fidl::Channel {
19644        self.client.as_channel()
19645    }
19646}
19647
19648#[cfg(target_os = "fuchsia")]
19649impl UsageAudioConsumerFactorySynchronousProxy {
19650    pub fn new(channel: fidl::Channel) -> Self {
19651        Self { client: fidl::client::sync::Client::new(channel) }
19652    }
19653
19654    pub fn into_channel(self) -> fidl::Channel {
19655        self.client.into_channel()
19656    }
19657
19658    /// Waits until an event arrives and returns it. It is safe for other
19659    /// threads to make concurrent requests while waiting for an event.
19660    pub fn wait_for_event(
19661        &self,
19662        deadline: zx::MonotonicInstant,
19663    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
19664        UsageAudioConsumerFactoryEvent::decode(
19665            self.client.wait_for_event::<UsageAudioConsumerFactoryMarker>(deadline)?,
19666        )
19667    }
19668
19669    pub fn r#create_audio_consumer(
19670        &self,
19671        mut usage: AudioRenderUsage,
19672        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19673    ) -> Result<(), fidl::Error> {
19674        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
19675            (usage, audio_consumer_request),
19676            0x4d975ca9b8f625a3,
19677            fidl::encoding::DynamicFlags::empty(),
19678        )
19679    }
19680}
19681
19682#[cfg(target_os = "fuchsia")]
19683impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
19684    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
19685        value.into_channel().into()
19686    }
19687}
19688
19689#[cfg(target_os = "fuchsia")]
19690impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
19691    fn from(value: fidl::Channel) -> Self {
19692        Self::new(value)
19693    }
19694}
19695
19696#[cfg(target_os = "fuchsia")]
19697impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
19698    type Protocol = UsageAudioConsumerFactoryMarker;
19699
19700    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
19701        Self::new(value.into_channel())
19702    }
19703}
19704
19705#[derive(Debug, Clone)]
19706pub struct UsageAudioConsumerFactoryProxy {
19707    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19708}
19709
19710impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
19711    type Protocol = UsageAudioConsumerFactoryMarker;
19712
19713    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19714        Self::new(inner)
19715    }
19716
19717    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19718        self.client.into_channel().map_err(|client| Self { client })
19719    }
19720
19721    fn as_channel(&self) -> &::fidl::AsyncChannel {
19722        self.client.as_channel()
19723    }
19724}
19725
19726impl UsageAudioConsumerFactoryProxy {
19727    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
19728    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19729        let protocol_name =
19730            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19731        Self { client: fidl::client::Client::new(channel, protocol_name) }
19732    }
19733
19734    /// Get a Stream of events from the remote end of the protocol.
19735    ///
19736    /// # Panics
19737    ///
19738    /// Panics if the event stream was already taken.
19739    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
19740        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
19741    }
19742
19743    pub fn r#create_audio_consumer(
19744        &self,
19745        mut usage: AudioRenderUsage,
19746        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19747    ) -> Result<(), fidl::Error> {
19748        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
19749            self,
19750            usage,
19751            audio_consumer_request,
19752        )
19753    }
19754}
19755
19756impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
19757    fn r#create_audio_consumer(
19758        &self,
19759        mut usage: AudioRenderUsage,
19760        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19761    ) -> Result<(), fidl::Error> {
19762        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
19763            (usage, audio_consumer_request),
19764            0x4d975ca9b8f625a3,
19765            fidl::encoding::DynamicFlags::empty(),
19766        )
19767    }
19768}
19769
19770pub struct UsageAudioConsumerFactoryEventStream {
19771    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19772}
19773
19774impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
19775
19776impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
19777    fn is_terminated(&self) -> bool {
19778        self.event_receiver.is_terminated()
19779    }
19780}
19781
19782impl futures::Stream for UsageAudioConsumerFactoryEventStream {
19783    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
19784
19785    fn poll_next(
19786        mut self: std::pin::Pin<&mut Self>,
19787        cx: &mut std::task::Context<'_>,
19788    ) -> std::task::Poll<Option<Self::Item>> {
19789        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19790            &mut self.event_receiver,
19791            cx
19792        )?) {
19793            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
19794            None => std::task::Poll::Ready(None),
19795        }
19796    }
19797}
19798
19799#[derive(Debug)]
19800pub enum UsageAudioConsumerFactoryEvent {}
19801
19802impl UsageAudioConsumerFactoryEvent {
19803    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
19804    fn decode(
19805        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19806    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
19807        let (bytes, _handles) = buf.split_mut();
19808        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19809        debug_assert_eq!(tx_header.tx_id, 0);
19810        match tx_header.ordinal {
19811            _ => Err(fidl::Error::UnknownOrdinal {
19812                ordinal: tx_header.ordinal,
19813                protocol_name:
19814                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19815            }),
19816        }
19817    }
19818}
19819
19820/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
19821pub struct UsageAudioConsumerFactoryRequestStream {
19822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19823    is_terminated: bool,
19824}
19825
19826impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
19827
19828impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
19829    fn is_terminated(&self) -> bool {
19830        self.is_terminated
19831    }
19832}
19833
19834impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
19835    type Protocol = UsageAudioConsumerFactoryMarker;
19836    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
19837
19838    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19839        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19840    }
19841
19842    fn control_handle(&self) -> Self::ControlHandle {
19843        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
19844    }
19845
19846    fn into_inner(
19847        self,
19848    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19849    {
19850        (self.inner, self.is_terminated)
19851    }
19852
19853    fn from_inner(
19854        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19855        is_terminated: bool,
19856    ) -> Self {
19857        Self { inner, is_terminated }
19858    }
19859}
19860
19861impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
19862    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
19863
19864    fn poll_next(
19865        mut self: std::pin::Pin<&mut Self>,
19866        cx: &mut std::task::Context<'_>,
19867    ) -> std::task::Poll<Option<Self::Item>> {
19868        let this = &mut *self;
19869        if this.inner.check_shutdown(cx) {
19870            this.is_terminated = true;
19871            return std::task::Poll::Ready(None);
19872        }
19873        if this.is_terminated {
19874            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
19875        }
19876        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19877            |bytes, handles| {
19878                match this.inner.channel().read_etc(cx, bytes, handles) {
19879                    std::task::Poll::Ready(Ok(())) => {}
19880                    std::task::Poll::Pending => return std::task::Poll::Pending,
19881                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19882                        this.is_terminated = true;
19883                        return std::task::Poll::Ready(None);
19884                    }
19885                    std::task::Poll::Ready(Err(e)) => {
19886                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19887                            e.into(),
19888                        ))));
19889                    }
19890                }
19891
19892                // A message has been received from the channel
19893                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19894
19895                std::task::Poll::Ready(Some(match header.ordinal {
19896                0x4d975ca9b8f625a3 => {
19897                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19898                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
19899                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
19900                    let control_handle = UsageAudioConsumerFactoryControlHandle {
19901                        inner: this.inner.clone(),
19902                    };
19903                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
19904audio_consumer_request: req.audio_consumer_request,
19905
19906                        control_handle,
19907                    })
19908                }
19909                _ => Err(fidl::Error::UnknownOrdinal {
19910                    ordinal: header.ordinal,
19911                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19912                }),
19913            }))
19914            },
19915        )
19916    }
19917}
19918
19919/// Interface for creating audio consumers for local rendering.
19920#[derive(Debug)]
19921pub enum UsageAudioConsumerFactoryRequest {
19922    CreateAudioConsumer {
19923        usage: AudioRenderUsage,
19924        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19925        control_handle: UsageAudioConsumerFactoryControlHandle,
19926    },
19927}
19928
19929impl UsageAudioConsumerFactoryRequest {
19930    #[allow(irrefutable_let_patterns)]
19931    pub fn into_create_audio_consumer(
19932        self,
19933    ) -> Option<(
19934        AudioRenderUsage,
19935        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19936        UsageAudioConsumerFactoryControlHandle,
19937    )> {
19938        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
19939            usage,
19940            audio_consumer_request,
19941            control_handle,
19942        } = self
19943        {
19944            Some((usage, audio_consumer_request, control_handle))
19945        } else {
19946            None
19947        }
19948    }
19949
19950    /// Name of the method defined in FIDL
19951    pub fn method_name(&self) -> &'static str {
19952        match *self {
19953            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
19954        }
19955    }
19956}
19957
19958#[derive(Debug, Clone)]
19959pub struct UsageAudioConsumerFactoryControlHandle {
19960    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19961}
19962
19963impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
19964    fn shutdown(&self) {
19965        self.inner.shutdown()
19966    }
19967
19968    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19969        self.inner.shutdown_with_epitaph(status)
19970    }
19971
19972    fn is_closed(&self) -> bool {
19973        self.inner.channel().is_closed()
19974    }
19975    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19976        self.inner.channel().on_closed()
19977    }
19978
19979    #[cfg(target_os = "fuchsia")]
19980    fn signal_peer(
19981        &self,
19982        clear_mask: zx::Signals,
19983        set_mask: zx::Signals,
19984    ) -> Result<(), zx_status::Status> {
19985        use fidl::Peered;
19986        self.inner.channel().signal_peer(clear_mask, set_mask)
19987    }
19988}
19989
19990impl UsageAudioConsumerFactoryControlHandle {}
19991
19992#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19993pub struct UsageGainListenerMarker;
19994
19995impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
19996    type Proxy = UsageGainListenerProxy;
19997    type RequestStream = UsageGainListenerRequestStream;
19998    #[cfg(target_os = "fuchsia")]
19999    type SynchronousProxy = UsageGainListenerSynchronousProxy;
20000
20001    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
20002}
20003
20004pub trait UsageGainListenerProxyInterface: Send + Sync {
20005    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
20006    fn r#on_gain_mute_changed(
20007        &self,
20008        muted: bool,
20009        gain_dbfs: f32,
20010    ) -> Self::OnGainMuteChangedResponseFut;
20011}
20012#[derive(Debug)]
20013#[cfg(target_os = "fuchsia")]
20014pub struct UsageGainListenerSynchronousProxy {
20015    client: fidl::client::sync::Client,
20016}
20017
20018#[cfg(target_os = "fuchsia")]
20019impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
20020    type Proxy = UsageGainListenerProxy;
20021    type Protocol = UsageGainListenerMarker;
20022
20023    fn from_channel(inner: fidl::Channel) -> Self {
20024        Self::new(inner)
20025    }
20026
20027    fn into_channel(self) -> fidl::Channel {
20028        self.client.into_channel()
20029    }
20030
20031    fn as_channel(&self) -> &fidl::Channel {
20032        self.client.as_channel()
20033    }
20034}
20035
20036#[cfg(target_os = "fuchsia")]
20037impl UsageGainListenerSynchronousProxy {
20038    pub fn new(channel: fidl::Channel) -> Self {
20039        Self { client: fidl::client::sync::Client::new(channel) }
20040    }
20041
20042    pub fn into_channel(self) -> fidl::Channel {
20043        self.client.into_channel()
20044    }
20045
20046    /// Waits until an event arrives and returns it. It is safe for other
20047    /// threads to make concurrent requests while waiting for an event.
20048    pub fn wait_for_event(
20049        &self,
20050        deadline: zx::MonotonicInstant,
20051    ) -> Result<UsageGainListenerEvent, fidl::Error> {
20052        UsageGainListenerEvent::decode(
20053            self.client.wait_for_event::<UsageGainListenerMarker>(deadline)?,
20054        )
20055    }
20056
20057    /// Called immediately on connection and afterward any time
20058    /// the usage gain setting changes.
20059    ///
20060    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20061    /// events will eventually be disconnected.
20062    ///
20063    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20064    pub fn r#on_gain_mute_changed(
20065        &self,
20066        mut muted: bool,
20067        mut gain_dbfs: f32,
20068        ___deadline: zx::MonotonicInstant,
20069    ) -> Result<(), fidl::Error> {
20070        let _response = self.client.send_query::<
20071            UsageGainListenerOnGainMuteChangedRequest,
20072            fidl::encoding::EmptyPayload,
20073            UsageGainListenerMarker,
20074        >(
20075            (muted, gain_dbfs,),
20076            0x681570258eac3a8d,
20077            fidl::encoding::DynamicFlags::empty(),
20078            ___deadline,
20079        )?;
20080        Ok(_response)
20081    }
20082}
20083
20084#[cfg(target_os = "fuchsia")]
20085impl From<UsageGainListenerSynchronousProxy> for zx::NullableHandle {
20086    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
20087        value.into_channel().into()
20088    }
20089}
20090
20091#[cfg(target_os = "fuchsia")]
20092impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
20093    fn from(value: fidl::Channel) -> Self {
20094        Self::new(value)
20095    }
20096}
20097
20098#[cfg(target_os = "fuchsia")]
20099impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
20100    type Protocol = UsageGainListenerMarker;
20101
20102    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
20103        Self::new(value.into_channel())
20104    }
20105}
20106
20107#[derive(Debug, Clone)]
20108pub struct UsageGainListenerProxy {
20109    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20110}
20111
20112impl fidl::endpoints::Proxy for UsageGainListenerProxy {
20113    type Protocol = UsageGainListenerMarker;
20114
20115    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20116        Self::new(inner)
20117    }
20118
20119    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20120        self.client.into_channel().map_err(|client| Self { client })
20121    }
20122
20123    fn as_channel(&self) -> &::fidl::AsyncChannel {
20124        self.client.as_channel()
20125    }
20126}
20127
20128impl UsageGainListenerProxy {
20129    /// Create a new Proxy for fuchsia.media/UsageGainListener.
20130    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20131        let protocol_name =
20132            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20133        Self { client: fidl::client::Client::new(channel, protocol_name) }
20134    }
20135
20136    /// Get a Stream of events from the remote end of the protocol.
20137    ///
20138    /// # Panics
20139    ///
20140    /// Panics if the event stream was already taken.
20141    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
20142        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
20143    }
20144
20145    /// Called immediately on connection and afterward any time
20146    /// the usage gain setting changes.
20147    ///
20148    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20149    /// events will eventually be disconnected.
20150    ///
20151    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20152    pub fn r#on_gain_mute_changed(
20153        &self,
20154        mut muted: bool,
20155        mut gain_dbfs: f32,
20156    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20157        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
20158    }
20159}
20160
20161impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
20162    type OnGainMuteChangedResponseFut =
20163        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20164    fn r#on_gain_mute_changed(
20165        &self,
20166        mut muted: bool,
20167        mut gain_dbfs: f32,
20168    ) -> Self::OnGainMuteChangedResponseFut {
20169        fn _decode(
20170            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20171        ) -> Result<(), fidl::Error> {
20172            let _response = fidl::client::decode_transaction_body::<
20173                fidl::encoding::EmptyPayload,
20174                fidl::encoding::DefaultFuchsiaResourceDialect,
20175                0x681570258eac3a8d,
20176            >(_buf?)?;
20177            Ok(_response)
20178        }
20179        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
20180            (muted, gain_dbfs),
20181            0x681570258eac3a8d,
20182            fidl::encoding::DynamicFlags::empty(),
20183            _decode,
20184        )
20185    }
20186}
20187
20188pub struct UsageGainListenerEventStream {
20189    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20190}
20191
20192impl std::marker::Unpin for UsageGainListenerEventStream {}
20193
20194impl futures::stream::FusedStream for UsageGainListenerEventStream {
20195    fn is_terminated(&self) -> bool {
20196        self.event_receiver.is_terminated()
20197    }
20198}
20199
20200impl futures::Stream for UsageGainListenerEventStream {
20201    type Item = Result<UsageGainListenerEvent, fidl::Error>;
20202
20203    fn poll_next(
20204        mut self: std::pin::Pin<&mut Self>,
20205        cx: &mut std::task::Context<'_>,
20206    ) -> std::task::Poll<Option<Self::Item>> {
20207        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20208            &mut self.event_receiver,
20209            cx
20210        )?) {
20211            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
20212            None => std::task::Poll::Ready(None),
20213        }
20214    }
20215}
20216
20217#[derive(Debug)]
20218pub enum UsageGainListenerEvent {}
20219
20220impl UsageGainListenerEvent {
20221    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
20222    fn decode(
20223        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20224    ) -> Result<UsageGainListenerEvent, fidl::Error> {
20225        let (bytes, _handles) = buf.split_mut();
20226        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20227        debug_assert_eq!(tx_header.tx_id, 0);
20228        match tx_header.ordinal {
20229            _ => Err(fidl::Error::UnknownOrdinal {
20230                ordinal: tx_header.ordinal,
20231                protocol_name:
20232                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20233            }),
20234        }
20235    }
20236}
20237
20238/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
20239pub struct UsageGainListenerRequestStream {
20240    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20241    is_terminated: bool,
20242}
20243
20244impl std::marker::Unpin for UsageGainListenerRequestStream {}
20245
20246impl futures::stream::FusedStream for UsageGainListenerRequestStream {
20247    fn is_terminated(&self) -> bool {
20248        self.is_terminated
20249    }
20250}
20251
20252impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
20253    type Protocol = UsageGainListenerMarker;
20254    type ControlHandle = UsageGainListenerControlHandle;
20255
20256    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20257        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20258    }
20259
20260    fn control_handle(&self) -> Self::ControlHandle {
20261        UsageGainListenerControlHandle { inner: self.inner.clone() }
20262    }
20263
20264    fn into_inner(
20265        self,
20266    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20267    {
20268        (self.inner, self.is_terminated)
20269    }
20270
20271    fn from_inner(
20272        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20273        is_terminated: bool,
20274    ) -> Self {
20275        Self { inner, is_terminated }
20276    }
20277}
20278
20279impl futures::Stream for UsageGainListenerRequestStream {
20280    type Item = Result<UsageGainListenerRequest, fidl::Error>;
20281
20282    fn poll_next(
20283        mut self: std::pin::Pin<&mut Self>,
20284        cx: &mut std::task::Context<'_>,
20285    ) -> std::task::Poll<Option<Self::Item>> {
20286        let this = &mut *self;
20287        if this.inner.check_shutdown(cx) {
20288            this.is_terminated = true;
20289            return std::task::Poll::Ready(None);
20290        }
20291        if this.is_terminated {
20292            panic!("polled UsageGainListenerRequestStream after completion");
20293        }
20294        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20295            |bytes, handles| {
20296                match this.inner.channel().read_etc(cx, bytes, handles) {
20297                    std::task::Poll::Ready(Ok(())) => {}
20298                    std::task::Poll::Pending => return std::task::Poll::Pending,
20299                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20300                        this.is_terminated = true;
20301                        return std::task::Poll::Ready(None);
20302                    }
20303                    std::task::Poll::Ready(Err(e)) => {
20304                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20305                            e.into(),
20306                        ))));
20307                    }
20308                }
20309
20310                // A message has been received from the channel
20311                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20312
20313                std::task::Poll::Ready(Some(match header.ordinal {
20314                    0x681570258eac3a8d => {
20315                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20316                        let mut req = fidl::new_empty!(
20317                            UsageGainListenerOnGainMuteChangedRequest,
20318                            fidl::encoding::DefaultFuchsiaResourceDialect
20319                        );
20320                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20321                        let control_handle =
20322                            UsageGainListenerControlHandle { inner: this.inner.clone() };
20323                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
20324                            muted: req.muted,
20325                            gain_dbfs: req.gain_dbfs,
20326
20327                            responder: UsageGainListenerOnGainMuteChangedResponder {
20328                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20329                                tx_id: header.tx_id,
20330                            },
20331                        })
20332                    }
20333                    _ => Err(fidl::Error::UnknownOrdinal {
20334                        ordinal: header.ordinal,
20335                        protocol_name:
20336                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20337                    }),
20338                }))
20339            },
20340        )
20341    }
20342}
20343
20344/// A protocol for watching changes to usage gain settings.
20345///
20346/// The channel will close when the device is not present.
20347#[derive(Debug)]
20348pub enum UsageGainListenerRequest {
20349    /// Called immediately on connection and afterward any time
20350    /// the usage gain setting changes.
20351    ///
20352    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20353    /// events will eventually be disconnected.
20354    ///
20355    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20356    OnGainMuteChanged {
20357        muted: bool,
20358        gain_dbfs: f32,
20359        responder: UsageGainListenerOnGainMuteChangedResponder,
20360    },
20361}
20362
20363impl UsageGainListenerRequest {
20364    #[allow(irrefutable_let_patterns)]
20365    pub fn into_on_gain_mute_changed(
20366        self,
20367    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
20368        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
20369            Some((muted, gain_dbfs, responder))
20370        } else {
20371            None
20372        }
20373    }
20374
20375    /// Name of the method defined in FIDL
20376    pub fn method_name(&self) -> &'static str {
20377        match *self {
20378            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
20379        }
20380    }
20381}
20382
20383#[derive(Debug, Clone)]
20384pub struct UsageGainListenerControlHandle {
20385    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20386}
20387
20388impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
20389    fn shutdown(&self) {
20390        self.inner.shutdown()
20391    }
20392
20393    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20394        self.inner.shutdown_with_epitaph(status)
20395    }
20396
20397    fn is_closed(&self) -> bool {
20398        self.inner.channel().is_closed()
20399    }
20400    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20401        self.inner.channel().on_closed()
20402    }
20403
20404    #[cfg(target_os = "fuchsia")]
20405    fn signal_peer(
20406        &self,
20407        clear_mask: zx::Signals,
20408        set_mask: zx::Signals,
20409    ) -> Result<(), zx_status::Status> {
20410        use fidl::Peered;
20411        self.inner.channel().signal_peer(clear_mask, set_mask)
20412    }
20413}
20414
20415impl UsageGainListenerControlHandle {}
20416
20417#[must_use = "FIDL methods require a response to be sent"]
20418#[derive(Debug)]
20419pub struct UsageGainListenerOnGainMuteChangedResponder {
20420    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
20421    tx_id: u32,
20422}
20423
20424/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
20425/// if the responder is dropped without sending a response, so that the client
20426/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20427impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
20428    fn drop(&mut self) {
20429        self.control_handle.shutdown();
20430        // Safety: drops once, never accessed again
20431        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20432    }
20433}
20434
20435impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
20436    type ControlHandle = UsageGainListenerControlHandle;
20437
20438    fn control_handle(&self) -> &UsageGainListenerControlHandle {
20439        &self.control_handle
20440    }
20441
20442    fn drop_without_shutdown(mut self) {
20443        // Safety: drops once, never accessed again due to mem::forget
20444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20445        // Prevent Drop from running (which would shut down the channel)
20446        std::mem::forget(self);
20447    }
20448}
20449
20450impl UsageGainListenerOnGainMuteChangedResponder {
20451    /// Sends a response to the FIDL transaction.
20452    ///
20453    /// Sets the channel to shutdown if an error occurs.
20454    pub fn send(self) -> Result<(), fidl::Error> {
20455        let _result = self.send_raw();
20456        if _result.is_err() {
20457            self.control_handle.shutdown();
20458        }
20459        self.drop_without_shutdown();
20460        _result
20461    }
20462
20463    /// Similar to "send" but does not shutdown the channel if an error occurs.
20464    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20465        let _result = self.send_raw();
20466        self.drop_without_shutdown();
20467        _result
20468    }
20469
20470    fn send_raw(&self) -> Result<(), fidl::Error> {
20471        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20472            (),
20473            self.tx_id,
20474            0x681570258eac3a8d,
20475            fidl::encoding::DynamicFlags::empty(),
20476        )
20477    }
20478}
20479
20480#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20481pub struct UsageGainReporterMarker;
20482
20483impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
20484    type Proxy = UsageGainReporterProxy;
20485    type RequestStream = UsageGainReporterRequestStream;
20486    #[cfg(target_os = "fuchsia")]
20487    type SynchronousProxy = UsageGainReporterSynchronousProxy;
20488
20489    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
20490}
20491impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
20492
20493pub trait UsageGainReporterProxyInterface: Send + Sync {
20494    fn r#register_listener(
20495        &self,
20496        device_unique_id: &str,
20497        usage: &Usage,
20498        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20499    ) -> Result<(), fidl::Error>;
20500    fn r#register_listener2(
20501        &self,
20502        device_unique_id: &str,
20503        usage: &Usage2,
20504        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20505    ) -> Result<(), fidl::Error>;
20506}
20507#[derive(Debug)]
20508#[cfg(target_os = "fuchsia")]
20509pub struct UsageGainReporterSynchronousProxy {
20510    client: fidl::client::sync::Client,
20511}
20512
20513#[cfg(target_os = "fuchsia")]
20514impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
20515    type Proxy = UsageGainReporterProxy;
20516    type Protocol = UsageGainReporterMarker;
20517
20518    fn from_channel(inner: fidl::Channel) -> Self {
20519        Self::new(inner)
20520    }
20521
20522    fn into_channel(self) -> fidl::Channel {
20523        self.client.into_channel()
20524    }
20525
20526    fn as_channel(&self) -> &fidl::Channel {
20527        self.client.as_channel()
20528    }
20529}
20530
20531#[cfg(target_os = "fuchsia")]
20532impl UsageGainReporterSynchronousProxy {
20533    pub fn new(channel: fidl::Channel) -> Self {
20534        Self { client: fidl::client::sync::Client::new(channel) }
20535    }
20536
20537    pub fn into_channel(self) -> fidl::Channel {
20538        self.client.into_channel()
20539    }
20540
20541    /// Waits until an event arrives and returns it. It is safe for other
20542    /// threads to make concurrent requests while waiting for an event.
20543    pub fn wait_for_event(
20544        &self,
20545        deadline: zx::MonotonicInstant,
20546    ) -> Result<UsageGainReporterEvent, fidl::Error> {
20547        UsageGainReporterEvent::decode(
20548            self.client.wait_for_event::<UsageGainReporterMarker>(deadline)?,
20549        )
20550    }
20551
20552    /// Connects a listener to a stream of usage gain setting changes
20553    /// for `usage` on the device identified by `device_token`. Usage
20554    /// Gain is not set directly by any client; it is a translation of
20555    /// the usage volume setting for each device, summed with active
20556    /// muting/ducking gain adjustments.
20557    ///
20558    /// Devices may map the same volume level to different dbfs, so
20559    /// a `device_unique_id` is needed to identify the device.
20560    ///
20561    /// `AudioDeviceEnumerator` provides programmatic access to devices
20562    /// and their unique ids if it is necessary for a client to select
20563    /// an id at runtime.
20564    pub fn r#register_listener(
20565        &self,
20566        mut device_unique_id: &str,
20567        mut usage: &Usage,
20568        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20569    ) -> Result<(), fidl::Error> {
20570        self.client.send::<UsageGainReporterRegisterListenerRequest>(
20571            (device_unique_id, usage, usage_gain_listener),
20572            0x767107c168c226af,
20573            fidl::encoding::DynamicFlags::empty(),
20574        )
20575    }
20576
20577    /// Connects a listener to a stream of usage gain setting changes
20578    /// for `usage` on the device identified by `device_token`. Usage
20579    /// Gain is not set directly by any client; it is a translation of
20580    /// the usage volume setting for each device, summed with active
20581    /// muting/ducking gain adjustments.
20582    ///
20583    /// Devices may map the same volume level to different dbfs, so
20584    /// a `device_unique_id` is needed to identify the device.
20585    ///
20586    /// `AudioDeviceEnumerator` provides programmatic access to devices
20587    /// and their unique ids if it is necessary for a client to select
20588    /// an id at runtime.
20589    pub fn r#register_listener2(
20590        &self,
20591        mut device_unique_id: &str,
20592        mut usage: &Usage2,
20593        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20594    ) -> Result<(), fidl::Error> {
20595        self.client.send::<UsageGainReporterRegisterListener2Request>(
20596            (device_unique_id, usage, usage_gain_listener),
20597            0x760a8e1c5873629c,
20598            fidl::encoding::DynamicFlags::FLEXIBLE,
20599        )
20600    }
20601}
20602
20603#[cfg(target_os = "fuchsia")]
20604impl From<UsageGainReporterSynchronousProxy> for zx::NullableHandle {
20605    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
20606        value.into_channel().into()
20607    }
20608}
20609
20610#[cfg(target_os = "fuchsia")]
20611impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
20612    fn from(value: fidl::Channel) -> Self {
20613        Self::new(value)
20614    }
20615}
20616
20617#[cfg(target_os = "fuchsia")]
20618impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
20619    type Protocol = UsageGainReporterMarker;
20620
20621    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
20622        Self::new(value.into_channel())
20623    }
20624}
20625
20626#[derive(Debug, Clone)]
20627pub struct UsageGainReporterProxy {
20628    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20629}
20630
20631impl fidl::endpoints::Proxy for UsageGainReporterProxy {
20632    type Protocol = UsageGainReporterMarker;
20633
20634    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20635        Self::new(inner)
20636    }
20637
20638    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20639        self.client.into_channel().map_err(|client| Self { client })
20640    }
20641
20642    fn as_channel(&self) -> &::fidl::AsyncChannel {
20643        self.client.as_channel()
20644    }
20645}
20646
20647impl UsageGainReporterProxy {
20648    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
20649    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20650        let protocol_name =
20651            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20652        Self { client: fidl::client::Client::new(channel, protocol_name) }
20653    }
20654
20655    /// Get a Stream of events from the remote end of the protocol.
20656    ///
20657    /// # Panics
20658    ///
20659    /// Panics if the event stream was already taken.
20660    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
20661        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
20662    }
20663
20664    /// Connects a listener to a stream of usage gain setting changes
20665    /// for `usage` on the device identified by `device_token`. Usage
20666    /// Gain is not set directly by any client; it is a translation of
20667    /// the usage volume setting for each device, summed with active
20668    /// muting/ducking gain adjustments.
20669    ///
20670    /// Devices may map the same volume level to different dbfs, so
20671    /// a `device_unique_id` is needed to identify the device.
20672    ///
20673    /// `AudioDeviceEnumerator` provides programmatic access to devices
20674    /// and their unique ids if it is necessary for a client to select
20675    /// an id at runtime.
20676    pub fn r#register_listener(
20677        &self,
20678        mut device_unique_id: &str,
20679        mut usage: &Usage,
20680        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20681    ) -> Result<(), fidl::Error> {
20682        UsageGainReporterProxyInterface::r#register_listener(
20683            self,
20684            device_unique_id,
20685            usage,
20686            usage_gain_listener,
20687        )
20688    }
20689
20690    /// Connects a listener to a stream of usage gain setting changes
20691    /// for `usage` on the device identified by `device_token`. Usage
20692    /// Gain is not set directly by any client; it is a translation of
20693    /// the usage volume setting for each device, summed with active
20694    /// muting/ducking gain adjustments.
20695    ///
20696    /// Devices may map the same volume level to different dbfs, so
20697    /// a `device_unique_id` is needed to identify the device.
20698    ///
20699    /// `AudioDeviceEnumerator` provides programmatic access to devices
20700    /// and their unique ids if it is necessary for a client to select
20701    /// an id at runtime.
20702    pub fn r#register_listener2(
20703        &self,
20704        mut device_unique_id: &str,
20705        mut usage: &Usage2,
20706        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20707    ) -> Result<(), fidl::Error> {
20708        UsageGainReporterProxyInterface::r#register_listener2(
20709            self,
20710            device_unique_id,
20711            usage,
20712            usage_gain_listener,
20713        )
20714    }
20715}
20716
20717impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
20718    fn r#register_listener(
20719        &self,
20720        mut device_unique_id: &str,
20721        mut usage: &Usage,
20722        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20723    ) -> Result<(), fidl::Error> {
20724        self.client.send::<UsageGainReporterRegisterListenerRequest>(
20725            (device_unique_id, usage, usage_gain_listener),
20726            0x767107c168c226af,
20727            fidl::encoding::DynamicFlags::empty(),
20728        )
20729    }
20730
20731    fn r#register_listener2(
20732        &self,
20733        mut device_unique_id: &str,
20734        mut usage: &Usage2,
20735        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20736    ) -> Result<(), fidl::Error> {
20737        self.client.send::<UsageGainReporterRegisterListener2Request>(
20738            (device_unique_id, usage, usage_gain_listener),
20739            0x760a8e1c5873629c,
20740            fidl::encoding::DynamicFlags::FLEXIBLE,
20741        )
20742    }
20743}
20744
20745pub struct UsageGainReporterEventStream {
20746    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20747}
20748
20749impl std::marker::Unpin for UsageGainReporterEventStream {}
20750
20751impl futures::stream::FusedStream for UsageGainReporterEventStream {
20752    fn is_terminated(&self) -> bool {
20753        self.event_receiver.is_terminated()
20754    }
20755}
20756
20757impl futures::Stream for UsageGainReporterEventStream {
20758    type Item = Result<UsageGainReporterEvent, fidl::Error>;
20759
20760    fn poll_next(
20761        mut self: std::pin::Pin<&mut Self>,
20762        cx: &mut std::task::Context<'_>,
20763    ) -> std::task::Poll<Option<Self::Item>> {
20764        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20765            &mut self.event_receiver,
20766            cx
20767        )?) {
20768            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
20769            None => std::task::Poll::Ready(None),
20770        }
20771    }
20772}
20773
20774#[derive(Debug)]
20775pub enum UsageGainReporterEvent {
20776    #[non_exhaustive]
20777    _UnknownEvent {
20778        /// Ordinal of the event that was sent.
20779        ordinal: u64,
20780    },
20781}
20782
20783impl UsageGainReporterEvent {
20784    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
20785    fn decode(
20786        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20787    ) -> Result<UsageGainReporterEvent, fidl::Error> {
20788        let (bytes, _handles) = buf.split_mut();
20789        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20790        debug_assert_eq!(tx_header.tx_id, 0);
20791        match tx_header.ordinal {
20792            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
20793                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
20794            }
20795            _ => Err(fidl::Error::UnknownOrdinal {
20796                ordinal: tx_header.ordinal,
20797                protocol_name:
20798                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20799            }),
20800        }
20801    }
20802}
20803
20804/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
20805pub struct UsageGainReporterRequestStream {
20806    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20807    is_terminated: bool,
20808}
20809
20810impl std::marker::Unpin for UsageGainReporterRequestStream {}
20811
20812impl futures::stream::FusedStream for UsageGainReporterRequestStream {
20813    fn is_terminated(&self) -> bool {
20814        self.is_terminated
20815    }
20816}
20817
20818impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
20819    type Protocol = UsageGainReporterMarker;
20820    type ControlHandle = UsageGainReporterControlHandle;
20821
20822    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20823        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20824    }
20825
20826    fn control_handle(&self) -> Self::ControlHandle {
20827        UsageGainReporterControlHandle { inner: self.inner.clone() }
20828    }
20829
20830    fn into_inner(
20831        self,
20832    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20833    {
20834        (self.inner, self.is_terminated)
20835    }
20836
20837    fn from_inner(
20838        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20839        is_terminated: bool,
20840    ) -> Self {
20841        Self { inner, is_terminated }
20842    }
20843}
20844
20845impl futures::Stream for UsageGainReporterRequestStream {
20846    type Item = Result<UsageGainReporterRequest, fidl::Error>;
20847
20848    fn poll_next(
20849        mut self: std::pin::Pin<&mut Self>,
20850        cx: &mut std::task::Context<'_>,
20851    ) -> std::task::Poll<Option<Self::Item>> {
20852        let this = &mut *self;
20853        if this.inner.check_shutdown(cx) {
20854            this.is_terminated = true;
20855            return std::task::Poll::Ready(None);
20856        }
20857        if this.is_terminated {
20858            panic!("polled UsageGainReporterRequestStream after completion");
20859        }
20860        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20861            |bytes, handles| {
20862                match this.inner.channel().read_etc(cx, bytes, handles) {
20863                    std::task::Poll::Ready(Ok(())) => {}
20864                    std::task::Poll::Pending => return std::task::Poll::Pending,
20865                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20866                        this.is_terminated = true;
20867                        return std::task::Poll::Ready(None);
20868                    }
20869                    std::task::Poll::Ready(Err(e)) => {
20870                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20871                            e.into(),
20872                        ))));
20873                    }
20874                }
20875
20876                // A message has been received from the channel
20877                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20878
20879                std::task::Poll::Ready(Some(match header.ordinal {
20880                    0x767107c168c226af => {
20881                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
20882                        let mut req = fidl::new_empty!(
20883                            UsageGainReporterRegisterListenerRequest,
20884                            fidl::encoding::DefaultFuchsiaResourceDialect
20885                        );
20886                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
20887                        let control_handle =
20888                            UsageGainReporterControlHandle { inner: this.inner.clone() };
20889                        Ok(UsageGainReporterRequest::RegisterListener {
20890                            device_unique_id: req.device_unique_id,
20891                            usage: req.usage,
20892                            usage_gain_listener: req.usage_gain_listener,
20893
20894                            control_handle,
20895                        })
20896                    }
20897                    0x760a8e1c5873629c => {
20898                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
20899                        let mut req = fidl::new_empty!(
20900                            UsageGainReporterRegisterListener2Request,
20901                            fidl::encoding::DefaultFuchsiaResourceDialect
20902                        );
20903                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
20904                        let control_handle =
20905                            UsageGainReporterControlHandle { inner: this.inner.clone() };
20906                        Ok(UsageGainReporterRequest::RegisterListener2 {
20907                            device_unique_id: req.device_unique_id,
20908                            usage: req.usage,
20909                            usage_gain_listener: req.usage_gain_listener,
20910
20911                            control_handle,
20912                        })
20913                    }
20914                    _ if header.tx_id == 0
20915                        && header
20916                            .dynamic_flags()
20917                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
20918                    {
20919                        Ok(UsageGainReporterRequest::_UnknownMethod {
20920                            ordinal: header.ordinal,
20921                            control_handle: UsageGainReporterControlHandle {
20922                                inner: this.inner.clone(),
20923                            },
20924                            method_type: fidl::MethodType::OneWay,
20925                        })
20926                    }
20927                    _ if header
20928                        .dynamic_flags()
20929                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
20930                    {
20931                        this.inner.send_framework_err(
20932                            fidl::encoding::FrameworkErr::UnknownMethod,
20933                            header.tx_id,
20934                            header.ordinal,
20935                            header.dynamic_flags(),
20936                            (bytes, handles),
20937                        )?;
20938                        Ok(UsageGainReporterRequest::_UnknownMethod {
20939                            ordinal: header.ordinal,
20940                            control_handle: UsageGainReporterControlHandle {
20941                                inner: this.inner.clone(),
20942                            },
20943                            method_type: fidl::MethodType::TwoWay,
20944                        })
20945                    }
20946                    _ => Err(fidl::Error::UnknownOrdinal {
20947                        ordinal: header.ordinal,
20948                        protocol_name:
20949                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20950                    }),
20951                }))
20952            },
20953        )
20954    }
20955}
20956
20957/// A protocol for setting up watchers of usage gain.
20958#[derive(Debug)]
20959pub enum UsageGainReporterRequest {
20960    /// Connects a listener to a stream of usage gain setting changes
20961    /// for `usage` on the device identified by `device_token`. Usage
20962    /// Gain is not set directly by any client; it is a translation of
20963    /// the usage volume setting for each device, summed with active
20964    /// muting/ducking gain adjustments.
20965    ///
20966    /// Devices may map the same volume level to different dbfs, so
20967    /// a `device_unique_id` is needed to identify the device.
20968    ///
20969    /// `AudioDeviceEnumerator` provides programmatic access to devices
20970    /// and their unique ids if it is necessary for a client to select
20971    /// an id at runtime.
20972    RegisterListener {
20973        device_unique_id: String,
20974        usage: Usage,
20975        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20976        control_handle: UsageGainReporterControlHandle,
20977    },
20978    /// Connects a listener to a stream of usage gain setting changes
20979    /// for `usage` on the device identified by `device_token`. Usage
20980    /// Gain is not set directly by any client; it is a translation of
20981    /// the usage volume setting for each device, summed with active
20982    /// muting/ducking gain adjustments.
20983    ///
20984    /// Devices may map the same volume level to different dbfs, so
20985    /// a `device_unique_id` is needed to identify the device.
20986    ///
20987    /// `AudioDeviceEnumerator` provides programmatic access to devices
20988    /// and their unique ids if it is necessary for a client to select
20989    /// an id at runtime.
20990    RegisterListener2 {
20991        device_unique_id: String,
20992        usage: Usage2,
20993        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20994        control_handle: UsageGainReporterControlHandle,
20995    },
20996    /// An interaction was received which does not match any known method.
20997    #[non_exhaustive]
20998    _UnknownMethod {
20999        /// Ordinal of the method that was called.
21000        ordinal: u64,
21001        control_handle: UsageGainReporterControlHandle,
21002        method_type: fidl::MethodType,
21003    },
21004}
21005
21006impl UsageGainReporterRequest {
21007    #[allow(irrefutable_let_patterns)]
21008    pub fn into_register_listener(
21009        self,
21010    ) -> Option<(
21011        String,
21012        Usage,
21013        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21014        UsageGainReporterControlHandle,
21015    )> {
21016        if let UsageGainReporterRequest::RegisterListener {
21017            device_unique_id,
21018            usage,
21019            usage_gain_listener,
21020            control_handle,
21021        } = self
21022        {
21023            Some((device_unique_id, usage, usage_gain_listener, control_handle))
21024        } else {
21025            None
21026        }
21027    }
21028
21029    #[allow(irrefutable_let_patterns)]
21030    pub fn into_register_listener2(
21031        self,
21032    ) -> Option<(
21033        String,
21034        Usage2,
21035        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21036        UsageGainReporterControlHandle,
21037    )> {
21038        if let UsageGainReporterRequest::RegisterListener2 {
21039            device_unique_id,
21040            usage,
21041            usage_gain_listener,
21042            control_handle,
21043        } = self
21044        {
21045            Some((device_unique_id, usage, usage_gain_listener, control_handle))
21046        } else {
21047            None
21048        }
21049    }
21050
21051    /// Name of the method defined in FIDL
21052    pub fn method_name(&self) -> &'static str {
21053        match *self {
21054            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
21055            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
21056            UsageGainReporterRequest::_UnknownMethod {
21057                method_type: fidl::MethodType::OneWay,
21058                ..
21059            } => "unknown one-way method",
21060            UsageGainReporterRequest::_UnknownMethod {
21061                method_type: fidl::MethodType::TwoWay,
21062                ..
21063            } => "unknown two-way method",
21064        }
21065    }
21066}
21067
21068#[derive(Debug, Clone)]
21069pub struct UsageGainReporterControlHandle {
21070    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21071}
21072
21073impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
21074    fn shutdown(&self) {
21075        self.inner.shutdown()
21076    }
21077
21078    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
21079        self.inner.shutdown_with_epitaph(status)
21080    }
21081
21082    fn is_closed(&self) -> bool {
21083        self.inner.channel().is_closed()
21084    }
21085    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
21086        self.inner.channel().on_closed()
21087    }
21088
21089    #[cfg(target_os = "fuchsia")]
21090    fn signal_peer(
21091        &self,
21092        clear_mask: zx::Signals,
21093        set_mask: zx::Signals,
21094    ) -> Result<(), zx_status::Status> {
21095        use fidl::Peered;
21096        self.inner.channel().signal_peer(clear_mask, set_mask)
21097    }
21098}
21099
21100impl UsageGainReporterControlHandle {}
21101
21102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
21103pub struct UsageReporterMarker;
21104
21105impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
21106    type Proxy = UsageReporterProxy;
21107    type RequestStream = UsageReporterRequestStream;
21108    #[cfg(target_os = "fuchsia")]
21109    type SynchronousProxy = UsageReporterSynchronousProxy;
21110
21111    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
21112}
21113impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
21114
21115pub trait UsageReporterProxyInterface: Send + Sync {
21116    fn r#watch(
21117        &self,
21118        usage: &Usage,
21119        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21120    ) -> Result<(), fidl::Error>;
21121    fn r#watch2(
21122        &self,
21123        usage: &Usage2,
21124        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21125    ) -> Result<(), fidl::Error>;
21126}
21127#[derive(Debug)]
21128#[cfg(target_os = "fuchsia")]
21129pub struct UsageReporterSynchronousProxy {
21130    client: fidl::client::sync::Client,
21131}
21132
21133#[cfg(target_os = "fuchsia")]
21134impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
21135    type Proxy = UsageReporterProxy;
21136    type Protocol = UsageReporterMarker;
21137
21138    fn from_channel(inner: fidl::Channel) -> Self {
21139        Self::new(inner)
21140    }
21141
21142    fn into_channel(self) -> fidl::Channel {
21143        self.client.into_channel()
21144    }
21145
21146    fn as_channel(&self) -> &fidl::Channel {
21147        self.client.as_channel()
21148    }
21149}
21150
21151#[cfg(target_os = "fuchsia")]
21152impl UsageReporterSynchronousProxy {
21153    pub fn new(channel: fidl::Channel) -> Self {
21154        Self { client: fidl::client::sync::Client::new(channel) }
21155    }
21156
21157    pub fn into_channel(self) -> fidl::Channel {
21158        self.client.into_channel()
21159    }
21160
21161    /// Waits until an event arrives and returns it. It is safe for other
21162    /// threads to make concurrent requests while waiting for an event.
21163    pub fn wait_for_event(
21164        &self,
21165        deadline: zx::MonotonicInstant,
21166    ) -> Result<UsageReporterEvent, fidl::Error> {
21167        UsageReporterEvent::decode(self.client.wait_for_event::<UsageReporterMarker>(deadline)?)
21168    }
21169
21170    pub fn r#watch(
21171        &self,
21172        mut usage: &Usage,
21173        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21174    ) -> Result<(), fidl::Error> {
21175        self.client.send::<UsageReporterWatchRequest>(
21176            (usage, usage_watcher),
21177            0x769e6fb17075c959,
21178            fidl::encoding::DynamicFlags::empty(),
21179        )
21180    }
21181
21182    pub fn r#watch2(
21183        &self,
21184        mut usage: &Usage2,
21185        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21186    ) -> Result<(), fidl::Error> {
21187        self.client.send::<UsageReporterWatch2Request>(
21188            (usage, usage_watcher),
21189            0x4a43c4c82f5d8ce8,
21190            fidl::encoding::DynamicFlags::FLEXIBLE,
21191        )
21192    }
21193}
21194
21195#[cfg(target_os = "fuchsia")]
21196impl From<UsageReporterSynchronousProxy> for zx::NullableHandle {
21197    fn from(value: UsageReporterSynchronousProxy) -> Self {
21198        value.into_channel().into()
21199    }
21200}
21201
21202#[cfg(target_os = "fuchsia")]
21203impl From<fidl::Channel> for UsageReporterSynchronousProxy {
21204    fn from(value: fidl::Channel) -> Self {
21205        Self::new(value)
21206    }
21207}
21208
21209#[cfg(target_os = "fuchsia")]
21210impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
21211    type Protocol = UsageReporterMarker;
21212
21213    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
21214        Self::new(value.into_channel())
21215    }
21216}
21217
21218#[derive(Debug, Clone)]
21219pub struct UsageReporterProxy {
21220    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
21221}
21222
21223impl fidl::endpoints::Proxy for UsageReporterProxy {
21224    type Protocol = UsageReporterMarker;
21225
21226    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
21227        Self::new(inner)
21228    }
21229
21230    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
21231        self.client.into_channel().map_err(|client| Self { client })
21232    }
21233
21234    fn as_channel(&self) -> &::fidl::AsyncChannel {
21235        self.client.as_channel()
21236    }
21237}
21238
21239impl UsageReporterProxy {
21240    /// Create a new Proxy for fuchsia.media/UsageReporter.
21241    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
21242        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
21243        Self { client: fidl::client::Client::new(channel, protocol_name) }
21244    }
21245
21246    /// Get a Stream of events from the remote end of the protocol.
21247    ///
21248    /// # Panics
21249    ///
21250    /// Panics if the event stream was already taken.
21251    pub fn take_event_stream(&self) -> UsageReporterEventStream {
21252        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
21253    }
21254
21255    pub fn r#watch(
21256        &self,
21257        mut usage: &Usage,
21258        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21259    ) -> Result<(), fidl::Error> {
21260        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
21261    }
21262
21263    pub fn r#watch2(
21264        &self,
21265        mut usage: &Usage2,
21266        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21267    ) -> Result<(), fidl::Error> {
21268        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
21269    }
21270}
21271
21272impl UsageReporterProxyInterface for UsageReporterProxy {
21273    fn r#watch(
21274        &self,
21275        mut usage: &Usage,
21276        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21277    ) -> Result<(), fidl::Error> {
21278        self.client.send::<UsageReporterWatchRequest>(
21279            (usage, usage_watcher),
21280            0x769e6fb17075c959,
21281            fidl::encoding::DynamicFlags::empty(),
21282        )
21283    }
21284
21285    fn r#watch2(
21286        &self,
21287        mut usage: &Usage2,
21288        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21289    ) -> Result<(), fidl::Error> {
21290        self.client.send::<UsageReporterWatch2Request>(
21291            (usage, usage_watcher),
21292            0x4a43c4c82f5d8ce8,
21293            fidl::encoding::DynamicFlags::FLEXIBLE,
21294        )
21295    }
21296}
21297
21298pub struct UsageReporterEventStream {
21299    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
21300}
21301
21302impl std::marker::Unpin for UsageReporterEventStream {}
21303
21304impl futures::stream::FusedStream for UsageReporterEventStream {
21305    fn is_terminated(&self) -> bool {
21306        self.event_receiver.is_terminated()
21307    }
21308}
21309
21310impl futures::Stream for UsageReporterEventStream {
21311    type Item = Result<UsageReporterEvent, fidl::Error>;
21312
21313    fn poll_next(
21314        mut self: std::pin::Pin<&mut Self>,
21315        cx: &mut std::task::Context<'_>,
21316    ) -> std::task::Poll<Option<Self::Item>> {
21317        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
21318            &mut self.event_receiver,
21319            cx
21320        )?) {
21321            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
21322            None => std::task::Poll::Ready(None),
21323        }
21324    }
21325}
21326
21327#[derive(Debug)]
21328pub enum UsageReporterEvent {
21329    #[non_exhaustive]
21330    _UnknownEvent {
21331        /// Ordinal of the event that was sent.
21332        ordinal: u64,
21333    },
21334}
21335
21336impl UsageReporterEvent {
21337    /// Decodes a message buffer as a [`UsageReporterEvent`].
21338    fn decode(
21339        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
21340    ) -> Result<UsageReporterEvent, fidl::Error> {
21341        let (bytes, _handles) = buf.split_mut();
21342        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21343        debug_assert_eq!(tx_header.tx_id, 0);
21344        match tx_header.ordinal {
21345            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
21346                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
21347            }
21348            _ => Err(fidl::Error::UnknownOrdinal {
21349                ordinal: tx_header.ordinal,
21350                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21351            }),
21352        }
21353    }
21354}
21355
21356/// A Stream of incoming requests for fuchsia.media/UsageReporter.
21357pub struct UsageReporterRequestStream {
21358    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21359    is_terminated: bool,
21360}
21361
21362impl std::marker::Unpin for UsageReporterRequestStream {}
21363
21364impl futures::stream::FusedStream for UsageReporterRequestStream {
21365    fn is_terminated(&self) -> bool {
21366        self.is_terminated
21367    }
21368}
21369
21370impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
21371    type Protocol = UsageReporterMarker;
21372    type ControlHandle = UsageReporterControlHandle;
21373
21374    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
21375        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
21376    }
21377
21378    fn control_handle(&self) -> Self::ControlHandle {
21379        UsageReporterControlHandle { inner: self.inner.clone() }
21380    }
21381
21382    fn into_inner(
21383        self,
21384    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
21385    {
21386        (self.inner, self.is_terminated)
21387    }
21388
21389    fn from_inner(
21390        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21391        is_terminated: bool,
21392    ) -> Self {
21393        Self { inner, is_terminated }
21394    }
21395}
21396
21397impl futures::Stream for UsageReporterRequestStream {
21398    type Item = Result<UsageReporterRequest, fidl::Error>;
21399
21400    fn poll_next(
21401        mut self: std::pin::Pin<&mut Self>,
21402        cx: &mut std::task::Context<'_>,
21403    ) -> std::task::Poll<Option<Self::Item>> {
21404        let this = &mut *self;
21405        if this.inner.check_shutdown(cx) {
21406            this.is_terminated = true;
21407            return std::task::Poll::Ready(None);
21408        }
21409        if this.is_terminated {
21410            panic!("polled UsageReporterRequestStream after completion");
21411        }
21412        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
21413            |bytes, handles| {
21414                match this.inner.channel().read_etc(cx, bytes, handles) {
21415                    std::task::Poll::Ready(Ok(())) => {}
21416                    std::task::Poll::Pending => return std::task::Poll::Pending,
21417                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
21418                        this.is_terminated = true;
21419                        return std::task::Poll::Ready(None);
21420                    }
21421                    std::task::Poll::Ready(Err(e)) => {
21422                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
21423                            e.into(),
21424                        ))));
21425                    }
21426                }
21427
21428                // A message has been received from the channel
21429                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21430
21431                std::task::Poll::Ready(Some(match header.ordinal {
21432                    0x769e6fb17075c959 => {
21433                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
21434                        let mut req = fidl::new_empty!(
21435                            UsageReporterWatchRequest,
21436                            fidl::encoding::DefaultFuchsiaResourceDialect
21437                        );
21438                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
21439                        let control_handle =
21440                            UsageReporterControlHandle { inner: this.inner.clone() };
21441                        Ok(UsageReporterRequest::Watch {
21442                            usage: req.usage,
21443                            usage_watcher: req.usage_watcher,
21444
21445                            control_handle,
21446                        })
21447                    }
21448                    0x4a43c4c82f5d8ce8 => {
21449                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
21450                        let mut req = fidl::new_empty!(
21451                            UsageReporterWatch2Request,
21452                            fidl::encoding::DefaultFuchsiaResourceDialect
21453                        );
21454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
21455                        let control_handle =
21456                            UsageReporterControlHandle { inner: this.inner.clone() };
21457                        Ok(UsageReporterRequest::Watch2 {
21458                            usage: req.usage,
21459                            usage_watcher: req.usage_watcher,
21460
21461                            control_handle,
21462                        })
21463                    }
21464                    _ if header.tx_id == 0
21465                        && header
21466                            .dynamic_flags()
21467                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21468                    {
21469                        Ok(UsageReporterRequest::_UnknownMethod {
21470                            ordinal: header.ordinal,
21471                            control_handle: UsageReporterControlHandle {
21472                                inner: this.inner.clone(),
21473                            },
21474                            method_type: fidl::MethodType::OneWay,
21475                        })
21476                    }
21477                    _ if header
21478                        .dynamic_flags()
21479                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21480                    {
21481                        this.inner.send_framework_err(
21482                            fidl::encoding::FrameworkErr::UnknownMethod,
21483                            header.tx_id,
21484                            header.ordinal,
21485                            header.dynamic_flags(),
21486                            (bytes, handles),
21487                        )?;
21488                        Ok(UsageReporterRequest::_UnknownMethod {
21489                            ordinal: header.ordinal,
21490                            control_handle: UsageReporterControlHandle {
21491                                inner: this.inner.clone(),
21492                            },
21493                            method_type: fidl::MethodType::TwoWay,
21494                        })
21495                    }
21496                    _ => Err(fidl::Error::UnknownOrdinal {
21497                        ordinal: header.ordinal,
21498                        protocol_name:
21499                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21500                    }),
21501                }))
21502            },
21503        )
21504    }
21505}
21506
21507/// A protocol for setting up watchers of audio usages.
21508#[derive(Debug)]
21509pub enum UsageReporterRequest {
21510    Watch {
21511        usage: Usage,
21512        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21513        control_handle: UsageReporterControlHandle,
21514    },
21515    Watch2 {
21516        usage: Usage2,
21517        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21518        control_handle: UsageReporterControlHandle,
21519    },
21520    /// An interaction was received which does not match any known method.
21521    #[non_exhaustive]
21522    _UnknownMethod {
21523        /// Ordinal of the method that was called.
21524        ordinal: u64,
21525        control_handle: UsageReporterControlHandle,
21526        method_type: fidl::MethodType,
21527    },
21528}
21529
21530impl UsageReporterRequest {
21531    #[allow(irrefutable_let_patterns)]
21532    pub fn into_watch(
21533        self,
21534    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
21535    {
21536        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
21537            Some((usage, usage_watcher, control_handle))
21538        } else {
21539            None
21540        }
21541    }
21542
21543    #[allow(irrefutable_let_patterns)]
21544    pub fn into_watch2(
21545        self,
21546    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
21547    {
21548        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
21549            Some((usage, usage_watcher, control_handle))
21550        } else {
21551            None
21552        }
21553    }
21554
21555    /// Name of the method defined in FIDL
21556    pub fn method_name(&self) -> &'static str {
21557        match *self {
21558            UsageReporterRequest::Watch { .. } => "watch",
21559            UsageReporterRequest::Watch2 { .. } => "watch2",
21560            UsageReporterRequest::_UnknownMethod {
21561                method_type: fidl::MethodType::OneWay, ..
21562            } => "unknown one-way method",
21563            UsageReporterRequest::_UnknownMethod {
21564                method_type: fidl::MethodType::TwoWay, ..
21565            } => "unknown two-way method",
21566        }
21567    }
21568}
21569
21570#[derive(Debug, Clone)]
21571pub struct UsageReporterControlHandle {
21572    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21573}
21574
21575impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
21576    fn shutdown(&self) {
21577        self.inner.shutdown()
21578    }
21579
21580    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
21581        self.inner.shutdown_with_epitaph(status)
21582    }
21583
21584    fn is_closed(&self) -> bool {
21585        self.inner.channel().is_closed()
21586    }
21587    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
21588        self.inner.channel().on_closed()
21589    }
21590
21591    #[cfg(target_os = "fuchsia")]
21592    fn signal_peer(
21593        &self,
21594        clear_mask: zx::Signals,
21595        set_mask: zx::Signals,
21596    ) -> Result<(), zx_status::Status> {
21597        use fidl::Peered;
21598        self.inner.channel().signal_peer(clear_mask, set_mask)
21599    }
21600}
21601
21602impl UsageReporterControlHandle {}
21603
21604#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
21605pub struct UsageWatcherMarker;
21606
21607impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
21608    type Proxy = UsageWatcherProxy;
21609    type RequestStream = UsageWatcherRequestStream;
21610    #[cfg(target_os = "fuchsia")]
21611    type SynchronousProxy = UsageWatcherSynchronousProxy;
21612
21613    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
21614}
21615
21616pub trait UsageWatcherProxyInterface: Send + Sync {
21617    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
21618    fn r#on_state_changed(
21619        &self,
21620        usage: &Usage,
21621        state: &UsageState,
21622    ) -> Self::OnStateChangedResponseFut;
21623}
21624#[derive(Debug)]
21625#[cfg(target_os = "fuchsia")]
21626pub struct UsageWatcherSynchronousProxy {
21627    client: fidl::client::sync::Client,
21628}
21629
21630#[cfg(target_os = "fuchsia")]
21631impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
21632    type Proxy = UsageWatcherProxy;
21633    type Protocol = UsageWatcherMarker;
21634
21635    fn from_channel(inner: fidl::Channel) -> Self {
21636        Self::new(inner)
21637    }
21638
21639    fn into_channel(self) -> fidl::Channel {
21640        self.client.into_channel()
21641    }
21642
21643    fn as_channel(&self) -> &fidl::Channel {
21644        self.client.as_channel()
21645    }
21646}
21647
21648#[cfg(target_os = "fuchsia")]
21649impl UsageWatcherSynchronousProxy {
21650    pub fn new(channel: fidl::Channel) -> Self {
21651        Self { client: fidl::client::sync::Client::new(channel) }
21652    }
21653
21654    pub fn into_channel(self) -> fidl::Channel {
21655        self.client.into_channel()
21656    }
21657
21658    /// Waits until an event arrives and returns it. It is safe for other
21659    /// threads to make concurrent requests while waiting for an event.
21660    pub fn wait_for_event(
21661        &self,
21662        deadline: zx::MonotonicInstant,
21663    ) -> Result<UsageWatcherEvent, fidl::Error> {
21664        UsageWatcherEvent::decode(self.client.wait_for_event::<UsageWatcherMarker>(deadline)?)
21665    }
21666
21667    /// Called on first connection and whenever the watched usage changes. The provided
21668    /// usage will always be the bound usage; it is provided so that an implementation of
21669    /// this protocol may be bound to more than one usage.
21670    ///
21671    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
21672    /// events will eventually be disconnected.
21673    pub fn r#on_state_changed(
21674        &self,
21675        mut usage: &Usage,
21676        mut state: &UsageState,
21677        ___deadline: zx::MonotonicInstant,
21678    ) -> Result<(), fidl::Error> {
21679        let _response = self.client.send_query::<
21680            UsageWatcherOnStateChangedRequest,
21681            fidl::encoding::EmptyPayload,
21682            UsageWatcherMarker,
21683        >(
21684            (usage, state,),
21685            0x5b955c5768ec75c5,
21686            fidl::encoding::DynamicFlags::empty(),
21687            ___deadline,
21688        )?;
21689        Ok(_response)
21690    }
21691}
21692
21693#[cfg(target_os = "fuchsia")]
21694impl From<UsageWatcherSynchronousProxy> for zx::NullableHandle {
21695    fn from(value: UsageWatcherSynchronousProxy) -> Self {
21696        value.into_channel().into()
21697    }
21698}
21699
21700#[cfg(target_os = "fuchsia")]
21701impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
21702    fn from(value: fidl::Channel) -> Self {
21703        Self::new(value)
21704    }
21705}
21706
21707#[cfg(target_os = "fuchsia")]
21708impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
21709    type Protocol = UsageWatcherMarker;
21710
21711    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
21712        Self::new(value.into_channel())
21713    }
21714}
21715
21716#[derive(Debug, Clone)]
21717pub struct UsageWatcherProxy {
21718    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
21719}
21720
21721impl fidl::endpoints::Proxy for UsageWatcherProxy {
21722    type Protocol = UsageWatcherMarker;
21723
21724    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
21725        Self::new(inner)
21726    }
21727
21728    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
21729        self.client.into_channel().map_err(|client| Self { client })
21730    }
21731
21732    fn as_channel(&self) -> &::fidl::AsyncChannel {
21733        self.client.as_channel()
21734    }
21735}
21736
21737impl UsageWatcherProxy {
21738    /// Create a new Proxy for fuchsia.media/UsageWatcher.
21739    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
21740        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
21741        Self { client: fidl::client::Client::new(channel, protocol_name) }
21742    }
21743
21744    /// Get a Stream of events from the remote end of the protocol.
21745    ///
21746    /// # Panics
21747    ///
21748    /// Panics if the event stream was already taken.
21749    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
21750        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
21751    }
21752
21753    /// Called on first connection and whenever the watched usage changes. The provided
21754    /// usage will always be the bound usage; it is provided so that an implementation of
21755    /// this protocol may be bound to more than one usage.
21756    ///
21757    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
21758    /// events will eventually be disconnected.
21759    pub fn r#on_state_changed(
21760        &self,
21761        mut usage: &Usage,
21762        mut state: &UsageState,
21763    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
21764        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
21765    }
21766}
21767
21768impl UsageWatcherProxyInterface for UsageWatcherProxy {
21769    type OnStateChangedResponseFut =
21770        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
21771    fn r#on_state_changed(
21772        &self,
21773        mut usage: &Usage,
21774        mut state: &UsageState,
21775    ) -> Self::OnStateChangedResponseFut {
21776        fn _decode(
21777            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
21778        ) -> Result<(), fidl::Error> {
21779            let _response = fidl::client::decode_transaction_body::<
21780                fidl::encoding::EmptyPayload,
21781                fidl::encoding::DefaultFuchsiaResourceDialect,
21782                0x5b955c5768ec75c5,
21783            >(_buf?)?;
21784            Ok(_response)
21785        }
21786        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
21787            (usage, state),
21788            0x5b955c5768ec75c5,
21789            fidl::encoding::DynamicFlags::empty(),
21790            _decode,
21791        )
21792    }
21793}
21794
21795pub struct UsageWatcherEventStream {
21796    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
21797}
21798
21799impl std::marker::Unpin for UsageWatcherEventStream {}
21800
21801impl futures::stream::FusedStream for UsageWatcherEventStream {
21802    fn is_terminated(&self) -> bool {
21803        self.event_receiver.is_terminated()
21804    }
21805}
21806
21807impl futures::Stream for UsageWatcherEventStream {
21808    type Item = Result<UsageWatcherEvent, fidl::Error>;
21809
21810    fn poll_next(
21811        mut self: std::pin::Pin<&mut Self>,
21812        cx: &mut std::task::Context<'_>,
21813    ) -> std::task::Poll<Option<Self::Item>> {
21814        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
21815            &mut self.event_receiver,
21816            cx
21817        )?) {
21818            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
21819            None => std::task::Poll::Ready(None),
21820        }
21821    }
21822}
21823
21824#[derive(Debug)]
21825pub enum UsageWatcherEvent {}
21826
21827impl UsageWatcherEvent {
21828    /// Decodes a message buffer as a [`UsageWatcherEvent`].
21829    fn decode(
21830        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
21831    ) -> Result<UsageWatcherEvent, fidl::Error> {
21832        let (bytes, _handles) = buf.split_mut();
21833        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21834        debug_assert_eq!(tx_header.tx_id, 0);
21835        match tx_header.ordinal {
21836            _ => Err(fidl::Error::UnknownOrdinal {
21837                ordinal: tx_header.ordinal,
21838                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21839            }),
21840        }
21841    }
21842}
21843
21844/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
21845pub struct UsageWatcherRequestStream {
21846    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21847    is_terminated: bool,
21848}
21849
21850impl std::marker::Unpin for UsageWatcherRequestStream {}
21851
21852impl futures::stream::FusedStream for UsageWatcherRequestStream {
21853    fn is_terminated(&self) -> bool {
21854        self.is_terminated
21855    }
21856}
21857
21858impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
21859    type Protocol = UsageWatcherMarker;
21860    type ControlHandle = UsageWatcherControlHandle;
21861
21862    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
21863        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
21864    }
21865
21866    fn control_handle(&self) -> Self::ControlHandle {
21867        UsageWatcherControlHandle { inner: self.inner.clone() }
21868    }
21869
21870    fn into_inner(
21871        self,
21872    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
21873    {
21874        (self.inner, self.is_terminated)
21875    }
21876
21877    fn from_inner(
21878        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21879        is_terminated: bool,
21880    ) -> Self {
21881        Self { inner, is_terminated }
21882    }
21883}
21884
21885impl futures::Stream for UsageWatcherRequestStream {
21886    type Item = Result<UsageWatcherRequest, fidl::Error>;
21887
21888    fn poll_next(
21889        mut self: std::pin::Pin<&mut Self>,
21890        cx: &mut std::task::Context<'_>,
21891    ) -> std::task::Poll<Option<Self::Item>> {
21892        let this = &mut *self;
21893        if this.inner.check_shutdown(cx) {
21894            this.is_terminated = true;
21895            return std::task::Poll::Ready(None);
21896        }
21897        if this.is_terminated {
21898            panic!("polled UsageWatcherRequestStream after completion");
21899        }
21900        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
21901            |bytes, handles| {
21902                match this.inner.channel().read_etc(cx, bytes, handles) {
21903                    std::task::Poll::Ready(Ok(())) => {}
21904                    std::task::Poll::Pending => return std::task::Poll::Pending,
21905                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
21906                        this.is_terminated = true;
21907                        return std::task::Poll::Ready(None);
21908                    }
21909                    std::task::Poll::Ready(Err(e)) => {
21910                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
21911                            e.into(),
21912                        ))));
21913                    }
21914                }
21915
21916                // A message has been received from the channel
21917                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21918
21919                std::task::Poll::Ready(Some(match header.ordinal {
21920                    0x5b955c5768ec75c5 => {
21921                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
21922                        let mut req = fidl::new_empty!(
21923                            UsageWatcherOnStateChangedRequest,
21924                            fidl::encoding::DefaultFuchsiaResourceDialect
21925                        );
21926                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
21927                        let control_handle =
21928                            UsageWatcherControlHandle { inner: this.inner.clone() };
21929                        Ok(UsageWatcherRequest::OnStateChanged {
21930                            usage: req.usage,
21931                            state: req.state,
21932
21933                            responder: UsageWatcherOnStateChangedResponder {
21934                                control_handle: std::mem::ManuallyDrop::new(control_handle),
21935                                tx_id: header.tx_id,
21936                            },
21937                        })
21938                    }
21939                    _ => Err(fidl::Error::UnknownOrdinal {
21940                        ordinal: header.ordinal,
21941                        protocol_name:
21942                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21943                    }),
21944                }))
21945            },
21946        )
21947    }
21948}
21949
21950/// A protocol for listening to changes to the policy state of an audio usage.
21951///
21952/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
21953#[derive(Debug)]
21954pub enum UsageWatcherRequest {
21955    /// Called on first connection and whenever the watched usage changes. The provided
21956    /// usage will always be the bound usage; it is provided so that an implementation of
21957    /// this protocol may be bound to more than one usage.
21958    ///
21959    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
21960    /// events will eventually be disconnected.
21961    OnStateChanged {
21962        usage: Usage,
21963        state: UsageState,
21964        responder: UsageWatcherOnStateChangedResponder,
21965    },
21966}
21967
21968impl UsageWatcherRequest {
21969    #[allow(irrefutable_let_patterns)]
21970    pub fn into_on_state_changed(
21971        self,
21972    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
21973        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
21974            Some((usage, state, responder))
21975        } else {
21976            None
21977        }
21978    }
21979
21980    /// Name of the method defined in FIDL
21981    pub fn method_name(&self) -> &'static str {
21982        match *self {
21983            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
21984        }
21985    }
21986}
21987
21988#[derive(Debug, Clone)]
21989pub struct UsageWatcherControlHandle {
21990    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21991}
21992
21993impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
21994    fn shutdown(&self) {
21995        self.inner.shutdown()
21996    }
21997
21998    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
21999        self.inner.shutdown_with_epitaph(status)
22000    }
22001
22002    fn is_closed(&self) -> bool {
22003        self.inner.channel().is_closed()
22004    }
22005    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
22006        self.inner.channel().on_closed()
22007    }
22008
22009    #[cfg(target_os = "fuchsia")]
22010    fn signal_peer(
22011        &self,
22012        clear_mask: zx::Signals,
22013        set_mask: zx::Signals,
22014    ) -> Result<(), zx_status::Status> {
22015        use fidl::Peered;
22016        self.inner.channel().signal_peer(clear_mask, set_mask)
22017    }
22018}
22019
22020impl UsageWatcherControlHandle {}
22021
22022#[must_use = "FIDL methods require a response to be sent"]
22023#[derive(Debug)]
22024pub struct UsageWatcherOnStateChangedResponder {
22025    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
22026    tx_id: u32,
22027}
22028
22029/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
22030/// if the responder is dropped without sending a response, so that the client
22031/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
22032impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
22033    fn drop(&mut self) {
22034        self.control_handle.shutdown();
22035        // Safety: drops once, never accessed again
22036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22037    }
22038}
22039
22040impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
22041    type ControlHandle = UsageWatcherControlHandle;
22042
22043    fn control_handle(&self) -> &UsageWatcherControlHandle {
22044        &self.control_handle
22045    }
22046
22047    fn drop_without_shutdown(mut self) {
22048        // Safety: drops once, never accessed again due to mem::forget
22049        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22050        // Prevent Drop from running (which would shut down the channel)
22051        std::mem::forget(self);
22052    }
22053}
22054
22055impl UsageWatcherOnStateChangedResponder {
22056    /// Sends a response to the FIDL transaction.
22057    ///
22058    /// Sets the channel to shutdown if an error occurs.
22059    pub fn send(self) -> Result<(), fidl::Error> {
22060        let _result = self.send_raw();
22061        if _result.is_err() {
22062            self.control_handle.shutdown();
22063        }
22064        self.drop_without_shutdown();
22065        _result
22066    }
22067
22068    /// Similar to "send" but does not shutdown the channel if an error occurs.
22069    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
22070        let _result = self.send_raw();
22071        self.drop_without_shutdown();
22072        _result
22073    }
22074
22075    fn send_raw(&self) -> Result<(), fidl::Error> {
22076        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
22077            (),
22078            self.tx_id,
22079            0x5b955c5768ec75c5,
22080            fidl::encoding::DynamicFlags::empty(),
22081        )
22082    }
22083}
22084
22085#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22086pub struct UsageWatcher2Marker;
22087
22088impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
22089    type Proxy = UsageWatcher2Proxy;
22090    type RequestStream = UsageWatcher2RequestStream;
22091    #[cfg(target_os = "fuchsia")]
22092    type SynchronousProxy = UsageWatcher2SynchronousProxy;
22093
22094    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
22095}
22096
22097pub trait UsageWatcher2ProxyInterface: Send + Sync {
22098    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
22099    fn r#on_state_changed(
22100        &self,
22101        usage: &Usage2,
22102        state: &UsageState,
22103    ) -> Self::OnStateChangedResponseFut;
22104}
22105#[derive(Debug)]
22106#[cfg(target_os = "fuchsia")]
22107pub struct UsageWatcher2SynchronousProxy {
22108    client: fidl::client::sync::Client,
22109}
22110
22111#[cfg(target_os = "fuchsia")]
22112impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
22113    type Proxy = UsageWatcher2Proxy;
22114    type Protocol = UsageWatcher2Marker;
22115
22116    fn from_channel(inner: fidl::Channel) -> Self {
22117        Self::new(inner)
22118    }
22119
22120    fn into_channel(self) -> fidl::Channel {
22121        self.client.into_channel()
22122    }
22123
22124    fn as_channel(&self) -> &fidl::Channel {
22125        self.client.as_channel()
22126    }
22127}
22128
22129#[cfg(target_os = "fuchsia")]
22130impl UsageWatcher2SynchronousProxy {
22131    pub fn new(channel: fidl::Channel) -> Self {
22132        Self { client: fidl::client::sync::Client::new(channel) }
22133    }
22134
22135    pub fn into_channel(self) -> fidl::Channel {
22136        self.client.into_channel()
22137    }
22138
22139    /// Waits until an event arrives and returns it. It is safe for other
22140    /// threads to make concurrent requests while waiting for an event.
22141    pub fn wait_for_event(
22142        &self,
22143        deadline: zx::MonotonicInstant,
22144    ) -> Result<UsageWatcher2Event, fidl::Error> {
22145        UsageWatcher2Event::decode(self.client.wait_for_event::<UsageWatcher2Marker>(deadline)?)
22146    }
22147
22148    /// Called on first connection and whenever the watched usage changes. The provided
22149    /// usage will always be the bound usage; it is provided so that an implementation of
22150    /// this protocol may be bound to more than one usage.
22151    ///
22152    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22153    /// events will eventually be disconnected.
22154    pub fn r#on_state_changed(
22155        &self,
22156        mut usage: &Usage2,
22157        mut state: &UsageState,
22158        ___deadline: zx::MonotonicInstant,
22159    ) -> Result<(), fidl::Error> {
22160        let _response = self.client.send_query::<
22161            UsageWatcher2OnStateChangedRequest,
22162            fidl::encoding::EmptyPayload,
22163            UsageWatcher2Marker,
22164        >(
22165            (usage, state,),
22166            0xca31a8b13c324d4,
22167            fidl::encoding::DynamicFlags::empty(),
22168            ___deadline,
22169        )?;
22170        Ok(_response)
22171    }
22172}
22173
22174#[cfg(target_os = "fuchsia")]
22175impl From<UsageWatcher2SynchronousProxy> for zx::NullableHandle {
22176    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
22177        value.into_channel().into()
22178    }
22179}
22180
22181#[cfg(target_os = "fuchsia")]
22182impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
22183    fn from(value: fidl::Channel) -> Self {
22184        Self::new(value)
22185    }
22186}
22187
22188#[cfg(target_os = "fuchsia")]
22189impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
22190    type Protocol = UsageWatcher2Marker;
22191
22192    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
22193        Self::new(value.into_channel())
22194    }
22195}
22196
22197#[derive(Debug, Clone)]
22198pub struct UsageWatcher2Proxy {
22199    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
22200}
22201
22202impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
22203    type Protocol = UsageWatcher2Marker;
22204
22205    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
22206        Self::new(inner)
22207    }
22208
22209    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
22210        self.client.into_channel().map_err(|client| Self { client })
22211    }
22212
22213    fn as_channel(&self) -> &::fidl::AsyncChannel {
22214        self.client.as_channel()
22215    }
22216}
22217
22218impl UsageWatcher2Proxy {
22219    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
22220    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
22221        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
22222        Self { client: fidl::client::Client::new(channel, protocol_name) }
22223    }
22224
22225    /// Get a Stream of events from the remote end of the protocol.
22226    ///
22227    /// # Panics
22228    ///
22229    /// Panics if the event stream was already taken.
22230    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
22231        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
22232    }
22233
22234    /// Called on first connection and whenever the watched usage changes. The provided
22235    /// usage will always be the bound usage; it is provided so that an implementation of
22236    /// this protocol may be bound to more than one usage.
22237    ///
22238    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22239    /// events will eventually be disconnected.
22240    pub fn r#on_state_changed(
22241        &self,
22242        mut usage: &Usage2,
22243        mut state: &UsageState,
22244    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
22245        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
22246    }
22247}
22248
22249impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
22250    type OnStateChangedResponseFut =
22251        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
22252    fn r#on_state_changed(
22253        &self,
22254        mut usage: &Usage2,
22255        mut state: &UsageState,
22256    ) -> Self::OnStateChangedResponseFut {
22257        fn _decode(
22258            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
22259        ) -> Result<(), fidl::Error> {
22260            let _response = fidl::client::decode_transaction_body::<
22261                fidl::encoding::EmptyPayload,
22262                fidl::encoding::DefaultFuchsiaResourceDialect,
22263                0xca31a8b13c324d4,
22264            >(_buf?)?;
22265            Ok(_response)
22266        }
22267        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
22268            (usage, state),
22269            0xca31a8b13c324d4,
22270            fidl::encoding::DynamicFlags::empty(),
22271            _decode,
22272        )
22273    }
22274}
22275
22276pub struct UsageWatcher2EventStream {
22277    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
22278}
22279
22280impl std::marker::Unpin for UsageWatcher2EventStream {}
22281
22282impl futures::stream::FusedStream for UsageWatcher2EventStream {
22283    fn is_terminated(&self) -> bool {
22284        self.event_receiver.is_terminated()
22285    }
22286}
22287
22288impl futures::Stream for UsageWatcher2EventStream {
22289    type Item = Result<UsageWatcher2Event, fidl::Error>;
22290
22291    fn poll_next(
22292        mut self: std::pin::Pin<&mut Self>,
22293        cx: &mut std::task::Context<'_>,
22294    ) -> std::task::Poll<Option<Self::Item>> {
22295        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
22296            &mut self.event_receiver,
22297            cx
22298        )?) {
22299            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
22300            None => std::task::Poll::Ready(None),
22301        }
22302    }
22303}
22304
22305#[derive(Debug)]
22306pub enum UsageWatcher2Event {}
22307
22308impl UsageWatcher2Event {
22309    /// Decodes a message buffer as a [`UsageWatcher2Event`].
22310    fn decode(
22311        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
22312    ) -> Result<UsageWatcher2Event, fidl::Error> {
22313        let (bytes, _handles) = buf.split_mut();
22314        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
22315        debug_assert_eq!(tx_header.tx_id, 0);
22316        match tx_header.ordinal {
22317            _ => Err(fidl::Error::UnknownOrdinal {
22318                ordinal: tx_header.ordinal,
22319                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
22320            }),
22321        }
22322    }
22323}
22324
22325/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
22326pub struct UsageWatcher2RequestStream {
22327    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22328    is_terminated: bool,
22329}
22330
22331impl std::marker::Unpin for UsageWatcher2RequestStream {}
22332
22333impl futures::stream::FusedStream for UsageWatcher2RequestStream {
22334    fn is_terminated(&self) -> bool {
22335        self.is_terminated
22336    }
22337}
22338
22339impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
22340    type Protocol = UsageWatcher2Marker;
22341    type ControlHandle = UsageWatcher2ControlHandle;
22342
22343    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
22344        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
22345    }
22346
22347    fn control_handle(&self) -> Self::ControlHandle {
22348        UsageWatcher2ControlHandle { inner: self.inner.clone() }
22349    }
22350
22351    fn into_inner(
22352        self,
22353    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
22354    {
22355        (self.inner, self.is_terminated)
22356    }
22357
22358    fn from_inner(
22359        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22360        is_terminated: bool,
22361    ) -> Self {
22362        Self { inner, is_terminated }
22363    }
22364}
22365
22366impl futures::Stream for UsageWatcher2RequestStream {
22367    type Item = Result<UsageWatcher2Request, fidl::Error>;
22368
22369    fn poll_next(
22370        mut self: std::pin::Pin<&mut Self>,
22371        cx: &mut std::task::Context<'_>,
22372    ) -> std::task::Poll<Option<Self::Item>> {
22373        let this = &mut *self;
22374        if this.inner.check_shutdown(cx) {
22375            this.is_terminated = true;
22376            return std::task::Poll::Ready(None);
22377        }
22378        if this.is_terminated {
22379            panic!("polled UsageWatcher2RequestStream after completion");
22380        }
22381        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
22382            |bytes, handles| {
22383                match this.inner.channel().read_etc(cx, bytes, handles) {
22384                    std::task::Poll::Ready(Ok(())) => {}
22385                    std::task::Poll::Pending => return std::task::Poll::Pending,
22386                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
22387                        this.is_terminated = true;
22388                        return std::task::Poll::Ready(None);
22389                    }
22390                    std::task::Poll::Ready(Err(e)) => {
22391                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
22392                            e.into(),
22393                        ))));
22394                    }
22395                }
22396
22397                // A message has been received from the channel
22398                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
22399
22400                std::task::Poll::Ready(Some(match header.ordinal {
22401                    0xca31a8b13c324d4 => {
22402                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
22403                        let mut req = fidl::new_empty!(
22404                            UsageWatcher2OnStateChangedRequest,
22405                            fidl::encoding::DefaultFuchsiaResourceDialect
22406                        );
22407                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
22408                        let control_handle =
22409                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
22410                        Ok(UsageWatcher2Request::OnStateChanged {
22411                            usage: req.usage,
22412                            state: req.state,
22413
22414                            responder: UsageWatcher2OnStateChangedResponder {
22415                                control_handle: std::mem::ManuallyDrop::new(control_handle),
22416                                tx_id: header.tx_id,
22417                            },
22418                        })
22419                    }
22420                    _ => Err(fidl::Error::UnknownOrdinal {
22421                        ordinal: header.ordinal,
22422                        protocol_name:
22423                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
22424                    }),
22425                }))
22426            },
22427        )
22428    }
22429}
22430
22431#[derive(Debug)]
22432pub enum UsageWatcher2Request {
22433    /// Called on first connection and whenever the watched usage changes. The provided
22434    /// usage will always be the bound usage; it is provided so that an implementation of
22435    /// this protocol may be bound to more than one usage.
22436    ///
22437    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22438    /// events will eventually be disconnected.
22439    OnStateChanged {
22440        usage: Usage2,
22441        state: UsageState,
22442        responder: UsageWatcher2OnStateChangedResponder,
22443    },
22444}
22445
22446impl UsageWatcher2Request {
22447    #[allow(irrefutable_let_patterns)]
22448    pub fn into_on_state_changed(
22449        self,
22450    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
22451        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
22452            Some((usage, state, responder))
22453        } else {
22454            None
22455        }
22456    }
22457
22458    /// Name of the method defined in FIDL
22459    pub fn method_name(&self) -> &'static str {
22460        match *self {
22461            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
22462        }
22463    }
22464}
22465
22466#[derive(Debug, Clone)]
22467pub struct UsageWatcher2ControlHandle {
22468    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22469}
22470
22471impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
22472    fn shutdown(&self) {
22473        self.inner.shutdown()
22474    }
22475
22476    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
22477        self.inner.shutdown_with_epitaph(status)
22478    }
22479
22480    fn is_closed(&self) -> bool {
22481        self.inner.channel().is_closed()
22482    }
22483    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
22484        self.inner.channel().on_closed()
22485    }
22486
22487    #[cfg(target_os = "fuchsia")]
22488    fn signal_peer(
22489        &self,
22490        clear_mask: zx::Signals,
22491        set_mask: zx::Signals,
22492    ) -> Result<(), zx_status::Status> {
22493        use fidl::Peered;
22494        self.inner.channel().signal_peer(clear_mask, set_mask)
22495    }
22496}
22497
22498impl UsageWatcher2ControlHandle {}
22499
22500#[must_use = "FIDL methods require a response to be sent"]
22501#[derive(Debug)]
22502pub struct UsageWatcher2OnStateChangedResponder {
22503    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
22504    tx_id: u32,
22505}
22506
22507/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
22508/// if the responder is dropped without sending a response, so that the client
22509/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
22510impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
22511    fn drop(&mut self) {
22512        self.control_handle.shutdown();
22513        // Safety: drops once, never accessed again
22514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22515    }
22516}
22517
22518impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
22519    type ControlHandle = UsageWatcher2ControlHandle;
22520
22521    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
22522        &self.control_handle
22523    }
22524
22525    fn drop_without_shutdown(mut self) {
22526        // Safety: drops once, never accessed again due to mem::forget
22527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22528        // Prevent Drop from running (which would shut down the channel)
22529        std::mem::forget(self);
22530    }
22531}
22532
22533impl UsageWatcher2OnStateChangedResponder {
22534    /// Sends a response to the FIDL transaction.
22535    ///
22536    /// Sets the channel to shutdown if an error occurs.
22537    pub fn send(self) -> Result<(), fidl::Error> {
22538        let _result = self.send_raw();
22539        if _result.is_err() {
22540            self.control_handle.shutdown();
22541        }
22542        self.drop_without_shutdown();
22543        _result
22544    }
22545
22546    /// Similar to "send" but does not shutdown the channel if an error occurs.
22547    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
22548        let _result = self.send_raw();
22549        self.drop_without_shutdown();
22550        _result
22551    }
22552
22553    fn send_raw(&self) -> Result<(), fidl::Error> {
22554        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
22555            (),
22556            self.tx_id,
22557            0xca31a8b13c324d4,
22558            fidl::encoding::DynamicFlags::empty(),
22559        )
22560    }
22561}
22562
22563mod internal {
22564    use super::*;
22565
22566    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
22567        type Borrowed<'a> = &'a mut Self;
22568        fn take_or_borrow<'a>(
22569            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22570        ) -> Self::Borrowed<'a> {
22571            value
22572        }
22573    }
22574
22575    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
22576        type Owned = Self;
22577
22578        #[inline(always)]
22579        fn inline_align(_context: fidl::encoding::Context) -> usize {
22580            4
22581        }
22582
22583        #[inline(always)]
22584        fn inline_size(_context: fidl::encoding::Context) -> usize {
22585            4
22586        }
22587    }
22588
22589    unsafe impl
22590        fidl::encoding::Encode<
22591            AudioCapturerBindGainControlRequest,
22592            fidl::encoding::DefaultFuchsiaResourceDialect,
22593        > for &mut AudioCapturerBindGainControlRequest
22594    {
22595        #[inline]
22596        unsafe fn encode(
22597            self,
22598            encoder: &mut fidl::encoding::Encoder<
22599                '_,
22600                fidl::encoding::DefaultFuchsiaResourceDialect,
22601            >,
22602            offset: usize,
22603            _depth: fidl::encoding::Depth,
22604        ) -> fidl::Result<()> {
22605            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
22606            // Delegate to tuple encoding.
22607            fidl::encoding::Encode::<
22608                AudioCapturerBindGainControlRequest,
22609                fidl::encoding::DefaultFuchsiaResourceDialect,
22610            >::encode(
22611                (<fidl::encoding::Endpoint<
22612                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22613                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22614                    &mut self.gain_control_request,
22615                ),),
22616                encoder,
22617                offset,
22618                _depth,
22619            )
22620        }
22621    }
22622    unsafe impl<
22623        T0: fidl::encoding::Encode<
22624                fidl::encoding::Endpoint<
22625                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22626                >,
22627                fidl::encoding::DefaultFuchsiaResourceDialect,
22628            >,
22629    >
22630        fidl::encoding::Encode<
22631            AudioCapturerBindGainControlRequest,
22632            fidl::encoding::DefaultFuchsiaResourceDialect,
22633        > for (T0,)
22634    {
22635        #[inline]
22636        unsafe fn encode(
22637            self,
22638            encoder: &mut fidl::encoding::Encoder<
22639                '_,
22640                fidl::encoding::DefaultFuchsiaResourceDialect,
22641            >,
22642            offset: usize,
22643            depth: fidl::encoding::Depth,
22644        ) -> fidl::Result<()> {
22645            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
22646            // Zero out padding regions. There's no need to apply masks
22647            // because the unmasked parts will be overwritten by fields.
22648            // Write the fields.
22649            self.0.encode(encoder, offset + 0, depth)?;
22650            Ok(())
22651        }
22652    }
22653
22654    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22655        for AudioCapturerBindGainControlRequest
22656    {
22657        #[inline(always)]
22658        fn new_empty() -> Self {
22659            Self {
22660                gain_control_request: fidl::new_empty!(
22661                    fidl::encoding::Endpoint<
22662                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22663                    >,
22664                    fidl::encoding::DefaultFuchsiaResourceDialect
22665                ),
22666            }
22667        }
22668
22669        #[inline]
22670        unsafe fn decode(
22671            &mut self,
22672            decoder: &mut fidl::encoding::Decoder<
22673                '_,
22674                fidl::encoding::DefaultFuchsiaResourceDialect,
22675            >,
22676            offset: usize,
22677            _depth: fidl::encoding::Depth,
22678        ) -> fidl::Result<()> {
22679            decoder.debug_check_bounds::<Self>(offset);
22680            // Verify that padding bytes are zero.
22681            fidl::decode!(
22682                fidl::encoding::Endpoint<
22683                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22684                >,
22685                fidl::encoding::DefaultFuchsiaResourceDialect,
22686                &mut self.gain_control_request,
22687                decoder,
22688                offset + 0,
22689                _depth
22690            )?;
22691            Ok(())
22692        }
22693    }
22694
22695    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
22696        type Borrowed<'a> = &'a mut Self;
22697        fn take_or_borrow<'a>(
22698            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22699        ) -> Self::Borrowed<'a> {
22700            value
22701        }
22702    }
22703
22704    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
22705        type Owned = Self;
22706
22707        #[inline(always)]
22708        fn inline_align(_context: fidl::encoding::Context) -> usize {
22709            4
22710        }
22711
22712        #[inline(always)]
22713        fn inline_size(_context: fidl::encoding::Context) -> usize {
22714            4
22715        }
22716    }
22717
22718    unsafe impl
22719        fidl::encoding::Encode<
22720            AudioCapturerGetReferenceClockResponse,
22721            fidl::encoding::DefaultFuchsiaResourceDialect,
22722        > for &mut AudioCapturerGetReferenceClockResponse
22723    {
22724        #[inline]
22725        unsafe fn encode(
22726            self,
22727            encoder: &mut fidl::encoding::Encoder<
22728                '_,
22729                fidl::encoding::DefaultFuchsiaResourceDialect,
22730            >,
22731            offset: usize,
22732            _depth: fidl::encoding::Depth,
22733        ) -> fidl::Result<()> {
22734            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
22735            // Delegate to tuple encoding.
22736            fidl::encoding::Encode::<
22737                AudioCapturerGetReferenceClockResponse,
22738                fidl::encoding::DefaultFuchsiaResourceDialect,
22739            >::encode(
22740                (<fidl::encoding::HandleType<
22741                    fidl::Clock,
22742                    { fidl::ObjectType::CLOCK.into_raw() },
22743                    2147483648,
22744                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22745                    &mut self.reference_clock,
22746                ),),
22747                encoder,
22748                offset,
22749                _depth,
22750            )
22751        }
22752    }
22753    unsafe impl<
22754        T0: fidl::encoding::Encode<
22755                fidl::encoding::HandleType<
22756                    fidl::Clock,
22757                    { fidl::ObjectType::CLOCK.into_raw() },
22758                    2147483648,
22759                >,
22760                fidl::encoding::DefaultFuchsiaResourceDialect,
22761            >,
22762    >
22763        fidl::encoding::Encode<
22764            AudioCapturerGetReferenceClockResponse,
22765            fidl::encoding::DefaultFuchsiaResourceDialect,
22766        > for (T0,)
22767    {
22768        #[inline]
22769        unsafe fn encode(
22770            self,
22771            encoder: &mut fidl::encoding::Encoder<
22772                '_,
22773                fidl::encoding::DefaultFuchsiaResourceDialect,
22774            >,
22775            offset: usize,
22776            depth: fidl::encoding::Depth,
22777        ) -> fidl::Result<()> {
22778            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
22779            // Zero out padding regions. There's no need to apply masks
22780            // because the unmasked parts will be overwritten by fields.
22781            // Write the fields.
22782            self.0.encode(encoder, offset + 0, depth)?;
22783            Ok(())
22784        }
22785    }
22786
22787    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22788        for AudioCapturerGetReferenceClockResponse
22789    {
22790        #[inline(always)]
22791        fn new_empty() -> Self {
22792            Self {
22793                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22794            }
22795        }
22796
22797        #[inline]
22798        unsafe fn decode(
22799            &mut self,
22800            decoder: &mut fidl::encoding::Decoder<
22801                '_,
22802                fidl::encoding::DefaultFuchsiaResourceDialect,
22803            >,
22804            offset: usize,
22805            _depth: fidl::encoding::Depth,
22806        ) -> fidl::Result<()> {
22807            decoder.debug_check_bounds::<Self>(offset);
22808            // Verify that padding bytes are zero.
22809            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22810            Ok(())
22811        }
22812    }
22813
22814    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
22815        type Borrowed<'a> = &'a mut Self;
22816        fn take_or_borrow<'a>(
22817            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22818        ) -> Self::Borrowed<'a> {
22819            value
22820        }
22821    }
22822
22823    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
22824        type Owned = Self;
22825
22826        #[inline(always)]
22827        fn inline_align(_context: fidl::encoding::Context) -> usize {
22828            4
22829        }
22830
22831        #[inline(always)]
22832        fn inline_size(_context: fidl::encoding::Context) -> usize {
22833            4
22834        }
22835    }
22836
22837    unsafe impl
22838        fidl::encoding::Encode<
22839            AudioCapturerSetReferenceClockRequest,
22840            fidl::encoding::DefaultFuchsiaResourceDialect,
22841        > for &mut AudioCapturerSetReferenceClockRequest
22842    {
22843        #[inline]
22844        unsafe fn encode(
22845            self,
22846            encoder: &mut fidl::encoding::Encoder<
22847                '_,
22848                fidl::encoding::DefaultFuchsiaResourceDialect,
22849            >,
22850            offset: usize,
22851            _depth: fidl::encoding::Depth,
22852        ) -> fidl::Result<()> {
22853            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
22854            // Delegate to tuple encoding.
22855            fidl::encoding::Encode::<
22856                AudioCapturerSetReferenceClockRequest,
22857                fidl::encoding::DefaultFuchsiaResourceDialect,
22858            >::encode(
22859                (<fidl::encoding::Optional<
22860                    fidl::encoding::HandleType<
22861                        fidl::Clock,
22862                        { fidl::ObjectType::CLOCK.into_raw() },
22863                        2147483648,
22864                    >,
22865                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22866                    &mut self.reference_clock,
22867                ),),
22868                encoder,
22869                offset,
22870                _depth,
22871            )
22872        }
22873    }
22874    unsafe impl<
22875        T0: fidl::encoding::Encode<
22876                fidl::encoding::Optional<
22877                    fidl::encoding::HandleType<
22878                        fidl::Clock,
22879                        { fidl::ObjectType::CLOCK.into_raw() },
22880                        2147483648,
22881                    >,
22882                >,
22883                fidl::encoding::DefaultFuchsiaResourceDialect,
22884            >,
22885    >
22886        fidl::encoding::Encode<
22887            AudioCapturerSetReferenceClockRequest,
22888            fidl::encoding::DefaultFuchsiaResourceDialect,
22889        > for (T0,)
22890    {
22891        #[inline]
22892        unsafe fn encode(
22893            self,
22894            encoder: &mut fidl::encoding::Encoder<
22895                '_,
22896                fidl::encoding::DefaultFuchsiaResourceDialect,
22897            >,
22898            offset: usize,
22899            depth: fidl::encoding::Depth,
22900        ) -> fidl::Result<()> {
22901            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
22902            // Zero out padding regions. There's no need to apply masks
22903            // because the unmasked parts will be overwritten by fields.
22904            // Write the fields.
22905            self.0.encode(encoder, offset + 0, depth)?;
22906            Ok(())
22907        }
22908    }
22909
22910    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22911        for AudioCapturerSetReferenceClockRequest
22912    {
22913        #[inline(always)]
22914        fn new_empty() -> Self {
22915            Self {
22916                reference_clock: fidl::new_empty!(
22917                    fidl::encoding::Optional<
22918                        fidl::encoding::HandleType<
22919                            fidl::Clock,
22920                            { fidl::ObjectType::CLOCK.into_raw() },
22921                            2147483648,
22922                        >,
22923                    >,
22924                    fidl::encoding::DefaultFuchsiaResourceDialect
22925                ),
22926            }
22927        }
22928
22929        #[inline]
22930        unsafe fn decode(
22931            &mut self,
22932            decoder: &mut fidl::encoding::Decoder<
22933                '_,
22934                fidl::encoding::DefaultFuchsiaResourceDialect,
22935            >,
22936            offset: usize,
22937            _depth: fidl::encoding::Depth,
22938        ) -> fidl::Result<()> {
22939            decoder.debug_check_bounds::<Self>(offset);
22940            // Verify that padding bytes are zero.
22941            fidl::decode!(
22942                fidl::encoding::Optional<
22943                    fidl::encoding::HandleType<
22944                        fidl::Clock,
22945                        { fidl::ObjectType::CLOCK.into_raw() },
22946                        2147483648,
22947                    >,
22948                >,
22949                fidl::encoding::DefaultFuchsiaResourceDialect,
22950                &mut self.reference_clock,
22951                decoder,
22952                offset + 0,
22953                _depth
22954            )?;
22955            Ok(())
22956        }
22957    }
22958
22959    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
22960        type Borrowed<'a> = &'a mut Self;
22961        fn take_or_borrow<'a>(
22962            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22963        ) -> Self::Borrowed<'a> {
22964            value
22965        }
22966    }
22967
22968    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
22969        type Owned = Self;
22970
22971        #[inline(always)]
22972        fn inline_align(_context: fidl::encoding::Context) -> usize {
22973            4
22974        }
22975
22976        #[inline(always)]
22977        fn inline_size(_context: fidl::encoding::Context) -> usize {
22978            4
22979        }
22980    }
22981
22982    unsafe impl
22983        fidl::encoding::Encode<
22984            AudioConsumerBindVolumeControlRequest,
22985            fidl::encoding::DefaultFuchsiaResourceDialect,
22986        > for &mut AudioConsumerBindVolumeControlRequest
22987    {
22988        #[inline]
22989        unsafe fn encode(
22990            self,
22991            encoder: &mut fidl::encoding::Encoder<
22992                '_,
22993                fidl::encoding::DefaultFuchsiaResourceDialect,
22994            >,
22995            offset: usize,
22996            _depth: fidl::encoding::Depth,
22997        ) -> fidl::Result<()> {
22998            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
22999            // Delegate to tuple encoding.
23000            fidl::encoding::Encode::<
23001                AudioConsumerBindVolumeControlRequest,
23002                fidl::encoding::DefaultFuchsiaResourceDialect,
23003            >::encode(
23004                (<fidl::encoding::Endpoint<
23005                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23006                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23007                    &mut self.volume_control_request,
23008                ),),
23009                encoder,
23010                offset,
23011                _depth,
23012            )
23013        }
23014    }
23015    unsafe impl<
23016        T0: fidl::encoding::Encode<
23017                fidl::encoding::Endpoint<
23018                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23019                >,
23020                fidl::encoding::DefaultFuchsiaResourceDialect,
23021            >,
23022    >
23023        fidl::encoding::Encode<
23024            AudioConsumerBindVolumeControlRequest,
23025            fidl::encoding::DefaultFuchsiaResourceDialect,
23026        > for (T0,)
23027    {
23028        #[inline]
23029        unsafe fn encode(
23030            self,
23031            encoder: &mut fidl::encoding::Encoder<
23032                '_,
23033                fidl::encoding::DefaultFuchsiaResourceDialect,
23034            >,
23035            offset: usize,
23036            depth: fidl::encoding::Depth,
23037        ) -> fidl::Result<()> {
23038            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
23039            // Zero out padding regions. There's no need to apply masks
23040            // because the unmasked parts will be overwritten by fields.
23041            // Write the fields.
23042            self.0.encode(encoder, offset + 0, depth)?;
23043            Ok(())
23044        }
23045    }
23046
23047    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23048        for AudioConsumerBindVolumeControlRequest
23049    {
23050        #[inline(always)]
23051        fn new_empty() -> Self {
23052            Self {
23053                volume_control_request: fidl::new_empty!(
23054                    fidl::encoding::Endpoint<
23055                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23056                    >,
23057                    fidl::encoding::DefaultFuchsiaResourceDialect
23058                ),
23059            }
23060        }
23061
23062        #[inline]
23063        unsafe fn decode(
23064            &mut self,
23065            decoder: &mut fidl::encoding::Decoder<
23066                '_,
23067                fidl::encoding::DefaultFuchsiaResourceDialect,
23068            >,
23069            offset: usize,
23070            _depth: fidl::encoding::Depth,
23071        ) -> fidl::Result<()> {
23072            decoder.debug_check_bounds::<Self>(offset);
23073            // Verify that padding bytes are zero.
23074            fidl::decode!(
23075                fidl::encoding::Endpoint<
23076                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23077                >,
23078                fidl::encoding::DefaultFuchsiaResourceDialect,
23079                &mut self.volume_control_request,
23080                decoder,
23081                offset + 0,
23082                _depth
23083            )?;
23084            Ok(())
23085        }
23086    }
23087
23088    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
23089        type Borrowed<'a> = &'a mut Self;
23090        fn take_or_borrow<'a>(
23091            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23092        ) -> Self::Borrowed<'a> {
23093            value
23094        }
23095    }
23096
23097    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
23098        type Owned = Self;
23099
23100        #[inline(always)]
23101        fn inline_align(_context: fidl::encoding::Context) -> usize {
23102            8
23103        }
23104
23105        #[inline(always)]
23106        fn inline_size(_context: fidl::encoding::Context) -> usize {
23107            48
23108        }
23109    }
23110
23111    unsafe impl
23112        fidl::encoding::Encode<
23113            AudioConsumerCreateStreamSinkRequest,
23114            fidl::encoding::DefaultFuchsiaResourceDialect,
23115        > for &mut AudioConsumerCreateStreamSinkRequest
23116    {
23117        #[inline]
23118        unsafe fn encode(
23119            self,
23120            encoder: &mut fidl::encoding::Encoder<
23121                '_,
23122                fidl::encoding::DefaultFuchsiaResourceDialect,
23123            >,
23124            offset: usize,
23125            _depth: fidl::encoding::Depth,
23126        ) -> fidl::Result<()> {
23127            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
23128            // Delegate to tuple encoding.
23129            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23130                (
23131                    <fidl::encoding::Vector<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
23132                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
23133                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
23134                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
23135                ),
23136                encoder, offset, _depth
23137            )
23138        }
23139    }
23140    unsafe impl<
23141        T0: fidl::encoding::Encode<
23142                fidl::encoding::Vector<
23143                    fidl::encoding::HandleType<
23144                        fidl::Vmo,
23145                        { fidl::ObjectType::VMO.into_raw() },
23146                        2147483648,
23147                    >,
23148                    16,
23149                >,
23150                fidl::encoding::DefaultFuchsiaResourceDialect,
23151            >,
23152        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
23153        T2: fidl::encoding::Encode<
23154                fidl::encoding::Boxed<Compression>,
23155                fidl::encoding::DefaultFuchsiaResourceDialect,
23156            >,
23157        T3: fidl::encoding::Encode<
23158                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23159                fidl::encoding::DefaultFuchsiaResourceDialect,
23160            >,
23161    >
23162        fidl::encoding::Encode<
23163            AudioConsumerCreateStreamSinkRequest,
23164            fidl::encoding::DefaultFuchsiaResourceDialect,
23165        > for (T0, T1, T2, T3)
23166    {
23167        #[inline]
23168        unsafe fn encode(
23169            self,
23170            encoder: &mut fidl::encoding::Encoder<
23171                '_,
23172                fidl::encoding::DefaultFuchsiaResourceDialect,
23173            >,
23174            offset: usize,
23175            depth: fidl::encoding::Depth,
23176        ) -> fidl::Result<()> {
23177            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
23178            // Zero out padding regions. There's no need to apply masks
23179            // because the unmasked parts will be overwritten by fields.
23180            unsafe {
23181                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
23182                (ptr as *mut u64).write_unaligned(0);
23183            }
23184            unsafe {
23185                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
23186                (ptr as *mut u64).write_unaligned(0);
23187            }
23188            // Write the fields.
23189            self.0.encode(encoder, offset + 0, depth)?;
23190            self.1.encode(encoder, offset + 16, depth)?;
23191            self.2.encode(encoder, offset + 32, depth)?;
23192            self.3.encode(encoder, offset + 40, depth)?;
23193            Ok(())
23194        }
23195    }
23196
23197    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23198        for AudioConsumerCreateStreamSinkRequest
23199    {
23200        #[inline(always)]
23201        fn new_empty() -> Self {
23202            Self {
23203                buffers: fidl::new_empty!(
23204                    fidl::encoding::Vector<
23205                        fidl::encoding::HandleType<
23206                            fidl::Vmo,
23207                            { fidl::ObjectType::VMO.into_raw() },
23208                            2147483648,
23209                        >,
23210                        16,
23211                    >,
23212                    fidl::encoding::DefaultFuchsiaResourceDialect
23213                ),
23214                stream_type: fidl::new_empty!(
23215                    AudioStreamType,
23216                    fidl::encoding::DefaultFuchsiaResourceDialect
23217                ),
23218                compression: fidl::new_empty!(
23219                    fidl::encoding::Boxed<Compression>,
23220                    fidl::encoding::DefaultFuchsiaResourceDialect
23221                ),
23222                stream_sink_request: fidl::new_empty!(
23223                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23224                    fidl::encoding::DefaultFuchsiaResourceDialect
23225                ),
23226            }
23227        }
23228
23229        #[inline]
23230        unsafe fn decode(
23231            &mut self,
23232            decoder: &mut fidl::encoding::Decoder<
23233                '_,
23234                fidl::encoding::DefaultFuchsiaResourceDialect,
23235            >,
23236            offset: usize,
23237            _depth: fidl::encoding::Depth,
23238        ) -> fidl::Result<()> {
23239            decoder.debug_check_bounds::<Self>(offset);
23240            // Verify that padding bytes are zero.
23241            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
23242            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23243            let mask = 0xffffffff00000000u64;
23244            let maskedval = padval & mask;
23245            if maskedval != 0 {
23246                return Err(fidl::Error::NonZeroPadding {
23247                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
23248                });
23249            }
23250            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
23251            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23252            let mask = 0xffffffff00000000u64;
23253            let maskedval = padval & mask;
23254            if maskedval != 0 {
23255                return Err(fidl::Error::NonZeroPadding {
23256                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
23257                });
23258            }
23259            fidl::decode!(
23260                fidl::encoding::Vector<
23261                    fidl::encoding::HandleType<
23262                        fidl::Vmo,
23263                        { fidl::ObjectType::VMO.into_raw() },
23264                        2147483648,
23265                    >,
23266                    16,
23267                >,
23268                fidl::encoding::DefaultFuchsiaResourceDialect,
23269                &mut self.buffers,
23270                decoder,
23271                offset + 0,
23272                _depth
23273            )?;
23274            fidl::decode!(
23275                AudioStreamType,
23276                fidl::encoding::DefaultFuchsiaResourceDialect,
23277                &mut self.stream_type,
23278                decoder,
23279                offset + 16,
23280                _depth
23281            )?;
23282            fidl::decode!(
23283                fidl::encoding::Boxed<Compression>,
23284                fidl::encoding::DefaultFuchsiaResourceDialect,
23285                &mut self.compression,
23286                decoder,
23287                offset + 32,
23288                _depth
23289            )?;
23290            fidl::decode!(
23291                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23292                fidl::encoding::DefaultFuchsiaResourceDialect,
23293                &mut self.stream_sink_request,
23294                decoder,
23295                offset + 40,
23296                _depth
23297            )?;
23298            Ok(())
23299        }
23300    }
23301
23302    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
23303        type Borrowed<'a> = &'a mut Self;
23304        fn take_or_borrow<'a>(
23305            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23306        ) -> Self::Borrowed<'a> {
23307            value
23308        }
23309    }
23310
23311    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
23312        type Owned = Self;
23313
23314        #[inline(always)]
23315        fn inline_align(_context: fidl::encoding::Context) -> usize {
23316            8
23317        }
23318
23319        #[inline(always)]
23320        fn inline_size(_context: fidl::encoding::Context) -> usize {
23321            24
23322        }
23323    }
23324
23325    unsafe impl
23326        fidl::encoding::Encode<
23327            AudioCoreBindUsageVolumeControl2Request,
23328            fidl::encoding::DefaultFuchsiaResourceDialect,
23329        > for &mut AudioCoreBindUsageVolumeControl2Request
23330    {
23331        #[inline]
23332        unsafe fn encode(
23333            self,
23334            encoder: &mut fidl::encoding::Encoder<
23335                '_,
23336                fidl::encoding::DefaultFuchsiaResourceDialect,
23337            >,
23338            offset: usize,
23339            _depth: fidl::encoding::Depth,
23340        ) -> fidl::Result<()> {
23341            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
23342            // Delegate to tuple encoding.
23343            fidl::encoding::Encode::<
23344                AudioCoreBindUsageVolumeControl2Request,
23345                fidl::encoding::DefaultFuchsiaResourceDialect,
23346            >::encode(
23347                (
23348                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23349                    <fidl::encoding::Endpoint<
23350                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23351                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23352                        &mut self.volume_control,
23353                    ),
23354                ),
23355                encoder,
23356                offset,
23357                _depth,
23358            )
23359        }
23360    }
23361    unsafe impl<
23362        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
23363        T1: fidl::encoding::Encode<
23364                fidl::encoding::Endpoint<
23365                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23366                >,
23367                fidl::encoding::DefaultFuchsiaResourceDialect,
23368            >,
23369    >
23370        fidl::encoding::Encode<
23371            AudioCoreBindUsageVolumeControl2Request,
23372            fidl::encoding::DefaultFuchsiaResourceDialect,
23373        > for (T0, T1)
23374    {
23375        #[inline]
23376        unsafe fn encode(
23377            self,
23378            encoder: &mut fidl::encoding::Encoder<
23379                '_,
23380                fidl::encoding::DefaultFuchsiaResourceDialect,
23381            >,
23382            offset: usize,
23383            depth: fidl::encoding::Depth,
23384        ) -> fidl::Result<()> {
23385            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
23386            // Zero out padding regions. There's no need to apply masks
23387            // because the unmasked parts will be overwritten by fields.
23388            unsafe {
23389                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
23390                (ptr as *mut u64).write_unaligned(0);
23391            }
23392            // Write the fields.
23393            self.0.encode(encoder, offset + 0, depth)?;
23394            self.1.encode(encoder, offset + 16, depth)?;
23395            Ok(())
23396        }
23397    }
23398
23399    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23400        for AudioCoreBindUsageVolumeControl2Request
23401    {
23402        #[inline(always)]
23403        fn new_empty() -> Self {
23404            Self {
23405                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
23406                volume_control: fidl::new_empty!(
23407                    fidl::encoding::Endpoint<
23408                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23409                    >,
23410                    fidl::encoding::DefaultFuchsiaResourceDialect
23411                ),
23412            }
23413        }
23414
23415        #[inline]
23416        unsafe fn decode(
23417            &mut self,
23418            decoder: &mut fidl::encoding::Decoder<
23419                '_,
23420                fidl::encoding::DefaultFuchsiaResourceDialect,
23421            >,
23422            offset: usize,
23423            _depth: fidl::encoding::Depth,
23424        ) -> fidl::Result<()> {
23425            decoder.debug_check_bounds::<Self>(offset);
23426            // Verify that padding bytes are zero.
23427            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
23428            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23429            let mask = 0xffffffff00000000u64;
23430            let maskedval = padval & mask;
23431            if maskedval != 0 {
23432                return Err(fidl::Error::NonZeroPadding {
23433                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
23434                });
23435            }
23436            fidl::decode!(
23437                Usage2,
23438                fidl::encoding::DefaultFuchsiaResourceDialect,
23439                &mut self.usage,
23440                decoder,
23441                offset + 0,
23442                _depth
23443            )?;
23444            fidl::decode!(
23445                fidl::encoding::Endpoint<
23446                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23447                >,
23448                fidl::encoding::DefaultFuchsiaResourceDialect,
23449                &mut self.volume_control,
23450                decoder,
23451                offset + 16,
23452                _depth
23453            )?;
23454            Ok(())
23455        }
23456    }
23457
23458    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
23459        type Borrowed<'a> = &'a mut Self;
23460        fn take_or_borrow<'a>(
23461            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23462        ) -> Self::Borrowed<'a> {
23463            value
23464        }
23465    }
23466
23467    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
23468        type Owned = Self;
23469
23470        #[inline(always)]
23471        fn inline_align(_context: fidl::encoding::Context) -> usize {
23472            8
23473        }
23474
23475        #[inline(always)]
23476        fn inline_size(_context: fidl::encoding::Context) -> usize {
23477            24
23478        }
23479    }
23480
23481    unsafe impl
23482        fidl::encoding::Encode<
23483            AudioCoreBindUsageVolumeControlRequest,
23484            fidl::encoding::DefaultFuchsiaResourceDialect,
23485        > for &mut AudioCoreBindUsageVolumeControlRequest
23486    {
23487        #[inline]
23488        unsafe fn encode(
23489            self,
23490            encoder: &mut fidl::encoding::Encoder<
23491                '_,
23492                fidl::encoding::DefaultFuchsiaResourceDialect,
23493            >,
23494            offset: usize,
23495            _depth: fidl::encoding::Depth,
23496        ) -> fidl::Result<()> {
23497            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
23498            // Delegate to tuple encoding.
23499            fidl::encoding::Encode::<
23500                AudioCoreBindUsageVolumeControlRequest,
23501                fidl::encoding::DefaultFuchsiaResourceDialect,
23502            >::encode(
23503                (
23504                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23505                    <fidl::encoding::Endpoint<
23506                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23507                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23508                        &mut self.volume_control,
23509                    ),
23510                ),
23511                encoder,
23512                offset,
23513                _depth,
23514            )
23515        }
23516    }
23517    unsafe impl<
23518        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
23519        T1: fidl::encoding::Encode<
23520                fidl::encoding::Endpoint<
23521                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23522                >,
23523                fidl::encoding::DefaultFuchsiaResourceDialect,
23524            >,
23525    >
23526        fidl::encoding::Encode<
23527            AudioCoreBindUsageVolumeControlRequest,
23528            fidl::encoding::DefaultFuchsiaResourceDialect,
23529        > for (T0, T1)
23530    {
23531        #[inline]
23532        unsafe fn encode(
23533            self,
23534            encoder: &mut fidl::encoding::Encoder<
23535                '_,
23536                fidl::encoding::DefaultFuchsiaResourceDialect,
23537            >,
23538            offset: usize,
23539            depth: fidl::encoding::Depth,
23540        ) -> fidl::Result<()> {
23541            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
23542            // Zero out padding regions. There's no need to apply masks
23543            // because the unmasked parts will be overwritten by fields.
23544            unsafe {
23545                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
23546                (ptr as *mut u64).write_unaligned(0);
23547            }
23548            // Write the fields.
23549            self.0.encode(encoder, offset + 0, depth)?;
23550            self.1.encode(encoder, offset + 16, depth)?;
23551            Ok(())
23552        }
23553    }
23554
23555    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23556        for AudioCoreBindUsageVolumeControlRequest
23557    {
23558        #[inline(always)]
23559        fn new_empty() -> Self {
23560            Self {
23561                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
23562                volume_control: fidl::new_empty!(
23563                    fidl::encoding::Endpoint<
23564                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23565                    >,
23566                    fidl::encoding::DefaultFuchsiaResourceDialect
23567                ),
23568            }
23569        }
23570
23571        #[inline]
23572        unsafe fn decode(
23573            &mut self,
23574            decoder: &mut fidl::encoding::Decoder<
23575                '_,
23576                fidl::encoding::DefaultFuchsiaResourceDialect,
23577            >,
23578            offset: usize,
23579            _depth: fidl::encoding::Depth,
23580        ) -> fidl::Result<()> {
23581            decoder.debug_check_bounds::<Self>(offset);
23582            // Verify that padding bytes are zero.
23583            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
23584            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23585            let mask = 0xffffffff00000000u64;
23586            let maskedval = padval & mask;
23587            if maskedval != 0 {
23588                return Err(fidl::Error::NonZeroPadding {
23589                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
23590                });
23591            }
23592            fidl::decode!(
23593                Usage,
23594                fidl::encoding::DefaultFuchsiaResourceDialect,
23595                &mut self.usage,
23596                decoder,
23597                offset + 0,
23598                _depth
23599            )?;
23600            fidl::decode!(
23601                fidl::encoding::Endpoint<
23602                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23603                >,
23604                fidl::encoding::DefaultFuchsiaResourceDialect,
23605                &mut self.volume_control,
23606                decoder,
23607                offset + 16,
23608                _depth
23609            )?;
23610            Ok(())
23611        }
23612    }
23613
23614    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
23615        type Borrowed<'a> = &'a mut Self;
23616        fn take_or_borrow<'a>(
23617            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23618        ) -> Self::Borrowed<'a> {
23619            value
23620        }
23621    }
23622
23623    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
23624        type Owned = Self;
23625
23626        #[inline(always)]
23627        fn inline_align(_context: fidl::encoding::Context) -> usize {
23628            4
23629        }
23630
23631        #[inline(always)]
23632        fn inline_size(_context: fidl::encoding::Context) -> usize {
23633            8
23634        }
23635    }
23636
23637    unsafe impl
23638        fidl::encoding::Encode<
23639            AudioCoreCreateAudioCapturerRequest,
23640            fidl::encoding::DefaultFuchsiaResourceDialect,
23641        > for &mut AudioCoreCreateAudioCapturerRequest
23642    {
23643        #[inline]
23644        unsafe fn encode(
23645            self,
23646            encoder: &mut fidl::encoding::Encoder<
23647                '_,
23648                fidl::encoding::DefaultFuchsiaResourceDialect,
23649            >,
23650            offset: usize,
23651            _depth: fidl::encoding::Depth,
23652        ) -> fidl::Result<()> {
23653            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
23654            // Delegate to tuple encoding.
23655            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23656                (
23657                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
23658                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
23659                ),
23660                encoder, offset, _depth
23661            )
23662        }
23663    }
23664    unsafe impl<
23665        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
23666        T1: fidl::encoding::Encode<
23667                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23668                fidl::encoding::DefaultFuchsiaResourceDialect,
23669            >,
23670    >
23671        fidl::encoding::Encode<
23672            AudioCoreCreateAudioCapturerRequest,
23673            fidl::encoding::DefaultFuchsiaResourceDialect,
23674        > for (T0, T1)
23675    {
23676        #[inline]
23677        unsafe fn encode(
23678            self,
23679            encoder: &mut fidl::encoding::Encoder<
23680                '_,
23681                fidl::encoding::DefaultFuchsiaResourceDialect,
23682            >,
23683            offset: usize,
23684            depth: fidl::encoding::Depth,
23685        ) -> fidl::Result<()> {
23686            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
23687            // Zero out padding regions. There's no need to apply masks
23688            // because the unmasked parts will be overwritten by fields.
23689            unsafe {
23690                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23691                (ptr as *mut u32).write_unaligned(0);
23692            }
23693            // Write the fields.
23694            self.0.encode(encoder, offset + 0, depth)?;
23695            self.1.encode(encoder, offset + 4, depth)?;
23696            Ok(())
23697        }
23698    }
23699
23700    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23701        for AudioCoreCreateAudioCapturerRequest
23702    {
23703        #[inline(always)]
23704        fn new_empty() -> Self {
23705            Self {
23706                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
23707                audio_in_request: fidl::new_empty!(
23708                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23709                    fidl::encoding::DefaultFuchsiaResourceDialect
23710                ),
23711            }
23712        }
23713
23714        #[inline]
23715        unsafe fn decode(
23716            &mut self,
23717            decoder: &mut fidl::encoding::Decoder<
23718                '_,
23719                fidl::encoding::DefaultFuchsiaResourceDialect,
23720            >,
23721            offset: usize,
23722            _depth: fidl::encoding::Depth,
23723        ) -> fidl::Result<()> {
23724            decoder.debug_check_bounds::<Self>(offset);
23725            // Verify that padding bytes are zero.
23726            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23727            let padval = unsafe { (ptr as *const u32).read_unaligned() };
23728            let mask = 0xffffff00u32;
23729            let maskedval = padval & mask;
23730            if maskedval != 0 {
23731                return Err(fidl::Error::NonZeroPadding {
23732                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23733                });
23734            }
23735            fidl::decode!(
23736                bool,
23737                fidl::encoding::DefaultFuchsiaResourceDialect,
23738                &mut self.loopback,
23739                decoder,
23740                offset + 0,
23741                _depth
23742            )?;
23743            fidl::decode!(
23744                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23745                fidl::encoding::DefaultFuchsiaResourceDialect,
23746                &mut self.audio_in_request,
23747                decoder,
23748                offset + 4,
23749                _depth
23750            )?;
23751            Ok(())
23752        }
23753    }
23754
23755    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
23756        type Borrowed<'a> = &'a mut Self;
23757        fn take_or_borrow<'a>(
23758            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23759        ) -> Self::Borrowed<'a> {
23760            value
23761        }
23762    }
23763
23764    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
23765        type Owned = Self;
23766
23767        #[inline(always)]
23768        fn inline_align(_context: fidl::encoding::Context) -> usize {
23769            8
23770        }
23771
23772        #[inline(always)]
23773        fn inline_size(_context: fidl::encoding::Context) -> usize {
23774            40
23775        }
23776    }
23777
23778    unsafe impl
23779        fidl::encoding::Encode<
23780            AudioCoreCreateAudioCapturerWithConfigurationRequest,
23781            fidl::encoding::DefaultFuchsiaResourceDialect,
23782        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
23783    {
23784        #[inline]
23785        unsafe fn encode(
23786            self,
23787            encoder: &mut fidl::encoding::Encoder<
23788                '_,
23789                fidl::encoding::DefaultFuchsiaResourceDialect,
23790            >,
23791            offset: usize,
23792            _depth: fidl::encoding::Depth,
23793        ) -> fidl::Result<()> {
23794            encoder
23795                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
23796            // Delegate to tuple encoding.
23797            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23798                (
23799                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
23800                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
23801                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
23802                ),
23803                encoder, offset, _depth
23804            )
23805        }
23806    }
23807    unsafe impl<
23808        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
23809        T1: fidl::encoding::Encode<
23810                AudioCapturerConfiguration,
23811                fidl::encoding::DefaultFuchsiaResourceDialect,
23812            >,
23813        T2: fidl::encoding::Encode<
23814                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23815                fidl::encoding::DefaultFuchsiaResourceDialect,
23816            >,
23817    >
23818        fidl::encoding::Encode<
23819            AudioCoreCreateAudioCapturerWithConfigurationRequest,
23820            fidl::encoding::DefaultFuchsiaResourceDialect,
23821        > for (T0, T1, T2)
23822    {
23823        #[inline]
23824        unsafe fn encode(
23825            self,
23826            encoder: &mut fidl::encoding::Encoder<
23827                '_,
23828                fidl::encoding::DefaultFuchsiaResourceDialect,
23829            >,
23830            offset: usize,
23831            depth: fidl::encoding::Depth,
23832        ) -> fidl::Result<()> {
23833            encoder
23834                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
23835            // Zero out padding regions. There's no need to apply masks
23836            // because the unmasked parts will be overwritten by fields.
23837            unsafe {
23838                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23839                (ptr as *mut u64).write_unaligned(0);
23840            }
23841            unsafe {
23842                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
23843                (ptr as *mut u64).write_unaligned(0);
23844            }
23845            // Write the fields.
23846            self.0.encode(encoder, offset + 0, depth)?;
23847            self.1.encode(encoder, offset + 16, depth)?;
23848            self.2.encode(encoder, offset + 32, depth)?;
23849            Ok(())
23850        }
23851    }
23852
23853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23854        for AudioCoreCreateAudioCapturerWithConfigurationRequest
23855    {
23856        #[inline(always)]
23857        fn new_empty() -> Self {
23858            Self {
23859                stream_type: fidl::new_empty!(
23860                    AudioStreamType,
23861                    fidl::encoding::DefaultFuchsiaResourceDialect
23862                ),
23863                configuration: fidl::new_empty!(
23864                    AudioCapturerConfiguration,
23865                    fidl::encoding::DefaultFuchsiaResourceDialect
23866                ),
23867                audio_capturer_request: fidl::new_empty!(
23868                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23869                    fidl::encoding::DefaultFuchsiaResourceDialect
23870                ),
23871            }
23872        }
23873
23874        #[inline]
23875        unsafe fn decode(
23876            &mut self,
23877            decoder: &mut fidl::encoding::Decoder<
23878                '_,
23879                fidl::encoding::DefaultFuchsiaResourceDialect,
23880            >,
23881            offset: usize,
23882            _depth: fidl::encoding::Depth,
23883        ) -> fidl::Result<()> {
23884            decoder.debug_check_bounds::<Self>(offset);
23885            // Verify that padding bytes are zero.
23886            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23887            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23888            let mask = 0xffffffff00000000u64;
23889            let maskedval = padval & mask;
23890            if maskedval != 0 {
23891                return Err(fidl::Error::NonZeroPadding {
23892                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23893                });
23894            }
23895            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
23896            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23897            let mask = 0xffffffff00000000u64;
23898            let maskedval = padval & mask;
23899            if maskedval != 0 {
23900                return Err(fidl::Error::NonZeroPadding {
23901                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
23902                });
23903            }
23904            fidl::decode!(
23905                AudioStreamType,
23906                fidl::encoding::DefaultFuchsiaResourceDialect,
23907                &mut self.stream_type,
23908                decoder,
23909                offset + 0,
23910                _depth
23911            )?;
23912            fidl::decode!(
23913                AudioCapturerConfiguration,
23914                fidl::encoding::DefaultFuchsiaResourceDialect,
23915                &mut self.configuration,
23916                decoder,
23917                offset + 16,
23918                _depth
23919            )?;
23920            fidl::decode!(
23921                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23922                fidl::encoding::DefaultFuchsiaResourceDialect,
23923                &mut self.audio_capturer_request,
23924                decoder,
23925                offset + 32,
23926                _depth
23927            )?;
23928            Ok(())
23929        }
23930    }
23931
23932    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
23933        type Borrowed<'a> = &'a mut Self;
23934        fn take_or_borrow<'a>(
23935            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23936        ) -> Self::Borrowed<'a> {
23937            value
23938        }
23939    }
23940
23941    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
23942        type Owned = Self;
23943
23944        #[inline(always)]
23945        fn inline_align(_context: fidl::encoding::Context) -> usize {
23946            4
23947        }
23948
23949        #[inline(always)]
23950        fn inline_size(_context: fidl::encoding::Context) -> usize {
23951            4
23952        }
23953    }
23954
23955    unsafe impl
23956        fidl::encoding::Encode<
23957            AudioCoreCreateAudioRendererRequest,
23958            fidl::encoding::DefaultFuchsiaResourceDialect,
23959        > for &mut AudioCoreCreateAudioRendererRequest
23960    {
23961        #[inline]
23962        unsafe fn encode(
23963            self,
23964            encoder: &mut fidl::encoding::Encoder<
23965                '_,
23966                fidl::encoding::DefaultFuchsiaResourceDialect,
23967            >,
23968            offset: usize,
23969            _depth: fidl::encoding::Depth,
23970        ) -> fidl::Result<()> {
23971            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
23972            // Delegate to tuple encoding.
23973            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23974                (
23975                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
23976                ),
23977                encoder, offset, _depth
23978            )
23979        }
23980    }
23981    unsafe impl<
23982        T0: fidl::encoding::Encode<
23983                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
23984                fidl::encoding::DefaultFuchsiaResourceDialect,
23985            >,
23986    >
23987        fidl::encoding::Encode<
23988            AudioCoreCreateAudioRendererRequest,
23989            fidl::encoding::DefaultFuchsiaResourceDialect,
23990        > for (T0,)
23991    {
23992        #[inline]
23993        unsafe fn encode(
23994            self,
23995            encoder: &mut fidl::encoding::Encoder<
23996                '_,
23997                fidl::encoding::DefaultFuchsiaResourceDialect,
23998            >,
23999            offset: usize,
24000            depth: fidl::encoding::Depth,
24001        ) -> fidl::Result<()> {
24002            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
24003            // Zero out padding regions. There's no need to apply masks
24004            // because the unmasked parts will be overwritten by fields.
24005            // Write the fields.
24006            self.0.encode(encoder, offset + 0, depth)?;
24007            Ok(())
24008        }
24009    }
24010
24011    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24012        for AudioCoreCreateAudioRendererRequest
24013    {
24014        #[inline(always)]
24015        fn new_empty() -> Self {
24016            Self {
24017                audio_out_request: fidl::new_empty!(
24018                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24019                    fidl::encoding::DefaultFuchsiaResourceDialect
24020                ),
24021            }
24022        }
24023
24024        #[inline]
24025        unsafe fn decode(
24026            &mut self,
24027            decoder: &mut fidl::encoding::Decoder<
24028                '_,
24029                fidl::encoding::DefaultFuchsiaResourceDialect,
24030            >,
24031            offset: usize,
24032            _depth: fidl::encoding::Depth,
24033        ) -> fidl::Result<()> {
24034            decoder.debug_check_bounds::<Self>(offset);
24035            // Verify that padding bytes are zero.
24036            fidl::decode!(
24037                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24038                fidl::encoding::DefaultFuchsiaResourceDialect,
24039                &mut self.audio_out_request,
24040                decoder,
24041                offset + 0,
24042                _depth
24043            )?;
24044            Ok(())
24045        }
24046    }
24047
24048    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
24049        type Borrowed<'a> = &'a mut Self;
24050        fn take_or_borrow<'a>(
24051            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24052        ) -> Self::Borrowed<'a> {
24053            value
24054        }
24055    }
24056
24057    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
24058        type Owned = Self;
24059
24060        #[inline(always)]
24061        fn inline_align(_context: fidl::encoding::Context) -> usize {
24062            4
24063        }
24064
24065        #[inline(always)]
24066        fn inline_size(_context: fidl::encoding::Context) -> usize {
24067            8
24068        }
24069    }
24070
24071    unsafe impl
24072        fidl::encoding::Encode<
24073            AudioCreateAudioCapturerRequest,
24074            fidl::encoding::DefaultFuchsiaResourceDialect,
24075        > for &mut AudioCreateAudioCapturerRequest
24076    {
24077        #[inline]
24078        unsafe fn encode(
24079            self,
24080            encoder: &mut fidl::encoding::Encoder<
24081                '_,
24082                fidl::encoding::DefaultFuchsiaResourceDialect,
24083            >,
24084            offset: usize,
24085            _depth: fidl::encoding::Depth,
24086        ) -> fidl::Result<()> {
24087            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
24088            // Delegate to tuple encoding.
24089            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24090                (
24091                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
24092                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
24093                ),
24094                encoder, offset, _depth
24095            )
24096        }
24097    }
24098    unsafe impl<
24099        T0: fidl::encoding::Encode<
24100                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24101                fidl::encoding::DefaultFuchsiaResourceDialect,
24102            >,
24103        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
24104    >
24105        fidl::encoding::Encode<
24106            AudioCreateAudioCapturerRequest,
24107            fidl::encoding::DefaultFuchsiaResourceDialect,
24108        > for (T0, T1)
24109    {
24110        #[inline]
24111        unsafe fn encode(
24112            self,
24113            encoder: &mut fidl::encoding::Encoder<
24114                '_,
24115                fidl::encoding::DefaultFuchsiaResourceDialect,
24116            >,
24117            offset: usize,
24118            depth: fidl::encoding::Depth,
24119        ) -> fidl::Result<()> {
24120            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
24121            // Zero out padding regions. There's no need to apply masks
24122            // because the unmasked parts will be overwritten by fields.
24123            unsafe {
24124                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
24125                (ptr as *mut u32).write_unaligned(0);
24126            }
24127            // Write the fields.
24128            self.0.encode(encoder, offset + 0, depth)?;
24129            self.1.encode(encoder, offset + 4, depth)?;
24130            Ok(())
24131        }
24132    }
24133
24134    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24135        for AudioCreateAudioCapturerRequest
24136    {
24137        #[inline(always)]
24138        fn new_empty() -> Self {
24139            Self {
24140                audio_capturer_request: fidl::new_empty!(
24141                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24142                    fidl::encoding::DefaultFuchsiaResourceDialect
24143                ),
24144                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
24145            }
24146        }
24147
24148        #[inline]
24149        unsafe fn decode(
24150            &mut self,
24151            decoder: &mut fidl::encoding::Decoder<
24152                '_,
24153                fidl::encoding::DefaultFuchsiaResourceDialect,
24154            >,
24155            offset: usize,
24156            _depth: fidl::encoding::Depth,
24157        ) -> fidl::Result<()> {
24158            decoder.debug_check_bounds::<Self>(offset);
24159            // Verify that padding bytes are zero.
24160            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
24161            let padval = unsafe { (ptr as *const u32).read_unaligned() };
24162            let mask = 0xffffff00u32;
24163            let maskedval = padval & mask;
24164            if maskedval != 0 {
24165                return Err(fidl::Error::NonZeroPadding {
24166                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
24167                });
24168            }
24169            fidl::decode!(
24170                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24171                fidl::encoding::DefaultFuchsiaResourceDialect,
24172                &mut self.audio_capturer_request,
24173                decoder,
24174                offset + 0,
24175                _depth
24176            )?;
24177            fidl::decode!(
24178                bool,
24179                fidl::encoding::DefaultFuchsiaResourceDialect,
24180                &mut self.loopback,
24181                decoder,
24182                offset + 4,
24183                _depth
24184            )?;
24185            Ok(())
24186        }
24187    }
24188
24189    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
24190        type Borrowed<'a> = &'a mut Self;
24191        fn take_or_borrow<'a>(
24192            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24193        ) -> Self::Borrowed<'a> {
24194            value
24195        }
24196    }
24197
24198    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
24199        type Owned = Self;
24200
24201        #[inline(always)]
24202        fn inline_align(_context: fidl::encoding::Context) -> usize {
24203            4
24204        }
24205
24206        #[inline(always)]
24207        fn inline_size(_context: fidl::encoding::Context) -> usize {
24208            4
24209        }
24210    }
24211
24212    unsafe impl
24213        fidl::encoding::Encode<
24214            AudioCreateAudioRendererRequest,
24215            fidl::encoding::DefaultFuchsiaResourceDialect,
24216        > for &mut AudioCreateAudioRendererRequest
24217    {
24218        #[inline]
24219        unsafe fn encode(
24220            self,
24221            encoder: &mut fidl::encoding::Encoder<
24222                '_,
24223                fidl::encoding::DefaultFuchsiaResourceDialect,
24224            >,
24225            offset: usize,
24226            _depth: fidl::encoding::Depth,
24227        ) -> fidl::Result<()> {
24228            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
24229            // Delegate to tuple encoding.
24230            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24231                (
24232                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
24233                ),
24234                encoder, offset, _depth
24235            )
24236        }
24237    }
24238    unsafe impl<
24239        T0: fidl::encoding::Encode<
24240                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24241                fidl::encoding::DefaultFuchsiaResourceDialect,
24242            >,
24243    >
24244        fidl::encoding::Encode<
24245            AudioCreateAudioRendererRequest,
24246            fidl::encoding::DefaultFuchsiaResourceDialect,
24247        > for (T0,)
24248    {
24249        #[inline]
24250        unsafe fn encode(
24251            self,
24252            encoder: &mut fidl::encoding::Encoder<
24253                '_,
24254                fidl::encoding::DefaultFuchsiaResourceDialect,
24255            >,
24256            offset: usize,
24257            depth: fidl::encoding::Depth,
24258        ) -> fidl::Result<()> {
24259            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
24260            // Zero out padding regions. There's no need to apply masks
24261            // because the unmasked parts will be overwritten by fields.
24262            // Write the fields.
24263            self.0.encode(encoder, offset + 0, depth)?;
24264            Ok(())
24265        }
24266    }
24267
24268    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24269        for AudioCreateAudioRendererRequest
24270    {
24271        #[inline(always)]
24272        fn new_empty() -> Self {
24273            Self {
24274                audio_renderer_request: fidl::new_empty!(
24275                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24276                    fidl::encoding::DefaultFuchsiaResourceDialect
24277                ),
24278            }
24279        }
24280
24281        #[inline]
24282        unsafe fn decode(
24283            &mut self,
24284            decoder: &mut fidl::encoding::Decoder<
24285                '_,
24286                fidl::encoding::DefaultFuchsiaResourceDialect,
24287            >,
24288            offset: usize,
24289            _depth: fidl::encoding::Depth,
24290        ) -> fidl::Result<()> {
24291            decoder.debug_check_bounds::<Self>(offset);
24292            // Verify that padding bytes are zero.
24293            fidl::decode!(
24294                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24295                fidl::encoding::DefaultFuchsiaResourceDialect,
24296                &mut self.audio_renderer_request,
24297                decoder,
24298                offset + 0,
24299                _depth
24300            )?;
24301            Ok(())
24302        }
24303    }
24304
24305    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
24306        type Borrowed<'a> = &'a mut Self;
24307        fn take_or_borrow<'a>(
24308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24309        ) -> Self::Borrowed<'a> {
24310            value
24311        }
24312    }
24313
24314    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
24315        type Owned = Self;
24316
24317        #[inline(always)]
24318        fn inline_align(_context: fidl::encoding::Context) -> usize {
24319            8
24320        }
24321
24322        #[inline(always)]
24323        fn inline_size(_context: fidl::encoding::Context) -> usize {
24324            24
24325        }
24326    }
24327
24328    unsafe impl
24329        fidl::encoding::Encode<
24330            AudioDeviceEnumeratorAddDeviceByChannelRequest,
24331            fidl::encoding::DefaultFuchsiaResourceDialect,
24332        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
24333    {
24334        #[inline]
24335        unsafe fn encode(
24336            self,
24337            encoder: &mut fidl::encoding::Encoder<
24338                '_,
24339                fidl::encoding::DefaultFuchsiaResourceDialect,
24340            >,
24341            offset: usize,
24342            _depth: fidl::encoding::Depth,
24343        ) -> fidl::Result<()> {
24344            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
24345            // Delegate to tuple encoding.
24346            fidl::encoding::Encode::<
24347                AudioDeviceEnumeratorAddDeviceByChannelRequest,
24348                fidl::encoding::DefaultFuchsiaResourceDialect,
24349            >::encode(
24350                (
24351                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
24352                        &self.device_name,
24353                    ),
24354                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
24355                    <fidl::encoding::Endpoint<
24356                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24357                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24358                        &mut self.channel
24359                    ),
24360                ),
24361                encoder,
24362                offset,
24363                _depth,
24364            )
24365        }
24366    }
24367    unsafe impl<
24368        T0: fidl::encoding::Encode<
24369                fidl::encoding::BoundedString<256>,
24370                fidl::encoding::DefaultFuchsiaResourceDialect,
24371            >,
24372        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
24373        T2: fidl::encoding::Encode<
24374                fidl::encoding::Endpoint<
24375                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24376                >,
24377                fidl::encoding::DefaultFuchsiaResourceDialect,
24378            >,
24379    >
24380        fidl::encoding::Encode<
24381            AudioDeviceEnumeratorAddDeviceByChannelRequest,
24382            fidl::encoding::DefaultFuchsiaResourceDialect,
24383        > for (T0, T1, T2)
24384    {
24385        #[inline]
24386        unsafe fn encode(
24387            self,
24388            encoder: &mut fidl::encoding::Encoder<
24389                '_,
24390                fidl::encoding::DefaultFuchsiaResourceDialect,
24391            >,
24392            offset: usize,
24393            depth: fidl::encoding::Depth,
24394        ) -> fidl::Result<()> {
24395            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
24396            // Zero out padding regions. There's no need to apply masks
24397            // because the unmasked parts will be overwritten by fields.
24398            unsafe {
24399                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24400                (ptr as *mut u64).write_unaligned(0);
24401            }
24402            // Write the fields.
24403            self.0.encode(encoder, offset + 0, depth)?;
24404            self.1.encode(encoder, offset + 16, depth)?;
24405            self.2.encode(encoder, offset + 20, depth)?;
24406            Ok(())
24407        }
24408    }
24409
24410    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24411        for AudioDeviceEnumeratorAddDeviceByChannelRequest
24412    {
24413        #[inline(always)]
24414        fn new_empty() -> Self {
24415            Self {
24416                device_name: fidl::new_empty!(
24417                    fidl::encoding::BoundedString<256>,
24418                    fidl::encoding::DefaultFuchsiaResourceDialect
24419                ),
24420                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
24421                channel: fidl::new_empty!(
24422                    fidl::encoding::Endpoint<
24423                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24424                    >,
24425                    fidl::encoding::DefaultFuchsiaResourceDialect
24426                ),
24427            }
24428        }
24429
24430        #[inline]
24431        unsafe fn decode(
24432            &mut self,
24433            decoder: &mut fidl::encoding::Decoder<
24434                '_,
24435                fidl::encoding::DefaultFuchsiaResourceDialect,
24436            >,
24437            offset: usize,
24438            _depth: fidl::encoding::Depth,
24439        ) -> fidl::Result<()> {
24440            decoder.debug_check_bounds::<Self>(offset);
24441            // Verify that padding bytes are zero.
24442            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24443            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24444            let mask = 0xffffff00u64;
24445            let maskedval = padval & mask;
24446            if maskedval != 0 {
24447                return Err(fidl::Error::NonZeroPadding {
24448                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24449                });
24450            }
24451            fidl::decode!(
24452                fidl::encoding::BoundedString<256>,
24453                fidl::encoding::DefaultFuchsiaResourceDialect,
24454                &mut self.device_name,
24455                decoder,
24456                offset + 0,
24457                _depth
24458            )?;
24459            fidl::decode!(
24460                bool,
24461                fidl::encoding::DefaultFuchsiaResourceDialect,
24462                &mut self.is_input,
24463                decoder,
24464                offset + 16,
24465                _depth
24466            )?;
24467            fidl::decode!(
24468                fidl::encoding::Endpoint<
24469                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24470                >,
24471                fidl::encoding::DefaultFuchsiaResourceDialect,
24472                &mut self.channel,
24473                decoder,
24474                offset + 20,
24475                _depth
24476            )?;
24477            Ok(())
24478        }
24479    }
24480
24481    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
24482        type Borrowed<'a> = &'a mut Self;
24483        fn take_or_borrow<'a>(
24484            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24485        ) -> Self::Borrowed<'a> {
24486            value
24487        }
24488    }
24489
24490    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
24491        type Owned = Self;
24492
24493        #[inline(always)]
24494        fn inline_align(_context: fidl::encoding::Context) -> usize {
24495            4
24496        }
24497
24498        #[inline(always)]
24499        fn inline_size(_context: fidl::encoding::Context) -> usize {
24500            4
24501        }
24502    }
24503
24504    unsafe impl
24505        fidl::encoding::Encode<
24506            AudioRendererBindGainControlRequest,
24507            fidl::encoding::DefaultFuchsiaResourceDialect,
24508        > for &mut AudioRendererBindGainControlRequest
24509    {
24510        #[inline]
24511        unsafe fn encode(
24512            self,
24513            encoder: &mut fidl::encoding::Encoder<
24514                '_,
24515                fidl::encoding::DefaultFuchsiaResourceDialect,
24516            >,
24517            offset: usize,
24518            _depth: fidl::encoding::Depth,
24519        ) -> fidl::Result<()> {
24520            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
24521            // Delegate to tuple encoding.
24522            fidl::encoding::Encode::<
24523                AudioRendererBindGainControlRequest,
24524                fidl::encoding::DefaultFuchsiaResourceDialect,
24525            >::encode(
24526                (<fidl::encoding::Endpoint<
24527                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24528                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24529                    &mut self.gain_control_request,
24530                ),),
24531                encoder,
24532                offset,
24533                _depth,
24534            )
24535        }
24536    }
24537    unsafe impl<
24538        T0: fidl::encoding::Encode<
24539                fidl::encoding::Endpoint<
24540                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24541                >,
24542                fidl::encoding::DefaultFuchsiaResourceDialect,
24543            >,
24544    >
24545        fidl::encoding::Encode<
24546            AudioRendererBindGainControlRequest,
24547            fidl::encoding::DefaultFuchsiaResourceDialect,
24548        > for (T0,)
24549    {
24550        #[inline]
24551        unsafe fn encode(
24552            self,
24553            encoder: &mut fidl::encoding::Encoder<
24554                '_,
24555                fidl::encoding::DefaultFuchsiaResourceDialect,
24556            >,
24557            offset: usize,
24558            depth: fidl::encoding::Depth,
24559        ) -> fidl::Result<()> {
24560            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
24561            // Zero out padding regions. There's no need to apply masks
24562            // because the unmasked parts will be overwritten by fields.
24563            // Write the fields.
24564            self.0.encode(encoder, offset + 0, depth)?;
24565            Ok(())
24566        }
24567    }
24568
24569    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24570        for AudioRendererBindGainControlRequest
24571    {
24572        #[inline(always)]
24573        fn new_empty() -> Self {
24574            Self {
24575                gain_control_request: fidl::new_empty!(
24576                    fidl::encoding::Endpoint<
24577                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24578                    >,
24579                    fidl::encoding::DefaultFuchsiaResourceDialect
24580                ),
24581            }
24582        }
24583
24584        #[inline]
24585        unsafe fn decode(
24586            &mut self,
24587            decoder: &mut fidl::encoding::Decoder<
24588                '_,
24589                fidl::encoding::DefaultFuchsiaResourceDialect,
24590            >,
24591            offset: usize,
24592            _depth: fidl::encoding::Depth,
24593        ) -> fidl::Result<()> {
24594            decoder.debug_check_bounds::<Self>(offset);
24595            // Verify that padding bytes are zero.
24596            fidl::decode!(
24597                fidl::encoding::Endpoint<
24598                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24599                >,
24600                fidl::encoding::DefaultFuchsiaResourceDialect,
24601                &mut self.gain_control_request,
24602                decoder,
24603                offset + 0,
24604                _depth
24605            )?;
24606            Ok(())
24607        }
24608    }
24609
24610    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
24611        type Borrowed<'a> = &'a mut Self;
24612        fn take_or_borrow<'a>(
24613            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24614        ) -> Self::Borrowed<'a> {
24615            value
24616        }
24617    }
24618
24619    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
24620        type Owned = Self;
24621
24622        #[inline(always)]
24623        fn inline_align(_context: fidl::encoding::Context) -> usize {
24624            4
24625        }
24626
24627        #[inline(always)]
24628        fn inline_size(_context: fidl::encoding::Context) -> usize {
24629            4
24630        }
24631    }
24632
24633    unsafe impl
24634        fidl::encoding::Encode<
24635            AudioRendererGetReferenceClockResponse,
24636            fidl::encoding::DefaultFuchsiaResourceDialect,
24637        > for &mut AudioRendererGetReferenceClockResponse
24638    {
24639        #[inline]
24640        unsafe fn encode(
24641            self,
24642            encoder: &mut fidl::encoding::Encoder<
24643                '_,
24644                fidl::encoding::DefaultFuchsiaResourceDialect,
24645            >,
24646            offset: usize,
24647            _depth: fidl::encoding::Depth,
24648        ) -> fidl::Result<()> {
24649            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
24650            // Delegate to tuple encoding.
24651            fidl::encoding::Encode::<
24652                AudioRendererGetReferenceClockResponse,
24653                fidl::encoding::DefaultFuchsiaResourceDialect,
24654            >::encode(
24655                (<fidl::encoding::HandleType<
24656                    fidl::Clock,
24657                    { fidl::ObjectType::CLOCK.into_raw() },
24658                    2147483648,
24659                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24660                    &mut self.reference_clock,
24661                ),),
24662                encoder,
24663                offset,
24664                _depth,
24665            )
24666        }
24667    }
24668    unsafe impl<
24669        T0: fidl::encoding::Encode<
24670                fidl::encoding::HandleType<
24671                    fidl::Clock,
24672                    { fidl::ObjectType::CLOCK.into_raw() },
24673                    2147483648,
24674                >,
24675                fidl::encoding::DefaultFuchsiaResourceDialect,
24676            >,
24677    >
24678        fidl::encoding::Encode<
24679            AudioRendererGetReferenceClockResponse,
24680            fidl::encoding::DefaultFuchsiaResourceDialect,
24681        > for (T0,)
24682    {
24683        #[inline]
24684        unsafe fn encode(
24685            self,
24686            encoder: &mut fidl::encoding::Encoder<
24687                '_,
24688                fidl::encoding::DefaultFuchsiaResourceDialect,
24689            >,
24690            offset: usize,
24691            depth: fidl::encoding::Depth,
24692        ) -> fidl::Result<()> {
24693            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
24694            // Zero out padding regions. There's no need to apply masks
24695            // because the unmasked parts will be overwritten by fields.
24696            // Write the fields.
24697            self.0.encode(encoder, offset + 0, depth)?;
24698            Ok(())
24699        }
24700    }
24701
24702    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24703        for AudioRendererGetReferenceClockResponse
24704    {
24705        #[inline(always)]
24706        fn new_empty() -> Self {
24707            Self {
24708                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
24709            }
24710        }
24711
24712        #[inline]
24713        unsafe fn decode(
24714            &mut self,
24715            decoder: &mut fidl::encoding::Decoder<
24716                '_,
24717                fidl::encoding::DefaultFuchsiaResourceDialect,
24718            >,
24719            offset: usize,
24720            _depth: fidl::encoding::Depth,
24721        ) -> fidl::Result<()> {
24722            decoder.debug_check_bounds::<Self>(offset);
24723            // Verify that padding bytes are zero.
24724            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
24725            Ok(())
24726        }
24727    }
24728
24729    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
24730        type Borrowed<'a> = &'a mut Self;
24731        fn take_or_borrow<'a>(
24732            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24733        ) -> Self::Borrowed<'a> {
24734            value
24735        }
24736    }
24737
24738    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
24739        type Owned = Self;
24740
24741        #[inline(always)]
24742        fn inline_align(_context: fidl::encoding::Context) -> usize {
24743            4
24744        }
24745
24746        #[inline(always)]
24747        fn inline_size(_context: fidl::encoding::Context) -> usize {
24748            4
24749        }
24750    }
24751
24752    unsafe impl
24753        fidl::encoding::Encode<
24754            AudioRendererSetReferenceClockRequest,
24755            fidl::encoding::DefaultFuchsiaResourceDialect,
24756        > for &mut AudioRendererSetReferenceClockRequest
24757    {
24758        #[inline]
24759        unsafe fn encode(
24760            self,
24761            encoder: &mut fidl::encoding::Encoder<
24762                '_,
24763                fidl::encoding::DefaultFuchsiaResourceDialect,
24764            >,
24765            offset: usize,
24766            _depth: fidl::encoding::Depth,
24767        ) -> fidl::Result<()> {
24768            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
24769            // Delegate to tuple encoding.
24770            fidl::encoding::Encode::<
24771                AudioRendererSetReferenceClockRequest,
24772                fidl::encoding::DefaultFuchsiaResourceDialect,
24773            >::encode(
24774                (<fidl::encoding::Optional<
24775                    fidl::encoding::HandleType<
24776                        fidl::Clock,
24777                        { fidl::ObjectType::CLOCK.into_raw() },
24778                        2147483648,
24779                    >,
24780                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24781                    &mut self.reference_clock,
24782                ),),
24783                encoder,
24784                offset,
24785                _depth,
24786            )
24787        }
24788    }
24789    unsafe impl<
24790        T0: fidl::encoding::Encode<
24791                fidl::encoding::Optional<
24792                    fidl::encoding::HandleType<
24793                        fidl::Clock,
24794                        { fidl::ObjectType::CLOCK.into_raw() },
24795                        2147483648,
24796                    >,
24797                >,
24798                fidl::encoding::DefaultFuchsiaResourceDialect,
24799            >,
24800    >
24801        fidl::encoding::Encode<
24802            AudioRendererSetReferenceClockRequest,
24803            fidl::encoding::DefaultFuchsiaResourceDialect,
24804        > for (T0,)
24805    {
24806        #[inline]
24807        unsafe fn encode(
24808            self,
24809            encoder: &mut fidl::encoding::Encoder<
24810                '_,
24811                fidl::encoding::DefaultFuchsiaResourceDialect,
24812            >,
24813            offset: usize,
24814            depth: fidl::encoding::Depth,
24815        ) -> fidl::Result<()> {
24816            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
24817            // Zero out padding regions. There's no need to apply masks
24818            // because the unmasked parts will be overwritten by fields.
24819            // Write the fields.
24820            self.0.encode(encoder, offset + 0, depth)?;
24821            Ok(())
24822        }
24823    }
24824
24825    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24826        for AudioRendererSetReferenceClockRequest
24827    {
24828        #[inline(always)]
24829        fn new_empty() -> Self {
24830            Self {
24831                reference_clock: fidl::new_empty!(
24832                    fidl::encoding::Optional<
24833                        fidl::encoding::HandleType<
24834                            fidl::Clock,
24835                            { fidl::ObjectType::CLOCK.into_raw() },
24836                            2147483648,
24837                        >,
24838                    >,
24839                    fidl::encoding::DefaultFuchsiaResourceDialect
24840                ),
24841            }
24842        }
24843
24844        #[inline]
24845        unsafe fn decode(
24846            &mut self,
24847            decoder: &mut fidl::encoding::Decoder<
24848                '_,
24849                fidl::encoding::DefaultFuchsiaResourceDialect,
24850            >,
24851            offset: usize,
24852            _depth: fidl::encoding::Depth,
24853        ) -> fidl::Result<()> {
24854            decoder.debug_check_bounds::<Self>(offset);
24855            // Verify that padding bytes are zero.
24856            fidl::decode!(
24857                fidl::encoding::Optional<
24858                    fidl::encoding::HandleType<
24859                        fidl::Clock,
24860                        { fidl::ObjectType::CLOCK.into_raw() },
24861                        2147483648,
24862                    >,
24863                >,
24864                fidl::encoding::DefaultFuchsiaResourceDialect,
24865                &mut self.reference_clock,
24866                decoder,
24867                offset + 0,
24868                _depth
24869            )?;
24870            Ok(())
24871        }
24872    }
24873
24874    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
24875        type Borrowed<'a> = &'a mut Self;
24876        fn take_or_borrow<'a>(
24877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24878        ) -> Self::Borrowed<'a> {
24879            value
24880        }
24881    }
24882
24883    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
24884        type Owned = Self;
24885
24886        #[inline(always)]
24887        fn inline_align(_context: fidl::encoding::Context) -> usize {
24888            8
24889        }
24890
24891        #[inline(always)]
24892        fn inline_size(_context: fidl::encoding::Context) -> usize {
24893            40
24894        }
24895    }
24896
24897    unsafe impl
24898        fidl::encoding::Encode<
24899            ProfileProviderRegisterHandlerWithCapacityRequest,
24900            fidl::encoding::DefaultFuchsiaResourceDialect,
24901        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
24902    {
24903        #[inline]
24904        unsafe fn encode(
24905            self,
24906            encoder: &mut fidl::encoding::Encoder<
24907                '_,
24908                fidl::encoding::DefaultFuchsiaResourceDialect,
24909            >,
24910            offset: usize,
24911            _depth: fidl::encoding::Depth,
24912        ) -> fidl::Result<()> {
24913            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
24914            // Delegate to tuple encoding.
24915            fidl::encoding::Encode::<
24916                ProfileProviderRegisterHandlerWithCapacityRequest,
24917                fidl::encoding::DefaultFuchsiaResourceDialect,
24918            >::encode(
24919                (
24920                    <fidl::encoding::HandleType<
24921                        fidl::Thread,
24922                        { fidl::ObjectType::THREAD.into_raw() },
24923                        2147483648,
24924                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24925                        &mut self.thread_handle,
24926                    ),
24927                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
24928                        &self.name,
24929                    ),
24930                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
24931                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
24932                ),
24933                encoder,
24934                offset,
24935                _depth,
24936            )
24937        }
24938    }
24939    unsafe impl<
24940        T0: fidl::encoding::Encode<
24941                fidl::encoding::HandleType<
24942                    fidl::Thread,
24943                    { fidl::ObjectType::THREAD.into_raw() },
24944                    2147483648,
24945                >,
24946                fidl::encoding::DefaultFuchsiaResourceDialect,
24947            >,
24948        T1: fidl::encoding::Encode<
24949                fidl::encoding::BoundedString<64>,
24950                fidl::encoding::DefaultFuchsiaResourceDialect,
24951            >,
24952        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
24953        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
24954    >
24955        fidl::encoding::Encode<
24956            ProfileProviderRegisterHandlerWithCapacityRequest,
24957            fidl::encoding::DefaultFuchsiaResourceDialect,
24958        > for (T0, T1, T2, T3)
24959    {
24960        #[inline]
24961        unsafe fn encode(
24962            self,
24963            encoder: &mut fidl::encoding::Encoder<
24964                '_,
24965                fidl::encoding::DefaultFuchsiaResourceDialect,
24966            >,
24967            offset: usize,
24968            depth: fidl::encoding::Depth,
24969        ) -> fidl::Result<()> {
24970            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
24971            // Zero out padding regions. There's no need to apply masks
24972            // because the unmasked parts will be overwritten by fields.
24973            unsafe {
24974                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
24975                (ptr as *mut u64).write_unaligned(0);
24976            }
24977            unsafe {
24978                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24979                (ptr as *mut u64).write_unaligned(0);
24980            }
24981            // Write the fields.
24982            self.0.encode(encoder, offset + 0, depth)?;
24983            self.1.encode(encoder, offset + 8, depth)?;
24984            self.2.encode(encoder, offset + 24, depth)?;
24985            self.3.encode(encoder, offset + 32, depth)?;
24986            Ok(())
24987        }
24988    }
24989
24990    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24991        for ProfileProviderRegisterHandlerWithCapacityRequest
24992    {
24993        #[inline(always)]
24994        fn new_empty() -> Self {
24995            Self {
24996                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
24997                name: fidl::new_empty!(
24998                    fidl::encoding::BoundedString<64>,
24999                    fidl::encoding::DefaultFuchsiaResourceDialect
25000                ),
25001                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
25002                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
25003            }
25004        }
25005
25006        #[inline]
25007        unsafe fn decode(
25008            &mut self,
25009            decoder: &mut fidl::encoding::Decoder<
25010                '_,
25011                fidl::encoding::DefaultFuchsiaResourceDialect,
25012            >,
25013            offset: usize,
25014            _depth: fidl::encoding::Depth,
25015        ) -> fidl::Result<()> {
25016            decoder.debug_check_bounds::<Self>(offset);
25017            // Verify that padding bytes are zero.
25018            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25019            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25020            let mask = 0xffffffff00000000u64;
25021            let maskedval = padval & mask;
25022            if maskedval != 0 {
25023                return Err(fidl::Error::NonZeroPadding {
25024                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25025                });
25026            }
25027            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
25028            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25029            let mask = 0xffffffff00000000u64;
25030            let maskedval = padval & mask;
25031            if maskedval != 0 {
25032                return Err(fidl::Error::NonZeroPadding {
25033                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
25034                });
25035            }
25036            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
25037            fidl::decode!(
25038                fidl::encoding::BoundedString<64>,
25039                fidl::encoding::DefaultFuchsiaResourceDialect,
25040                &mut self.name,
25041                decoder,
25042                offset + 8,
25043                _depth
25044            )?;
25045            fidl::decode!(
25046                i64,
25047                fidl::encoding::DefaultFuchsiaResourceDialect,
25048                &mut self.period,
25049                decoder,
25050                offset + 24,
25051                _depth
25052            )?;
25053            fidl::decode!(
25054                f32,
25055                fidl::encoding::DefaultFuchsiaResourceDialect,
25056                &mut self.capacity,
25057                decoder,
25058                offset + 32,
25059                _depth
25060            )?;
25061            Ok(())
25062        }
25063    }
25064
25065    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
25066        type Borrowed<'a> = &'a mut Self;
25067        fn take_or_borrow<'a>(
25068            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25069        ) -> Self::Borrowed<'a> {
25070            value
25071        }
25072    }
25073
25074    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
25075        type Owned = Self;
25076
25077        #[inline(always)]
25078        fn inline_align(_context: fidl::encoding::Context) -> usize {
25079            8
25080        }
25081
25082        #[inline(always)]
25083        fn inline_size(_context: fidl::encoding::Context) -> usize {
25084            24
25085        }
25086    }
25087
25088    unsafe impl
25089        fidl::encoding::Encode<
25090            ProfileProviderRegisterMemoryRangeRequest,
25091            fidl::encoding::DefaultFuchsiaResourceDialect,
25092        > for &mut ProfileProviderRegisterMemoryRangeRequest
25093    {
25094        #[inline]
25095        unsafe fn encode(
25096            self,
25097            encoder: &mut fidl::encoding::Encoder<
25098                '_,
25099                fidl::encoding::DefaultFuchsiaResourceDialect,
25100            >,
25101            offset: usize,
25102            _depth: fidl::encoding::Depth,
25103        ) -> fidl::Result<()> {
25104            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
25105            // Delegate to tuple encoding.
25106            fidl::encoding::Encode::<
25107                ProfileProviderRegisterMemoryRangeRequest,
25108                fidl::encoding::DefaultFuchsiaResourceDialect,
25109            >::encode(
25110                (
25111                    <fidl::encoding::HandleType<
25112                        fidl::Vmar,
25113                        { fidl::ObjectType::VMAR.into_raw() },
25114                        2147483648,
25115                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25116                        &mut self.vmar_handle
25117                    ),
25118                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
25119                        &self.name,
25120                    ),
25121                ),
25122                encoder,
25123                offset,
25124                _depth,
25125            )
25126        }
25127    }
25128    unsafe impl<
25129        T0: fidl::encoding::Encode<
25130                fidl::encoding::HandleType<
25131                    fidl::Vmar,
25132                    { fidl::ObjectType::VMAR.into_raw() },
25133                    2147483648,
25134                >,
25135                fidl::encoding::DefaultFuchsiaResourceDialect,
25136            >,
25137        T1: fidl::encoding::Encode<
25138                fidl::encoding::BoundedString<64>,
25139                fidl::encoding::DefaultFuchsiaResourceDialect,
25140            >,
25141    >
25142        fidl::encoding::Encode<
25143            ProfileProviderRegisterMemoryRangeRequest,
25144            fidl::encoding::DefaultFuchsiaResourceDialect,
25145        > for (T0, T1)
25146    {
25147        #[inline]
25148        unsafe fn encode(
25149            self,
25150            encoder: &mut fidl::encoding::Encoder<
25151                '_,
25152                fidl::encoding::DefaultFuchsiaResourceDialect,
25153            >,
25154            offset: usize,
25155            depth: fidl::encoding::Depth,
25156        ) -> fidl::Result<()> {
25157            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
25158            // Zero out padding regions. There's no need to apply masks
25159            // because the unmasked parts will be overwritten by fields.
25160            unsafe {
25161                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
25162                (ptr as *mut u64).write_unaligned(0);
25163            }
25164            // Write the fields.
25165            self.0.encode(encoder, offset + 0, depth)?;
25166            self.1.encode(encoder, offset + 8, depth)?;
25167            Ok(())
25168        }
25169    }
25170
25171    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25172        for ProfileProviderRegisterMemoryRangeRequest
25173    {
25174        #[inline(always)]
25175        fn new_empty() -> Self {
25176            Self {
25177                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25178                name: fidl::new_empty!(
25179                    fidl::encoding::BoundedString<64>,
25180                    fidl::encoding::DefaultFuchsiaResourceDialect
25181                ),
25182            }
25183        }
25184
25185        #[inline]
25186        unsafe fn decode(
25187            &mut self,
25188            decoder: &mut fidl::encoding::Decoder<
25189                '_,
25190                fidl::encoding::DefaultFuchsiaResourceDialect,
25191            >,
25192            offset: usize,
25193            _depth: fidl::encoding::Depth,
25194        ) -> fidl::Result<()> {
25195            decoder.debug_check_bounds::<Self>(offset);
25196            // Verify that padding bytes are zero.
25197            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25198            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25199            let mask = 0xffffffff00000000u64;
25200            let maskedval = padval & mask;
25201            if maskedval != 0 {
25202                return Err(fidl::Error::NonZeroPadding {
25203                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25204                });
25205            }
25206            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
25207            fidl::decode!(
25208                fidl::encoding::BoundedString<64>,
25209                fidl::encoding::DefaultFuchsiaResourceDialect,
25210                &mut self.name,
25211                decoder,
25212                offset + 8,
25213                _depth
25214            )?;
25215            Ok(())
25216        }
25217    }
25218
25219    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
25220        type Borrowed<'a> = &'a mut Self;
25221        fn take_or_borrow<'a>(
25222            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25223        ) -> Self::Borrowed<'a> {
25224            value
25225        }
25226    }
25227
25228    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
25229        type Owned = Self;
25230
25231        #[inline(always)]
25232        fn inline_align(_context: fidl::encoding::Context) -> usize {
25233            8
25234        }
25235
25236        #[inline(always)]
25237        fn inline_size(_context: fidl::encoding::Context) -> usize {
25238            24
25239        }
25240    }
25241
25242    unsafe impl
25243        fidl::encoding::Encode<
25244            ProfileProviderUnregisterHandlerRequest,
25245            fidl::encoding::DefaultFuchsiaResourceDialect,
25246        > for &mut ProfileProviderUnregisterHandlerRequest
25247    {
25248        #[inline]
25249        unsafe fn encode(
25250            self,
25251            encoder: &mut fidl::encoding::Encoder<
25252                '_,
25253                fidl::encoding::DefaultFuchsiaResourceDialect,
25254            >,
25255            offset: usize,
25256            _depth: fidl::encoding::Depth,
25257        ) -> fidl::Result<()> {
25258            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
25259            // Delegate to tuple encoding.
25260            fidl::encoding::Encode::<
25261                ProfileProviderUnregisterHandlerRequest,
25262                fidl::encoding::DefaultFuchsiaResourceDialect,
25263            >::encode(
25264                (
25265                    <fidl::encoding::HandleType<
25266                        fidl::Thread,
25267                        { fidl::ObjectType::THREAD.into_raw() },
25268                        2147483648,
25269                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25270                        &mut self.thread_handle,
25271                    ),
25272                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
25273                        &self.name,
25274                    ),
25275                ),
25276                encoder,
25277                offset,
25278                _depth,
25279            )
25280        }
25281    }
25282    unsafe impl<
25283        T0: fidl::encoding::Encode<
25284                fidl::encoding::HandleType<
25285                    fidl::Thread,
25286                    { fidl::ObjectType::THREAD.into_raw() },
25287                    2147483648,
25288                >,
25289                fidl::encoding::DefaultFuchsiaResourceDialect,
25290            >,
25291        T1: fidl::encoding::Encode<
25292                fidl::encoding::BoundedString<64>,
25293                fidl::encoding::DefaultFuchsiaResourceDialect,
25294            >,
25295    >
25296        fidl::encoding::Encode<
25297            ProfileProviderUnregisterHandlerRequest,
25298            fidl::encoding::DefaultFuchsiaResourceDialect,
25299        > for (T0, T1)
25300    {
25301        #[inline]
25302        unsafe fn encode(
25303            self,
25304            encoder: &mut fidl::encoding::Encoder<
25305                '_,
25306                fidl::encoding::DefaultFuchsiaResourceDialect,
25307            >,
25308            offset: usize,
25309            depth: fidl::encoding::Depth,
25310        ) -> fidl::Result<()> {
25311            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
25312            // Zero out padding regions. There's no need to apply masks
25313            // because the unmasked parts will be overwritten by fields.
25314            unsafe {
25315                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
25316                (ptr as *mut u64).write_unaligned(0);
25317            }
25318            // Write the fields.
25319            self.0.encode(encoder, offset + 0, depth)?;
25320            self.1.encode(encoder, offset + 8, depth)?;
25321            Ok(())
25322        }
25323    }
25324
25325    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25326        for ProfileProviderUnregisterHandlerRequest
25327    {
25328        #[inline(always)]
25329        fn new_empty() -> Self {
25330            Self {
25331                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25332                name: fidl::new_empty!(
25333                    fidl::encoding::BoundedString<64>,
25334                    fidl::encoding::DefaultFuchsiaResourceDialect
25335                ),
25336            }
25337        }
25338
25339        #[inline]
25340        unsafe fn decode(
25341            &mut self,
25342            decoder: &mut fidl::encoding::Decoder<
25343                '_,
25344                fidl::encoding::DefaultFuchsiaResourceDialect,
25345            >,
25346            offset: usize,
25347            _depth: fidl::encoding::Depth,
25348        ) -> fidl::Result<()> {
25349            decoder.debug_check_bounds::<Self>(offset);
25350            // Verify that padding bytes are zero.
25351            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25352            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25353            let mask = 0xffffffff00000000u64;
25354            let maskedval = padval & mask;
25355            if maskedval != 0 {
25356                return Err(fidl::Error::NonZeroPadding {
25357                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25358                });
25359            }
25360            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
25361            fidl::decode!(
25362                fidl::encoding::BoundedString<64>,
25363                fidl::encoding::DefaultFuchsiaResourceDialect,
25364                &mut self.name,
25365                decoder,
25366                offset + 8,
25367                _depth
25368            )?;
25369            Ok(())
25370        }
25371    }
25372
25373    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
25374        type Borrowed<'a> = &'a mut Self;
25375        fn take_or_borrow<'a>(
25376            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25377        ) -> Self::Borrowed<'a> {
25378            value
25379        }
25380    }
25381
25382    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
25383        type Owned = Self;
25384
25385        #[inline(always)]
25386        fn inline_align(_context: fidl::encoding::Context) -> usize {
25387            4
25388        }
25389
25390        #[inline(always)]
25391        fn inline_size(_context: fidl::encoding::Context) -> usize {
25392            4
25393        }
25394    }
25395
25396    unsafe impl
25397        fidl::encoding::Encode<
25398            ProfileProviderUnregisterMemoryRangeRequest,
25399            fidl::encoding::DefaultFuchsiaResourceDialect,
25400        > for &mut ProfileProviderUnregisterMemoryRangeRequest
25401    {
25402        #[inline]
25403        unsafe fn encode(
25404            self,
25405            encoder: &mut fidl::encoding::Encoder<
25406                '_,
25407                fidl::encoding::DefaultFuchsiaResourceDialect,
25408            >,
25409            offset: usize,
25410            _depth: fidl::encoding::Depth,
25411        ) -> fidl::Result<()> {
25412            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
25413            // Delegate to tuple encoding.
25414            fidl::encoding::Encode::<
25415                ProfileProviderUnregisterMemoryRangeRequest,
25416                fidl::encoding::DefaultFuchsiaResourceDialect,
25417            >::encode(
25418                (<fidl::encoding::HandleType<
25419                    fidl::Vmar,
25420                    { fidl::ObjectType::VMAR.into_raw() },
25421                    2147483648,
25422                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25423                    &mut self.vmar_handle
25424                ),),
25425                encoder,
25426                offset,
25427                _depth,
25428            )
25429        }
25430    }
25431    unsafe impl<
25432        T0: fidl::encoding::Encode<
25433                fidl::encoding::HandleType<
25434                    fidl::Vmar,
25435                    { fidl::ObjectType::VMAR.into_raw() },
25436                    2147483648,
25437                >,
25438                fidl::encoding::DefaultFuchsiaResourceDialect,
25439            >,
25440    >
25441        fidl::encoding::Encode<
25442            ProfileProviderUnregisterMemoryRangeRequest,
25443            fidl::encoding::DefaultFuchsiaResourceDialect,
25444        > for (T0,)
25445    {
25446        #[inline]
25447        unsafe fn encode(
25448            self,
25449            encoder: &mut fidl::encoding::Encoder<
25450                '_,
25451                fidl::encoding::DefaultFuchsiaResourceDialect,
25452            >,
25453            offset: usize,
25454            depth: fidl::encoding::Depth,
25455        ) -> fidl::Result<()> {
25456            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
25457            // Zero out padding regions. There's no need to apply masks
25458            // because the unmasked parts will be overwritten by fields.
25459            // Write the fields.
25460            self.0.encode(encoder, offset + 0, depth)?;
25461            Ok(())
25462        }
25463    }
25464
25465    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25466        for ProfileProviderUnregisterMemoryRangeRequest
25467    {
25468        #[inline(always)]
25469        fn new_empty() -> Self {
25470            Self {
25471                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25472            }
25473        }
25474
25475        #[inline]
25476        unsafe fn decode(
25477            &mut self,
25478            decoder: &mut fidl::encoding::Decoder<
25479                '_,
25480                fidl::encoding::DefaultFuchsiaResourceDialect,
25481            >,
25482            offset: usize,
25483            _depth: fidl::encoding::Depth,
25484        ) -> fidl::Result<()> {
25485            decoder.debug_check_bounds::<Self>(offset);
25486            // Verify that padding bytes are zero.
25487            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
25488            Ok(())
25489        }
25490    }
25491
25492    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
25493        type Borrowed<'a> = &'a mut Self;
25494        fn take_or_borrow<'a>(
25495            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25496        ) -> Self::Borrowed<'a> {
25497            value
25498        }
25499    }
25500
25501    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
25502        type Owned = Self;
25503
25504        #[inline(always)]
25505        fn inline_align(_context: fidl::encoding::Context) -> usize {
25506            8
25507        }
25508
25509        #[inline(always)]
25510        fn inline_size(_context: fidl::encoding::Context) -> usize {
25511            16
25512        }
25513    }
25514
25515    unsafe impl
25516        fidl::encoding::Encode<
25517            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
25518            fidl::encoding::DefaultFuchsiaResourceDialect,
25519        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
25520    {
25521        #[inline]
25522        unsafe fn encode(
25523            self,
25524            encoder: &mut fidl::encoding::Encoder<
25525                '_,
25526                fidl::encoding::DefaultFuchsiaResourceDialect,
25527            >,
25528            offset: usize,
25529            _depth: fidl::encoding::Depth,
25530        ) -> fidl::Result<()> {
25531            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
25532                offset,
25533            );
25534            // Delegate to tuple encoding.
25535            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
25536                (
25537                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
25538                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
25539                ),
25540                encoder, offset, _depth
25541            )
25542        }
25543    }
25544    unsafe impl<
25545        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
25546        T1: fidl::encoding::Encode<
25547                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25548                fidl::encoding::DefaultFuchsiaResourceDialect,
25549            >,
25550    >
25551        fidl::encoding::Encode<
25552            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
25553            fidl::encoding::DefaultFuchsiaResourceDialect,
25554        > for (T0, T1)
25555    {
25556        #[inline]
25557        unsafe fn encode(
25558            self,
25559            encoder: &mut fidl::encoding::Encoder<
25560                '_,
25561                fidl::encoding::DefaultFuchsiaResourceDialect,
25562            >,
25563            offset: usize,
25564            depth: fidl::encoding::Depth,
25565        ) -> fidl::Result<()> {
25566            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
25567                offset,
25568            );
25569            // Zero out padding regions. There's no need to apply masks
25570            // because the unmasked parts will be overwritten by fields.
25571            unsafe {
25572                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
25573                (ptr as *mut u64).write_unaligned(0);
25574            }
25575            // Write the fields.
25576            self.0.encode(encoder, offset + 0, depth)?;
25577            self.1.encode(encoder, offset + 8, depth)?;
25578            Ok(())
25579        }
25580    }
25581
25582    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25583        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
25584    {
25585        #[inline(always)]
25586        fn new_empty() -> Self {
25587            Self {
25588                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
25589                audio_consumer_request: fidl::new_empty!(
25590                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25591                    fidl::encoding::DefaultFuchsiaResourceDialect
25592                ),
25593            }
25594        }
25595
25596        #[inline]
25597        unsafe fn decode(
25598            &mut self,
25599            decoder: &mut fidl::encoding::Decoder<
25600                '_,
25601                fidl::encoding::DefaultFuchsiaResourceDialect,
25602            >,
25603            offset: usize,
25604            _depth: fidl::encoding::Depth,
25605        ) -> fidl::Result<()> {
25606            decoder.debug_check_bounds::<Self>(offset);
25607            // Verify that padding bytes are zero.
25608            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
25609            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25610            let mask = 0xffffffff00000000u64;
25611            let maskedval = padval & mask;
25612            if maskedval != 0 {
25613                return Err(fidl::Error::NonZeroPadding {
25614                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
25615                });
25616            }
25617            fidl::decode!(
25618                u64,
25619                fidl::encoding::DefaultFuchsiaResourceDialect,
25620                &mut self.session_id,
25621                decoder,
25622                offset + 0,
25623                _depth
25624            )?;
25625            fidl::decode!(
25626                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25627                fidl::encoding::DefaultFuchsiaResourceDialect,
25628                &mut self.audio_consumer_request,
25629                decoder,
25630                offset + 8,
25631                _depth
25632            )?;
25633            Ok(())
25634        }
25635    }
25636
25637    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
25638        type Borrowed<'a> = &'a mut Self;
25639        fn take_or_borrow<'a>(
25640            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25641        ) -> Self::Borrowed<'a> {
25642            value
25643        }
25644    }
25645
25646    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
25647        type Owned = Self;
25648
25649        #[inline(always)]
25650        fn inline_align(_context: fidl::encoding::Context) -> usize {
25651            4
25652        }
25653
25654        #[inline(always)]
25655        fn inline_size(_context: fidl::encoding::Context) -> usize {
25656            8
25657        }
25658    }
25659
25660    unsafe impl
25661        fidl::encoding::Encode<
25662            StreamBufferSetAddPayloadBufferRequest,
25663            fidl::encoding::DefaultFuchsiaResourceDialect,
25664        > for &mut StreamBufferSetAddPayloadBufferRequest
25665    {
25666        #[inline]
25667        unsafe fn encode(
25668            self,
25669            encoder: &mut fidl::encoding::Encoder<
25670                '_,
25671                fidl::encoding::DefaultFuchsiaResourceDialect,
25672            >,
25673            offset: usize,
25674            _depth: fidl::encoding::Depth,
25675        ) -> fidl::Result<()> {
25676            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
25677            // Delegate to tuple encoding.
25678            fidl::encoding::Encode::<
25679                StreamBufferSetAddPayloadBufferRequest,
25680                fidl::encoding::DefaultFuchsiaResourceDialect,
25681            >::encode(
25682                (
25683                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
25684                    <fidl::encoding::HandleType<
25685                        fidl::Vmo,
25686                        { fidl::ObjectType::VMO.into_raw() },
25687                        2147483648,
25688                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25689                        &mut self.payload_buffer,
25690                    ),
25691                ),
25692                encoder,
25693                offset,
25694                _depth,
25695            )
25696        }
25697    }
25698    unsafe impl<
25699        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
25700        T1: fidl::encoding::Encode<
25701                fidl::encoding::HandleType<
25702                    fidl::Vmo,
25703                    { fidl::ObjectType::VMO.into_raw() },
25704                    2147483648,
25705                >,
25706                fidl::encoding::DefaultFuchsiaResourceDialect,
25707            >,
25708    >
25709        fidl::encoding::Encode<
25710            StreamBufferSetAddPayloadBufferRequest,
25711            fidl::encoding::DefaultFuchsiaResourceDialect,
25712        > for (T0, T1)
25713    {
25714        #[inline]
25715        unsafe fn encode(
25716            self,
25717            encoder: &mut fidl::encoding::Encoder<
25718                '_,
25719                fidl::encoding::DefaultFuchsiaResourceDialect,
25720            >,
25721            offset: usize,
25722            depth: fidl::encoding::Depth,
25723        ) -> fidl::Result<()> {
25724            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
25725            // Zero out padding regions. There's no need to apply masks
25726            // because the unmasked parts will be overwritten by fields.
25727            // Write the fields.
25728            self.0.encode(encoder, offset + 0, depth)?;
25729            self.1.encode(encoder, offset + 4, depth)?;
25730            Ok(())
25731        }
25732    }
25733
25734    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25735        for StreamBufferSetAddPayloadBufferRequest
25736    {
25737        #[inline(always)]
25738        fn new_empty() -> Self {
25739            Self {
25740                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
25741                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25742            }
25743        }
25744
25745        #[inline]
25746        unsafe fn decode(
25747            &mut self,
25748            decoder: &mut fidl::encoding::Decoder<
25749                '_,
25750                fidl::encoding::DefaultFuchsiaResourceDialect,
25751            >,
25752            offset: usize,
25753            _depth: fidl::encoding::Depth,
25754        ) -> fidl::Result<()> {
25755            decoder.debug_check_bounds::<Self>(offset);
25756            // Verify that padding bytes are zero.
25757            fidl::decode!(
25758                u32,
25759                fidl::encoding::DefaultFuchsiaResourceDialect,
25760                &mut self.id,
25761                decoder,
25762                offset + 0,
25763                _depth
25764            )?;
25765            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
25766            Ok(())
25767        }
25768    }
25769
25770    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
25771        type Borrowed<'a> = &'a mut Self;
25772        fn take_or_borrow<'a>(
25773            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25774        ) -> Self::Borrowed<'a> {
25775            value
25776        }
25777    }
25778
25779    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
25780        type Owned = Self;
25781
25782        #[inline(always)]
25783        fn inline_align(_context: fidl::encoding::Context) -> usize {
25784            8
25785        }
25786
25787        #[inline(always)]
25788        fn inline_size(_context: fidl::encoding::Context) -> usize {
25789            16
25790        }
25791    }
25792
25793    unsafe impl
25794        fidl::encoding::Encode<
25795            StreamProcessorSetInputBufferPartialSettingsRequest,
25796            fidl::encoding::DefaultFuchsiaResourceDialect,
25797        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
25798    {
25799        #[inline]
25800        unsafe fn encode(
25801            self,
25802            encoder: &mut fidl::encoding::Encoder<
25803                '_,
25804                fidl::encoding::DefaultFuchsiaResourceDialect,
25805            >,
25806            offset: usize,
25807            _depth: fidl::encoding::Depth,
25808        ) -> fidl::Result<()> {
25809            encoder
25810                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
25811            // Delegate to tuple encoding.
25812            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
25813                (
25814                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
25815                ),
25816                encoder, offset, _depth
25817            )
25818        }
25819    }
25820    unsafe impl<
25821        T0: fidl::encoding::Encode<
25822                StreamBufferPartialSettings,
25823                fidl::encoding::DefaultFuchsiaResourceDialect,
25824            >,
25825    >
25826        fidl::encoding::Encode<
25827            StreamProcessorSetInputBufferPartialSettingsRequest,
25828            fidl::encoding::DefaultFuchsiaResourceDialect,
25829        > for (T0,)
25830    {
25831        #[inline]
25832        unsafe fn encode(
25833            self,
25834            encoder: &mut fidl::encoding::Encoder<
25835                '_,
25836                fidl::encoding::DefaultFuchsiaResourceDialect,
25837            >,
25838            offset: usize,
25839            depth: fidl::encoding::Depth,
25840        ) -> fidl::Result<()> {
25841            encoder
25842                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
25843            // Zero out padding regions. There's no need to apply masks
25844            // because the unmasked parts will be overwritten by fields.
25845            // Write the fields.
25846            self.0.encode(encoder, offset + 0, depth)?;
25847            Ok(())
25848        }
25849    }
25850
25851    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25852        for StreamProcessorSetInputBufferPartialSettingsRequest
25853    {
25854        #[inline(always)]
25855        fn new_empty() -> Self {
25856            Self {
25857                input_settings: fidl::new_empty!(
25858                    StreamBufferPartialSettings,
25859                    fidl::encoding::DefaultFuchsiaResourceDialect
25860                ),
25861            }
25862        }
25863
25864        #[inline]
25865        unsafe fn decode(
25866            &mut self,
25867            decoder: &mut fidl::encoding::Decoder<
25868                '_,
25869                fidl::encoding::DefaultFuchsiaResourceDialect,
25870            >,
25871            offset: usize,
25872            _depth: fidl::encoding::Depth,
25873        ) -> fidl::Result<()> {
25874            decoder.debug_check_bounds::<Self>(offset);
25875            // Verify that padding bytes are zero.
25876            fidl::decode!(
25877                StreamBufferPartialSettings,
25878                fidl::encoding::DefaultFuchsiaResourceDialect,
25879                &mut self.input_settings,
25880                decoder,
25881                offset + 0,
25882                _depth
25883            )?;
25884            Ok(())
25885        }
25886    }
25887
25888    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
25889        type Borrowed<'a> = &'a mut Self;
25890        fn take_or_borrow<'a>(
25891            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25892        ) -> Self::Borrowed<'a> {
25893            value
25894        }
25895    }
25896
25897    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
25898        type Owned = Self;
25899
25900        #[inline(always)]
25901        fn inline_align(_context: fidl::encoding::Context) -> usize {
25902            8
25903        }
25904
25905        #[inline(always)]
25906        fn inline_size(_context: fidl::encoding::Context) -> usize {
25907            16
25908        }
25909    }
25910
25911    unsafe impl
25912        fidl::encoding::Encode<
25913            StreamProcessorSetOutputBufferPartialSettingsRequest,
25914            fidl::encoding::DefaultFuchsiaResourceDialect,
25915        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
25916    {
25917        #[inline]
25918        unsafe fn encode(
25919            self,
25920            encoder: &mut fidl::encoding::Encoder<
25921                '_,
25922                fidl::encoding::DefaultFuchsiaResourceDialect,
25923            >,
25924            offset: usize,
25925            _depth: fidl::encoding::Depth,
25926        ) -> fidl::Result<()> {
25927            encoder
25928                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
25929            // Delegate to tuple encoding.
25930            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
25931                (
25932                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
25933                ),
25934                encoder, offset, _depth
25935            )
25936        }
25937    }
25938    unsafe impl<
25939        T0: fidl::encoding::Encode<
25940                StreamBufferPartialSettings,
25941                fidl::encoding::DefaultFuchsiaResourceDialect,
25942            >,
25943    >
25944        fidl::encoding::Encode<
25945            StreamProcessorSetOutputBufferPartialSettingsRequest,
25946            fidl::encoding::DefaultFuchsiaResourceDialect,
25947        > for (T0,)
25948    {
25949        #[inline]
25950        unsafe fn encode(
25951            self,
25952            encoder: &mut fidl::encoding::Encoder<
25953                '_,
25954                fidl::encoding::DefaultFuchsiaResourceDialect,
25955            >,
25956            offset: usize,
25957            depth: fidl::encoding::Depth,
25958        ) -> fidl::Result<()> {
25959            encoder
25960                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
25961            // Zero out padding regions. There's no need to apply masks
25962            // because the unmasked parts will be overwritten by fields.
25963            // Write the fields.
25964            self.0.encode(encoder, offset + 0, depth)?;
25965            Ok(())
25966        }
25967    }
25968
25969    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25970        for StreamProcessorSetOutputBufferPartialSettingsRequest
25971    {
25972        #[inline(always)]
25973        fn new_empty() -> Self {
25974            Self {
25975                output_settings: fidl::new_empty!(
25976                    StreamBufferPartialSettings,
25977                    fidl::encoding::DefaultFuchsiaResourceDialect
25978                ),
25979            }
25980        }
25981
25982        #[inline]
25983        unsafe fn decode(
25984            &mut self,
25985            decoder: &mut fidl::encoding::Decoder<
25986                '_,
25987                fidl::encoding::DefaultFuchsiaResourceDialect,
25988            >,
25989            offset: usize,
25990            _depth: fidl::encoding::Depth,
25991        ) -> fidl::Result<()> {
25992            decoder.debug_check_bounds::<Self>(offset);
25993            // Verify that padding bytes are zero.
25994            fidl::decode!(
25995                StreamBufferPartialSettings,
25996                fidl::encoding::DefaultFuchsiaResourceDialect,
25997                &mut self.output_settings,
25998                decoder,
25999                offset + 0,
26000                _depth
26001            )?;
26002            Ok(())
26003        }
26004    }
26005
26006    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
26007        type Borrowed<'a> = &'a mut Self;
26008        fn take_or_borrow<'a>(
26009            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26010        ) -> Self::Borrowed<'a> {
26011            value
26012        }
26013    }
26014
26015    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
26016        type Owned = Self;
26017
26018        #[inline(always)]
26019        fn inline_align(_context: fidl::encoding::Context) -> usize {
26020            4
26021        }
26022
26023        #[inline(always)]
26024        fn inline_size(_context: fidl::encoding::Context) -> usize {
26025            8
26026        }
26027    }
26028
26029    unsafe impl
26030        fidl::encoding::Encode<
26031            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
26032            fidl::encoding::DefaultFuchsiaResourceDialect,
26033        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
26034    {
26035        #[inline]
26036        unsafe fn encode(
26037            self,
26038            encoder: &mut fidl::encoding::Encoder<
26039                '_,
26040                fidl::encoding::DefaultFuchsiaResourceDialect,
26041            >,
26042            offset: usize,
26043            _depth: fidl::encoding::Depth,
26044        ) -> fidl::Result<()> {
26045            encoder
26046                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26047            // Delegate to tuple encoding.
26048            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26049                (
26050                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26051                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
26052                ),
26053                encoder, offset, _depth
26054            )
26055        }
26056    }
26057    unsafe impl<
26058        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26059        T1: fidl::encoding::Encode<
26060                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26061                fidl::encoding::DefaultFuchsiaResourceDialect,
26062            >,
26063    >
26064        fidl::encoding::Encode<
26065            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
26066            fidl::encoding::DefaultFuchsiaResourceDialect,
26067        > for (T0, T1)
26068    {
26069        #[inline]
26070        unsafe fn encode(
26071            self,
26072            encoder: &mut fidl::encoding::Encoder<
26073                '_,
26074                fidl::encoding::DefaultFuchsiaResourceDialect,
26075            >,
26076            offset: usize,
26077            depth: fidl::encoding::Depth,
26078        ) -> fidl::Result<()> {
26079            encoder
26080                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26081            // Zero out padding regions. There's no need to apply masks
26082            // because the unmasked parts will be overwritten by fields.
26083            // Write the fields.
26084            self.0.encode(encoder, offset + 0, depth)?;
26085            self.1.encode(encoder, offset + 4, depth)?;
26086            Ok(())
26087        }
26088    }
26089
26090    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26091        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
26092    {
26093        #[inline(always)]
26094        fn new_empty() -> Self {
26095            Self {
26096                usage: fidl::new_empty!(
26097                    AudioRenderUsage2,
26098                    fidl::encoding::DefaultFuchsiaResourceDialect
26099                ),
26100                audio_consumer_request: fidl::new_empty!(
26101                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26102                    fidl::encoding::DefaultFuchsiaResourceDialect
26103                ),
26104            }
26105        }
26106
26107        #[inline]
26108        unsafe fn decode(
26109            &mut self,
26110            decoder: &mut fidl::encoding::Decoder<
26111                '_,
26112                fidl::encoding::DefaultFuchsiaResourceDialect,
26113            >,
26114            offset: usize,
26115            _depth: fidl::encoding::Depth,
26116        ) -> fidl::Result<()> {
26117            decoder.debug_check_bounds::<Self>(offset);
26118            // Verify that padding bytes are zero.
26119            fidl::decode!(
26120                AudioRenderUsage2,
26121                fidl::encoding::DefaultFuchsiaResourceDialect,
26122                &mut self.usage,
26123                decoder,
26124                offset + 0,
26125                _depth
26126            )?;
26127            fidl::decode!(
26128                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26129                fidl::encoding::DefaultFuchsiaResourceDialect,
26130                &mut self.audio_consumer_request,
26131                decoder,
26132                offset + 4,
26133                _depth
26134            )?;
26135            Ok(())
26136        }
26137    }
26138
26139    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
26140        type Borrowed<'a> = &'a mut Self;
26141        fn take_or_borrow<'a>(
26142            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26143        ) -> Self::Borrowed<'a> {
26144            value
26145        }
26146    }
26147
26148    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
26149        type Owned = Self;
26150
26151        #[inline(always)]
26152        fn inline_align(_context: fidl::encoding::Context) -> usize {
26153            4
26154        }
26155
26156        #[inline(always)]
26157        fn inline_size(_context: fidl::encoding::Context) -> usize {
26158            8
26159        }
26160    }
26161
26162    unsafe impl
26163        fidl::encoding::Encode<
26164            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
26165            fidl::encoding::DefaultFuchsiaResourceDialect,
26166        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
26167    {
26168        #[inline]
26169        unsafe fn encode(
26170            self,
26171            encoder: &mut fidl::encoding::Encoder<
26172                '_,
26173                fidl::encoding::DefaultFuchsiaResourceDialect,
26174            >,
26175            offset: usize,
26176            _depth: fidl::encoding::Depth,
26177        ) -> fidl::Result<()> {
26178            encoder
26179                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26180            // Delegate to tuple encoding.
26181            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26182                (
26183                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26184                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
26185                ),
26186                encoder, offset, _depth
26187            )
26188        }
26189    }
26190    unsafe impl<
26191        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26192        T1: fidl::encoding::Encode<
26193                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26194                fidl::encoding::DefaultFuchsiaResourceDialect,
26195            >,
26196    >
26197        fidl::encoding::Encode<
26198            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
26199            fidl::encoding::DefaultFuchsiaResourceDialect,
26200        > for (T0, T1)
26201    {
26202        #[inline]
26203        unsafe fn encode(
26204            self,
26205            encoder: &mut fidl::encoding::Encoder<
26206                '_,
26207                fidl::encoding::DefaultFuchsiaResourceDialect,
26208            >,
26209            offset: usize,
26210            depth: fidl::encoding::Depth,
26211        ) -> fidl::Result<()> {
26212            encoder
26213                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26214            // Zero out padding regions. There's no need to apply masks
26215            // because the unmasked parts will be overwritten by fields.
26216            // Write the fields.
26217            self.0.encode(encoder, offset + 0, depth)?;
26218            self.1.encode(encoder, offset + 4, depth)?;
26219            Ok(())
26220        }
26221    }
26222
26223    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26224        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
26225    {
26226        #[inline(always)]
26227        fn new_empty() -> Self {
26228            Self {
26229                usage: fidl::new_empty!(
26230                    AudioRenderUsage,
26231                    fidl::encoding::DefaultFuchsiaResourceDialect
26232                ),
26233                audio_consumer_request: fidl::new_empty!(
26234                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26235                    fidl::encoding::DefaultFuchsiaResourceDialect
26236                ),
26237            }
26238        }
26239
26240        #[inline]
26241        unsafe fn decode(
26242            &mut self,
26243            decoder: &mut fidl::encoding::Decoder<
26244                '_,
26245                fidl::encoding::DefaultFuchsiaResourceDialect,
26246            >,
26247            offset: usize,
26248            _depth: fidl::encoding::Depth,
26249        ) -> fidl::Result<()> {
26250            decoder.debug_check_bounds::<Self>(offset);
26251            // Verify that padding bytes are zero.
26252            fidl::decode!(
26253                AudioRenderUsage,
26254                fidl::encoding::DefaultFuchsiaResourceDialect,
26255                &mut self.usage,
26256                decoder,
26257                offset + 0,
26258                _depth
26259            )?;
26260            fidl::decode!(
26261                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26262                fidl::encoding::DefaultFuchsiaResourceDialect,
26263                &mut self.audio_consumer_request,
26264                decoder,
26265                offset + 4,
26266                _depth
26267            )?;
26268            Ok(())
26269        }
26270    }
26271
26272    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
26273        type Borrowed<'a> = &'a mut Self;
26274        fn take_or_borrow<'a>(
26275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26276        ) -> Self::Borrowed<'a> {
26277            value
26278        }
26279    }
26280
26281    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
26282        type Owned = Self;
26283
26284        #[inline(always)]
26285        fn inline_align(_context: fidl::encoding::Context) -> usize {
26286            8
26287        }
26288
26289        #[inline(always)]
26290        fn inline_size(_context: fidl::encoding::Context) -> usize {
26291            40
26292        }
26293    }
26294
26295    unsafe impl
26296        fidl::encoding::Encode<
26297            UsageGainReporterRegisterListener2Request,
26298            fidl::encoding::DefaultFuchsiaResourceDialect,
26299        > for &mut UsageGainReporterRegisterListener2Request
26300    {
26301        #[inline]
26302        unsafe fn encode(
26303            self,
26304            encoder: &mut fidl::encoding::Encoder<
26305                '_,
26306                fidl::encoding::DefaultFuchsiaResourceDialect,
26307            >,
26308            offset: usize,
26309            _depth: fidl::encoding::Depth,
26310        ) -> fidl::Result<()> {
26311            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
26312            // Delegate to tuple encoding.
26313            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26314                (
26315                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
26316                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26317                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
26318                ),
26319                encoder, offset, _depth
26320            )
26321        }
26322    }
26323    unsafe impl<
26324        T0: fidl::encoding::Encode<
26325                fidl::encoding::BoundedString<36>,
26326                fidl::encoding::DefaultFuchsiaResourceDialect,
26327            >,
26328        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26329        T2: fidl::encoding::Encode<
26330                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26331                fidl::encoding::DefaultFuchsiaResourceDialect,
26332            >,
26333    >
26334        fidl::encoding::Encode<
26335            UsageGainReporterRegisterListener2Request,
26336            fidl::encoding::DefaultFuchsiaResourceDialect,
26337        > for (T0, T1, T2)
26338    {
26339        #[inline]
26340        unsafe fn encode(
26341            self,
26342            encoder: &mut fidl::encoding::Encoder<
26343                '_,
26344                fidl::encoding::DefaultFuchsiaResourceDialect,
26345            >,
26346            offset: usize,
26347            depth: fidl::encoding::Depth,
26348        ) -> fidl::Result<()> {
26349            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
26350            // Zero out padding regions. There's no need to apply masks
26351            // because the unmasked parts will be overwritten by fields.
26352            unsafe {
26353                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
26354                (ptr as *mut u64).write_unaligned(0);
26355            }
26356            // Write the fields.
26357            self.0.encode(encoder, offset + 0, depth)?;
26358            self.1.encode(encoder, offset + 16, depth)?;
26359            self.2.encode(encoder, offset + 32, depth)?;
26360            Ok(())
26361        }
26362    }
26363
26364    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26365        for UsageGainReporterRegisterListener2Request
26366    {
26367        #[inline(always)]
26368        fn new_empty() -> Self {
26369            Self {
26370                device_unique_id: fidl::new_empty!(
26371                    fidl::encoding::BoundedString<36>,
26372                    fidl::encoding::DefaultFuchsiaResourceDialect
26373                ),
26374                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
26375                usage_gain_listener: fidl::new_empty!(
26376                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26377                    fidl::encoding::DefaultFuchsiaResourceDialect
26378                ),
26379            }
26380        }
26381
26382        #[inline]
26383        unsafe fn decode(
26384            &mut self,
26385            decoder: &mut fidl::encoding::Decoder<
26386                '_,
26387                fidl::encoding::DefaultFuchsiaResourceDialect,
26388            >,
26389            offset: usize,
26390            _depth: fidl::encoding::Depth,
26391        ) -> fidl::Result<()> {
26392            decoder.debug_check_bounds::<Self>(offset);
26393            // Verify that padding bytes are zero.
26394            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
26395            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26396            let mask = 0xffffffff00000000u64;
26397            let maskedval = padval & mask;
26398            if maskedval != 0 {
26399                return Err(fidl::Error::NonZeroPadding {
26400                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
26401                });
26402            }
26403            fidl::decode!(
26404                fidl::encoding::BoundedString<36>,
26405                fidl::encoding::DefaultFuchsiaResourceDialect,
26406                &mut self.device_unique_id,
26407                decoder,
26408                offset + 0,
26409                _depth
26410            )?;
26411            fidl::decode!(
26412                Usage2,
26413                fidl::encoding::DefaultFuchsiaResourceDialect,
26414                &mut self.usage,
26415                decoder,
26416                offset + 16,
26417                _depth
26418            )?;
26419            fidl::decode!(
26420                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26421                fidl::encoding::DefaultFuchsiaResourceDialect,
26422                &mut self.usage_gain_listener,
26423                decoder,
26424                offset + 32,
26425                _depth
26426            )?;
26427            Ok(())
26428        }
26429    }
26430
26431    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
26432        type Borrowed<'a> = &'a mut Self;
26433        fn take_or_borrow<'a>(
26434            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26435        ) -> Self::Borrowed<'a> {
26436            value
26437        }
26438    }
26439
26440    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
26441        type Owned = Self;
26442
26443        #[inline(always)]
26444        fn inline_align(_context: fidl::encoding::Context) -> usize {
26445            8
26446        }
26447
26448        #[inline(always)]
26449        fn inline_size(_context: fidl::encoding::Context) -> usize {
26450            40
26451        }
26452    }
26453
26454    unsafe impl
26455        fidl::encoding::Encode<
26456            UsageGainReporterRegisterListenerRequest,
26457            fidl::encoding::DefaultFuchsiaResourceDialect,
26458        > for &mut UsageGainReporterRegisterListenerRequest
26459    {
26460        #[inline]
26461        unsafe fn encode(
26462            self,
26463            encoder: &mut fidl::encoding::Encoder<
26464                '_,
26465                fidl::encoding::DefaultFuchsiaResourceDialect,
26466            >,
26467            offset: usize,
26468            _depth: fidl::encoding::Depth,
26469        ) -> fidl::Result<()> {
26470            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
26471            // Delegate to tuple encoding.
26472            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26473                (
26474                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
26475                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26476                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
26477                ),
26478                encoder, offset, _depth
26479            )
26480        }
26481    }
26482    unsafe impl<
26483        T0: fidl::encoding::Encode<
26484                fidl::encoding::BoundedString<36>,
26485                fidl::encoding::DefaultFuchsiaResourceDialect,
26486            >,
26487        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26488        T2: fidl::encoding::Encode<
26489                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26490                fidl::encoding::DefaultFuchsiaResourceDialect,
26491            >,
26492    >
26493        fidl::encoding::Encode<
26494            UsageGainReporterRegisterListenerRequest,
26495            fidl::encoding::DefaultFuchsiaResourceDialect,
26496        > for (T0, T1, T2)
26497    {
26498        #[inline]
26499        unsafe fn encode(
26500            self,
26501            encoder: &mut fidl::encoding::Encoder<
26502                '_,
26503                fidl::encoding::DefaultFuchsiaResourceDialect,
26504            >,
26505            offset: usize,
26506            depth: fidl::encoding::Depth,
26507        ) -> fidl::Result<()> {
26508            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
26509            // Zero out padding regions. There's no need to apply masks
26510            // because the unmasked parts will be overwritten by fields.
26511            unsafe {
26512                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
26513                (ptr as *mut u64).write_unaligned(0);
26514            }
26515            // Write the fields.
26516            self.0.encode(encoder, offset + 0, depth)?;
26517            self.1.encode(encoder, offset + 16, depth)?;
26518            self.2.encode(encoder, offset + 32, depth)?;
26519            Ok(())
26520        }
26521    }
26522
26523    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26524        for UsageGainReporterRegisterListenerRequest
26525    {
26526        #[inline(always)]
26527        fn new_empty() -> Self {
26528            Self {
26529                device_unique_id: fidl::new_empty!(
26530                    fidl::encoding::BoundedString<36>,
26531                    fidl::encoding::DefaultFuchsiaResourceDialect
26532                ),
26533                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
26534                usage_gain_listener: fidl::new_empty!(
26535                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26536                    fidl::encoding::DefaultFuchsiaResourceDialect
26537                ),
26538            }
26539        }
26540
26541        #[inline]
26542        unsafe fn decode(
26543            &mut self,
26544            decoder: &mut fidl::encoding::Decoder<
26545                '_,
26546                fidl::encoding::DefaultFuchsiaResourceDialect,
26547            >,
26548            offset: usize,
26549            _depth: fidl::encoding::Depth,
26550        ) -> fidl::Result<()> {
26551            decoder.debug_check_bounds::<Self>(offset);
26552            // Verify that padding bytes are zero.
26553            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
26554            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26555            let mask = 0xffffffff00000000u64;
26556            let maskedval = padval & mask;
26557            if maskedval != 0 {
26558                return Err(fidl::Error::NonZeroPadding {
26559                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
26560                });
26561            }
26562            fidl::decode!(
26563                fidl::encoding::BoundedString<36>,
26564                fidl::encoding::DefaultFuchsiaResourceDialect,
26565                &mut self.device_unique_id,
26566                decoder,
26567                offset + 0,
26568                _depth
26569            )?;
26570            fidl::decode!(
26571                Usage,
26572                fidl::encoding::DefaultFuchsiaResourceDialect,
26573                &mut self.usage,
26574                decoder,
26575                offset + 16,
26576                _depth
26577            )?;
26578            fidl::decode!(
26579                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26580                fidl::encoding::DefaultFuchsiaResourceDialect,
26581                &mut self.usage_gain_listener,
26582                decoder,
26583                offset + 32,
26584                _depth
26585            )?;
26586            Ok(())
26587        }
26588    }
26589
26590    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
26591        type Borrowed<'a> = &'a mut Self;
26592        fn take_or_borrow<'a>(
26593            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26594        ) -> Self::Borrowed<'a> {
26595            value
26596        }
26597    }
26598
26599    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
26600        type Owned = Self;
26601
26602        #[inline(always)]
26603        fn inline_align(_context: fidl::encoding::Context) -> usize {
26604            8
26605        }
26606
26607        #[inline(always)]
26608        fn inline_size(_context: fidl::encoding::Context) -> usize {
26609            24
26610        }
26611    }
26612
26613    unsafe impl
26614        fidl::encoding::Encode<
26615            UsageReporterWatch2Request,
26616            fidl::encoding::DefaultFuchsiaResourceDialect,
26617        > for &mut UsageReporterWatch2Request
26618    {
26619        #[inline]
26620        unsafe fn encode(
26621            self,
26622            encoder: &mut fidl::encoding::Encoder<
26623                '_,
26624                fidl::encoding::DefaultFuchsiaResourceDialect,
26625            >,
26626            offset: usize,
26627            _depth: fidl::encoding::Depth,
26628        ) -> fidl::Result<()> {
26629            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
26630            // Delegate to tuple encoding.
26631            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26632                (
26633                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26634                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
26635                ),
26636                encoder, offset, _depth
26637            )
26638        }
26639    }
26640    unsafe impl<
26641        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26642        T1: fidl::encoding::Encode<
26643                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26644                fidl::encoding::DefaultFuchsiaResourceDialect,
26645            >,
26646    >
26647        fidl::encoding::Encode<
26648            UsageReporterWatch2Request,
26649            fidl::encoding::DefaultFuchsiaResourceDialect,
26650        > for (T0, T1)
26651    {
26652        #[inline]
26653        unsafe fn encode(
26654            self,
26655            encoder: &mut fidl::encoding::Encoder<
26656                '_,
26657                fidl::encoding::DefaultFuchsiaResourceDialect,
26658            >,
26659            offset: usize,
26660            depth: fidl::encoding::Depth,
26661        ) -> fidl::Result<()> {
26662            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
26663            // Zero out padding regions. There's no need to apply masks
26664            // because the unmasked parts will be overwritten by fields.
26665            unsafe {
26666                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
26667                (ptr as *mut u64).write_unaligned(0);
26668            }
26669            // Write the fields.
26670            self.0.encode(encoder, offset + 0, depth)?;
26671            self.1.encode(encoder, offset + 16, depth)?;
26672            Ok(())
26673        }
26674    }
26675
26676    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26677        for UsageReporterWatch2Request
26678    {
26679        #[inline(always)]
26680        fn new_empty() -> Self {
26681            Self {
26682                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
26683                usage_watcher: fidl::new_empty!(
26684                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26685                    fidl::encoding::DefaultFuchsiaResourceDialect
26686                ),
26687            }
26688        }
26689
26690        #[inline]
26691        unsafe fn decode(
26692            &mut self,
26693            decoder: &mut fidl::encoding::Decoder<
26694                '_,
26695                fidl::encoding::DefaultFuchsiaResourceDialect,
26696            >,
26697            offset: usize,
26698            _depth: fidl::encoding::Depth,
26699        ) -> fidl::Result<()> {
26700            decoder.debug_check_bounds::<Self>(offset);
26701            // Verify that padding bytes are zero.
26702            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
26703            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26704            let mask = 0xffffffff00000000u64;
26705            let maskedval = padval & mask;
26706            if maskedval != 0 {
26707                return Err(fidl::Error::NonZeroPadding {
26708                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
26709                });
26710            }
26711            fidl::decode!(
26712                Usage2,
26713                fidl::encoding::DefaultFuchsiaResourceDialect,
26714                &mut self.usage,
26715                decoder,
26716                offset + 0,
26717                _depth
26718            )?;
26719            fidl::decode!(
26720                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26721                fidl::encoding::DefaultFuchsiaResourceDialect,
26722                &mut self.usage_watcher,
26723                decoder,
26724                offset + 16,
26725                _depth
26726            )?;
26727            Ok(())
26728        }
26729    }
26730
26731    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
26732        type Borrowed<'a> = &'a mut Self;
26733        fn take_or_borrow<'a>(
26734            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26735        ) -> Self::Borrowed<'a> {
26736            value
26737        }
26738    }
26739
26740    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
26741        type Owned = Self;
26742
26743        #[inline(always)]
26744        fn inline_align(_context: fidl::encoding::Context) -> usize {
26745            8
26746        }
26747
26748        #[inline(always)]
26749        fn inline_size(_context: fidl::encoding::Context) -> usize {
26750            24
26751        }
26752    }
26753
26754    unsafe impl
26755        fidl::encoding::Encode<
26756            UsageReporterWatchRequest,
26757            fidl::encoding::DefaultFuchsiaResourceDialect,
26758        > for &mut UsageReporterWatchRequest
26759    {
26760        #[inline]
26761        unsafe fn encode(
26762            self,
26763            encoder: &mut fidl::encoding::Encoder<
26764                '_,
26765                fidl::encoding::DefaultFuchsiaResourceDialect,
26766            >,
26767            offset: usize,
26768            _depth: fidl::encoding::Depth,
26769        ) -> fidl::Result<()> {
26770            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
26771            // Delegate to tuple encoding.
26772            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26773                (
26774                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26775                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
26776                ),
26777                encoder, offset, _depth
26778            )
26779        }
26780    }
26781    unsafe impl<
26782        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26783        T1: fidl::encoding::Encode<
26784                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26785                fidl::encoding::DefaultFuchsiaResourceDialect,
26786            >,
26787    >
26788        fidl::encoding::Encode<
26789            UsageReporterWatchRequest,
26790            fidl::encoding::DefaultFuchsiaResourceDialect,
26791        > for (T0, T1)
26792    {
26793        #[inline]
26794        unsafe fn encode(
26795            self,
26796            encoder: &mut fidl::encoding::Encoder<
26797                '_,
26798                fidl::encoding::DefaultFuchsiaResourceDialect,
26799            >,
26800            offset: usize,
26801            depth: fidl::encoding::Depth,
26802        ) -> fidl::Result<()> {
26803            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
26804            // Zero out padding regions. There's no need to apply masks
26805            // because the unmasked parts will be overwritten by fields.
26806            unsafe {
26807                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
26808                (ptr as *mut u64).write_unaligned(0);
26809            }
26810            // Write the fields.
26811            self.0.encode(encoder, offset + 0, depth)?;
26812            self.1.encode(encoder, offset + 16, depth)?;
26813            Ok(())
26814        }
26815    }
26816
26817    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26818        for UsageReporterWatchRequest
26819    {
26820        #[inline(always)]
26821        fn new_empty() -> Self {
26822            Self {
26823                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
26824                usage_watcher: fidl::new_empty!(
26825                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26826                    fidl::encoding::DefaultFuchsiaResourceDialect
26827                ),
26828            }
26829        }
26830
26831        #[inline]
26832        unsafe fn decode(
26833            &mut self,
26834            decoder: &mut fidl::encoding::Decoder<
26835                '_,
26836                fidl::encoding::DefaultFuchsiaResourceDialect,
26837            >,
26838            offset: usize,
26839            _depth: fidl::encoding::Depth,
26840        ) -> fidl::Result<()> {
26841            decoder.debug_check_bounds::<Self>(offset);
26842            // Verify that padding bytes are zero.
26843            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
26844            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26845            let mask = 0xffffffff00000000u64;
26846            let maskedval = padval & mask;
26847            if maskedval != 0 {
26848                return Err(fidl::Error::NonZeroPadding {
26849                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
26850                });
26851            }
26852            fidl::decode!(
26853                Usage,
26854                fidl::encoding::DefaultFuchsiaResourceDialect,
26855                &mut self.usage,
26856                decoder,
26857                offset + 0,
26858                _depth
26859            )?;
26860            fidl::decode!(
26861                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26862                fidl::encoding::DefaultFuchsiaResourceDialect,
26863                &mut self.usage_watcher,
26864                decoder,
26865                offset + 16,
26866                _depth
26867            )?;
26868            Ok(())
26869        }
26870    }
26871
26872    impl StreamBufferPartialSettings {
26873        #[inline(always)]
26874        fn max_ordinal_present(&self) -> u64 {
26875            if let Some(_) = self.sysmem2_token {
26876                return 7;
26877            }
26878            if let Some(_) = self.sysmem_token {
26879                return 6;
26880            }
26881            if let Some(_) = self.packet_count_for_client {
26882                return 5;
26883            }
26884            if let Some(_) = self.packet_count_for_server {
26885                return 4;
26886            }
26887            if let Some(_) = self.single_buffer_mode {
26888                return 3;
26889            }
26890            if let Some(_) = self.buffer_constraints_version_ordinal {
26891                return 2;
26892            }
26893            if let Some(_) = self.buffer_lifetime_ordinal {
26894                return 1;
26895            }
26896            0
26897        }
26898    }
26899
26900    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
26901        type Borrowed<'a> = &'a mut Self;
26902        fn take_or_borrow<'a>(
26903            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26904        ) -> Self::Borrowed<'a> {
26905            value
26906        }
26907    }
26908
26909    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
26910        type Owned = Self;
26911
26912        #[inline(always)]
26913        fn inline_align(_context: fidl::encoding::Context) -> usize {
26914            8
26915        }
26916
26917        #[inline(always)]
26918        fn inline_size(_context: fidl::encoding::Context) -> usize {
26919            16
26920        }
26921    }
26922
26923    unsafe impl
26924        fidl::encoding::Encode<
26925            StreamBufferPartialSettings,
26926            fidl::encoding::DefaultFuchsiaResourceDialect,
26927        > for &mut StreamBufferPartialSettings
26928    {
26929        unsafe fn encode(
26930            self,
26931            encoder: &mut fidl::encoding::Encoder<
26932                '_,
26933                fidl::encoding::DefaultFuchsiaResourceDialect,
26934            >,
26935            offset: usize,
26936            mut depth: fidl::encoding::Depth,
26937        ) -> fidl::Result<()> {
26938            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
26939            // Vector header
26940            let max_ordinal: u64 = self.max_ordinal_present();
26941            encoder.write_num(max_ordinal, offset);
26942            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
26943            // Calling encoder.out_of_line_offset(0) is not allowed.
26944            if max_ordinal == 0 {
26945                return Ok(());
26946            }
26947            depth.increment()?;
26948            let envelope_size = 8;
26949            let bytes_len = max_ordinal as usize * envelope_size;
26950            #[allow(unused_variables)]
26951            let offset = encoder.out_of_line_offset(bytes_len);
26952            let mut _prev_end_offset: usize = 0;
26953            if 1 > max_ordinal {
26954                return Ok(());
26955            }
26956
26957            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
26958            // are envelope_size bytes.
26959            let cur_offset: usize = (1 - 1) * envelope_size;
26960
26961            // Zero reserved fields.
26962            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
26963
26964            // Safety:
26965            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
26966            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
26967            //   envelope_size bytes, there is always sufficient room.
26968            fidl::encoding::encode_in_envelope_optional::<
26969                u64,
26970                fidl::encoding::DefaultFuchsiaResourceDialect,
26971            >(
26972                self.buffer_lifetime_ordinal
26973                    .as_ref()
26974                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
26975                encoder,
26976                offset + cur_offset,
26977                depth,
26978            )?;
26979
26980            _prev_end_offset = cur_offset + envelope_size;
26981            if 2 > max_ordinal {
26982                return Ok(());
26983            }
26984
26985            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
26986            // are envelope_size bytes.
26987            let cur_offset: usize = (2 - 1) * envelope_size;
26988
26989            // Zero reserved fields.
26990            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
26991
26992            // Safety:
26993            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
26994            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
26995            //   envelope_size bytes, there is always sufficient room.
26996            fidl::encoding::encode_in_envelope_optional::<
26997                u64,
26998                fidl::encoding::DefaultFuchsiaResourceDialect,
26999            >(
27000                self.buffer_constraints_version_ordinal
27001                    .as_ref()
27002                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27003                encoder,
27004                offset + cur_offset,
27005                depth,
27006            )?;
27007
27008            _prev_end_offset = cur_offset + envelope_size;
27009            if 3 > max_ordinal {
27010                return Ok(());
27011            }
27012
27013            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27014            // are envelope_size bytes.
27015            let cur_offset: usize = (3 - 1) * envelope_size;
27016
27017            // Zero reserved fields.
27018            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27019
27020            // Safety:
27021            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27022            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27023            //   envelope_size bytes, there is always sufficient room.
27024            fidl::encoding::encode_in_envelope_optional::<
27025                bool,
27026                fidl::encoding::DefaultFuchsiaResourceDialect,
27027            >(
27028                self.single_buffer_mode
27029                    .as_ref()
27030                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
27031                encoder,
27032                offset + cur_offset,
27033                depth,
27034            )?;
27035
27036            _prev_end_offset = cur_offset + envelope_size;
27037            if 4 > max_ordinal {
27038                return Ok(());
27039            }
27040
27041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27042            // are envelope_size bytes.
27043            let cur_offset: usize = (4 - 1) * envelope_size;
27044
27045            // Zero reserved fields.
27046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27047
27048            // Safety:
27049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27051            //   envelope_size bytes, there is always sufficient room.
27052            fidl::encoding::encode_in_envelope_optional::<
27053                u32,
27054                fidl::encoding::DefaultFuchsiaResourceDialect,
27055            >(
27056                self.packet_count_for_server
27057                    .as_ref()
27058                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27059                encoder,
27060                offset + cur_offset,
27061                depth,
27062            )?;
27063
27064            _prev_end_offset = cur_offset + envelope_size;
27065            if 5 > max_ordinal {
27066                return Ok(());
27067            }
27068
27069            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27070            // are envelope_size bytes.
27071            let cur_offset: usize = (5 - 1) * envelope_size;
27072
27073            // Zero reserved fields.
27074            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27075
27076            // Safety:
27077            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27078            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27079            //   envelope_size bytes, there is always sufficient room.
27080            fidl::encoding::encode_in_envelope_optional::<
27081                u32,
27082                fidl::encoding::DefaultFuchsiaResourceDialect,
27083            >(
27084                self.packet_count_for_client
27085                    .as_ref()
27086                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27087                encoder,
27088                offset + cur_offset,
27089                depth,
27090            )?;
27091
27092            _prev_end_offset = cur_offset + envelope_size;
27093            if 6 > max_ordinal {
27094                return Ok(());
27095            }
27096
27097            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27098            // are envelope_size bytes.
27099            let cur_offset: usize = (6 - 1) * envelope_size;
27100
27101            // Zero reserved fields.
27102            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27103
27104            // Safety:
27105            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27106            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27107            //   envelope_size bytes, there is always sufficient room.
27108            fidl::encoding::encode_in_envelope_optional::<
27109                fidl::encoding::Endpoint<
27110                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
27111                >,
27112                fidl::encoding::DefaultFuchsiaResourceDialect,
27113            >(
27114                self.sysmem_token.as_mut().map(
27115                    <fidl::encoding::Endpoint<
27116                        fidl::endpoints::ClientEnd<
27117                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27118                        >,
27119                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27120                ),
27121                encoder,
27122                offset + cur_offset,
27123                depth,
27124            )?;
27125
27126            _prev_end_offset = cur_offset + envelope_size;
27127            if 7 > max_ordinal {
27128                return Ok(());
27129            }
27130
27131            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27132            // are envelope_size bytes.
27133            let cur_offset: usize = (7 - 1) * envelope_size;
27134
27135            // Zero reserved fields.
27136            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27137
27138            // Safety:
27139            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27140            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27141            //   envelope_size bytes, there is always sufficient room.
27142            fidl::encoding::encode_in_envelope_optional::<
27143                fidl::encoding::Endpoint<
27144                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
27145                >,
27146                fidl::encoding::DefaultFuchsiaResourceDialect,
27147            >(
27148                self.sysmem2_token.as_mut().map(
27149                    <fidl::encoding::Endpoint<
27150                        fidl::endpoints::ClientEnd<
27151                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27152                        >,
27153                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27154                ),
27155                encoder,
27156                offset + cur_offset,
27157                depth,
27158            )?;
27159
27160            _prev_end_offset = cur_offset + envelope_size;
27161
27162            Ok(())
27163        }
27164    }
27165
27166    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
27167        for StreamBufferPartialSettings
27168    {
27169        #[inline(always)]
27170        fn new_empty() -> Self {
27171            Self::default()
27172        }
27173
27174        unsafe fn decode(
27175            &mut self,
27176            decoder: &mut fidl::encoding::Decoder<
27177                '_,
27178                fidl::encoding::DefaultFuchsiaResourceDialect,
27179            >,
27180            offset: usize,
27181            mut depth: fidl::encoding::Depth,
27182        ) -> fidl::Result<()> {
27183            decoder.debug_check_bounds::<Self>(offset);
27184            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
27185                None => return Err(fidl::Error::NotNullable),
27186                Some(len) => len,
27187            };
27188            // Calling decoder.out_of_line_offset(0) is not allowed.
27189            if len == 0 {
27190                return Ok(());
27191            };
27192            depth.increment()?;
27193            let envelope_size = 8;
27194            let bytes_len = len * envelope_size;
27195            let offset = decoder.out_of_line_offset(bytes_len)?;
27196            // Decode the envelope for each type.
27197            let mut _next_ordinal_to_read = 0;
27198            let mut next_offset = offset;
27199            let end_offset = offset + bytes_len;
27200            _next_ordinal_to_read += 1;
27201            if next_offset >= end_offset {
27202                return Ok(());
27203            }
27204
27205            // Decode unknown envelopes for gaps in ordinals.
27206            while _next_ordinal_to_read < 1 {
27207                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27208                _next_ordinal_to_read += 1;
27209                next_offset += envelope_size;
27210            }
27211
27212            let next_out_of_line = decoder.next_out_of_line();
27213            let handles_before = decoder.remaining_handles();
27214            if let Some((inlined, num_bytes, num_handles)) =
27215                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27216            {
27217                let member_inline_size =
27218                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27219                if inlined != (member_inline_size <= 4) {
27220                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27221                }
27222                let inner_offset;
27223                let mut inner_depth = depth.clone();
27224                if inlined {
27225                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27226                    inner_offset = next_offset;
27227                } else {
27228                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27229                    inner_depth.increment()?;
27230                }
27231                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
27232                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27233                });
27234                fidl::decode!(
27235                    u64,
27236                    fidl::encoding::DefaultFuchsiaResourceDialect,
27237                    val_ref,
27238                    decoder,
27239                    inner_offset,
27240                    inner_depth
27241                )?;
27242                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27243                {
27244                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27245                }
27246                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27247                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27248                }
27249            }
27250
27251            next_offset += envelope_size;
27252            _next_ordinal_to_read += 1;
27253            if next_offset >= end_offset {
27254                return Ok(());
27255            }
27256
27257            // Decode unknown envelopes for gaps in ordinals.
27258            while _next_ordinal_to_read < 2 {
27259                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27260                _next_ordinal_to_read += 1;
27261                next_offset += envelope_size;
27262            }
27263
27264            let next_out_of_line = decoder.next_out_of_line();
27265            let handles_before = decoder.remaining_handles();
27266            if let Some((inlined, num_bytes, num_handles)) =
27267                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27268            {
27269                let member_inline_size =
27270                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27271                if inlined != (member_inline_size <= 4) {
27272                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27273                }
27274                let inner_offset;
27275                let mut inner_depth = depth.clone();
27276                if inlined {
27277                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27278                    inner_offset = next_offset;
27279                } else {
27280                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27281                    inner_depth.increment()?;
27282                }
27283                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
27284                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27285                });
27286                fidl::decode!(
27287                    u64,
27288                    fidl::encoding::DefaultFuchsiaResourceDialect,
27289                    val_ref,
27290                    decoder,
27291                    inner_offset,
27292                    inner_depth
27293                )?;
27294                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27295                {
27296                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27297                }
27298                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27299                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27300                }
27301            }
27302
27303            next_offset += envelope_size;
27304            _next_ordinal_to_read += 1;
27305            if next_offset >= end_offset {
27306                return Ok(());
27307            }
27308
27309            // Decode unknown envelopes for gaps in ordinals.
27310            while _next_ordinal_to_read < 3 {
27311                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27312                _next_ordinal_to_read += 1;
27313                next_offset += envelope_size;
27314            }
27315
27316            let next_out_of_line = decoder.next_out_of_line();
27317            let handles_before = decoder.remaining_handles();
27318            if let Some((inlined, num_bytes, num_handles)) =
27319                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27320            {
27321                let member_inline_size =
27322                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27323                if inlined != (member_inline_size <= 4) {
27324                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27325                }
27326                let inner_offset;
27327                let mut inner_depth = depth.clone();
27328                if inlined {
27329                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27330                    inner_offset = next_offset;
27331                } else {
27332                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27333                    inner_depth.increment()?;
27334                }
27335                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
27336                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
27337                });
27338                fidl::decode!(
27339                    bool,
27340                    fidl::encoding::DefaultFuchsiaResourceDialect,
27341                    val_ref,
27342                    decoder,
27343                    inner_offset,
27344                    inner_depth
27345                )?;
27346                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27347                {
27348                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27349                }
27350                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27351                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27352                }
27353            }
27354
27355            next_offset += envelope_size;
27356            _next_ordinal_to_read += 1;
27357            if next_offset >= end_offset {
27358                return Ok(());
27359            }
27360
27361            // Decode unknown envelopes for gaps in ordinals.
27362            while _next_ordinal_to_read < 4 {
27363                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27364                _next_ordinal_to_read += 1;
27365                next_offset += envelope_size;
27366            }
27367
27368            let next_out_of_line = decoder.next_out_of_line();
27369            let handles_before = decoder.remaining_handles();
27370            if let Some((inlined, num_bytes, num_handles)) =
27371                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27372            {
27373                let member_inline_size =
27374                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27375                if inlined != (member_inline_size <= 4) {
27376                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27377                }
27378                let inner_offset;
27379                let mut inner_depth = depth.clone();
27380                if inlined {
27381                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27382                    inner_offset = next_offset;
27383                } else {
27384                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27385                    inner_depth.increment()?;
27386                }
27387                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
27388                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
27389                });
27390                fidl::decode!(
27391                    u32,
27392                    fidl::encoding::DefaultFuchsiaResourceDialect,
27393                    val_ref,
27394                    decoder,
27395                    inner_offset,
27396                    inner_depth
27397                )?;
27398                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27399                {
27400                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27401                }
27402                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27403                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27404                }
27405            }
27406
27407            next_offset += envelope_size;
27408            _next_ordinal_to_read += 1;
27409            if next_offset >= end_offset {
27410                return Ok(());
27411            }
27412
27413            // Decode unknown envelopes for gaps in ordinals.
27414            while _next_ordinal_to_read < 5 {
27415                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27416                _next_ordinal_to_read += 1;
27417                next_offset += envelope_size;
27418            }
27419
27420            let next_out_of_line = decoder.next_out_of_line();
27421            let handles_before = decoder.remaining_handles();
27422            if let Some((inlined, num_bytes, num_handles)) =
27423                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27424            {
27425                let member_inline_size =
27426                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27427                if inlined != (member_inline_size <= 4) {
27428                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27429                }
27430                let inner_offset;
27431                let mut inner_depth = depth.clone();
27432                if inlined {
27433                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27434                    inner_offset = next_offset;
27435                } else {
27436                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27437                    inner_depth.increment()?;
27438                }
27439                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
27440                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
27441                });
27442                fidl::decode!(
27443                    u32,
27444                    fidl::encoding::DefaultFuchsiaResourceDialect,
27445                    val_ref,
27446                    decoder,
27447                    inner_offset,
27448                    inner_depth
27449                )?;
27450                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27451                {
27452                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27453                }
27454                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27455                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27456                }
27457            }
27458
27459            next_offset += envelope_size;
27460            _next_ordinal_to_read += 1;
27461            if next_offset >= end_offset {
27462                return Ok(());
27463            }
27464
27465            // Decode unknown envelopes for gaps in ordinals.
27466            while _next_ordinal_to_read < 6 {
27467                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27468                _next_ordinal_to_read += 1;
27469                next_offset += envelope_size;
27470            }
27471
27472            let next_out_of_line = decoder.next_out_of_line();
27473            let handles_before = decoder.remaining_handles();
27474            if let Some((inlined, num_bytes, num_handles)) =
27475                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27476            {
27477                let member_inline_size = <fidl::encoding::Endpoint<
27478                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
27479                > as fidl::encoding::TypeMarker>::inline_size(
27480                    decoder.context
27481                );
27482                if inlined != (member_inline_size <= 4) {
27483                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27484                }
27485                let inner_offset;
27486                let mut inner_depth = depth.clone();
27487                if inlined {
27488                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27489                    inner_offset = next_offset;
27490                } else {
27491                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27492                    inner_depth.increment()?;
27493                }
27494                let val_ref = self.sysmem_token.get_or_insert_with(|| {
27495                    fidl::new_empty!(
27496                        fidl::encoding::Endpoint<
27497                            fidl::endpoints::ClientEnd<
27498                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27499                            >,
27500                        >,
27501                        fidl::encoding::DefaultFuchsiaResourceDialect
27502                    )
27503                });
27504                fidl::decode!(
27505                    fidl::encoding::Endpoint<
27506                        fidl::endpoints::ClientEnd<
27507                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27508                        >,
27509                    >,
27510                    fidl::encoding::DefaultFuchsiaResourceDialect,
27511                    val_ref,
27512                    decoder,
27513                    inner_offset,
27514                    inner_depth
27515                )?;
27516                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27517                {
27518                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27519                }
27520                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27521                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27522                }
27523            }
27524
27525            next_offset += envelope_size;
27526            _next_ordinal_to_read += 1;
27527            if next_offset >= end_offset {
27528                return Ok(());
27529            }
27530
27531            // Decode unknown envelopes for gaps in ordinals.
27532            while _next_ordinal_to_read < 7 {
27533                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27534                _next_ordinal_to_read += 1;
27535                next_offset += envelope_size;
27536            }
27537
27538            let next_out_of_line = decoder.next_out_of_line();
27539            let handles_before = decoder.remaining_handles();
27540            if let Some((inlined, num_bytes, num_handles)) =
27541                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27542            {
27543                let member_inline_size = <fidl::encoding::Endpoint<
27544                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
27545                > as fidl::encoding::TypeMarker>::inline_size(
27546                    decoder.context
27547                );
27548                if inlined != (member_inline_size <= 4) {
27549                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27550                }
27551                let inner_offset;
27552                let mut inner_depth = depth.clone();
27553                if inlined {
27554                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27555                    inner_offset = next_offset;
27556                } else {
27557                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27558                    inner_depth.increment()?;
27559                }
27560                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
27561                    fidl::new_empty!(
27562                        fidl::encoding::Endpoint<
27563                            fidl::endpoints::ClientEnd<
27564                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27565                            >,
27566                        >,
27567                        fidl::encoding::DefaultFuchsiaResourceDialect
27568                    )
27569                });
27570                fidl::decode!(
27571                    fidl::encoding::Endpoint<
27572                        fidl::endpoints::ClientEnd<
27573                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27574                        >,
27575                    >,
27576                    fidl::encoding::DefaultFuchsiaResourceDialect,
27577                    val_ref,
27578                    decoder,
27579                    inner_offset,
27580                    inner_depth
27581                )?;
27582                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27583                {
27584                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27585                }
27586                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27587                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27588                }
27589            }
27590
27591            next_offset += envelope_size;
27592
27593            // Decode the remaining unknown envelopes.
27594            while next_offset < end_offset {
27595                _next_ordinal_to_read += 1;
27596                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27597                next_offset += envelope_size;
27598            }
27599
27600            Ok(())
27601        }
27602    }
27603
27604    impl StreamProcessorAddBufferRequest {
27605        #[inline(always)]
27606        fn max_ordinal_present(&self) -> u64 {
27607            if let Some(_) = self.buffer {
27608                return 5;
27609            }
27610            if let Some(_) = self.buffer_index {
27611                return 4;
27612            }
27613            if let Some(_) = self.buffer_lifetime_ordinal {
27614                return 3;
27615            }
27616            if let Some(_) = self.buffer_constraints_version_ordinal {
27617                return 2;
27618            }
27619            if let Some(_) = self.port {
27620                return 1;
27621            }
27622            0
27623        }
27624    }
27625
27626    impl fidl::encoding::ResourceTypeMarker for StreamProcessorAddBufferRequest {
27627        type Borrowed<'a> = &'a mut Self;
27628        fn take_or_borrow<'a>(
27629            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
27630        ) -> Self::Borrowed<'a> {
27631            value
27632        }
27633    }
27634
27635    unsafe impl fidl::encoding::TypeMarker for StreamProcessorAddBufferRequest {
27636        type Owned = Self;
27637
27638        #[inline(always)]
27639        fn inline_align(_context: fidl::encoding::Context) -> usize {
27640            8
27641        }
27642
27643        #[inline(always)]
27644        fn inline_size(_context: fidl::encoding::Context) -> usize {
27645            16
27646        }
27647    }
27648
27649    unsafe impl
27650        fidl::encoding::Encode<
27651            StreamProcessorAddBufferRequest,
27652            fidl::encoding::DefaultFuchsiaResourceDialect,
27653        > for &mut StreamProcessorAddBufferRequest
27654    {
27655        unsafe fn encode(
27656            self,
27657            encoder: &mut fidl::encoding::Encoder<
27658                '_,
27659                fidl::encoding::DefaultFuchsiaResourceDialect,
27660            >,
27661            offset: usize,
27662            mut depth: fidl::encoding::Depth,
27663        ) -> fidl::Result<()> {
27664            encoder.debug_check_bounds::<StreamProcessorAddBufferRequest>(offset);
27665            // Vector header
27666            let max_ordinal: u64 = self.max_ordinal_present();
27667            encoder.write_num(max_ordinal, offset);
27668            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
27669            // Calling encoder.out_of_line_offset(0) is not allowed.
27670            if max_ordinal == 0 {
27671                return Ok(());
27672            }
27673            depth.increment()?;
27674            let envelope_size = 8;
27675            let bytes_len = max_ordinal as usize * envelope_size;
27676            #[allow(unused_variables)]
27677            let offset = encoder.out_of_line_offset(bytes_len);
27678            let mut _prev_end_offset: usize = 0;
27679            if 1 > max_ordinal {
27680                return Ok(());
27681            }
27682
27683            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27684            // are envelope_size bytes.
27685            let cur_offset: usize = (1 - 1) * envelope_size;
27686
27687            // Zero reserved fields.
27688            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27689
27690            // Safety:
27691            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27692            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27693            //   envelope_size bytes, there is always sufficient room.
27694            fidl::encoding::encode_in_envelope_optional::<
27695                Port,
27696                fidl::encoding::DefaultFuchsiaResourceDialect,
27697            >(
27698                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
27699                encoder,
27700                offset + cur_offset,
27701                depth,
27702            )?;
27703
27704            _prev_end_offset = cur_offset + envelope_size;
27705            if 2 > max_ordinal {
27706                return Ok(());
27707            }
27708
27709            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27710            // are envelope_size bytes.
27711            let cur_offset: usize = (2 - 1) * envelope_size;
27712
27713            // Zero reserved fields.
27714            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27715
27716            // Safety:
27717            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27718            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27719            //   envelope_size bytes, there is always sufficient room.
27720            fidl::encoding::encode_in_envelope_optional::<
27721                u64,
27722                fidl::encoding::DefaultFuchsiaResourceDialect,
27723            >(
27724                self.buffer_constraints_version_ordinal
27725                    .as_ref()
27726                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27727                encoder,
27728                offset + cur_offset,
27729                depth,
27730            )?;
27731
27732            _prev_end_offset = cur_offset + envelope_size;
27733            if 3 > max_ordinal {
27734                return Ok(());
27735            }
27736
27737            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27738            // are envelope_size bytes.
27739            let cur_offset: usize = (3 - 1) * envelope_size;
27740
27741            // Zero reserved fields.
27742            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27743
27744            // Safety:
27745            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27746            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27747            //   envelope_size bytes, there is always sufficient room.
27748            fidl::encoding::encode_in_envelope_optional::<
27749                u64,
27750                fidl::encoding::DefaultFuchsiaResourceDialect,
27751            >(
27752                self.buffer_lifetime_ordinal
27753                    .as_ref()
27754                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27755                encoder,
27756                offset + cur_offset,
27757                depth,
27758            )?;
27759
27760            _prev_end_offset = cur_offset + envelope_size;
27761            if 4 > max_ordinal {
27762                return Ok(());
27763            }
27764
27765            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27766            // are envelope_size bytes.
27767            let cur_offset: usize = (4 - 1) * envelope_size;
27768
27769            // Zero reserved fields.
27770            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27771
27772            // Safety:
27773            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27774            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27775            //   envelope_size bytes, there is always sufficient room.
27776            fidl::encoding::encode_in_envelope_optional::<
27777                u32,
27778                fidl::encoding::DefaultFuchsiaResourceDialect,
27779            >(
27780                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27781                encoder,
27782                offset + cur_offset,
27783                depth,
27784            )?;
27785
27786            _prev_end_offset = cur_offset + envelope_size;
27787            if 5 > max_ordinal {
27788                return Ok(());
27789            }
27790
27791            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27792            // are envelope_size bytes.
27793            let cur_offset: usize = (5 - 1) * envelope_size;
27794
27795            // Zero reserved fields.
27796            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27797
27798            // Safety:
27799            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27800            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27801            //   envelope_size bytes, there is always sufficient room.
27802            fidl::encoding::encode_in_envelope_optional::<
27803                fidl::encoding::HandleType<
27804                    fidl::Vmo,
27805                    { fidl::ObjectType::VMO.into_raw() },
27806                    2147483648,
27807                >,
27808                fidl::encoding::DefaultFuchsiaResourceDialect,
27809            >(
27810                self.buffer.as_mut().map(
27811                    <fidl::encoding::HandleType<
27812                        fidl::Vmo,
27813                        { fidl::ObjectType::VMO.into_raw() },
27814                        2147483648,
27815                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27816                ),
27817                encoder,
27818                offset + cur_offset,
27819                depth,
27820            )?;
27821
27822            _prev_end_offset = cur_offset + envelope_size;
27823
27824            Ok(())
27825        }
27826    }
27827
27828    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
27829        for StreamProcessorAddBufferRequest
27830    {
27831        #[inline(always)]
27832        fn new_empty() -> Self {
27833            Self::default()
27834        }
27835
27836        unsafe fn decode(
27837            &mut self,
27838            decoder: &mut fidl::encoding::Decoder<
27839                '_,
27840                fidl::encoding::DefaultFuchsiaResourceDialect,
27841            >,
27842            offset: usize,
27843            mut depth: fidl::encoding::Depth,
27844        ) -> fidl::Result<()> {
27845            decoder.debug_check_bounds::<Self>(offset);
27846            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
27847                None => return Err(fidl::Error::NotNullable),
27848                Some(len) => len,
27849            };
27850            // Calling decoder.out_of_line_offset(0) is not allowed.
27851            if len == 0 {
27852                return Ok(());
27853            };
27854            depth.increment()?;
27855            let envelope_size = 8;
27856            let bytes_len = len * envelope_size;
27857            let offset = decoder.out_of_line_offset(bytes_len)?;
27858            // Decode the envelope for each type.
27859            let mut _next_ordinal_to_read = 0;
27860            let mut next_offset = offset;
27861            let end_offset = offset + bytes_len;
27862            _next_ordinal_to_read += 1;
27863            if next_offset >= end_offset {
27864                return Ok(());
27865            }
27866
27867            // Decode unknown envelopes for gaps in ordinals.
27868            while _next_ordinal_to_read < 1 {
27869                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27870                _next_ordinal_to_read += 1;
27871                next_offset += envelope_size;
27872            }
27873
27874            let next_out_of_line = decoder.next_out_of_line();
27875            let handles_before = decoder.remaining_handles();
27876            if let Some((inlined, num_bytes, num_handles)) =
27877                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27878            {
27879                let member_inline_size =
27880                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27881                if inlined != (member_inline_size <= 4) {
27882                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27883                }
27884                let inner_offset;
27885                let mut inner_depth = depth.clone();
27886                if inlined {
27887                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27888                    inner_offset = next_offset;
27889                } else {
27890                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27891                    inner_depth.increment()?;
27892                }
27893                let val_ref = self.port.get_or_insert_with(|| {
27894                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
27895                });
27896                fidl::decode!(
27897                    Port,
27898                    fidl::encoding::DefaultFuchsiaResourceDialect,
27899                    val_ref,
27900                    decoder,
27901                    inner_offset,
27902                    inner_depth
27903                )?;
27904                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27905                {
27906                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27907                }
27908                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27909                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27910                }
27911            }
27912
27913            next_offset += envelope_size;
27914            _next_ordinal_to_read += 1;
27915            if next_offset >= end_offset {
27916                return Ok(());
27917            }
27918
27919            // Decode unknown envelopes for gaps in ordinals.
27920            while _next_ordinal_to_read < 2 {
27921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27922                _next_ordinal_to_read += 1;
27923                next_offset += envelope_size;
27924            }
27925
27926            let next_out_of_line = decoder.next_out_of_line();
27927            let handles_before = decoder.remaining_handles();
27928            if let Some((inlined, num_bytes, num_handles)) =
27929                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27930            {
27931                let member_inline_size =
27932                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27933                if inlined != (member_inline_size <= 4) {
27934                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27935                }
27936                let inner_offset;
27937                let mut inner_depth = depth.clone();
27938                if inlined {
27939                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27940                    inner_offset = next_offset;
27941                } else {
27942                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27943                    inner_depth.increment()?;
27944                }
27945                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
27946                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27947                });
27948                fidl::decode!(
27949                    u64,
27950                    fidl::encoding::DefaultFuchsiaResourceDialect,
27951                    val_ref,
27952                    decoder,
27953                    inner_offset,
27954                    inner_depth
27955                )?;
27956                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27957                {
27958                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27959                }
27960                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27961                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27962                }
27963            }
27964
27965            next_offset += envelope_size;
27966            _next_ordinal_to_read += 1;
27967            if next_offset >= end_offset {
27968                return Ok(());
27969            }
27970
27971            // Decode unknown envelopes for gaps in ordinals.
27972            while _next_ordinal_to_read < 3 {
27973                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27974                _next_ordinal_to_read += 1;
27975                next_offset += envelope_size;
27976            }
27977
27978            let next_out_of_line = decoder.next_out_of_line();
27979            let handles_before = decoder.remaining_handles();
27980            if let Some((inlined, num_bytes, num_handles)) =
27981                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27982            {
27983                let member_inline_size =
27984                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27985                if inlined != (member_inline_size <= 4) {
27986                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27987                }
27988                let inner_offset;
27989                let mut inner_depth = depth.clone();
27990                if inlined {
27991                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27992                    inner_offset = next_offset;
27993                } else {
27994                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27995                    inner_depth.increment()?;
27996                }
27997                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
27998                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27999                });
28000                fidl::decode!(
28001                    u64,
28002                    fidl::encoding::DefaultFuchsiaResourceDialect,
28003                    val_ref,
28004                    decoder,
28005                    inner_offset,
28006                    inner_depth
28007                )?;
28008                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28009                {
28010                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28011                }
28012                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28013                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28014                }
28015            }
28016
28017            next_offset += envelope_size;
28018            _next_ordinal_to_read += 1;
28019            if next_offset >= end_offset {
28020                return Ok(());
28021            }
28022
28023            // Decode unknown envelopes for gaps in ordinals.
28024            while _next_ordinal_to_read < 4 {
28025                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28026                _next_ordinal_to_read += 1;
28027                next_offset += envelope_size;
28028            }
28029
28030            let next_out_of_line = decoder.next_out_of_line();
28031            let handles_before = decoder.remaining_handles();
28032            if let Some((inlined, num_bytes, num_handles)) =
28033                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28034            {
28035                let member_inline_size =
28036                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28037                if inlined != (member_inline_size <= 4) {
28038                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28039                }
28040                let inner_offset;
28041                let mut inner_depth = depth.clone();
28042                if inlined {
28043                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28044                    inner_offset = next_offset;
28045                } else {
28046                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28047                    inner_depth.increment()?;
28048                }
28049                let val_ref = self.buffer_index.get_or_insert_with(|| {
28050                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
28051                });
28052                fidl::decode!(
28053                    u32,
28054                    fidl::encoding::DefaultFuchsiaResourceDialect,
28055                    val_ref,
28056                    decoder,
28057                    inner_offset,
28058                    inner_depth
28059                )?;
28060                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28061                {
28062                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28063                }
28064                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28065                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28066                }
28067            }
28068
28069            next_offset += envelope_size;
28070            _next_ordinal_to_read += 1;
28071            if next_offset >= end_offset {
28072                return Ok(());
28073            }
28074
28075            // Decode unknown envelopes for gaps in ordinals.
28076            while _next_ordinal_to_read < 5 {
28077                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28078                _next_ordinal_to_read += 1;
28079                next_offset += envelope_size;
28080            }
28081
28082            let next_out_of_line = decoder.next_out_of_line();
28083            let handles_before = decoder.remaining_handles();
28084            if let Some((inlined, num_bytes, num_handles)) =
28085                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28086            {
28087                let member_inline_size = <fidl::encoding::HandleType<
28088                    fidl::Vmo,
28089                    { fidl::ObjectType::VMO.into_raw() },
28090                    2147483648,
28091                > as fidl::encoding::TypeMarker>::inline_size(
28092                    decoder.context
28093                );
28094                if inlined != (member_inline_size <= 4) {
28095                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28096                }
28097                let inner_offset;
28098                let mut inner_depth = depth.clone();
28099                if inlined {
28100                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28101                    inner_offset = next_offset;
28102                } else {
28103                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28104                    inner_depth.increment()?;
28105                }
28106                let val_ref =
28107                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
28108                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
28109                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28110                {
28111                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28112                }
28113                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28114                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28115                }
28116            }
28117
28118            next_offset += envelope_size;
28119
28120            // Decode the remaining unknown envelopes.
28121            while next_offset < end_offset {
28122                _next_ordinal_to_read += 1;
28123                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28124                next_offset += envelope_size;
28125            }
28126
28127            Ok(())
28128        }
28129    }
28130
28131    impl StreamProcessorParticipateInBufferAllocationRequest {
28132        #[inline(always)]
28133        fn max_ordinal_present(&self) -> u64 {
28134            if let Some(_) = self.allow_single_buffer {
28135                return 5;
28136            }
28137            if let Some(_) = self.buffer_lifetime_ordinal {
28138                return 4;
28139            }
28140            if let Some(_) = self.sysmem2_token {
28141                return 3;
28142            }
28143            if let Some(_) = self.buffer_constraints_version_ordinal {
28144                return 2;
28145            }
28146            if let Some(_) = self.port {
28147                return 1;
28148            }
28149            0
28150        }
28151    }
28152
28153    impl fidl::encoding::ResourceTypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
28154        type Borrowed<'a> = &'a mut Self;
28155        fn take_or_borrow<'a>(
28156            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
28157        ) -> Self::Borrowed<'a> {
28158            value
28159        }
28160    }
28161
28162    unsafe impl fidl::encoding::TypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
28163        type Owned = Self;
28164
28165        #[inline(always)]
28166        fn inline_align(_context: fidl::encoding::Context) -> usize {
28167            8
28168        }
28169
28170        #[inline(always)]
28171        fn inline_size(_context: fidl::encoding::Context) -> usize {
28172            16
28173        }
28174    }
28175
28176    unsafe impl
28177        fidl::encoding::Encode<
28178            StreamProcessorParticipateInBufferAllocationRequest,
28179            fidl::encoding::DefaultFuchsiaResourceDialect,
28180        > for &mut StreamProcessorParticipateInBufferAllocationRequest
28181    {
28182        unsafe fn encode(
28183            self,
28184            encoder: &mut fidl::encoding::Encoder<
28185                '_,
28186                fidl::encoding::DefaultFuchsiaResourceDialect,
28187            >,
28188            offset: usize,
28189            mut depth: fidl::encoding::Depth,
28190        ) -> fidl::Result<()> {
28191            encoder
28192                .debug_check_bounds::<StreamProcessorParticipateInBufferAllocationRequest>(offset);
28193            // Vector header
28194            let max_ordinal: u64 = self.max_ordinal_present();
28195            encoder.write_num(max_ordinal, offset);
28196            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
28197            // Calling encoder.out_of_line_offset(0) is not allowed.
28198            if max_ordinal == 0 {
28199                return Ok(());
28200            }
28201            depth.increment()?;
28202            let envelope_size = 8;
28203            let bytes_len = max_ordinal as usize * envelope_size;
28204            #[allow(unused_variables)]
28205            let offset = encoder.out_of_line_offset(bytes_len);
28206            let mut _prev_end_offset: usize = 0;
28207            if 1 > max_ordinal {
28208                return Ok(());
28209            }
28210
28211            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28212            // are envelope_size bytes.
28213            let cur_offset: usize = (1 - 1) * envelope_size;
28214
28215            // Zero reserved fields.
28216            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28217
28218            // Safety:
28219            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28220            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28221            //   envelope_size bytes, there is always sufficient room.
28222            fidl::encoding::encode_in_envelope_optional::<
28223                Port,
28224                fidl::encoding::DefaultFuchsiaResourceDialect,
28225            >(
28226                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
28227                encoder,
28228                offset + cur_offset,
28229                depth,
28230            )?;
28231
28232            _prev_end_offset = cur_offset + envelope_size;
28233            if 2 > max_ordinal {
28234                return Ok(());
28235            }
28236
28237            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28238            // are envelope_size bytes.
28239            let cur_offset: usize = (2 - 1) * envelope_size;
28240
28241            // Zero reserved fields.
28242            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28243
28244            // Safety:
28245            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28246            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28247            //   envelope_size bytes, there is always sufficient room.
28248            fidl::encoding::encode_in_envelope_optional::<
28249                u64,
28250                fidl::encoding::DefaultFuchsiaResourceDialect,
28251            >(
28252                self.buffer_constraints_version_ordinal
28253                    .as_ref()
28254                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28255                encoder,
28256                offset + cur_offset,
28257                depth,
28258            )?;
28259
28260            _prev_end_offset = cur_offset + envelope_size;
28261            if 3 > max_ordinal {
28262                return Ok(());
28263            }
28264
28265            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28266            // are envelope_size bytes.
28267            let cur_offset: usize = (3 - 1) * envelope_size;
28268
28269            // Zero reserved fields.
28270            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28271
28272            // Safety:
28273            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28274            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28275            //   envelope_size bytes, there is always sufficient room.
28276            fidl::encoding::encode_in_envelope_optional::<
28277                fidl::encoding::Endpoint<
28278                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
28279                >,
28280                fidl::encoding::DefaultFuchsiaResourceDialect,
28281            >(
28282                self.sysmem2_token.as_mut().map(
28283                    <fidl::encoding::Endpoint<
28284                        fidl::endpoints::ClientEnd<
28285                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28286                        >,
28287                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
28288                ),
28289                encoder,
28290                offset + cur_offset,
28291                depth,
28292            )?;
28293
28294            _prev_end_offset = cur_offset + envelope_size;
28295            if 4 > max_ordinal {
28296                return Ok(());
28297            }
28298
28299            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28300            // are envelope_size bytes.
28301            let cur_offset: usize = (4 - 1) * envelope_size;
28302
28303            // Zero reserved fields.
28304            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28305
28306            // Safety:
28307            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28308            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28309            //   envelope_size bytes, there is always sufficient room.
28310            fidl::encoding::encode_in_envelope_optional::<
28311                u64,
28312                fidl::encoding::DefaultFuchsiaResourceDialect,
28313            >(
28314                self.buffer_lifetime_ordinal
28315                    .as_ref()
28316                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28317                encoder,
28318                offset + cur_offset,
28319                depth,
28320            )?;
28321
28322            _prev_end_offset = cur_offset + envelope_size;
28323            if 5 > max_ordinal {
28324                return Ok(());
28325            }
28326
28327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28328            // are envelope_size bytes.
28329            let cur_offset: usize = (5 - 1) * envelope_size;
28330
28331            // Zero reserved fields.
28332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28333
28334            // Safety:
28335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28337            //   envelope_size bytes, there is always sufficient room.
28338            fidl::encoding::encode_in_envelope_optional::<
28339                bool,
28340                fidl::encoding::DefaultFuchsiaResourceDialect,
28341            >(
28342                self.allow_single_buffer
28343                    .as_ref()
28344                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
28345                encoder,
28346                offset + cur_offset,
28347                depth,
28348            )?;
28349
28350            _prev_end_offset = cur_offset + envelope_size;
28351
28352            Ok(())
28353        }
28354    }
28355
28356    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
28357        for StreamProcessorParticipateInBufferAllocationRequest
28358    {
28359        #[inline(always)]
28360        fn new_empty() -> Self {
28361            Self::default()
28362        }
28363
28364        unsafe fn decode(
28365            &mut self,
28366            decoder: &mut fidl::encoding::Decoder<
28367                '_,
28368                fidl::encoding::DefaultFuchsiaResourceDialect,
28369            >,
28370            offset: usize,
28371            mut depth: fidl::encoding::Depth,
28372        ) -> fidl::Result<()> {
28373            decoder.debug_check_bounds::<Self>(offset);
28374            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
28375                None => return Err(fidl::Error::NotNullable),
28376                Some(len) => len,
28377            };
28378            // Calling decoder.out_of_line_offset(0) is not allowed.
28379            if len == 0 {
28380                return Ok(());
28381            };
28382            depth.increment()?;
28383            let envelope_size = 8;
28384            let bytes_len = len * envelope_size;
28385            let offset = decoder.out_of_line_offset(bytes_len)?;
28386            // Decode the envelope for each type.
28387            let mut _next_ordinal_to_read = 0;
28388            let mut next_offset = offset;
28389            let end_offset = offset + bytes_len;
28390            _next_ordinal_to_read += 1;
28391            if next_offset >= end_offset {
28392                return Ok(());
28393            }
28394
28395            // Decode unknown envelopes for gaps in ordinals.
28396            while _next_ordinal_to_read < 1 {
28397                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28398                _next_ordinal_to_read += 1;
28399                next_offset += envelope_size;
28400            }
28401
28402            let next_out_of_line = decoder.next_out_of_line();
28403            let handles_before = decoder.remaining_handles();
28404            if let Some((inlined, num_bytes, num_handles)) =
28405                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28406            {
28407                let member_inline_size =
28408                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28409                if inlined != (member_inline_size <= 4) {
28410                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28411                }
28412                let inner_offset;
28413                let mut inner_depth = depth.clone();
28414                if inlined {
28415                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28416                    inner_offset = next_offset;
28417                } else {
28418                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28419                    inner_depth.increment()?;
28420                }
28421                let val_ref = self.port.get_or_insert_with(|| {
28422                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
28423                });
28424                fidl::decode!(
28425                    Port,
28426                    fidl::encoding::DefaultFuchsiaResourceDialect,
28427                    val_ref,
28428                    decoder,
28429                    inner_offset,
28430                    inner_depth
28431                )?;
28432                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28433                {
28434                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28435                }
28436                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28437                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28438                }
28439            }
28440
28441            next_offset += envelope_size;
28442            _next_ordinal_to_read += 1;
28443            if next_offset >= end_offset {
28444                return Ok(());
28445            }
28446
28447            // Decode unknown envelopes for gaps in ordinals.
28448            while _next_ordinal_to_read < 2 {
28449                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28450                _next_ordinal_to_read += 1;
28451                next_offset += envelope_size;
28452            }
28453
28454            let next_out_of_line = decoder.next_out_of_line();
28455            let handles_before = decoder.remaining_handles();
28456            if let Some((inlined, num_bytes, num_handles)) =
28457                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28458            {
28459                let member_inline_size =
28460                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28461                if inlined != (member_inline_size <= 4) {
28462                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28463                }
28464                let inner_offset;
28465                let mut inner_depth = depth.clone();
28466                if inlined {
28467                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28468                    inner_offset = next_offset;
28469                } else {
28470                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28471                    inner_depth.increment()?;
28472                }
28473                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
28474                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28475                });
28476                fidl::decode!(
28477                    u64,
28478                    fidl::encoding::DefaultFuchsiaResourceDialect,
28479                    val_ref,
28480                    decoder,
28481                    inner_offset,
28482                    inner_depth
28483                )?;
28484                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28485                {
28486                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28487                }
28488                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28489                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28490                }
28491            }
28492
28493            next_offset += envelope_size;
28494            _next_ordinal_to_read += 1;
28495            if next_offset >= end_offset {
28496                return Ok(());
28497            }
28498
28499            // Decode unknown envelopes for gaps in ordinals.
28500            while _next_ordinal_to_read < 3 {
28501                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28502                _next_ordinal_to_read += 1;
28503                next_offset += envelope_size;
28504            }
28505
28506            let next_out_of_line = decoder.next_out_of_line();
28507            let handles_before = decoder.remaining_handles();
28508            if let Some((inlined, num_bytes, num_handles)) =
28509                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28510            {
28511                let member_inline_size = <fidl::encoding::Endpoint<
28512                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
28513                > as fidl::encoding::TypeMarker>::inline_size(
28514                    decoder.context
28515                );
28516                if inlined != (member_inline_size <= 4) {
28517                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28518                }
28519                let inner_offset;
28520                let mut inner_depth = depth.clone();
28521                if inlined {
28522                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28523                    inner_offset = next_offset;
28524                } else {
28525                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28526                    inner_depth.increment()?;
28527                }
28528                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
28529                    fidl::new_empty!(
28530                        fidl::encoding::Endpoint<
28531                            fidl::endpoints::ClientEnd<
28532                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28533                            >,
28534                        >,
28535                        fidl::encoding::DefaultFuchsiaResourceDialect
28536                    )
28537                });
28538                fidl::decode!(
28539                    fidl::encoding::Endpoint<
28540                        fidl::endpoints::ClientEnd<
28541                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28542                        >,
28543                    >,
28544                    fidl::encoding::DefaultFuchsiaResourceDialect,
28545                    val_ref,
28546                    decoder,
28547                    inner_offset,
28548                    inner_depth
28549                )?;
28550                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28551                {
28552                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28553                }
28554                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28555                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28556                }
28557            }
28558
28559            next_offset += envelope_size;
28560            _next_ordinal_to_read += 1;
28561            if next_offset >= end_offset {
28562                return Ok(());
28563            }
28564
28565            // Decode unknown envelopes for gaps in ordinals.
28566            while _next_ordinal_to_read < 4 {
28567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28568                _next_ordinal_to_read += 1;
28569                next_offset += envelope_size;
28570            }
28571
28572            let next_out_of_line = decoder.next_out_of_line();
28573            let handles_before = decoder.remaining_handles();
28574            if let Some((inlined, num_bytes, num_handles)) =
28575                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28576            {
28577                let member_inline_size =
28578                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28579                if inlined != (member_inline_size <= 4) {
28580                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28581                }
28582                let inner_offset;
28583                let mut inner_depth = depth.clone();
28584                if inlined {
28585                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28586                    inner_offset = next_offset;
28587                } else {
28588                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28589                    inner_depth.increment()?;
28590                }
28591                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
28592                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28593                });
28594                fidl::decode!(
28595                    u64,
28596                    fidl::encoding::DefaultFuchsiaResourceDialect,
28597                    val_ref,
28598                    decoder,
28599                    inner_offset,
28600                    inner_depth
28601                )?;
28602                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28603                {
28604                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28605                }
28606                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28607                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28608                }
28609            }
28610
28611            next_offset += envelope_size;
28612            _next_ordinal_to_read += 1;
28613            if next_offset >= end_offset {
28614                return Ok(());
28615            }
28616
28617            // Decode unknown envelopes for gaps in ordinals.
28618            while _next_ordinal_to_read < 5 {
28619                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28620                _next_ordinal_to_read += 1;
28621                next_offset += envelope_size;
28622            }
28623
28624            let next_out_of_line = decoder.next_out_of_line();
28625            let handles_before = decoder.remaining_handles();
28626            if let Some((inlined, num_bytes, num_handles)) =
28627                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28628            {
28629                let member_inline_size =
28630                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28631                if inlined != (member_inline_size <= 4) {
28632                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28633                }
28634                let inner_offset;
28635                let mut inner_depth = depth.clone();
28636                if inlined {
28637                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28638                    inner_offset = next_offset;
28639                } else {
28640                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28641                    inner_depth.increment()?;
28642                }
28643                let val_ref = self.allow_single_buffer.get_or_insert_with(|| {
28644                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
28645                });
28646                fidl::decode!(
28647                    bool,
28648                    fidl::encoding::DefaultFuchsiaResourceDialect,
28649                    val_ref,
28650                    decoder,
28651                    inner_offset,
28652                    inner_depth
28653                )?;
28654                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28655                {
28656                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28657                }
28658                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28659                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28660                }
28661            }
28662
28663            next_offset += envelope_size;
28664
28665            // Decode the remaining unknown envelopes.
28666            while next_offset < end_offset {
28667                _next_ordinal_to_read += 1;
28668                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28669                next_offset += envelope_size;
28670            }
28671
28672            Ok(())
28673        }
28674    }
28675
28676    impl StreamProcessorRemoveBufferRequest {
28677        #[inline(always)]
28678        fn max_ordinal_present(&self) -> u64 {
28679            if let Some(_) = self.buffer_index {
28680                return 3;
28681            }
28682            if let Some(_) = self.buffer_lifetime_ordinal {
28683                return 2;
28684            }
28685            if let Some(_) = self.port {
28686                return 1;
28687            }
28688            0
28689        }
28690    }
28691
28692    impl fidl::encoding::ResourceTypeMarker for StreamProcessorRemoveBufferRequest {
28693        type Borrowed<'a> = &'a mut Self;
28694        fn take_or_borrow<'a>(
28695            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
28696        ) -> Self::Borrowed<'a> {
28697            value
28698        }
28699    }
28700
28701    unsafe impl fidl::encoding::TypeMarker for StreamProcessorRemoveBufferRequest {
28702        type Owned = Self;
28703
28704        #[inline(always)]
28705        fn inline_align(_context: fidl::encoding::Context) -> usize {
28706            8
28707        }
28708
28709        #[inline(always)]
28710        fn inline_size(_context: fidl::encoding::Context) -> usize {
28711            16
28712        }
28713    }
28714
28715    unsafe impl
28716        fidl::encoding::Encode<
28717            StreamProcessorRemoveBufferRequest,
28718            fidl::encoding::DefaultFuchsiaResourceDialect,
28719        > for &mut StreamProcessorRemoveBufferRequest
28720    {
28721        unsafe fn encode(
28722            self,
28723            encoder: &mut fidl::encoding::Encoder<
28724                '_,
28725                fidl::encoding::DefaultFuchsiaResourceDialect,
28726            >,
28727            offset: usize,
28728            mut depth: fidl::encoding::Depth,
28729        ) -> fidl::Result<()> {
28730            encoder.debug_check_bounds::<StreamProcessorRemoveBufferRequest>(offset);
28731            // Vector header
28732            let max_ordinal: u64 = self.max_ordinal_present();
28733            encoder.write_num(max_ordinal, offset);
28734            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
28735            // Calling encoder.out_of_line_offset(0) is not allowed.
28736            if max_ordinal == 0 {
28737                return Ok(());
28738            }
28739            depth.increment()?;
28740            let envelope_size = 8;
28741            let bytes_len = max_ordinal as usize * envelope_size;
28742            #[allow(unused_variables)]
28743            let offset = encoder.out_of_line_offset(bytes_len);
28744            let mut _prev_end_offset: usize = 0;
28745            if 1 > max_ordinal {
28746                return Ok(());
28747            }
28748
28749            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28750            // are envelope_size bytes.
28751            let cur_offset: usize = (1 - 1) * envelope_size;
28752
28753            // Zero reserved fields.
28754            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28755
28756            // Safety:
28757            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28758            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28759            //   envelope_size bytes, there is always sufficient room.
28760            fidl::encoding::encode_in_envelope_optional::<
28761                Port,
28762                fidl::encoding::DefaultFuchsiaResourceDialect,
28763            >(
28764                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
28765                encoder,
28766                offset + cur_offset,
28767                depth,
28768            )?;
28769
28770            _prev_end_offset = cur_offset + envelope_size;
28771            if 2 > max_ordinal {
28772                return Ok(());
28773            }
28774
28775            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28776            // are envelope_size bytes.
28777            let cur_offset: usize = (2 - 1) * envelope_size;
28778
28779            // Zero reserved fields.
28780            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28781
28782            // Safety:
28783            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28784            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28785            //   envelope_size bytes, there is always sufficient room.
28786            fidl::encoding::encode_in_envelope_optional::<
28787                u64,
28788                fidl::encoding::DefaultFuchsiaResourceDialect,
28789            >(
28790                self.buffer_lifetime_ordinal
28791                    .as_ref()
28792                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28793                encoder,
28794                offset + cur_offset,
28795                depth,
28796            )?;
28797
28798            _prev_end_offset = cur_offset + envelope_size;
28799            if 3 > max_ordinal {
28800                return Ok(());
28801            }
28802
28803            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28804            // are envelope_size bytes.
28805            let cur_offset: usize = (3 - 1) * envelope_size;
28806
28807            // Zero reserved fields.
28808            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28809
28810            // Safety:
28811            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28812            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28813            //   envelope_size bytes, there is always sufficient room.
28814            fidl::encoding::encode_in_envelope_optional::<
28815                u32,
28816                fidl::encoding::DefaultFuchsiaResourceDialect,
28817            >(
28818                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
28819                encoder,
28820                offset + cur_offset,
28821                depth,
28822            )?;
28823
28824            _prev_end_offset = cur_offset + envelope_size;
28825
28826            Ok(())
28827        }
28828    }
28829
28830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
28831        for StreamProcessorRemoveBufferRequest
28832    {
28833        #[inline(always)]
28834        fn new_empty() -> Self {
28835            Self::default()
28836        }
28837
28838        unsafe fn decode(
28839            &mut self,
28840            decoder: &mut fidl::encoding::Decoder<
28841                '_,
28842                fidl::encoding::DefaultFuchsiaResourceDialect,
28843            >,
28844            offset: usize,
28845            mut depth: fidl::encoding::Depth,
28846        ) -> fidl::Result<()> {
28847            decoder.debug_check_bounds::<Self>(offset);
28848            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
28849                None => return Err(fidl::Error::NotNullable),
28850                Some(len) => len,
28851            };
28852            // Calling decoder.out_of_line_offset(0) is not allowed.
28853            if len == 0 {
28854                return Ok(());
28855            };
28856            depth.increment()?;
28857            let envelope_size = 8;
28858            let bytes_len = len * envelope_size;
28859            let offset = decoder.out_of_line_offset(bytes_len)?;
28860            // Decode the envelope for each type.
28861            let mut _next_ordinal_to_read = 0;
28862            let mut next_offset = offset;
28863            let end_offset = offset + bytes_len;
28864            _next_ordinal_to_read += 1;
28865            if next_offset >= end_offset {
28866                return Ok(());
28867            }
28868
28869            // Decode unknown envelopes for gaps in ordinals.
28870            while _next_ordinal_to_read < 1 {
28871                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28872                _next_ordinal_to_read += 1;
28873                next_offset += envelope_size;
28874            }
28875
28876            let next_out_of_line = decoder.next_out_of_line();
28877            let handles_before = decoder.remaining_handles();
28878            if let Some((inlined, num_bytes, num_handles)) =
28879                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28880            {
28881                let member_inline_size =
28882                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28883                if inlined != (member_inline_size <= 4) {
28884                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28885                }
28886                let inner_offset;
28887                let mut inner_depth = depth.clone();
28888                if inlined {
28889                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28890                    inner_offset = next_offset;
28891                } else {
28892                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28893                    inner_depth.increment()?;
28894                }
28895                let val_ref = self.port.get_or_insert_with(|| {
28896                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
28897                });
28898                fidl::decode!(
28899                    Port,
28900                    fidl::encoding::DefaultFuchsiaResourceDialect,
28901                    val_ref,
28902                    decoder,
28903                    inner_offset,
28904                    inner_depth
28905                )?;
28906                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28907                {
28908                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28909                }
28910                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28911                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28912                }
28913            }
28914
28915            next_offset += envelope_size;
28916            _next_ordinal_to_read += 1;
28917            if next_offset >= end_offset {
28918                return Ok(());
28919            }
28920
28921            // Decode unknown envelopes for gaps in ordinals.
28922            while _next_ordinal_to_read < 2 {
28923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28924                _next_ordinal_to_read += 1;
28925                next_offset += envelope_size;
28926            }
28927
28928            let next_out_of_line = decoder.next_out_of_line();
28929            let handles_before = decoder.remaining_handles();
28930            if let Some((inlined, num_bytes, num_handles)) =
28931                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28932            {
28933                let member_inline_size =
28934                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28935                if inlined != (member_inline_size <= 4) {
28936                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28937                }
28938                let inner_offset;
28939                let mut inner_depth = depth.clone();
28940                if inlined {
28941                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28942                    inner_offset = next_offset;
28943                } else {
28944                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28945                    inner_depth.increment()?;
28946                }
28947                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
28948                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28949                });
28950                fidl::decode!(
28951                    u64,
28952                    fidl::encoding::DefaultFuchsiaResourceDialect,
28953                    val_ref,
28954                    decoder,
28955                    inner_offset,
28956                    inner_depth
28957                )?;
28958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28959                {
28960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28961                }
28962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28964                }
28965            }
28966
28967            next_offset += envelope_size;
28968            _next_ordinal_to_read += 1;
28969            if next_offset >= end_offset {
28970                return Ok(());
28971            }
28972
28973            // Decode unknown envelopes for gaps in ordinals.
28974            while _next_ordinal_to_read < 3 {
28975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28976                _next_ordinal_to_read += 1;
28977                next_offset += envelope_size;
28978            }
28979
28980            let next_out_of_line = decoder.next_out_of_line();
28981            let handles_before = decoder.remaining_handles();
28982            if let Some((inlined, num_bytes, num_handles)) =
28983                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28984            {
28985                let member_inline_size =
28986                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28987                if inlined != (member_inline_size <= 4) {
28988                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28989                }
28990                let inner_offset;
28991                let mut inner_depth = depth.clone();
28992                if inlined {
28993                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28994                    inner_offset = next_offset;
28995                } else {
28996                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28997                    inner_depth.increment()?;
28998                }
28999                let val_ref = self.buffer_index.get_or_insert_with(|| {
29000                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
29001                });
29002                fidl::decode!(
29003                    u32,
29004                    fidl::encoding::DefaultFuchsiaResourceDialect,
29005                    val_ref,
29006                    decoder,
29007                    inner_offset,
29008                    inner_depth
29009                )?;
29010                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
29011                {
29012                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
29013                }
29014                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
29015                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
29016                }
29017            }
29018
29019            next_offset += envelope_size;
29020
29021            // Decode the remaining unknown envelopes.
29022            while next_offset < end_offset {
29023                _next_ordinal_to_read += 1;
29024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
29025                next_offset += envelope_size;
29026            }
29027
29028            Ok(())
29029        }
29030    }
29031}