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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub enum VfsType {
15 Blobfs,
16 Fatfs,
17 Minfs,
18 Memfs,
19 Factoryfs,
20 Fxfs,
21 F2Fs,
22 #[doc(hidden)]
23 __SourceBreaking {
24 unknown_ordinal: u32,
25 },
26}
27
28#[macro_export]
30macro_rules! VfsTypeUnknown {
31 () => {
32 _
33 };
34}
35
36impl VfsType {
37 #[inline]
38 pub fn from_primitive(prim: u32) -> Option<Self> {
39 match prim {
40 2657701153 => Some(Self::Blobfs),
41 3463007521 => Some(Self::Fatfs),
42 1852394785 => Some(Self::Minfs),
43 1047088417 => Some(Self::Memfs),
44 510217505 => Some(Self::Factoryfs),
45 1936095334 => Some(Self::Fxfs),
46 4268313889 => Some(Self::F2Fs),
47 _ => None,
48 }
49 }
50
51 #[inline]
52 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
53 match prim {
54 2657701153 => Self::Blobfs,
55 3463007521 => Self::Fatfs,
56 1852394785 => Self::Minfs,
57 1047088417 => Self::Memfs,
58 510217505 => Self::Factoryfs,
59 1936095334 => Self::Fxfs,
60 4268313889 => Self::F2Fs,
61 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
62 }
63 }
64
65 #[inline]
66 pub fn unknown() -> Self {
67 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
68 }
69
70 #[inline]
71 pub const fn into_primitive(self) -> u32 {
72 match self {
73 Self::Blobfs => 2657701153,
74 Self::Fatfs => 3463007521,
75 Self::Minfs => 1852394785,
76 Self::Memfs => 1047088417,
77 Self::Factoryfs => 510217505,
78 Self::Fxfs => 1936095334,
79 Self::F2Fs => 4268313889,
80 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
81 }
82 }
83
84 #[inline]
85 pub fn is_unknown(&self) -> bool {
86 match self {
87 Self::__SourceBreaking { unknown_ordinal: _ } => true,
88 _ => false,
89 }
90 }
91}
92
93#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
94pub struct AdminMarker;
95
96impl fidl::endpoints::ProtocolMarker for AdminMarker {
97 type Proxy = AdminProxy;
98 type RequestStream = AdminRequestStream;
99 #[cfg(target_os = "fuchsia")]
100 type SynchronousProxy = AdminSynchronousProxy;
101
102 const DEBUG_NAME: &'static str = "fuchsia.fs.Admin";
103}
104impl fidl::endpoints::DiscoverableProtocolMarker for AdminMarker {}
105
106pub trait AdminProxyInterface: Send + Sync {
107 type ShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
108 fn r#shutdown(&self) -> Self::ShutdownResponseFut;
109}
110#[derive(Debug)]
111#[cfg(target_os = "fuchsia")]
112pub struct AdminSynchronousProxy {
113 client: fidl::client::sync::Client,
114}
115
116#[cfg(target_os = "fuchsia")]
117impl fidl::endpoints::SynchronousProxy for AdminSynchronousProxy {
118 type Proxy = AdminProxy;
119 type Protocol = AdminMarker;
120
121 fn from_channel(inner: fidl::Channel) -> Self {
122 Self::new(inner)
123 }
124
125 fn into_channel(self) -> fidl::Channel {
126 self.client.into_channel()
127 }
128
129 fn as_channel(&self) -> &fidl::Channel {
130 self.client.as_channel()
131 }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl AdminSynchronousProxy {
136 pub fn new(channel: fidl::Channel) -> Self {
137 let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
138 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
139 }
140
141 pub fn into_channel(self) -> fidl::Channel {
142 self.client.into_channel()
143 }
144
145 pub fn wait_for_event(
148 &self,
149 deadline: zx::MonotonicInstant,
150 ) -> Result<AdminEvent, fidl::Error> {
151 AdminEvent::decode(self.client.wait_for_event(deadline)?)
152 }
153
154 pub fn r#shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
160 let _response =
161 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
162 (),
163 0x5476abc45167ca8e,
164 fidl::encoding::DynamicFlags::empty(),
165 ___deadline,
166 )?;
167 Ok(_response)
168 }
169}
170
171#[derive(Debug, Clone)]
172pub struct AdminProxy {
173 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
174}
175
176impl fidl::endpoints::Proxy for AdminProxy {
177 type Protocol = AdminMarker;
178
179 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
180 Self::new(inner)
181 }
182
183 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
184 self.client.into_channel().map_err(|client| Self { client })
185 }
186
187 fn as_channel(&self) -> &::fidl::AsyncChannel {
188 self.client.as_channel()
189 }
190}
191
192impl AdminProxy {
193 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
195 let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
196 Self { client: fidl::client::Client::new(channel, protocol_name) }
197 }
198
199 pub fn take_event_stream(&self) -> AdminEventStream {
205 AdminEventStream { event_receiver: self.client.take_event_receiver() }
206 }
207
208 pub fn r#shutdown(
214 &self,
215 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
216 AdminProxyInterface::r#shutdown(self)
217 }
218}
219
220impl AdminProxyInterface for AdminProxy {
221 type ShutdownResponseFut =
222 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
223 fn r#shutdown(&self) -> Self::ShutdownResponseFut {
224 fn _decode(
225 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
226 ) -> Result<(), fidl::Error> {
227 let _response = fidl::client::decode_transaction_body::<
228 fidl::encoding::EmptyPayload,
229 fidl::encoding::DefaultFuchsiaResourceDialect,
230 0x5476abc45167ca8e,
231 >(_buf?)?;
232 Ok(_response)
233 }
234 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
235 (),
236 0x5476abc45167ca8e,
237 fidl::encoding::DynamicFlags::empty(),
238 _decode,
239 )
240 }
241}
242
243pub struct AdminEventStream {
244 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
245}
246
247impl std::marker::Unpin for AdminEventStream {}
248
249impl futures::stream::FusedStream for AdminEventStream {
250 fn is_terminated(&self) -> bool {
251 self.event_receiver.is_terminated()
252 }
253}
254
255impl futures::Stream for AdminEventStream {
256 type Item = Result<AdminEvent, fidl::Error>;
257
258 fn poll_next(
259 mut self: std::pin::Pin<&mut Self>,
260 cx: &mut std::task::Context<'_>,
261 ) -> std::task::Poll<Option<Self::Item>> {
262 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
263 &mut self.event_receiver,
264 cx
265 )?) {
266 Some(buf) => std::task::Poll::Ready(Some(AdminEvent::decode(buf))),
267 None => std::task::Poll::Ready(None),
268 }
269 }
270}
271
272#[derive(Debug)]
273pub enum AdminEvent {}
274
275impl AdminEvent {
276 fn decode(
278 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
279 ) -> Result<AdminEvent, fidl::Error> {
280 let (bytes, _handles) = buf.split_mut();
281 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
282 debug_assert_eq!(tx_header.tx_id, 0);
283 match tx_header.ordinal {
284 _ => Err(fidl::Error::UnknownOrdinal {
285 ordinal: tx_header.ordinal,
286 protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
287 }),
288 }
289 }
290}
291
292pub struct AdminRequestStream {
294 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
295 is_terminated: bool,
296}
297
298impl std::marker::Unpin for AdminRequestStream {}
299
300impl futures::stream::FusedStream for AdminRequestStream {
301 fn is_terminated(&self) -> bool {
302 self.is_terminated
303 }
304}
305
306impl fidl::endpoints::RequestStream for AdminRequestStream {
307 type Protocol = AdminMarker;
308 type ControlHandle = AdminControlHandle;
309
310 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
311 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
312 }
313
314 fn control_handle(&self) -> Self::ControlHandle {
315 AdminControlHandle { inner: self.inner.clone() }
316 }
317
318 fn into_inner(
319 self,
320 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
321 {
322 (self.inner, self.is_terminated)
323 }
324
325 fn from_inner(
326 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
327 is_terminated: bool,
328 ) -> Self {
329 Self { inner, is_terminated }
330 }
331}
332
333impl futures::Stream for AdminRequestStream {
334 type Item = Result<AdminRequest, fidl::Error>;
335
336 fn poll_next(
337 mut self: std::pin::Pin<&mut Self>,
338 cx: &mut std::task::Context<'_>,
339 ) -> std::task::Poll<Option<Self::Item>> {
340 let this = &mut *self;
341 if this.inner.check_shutdown(cx) {
342 this.is_terminated = true;
343 return std::task::Poll::Ready(None);
344 }
345 if this.is_terminated {
346 panic!("polled AdminRequestStream after completion");
347 }
348 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
349 |bytes, handles| {
350 match this.inner.channel().read_etc(cx, bytes, handles) {
351 std::task::Poll::Ready(Ok(())) => {}
352 std::task::Poll::Pending => return std::task::Poll::Pending,
353 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
354 this.is_terminated = true;
355 return std::task::Poll::Ready(None);
356 }
357 std::task::Poll::Ready(Err(e)) => {
358 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
359 e.into(),
360 ))))
361 }
362 }
363
364 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
366
367 std::task::Poll::Ready(Some(match header.ordinal {
368 0x5476abc45167ca8e => {
369 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
370 let mut req = fidl::new_empty!(
371 fidl::encoding::EmptyPayload,
372 fidl::encoding::DefaultFuchsiaResourceDialect
373 );
374 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
375 let control_handle = AdminControlHandle { inner: this.inner.clone() };
376 Ok(AdminRequest::Shutdown {
377 responder: AdminShutdownResponder {
378 control_handle: std::mem::ManuallyDrop::new(control_handle),
379 tx_id: header.tx_id,
380 },
381 })
382 }
383 _ => Err(fidl::Error::UnknownOrdinal {
384 ordinal: header.ordinal,
385 protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
386 }),
387 }))
388 },
389 )
390 }
391}
392
393#[derive(Debug)]
395pub enum AdminRequest {
396 Shutdown { responder: AdminShutdownResponder },
402}
403
404impl AdminRequest {
405 #[allow(irrefutable_let_patterns)]
406 pub fn into_shutdown(self) -> Option<(AdminShutdownResponder)> {
407 if let AdminRequest::Shutdown { responder } = self {
408 Some((responder))
409 } else {
410 None
411 }
412 }
413
414 pub fn method_name(&self) -> &'static str {
416 match *self {
417 AdminRequest::Shutdown { .. } => "shutdown",
418 }
419 }
420}
421
422#[derive(Debug, Clone)]
423pub struct AdminControlHandle {
424 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
425}
426
427impl fidl::endpoints::ControlHandle for AdminControlHandle {
428 fn shutdown(&self) {
429 self.inner.shutdown()
430 }
431 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
432 self.inner.shutdown_with_epitaph(status)
433 }
434
435 fn is_closed(&self) -> bool {
436 self.inner.channel().is_closed()
437 }
438 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
439 self.inner.channel().on_closed()
440 }
441
442 #[cfg(target_os = "fuchsia")]
443 fn signal_peer(
444 &self,
445 clear_mask: zx::Signals,
446 set_mask: zx::Signals,
447 ) -> Result<(), zx_status::Status> {
448 use fidl::Peered;
449 self.inner.channel().signal_peer(clear_mask, set_mask)
450 }
451}
452
453impl AdminControlHandle {}
454
455#[must_use = "FIDL methods require a response to be sent"]
456#[derive(Debug)]
457pub struct AdminShutdownResponder {
458 control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
459 tx_id: u32,
460}
461
462impl std::ops::Drop for AdminShutdownResponder {
466 fn drop(&mut self) {
467 self.control_handle.shutdown();
468 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
470 }
471}
472
473impl fidl::endpoints::Responder for AdminShutdownResponder {
474 type ControlHandle = AdminControlHandle;
475
476 fn control_handle(&self) -> &AdminControlHandle {
477 &self.control_handle
478 }
479
480 fn drop_without_shutdown(mut self) {
481 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
483 std::mem::forget(self);
485 }
486}
487
488impl AdminShutdownResponder {
489 pub fn send(self) -> Result<(), fidl::Error> {
493 let _result = self.send_raw();
494 if _result.is_err() {
495 self.control_handle.shutdown();
496 }
497 self.drop_without_shutdown();
498 _result
499 }
500
501 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
503 let _result = self.send_raw();
504 self.drop_without_shutdown();
505 _result
506 }
507
508 fn send_raw(&self) -> Result<(), fidl::Error> {
509 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
510 (),
511 self.tx_id,
512 0x5476abc45167ca8e,
513 fidl::encoding::DynamicFlags::empty(),
514 )
515 }
516}
517
518mod internal {
519 use super::*;
520 unsafe impl fidl::encoding::TypeMarker for VfsType {
521 type Owned = Self;
522
523 #[inline(always)]
524 fn inline_align(_context: fidl::encoding::Context) -> usize {
525 std::mem::align_of::<u32>()
526 }
527
528 #[inline(always)]
529 fn inline_size(_context: fidl::encoding::Context) -> usize {
530 std::mem::size_of::<u32>()
531 }
532
533 #[inline(always)]
534 fn encode_is_copy() -> bool {
535 false
536 }
537
538 #[inline(always)]
539 fn decode_is_copy() -> bool {
540 false
541 }
542 }
543
544 impl fidl::encoding::ValueTypeMarker for VfsType {
545 type Borrowed<'a> = Self;
546 #[inline(always)]
547 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
548 *value
549 }
550 }
551
552 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for VfsType {
553 #[inline]
554 unsafe fn encode(
555 self,
556 encoder: &mut fidl::encoding::Encoder<'_, D>,
557 offset: usize,
558 _depth: fidl::encoding::Depth,
559 ) -> fidl::Result<()> {
560 encoder.debug_check_bounds::<Self>(offset);
561 encoder.write_num(self.into_primitive(), offset);
562 Ok(())
563 }
564 }
565
566 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VfsType {
567 #[inline(always)]
568 fn new_empty() -> Self {
569 Self::unknown()
570 }
571
572 #[inline]
573 unsafe fn decode(
574 &mut self,
575 decoder: &mut fidl::encoding::Decoder<'_, D>,
576 offset: usize,
577 _depth: fidl::encoding::Depth,
578 ) -> fidl::Result<()> {
579 decoder.debug_check_bounds::<Self>(offset);
580 let prim = decoder.read_num::<u32>(offset);
581
582 *self = Self::from_primitive_allow_unknown(prim);
583 Ok(())
584 }
585 }
586}