| 1 | use craterust-analyzer cargo imagesize 0.13.0 crate/::utilrust-analyzer cargo imagesize 0.13.0 util/::*; |
| 2 | use craterust-analyzer cargo imagesize 0.13.0 crate/::{ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#, ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#}; |
| 3 | |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#}; |
| 5 | |
| 6 | pub fn sizerust-analyzer cargo imagesize 0.13.0 formats/webp/size().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(reader: &mut R) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#> { |
| 7 | let mut buffer = [0; 4]; |
| 8 | reader.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut buffer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 9 | |
| 10 | if buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b' ' { |
| 11 | webp_vp8_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8_size().(reader) |
| 12 | } else if buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'L' { |
| 13 | webp_vp8l_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8l_size().(reader) |
| 14 | } else if buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'X' { |
| 15 | webp_vp8x_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8x_size().(reader) |
| 16 | } else { |
| 17 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidDatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidData#, "Invalid VP8 Tag").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | pub fn matchesrust-analyzer cargo imagesize 0.13.0 formats/webp/matches().(header: &[u8]) -> bool { |
| 22 | header.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().12 && &header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b"RIFF" && &header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#12]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b"WEBP" |
| 23 | } |
| 24 | |
| 25 | fn webp_vp8x_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8x_size().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(reader: &mut R) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#> { |
| 26 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(0x18))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 27 | |
| 28 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize# { |
| 29 | widthrust-analyzer cargo imagesize 0.13.0 ImageSize#width.: read_u24rust-analyzer cargo imagesize 0.13.0 util/read_u24().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, |
| 30 | heightrust-analyzer cargo imagesize 0.13.0 ImageSize#height.: read_u24rust-analyzer cargo imagesize 0.13.0 util/read_u24().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, |
| 31 | }) |
| 32 | } |
| 33 | |
| 34 | fn webp_vp8l_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8l_size().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(reader: &mut R) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#> { |
| 35 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(0x15))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 36 | |
| 37 | let dims = read_u32rust-analyzer cargo imagesize 0.13.0 util/read_u32().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 38 | |
| 39 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize# { |
| 40 | widthrust-analyzer cargo imagesize 0.13.0 ImageSize#width.: (dims rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x3FFF) as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, |
| 41 | heightrust-analyzer cargo imagesize 0.13.0 ImageSize#height.: ((dims rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().14) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x3FFF) as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, |
| 42 | }) |
| 43 | } |
| 44 | |
| 45 | fn webp_vp8_sizerust-analyzer cargo imagesize 0.13.0 formats/webp/webp_vp8_size().<R: BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>(reader: &mut R) -> ImageResultrust-analyzer cargo imagesize 0.13.0 ImageResult#<ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize#> { |
| 46 | reader.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(0x1A))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 47 | |
| 48 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImageSizerust-analyzer cargo imagesize 0.13.0 ImageSize# { |
| 49 | widthrust-analyzer cargo imagesize 0.13.0 ImageSize#width.: read_u16rust-analyzer cargo imagesize 0.13.0 util/read_u16().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize, |
| 50 | heightrust-analyzer cargo imagesize 0.13.0 ImageSize#height.: read_u16rust-analyzer cargo imagesize 0.13.0 util/read_u16().(reader, &Endianrust-analyzer cargo imagesize 0.13.0 util/Endian#::Littlerust-analyzer cargo imagesize 0.13.0 util/Endian#Little#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as usize, |
| 51 | }) |
| 52 | } |