1 //! Implementations of the [`Connection`] trait for various built-in types 2 // TODO: impl Connection for all `Read + Write` (blocked on specialization) 3 4 #[cfg(feature = "alloc")] 5 mod boxed; 6 7 #[cfg(feature = "std")] 8 mod tcpstream; 9 10 #[cfg(all(feature = "std", unix))] 11 mod unixstream; 12 13 use super::Connection; 14 15 impl<E> Connection for &mut dyn Connection<Error = E> { 16 type Error = E; 17 read(&mut self) -> Result<u8, Self::Error>18 fn read(&mut self) -> Result<u8, Self::Error> { 19 (**self).read() 20 } 21 read_exact(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>22 fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Self::Error> { 23 (**self).read_exact(buf) 24 } 25 write(&mut self, byte: u8) -> Result<(), Self::Error>26 fn write(&mut self, byte: u8) -> Result<(), Self::Error> { 27 (**self).write(byte) 28 } 29 write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>30 fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { 31 (**self).write_all(buf) 32 } 33 peek(&mut self) -> Result<Option<u8>, Self::Error>34 fn peek(&mut self) -> Result<Option<u8>, Self::Error> { 35 (**self).peek() 36 } 37 flush(&mut self) -> Result<(), Self::Error>38 fn flush(&mut self) -> Result<(), Self::Error> { 39 (**self).flush() 40 } 41 on_session_start(&mut self) -> Result<(), Self::Error>42 fn on_session_start(&mut self) -> Result<(), Self::Error> { 43 (**self).on_session_start() 44 } 45 } 46