multiversx_sc/io/
arg_id.rs

1/// Some info to display in endpoint argument deserialization error messages,
2/// to help users identify the faulty argument.
3/// Generated automatically.
4/// Current version uses argument names,
5/// but in principle it could be changed to argument index to save some bytes from the wasm output.
6#[derive(Clone, Copy)]
7pub struct ArgId(&'static [u8]);
8
9impl From<&'static [u8]> for ArgId {
10    #[inline]
11    fn from(static_bytes: &'static [u8]) -> Self {
12        ArgId(static_bytes)
13    }
14}
15
16impl From<&'static str> for ArgId {
17    #[inline]
18    fn from(static_str: &'static str) -> Self {
19        ArgId(static_str.as_bytes())
20    }
21}
22
23impl ArgId {
24    pub fn as_bytes(&self) -> &'static [u8] {
25        self.0
26    }
27
28    #[inline]
29    pub fn empty() -> Self {
30        ArgId::from(&[][..])
31    }
32}