testnumbat_wasm/api/
endpoint_arg_api.rs

1use crate::{api::ErrorApi, err_msg, types::BoxedBytes};
2use alloc::vec::Vec;
3
4use super::Handle;
5
6/// Interface to only be used by code generated by the macros.
7/// The smart contract code doesn't have access to these methods directly.
8pub trait EndpointArgumentApi: ErrorApi {
9    fn get_num_arguments(&self) -> i32;
10
11    fn check_num_arguments(&self, expected: i32) {
12        let nr_args = self.get_num_arguments();
13        if nr_args != expected {
14            self.signal_error(err_msg::ARG_WRONG_NUMBER);
15        }
16    }
17
18    fn get_argument_len(&self, arg_index: i32) -> usize;
19
20    fn copy_argument_to_slice(&self, arg_index: i32, slice: &mut [u8]);
21
22    fn get_argument_vec_u8(&self, arg_index: i32) -> Vec<u8>;
23
24    fn get_argument_boxed_bytes(&self, arg_index: i32) -> BoxedBytes {
25        self.get_argument_vec_u8(arg_index).into()
26    }
27
28    fn get_argument_big_int_raw(&self, arg_id: i32) -> Handle;
29
30    fn get_argument_big_uint_raw(&self, arg_id: i32) -> Handle;
31
32    fn get_argument_managed_buffer_raw(&self, arg_id: i32) -> Handle;
33
34    fn get_argument_u64(&self, arg_id: i32) -> u64;
35
36    fn get_argument_i64(&self, arg_id: i32) -> i64;
37}