1use Error;
2
3pub unsafe trait Plain {
26 #[inline(always)]
27 fn from_bytes(bytes: &[u8]) -> Result<&Self, Error>
28 where
29 Self: Sized,
30 {
31 ::from_bytes(bytes)
32 }
33
34 #[inline(always)]
35 fn slice_from_bytes(bytes: &[u8]) -> Result<&[Self], Error>
36 where
37 Self: Sized,
38 {
39 ::slice_from_bytes(bytes)
40 }
41
42 #[inline(always)]
43 fn slice_from_bytes_len(bytes: &[u8], len: usize) -> Result<&[Self], Error>
44 where
45 Self: Sized,
46 {
47 ::slice_from_bytes_len(bytes, len)
48 }
49
50 #[inline(always)]
51 fn from_mut_bytes(bytes: &mut [u8]) -> Result<&mut Self, Error>
52 where
53 Self: Sized,
54 {
55 ::from_mut_bytes(bytes)
56 }
57
58 #[inline(always)]
59 fn slice_from_mut_bytes(bytes: &mut [u8]) -> Result<&mut [Self], Error>
60 where
61 Self: Sized,
62 {
63 ::slice_from_mut_bytes(bytes)
64 }
65
66 #[inline(always)]
67 fn slice_from_mut_bytes_len(bytes: &mut [u8], len: usize) -> Result<&mut [Self], Error>
68 where
69 Self: Sized,
70 {
71 ::slice_from_mut_bytes_len(bytes, len)
72 }
73
74 #[inline(always)]
75 fn copy_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> {
76 ::copy_from_bytes(self, bytes)
77 }
78}
79
80unsafe impl Plain for u8 {}
81unsafe impl Plain for u16 {}
82unsafe impl Plain for u32 {}
83unsafe impl Plain for u64 {}
84unsafe impl Plain for usize {}
85
86unsafe impl Plain for i8 {}
87unsafe impl Plain for i16 {}
88unsafe impl Plain for i32 {}
89unsafe impl Plain for i64 {}
90unsafe impl Plain for isize {}
91
92unsafe impl<S> Plain for [S]
93where
94 S: Plain,
95{
96}