/rust/registry/src/index.crates.io-1949cf8c6b5b557f/gif-0.13.3/src/traits.rs
Line | Count | Source |
1 | | //! Traits used in this library |
2 | | use std::io; |
3 | | |
4 | | /// Writer extension to write little endian data |
5 | | pub trait WriteBytesExt<T> { |
6 | | /// Writes `T` to a bytes stream. Least significant byte first. |
7 | | fn write_le(&mut self, n: T) -> io::Result<()>; |
8 | | |
9 | | /* |
10 | | #[inline] |
11 | | fn write_byte(&mut self, n: u8) -> io::Result<()> where Self: Write { |
12 | | self.write_all(&[n]) |
13 | | } |
14 | | */ |
15 | | } |
16 | | |
17 | | impl<W: io::Write + ?Sized> WriteBytesExt<u8> for W { |
18 | | #[inline(always)] |
19 | 0 | fn write_le(&mut self, n: u8) -> io::Result<()> { |
20 | 0 | self.write_all(&[n]) |
21 | 0 | } Unexecuted instantiation: <_ as gif::traits::WriteBytesExt<u8>>::write_le Unexecuted instantiation: <gif::encoder::Buf<17> as gif::traits::WriteBytesExt<u8>>::write_le Unexecuted instantiation: <gif::encoder::Buf<6> as gif::traits::WriteBytesExt<u8>>::write_le Unexecuted instantiation: <gif::encoder::Buf<10> as gif::traits::WriteBytesExt<u8>>::write_le Unexecuted instantiation: <gif::encoder::Buf<13> as gif::traits::WriteBytesExt<u8>>::write_le Unexecuted instantiation: <&mut std::io::cursor::Cursor<alloc::vec::Vec<u8>> as gif::traits::WriteBytesExt<u8>>::write_le |
22 | | } |
23 | | |
24 | | impl<W: io::Write + ?Sized> WriteBytesExt<u16> for W { |
25 | | #[inline] |
26 | 0 | fn write_le(&mut self, n: u16) -> io::Result<()> { |
27 | 0 | self.write_all(&[n as u8, (n >> 8) as u8]) |
28 | 0 | } Unexecuted instantiation: <_ as gif::traits::WriteBytesExt<u16>>::write_le Unexecuted instantiation: <gif::encoder::Buf<17> as gif::traits::WriteBytesExt<u16>>::write_le Unexecuted instantiation: <gif::encoder::Buf<6> as gif::traits::WriteBytesExt<u16>>::write_le Unexecuted instantiation: <gif::encoder::Buf<10> as gif::traits::WriteBytesExt<u16>>::write_le Unexecuted instantiation: <gif::encoder::Buf<13> as gif::traits::WriteBytesExt<u16>>::write_le |
29 | | } |
30 | | |
31 | | impl<W: io::Write + ?Sized> WriteBytesExt<u32> for W { |
32 | | #[inline] |
33 | 0 | fn write_le(&mut self, n: u32) -> io::Result<()> { |
34 | 0 | self.write_le(n as u16)?; |
35 | 0 | self.write_le((n >> 16) as u16) |
36 | 0 | } |
37 | | } |
38 | | |
39 | | impl<W: io::Write + ?Sized> WriteBytesExt<u64> for W { |
40 | | #[inline] |
41 | 0 | fn write_le(&mut self, n: u64) -> io::Result<()> { |
42 | 0 | self.write_le(n as u32)?; |
43 | 0 | self.write_le((n >> 32) as u32) |
44 | 0 | } |
45 | | } |