multiversx_sc/io/
arg_id.rs

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
/// Some info to display in endpoint argument deserialization error messages,
/// to help users identify the faulty argument.
/// Generated automatically.
/// Current version uses argument names,
/// but in principle it could be changed to argument index to save some bytes from the wasm output.
#[derive(Clone, Copy)]
pub struct ArgId(&'static [u8]);

impl From<&'static [u8]> for ArgId {
    #[inline]
    fn from(static_bytes: &'static [u8]) -> Self {
        ArgId(static_bytes)
    }
}

impl From<&'static str> for ArgId {
    #[inline]
    fn from(static_str: &'static str) -> Self {
        ArgId(static_str.as_bytes())
    }
}

impl ArgId {
    pub fn as_bytes(&self) -> &'static [u8] {
        self.0
    }

    #[inline]
    pub fn empty() -> Self {
        ArgId::from(&[][..])
    }
}