ark-api-ffi 0.17.0-pre.15

Ark low-level Wasm FFI API
Documentation
define_api_id!(0x37d7_3b57_d84f_2ea9, "resource-v1");

use crate::FFIResult;

pub type ResourceHandleRepr = u32;

#[ark_api_macros::ark_bindgen(imports = "ark-resource-v1")]
mod resource {
    use super::*;

    extern "C" {
        /// Requests the latest version of a resource given the provided name
        ///
        /// This will start downloading the resource if it isn't present in Ark
        pub fn request_resource_by_name(name: &str) -> ResourceHandleRepr;

        /// Retrieve the handle's data
        ///
        /// Returns [`Unavailable`](crate::ErrorCode::Unavailable) if the resource hasn't finished downloading
        pub fn try_retrieve(resource_handle: ResourceHandleRepr) -> FFIResult<Vec<u8>>;

        /// Check if the resource is available for use
        ///
        /// Returns [`Unavailable`](crate::ErrorCode::Unavailable) if the resource hasn't finished downloading
        pub fn is_ready(resource_handle: ResourceHandleRepr) -> FFIResult<()>;
    }
}

pub use resource::*;