// The Axiom guest ABI for Rust, written from surface.h at 607a9c5.
// Generated by the Axiom website from the same header; do not edit it,
// download it again when the surface changes.
//
// Every pointer is into the mod's own memory. Every call that can fail
// returns a status: 0 is success, the rest are the capability's errors.

#![allow(dead_code, non_snake_case, clippy::missing_safety_doc)]

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomSpan {
    pub Offset: u32,
    pub Length: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomVec2 {
    pub x: f32,
    pub y: f32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomVec3 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomVec4 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomQuat {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomTransform {
    pub position: AxiomVec3,
    pub rotation: AxiomQuat,
    pub scale: AxiomVec3,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomMat4 {
    pub c0: AxiomVec4,
    pub c1: AxiomVec4,
    pub c2: AxiomVec4,
    pub c3: AxiomVec4,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomClip {
    pub near: f32,
    pub far: f32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomEntityQueryEntityId {
    pub index: u32,
    pub generation: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomUiOverlayPanelId {
    pub index: u32,
    pub generation: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomUiOverlayNodeId {
    pub index: u32,
    pub generation: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomHookHookId {
    pub index: u32,
    pub generation: u32,
}

pub const AXIOM_EVENT_READ_OK: i32 = 0;
pub const AXIOM_EVENT_READ_NONE: i32 = 1;
pub const AXIOM_EVENT_READ_TOO_SMALL: i32 = 2;
pub const AXIOM_EVENT_ENTITY_QUERY_SPAWNED: u32 = 0x454c34db;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomEntityQuerySpawnedEvent {
    pub entity: AxiomEntityQueryEntityId,
}

pub const AXIOM_EVENT_ENTITY_QUERY_DESPAWNED: u32 = 0x84e90952;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomEntityQueryDespawnedEvent {
    pub entity: AxiomEntityQueryEntityId,
}

pub const AXIOM_EVENT_ENTITY_TRANSFORM_MOVED: u32 = 0x629e1296;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomEntityTransformMovedEvent {
    pub entity: AxiomEntityQueryEntityId,
    pub from: AxiomVec3,
    pub to: AxiomVec3,
}

pub const AXIOM_EVENT_UI_OVERLAY_PRESSED: u32 = 0x44f17222;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomUiOverlayPressedEvent {
    pub panel: AxiomUiOverlayPanelId,
    pub id: AxiomSpan,
}

pub const AXIOM_EVENT_INPUT_OBSERVE_BOUND: u32 = 0x8f92f3c8;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomInputObserveBoundEvent {
    pub id: AxiomSpan,
    pub key: AxiomSpan,
}

pub const AXIOM_EVENT_CONFIG_CHANGED: u32 = 0x11c66332;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomConfigChangedEvent {
    pub key: AxiomSpan,
}

pub const AXIOM_EVENT_HOOK_CALLED: u32 = 0x61f77294;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct AxiomHookCalledEvent {
    pub hook: AxiomHookHookId,
}


#[link(wasm_import_module = "axiom:event")]
unsafe extern "C" {
    #[link_name = "read"]
    pub fn axiom_event_read(out: *mut u8, capacity: u32) -> i32;
}

#[link(wasm_import_module = "axiom:entity.query@1")]
unsafe extern "C" {
    #[link_name = "alive"]
    pub fn axiom_entity_query_alive(out: *mut AxiomEntityQueryEntityId, out_count: u32) -> u32;
    #[link_name = "by_kind"]
    pub fn axiom_entity_query_by_kind(kind: *const u8, kind_length: u32, out: *mut AxiomEntityQueryEntityId, out_count: u32) -> u32;
    #[link_name = "within"]
    pub fn axiom_entity_query_within(centre_x: f32, centre_y: f32, centre_z: f32, radius: f32, out: *mut AxiomEntityQueryEntityId, out_count: u32) -> u32;
    #[link_name = "is_alive"]
    pub fn axiom_entity_query_is_alive(id_index: u32, id_generation: u32) -> i32;
    #[link_name = "count"]
    pub fn axiom_entity_query_count() -> u32;
}

#[link(wasm_import_module = "axiom:entity.transform@1")]
unsafe extern "C" {
    #[link_name = "transform"]
    pub fn axiom_entity_transform_transform(id_index: u32, id_generation: u32, out: *mut AxiomTransform) -> i32;
    #[link_name = "transforms"]
    pub fn axiom_entity_transform_transforms(ids: *const AxiomEntityQueryEntityId, ids_count: u32, out: *mut AxiomTransform, out_count: u32, out_used: *mut u32) -> i32;
    #[link_name = "position"]
    pub fn axiom_entity_transform_position(id_index: u32, id_generation: u32, out: *mut AxiomVec3) -> i32;
    #[link_name = "positions"]
    pub fn axiom_entity_transform_positions(ids: *const AxiomEntityQueryEntityId, ids_count: u32, out: *mut AxiomVec3, out_count: u32, out_used: *mut u32) -> i32;
    #[link_name = "set_position"]
    pub fn axiom_entity_transform_set_position(id_index: u32, id_generation: u32, position_x: f32, position_y: f32, position_z: f32) -> i32;
    #[link_name = "writable"]
    pub fn axiom_entity_transform_writable() -> i32;
}

#[link(wasm_import_module = "axiom:frame@1")]
unsafe extern "C" {
    #[link_name = "delta"]
    pub fn axiom_frame_delta() -> f32;
    #[link_name = "index"]
    pub fn axiom_frame_index() -> u64;
    #[link_name = "staleness_ms"]
    pub fn axiom_frame_staleness_ms() -> u32;
}

#[link(wasm_import_module = "axiom:camera@1")]
unsafe extern "C" {
    #[link_name = "view"]
    pub fn axiom_camera_view(out: *mut AxiomMat4) -> i32;
    #[link_name = "projection"]
    pub fn axiom_camera_projection(out: *mut AxiomMat4) -> i32;
    #[link_name = "view_projection"]
    pub fn axiom_camera_view_projection(out: *mut AxiomMat4) -> i32;
    #[link_name = "position"]
    pub fn axiom_camera_position(out: *mut AxiomVec3) -> i32;
    #[link_name = "fov"]
    pub fn axiom_camera_fov(out: *mut f32) -> i32;
    #[link_name = "clip"]
    pub fn axiom_camera_clip(out: *mut AxiomClip) -> i32;
}

#[link(wasm_import_module = "axiom:project@1")]
unsafe extern "C" {
    #[link_name = "world_to_screen"]
    pub fn axiom_project_world_to_screen(point_x: f32, point_y: f32, point_z: f32, out: *mut AxiomVec2) -> i32;
}

#[link(wasm_import_module = "axiom:ui.overlay@1")]
unsafe extern "C" {
    #[link_name = "panel"]
    pub fn axiom_ui_overlay_panel(title: *const u8, title_length: u32, out: *mut AxiomUiOverlayPanelId) -> i32;
    #[link_name = "list"]
    pub fn axiom_ui_overlay_list(panel_index: u32, panel_generation: u32, out: *mut AxiomUiOverlayNodeId) -> i32;
    #[link_name = "set"]
    pub fn axiom_ui_overlay_set(list_index: u32, list_generation: u32, cells: *const AxiomSpan, cells_count: u32, columns: u32) -> i32;
    #[link_name = "table"]
    pub fn axiom_ui_overlay_table(panel_index: u32, panel_generation: u32, columns: *const AxiomSpan, columns_count: u32, out: *mut AxiomUiOverlayNodeId) -> i32;
    #[link_name = "text"]
    pub fn axiom_ui_overlay_text(panel_index: u32, panel_generation: u32, line: *const u8, line_length: u32) -> i32;
    #[link_name = "slider"]
    pub fn axiom_ui_overlay_slider(panel_index: u32, panel_generation: u32, label: *const u8, label_length: u32, bound: *const u8, bound_length: u32) -> i32;
    #[link_name = "toggle"]
    pub fn axiom_ui_overlay_toggle(panel_index: u32, panel_generation: u32, label: *const u8, label_length: u32, bound: *const u8, bound_length: u32) -> i32;
    #[link_name = "select"]
    pub fn axiom_ui_overlay_select(panel_index: u32, panel_generation: u32, label: *const u8, label_length: u32, bound: *const u8, bound_length: u32) -> i32;
    #[link_name = "button"]
    pub fn axiom_ui_overlay_button(panel_index: u32, panel_generation: u32, label: *const u8, label_length: u32, id: *const u8, id_length: u32) -> i32;
    #[link_name = "graph"]
    pub fn axiom_ui_overlay_graph(panel_index: u32, panel_generation: u32, label: *const u8, label_length: u32, value: f32, window: u32) -> i32;
    #[link_name = "note"]
    pub fn axiom_ui_overlay_note(panel_index: u32, panel_generation: u32, text: *const u8, text_length: u32) -> i32;
}

#[link(wasm_import_module = "axiom:input.observe@1")]
unsafe extern "C" {
    #[link_name = "down"]
    pub fn axiom_input_observe_down(key: *const u8, key_length: u32, out: *mut i32) -> i32;
    #[link_name = "cursor"]
    pub fn axiom_input_observe_cursor(out: *mut AxiomVec2) -> i32;
    #[link_name = "captured"]
    pub fn axiom_input_observe_captured(out: *mut i32) -> i32;
    #[link_name = "bind"]
    pub fn axiom_input_observe_bind(id: *const u8, id_length: u32, label: *const u8, label_length: u32, preferred: *const u8, preferred_length: u32) -> i32;
}

#[link(wasm_import_module = "axiom:config@1")]
unsafe extern "C" {
    #[link_name = "number"]
    pub fn axiom_config_number(key: *const u8, key_length: u32, out: *mut f32) -> i32;
    #[link_name = "flag"]
    pub fn axiom_config_flag(key: *const u8, key_length: u32, out: *mut i32) -> i32;
    #[link_name = "text"]
    pub fn axiom_config_text(key: *const u8, key_length: u32, out: *mut u8, out_length: u32, out_used: *mut u32) -> i32;
}

#[link(wasm_import_module = "axiom:hook@1")]
unsafe extern "C" {
    #[link_name = "attach"]
    pub fn axiom_hook_attach(function: *const u8, function_length: u32, priority: u32, out: *mut AxiomHookHookId) -> i32;
    #[link_name = "detach"]
    pub fn axiom_hook_detach(hook_index: u32, hook_generation: u32) -> i32;
    #[link_name = "attached"]
    pub fn axiom_hook_attached(function: *const u8, function_length: u32, out: *mut i32) -> i32;
}

#[link(wasm_import_module = "axiom:fs@1")]
unsafe extern "C" {
    #[link_name = "read"]
    pub fn axiom_fs_read(path: *const u8, path_length: u32, out: *mut u8, out_length: u32, out_used: *mut u32) -> i32;
    #[link_name = "write"]
    pub fn axiom_fs_write(path: *const u8, path_length: u32, contents: *const u8, contents_length: u32) -> i32;
    #[link_name = "exists"]
    pub fn axiom_fs_exists(path: *const u8, path_length: u32, out: *mut i32) -> i32;
}

#[link(wasm_import_module = "axiom:fs.any@1")]
unsafe extern "C" {
    #[link_name = "read"]
    pub fn axiom_fs_any_read(path: *const u8, path_length: u32, out: *mut u8, out_length: u32, out_used: *mut u32) -> i32;
    #[link_name = "exists"]
    pub fn axiom_fs_any_exists(path: *const u8, path_length: u32, out: *mut i32) -> i32;
}

#[link(wasm_import_module = "axiom:assets.redirect@1")]
unsafe extern "C" {
    #[link_name = "redirect"]
    pub fn axiom_assets_redirect_redirect(asset: *const u8, asset_length: u32, to: *const u8, to_length: u32) -> i32;
    #[link_name = "restore"]
    pub fn axiom_assets_redirect_restore(asset: *const u8, asset_length: u32) -> i32;
}

#[link(wasm_import_module = "axiom:net@1")]
unsafe extern "C" {
    #[link_name = "get"]
    pub fn axiom_net_get(url: *const u8, url_length: u32, out: *mut u8, out_length: u32, out_used: *mut u32) -> i32;
    #[link_name = "post"]
    pub fn axiom_net_post(url: *const u8, url_length: u32, body: *const u8, body_length: u32, out: *mut u8, out_length: u32, out_used: *mut u32) -> i32;
}
