iop_sdk_ffi/signed/
json.rs1use super::*;
2
3#[no_mangle]
4pub extern "C" fn delete_SignedJson(signed: *mut Signed<serde_json::Value>) {
5 delete(signed)
6}
7
8#[no_mangle]
9pub extern "C" fn SignedJson_public_key_get(
10 signed: *mut Signed<serde_json::Value>,
11) -> *mut MPublicKey {
12 public_key(signed)
13}
14
15#[no_mangle]
16pub extern "C" fn SignedJson_content_get(
17 signed: *mut Signed<serde_json::Value>,
18) -> *mut raw::c_char {
19 let signed = unsafe { convert::borrow_in(signed) };
20 let string = serde_json::to_string_pretty(signed.content()).unwrap();
22 convert::string_out(string)
23}
24
25#[no_mangle]
26pub extern "C" fn SignedJson_signature_get(
27 signed: *mut Signed<serde_json::Value>,
28) -> *mut MSignature {
29 signature(signed)
30}
31
32#[no_mangle]
33pub extern "C" fn SignedJson_validate(signed: *const Signed<serde_json::Value>) -> bool {
34 let signed = unsafe { convert::borrow_in(signed) };
35 signed.validate()
36}
37
38#[no_mangle]
39pub extern "C" fn SignedJson_validate_with_keyid(
40 signed: *const Signed<serde_json::Value>, signer_id: *mut MKeyId,
41) -> bool {
42 let signed = unsafe { convert::borrow_in(signed) };
43 let signer_id = unsafe { convert::borrow_in(signer_id) };
44 signed.validate_with_keyid(Some(signer_id))
45}
46
47#[no_mangle]
48pub extern "C" fn SignedJson_validate_with_did_doc(
49 signed: *const Signed<serde_json::Value>, did_doc_str: *const raw::c_char,
50 from_height_inc: *const BlockHeight, until_height_exc: *const BlockHeight,
51) -> CPtrResult<ValidationResult> {
52 validate_with_did_doc(signed, did_doc_str, from_height_inc, until_height_exc)
53}
54
55#[no_mangle]
56pub extern "C" fn SignedJson_to_json(signed: *const Signed<serde_json::Value>) -> *mut raw::c_char {
57 let signed = unsafe { convert::borrow_in(signed) };
58 let signed_string =
59 serde_json::to_string(signed).expect("SignedJson serialize implementation error");
60 convert::string_out(signed_string)
61}
62
63#[no_mangle]
64pub extern "C" fn SignedJson_from_json(
65 signed_str: *const raw::c_char,
66) -> *mut CResult<Signed<serde_json::Value>> {
67 let fun = || {
68 let signed_str = unsafe { convert::str_in(signed_str)? };
69 let signed: Signed<serde_json::Value> = serde_json::from_str(signed_str)?;
70 Ok(convert::move_out(signed))
71 };
72 cresult(fun())
73}