Skip to main content

libasync_sys/
bindings.rs

1// Copyright 2025 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file is automatically generated by //sdk/lib/async/rust/sys:async_sys_bindgen_golden.
6
7#![expect(non_camel_case_types)]
8
9use zx_types::*;
10
11#[doc = " Dispatcher interface for performing asynchronous operations.\n There may be multiple implementations of this interface."]
12pub type async_dispatcher_t = async_dispatcher;
13#[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down.  There is no way to cancel a trap which has been set."]
14pub type async_guest_bell_trap_t = async_guest_bell_trap;
15#[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down.  Thereafter, the wait\n may be started begun or destroyed."]
16pub type async_wait_t = async_wait;
17#[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down.  Thereafter, the task\n may be posted again or destroyed."]
18pub type async_task_t = async_task;
19#[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down.  There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."]
20pub type async_receiver_t = async_receiver;
21#[repr(C)]
22#[derive(Debug)]
23pub struct async_irq {
24    _unused: [u8; 0],
25}
26pub type async_irq_t = async_irq;
27#[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."]
28pub type async_paged_vmo_t = async_paged_vmo;
29#[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."]
30pub type async_sequence_id_t = async_sequence_id;
31#[doc = " Private state owned by the asynchronous dispatcher.\n This allows the dispatcher to associate a small amount of state with pending\n asynchronous operations without having to allocate additional heap storage of\n its own.\n\n Clients must initialize the contents of this structure to zero using\n |ASYNC_STATE_INIT| or with calloc, memset, or a similar means."]
32#[repr(C)]
33#[derive(Debug, Default, Copy, Clone)]
34pub struct async_state_t {
35    pub reserved: [usize; 2usize],
36}
37#[allow(clippy::unnecessary_operation, clippy::identity_op)]
38const _: () = {
39    ["Size of async_state_t"][::core::mem::size_of::<async_state_t>() - 16usize];
40    ["Alignment of async_state_t"][::core::mem::align_of::<async_state_t>() - 8usize];
41    ["Offset of field: async_state_t::reserved"]
42        [::core::mem::offset_of!(async_state_t, reserved) - 0usize];
43};
44#[doc = " Asynchronous dispatcher interface.\n\n Clients should not call into this interface directly: use the wrapper functions\n declared in other header files, such as |async_begin_wait()| in <lib/async/wait.h>.\n See the documentation of those functions for details about each method's purpose\n and behavior.\n\n This interface consists of several groups of methods:\n\n - Timing: |now|\n - Waiting for signals: |begin_wait|, |cancel_wait|\n - Posting tasks: |post_task|, |cancel_task|\n - Queuing packets: |queue_packet|\n - Virtual machine operations: |set_guest_bell_trap|\n\n To preserve binary compatibility, each successive version of this interface\n is guaranteed to be backwards-compatible with clients of earlier versions.\n New methods must only be added by extending the structure at the end and\n declaring a new version number.  Do not reorder the declarations or modify\n existing versions.\n\n Implementations of this interface must provide valid (non-null) function pointers\n for every method declared in the interface version they support.  Unsupported\n methods must return |ZX_ERR_NOT_SUPPORTED| and have no other side-effects.\n Furthermore, if an implementation supports one method of a group, such as |begin_wait|,\n then it must also support the other methods of the group, such as |cancel_wait|.\n\n Many clients assume that the dispatcher interface is fully implemented and may\n fail to work with dispatchers that do not support the methods they need.\n Therefore general-purpose dispatcher implementations are encouraged to support\n the whole interface to ensure broad compatibility."]
45pub type async_ops_version_t = u32;
46pub const ASYNC_OPS_V1: async_ops_version_t = 1;
47pub const ASYNC_OPS_V2: async_ops_version_t = 2;
48pub const ASYNC_OPS_V3: async_ops_version_t = 3;
49pub const ASYNC_OPS_V4: async_ops_version_t = 4;
50#[repr(C)]
51#[derive(Debug, Default, Copy, Clone)]
52pub struct async_ops {
53    #[doc = " The interface version number, e.g. |ASYNC_OPS_V1|."]
54    pub version: async_ops_version_t,
55    #[doc = " Reserved for future expansion, set to zero."]
56    pub reserved: u32,
57    pub v1: async_ops_v1,
58    pub v2: async_ops_v2,
59    pub v3: async_ops_v3,
60    pub v4: async_ops_v4,
61}
62#[doc = " Operations supported by |ASYNC_OPS_V1|."]
63#[repr(C)]
64#[derive(Debug, Default, Copy, Clone)]
65pub struct async_ops_v1 {
66    #[doc = " See |async_now()| for details."]
67    pub now: ::core::option::Option<
68        unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_time_t,
69    >,
70    #[doc = " See |async_begin_wait()| for details."]
71    pub begin_wait: ::core::option::Option<
72        unsafe extern "C" fn(
73            dispatcher: *mut async_dispatcher_t,
74            wait: *mut async_wait_t,
75        ) -> zx_status_t,
76    >,
77    #[doc = " See |async_cancel_wait()| for details."]
78    pub cancel_wait: ::core::option::Option<
79        unsafe extern "C" fn(
80            dispatcher: *mut async_dispatcher_t,
81            wait: *mut async_wait_t,
82        ) -> zx_status_t,
83    >,
84    #[doc = " See |async_post_task()| for details."]
85    pub post_task: ::core::option::Option<
86        unsafe extern "C" fn(
87            dispatcher: *mut async_dispatcher_t,
88            task: *mut async_task_t,
89        ) -> zx_status_t,
90    >,
91    #[doc = " See |async_cancel_task()| for details."]
92    pub cancel_task: ::core::option::Option<
93        unsafe extern "C" fn(
94            dispatcher: *mut async_dispatcher_t,
95            task: *mut async_task_t,
96        ) -> zx_status_t,
97    >,
98    #[doc = " See |async_queue_packet()| for details."]
99    pub queue_packet: ::core::option::Option<
100        unsafe extern "C" fn(
101            dispatcher: *mut async_dispatcher_t,
102            receiver: *mut async_receiver_t,
103            data: *const zx_packet_user_t,
104        ) -> zx_status_t,
105    >,
106    #[doc = " See |async_set_guest_bell_trap()| for details."]
107    pub set_guest_bell_trap: ::core::option::Option<
108        unsafe extern "C" fn(
109            dispatcher: *mut async_dispatcher_t,
110            trap: *mut async_guest_bell_trap_t,
111            guest: zx_handle_t,
112            addr: zx_vaddr_t,
113            length: usize,
114        ) -> zx_status_t,
115    >,
116}
117#[allow(clippy::unnecessary_operation, clippy::identity_op)]
118const _: () = {
119    ["Size of async_ops_v1"][::core::mem::size_of::<async_ops_v1>() - 56usize];
120    ["Alignment of async_ops_v1"][::core::mem::align_of::<async_ops_v1>() - 8usize];
121    ["Offset of field: async_ops_v1::now"][::core::mem::offset_of!(async_ops_v1, now) - 0usize];
122    ["Offset of field: async_ops_v1::begin_wait"]
123        [::core::mem::offset_of!(async_ops_v1, begin_wait) - 8usize];
124    ["Offset of field: async_ops_v1::cancel_wait"]
125        [::core::mem::offset_of!(async_ops_v1, cancel_wait) - 16usize];
126    ["Offset of field: async_ops_v1::post_task"]
127        [::core::mem::offset_of!(async_ops_v1, post_task) - 24usize];
128    ["Offset of field: async_ops_v1::cancel_task"]
129        [::core::mem::offset_of!(async_ops_v1, cancel_task) - 32usize];
130    ["Offset of field: async_ops_v1::queue_packet"]
131        [::core::mem::offset_of!(async_ops_v1, queue_packet) - 40usize];
132    ["Offset of field: async_ops_v1::set_guest_bell_trap"]
133        [::core::mem::offset_of!(async_ops_v1, set_guest_bell_trap) - 48usize];
134};
135#[repr(C)]
136#[derive(Debug, Default, Copy, Clone)]
137pub struct async_ops_v2 {
138    pub bind_irq: ::core::option::Option<
139        unsafe extern "C" fn(
140            dispatcher: *mut async_dispatcher_t,
141            irq: *mut async_irq_t,
142        ) -> zx_status_t,
143    >,
144    pub unbind_irq: ::core::option::Option<
145        unsafe extern "C" fn(
146            dispatcher: *mut async_dispatcher_t,
147            irq: *mut async_irq_t,
148        ) -> zx_status_t,
149    >,
150    pub create_paged_vmo: ::core::option::Option<
151        unsafe extern "C" fn(
152            dispatcher: *mut async_dispatcher_t,
153            paged_vmo: *mut async_paged_vmo_t,
154            options: u32,
155            pager: zx_handle_t,
156            vmo_size: u64,
157            vmo_out: *mut zx_handle_t,
158        ) -> zx_status_t,
159    >,
160    pub detach_paged_vmo: ::core::option::Option<
161        unsafe extern "C" fn(
162            dispatcher: *mut async_dispatcher_t,
163            paged_vmo: *mut async_paged_vmo_t,
164        ) -> zx_status_t,
165    >,
166}
167#[allow(clippy::unnecessary_operation, clippy::identity_op)]
168const _: () = {
169    ["Size of async_ops_v2"][::core::mem::size_of::<async_ops_v2>() - 32usize];
170    ["Alignment of async_ops_v2"][::core::mem::align_of::<async_ops_v2>() - 8usize];
171    ["Offset of field: async_ops_v2::bind_irq"]
172        [::core::mem::offset_of!(async_ops_v2, bind_irq) - 0usize];
173    ["Offset of field: async_ops_v2::unbind_irq"]
174        [::core::mem::offset_of!(async_ops_v2, unbind_irq) - 8usize];
175    ["Offset of field: async_ops_v2::create_paged_vmo"]
176        [::core::mem::offset_of!(async_ops_v2, create_paged_vmo) - 16usize];
177    ["Offset of field: async_ops_v2::detach_paged_vmo"]
178        [::core::mem::offset_of!(async_ops_v2, detach_paged_vmo) - 24usize];
179};
180#[repr(C)]
181#[derive(Debug, Default, Copy, Clone)]
182pub struct async_ops_v3 {
183    #[doc = " See |async_get_sequence_id()| for details."]
184    pub get_sequence_id: ::core::option::Option<
185        unsafe extern "C" fn(
186            dispatcher: *mut async_dispatcher_t,
187            out_sequence_id: *mut async_sequence_id_t,
188            out_error: *mut *const ::core::ffi::c_char,
189        ) -> zx_status_t,
190    >,
191    #[doc = " See |async_check_sequence_id()| for details."]
192    pub check_sequence_id: ::core::option::Option<
193        unsafe extern "C" fn(
194            dispatcher: *mut async_dispatcher_t,
195            sequence_id: async_sequence_id_t,
196            out_error: *mut *const ::core::ffi::c_char,
197        ) -> zx_status_t,
198    >,
199}
200#[allow(clippy::unnecessary_operation, clippy::identity_op)]
201const _: () = {
202    ["Size of async_ops_v3"][::core::mem::size_of::<async_ops_v3>() - 16usize];
203    ["Alignment of async_ops_v3"][::core::mem::align_of::<async_ops_v3>() - 8usize];
204    ["Offset of field: async_ops_v3::get_sequence_id"]
205        [::core::mem::offset_of!(async_ops_v3, get_sequence_id) - 0usize];
206    ["Offset of field: async_ops_v3::check_sequence_id"]
207        [::core::mem::offset_of!(async_ops_v3, check_sequence_id) - 8usize];
208};
209#[repr(C)]
210#[derive(Debug, Default, Copy, Clone)]
211pub struct async_ops_v4 {
212    #[doc = " See |async_acquire_shared_ref| for details."]
213    pub acquire_shared_ref: ::core::option::Option<
214        unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t,
215    >,
216    #[doc = " See |async_release_shared_ref| for details."]
217    pub release_shared_ref: ::core::option::Option<
218        unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t,
219    >,
220}
221#[allow(clippy::unnecessary_operation, clippy::identity_op)]
222const _: () = {
223    ["Size of async_ops_v4"][::core::mem::size_of::<async_ops_v4>() - 16usize];
224    ["Alignment of async_ops_v4"][::core::mem::align_of::<async_ops_v4>() - 8usize];
225    ["Offset of field: async_ops_v4::acquire_shared_ref"]
226        [::core::mem::offset_of!(async_ops_v4, acquire_shared_ref) - 0usize];
227    ["Offset of field: async_ops_v4::release_shared_ref"]
228        [::core::mem::offset_of!(async_ops_v4, release_shared_ref) - 8usize];
229};
230#[allow(clippy::unnecessary_operation, clippy::identity_op)]
231const _: () = {
232    ["Size of async_ops"][::core::mem::size_of::<async_ops>() - 128usize];
233    ["Alignment of async_ops"][::core::mem::align_of::<async_ops>() - 8usize];
234    ["Offset of field: async_ops::version"][::core::mem::offset_of!(async_ops, version) - 0usize];
235    ["Offset of field: async_ops::reserved"][::core::mem::offset_of!(async_ops, reserved) - 4usize];
236    ["Offset of field: async_ops::v1"][::core::mem::offset_of!(async_ops, v1) - 8usize];
237    ["Offset of field: async_ops::v2"][::core::mem::offset_of!(async_ops, v2) - 64usize];
238    ["Offset of field: async_ops::v3"][::core::mem::offset_of!(async_ops, v3) - 96usize];
239    ["Offset of field: async_ops::v4"][::core::mem::offset_of!(async_ops, v4) - 112usize];
240};
241pub type async_ops_t = async_ops;
242#[repr(C)]
243#[derive(Debug, Copy, Clone)]
244pub struct async_dispatcher {
245    pub ops: *const async_ops_t,
246}
247#[allow(clippy::unnecessary_operation, clippy::identity_op)]
248const _: () = {
249    ["Size of async_dispatcher"][::core::mem::size_of::<async_dispatcher>() - 8usize];
250    ["Alignment of async_dispatcher"][::core::mem::align_of::<async_dispatcher>() - 8usize];
251    ["Offset of field: async_dispatcher::ops"]
252        [::core::mem::offset_of!(async_dispatcher, ops) - 0usize];
253};
254impl Default for async_dispatcher {
255    fn default() -> Self {
256        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
257        unsafe {
258            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
259            s.assume_init()
260        }
261    }
262}
263unsafe extern "C" {
264    #[doc = " If supported, acquires a shared dispatcher reference for this dispatcher.\n\n If successful, the internal reference count of the dispatcher object will be incremented so that\n it will not be deallocated for any other reason than the outstanding refcount reaching zero. If\n it fails there will be no guarantees about the lifetime of the dispatcher object.\n\n Note that this will not prevent the dispatcher from shutting down. Calls to dispatcher methods\n after shutting down will behave as if the dispatcher is still shutting down.\n\n The client MUST call |async_release_shared_ref| on the returned pointer when it is no\n longer in use if this call succeeds. Not doing so will result in memory leaks.\n\n Returns |ZX_OK| if a shared dispatcher object's reference count has been incremented and its\n memory won't be released before you have called a corresponding |async_release_shared_ref|.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
265    pub fn async_acquire_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t;
266}
267unsafe extern "C" {
268    #[doc = " Releases a shared dispatcher reference for this dispatcher.\n\n The caller must call this to release a shared dispatcher object acquired by\n |async_acquire_shared_ref|. In general, this should always return ZX_OK if the\n api is used correctly.\n\n Returns |ZX_OK| if the dispatcher has been successfully released.\n Returns |ZX_ERR_NOT_SUPPORTED| if you have tried to call this on a dispatcher that\n does not support having shared references."]
269    pub fn async_release_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t;
270}
271#[doc = " Handles port packets containing page requests.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |request|\n contains the information from the packet, otherwise |request| is null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down."]
272pub type async_paged_vmo_handler_t = ::core::option::Option<
273    unsafe extern "C" fn(
274        dispatcher: *mut async_dispatcher_t,
275        paged_vmo: *mut async_paged_vmo_t,
276        status: zx_status_t,
277        request: *const zx_packet_page_request_t,
278    ),
279>;
280#[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."]
281#[repr(C)]
282pub struct async_paged_vmo {
283    #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
284    pub state: async_state_t,
285    #[doc = " The handler to invoke when a packet is received."]
286    pub handler: async_paged_vmo_handler_t,
287    #[doc = " The associated pager when creating the VMO."]
288    pub pager: zx_handle_t,
289    #[doc = " The VMO for this request."]
290    pub vmo: zx_handle_t,
291}
292#[allow(clippy::unnecessary_operation, clippy::identity_op)]
293const _: () = {
294    ["Size of async_paged_vmo"][::core::mem::size_of::<async_paged_vmo>() - 32usize];
295    ["Alignment of async_paged_vmo"][::core::mem::align_of::<async_paged_vmo>() - 8usize];
296    ["Offset of field: async_paged_vmo::state"]
297        [::core::mem::offset_of!(async_paged_vmo, state) - 0usize];
298    ["Offset of field: async_paged_vmo::handler"]
299        [::core::mem::offset_of!(async_paged_vmo, handler) - 16usize];
300    ["Offset of field: async_paged_vmo::pager"]
301        [::core::mem::offset_of!(async_paged_vmo, pager) - 24usize];
302    ["Offset of field: async_paged_vmo::vmo"]
303        [::core::mem::offset_of!(async_paged_vmo, vmo) - 28usize];
304};
305impl Default for async_paged_vmo {
306    fn default() -> Self {
307        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
308        unsafe {
309            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
310            s.assume_init()
311        }
312    }
313}
314impl ::core::fmt::Debug for async_paged_vmo {
315    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
316        write!(f, "async_paged_vmo {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
317    }
318}
319unsafe extern "C" {
320    #[doc = " Create a pager owned VMO.\n\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Other error values are possible. See the documentation for\n |zx_pager_create_vmo()|."]
321    pub fn async_create_paged_vmo(
322        dispatcher: *mut async_dispatcher_t,
323        paged_vmo: *mut async_paged_vmo_t,
324        options: u32,
325        pager: zx_handle_t,
326        vmo_size: u64,
327        vmo_out: *mut zx_handle_t,
328    ) -> zx_status_t;
329}
330unsafe extern "C" {
331    #[doc = " Detach ownership of VMO from pager.\n\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Returns |ZX_ERR_BAD_HANDLE| if pager or vmo is not a valid handle.\n Returns |ZX_ERR_WRONG_TYPE| if pager is not a pager handle or vmo is not a vmo handle.\n Returns |ZX_ERR_INVALID_ARGS| if vmo is not a vmo created from pager.\n Other error values are possible. See the documentation for\n |zx_detach_paged_vmo()|."]
332    pub fn async_detach_paged_vmo(
333        dispatcher: *mut async_dispatcher_t,
334        paged_vmo: *mut async_paged_vmo_t,
335    ) -> zx_status_t;
336}
337#[doc = " Handles receipt of packets containing user supplied data.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |data|\n contains the information from the packet, otherwise |data| is null."]
338pub type async_receiver_handler_t = ::core::option::Option<
339    unsafe extern "C" fn(
340        dispatcher: *mut async_dispatcher_t,
341        receiver: *mut async_receiver_t,
342        status: zx_status_t,
343        data: *const zx_packet_user_t,
344    ),
345>;
346#[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down.  There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."]
347#[repr(C)]
348#[derive(Debug, Default, Copy, Clone)]
349pub struct async_receiver {
350    #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
351    pub state: async_state_t,
352    #[doc = " The handler to invoke when a packet is received."]
353    pub handler: async_receiver_handler_t,
354}
355#[allow(clippy::unnecessary_operation, clippy::identity_op)]
356const _: () = {
357    ["Size of async_receiver"][::core::mem::size_of::<async_receiver>() - 24usize];
358    ["Alignment of async_receiver"][::core::mem::align_of::<async_receiver>() - 8usize];
359    ["Offset of field: async_receiver::state"]
360        [::core::mem::offset_of!(async_receiver, state) - 0usize];
361    ["Offset of field: async_receiver::handler"]
362        [::core::mem::offset_of!(async_receiver, handler) - 16usize];
363};
364unsafe extern "C" {
365    #[doc = " Enqueues a packet of data for delivery to a receiver.\n\n The |data| will be copied into the packet.  May be NULL to create a\n zero-initialized packet payload.\n\n Returns |ZX_OK| if the packet was successfully enqueued.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
366    pub fn async_queue_packet(
367        dispatcher: *mut async_dispatcher_t,
368        receiver: *mut async_receiver_t,
369        data: *const zx_packet_user_t,
370    ) -> zx_status_t;
371}
372#[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."]
373#[repr(C)]
374#[derive(Debug, Default, Copy, Clone)]
375pub struct async_sequence_id {
376    pub value: u64,
377}
378#[allow(clippy::unnecessary_operation, clippy::identity_op)]
379const _: () = {
380    ["Size of async_sequence_id"][::core::mem::size_of::<async_sequence_id>() - 8usize];
381    ["Alignment of async_sequence_id"][::core::mem::align_of::<async_sequence_id>() - 8usize];
382    ["Offset of field: async_sequence_id::value"]
383        [::core::mem::offset_of!(async_sequence_id, value) - 0usize];
384};
385unsafe extern "C" {
386    #[doc = " Gets the dispatcher-specific sequence identifier of the currently executing\n task.\n\n If the execution context of the calling thread is associated with a sequence,\n the dispatcher should populate the sequence identifier representing the\n current sequence. Otherwise, it should return an error code detailed below.\n\n Returns |ZX_OK| if the sequence identifier was successfully obtained.\n Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n calling thread is not executing a task managed by the dispatcher.\n Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n managed by the dispatcher, but that task is not part of a sequence.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."]
387    pub fn async_get_sequence_id(
388        dispatcher: *mut async_dispatcher_t,
389        out_sequence_id: *mut async_sequence_id_t,
390        out_error: *mut *const ::core::ffi::c_char,
391    ) -> zx_status_t;
392}
393unsafe extern "C" {
394    #[doc = " Checks that the the dispatcher-specific sequence identifier of the currently\n executing task is equal to |sequence_id|.\n\n If the sequence identifier of the calling thread cannot be successfully\n obtained, it should return an error code detailed below:\n\n - Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n   calling thread is not executing a task managed by the dispatcher.\n - Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n   managed by the dispatcher, but that task is not part of a sequence.\n - Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n Otherwise, the dispatcher should check that the sequence identifier\n representing the current sequence equals to |sequence_id|:\n\n - Returns |ZX_OK| if the sequence identifiers are equal.\n - Returns |ZX_ERR_OUT_OF_RANGE| if the sequence identifiers are not equal.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."]
395    pub fn async_check_sequence_id(
396        dispatcher: *mut async_dispatcher_t,
397        sequence_id: async_sequence_id_t,
398        out_error: *mut *const ::core::ffi::c_char,
399    ) -> zx_status_t;
400}
401#[doc = " Handles execution of a posted task.\n\n The |status| is |ZX_OK| if the task's deadline elapsed and the task should run.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran."]
402pub type async_task_handler_t = ::core::option::Option<
403    unsafe extern "C" fn(
404        dispatcher: *mut async_dispatcher_t,
405        task: *mut async_task_t,
406        status: zx_status_t,
407    ),
408>;
409#[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down.  Thereafter, the task\n may be posted again or destroyed."]
410#[repr(C)]
411pub struct async_task {
412    #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
413    pub state: async_state_t,
414    #[doc = " The task's handler function."]
415    pub handler: async_task_handler_t,
416    #[doc = " The task's deadline must be expressed in the time base used by the asynchronous\n dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).\n See |async_now()| for details."]
417    pub deadline: zx_time_t,
418}
419#[allow(clippy::unnecessary_operation, clippy::identity_op)]
420const _: () = {
421    ["Size of async_task"][::core::mem::size_of::<async_task>() - 32usize];
422    ["Alignment of async_task"][::core::mem::align_of::<async_task>() - 8usize];
423    ["Offset of field: async_task::state"][::core::mem::offset_of!(async_task, state) - 0usize];
424    ["Offset of field: async_task::handler"]
425        [::core::mem::offset_of!(async_task, handler) - 16usize];
426    ["Offset of field: async_task::deadline"]
427        [::core::mem::offset_of!(async_task, deadline) - 24usize];
428};
429impl Default for async_task {
430    fn default() -> Self {
431        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
432        unsafe {
433            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
434            s.assume_init()
435        }
436    }
437}
438impl ::core::fmt::Debug for async_task {
439    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
440        write!(f, "async_task {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
441    }
442}
443unsafe extern "C" {
444    #[doc = " Posts a task to run on or after its deadline following all posted\n tasks with lesser or equal deadlines.\n\n The task's handler will be invoked exactly once unless the task is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining tasks will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Dispatcher implementations must treat |ZX_TIME_INFINITE_PAST| as a sentinel\n value meaning \"no deadline\". Tasks with expired deadlines must always be\n processed before tasks without deadlines (those posted with\n |ZX_TIME_INFINITE_PAST|).\n\n Note: If there are always tasks with expired deadlines, tasks without\n deadlines may be starved.\n\n Returns |ZX_OK| if the task was successfully posted.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
445    pub fn async_post_task(
446        dispatcher: *mut async_dispatcher_t,
447        task: *mut async_task_t,
448    ) -> zx_status_t;
449}
450unsafe extern "C" {
451    #[doc = " Cancels the task associated with |task|.\n\n If successful, the task's handler will not run.\n\n Returns |ZX_OK| if the task was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending task either because it\n already ran, had not been posted, or has been dequeued and is pending\n execution (perhaps on another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
452    pub fn async_cancel_task(
453        dispatcher: *mut async_dispatcher_t,
454        task: *mut async_task_t,
455    ) -> zx_status_t;
456}
457unsafe extern "C" {
458    #[doc = " Returns the current time in the dispatcher's timebase.\n For most loops, this is generally obtained from |ZX_CLOCK_MONOTONIC|\n but certain loops may use a different tiembase, notably for testing."]
459    pub fn async_now(dispatcher: *mut async_dispatcher_t) -> zx_time_t;
460}
461#[doc = " Handles an asynchronous trap access.\n\n The |status| is |ZX_OK| if the bell was received and |bell| contains the\n information from the packet, otherwise |bell| is null."]
462pub type async_guest_bell_trap_handler_t = ::core::option::Option<
463    unsafe extern "C" fn(
464        dispatcher: *mut async_dispatcher_t,
465        trap: *mut async_guest_bell_trap_t,
466        status: zx_status_t,
467        bell: *const zx_packet_guest_bell_t,
468    ),
469>;
470#[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down.  There is no way to cancel a trap which has been set."]
471#[repr(C)]
472#[derive(Debug, Default, Copy, Clone)]
473pub struct async_guest_bell_trap {
474    #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
475    pub state: async_state_t,
476    #[doc = " The handler to invoke to handle the trap access."]
477    pub handler: async_guest_bell_trap_handler_t,
478}
479#[allow(clippy::unnecessary_operation, clippy::identity_op)]
480const _: () = {
481    ["Size of async_guest_bell_trap"][::core::mem::size_of::<async_guest_bell_trap>() - 24usize];
482    ["Alignment of async_guest_bell_trap"]
483        [::core::mem::align_of::<async_guest_bell_trap>() - 8usize];
484    ["Offset of field: async_guest_bell_trap::state"]
485        [::core::mem::offset_of!(async_guest_bell_trap, state) - 0usize];
486    ["Offset of field: async_guest_bell_trap::handler"]
487        [::core::mem::offset_of!(async_guest_bell_trap, handler) - 16usize];
488};
489unsafe extern "C" {
490    #[doc = " Sets a bell trap in the guest to be handled asynchronously via a handler.\n\n |guest| is the handle of the guest the trap will be set on.\n |addr| is the base address for the trap in the guest's physical address space.\n |length| is the size of the trap in the guest's physical address space.\n\n Returns |ZX_OK| if the trap was successfully set.\n Returns |ZX_ERR_ACCESS_DENIED| if the guest does not have |ZX_RIGHT_WRITE|.\n Returns |ZX_ERR_ALREADY_EXISTS| if a bell trap with the same |addr| exists.\n Returns |ZX_ERR_INVALID_ARGS| if |addr| or |length| are invalid.\n Returns |ZX_ERR_OUT_OF_RANGE| if |addr| or |length| are out of range of the\n address space.\n Returns |ZX_ERR_WRONG_TYPE| if |guest| is not a handle to a guest.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
491    pub fn async_set_guest_bell_trap(
492        dispatcher: *mut async_dispatcher_t,
493        trap: *mut async_guest_bell_trap_t,
494        guest: zx_handle_t,
495        addr: zx_vaddr_t,
496        length: usize,
497    ) -> zx_status_t;
498}
499#[doc = " Handles completion of asynchronous wait operations.\n\n The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran or the task was canceled."]
500pub type async_wait_handler_t = ::core::option::Option<
501    unsafe extern "C" fn(
502        dispatcher: *mut async_dispatcher_t,
503        wait: *mut async_wait_t,
504        status: zx_status_t,
505        signal: *const zx_packet_signal_t,
506    ),
507>;
508#[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down.  Thereafter, the wait\n may be started begun or destroyed."]
509#[repr(C)]
510pub struct async_wait {
511    #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
512    pub state: async_state_t,
513    #[doc = " The wait's handler function."]
514    pub handler: async_wait_handler_t,
515    #[doc = " The object to wait for signals on."]
516    pub object: zx_handle_t,
517    #[doc = " The set of signals to wait for."]
518    pub trigger: zx_signals_t,
519    #[doc = " Wait options, see zx_object_wait_async()."]
520    pub options: u32,
521}
522#[allow(clippy::unnecessary_operation, clippy::identity_op)]
523const _: () = {
524    ["Size of async_wait"][::core::mem::size_of::<async_wait>() - 40usize];
525    ["Alignment of async_wait"][::core::mem::align_of::<async_wait>() - 8usize];
526    ["Offset of field: async_wait::state"][::core::mem::offset_of!(async_wait, state) - 0usize];
527    ["Offset of field: async_wait::handler"]
528        [::core::mem::offset_of!(async_wait, handler) - 16usize];
529    ["Offset of field: async_wait::object"][::core::mem::offset_of!(async_wait, object) - 24usize];
530    ["Offset of field: async_wait::trigger"]
531        [::core::mem::offset_of!(async_wait, trigger) - 28usize];
532    ["Offset of field: async_wait::options"]
533        [::core::mem::offset_of!(async_wait, options) - 32usize];
534};
535impl Default for async_wait {
536    fn default() -> Self {
537        let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
538        unsafe {
539            ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
540            s.assume_init()
541        }
542    }
543}
544impl ::core::fmt::Debug for async_wait {
545    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
546        write!(f, "async_wait {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
547    }
548}
549unsafe extern "C" {
550    #[doc = " Begins asynchronously waiting for an object to receive one or more signals\n specified in |wait|.  Invokes the handler when the wait completes.\n\n The wait's handler will be invoked exactly once unless the wait is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Returns |ZX_OK| if the wait was successfully begun.\n Returns |ZX_ERR_ACCESS_DENIED| if the object does not have |ZX_RIGHT_WAIT|.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
551    pub fn async_begin_wait(
552        dispatcher: *mut async_dispatcher_t,
553        wait: *mut async_wait_t,
554    ) -> zx_status_t;
555}
556unsafe extern "C" {
557    #[doc = " Cancels the wait associated with |wait|.\n\n If successful, the wait's handler will not run.\n\n Returns |ZX_OK| if the wait was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending wait either because it\n already completed, had not been started, or its completion packet has been\n dequeued from the port and is pending delivery to its handler (perhaps on\n another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
558    pub fn async_cancel_wait(
559        dispatcher: *mut async_dispatcher_t,
560        wait: *mut async_wait_t,
561    ) -> zx_status_t;
562}