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 { Some((responder)) } else { None }
352 }
353
354 pub fn method_name(&self) -> &'static str {
356 match *self {
357 AdminRequest::Shutdown { .. } => "shutdown",
358 }
359 }
360}
361
362#[derive(Debug, Clone)]
363pub struct AdminControlHandle {
364 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
365}
366
367impl fidl::endpoints::ControlHandle for AdminControlHandle {
368 fn shutdown(&self) {
369 self.inner.shutdown()
370 }
371 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
372 self.inner.shutdown_with_epitaph(status)
373 }
374
375 fn is_closed(&self) -> bool {
376 self.inner.channel().is_closed()
377 }
378 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
379 self.inner.channel().on_closed()
380 }
381
382 #[cfg(target_os = "fuchsia")]
383 fn signal_peer(
384 &self,
385 clear_mask: zx::Signals,
386 set_mask: zx::Signals,
387 ) -> Result<(), zx_status::Status> {
388 use fidl::Peered;
389 self.inner.channel().signal_peer(clear_mask, set_mask)
390 }
391}
392
393impl AdminControlHandle {}
394
395#[must_use = "FIDL methods require a response to be sent"]
396#[derive(Debug)]
397pub struct AdminShutdownResponder {
398 control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
399 tx_id: u32,
400}
401
402impl std::ops::Drop for AdminShutdownResponder {
406 fn drop(&mut self) {
407 self.control_handle.shutdown();
408 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
410 }
411}
412
413impl fidl::endpoints::Responder for AdminShutdownResponder {
414 type ControlHandle = AdminControlHandle;
415
416 fn control_handle(&self) -> &AdminControlHandle {
417 &self.control_handle
418 }
419
420 fn drop_without_shutdown(mut self) {
421 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
423 std::mem::forget(self);
425 }
426}
427
428impl AdminShutdownResponder {
429 pub fn send(self) -> Result<(), fidl::Error> {
433 let _result = self.send_raw();
434 if _result.is_err() {
435 self.control_handle.shutdown();
436 }
437 self.drop_without_shutdown();
438 _result
439 }
440
441 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
443 let _result = self.send_raw();
444 self.drop_without_shutdown();
445 _result
446 }
447
448 fn send_raw(&self) -> Result<(), fidl::Error> {
449 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
450 (),
451 self.tx_id,
452 0x5476abc45167ca8e,
453 fidl::encoding::DynamicFlags::empty(),
454 )
455 }
456}
457
458mod internal {
459 use super::*;
460}