Line | Count | Source |
1 | | //! Input and output of images. |
2 | | |
3 | | use std::io; |
4 | | use std::io::Read as _; |
5 | | |
6 | | /// The decoder traits. |
7 | | pub(crate) mod decoder; |
8 | | /// The encoder traits. |
9 | | pub(crate) mod encoder; |
10 | | |
11 | | pub(crate) mod format; |
12 | | pub(crate) mod free_functions; |
13 | | pub(crate) mod image_reader_type; |
14 | | pub(crate) mod limits; |
15 | | |
16 | | #[deprecated(note = "this type has been moved and renamed to image::ImageReader")] |
17 | | /// Deprecated re-export of `ImageReader` as `Reader` |
18 | | pub type Reader<R> = ImageReader<R>; |
19 | | #[deprecated(note = "this type has been moved to image::Limits")] |
20 | | /// Deprecated re-export of `Limits` |
21 | | pub type Limits = limits::Limits; |
22 | | #[deprecated(note = "this type has been moved to image::LimitSupport")] |
23 | | /// Deprecated re-export of `LimitSupport` |
24 | | pub type LimitSupport = limits::LimitSupport; |
25 | | |
26 | | pub(crate) use self::image_reader_type::ImageReader; |
27 | | |
28 | | /// Adds `read_exact_vec` |
29 | | pub(crate) trait ReadExt { |
30 | | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()>; |
31 | | } |
32 | | |
33 | | impl<R: io::Read> ReadExt for R { |
34 | 170k | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()> { |
35 | 170k | let initial_len = vec.len(); |
36 | 170k | vec.try_reserve(len)?; |
37 | 170k | match self.take(len as u64).read_to_end(vec) { |
38 | 170k | Ok(read) if read == len => Ok(()), |
39 | 479 | fail => { |
40 | 479 | vec.truncate(initial_len); |
41 | 479 | Err(fail.err().unwrap_or(io::ErrorKind::UnexpectedEof.into())) |
42 | | } |
43 | | } |
44 | 170k | } Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Line | Count | Source | 34 | 153k | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()> { | 35 | 153k | let initial_len = vec.len(); | 36 | 153k | vec.try_reserve(len)?; | 37 | 153k | match self.take(len as u64).read_to_end(vec) { | 38 | 153k | Ok(read) if read == len => Ok(()), | 39 | 76 | fail => { | 40 | 76 | vec.truncate(initial_len); | 41 | 76 | Err(fail.err().unwrap_or(io::ErrorKind::UnexpectedEof.into())) | 42 | | } | 43 | | } | 44 | 153k | } |
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Line | Count | Source | 34 | 15.9k | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()> { | 35 | 15.9k | let initial_len = vec.len(); | 36 | 15.9k | vec.try_reserve(len)?; | 37 | 15.9k | match self.take(len as u64).read_to_end(vec) { | 38 | 15.9k | Ok(read) if read == len => Ok(()), | 39 | 63 | fail => { | 40 | 63 | vec.truncate(initial_len); | 41 | 63 | Err(fail.err().unwrap_or(io::ErrorKind::UnexpectedEof.into())) | 42 | | } | 43 | | } | 44 | 15.9k | } |
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Line | Count | Source | 34 | 823 | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()> { | 35 | 823 | let initial_len = vec.len(); | 36 | 823 | vec.try_reserve(len)?; | 37 | 823 | match self.take(len as u64).read_to_end(vec) { | 38 | 823 | Ok(read) if read == len => Ok(()), | 39 | 259 | fail => { | 40 | 259 | vec.truncate(initial_len); | 41 | 259 | Err(fail.err().unwrap_or(io::ErrorKind::UnexpectedEof.into())) | 42 | | } | 43 | | } | 44 | 823 | } |
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec <std::io::cursor::Cursor<&[u8]> as image::io::ReadExt>::read_exact_vec Line | Count | Source | 34 | 527 | fn read_exact_vec(&mut self, vec: &mut Vec<u8>, len: usize) -> io::Result<()> { | 35 | 527 | let initial_len = vec.len(); | 36 | 527 | vec.try_reserve(len)?; | 37 | 527 | match self.take(len as u64).read_to_end(vec) { | 38 | 527 | Ok(read) if read == len => Ok(()), | 39 | 81 | fail => { | 40 | 81 | vec.truncate(initial_len); | 41 | 81 | Err(fail.err().unwrap_or(io::ErrorKind::UnexpectedEof.into())) | 42 | | } | 43 | | } | 44 | 527 | } |
|
45 | | } |