1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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::*;