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
use crate::{
error::{ZomeApiError, ZomeApiResult},
meta::ZomeDefinition,
};
use holochain_core_types::entry::entry_type::EntryType;
use holochain_json_api::json::JsonString;
#[allow(improper_ctypes)]
extern "C" {
fn zome_setup(zd: &mut ZomeDefinition);
}
pub fn entry_type_properties(name: &EntryType) -> ZomeApiResult<JsonString> {
let mut zd = ZomeDefinition::new();
unsafe { zome_setup(&mut zd) };
let entry_def = zd.entry_types.iter().find(|elem| &elem.name == name);
entry_def
.map(|entry_def| entry_def.entry_type_definition.properties.clone())
.ok_or_else(|| ZomeApiError::Internal("No matching entry type in this zome".into()))
}