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