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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::types::BoxedBytes;
use alloc::string::String;
use alloc::vec::Vec;
use elrond_codec::{DecodeError, EncodeError};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct SCError(BoxedBytes);
impl SCError {
    #[inline]
    pub fn as_bytes(&self) -> &[u8] {
        self.0.as_slice()
    }
}
impl From<BoxedBytes> for SCError {
    #[inline]
    fn from(boxed_bytes: BoxedBytes) -> Self {
        SCError(boxed_bytes)
    }
}
impl From<&str> for SCError {
    #[inline]
    fn from(s: &str) -> Self {
        SCError(BoxedBytes::from(s.as_bytes()))
    }
}
impl From<String> for SCError {
    #[inline]
    fn from(s: String) -> Self {
        
        
        
        SCError(BoxedBytes::from(s.into_bytes()))
    }
}
impl From<&[u8]> for SCError {
    #[inline]
    fn from(byte_slice: &[u8]) -> Self {
        SCError(BoxedBytes::from(byte_slice))
    }
}
impl From<Vec<u8>> for SCError {
    #[inline]
    fn from(v: Vec<u8>) -> Self {
        SCError(BoxedBytes::from(v))
    }
}
impl From<EncodeError> for SCError {
    #[inline]
    fn from(err: EncodeError) -> Self {
        SCError::from(err.message_bytes())
    }
}
impl From<DecodeError> for SCError {
    #[inline]
    fn from(err: DecodeError) -> Self {
        SCError::from(err.message_bytes())
    }
}
impl From<!> for SCError {
    fn from(_: !) -> Self {
        unreachable!()
    }
}