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