Skip to main content

dpp_plugin_sdk/
entry.rs

1//! ABI entry-point wrappers called by [`crate::export_plugin!`].
2
3use dpp_plugin_traits::DppProductGroupPlugin;
4
5use crate::abi;
6use crate::codec::{
7    calculate_metrics_bytes, describe_bytes, generate_passport_bytes, metadata_bytes,
8    validate_bytes,
9};
10
11pub fn run_metadata<P: DppProductGroupPlugin>(plugin: &P) -> u64 {
12    abi::write_output(metadata_bytes(plugin))
13}
14
15pub fn run_describe<P: DppProductGroupPlugin>(plugin: &P) -> u64 {
16    abi::write_output(describe_bytes(plugin))
17}
18
19/// # Safety
20/// `ptr`/`len` must describe a host-written input buffer (see [`abi::read_input`]).
21pub unsafe fn run_validate<P: DppProductGroupPlugin>(plugin: &P, ptr: u32, len: u32) -> u64 {
22    unsafe { abi::write_output(validate_bytes(plugin, abi::read_input(ptr, len))) }
23}
24
25/// # Safety
26/// `ptr`/`len` must describe a host-written input buffer (see [`abi::read_input`]).
27pub unsafe fn run_calculate_metrics<P: DppProductGroupPlugin>(
28    plugin: &P,
29    ptr: u32,
30    len: u32,
31) -> u64 {
32    unsafe { abi::write_output(calculate_metrics_bytes(plugin, abi::read_input(ptr, len))) }
33}
34
35/// # Safety
36/// `ptr`/`len` must describe a host-written input buffer (see [`abi::read_input`]).
37pub unsafe fn run_generate_passport<P: DppProductGroupPlugin>(
38    plugin: &P,
39    ptr: u32,
40    len: u32,
41) -> u64 {
42    unsafe { abi::write_output(generate_passport_bytes(plugin, abi::read_input(ptr, len))) }
43}