fidl_fuchsia_driver_metadata/
fidl_fuchsia_driver_metadata.rs1#![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_driver_metadata_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct MetadataMarker;
16
17impl fidl::endpoints::ProtocolMarker for MetadataMarker {
18 type Proxy = MetadataProxy;
19 type RequestStream = MetadataRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = MetadataSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) Metadata";
24}
25pub type MetadataGetPersistedMetadataResult = Result<Vec<u8>, i32>;
26
27pub trait MetadataProxyInterface: Send + Sync {
28 type GetPersistedMetadataResponseFut: std::future::Future<Output = Result<MetadataGetPersistedMetadataResult, fidl::Error>>
29 + Send;
30 fn r#get_persisted_metadata(&self) -> Self::GetPersistedMetadataResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct MetadataSynchronousProxy {
35 client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for MetadataSynchronousProxy {
40 type Proxy = MetadataProxy;
41 type Protocol = MetadataMarker;
42
43 fn from_channel(inner: fidl::Channel) -> Self {
44 Self::new(inner)
45 }
46
47 fn into_channel(self) -> fidl::Channel {
48 self.client.into_channel()
49 }
50
51 fn as_channel(&self) -> &fidl::Channel {
52 self.client.as_channel()
53 }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl MetadataSynchronousProxy {
58 pub fn new(channel: fidl::Channel) -> Self {
59 Self { client: fidl::client::sync::Client::new(channel) }
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<MetadataEvent, fidl::Error> {
72 MetadataEvent::decode(self.client.wait_for_event::<MetadataMarker>(deadline)?)
73 }
74
75 pub fn r#get_persisted_metadata(
78 &self,
79 ___deadline: zx::MonotonicInstant,
80 ) -> Result<MetadataGetPersistedMetadataResult, fidl::Error> {
81 let _response = self.client.send_query::<
82 fidl::encoding::EmptyPayload,
83 fidl::encoding::ResultType<MetadataGetPersistedMetadataResponse, i32>,
84 MetadataMarker,
85 >(
86 (),
87 0x431a76979a5b3277,
88 fidl::encoding::DynamicFlags::empty(),
89 ___deadline,
90 )?;
91 Ok(_response.map(|x| x.persisted_metadata))
92 }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl From<MetadataSynchronousProxy> for zx::NullableHandle {
97 fn from(value: MetadataSynchronousProxy) -> Self {
98 value.into_channel().into()
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<fidl::Channel> for MetadataSynchronousProxy {
104 fn from(value: fidl::Channel) -> Self {
105 Self::new(value)
106 }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl fidl::endpoints::FromClient for MetadataSynchronousProxy {
111 type Protocol = MetadataMarker;
112
113 fn from_client(value: fidl::endpoints::ClientEnd<MetadataMarker>) -> Self {
114 Self::new(value.into_channel())
115 }
116}
117
118#[derive(Debug, Clone)]
119pub struct MetadataProxy {
120 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
121}
122
123impl fidl::endpoints::Proxy for MetadataProxy {
124 type Protocol = MetadataMarker;
125
126 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
127 Self::new(inner)
128 }
129
130 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
131 self.client.into_channel().map_err(|client| Self { client })
132 }
133
134 fn as_channel(&self) -> &::fidl::AsyncChannel {
135 self.client.as_channel()
136 }
137}
138
139impl MetadataProxy {
140 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
142 let protocol_name = <MetadataMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
143 Self { client: fidl::client::Client::new(channel, protocol_name) }
144 }
145
146 pub fn take_event_stream(&self) -> MetadataEventStream {
152 MetadataEventStream { event_receiver: self.client.take_event_receiver() }
153 }
154
155 pub fn r#get_persisted_metadata(
158 &self,
159 ) -> fidl::client::QueryResponseFut<
160 MetadataGetPersistedMetadataResult,
161 fidl::encoding::DefaultFuchsiaResourceDialect,
162 > {
163 MetadataProxyInterface::r#get_persisted_metadata(self)
164 }
165}
166
167impl MetadataProxyInterface for MetadataProxy {
168 type GetPersistedMetadataResponseFut = fidl::client::QueryResponseFut<
169 MetadataGetPersistedMetadataResult,
170 fidl::encoding::DefaultFuchsiaResourceDialect,
171 >;
172 fn r#get_persisted_metadata(&self) -> Self::GetPersistedMetadataResponseFut {
173 fn _decode(
174 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
175 ) -> Result<MetadataGetPersistedMetadataResult, fidl::Error> {
176 let _response = fidl::client::decode_transaction_body::<
177 fidl::encoding::ResultType<MetadataGetPersistedMetadataResponse, i32>,
178 fidl::encoding::DefaultFuchsiaResourceDialect,
179 0x431a76979a5b3277,
180 >(_buf?)?;
181 Ok(_response.map(|x| x.persisted_metadata))
182 }
183 self.client.send_query_and_decode::<
184 fidl::encoding::EmptyPayload,
185 MetadataGetPersistedMetadataResult,
186 >(
187 (),
188 0x431a76979a5b3277,
189 fidl::encoding::DynamicFlags::empty(),
190 _decode,
191 )
192 }
193}
194
195pub struct MetadataEventStream {
196 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl std::marker::Unpin for MetadataEventStream {}
200
201impl futures::stream::FusedStream for MetadataEventStream {
202 fn is_terminated(&self) -> bool {
203 self.event_receiver.is_terminated()
204 }
205}
206
207impl futures::Stream for MetadataEventStream {
208 type Item = Result<MetadataEvent, fidl::Error>;
209
210 fn poll_next(
211 mut self: std::pin::Pin<&mut Self>,
212 cx: &mut std::task::Context<'_>,
213 ) -> std::task::Poll<Option<Self::Item>> {
214 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
215 &mut self.event_receiver,
216 cx
217 )?) {
218 Some(buf) => std::task::Poll::Ready(Some(MetadataEvent::decode(buf))),
219 None => std::task::Poll::Ready(None),
220 }
221 }
222}
223
224#[derive(Debug)]
225pub enum MetadataEvent {}
226
227impl MetadataEvent {
228 fn decode(
230 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
231 ) -> Result<MetadataEvent, fidl::Error> {
232 let (bytes, _handles) = buf.split_mut();
233 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
234 debug_assert_eq!(tx_header.tx_id, 0);
235 match tx_header.ordinal {
236 _ => Err(fidl::Error::UnknownOrdinal {
237 ordinal: tx_header.ordinal,
238 protocol_name: <MetadataMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
239 }),
240 }
241 }
242}
243
244pub struct MetadataRequestStream {
246 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
247 is_terminated: bool,
248}
249
250impl std::marker::Unpin for MetadataRequestStream {}
251
252impl futures::stream::FusedStream for MetadataRequestStream {
253 fn is_terminated(&self) -> bool {
254 self.is_terminated
255 }
256}
257
258impl fidl::endpoints::RequestStream for MetadataRequestStream {
259 type Protocol = MetadataMarker;
260 type ControlHandle = MetadataControlHandle;
261
262 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
263 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
264 }
265
266 fn control_handle(&self) -> Self::ControlHandle {
267 MetadataControlHandle { inner: self.inner.clone() }
268 }
269
270 fn into_inner(
271 self,
272 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
273 {
274 (self.inner, self.is_terminated)
275 }
276
277 fn from_inner(
278 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
279 is_terminated: bool,
280 ) -> Self {
281 Self { inner, is_terminated }
282 }
283}
284
285impl futures::Stream for MetadataRequestStream {
286 type Item = Result<MetadataRequest, fidl::Error>;
287
288 fn poll_next(
289 mut self: std::pin::Pin<&mut Self>,
290 cx: &mut std::task::Context<'_>,
291 ) -> std::task::Poll<Option<Self::Item>> {
292 let this = &mut *self;
293 if this.inner.check_shutdown(cx) {
294 this.is_terminated = true;
295 return std::task::Poll::Ready(None);
296 }
297 if this.is_terminated {
298 panic!("polled MetadataRequestStream after completion");
299 }
300 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
301 |bytes, handles| {
302 match this.inner.channel().read_etc(cx, bytes, handles) {
303 std::task::Poll::Ready(Ok(())) => {}
304 std::task::Poll::Pending => return std::task::Poll::Pending,
305 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
306 this.is_terminated = true;
307 return std::task::Poll::Ready(None);
308 }
309 std::task::Poll::Ready(Err(e)) => {
310 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
311 e.into(),
312 ))));
313 }
314 }
315
316 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
318
319 std::task::Poll::Ready(Some(match header.ordinal {
320 0x431a76979a5b3277 => {
321 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
322 let mut req = fidl::new_empty!(
323 fidl::encoding::EmptyPayload,
324 fidl::encoding::DefaultFuchsiaResourceDialect
325 );
326 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
327 let control_handle = MetadataControlHandle { inner: this.inner.clone() };
328 Ok(MetadataRequest::GetPersistedMetadata {
329 responder: MetadataGetPersistedMetadataResponder {
330 control_handle: std::mem::ManuallyDrop::new(control_handle),
331 tx_id: header.tx_id,
332 },
333 })
334 }
335 _ => Err(fidl::Error::UnknownOrdinal {
336 ordinal: header.ordinal,
337 protocol_name:
338 <MetadataMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
339 }),
340 }))
341 },
342 )
343 }
344}
345
346#[derive(Debug)]
347pub enum MetadataRequest {
348 GetPersistedMetadata { responder: MetadataGetPersistedMetadataResponder },
351}
352
353impl MetadataRequest {
354 #[allow(irrefutable_let_patterns)]
355 pub fn into_get_persisted_metadata(self) -> Option<(MetadataGetPersistedMetadataResponder)> {
356 if let MetadataRequest::GetPersistedMetadata { responder } = self {
357 Some((responder))
358 } else {
359 None
360 }
361 }
362
363 pub fn method_name(&self) -> &'static str {
365 match *self {
366 MetadataRequest::GetPersistedMetadata { .. } => "get_persisted_metadata",
367 }
368 }
369}
370
371#[derive(Debug, Clone)]
372pub struct MetadataControlHandle {
373 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
374}
375
376impl MetadataControlHandle {
377 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
378 self.inner.shutdown_with_epitaph(status.into())
379 }
380}
381
382impl fidl::endpoints::ControlHandle for MetadataControlHandle {
383 fn shutdown(&self) {
384 self.inner.shutdown()
385 }
386
387 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
388 self.inner.shutdown_with_epitaph(status)
389 }
390
391 fn is_closed(&self) -> bool {
392 self.inner.channel().is_closed()
393 }
394 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
395 self.inner.channel().on_closed()
396 }
397
398 #[cfg(target_os = "fuchsia")]
399 fn signal_peer(
400 &self,
401 clear_mask: zx::Signals,
402 set_mask: zx::Signals,
403 ) -> Result<(), zx_status::Status> {
404 use fidl::Peered;
405 self.inner.channel().signal_peer(clear_mask, set_mask)
406 }
407}
408
409impl MetadataControlHandle {}
410
411#[must_use = "FIDL methods require a response to be sent"]
412#[derive(Debug)]
413pub struct MetadataGetPersistedMetadataResponder {
414 control_handle: std::mem::ManuallyDrop<MetadataControlHandle>,
415 tx_id: u32,
416}
417
418impl std::ops::Drop for MetadataGetPersistedMetadataResponder {
422 fn drop(&mut self) {
423 self.control_handle.shutdown();
424 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
426 }
427}
428
429impl fidl::endpoints::Responder for MetadataGetPersistedMetadataResponder {
430 type ControlHandle = MetadataControlHandle;
431
432 fn control_handle(&self) -> &MetadataControlHandle {
433 &self.control_handle
434 }
435
436 fn drop_without_shutdown(mut self) {
437 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
439 std::mem::forget(self);
441 }
442}
443
444impl MetadataGetPersistedMetadataResponder {
445 pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
449 let _result = self.send_raw(result);
450 if _result.is_err() {
451 self.control_handle.shutdown();
452 }
453 self.drop_without_shutdown();
454 _result
455 }
456
457 pub fn send_no_shutdown_on_err(
459 self,
460 mut result: Result<&[u8], i32>,
461 ) -> Result<(), fidl::Error> {
462 let _result = self.send_raw(result);
463 self.drop_without_shutdown();
464 _result
465 }
466
467 fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
468 self.control_handle.inner.send::<fidl::encoding::ResultType<
469 MetadataGetPersistedMetadataResponse,
470 i32,
471 >>(
472 result.map(|persisted_metadata| (persisted_metadata,)),
473 self.tx_id,
474 0x431a76979a5b3277,
475 fidl::encoding::DynamicFlags::empty(),
476 )
477 }
478}
479
480#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
481pub struct ServiceMarker;
482
483#[cfg(target_os = "fuchsia")]
484impl fidl::endpoints::ServiceMarker for ServiceMarker {
485 type Proxy = ServiceProxy;
486 type Request = ServiceRequest;
487 const SERVICE_NAME: &'static str = "fuchsia.driver.metadata.Service";
488}
489
490#[cfg(target_os = "fuchsia")]
493pub enum ServiceRequest {
494 Metadata(MetadataRequestStream),
495}
496
497#[cfg(target_os = "fuchsia")]
498impl fidl::endpoints::ServiceRequest for ServiceRequest {
499 type Service = ServiceMarker;
500
501 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
502 match name {
503 "metadata" => Self::Metadata(
504 <MetadataRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
505 ),
506 _ => panic!("no such member protocol name for service Service"),
507 }
508 }
509
510 fn member_names() -> &'static [&'static str] {
511 &["metadata"]
512 }
513}
514#[cfg(target_os = "fuchsia")]
515pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
516
517#[cfg(target_os = "fuchsia")]
518impl fidl::endpoints::ServiceProxy for ServiceProxy {
519 type Service = ServiceMarker;
520
521 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
522 Self(opener)
523 }
524}
525
526#[cfg(target_os = "fuchsia")]
527impl ServiceProxy {
528 pub fn connect_to_metadata(&self) -> Result<MetadataProxy, fidl::Error> {
529 let (proxy, server_end) = fidl::endpoints::create_proxy::<MetadataMarker>();
530 self.connect_channel_to_metadata(server_end)?;
531 Ok(proxy)
532 }
533
534 pub fn connect_to_metadata_sync(&self) -> Result<MetadataSynchronousProxy, fidl::Error> {
537 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<MetadataMarker>();
538 self.connect_channel_to_metadata(server_end)?;
539 Ok(proxy)
540 }
541
542 pub fn connect_channel_to_metadata(
545 &self,
546 server_end: fidl::endpoints::ServerEnd<MetadataMarker>,
547 ) -> Result<(), fidl::Error> {
548 self.0.open_member("metadata", server_end.into_channel())
549 }
550
551 pub fn instance_name(&self) -> &str {
552 self.0.instance_name()
553 }
554}
555
556mod internal {
557 use super::*;
558}