Debian Codegraph @

src/bytestream/reader/std_readers.rs

raw symbols SCIP
1 #![cfg(feature = "std")]
2
3 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/;
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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#;
5
6 use craterust-analyzer cargo zune-core 0.5.1 crate/::bytestreamrust-analyzer cargo zune-core 0.5.1 bytestream/::readerrust-analyzer cargo zune-core 0.5.1 bytestream/reader/::{ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#, ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#};
7 use craterust-analyzer cargo zune-core 0.5.1 crate/::bytestreamrust-analyzer cargo zune-core 0.5.1 bytestream/::{ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#, ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#};
8 // note (cae): If Rust ever stabilizes trait specialization, specialize this for Cursor
9 impl<T: 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# + iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#> ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait# for T {
10 #[inline(always)]
11 fn read_byte_no_errorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_byte_no_error().(&mut self) -> u8 {
12 let mut buf = [0];
13 let _ = self.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(&mut buf);
14 buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().
15 }
16 #[inline(always)]
17 fn read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_exact_bytes().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
18 let mut bytes_read = 0;
19
20 while bytes_read rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
21 match self.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().bytes_read..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().) {
22 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0) => {
23 // if a read returns zero bytes read, it means it encountered an EOF so we seek
24 // back to where we started because some paths may aggressively read forward and
25 // ZCursor maintains the position.
26
27 // NB: (cae) [tag=perf] This adds a branch on every read, and will slow down every function
28 // resting on it. Sorry
29 self.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#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().(bytes_read as i64)))
30 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
31 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::NotEnoughBytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#NotEnoughBytes#(bytes_read, buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()));
32 }
33 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes) => {
34 bytes_read rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().bytes;
35 }
36 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().(e))
37 }
38 }
39
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
41 }
42
43 #[inline]
44 fn read_const_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_const_bytes().<const N: usize>(&mut self, buf: &mut [u8; N]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
45 self.read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_exact_bytes().(buf)
46 }
47
48 fn read_const_bytes_no_errorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_const_bytes_no_error().<const N: usize>(&mut self, buf: &mut [u8; N]) {
49 let _ = self.read_const_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_const_bytes().(buf);
50 }
51
52 #[inline(always)]
53 fn read_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_bytes().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
54 self.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)
55 }
56
57 #[inline(always)]
58 fn peek_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]peek_bytes().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
59 // first read bytes to the buffer
60 let bytes_read = self.read_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_bytes().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
61 let converted = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().i64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i64][`TryFrom<usize>`]try_from().(bytes_read).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::num::TryFromIntError>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
62 self.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(converted))
63 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
64
65 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes_read)
66 }
67
68 #[inline(always)]
69 fn peek_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]peek_exact_bytes().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
70 // first read bytes to the buffer
71 self.read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_exact_bytes().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
72 let converted = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().i64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i64][`TryFrom<usize>`]try_from().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::num::TryFromIntError>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
73 self.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(converted))
74 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
75
76 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
77 }
78
79 #[inline(always)]
80 fn z_seekrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]z_seek().(&mut self, from: ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u64, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
81 self.seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(from.to_std_seekrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZSeekFrom]to_std_seek().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)
82 }
83
84 #[inline(always)]
85 fn is_eofrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]is_eof().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
86 self.fill_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#fill_buf().()
87 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|b| b.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().())
88 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)
89 }
90
91 #[inline(always)]
92 fn z_positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]z_position().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u64, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
93 self.stream_positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#stream_position().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)
94 }
95
96 #[inline(always)]
97 fn read_remainingrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[T][ZByteReaderTrait]read_remaining().(&mut self, sink: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#> {
98 self.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(sink).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[ZByteIoError][`From<std::io::Error>`]from().)
99 }
100 }
101
102 impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> 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# for ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> {
103 fn readrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[`ZCursor<T>`][Read]read().(&mut self, buf: &mut [u8]) -> 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/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
104 self.read_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_bytes_impl().(buf)
105 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| 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#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", e)))
106 }
107 }
108
109 impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> 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# for ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> {
110 fn fill_bufrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[`ZCursor<T>`][BufRead]fill_buf().(&mut self) -> 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/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&[u8]> {
111 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#::splitrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]split().(self).1)
112 }
113
114 fn consumerust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[`ZCursor<T>`][BufRead]consume().(&mut self, amount: usize) {
115 self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().amount;
116 }
117 }
118
119 impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> 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/::Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek# for ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> {
120 fn seekrust-analyzer cargo zune-core 0.5.1 bytestream/reader/std_readers/impl#[`ZCursor<T>`][Seek]seek().(&mut self, pos: 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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#) -> 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/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<u64> {
121 let (base_pos, offset) = match pos {
122 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/::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#(n) => {
123 self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = n as usize;
124 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n);
125 }
126 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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#End#(n) => (self.streamrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#stream..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), n as isize),
127 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/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(n) => (self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position., n as isize)
128 };
129 match base_pos.checked_add_signedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add_signed().(offset) {
130 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) => {
131 self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = n;
132 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. as u64)
133 }
134 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#(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().(
135 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#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#,
136 "Negative seek"
137 ))
138 }
139 }
140 }