1#![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_storage_blobfs__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct OverwriteConfigurationMarker;
16
17impl fidl::endpoints::ProtocolMarker for OverwriteConfigurationMarker {
18 type Proxy = OverwriteConfigurationProxy;
19 type RequestStream = OverwriteConfigurationRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = OverwriteConfigurationSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.storage.blobfs.OverwriteConfiguration";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for OverwriteConfigurationMarker {}
26pub type OverwriteConfigurationSetResult = Result<(), i32>;
27
28pub trait OverwriteConfigurationProxyInterface: Send + Sync {
29 type SetResponseFut: std::future::Future<Output = Result<OverwriteConfigurationSetResult, fidl::Error>>
30 + Send;
31 fn r#set(&self, overwrite_format: OverwriteFormat) -> Self::SetResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct OverwriteConfigurationSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for OverwriteConfigurationSynchronousProxy {
41 type Proxy = OverwriteConfigurationProxy;
42 type Protocol = OverwriteConfigurationMarker;
43
44 fn from_channel(inner: fidl::Channel) -> Self {
45 Self::new(inner)
46 }
47
48 fn into_channel(self) -> fidl::Channel {
49 self.client.into_channel()
50 }
51
52 fn as_channel(&self) -> &fidl::Channel {
53 self.client.as_channel()
54 }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl OverwriteConfigurationSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 Self { client: fidl::client::sync::Client::new(channel) }
61 }
62
63 pub fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 pub fn wait_for_event(
70 &self,
71 deadline: zx::MonotonicInstant,
72 ) -> Result<OverwriteConfigurationEvent, fidl::Error> {
73 OverwriteConfigurationEvent::decode(
74 self.client.wait_for_event::<OverwriteConfigurationMarker>(deadline)?,
75 )
76 }
77
78 pub fn r#set(
80 &self,
81 mut overwrite_format: OverwriteFormat,
82 ___deadline: zx::MonotonicInstant,
83 ) -> Result<OverwriteConfigurationSetResult, fidl::Error> {
84 let _response = self.client.send_query::<
85 OverwriteConfigurationSetRequest,
86 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
87 OverwriteConfigurationMarker,
88 >(
89 (overwrite_format,),
90 0x756a2a36396e0e08,
91 fidl::encoding::DynamicFlags::empty(),
92 ___deadline,
93 )?;
94 Ok(_response.map(|x| x))
95 }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl From<OverwriteConfigurationSynchronousProxy> for zx::NullableHandle {
100 fn from(value: OverwriteConfigurationSynchronousProxy) -> Self {
101 value.into_channel().into()
102 }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<fidl::Channel> for OverwriteConfigurationSynchronousProxy {
107 fn from(value: fidl::Channel) -> Self {
108 Self::new(value)
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl fidl::endpoints::FromClient for OverwriteConfigurationSynchronousProxy {
114 type Protocol = OverwriteConfigurationMarker;
115
116 fn from_client(value: fidl::endpoints::ClientEnd<OverwriteConfigurationMarker>) -> Self {
117 Self::new(value.into_channel())
118 }
119}
120
121#[derive(Debug, Clone)]
122pub struct OverwriteConfigurationProxy {
123 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
124}
125
126impl fidl::endpoints::Proxy for OverwriteConfigurationProxy {
127 type Protocol = OverwriteConfigurationMarker;
128
129 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
130 Self::new(inner)
131 }
132
133 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
134 self.client.into_channel().map_err(|client| Self { client })
135 }
136
137 fn as_channel(&self) -> &::fidl::AsyncChannel {
138 self.client.as_channel()
139 }
140}
141
142impl OverwriteConfigurationProxy {
143 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
145 let protocol_name =
146 <OverwriteConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
147 Self { client: fidl::client::Client::new(channel, protocol_name) }
148 }
149
150 pub fn take_event_stream(&self) -> OverwriteConfigurationEventStream {
156 OverwriteConfigurationEventStream { event_receiver: self.client.take_event_receiver() }
157 }
158
159 pub fn r#set(
161 &self,
162 mut overwrite_format: OverwriteFormat,
163 ) -> fidl::client::QueryResponseFut<
164 OverwriteConfigurationSetResult,
165 fidl::encoding::DefaultFuchsiaResourceDialect,
166 > {
167 OverwriteConfigurationProxyInterface::r#set(self, overwrite_format)
168 }
169}
170
171impl OverwriteConfigurationProxyInterface for OverwriteConfigurationProxy {
172 type SetResponseFut = fidl::client::QueryResponseFut<
173 OverwriteConfigurationSetResult,
174 fidl::encoding::DefaultFuchsiaResourceDialect,
175 >;
176 fn r#set(&self, mut overwrite_format: OverwriteFormat) -> Self::SetResponseFut {
177 fn _decode(
178 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
179 ) -> Result<OverwriteConfigurationSetResult, fidl::Error> {
180 let _response = fidl::client::decode_transaction_body::<
181 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
182 fidl::encoding::DefaultFuchsiaResourceDialect,
183 0x756a2a36396e0e08,
184 >(_buf?)?;
185 Ok(_response.map(|x| x))
186 }
187 self.client.send_query_and_decode::<
188 OverwriteConfigurationSetRequest,
189 OverwriteConfigurationSetResult,
190 >(
191 (overwrite_format,),
192 0x756a2a36396e0e08,
193 fidl::encoding::DynamicFlags::empty(),
194 _decode,
195 )
196 }
197}
198
199pub struct OverwriteConfigurationEventStream {
200 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
201}
202
203impl std::marker::Unpin for OverwriteConfigurationEventStream {}
204
205impl futures::stream::FusedStream for OverwriteConfigurationEventStream {
206 fn is_terminated(&self) -> bool {
207 self.event_receiver.is_terminated()
208 }
209}
210
211impl futures::Stream for OverwriteConfigurationEventStream {
212 type Item = Result<OverwriteConfigurationEvent, fidl::Error>;
213
214 fn poll_next(
215 mut self: std::pin::Pin<&mut Self>,
216 cx: &mut std::task::Context<'_>,
217 ) -> std::task::Poll<Option<Self::Item>> {
218 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
219 &mut self.event_receiver,
220 cx
221 )?) {
222 Some(buf) => std::task::Poll::Ready(Some(OverwriteConfigurationEvent::decode(buf))),
223 None => std::task::Poll::Ready(None),
224 }
225 }
226}
227
228#[derive(Debug)]
229pub enum OverwriteConfigurationEvent {
230 #[non_exhaustive]
231 _UnknownEvent {
232 ordinal: u64,
234 },
235}
236
237impl OverwriteConfigurationEvent {
238 fn decode(
240 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
241 ) -> Result<OverwriteConfigurationEvent, fidl::Error> {
242 let (bytes, _handles) = buf.split_mut();
243 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
244 debug_assert_eq!(tx_header.tx_id, 0);
245 match tx_header.ordinal {
246 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
247 Ok(OverwriteConfigurationEvent::_UnknownEvent { ordinal: tx_header.ordinal })
248 }
249 _ => Err(fidl::Error::UnknownOrdinal {
250 ordinal: tx_header.ordinal,
251 protocol_name:
252 <OverwriteConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
253 }),
254 }
255 }
256}
257
258pub struct OverwriteConfigurationRequestStream {
260 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261 is_terminated: bool,
262}
263
264impl std::marker::Unpin for OverwriteConfigurationRequestStream {}
265
266impl futures::stream::FusedStream for OverwriteConfigurationRequestStream {
267 fn is_terminated(&self) -> bool {
268 self.is_terminated
269 }
270}
271
272impl fidl::endpoints::RequestStream for OverwriteConfigurationRequestStream {
273 type Protocol = OverwriteConfigurationMarker;
274 type ControlHandle = OverwriteConfigurationControlHandle;
275
276 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
277 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
278 }
279
280 fn control_handle(&self) -> Self::ControlHandle {
281 OverwriteConfigurationControlHandle { inner: self.inner.clone() }
282 }
283
284 fn into_inner(
285 self,
286 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
287 {
288 (self.inner, self.is_terminated)
289 }
290
291 fn from_inner(
292 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293 is_terminated: bool,
294 ) -> Self {
295 Self { inner, is_terminated }
296 }
297}
298
299impl futures::Stream for OverwriteConfigurationRequestStream {
300 type Item = Result<OverwriteConfigurationRequest, fidl::Error>;
301
302 fn poll_next(
303 mut self: std::pin::Pin<&mut Self>,
304 cx: &mut std::task::Context<'_>,
305 ) -> std::task::Poll<Option<Self::Item>> {
306 let this = &mut *self;
307 if this.inner.check_shutdown(cx) {
308 this.is_terminated = true;
309 return std::task::Poll::Ready(None);
310 }
311 if this.is_terminated {
312 panic!("polled OverwriteConfigurationRequestStream after completion");
313 }
314 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
315 |bytes, handles| {
316 match this.inner.channel().read_etc(cx, bytes, handles) {
317 std::task::Poll::Ready(Ok(())) => {}
318 std::task::Poll::Pending => return std::task::Poll::Pending,
319 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
320 this.is_terminated = true;
321 return std::task::Poll::Ready(None);
322 }
323 std::task::Poll::Ready(Err(e)) => {
324 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
325 e.into(),
326 ))));
327 }
328 }
329
330 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
332
333 std::task::Poll::Ready(Some(match header.ordinal {
334 0x756a2a36396e0e08 => {
335 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
336 let mut req = fidl::new_empty!(OverwriteConfigurationSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
337 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<OverwriteConfigurationSetRequest>(&header, _body_bytes, handles, &mut req)?;
338 let control_handle = OverwriteConfigurationControlHandle {
339 inner: this.inner.clone(),
340 };
341 Ok(OverwriteConfigurationRequest::Set {overwrite_format: req.overwrite_format,
342
343 responder: OverwriteConfigurationSetResponder {
344 control_handle: std::mem::ManuallyDrop::new(control_handle),
345 tx_id: header.tx_id,
346 },
347 })
348 }
349 _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
350 Ok(OverwriteConfigurationRequest::_UnknownMethod {
351 ordinal: header.ordinal,
352 control_handle: OverwriteConfigurationControlHandle { inner: this.inner.clone() },
353 method_type: fidl::MethodType::OneWay,
354 })
355 }
356 _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
357 this.inner.send_framework_err(
358 fidl::encoding::FrameworkErr::UnknownMethod,
359 header.tx_id,
360 header.ordinal,
361 header.dynamic_flags(),
362 (bytes, handles),
363 )?;
364 Ok(OverwriteConfigurationRequest::_UnknownMethod {
365 ordinal: header.ordinal,
366 control_handle: OverwriteConfigurationControlHandle { inner: this.inner.clone() },
367 method_type: fidl::MethodType::TwoWay,
368 })
369 }
370 _ => Err(fidl::Error::UnknownOrdinal {
371 ordinal: header.ordinal,
372 protocol_name: <OverwriteConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
373 }),
374 }))
375 },
376 )
377 }
378}
379
380#[derive(Debug)]
384pub enum OverwriteConfigurationRequest {
385 Set { overwrite_format: OverwriteFormat, responder: OverwriteConfigurationSetResponder },
387 #[non_exhaustive]
389 _UnknownMethod {
390 ordinal: u64,
392 control_handle: OverwriteConfigurationControlHandle,
393 method_type: fidl::MethodType,
394 },
395}
396
397impl OverwriteConfigurationRequest {
398 #[allow(irrefutable_let_patterns)]
399 pub fn into_set(self) -> Option<(OverwriteFormat, OverwriteConfigurationSetResponder)> {
400 if let OverwriteConfigurationRequest::Set { overwrite_format, responder } = self {
401 Some((overwrite_format, responder))
402 } else {
403 None
404 }
405 }
406
407 pub fn method_name(&self) -> &'static str {
409 match *self {
410 OverwriteConfigurationRequest::Set { .. } => "set",
411 OverwriteConfigurationRequest::_UnknownMethod {
412 method_type: fidl::MethodType::OneWay,
413 ..
414 } => "unknown one-way method",
415 OverwriteConfigurationRequest::_UnknownMethod {
416 method_type: fidl::MethodType::TwoWay,
417 ..
418 } => "unknown two-way method",
419 }
420 }
421}
422
423#[derive(Debug, Clone)]
424pub struct OverwriteConfigurationControlHandle {
425 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
426}
427
428impl fidl::endpoints::ControlHandle for OverwriteConfigurationControlHandle {
429 fn shutdown(&self) {
430 self.inner.shutdown()
431 }
432
433 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
434 self.inner.shutdown_with_epitaph(status)
435 }
436
437 fn is_closed(&self) -> bool {
438 self.inner.channel().is_closed()
439 }
440 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
441 self.inner.channel().on_closed()
442 }
443
444 #[cfg(target_os = "fuchsia")]
445 fn signal_peer(
446 &self,
447 clear_mask: zx::Signals,
448 set_mask: zx::Signals,
449 ) -> Result<(), zx_status::Status> {
450 use fidl::Peered;
451 self.inner.channel().signal_peer(clear_mask, set_mask)
452 }
453}
454
455impl OverwriteConfigurationControlHandle {}
456
457#[must_use = "FIDL methods require a response to be sent"]
458#[derive(Debug)]
459pub struct OverwriteConfigurationSetResponder {
460 control_handle: std::mem::ManuallyDrop<OverwriteConfigurationControlHandle>,
461 tx_id: u32,
462}
463
464impl std::ops::Drop for OverwriteConfigurationSetResponder {
468 fn drop(&mut self) {
469 self.control_handle.shutdown();
470 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
472 }
473}
474
475impl fidl::endpoints::Responder for OverwriteConfigurationSetResponder {
476 type ControlHandle = OverwriteConfigurationControlHandle;
477
478 fn control_handle(&self) -> &OverwriteConfigurationControlHandle {
479 &self.control_handle
480 }
481
482 fn drop_without_shutdown(mut self) {
483 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
485 std::mem::forget(self);
487 }
488}
489
490impl OverwriteConfigurationSetResponder {
491 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
495 let _result = self.send_raw(result);
496 if _result.is_err() {
497 self.control_handle.shutdown();
498 }
499 self.drop_without_shutdown();
500 _result
501 }
502
503 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
505 let _result = self.send_raw(result);
506 self.drop_without_shutdown();
507 _result
508 }
509
510 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
511 self.control_handle
512 .inner
513 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
514 result,
515 self.tx_id,
516 0x756a2a36396e0e08,
517 fidl::encoding::DynamicFlags::empty(),
518 )
519 }
520}
521
522mod internal {
523 use super::*;
524}