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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::{
    abi::TypeAbi,
    api::{EndpointFinishApi, ManagedTypeApi},
    io::{ArgId, ContractCallArg, DynArg, DynArgInput},
    DynArgOutput, EndpointResult,
};
use alloc::string::String;

/// Structure that allows taking a variable number of arguments,
/// but does nothing with them, not even deserialization.
#[derive(Default, Clone)]
pub struct IgnoreVarArgs;

impl DynArg for IgnoreVarArgs {
    fn dyn_load<I: DynArgInput>(loader: &mut I, _arg_id: ArgId) -> Self {
        loader.flush_ignore();
        IgnoreVarArgs
    }
}

impl EndpointResult for IgnoreVarArgs {
    type DecodeAs = IgnoreVarArgs;

    #[inline]
    fn finish<FA>(&self, _api: FA)
    where
        FA: ManagedTypeApi + EndpointFinishApi + Clone + 'static,
    {
    }
}

impl ContractCallArg for &IgnoreVarArgs {
    fn push_dyn_arg<O: DynArgOutput>(&self, _output: &mut O) {}
}

impl ContractCallArg for IgnoreVarArgs {
    fn push_dyn_arg<O: DynArgOutput>(&self, _output: &mut O) {}
}

impl TypeAbi for IgnoreVarArgs {
    fn type_name() -> String {
        String::from("ignore")
    }

    fn is_multi_arg_or_result() -> bool {
        true
    }
}