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 std::ops::{Index, RangeTo, RangeFrom, Range, Deref, DerefMut}; use std::fmt; use std::mem; use ::libc; pub struct Out([libc::c_uchar; 496]); impl Default for Out { fn default() -> Out { unsafe { Out(mem::zeroed()) } } } impl Deref for Out { type Target = [libc::c_uchar]; fn deref<'a>(&'a self) -> &[libc::c_uchar] { &self.0 } } impl DerefMut for Out { fn deref_mut(&mut self) -> &mut [libc::c_uchar] { &mut self.0 } } impl Index<libc::size_t> for Out { type Output = libc::c_uchar; fn index(&self, count: libc::size_t) -> &libc::c_uchar { &self.0[count] } } impl Index<RangeTo<libc::size_t>> for Out { type Output = [libc::c_uchar]; fn index(&self, range: RangeTo<libc::size_t>) -> &[libc::c_uchar] { &self.0[range] } } impl Index<RangeFrom<libc::size_t>> for Out { type Output = [libc::c_uchar]; fn index(&self, range: RangeFrom<libc::size_t>) -> &[libc::c_uchar] { &self.0[range] } } impl Index<Range<libc::size_t>> for Out { type Output = [libc::c_uchar]; fn index(&self, range: Range<libc::size_t>) -> &[libc::c_uchar] { &self.0[range] } } impl Copy for Out {} impl Clone for Out { fn clone(&self) -> Self { Out(self.0) } } impl fmt::Debug for Out { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", String::from_utf8_lossy(&self.0) ) } }