| 1 | #![allow(dead_code)] |
| 2 | |
| 3 | use craterust-analyzer cargo zune-core 0.5.1 crate/::bytestreamrust-analyzer cargo zune-core 0.5.1 bytestream/::{ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#, ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#, ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#}; |
| 4 | /// Wraps an in memory buffer providing it with a `Seek` method |
| 5 | /// but works in `no_std` environments |
| 6 | /// |
| 7 | /// `std::io::Cursor` is available in std environments, but we also need support |
| 8 | /// for `no_std` environments so this serves as a drop in replacement |
| 9 | pub struct ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 10 | pub(craterust-analyzer cargo zune-core 0.5.1 crate/) streamrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#stream.: T, |
| 11 | pub(craterust-analyzer cargo zune-core 0.5.1 crate/) positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.: usize |
| 12 | } |
| 13 | |
| 14 | impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 15 | pub fn newrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]new().(buffer: T) -> ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 16 | ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor# { |
| 17 | streamrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#stream.: buffer, |
| 18 | positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.: 0 |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 24 | /// Move forward `num` bytes from |
| 25 | /// the current position. |
| 26 | /// |
| 27 | /// It doesn't check that position overflowed, new position |
| 28 | /// may point past the internal buffer, all subsequent reads will |
| 29 | /// either return an error or zero depending on the method called |
| 30 | #[inline] |
| 31 | pub fn skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]skip().(&mut self, num: usize) { |
| 32 | // Can this overflow ?? |
| 33 | self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]wrapping_add().(num); |
| 34 | } |
| 35 | /// Move back `num` bytes from the current position |
| 36 | /// |
| 37 | /// |
| 38 | /// This saturates at zero, it can never be negative or wraparound |
| 39 | /// when the value becomes too small |
| 40 | #[inline] |
| 41 | pub fn rewindrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]rewind().(&mut self, num: usize) { |
| 42 | self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(num); |
| 43 | } |
| 44 | |
| 45 | pub fn splitrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]split().(&self) -> (&[u8], &[u8]) { |
| 46 | let slice = 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().(); |
| 47 | let pos = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position..minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 48 | slice.split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at().(pos) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 53 | #[inline(always)] |
| 54 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_byte_no_error_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_byte_no_error_impl().(&mut self) -> u8 { |
| 55 | let byte = 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().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&0); |
| 56 | 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().1; |
| 57 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().byte |
| 58 | } |
| 59 | #[inline(always)] |
| 60 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_exact_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_exact_bytes_impl().(&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#> { |
| 61 | 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().; |
| 62 | if bytes_read rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 63 | // restore read to initial position it was in. |
| 64 | self.rewindrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]rewind().(bytes_read); |
| 65 | // not all bytes were read. |
| 66 | 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().())); |
| 67 | } |
| 68 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 69 | } |
| 70 | |
| 71 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_const_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_const_bytes_impl().<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#> { |
| 72 | if 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][`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().N rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().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().() { |
| 73 | // we are in bounds |
| 74 | let reference = 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().(); |
| 75 | let position = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.; |
| 76 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(buf_ref) = reference.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(position..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#position 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().N) { |
| 77 | 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().N; |
| 78 | buf.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(buf_ref); |
| 79 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 80 | } |
| 81 | } |
| 82 | 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#::Genericrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#Generic#("Cannot satisfy read")) |
| 83 | } |
| 84 | |
| 85 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_const_bytes_no_error_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_const_bytes_no_error_impl().<const N: usize>(&mut self, buf: &mut [u8; N]) { |
| 86 | if 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][`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().N rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().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().() { |
| 87 | // we are in bounds |
| 88 | let reference = 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().(); |
| 89 | let position = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.; |
| 90 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(buf_ref) = reference.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(position..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#position 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().N) { |
| 91 | 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().N; |
| 92 | buf.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(buf_ref); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | #[inline(always)] |
| 98 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_bytes_impl().(&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#> { |
| 99 | let len = self.peek_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]peek_bytes_impl().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 100 | self.skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]skip().(len); |
| 101 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len) |
| 102 | } |
| 103 | |
| 104 | #[inline(always)] |
| 105 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn peek_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]peek_bytes_impl().(&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#> { |
| 106 | let stream_end = 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().(); |
| 107 | |
| 108 | let start = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position., stream_end); |
| 109 | let end = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(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][`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().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), stream_end); |
| 110 | |
| 111 | let slice = 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().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 112 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#slice.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 ops/index/IndexMut#index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(slice); |
| 113 | let len = slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 114 | |
| 115 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len) |
| 116 | } |
| 117 | |
| 118 | #[inline(always)] |
| 119 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn peek_exact_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]peek_exact_bytes_impl().(&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#> { |
| 120 | self.read_exact_bytes_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_exact_bytes_impl().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 121 | self.rewindrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]rewind().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 122 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 123 | } |
| 124 | |
| 125 | #[inline(always)] |
| 126 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn z_seek_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]z_seek_impl().(&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#> { |
| 127 | let (base_pos, offset) = match from { |
| 128 | ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#::Startrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#Start#(n) => { |
| 129 | self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = n as usize; |
| 130 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n); |
| 131 | } |
| 132 | ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#::Endrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#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), |
| 133 | ZSeekFromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#::Currentrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZSeekFrom#Current#(n) => (self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position., n as isize) |
| 134 | }; |
| 135 | match base_pos.checked_add_signedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add_signed().(offset) { |
| 136 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) => { |
| 137 | self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position. = n; |
| 138 | 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) |
| 139 | } |
| 140 | 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#(ZByteIoErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#::SeekErrorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#SeekError#("Negative seek")) |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | #[inline(always)] |
| 145 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn is_eof_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]is_eof_impl().(&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#> { |
| 146 | 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. 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().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().()) |
| 147 | } |
| 148 | #[inline(always)] |
| 149 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn z_position_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]z_position_impl().(&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#> { |
| 150 | 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) |
| 151 | } |
| 152 | |
| 153 | pub (craterust-analyzer cargo zune-core 0.5.1 crate/) fn read_remaining_implrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]read_remaining_impl().(&mut self, sink: &mut allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::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#> { |
| 154 | let start = self.positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#position.; |
| 155 | let end = 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().(); |
| 156 | match 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().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end) { |
| 157 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 158 | 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#::Genericrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZByteIoError#Generic#( |
| 159 | "Somehow read remaining couldn't satisfy it's invariants" |
| 160 | )) |
| 161 | } |
| 162 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e) => { |
| 163 | sink.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(e); |
| 164 | } |
| 165 | } |
| 166 | self.skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]skip().(end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().start); |
| 167 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().start) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | impl<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]>> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<T> for ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#<T> { |
| 172 | fn fromrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`][`From<T>`]from().(value: T) -> Selfrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`][`From<T>`] { |
| 173 | ZCursorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/ZCursor#::newrust-analyzer cargo zune-core 0.5.1 bytestream/reader/no_std_readers/impl#[`ZCursor<T>`]new().(value) |
| 174 | } |
| 175 | } |