Debian Codegraph @

src/decoder/tag_reader.rs

raw symbols SCIP
1 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/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#};
2
3 use craterust-analyzer cargo tiff 0.11.3 crate/::{
4 tagsrust-analyzer cargo tiff 0.11.3 tags/::{Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#},
5 Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#, TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#, TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#, TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#,
6 };
7
8 use superrust-analyzer cargo tiff 0.11.3 decoder/::ifdrust-analyzer cargo tiff 0.11.3 decoder/ifd/::{Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, Valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/Value#};
9 use superrust-analyzer cargo tiff 0.11.3 decoder/::ValueReaderrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#;
10
11 pub(craterust-analyzer cargo tiff 0.11.3 crate/) struct TagReaderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#<'lt, R: EntryDecoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> {
12 pub(craterust-analyzer cargo tiff 0.11.3 crate/) decoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#decoder.: &'lt mut R,
13 pub(craterust-analyzer cargo tiff 0.11.3 crate/) ifdrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#ifd.: &'lt Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#,
14 }
15
16 pub(craterust-analyzer cargo tiff 0.11.3 crate/) trait EntryDecoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder# {
17 /// Turn an entry into a value by fetching the required bytes in the stream.
18 fn entry_valrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_val().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/Value#>;
19 /// Fill a `ValueBuffer` by fetching the required bytes.
20 fn entry_bufrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_buf().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, _: &mut ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<()>;
21 /// Fill the prefix of the buffer and return the actual bytes. Start interpreting the inner
22 /// value at `offset`.
23 fn entry_rawrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_raw().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, _: &mut [u8], offset: u64) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<usize>;
24 }
25
26 impl<R: Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek# + Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> EntryDecoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder# for ValueReaderrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#<R> {
27 fn entry_valrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`ValueReader<R>`][EntryDecoder]entry_val().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/Value#> {
28 entry.valrust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]val().(&self.limitsrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#limits., self.bigtiffrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#bigtiff., &mut self.readerrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#reader.)
29 }
30
31 fn entry_bufrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`ValueReader<R>`][EntryDecoder]entry_buf().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, buf: &mut ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<()> {
32 entry.buffered_valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]buffered_value().(buf, &self.limitsrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#limits., self.bigtiffrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#bigtiff., &mut self.readerrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#reader.)
33 }
34
35 fn entry_rawrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`ValueReader<R>`][EntryDecoder]entry_raw().(&mut self, entry: &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, buf: &mut [u8], offset: u64) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<usize> {
36 entry.raw_value_atrust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]raw_value_at().(buf, self.bigtiffrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#bigtiff., &mut self.readerrust-analyzer cargo tiff 0.11.3 decoder/ValueReader#reader., offset)
37 }
38 }
39
40 impl<'a, R: EntryDecoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> TagReaderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#<'a, R> {
41 pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn find_tagrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag().(&mut self, tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/Value#>> {
42 let entry = match self.ifdrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#ifd..getrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]get().(tag) {
43 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
44 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) => entry.clonerust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry][Clone]clone().(),
45 };
46
47 self.decoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#decoder..entry_valrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_val().(&entry).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#)
48 }
49
50 /// Find a tag and fill the provided buffer with its raw data.
51 ///
52 /// Returns the entry of the tag if found. This signals that the buffer was overwritten.
53 /// Otherwise the buffer is preserved as-is.
54 pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn find_tag_bufrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag_buf().(
55 &mut self,
56 tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#,
57 buf: &mut ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#,
58 ) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#>> {
59 let entry = match self.ifdrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#ifd..getrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]get().(tag) {
60 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
61 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) => entry.clonerust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry][Clone]clone().(),
62 };
63
64 self.decoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#decoder..entry_bufrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_buf().(&entry, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
65 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry))
66 }
67
68 pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn find_tag_rawrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag_raw().(
69 &mut self,
70 tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#,
71 buf: &mut [u8],
72 at: u64,
73 ) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>> {
74 let entry = match self.ifdrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#ifd..getrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]get().(tag) {
75 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
76 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) => entry.clonerust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry][Clone]clone().(),
77 };
78
79 let len = self.decoderrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/TagReader#decoder..entry_rawrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/EntryDecoder#entry_raw().(&entry, buf, at)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
80 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
81 }
82
83 pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn require_tagrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]require_tag().(&mut self, tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Valuerust-analyzer cargo tiff 0.11.3 decoder/ifd/Value#> {
84 match self.find_tagrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag().(tag)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
85 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(val),
86 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::FormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#FormatError#(
87 TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#::RequiredTagNotFoundrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#RequiredTagNotFound#(tag),
88 )),
89 }
90 }
91
92 pub fn find_tag_uint_vecrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag_uint_vec().<T: TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<u64>>(&mut self, tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#) -> TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>>> {
93 self.find_tagrust-analyzer cargo tiff 0.11.3 decoder/tag_reader/impl#[`TagReader<'a, R>`]find_tag().(tag)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
94 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| v.into_u64_vecrust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Value]into_u64_vec().())
95 .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
96 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| {
97 v.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
98 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|u| {
99 T::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#try_from().(u).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| TiffFormatErrorrust-analyzer cargo tiff 0.11.3 error/TiffFormatError#::InvalidTagValueTyperust-analyzer cargo tiff 0.11.3 error/TiffFormatError#InvalidTagValueType#(tag).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
100 })
101 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
102 })
103 .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()
104 }
105 }