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_fs__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct AdminMarker;
16
17impl fidl::endpoints::ProtocolMarker for AdminMarker {
18 type Proxy = AdminProxy;
19 type RequestStream = AdminRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = AdminSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.fs.Admin";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for AdminMarker {}
26
27pub trait AdminProxyInterface: Send + Sync {
28 type ShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
29 fn r#shutdown(&self) -> Self::ShutdownResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct AdminSynchronousProxy {
34 client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for AdminSynchronousProxy {
39 type Proxy = AdminProxy;
40 type Protocol = AdminMarker;
41
42 fn from_channel(inner: fidl::Channel) -> Self {
43 Self::new(inner)
44 }
45
46 fn into_channel(self) -> fidl::Channel {
47 self.client.into_channel()
48 }
49
50 fn as_channel(&self) -> &fidl::Channel {
51 self.client.as_channel()
52 }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl AdminSynchronousProxy {
57 pub fn new(channel: fidl::Channel) -> Self {
58 let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<AdminEvent, fidl::Error> {
72 AdminEvent::decode(self.client.wait_for_event(deadline)?)
73 }
74
75 pub fn r#shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
81 let _response =
82 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
83 (),
84 0x5476abc45167ca8e,
85 fidl::encoding::DynamicFlags::empty(),
86 ___deadline,
87 )?;
88 Ok(_response)
89 }
90}
91
92#[cfg(target_os = "fuchsia")]
93impl From<AdminSynchronousProxy> for zx::Handle {
94 fn from(value: AdminSynchronousProxy) -> Self {
95 value.into_channel().into()
96 }
97}
98
99#[cfg(target_os = "fuchsia")]
100impl From<fidl::Channel> for AdminSynchronousProxy {
101 fn from(value: fidl::Channel) -> Self {
102 Self::new(value)
103 }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl fidl::endpoints::FromClient for AdminSynchronousProxy {
108 type Protocol = AdminMarker;
109
110 fn from_client(value: fidl::endpoints::ClientEnd<AdminMarker>) -> Self {
111 Self::new(value.into_channel())
112 }
113}
114
115#[derive(Debug, Clone)]
116pub struct AdminProxy {
117 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
118}
119
120impl fidl::endpoints::Proxy for AdminProxy {
121 type Protocol = AdminMarker;
122
123 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
124 Self::new(inner)
125 }
126
127 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
128 self.client.into_channel().map_err(|client| Self { client })
129 }
130
131 fn as_channel(&self) -> &::fidl::AsyncChannel {
132 self.client.as_channel()
133 }
134}
135
136impl AdminProxy {
137 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
139 let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
140 Self { client: fidl::client::Client::new(channel, protocol_name) }
141 }
142
143 pub fn take_event_stream(&self) -> AdminEventStream {
149 AdminEventStream { event_receiver: self.client.take_event_receiver() }
150 }
151
152 pub fn r#shutdown(
158 &self,
159 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
160 AdminProxyInterface::r#shutdown(self)
161 }
162}
163
164impl AdminProxyInterface for AdminProxy {
165 type ShutdownResponseFut =
166 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
167 fn r#shutdown(&self) -> Self::ShutdownResponseFut {
168 fn _decode(
169 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
170 ) -> Result<(), fidl::Error> {
171 let _response = fidl::client::decode_transaction_body::<
172 fidl::encoding::EmptyPayload,
173 fidl::encoding::DefaultFuchsiaResourceDialect,
174 0x5476abc45167ca8e,
175 >(_buf?)?;
176 Ok(_response)
177 }
178 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
179 (),
180 0x5476abc45167ca8e,
181 fidl::encoding::DynamicFlags::empty(),
182 _decode,
183 )
184 }
185}
186
187pub struct AdminEventStream {
188 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
189}
190
191impl std::marker::Unpin for AdminEventStream {}
192
193impl futures::stream::FusedStream for AdminEventStream {
194 fn is_terminated(&self) -> bool {
195 self.event_receiver.is_terminated()
196 }
197}
198
199impl futures::Stream for AdminEventStream {
200 type Item = Result<AdminEvent, fidl::Error>;
201
202 fn poll_next(
203 mut self: std::pin::Pin<&mut Self>,
204 cx: &mut std::task::Context<'_>,
205 ) -> std::task::Poll<Option<Self::Item>> {
206 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
207 &mut self.event_receiver,
208 cx
209 )?) {
210 Some(buf) => std::task::Poll::Ready(Some(AdminEvent::decode(buf))),
211 None => std::task::Poll::Ready(None),
212 }
213 }
214}
215
216#[derive(Debug)]
217pub enum AdminEvent {}
218
219impl AdminEvent {
220 fn decode(
222 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
223 ) -> Result<AdminEvent, fidl::Error> {
224 let (bytes, _handles) = buf.split_mut();
225 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
226 debug_assert_eq!(tx_header.tx_id, 0);
227 match tx_header.ordinal {
228 _ => Err(fidl::Error::UnknownOrdinal {
229 ordinal: tx_header.ordinal,
230 protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
231 }),
232 }
233 }
234}
235
236pub struct AdminRequestStream {
238 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
239 is_terminated: bool,
240}
241
242impl std::marker::Unpin for AdminRequestStream {}
243
244impl futures::stream::FusedStream for AdminRequestStream {
245 fn is_terminated(&self) -> bool {
246 self.is_terminated
247 }
248}
249
250impl fidl::endpoints::RequestStream for AdminRequestStream {
251 type Protocol = AdminMarker;
252 type ControlHandle = AdminControlHandle;
253
254 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
255 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
256 }
257
258 fn control_handle(&self) -> Self::ControlHandle {
259 AdminControlHandle { inner: self.inner.clone() }
260 }
261
262 fn into_inner(
263 self,
264 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
265 {
266 (self.inner, self.is_terminated)
267 }
268
269 fn from_inner(
270 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
271 is_terminated: bool,
272 ) -> Self {
273 Self { inner, is_terminated }
274 }
275}
276
277impl futures::Stream for AdminRequestStream {
278 type Item = Result<AdminRequest, fidl::Error>;
279
280 fn poll_next(
281 mut self: std::pin::Pin<&mut Self>,
282 cx: &mut std::task::Context<'_>,
283 ) -> std::task::Poll<Option<Self::Item>> {
284 let this = &mut *self;
285 if this.inner.check_shutdown(cx) {
286 this.is_terminated = true;
287 return std::task::Poll::Ready(None);
288 }
289 if this.is_terminated {
290 panic!("polled AdminRequestStream after completion");
291 }
292 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
293 |bytes, handles| {
294 match this.inner.channel().read_etc(cx, bytes, handles) {
295 std::task::Poll::Ready(Ok(())) => {}
296 std::task::Poll::Pending => return std::task::Poll::Pending,
297 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
298 this.is_terminated = true;
299 return std::task::Poll::Ready(None);
300 }
301 std::task::Poll::Ready(Err(e)) => {
302 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
303 e.into(),
304 ))))
305 }
306 }
307
308 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310
311 std::task::Poll::Ready(Some(match header.ordinal {
312 0x5476abc45167ca8e => {
313 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
314 let mut req = fidl::new_empty!(
315 fidl::encoding::EmptyPayload,
316 fidl::encoding::DefaultFuchsiaResourceDialect
317 );
318 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
319 let control_handle = AdminControlHandle { inner: this.inner.clone() };
320 Ok(AdminRequest::Shutdown {
321 responder: AdminShutdownResponder {
322 control_handle: std::mem::ManuallyDrop::new(control_handle),
323 tx_id: header.tx_id,
324 },
325 })
326 }
327 _ => Err(fidl::Error::UnknownOrdinal {
328 ordinal: header.ordinal,
329 protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330 }),
331 }))
332 },
333 )
334 }
335}
336
337#[derive(Debug)]
339pub enum AdminRequest {
340 Shutdown { responder: AdminShutdownResponder },
346}
347
348impl AdminRequest {
349 #[allow(irrefutable_let_patterns)]
350 pub fn into_shutdown(self) -> Option<(AdminShutdownResponder)> {
351 if let AdminRequest::Shutdown { responder } = self {
352 Some((responder))
353 } else {
354 None
355 }
356 }
357
358 pub fn method_name(&self) -> &'static str {
360 match *self {
361 AdminRequest::Shutdown { .. } => "shutdown",
362 }
363 }
364}
365
366#[derive(Debug, Clone)]
367pub struct AdminControlHandle {
368 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
369}
370
371impl fidl::endpoints::ControlHandle for AdminControlHandle {
372 fn shutdown(&self) {
373 self.inner.shutdown()
374 }
375 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
376 self.inner.shutdown_with_epitaph(status)
377 }
378
379 fn is_closed(&self) -> bool {
380 self.inner.channel().is_closed()
381 }
382 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
383 self.inner.channel().on_closed()
384 }
385
386 #[cfg(target_os = "fuchsia")]
387 fn signal_peer(
388 &self,
389 clear_mask: zx::Signals,
390 set_mask: zx::Signals,
391 ) -> Result<(), zx_status::Status> {
392 use fidl::Peered;
393 self.inner.channel().signal_peer(clear_mask, set_mask)
394 }
395}
396
397impl AdminControlHandle {}
398
399#[must_use = "FIDL methods require a response to be sent"]
400#[derive(Debug)]
401pub struct AdminShutdownResponder {
402 control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
403 tx_id: u32,
404}
405
406impl std::ops::Drop for AdminShutdownResponder {
410 fn drop(&mut self) {
411 self.control_handle.shutdown();
412 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
414 }
415}
416
417impl fidl::endpoints::Responder for AdminShutdownResponder {
418 type ControlHandle = AdminControlHandle;
419
420 fn control_handle(&self) -> &AdminControlHandle {
421 &self.control_handle
422 }
423
424 fn drop_without_shutdown(mut self) {
425 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
427 std::mem::forget(self);
429 }
430}
431
432impl AdminShutdownResponder {
433 pub fn send(self) -> Result<(), fidl::Error> {
437 let _result = self.send_raw();
438 if _result.is_err() {
439 self.control_handle.shutdown();
440 }
441 self.drop_without_shutdown();
442 _result
443 }
444
445 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
447 let _result = self.send_raw();
448 self.drop_without_shutdown();
449 _result
450 }
451
452 fn send_raw(&self) -> Result<(), fidl::Error> {
453 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
454 (),
455 self.tx_id,
456 0x5476abc45167ca8e,
457 fidl::encoding::DynamicFlags::empty(),
458 )
459 }
460}
461
462mod internal {
463 use super::*;
464}