Debian Codegraph @

src/buf.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::{copy_nonoverlappingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/copy_nonoverlapping()., copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/copy().};
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#, IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#, RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#, RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#, RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#};
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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()., maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().};
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/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#};
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#};
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().;
7
8 use range::RangeArgument;
9
10 const READ_MINrust-analyzer cargo netbuf 0.4.1 buf/READ_MIN.: usize = 4096;
11 const ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.: usize = 16384;
12
13 ///
14 /// A buffer object to be used for reading from network
15 ///
16 /// Assumptions:
17 ///
18 /// 1. Buffer needs to be growable as sometimes requests are large
19 ///
20 /// 2. Buffer should deallocate when empty as
21 /// most of the time connections are idle
22 ///
23 /// a. Deallocations are cheap as we have a cool memory allocator
24 /// (jemalloc)
25 ///
26 /// b. First allocation should be big (i.e. kilobytes not few bytes)
27 ///
28 /// 3. Should be easy to peek and get a slice as it makes packet parsing easy
29 ///
30 /// 4. Cheap removing bytes at the start of the buf
31 ///
32 pub struct Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
33 datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]>>,
34 consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed.: usize,
35 remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining.: usize,
36 }
37
38
39 // TODO(tailhook) use std::slice::bytes::copy_memory;
40 fn copy_memoryrust-analyzer cargo netbuf 0.4.1 buf/copy_memory().(src: &[u8], dst: &mut [u8]) {
41 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() == dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
42 unsafe {
43 copy_nonoverlappingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/copy_nonoverlapping().(src.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), dst.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
44 }
45 }
46
47
48 impl Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
49 /// Create empty buffer. It has no preallocated size. The underlying memory
50 /// chunk is always deallocated when there are no useful bytes in the
51 /// buffer.
52 pub fn newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().() -> Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
53 Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
54 datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
55 consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed.: 0,
56 remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining.: 0,
57 }
58 }
59 fn reserverust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve().(&mut self, bytes: usize) {
60 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|slice| {
61 let old_cap = slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
62 let old_bytes = old_cap 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().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
63
64 if self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { // let's allocate new slice and move
65 let min_size = old_bytes 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().bytes;
66
67 let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(min_size, old_cap.saturating_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_mul().(2)));
68 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
69 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
70 copy_memoryrust-analyzer cargo netbuf 0.4.1 buf/copy_memory().(&slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#old_cap 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
71 &mut vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#old_bytes]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().);
72 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap 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().old_bytes;
73 self.consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed. = 0;
74 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
75 } else { // just reallocate
76 let mut vec = slice.into_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]into_vec().();
77 vec.reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve().(bytes);
78 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
79 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
80 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap 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().old_bytes;
81 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
82 }
83 }).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| {
84 let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(bytes, ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.));
85 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
86 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
87
88 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap;
89 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
90 })
91 }
92 fn reserve_exactrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve_exact().(&mut self, bytes: usize) {
93 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|slice| {
94 let old_cap = slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
95 let old_bytes = old_cap 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().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
96
97 if self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { // let's allocate new slice and move
98 let size = old_bytes 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().bytes;
99 let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(size);
100 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
101 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
102 copy_memoryrust-analyzer cargo netbuf 0.4.1 buf/copy_memory().(&slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#old_cap 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
103 &mut vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#old_bytes]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().);
104 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap 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().old_bytes;
105 self.consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed. = 0;
106 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
107 } else { // just reallocate
108 let mut vec = slice.into_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]into_vec().();
109 vec.reserve_exactrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve_exact().(bytes);
110 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
111 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
112 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap 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().old_bytes;
113 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
114 }
115 }).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| {
116 let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(bytes);
117 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
118 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(cap) };
119
120 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. = cap;
121 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vec.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())
122 })
123 }
124 fn remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().(&self) -> usize {
125 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. as usize
126 }
127 fn consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(&self) -> usize {
128 self.consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed. as usize
129 }
130
131 /// Mark the first `bytes` of the buffer as read. Basically it's shaving
132 /// off bytes from the buffer, but does it efficiently. When there are
133 /// no more bytes in the buffer it's deallocated.
134 ///
135 /// Note: Buffer currently doesn't shrink when calling this method. It's
136 /// assumed that all bytes will be consumed shortly. In case you're
137 /// appending to the buffer after consume, old data is discarded.
138 ///
139 /// # Panics
140 ///
141 /// Panics if `bytes` is larger than current length of buffer
142 pub fn consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(&mut self, bytes: usize) {
143 let ln = self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().();
144 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(bytes <= ln);
145 if bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().ln {
146 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
147 } else {
148 self.consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed. 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;
149 }
150 }
151
152 /// Allows removing an arbitrary range of bytes
153 ///
154 /// A more comprehensive version of `consume()`. It's occasionally useful
155 /// if your data is in frames/chunks but you want to buffer the whole body
156 /// anyway. E.g. in http chunked encoding you have each chunk prefixed by
157 /// its length, but that doesn't mean you can't buffer the whole request
158 /// into memory. This method allows you to continue reading the next chunk
159 /// into the same buffer while removing the chunk length.
160 ///
161 /// Note: it's not super efficient, as it requires to move (copy) bytes
162 /// after the range, in case range is neither at the start nor at the
163 /// end of buffer. Still it should be faster than copying everything
164 /// to yet another buffer.
165 ///
166 /// We never shrink the buffer here (except when it becomes empty, to
167 /// keep this invariant), assuming that you will receive more data into
168 /// the buffer shortly.
169 ///
170 /// The `RangeArgument` type is a temporary type until rust provides
171 /// the one in standard library, you should use the range syntax directly:
172 ///
173 /// ```ignore
174 /// buf.remove_range(5..7)
175 /// ```
176 ///
177 /// # Panics
178 ///
179 /// Panics if range is invalid for the buffer
180 pub fn remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().<R: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<RangeArgumentrust-analyzer cargo netbuf 0.4.1 range/RangeArgument#>>(&mut self, range: R) {
181 use range::RangeArgument::*;
182 match range.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() {
183 RangeTorust-analyzer cargo netbuf 0.4.1 range/RangeArgument#RangeTo#(x) | Rangerust-analyzer cargo netbuf 0.4.1 range/RangeArgument#Range#(0, x) => self.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(x),
184 RangeFromrust-analyzer cargo netbuf 0.4.1 range/RangeArgument#RangeFrom#(0) => *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().(),
185 RangeFromrust-analyzer cargo netbuf 0.4.1 range/RangeArgument#RangeFrom#(x) => {
186 let ln = self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().();
187 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(x <= ln);
188 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. 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().ln 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().x;
189 }
190 Rangerust-analyzer cargo netbuf 0.4.1 range/RangeArgument#Range#(x, y) => {
191 let ln = self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().();
192 if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().y { return; }
193 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(x <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). y);
194 let removed_bytes = y 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().x;
195 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(y <= ln);
196 let start = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().x;
197 let end = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().y;
198 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref mut data) = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. {
199 let dlen = data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
200 unsafe {
201 copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/copy().(data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().end..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/Index#index()..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(),
202 data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#dlen 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().removed_bytes]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(),
203 dlen 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().end);
204 }
205 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. 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().removed_bytes;
206 } else {
207 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Not-existent buffere where data exists");
208 }
209 }
210 }
211 }
212
213
214 /// Capacity of the buffer. I.e. the bytes it is allocated for. Use for
215 /// debugging or for calculating memory usage. Note it's not guaranteed
216 /// that you can write `buf.capacity() - buf.len()` bytes without resize
217 pub fn capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(&self) -> usize {
218 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| x.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0)
219 }
220
221 /// Number of useful bytes in the buffer
222 pub fn lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(&self) -> usize {
223 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
224 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| x.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/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().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().())
225 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0)
226 }
227
228 /// If buffer is empty. Potentially a little bit faster than
229 /// getting `len()`
230 pub fn is_emptyrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]is_empty().(&self) -> bool {
231 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()
232 }
233
234 fn future_slicerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]future_slice().<'x>(&'x mut self) -> &'x mut [u8] {
235 let rem = self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
236 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().()
237 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| {
238 let upto = x.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
239 &mut x[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().upto 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().rem rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#upto]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
240 })
241 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
242 }
243
244 /// Extend buffer. Note unlike `Write::write()` and `read_from()` this
245 /// method reserves as small as possible a chunk of memory. So it's
246 /// inefficien to grow with this method. You may use the Write trait to
247 /// grow incrementally.
248 pub fn extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(&mut self, buf: &[u8]) {
249 if buf.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][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { return; }
250 if self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().() 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().() {
251 self.reserve_exactrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve_exact().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
252 }
253 copy_memoryrust-analyzer cargo netbuf 0.4.1 buf/copy_memory().(buf, &mut self.future_slicerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]future_slice().()[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#buf.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().);
254 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
255 }
256
257 /// Read some bytes from stream (object implementing `Read`) into buffer
258 ///
259 /// Note this does *not* continue to read until getting `WouldBlock`. It
260 /// passes all errors as is. It preallocates some chunk to read into
261 /// buffer. It may be possible that the stream still has bytes buffered
262 /// after this method returns. This method is expected either to be called
263 /// until `WouldBlock` is returned or is used with level-triggered polling.
264 pub fn read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().<R:Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(&mut self, stream: &mut R) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
265 if self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().() 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().READ_MINrust-analyzer cargo netbuf 0.4.1 buf/READ_MIN. {
266 self.reserverust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve().(READ_MINrust-analyzer cargo netbuf 0.4.1 buf/READ_MIN.);
267 }
268 let bytes = match stream.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(self.future_slicerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]future_slice().()) {
269 res @ Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0) | res @ Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
270 self.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(0);
271 return res;
272 }
273 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(x) => x,
274 };
275 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(bytes <= self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().());
276 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().bytes;
277 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes)
278 }
279
280 /// Reads no more than max bytes into buffer and returns boolean flag
281 /// of whether max bytes are reached
282 ///
283 /// Except for the limit on number of bytes and slightly different
284 /// allocation strategy, this method has the same considerations as
285 /// read_from
286 ///
287 /// Note this method might be used for two purposes:
288 ///
289 /// 1. Limit number of bytes buffered until parser can process data
290 /// (for example HTTP header size, which is number of bytes read before
291 /// `\r\n\r\n` delimiter reached)
292 /// 2. Wait until exact number of bytes are fully received
293 ///
294 /// Since we support (1) we don't preallocate buffer for exact size of
295 /// the `max` value. It also helps a little in case (2) for minimizing
296 /// DDoS attack vector. If that doesn't suit you, you may wish to use
297 /// `Vec::with_capacity()` for the purpose of (2).
298 ///
299 /// On the contrary we don't overallocate more than `max` bytes, so if
300 /// you expect data to go after exact number of bytes read, it might be
301 /// better to use `read_from()` and check buffer length.
302 ///
303 pub fn read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().<R:Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(&mut self, max: usize, stream: &mut R)
304 -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool>
305 {
306 let todo = max.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
307 if todo rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
308 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
309 }
310 if self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().() 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().READ_MINrust-analyzer cargo netbuf 0.4.1 buf/READ_MIN. {
311 if self.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().().saturating_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_mul().(2) 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().max {
312 // TODO is too large we may never need so big buffer
313 self.reserverust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve().(READ_MINrust-analyzer cargo netbuf 0.4.1 buf/READ_MIN.);
314 } else {
315 self.reserve_exactrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve_exact().(todo);
316 }
317 }
318 let res = {
319 let slc = self.future_slicerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]future_slice().();
320 let do_now = minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(slc.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), todo);
321 stream.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(&mut slc[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#do_now]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().)
322 };
323 let bytes = match res {
324 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0) => {
325 self.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(0);
326 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false);
327 }
328 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => {
329 self.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(0);
330 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e);
331 }
332 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(x) => x,
333 };
334 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(bytes <= self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().());
335 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().bytes;
336 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]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().max)
337 }
338
339 /// Write contents of buffer to the stream (object implementing
340 /// the Write trait). We assume that stream is non-blocking, use
341 /// `Write::write` (instead of `Write::write_all`) and return all errors
342 /// to the caller (including `WouldBlock` or `Interrupted`).
343 ///
344 /// In addition to returning the number of bytes written, it also
345 /// `consume()`s those bytes from the buffer, so it's safe to retry calling
346 /// the method at any moment. Also it's a common pattern to append more
347 /// data to the buffer between calls.
348 pub fn write_torust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]write_to().<W:Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&mut self, sock: &mut W) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
349 let bytes = match sock.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write().(&self[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 ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) {
350 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes) => bytes,
351 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#(e),
352 };
353 self.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(bytes);
354 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes)
355 }
356
357 /// Splits buffer into two at the given index.
358 ///
359 /// `self` contains bytes `[0, at)` and the returned `Buf` contains
360 /// bytes `[at, len)`.
361 ///
362 /// Reallocates smaller part of buffer.
363 ///
364 /// # Panics
365 ///
366 /// Panics if at > len.
367 ///
368 /// # Examples
369 /// ```rust
370 /// let mut buf = netbuf::Buf::new();
371 /// buf.extend(b"Hello World!");
372 /// let tail = buf.split_off(6);
373 /// assert_eq!(&buf[..], b"Hello ");
374 /// assert_eq!(&tail[..], b"World!");
375 /// ```
376 pub fn split_offrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]split_off().(&mut self, at: usize) -> Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
377 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(at <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
378 let mut tail = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
379 match self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| x.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/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().at rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().at) {
380 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) => { // re-allocate self;
381 swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut tail, self);
382 if at rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
383 self.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(&tail[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#at]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index().);
384 tail.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(at);
385 }
386 },
387 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(false) => { // allocate for tail;
388 tail.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(&self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().at..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/Index#index().);
389 self.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(at..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#);
390 },
391 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {}
392 }
393 tail
394 }
395
396 /// Returns the byte at the index, or `None` if the index is
397 /// out of bounds.
398 pub fn getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> {
399 if index 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.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().() {
400 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
401 }
402 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
403 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref data) = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. {
404 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().consumed 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().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
405 } else {
406 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
407 }
408 }
409
410 /// Returns a mutable reference to the byte at the index, or
411 /// `None` if the index is out of bounds.
412 pub fn get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(&mut self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut u8> {
413 if index 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.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().() {
414 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
415 }
416 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
417 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref mut data) = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. {
418 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed 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().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().)
419 } else {
420 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
421 }
422 }
423
424 }
425
426
427 impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
428 fn fmtrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
429 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Buf {{ len={}; consumed={}; remaining={} }}",
430 self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(), self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().())
431 }
432 }
433
434 impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
435 fn as_refrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`AsRef<[u8]>`]as_ref().(&self) -> &[u8] {
436 &self[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 ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
437 }
438 }
439
440 impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
441 fn intorust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Into<Vec<u8>>`]into().(mut self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
442 if self.consumedrust-analyzer cargo netbuf 0.4.1 buf/Buf#consumed. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
443 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|slice| {
444 let mut vec = slice.into_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]into_vec().();
445 if self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
446 let nlen = vec.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
447 unsafe { vec.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(nlen) };
448 }
449 vec
450 }).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().)
451 } else {
452 self[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()
453 }
454 }
455 }
456
457 impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<usize> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
458 type Outputrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]Output# = u8;
459 fn indexrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().<'x>(&'x self, index: usize) -> &'x u8 {
460 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref data) = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. {
461 return &data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
462 }
463 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("cannot index empty buffer");
464
465 }
466 }
467
468 impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
469 type Outputrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]Output# = [u8];
470 fn indexrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index().<'x>(&'x self, _idx: RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#) -> &'x[u8] {
471 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
472 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| &x[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#x.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/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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
473 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(b"")
474 }
475 }
476
477 impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
478 type Outputrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]Output# = [u8];
479 fn indexrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index().<'x>(&'x self, slice: RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize>) -> &'x[u8] {
480 let idx = slice.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end.;
481 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
482 return b"";
483 }
484 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(idx <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
485 &self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
486 }
487 }
488
489 impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
490 type Outputrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]Output# = [u8];
491 fn indexrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().<'x>(&'x self, slice: RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize>) -> &'x[u8] {
492 let idx = slice.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#start.;
493 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().() {
494 return b"";
495 }
496 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(idx <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
497 let buf = &self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
498 &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#buf.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/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().self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
499 }
500 }
501
502 impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
503 type Outputrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]Output# = [u8];
504 fn indexrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().<'x>(&'x self, slice: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>) -> &'x[u8] {
505 let start = slice.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.;
506 let end = slice.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.;
507 if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
508 return b"";
509 }
510 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(end <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
511 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(start <= end);
512 let buf = &self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
513 &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().() 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().end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
514 }
515 }
516
517 impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<usize> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
518 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().<'x>(&'x mut self, index: usize) -> &'x mut u8 {
519 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
520 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref mut data) = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data. {
521 return &mut data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed 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().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
522 }
523 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("cannot index empty buffer");
524 }
525 }
526
527 impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
528 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFull>`]index_mut().<'x>(&'x mut self, _idx: RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#) -> &'x mut[u8] {
529 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
530 let remaining = self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
531 self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().()
532 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| {
533 let len = x.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
534 &mut x[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len 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().remaining]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
535 })
536 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&mut [])
537 }
538 }
539
540 impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
541 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeTo<usize>>`]index_mut().<'x>(&'x mut self, slice: RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize>) -> &'x mut[u8] {
542 let idx = slice.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end.;
543 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
544 return &mut [];
545 }
546 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(idx <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
547 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
548 &mut self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#consumed 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().idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
549 }
550 }
551
552 impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
553 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFrom<usize>>`]index_mut().<'x>(&'x mut self, slice: RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize>) -> &'x mut[u8] {
554 let idx = slice.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#start.;
555 if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().() {
556 return &mut [];
557 }
558 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(idx <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
559 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
560 let remaining = self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().();
561 let buf = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
562 let len = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
563 &mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed 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().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len 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().remaining]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
564 }
565 }
566
567 impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>> for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
568 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<Range<usize>>`]index_mut().<'x>(&'x mut self, slice: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>) -> &'x mut[u8] {
569 let start = slice.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.;
570 let end = slice.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.;
571 if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
572 return &mut [];
573 }
574 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(end <= self.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
575 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(start <= end);
576 let consumed = self.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().();
577 let buf = self.datarust-analyzer cargo netbuf 0.4.1 buf/Buf#data..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
578 &mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().consumed 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().start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#consumed 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().end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().
579 }
580 }
581
582 impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
583 fn writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(&mut self, buf: &[u8]) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
584 if buf.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][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
585 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0);
586 }
587 if self.remainingrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remaining().() 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().() {
588 self.reserverust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
589 }
590 copy_memoryrust-analyzer cargo netbuf 0.4.1 buf/copy_memory().(buf, &mut self.future_slicerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]future_slice().()[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#buf.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().);
591 self.remainingrust-analyzer cargo netbuf 0.4.1 buf/Buf#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
592 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())
593 }
594 fn flushrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]flush().(&mut self) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) }
595 }
596
597 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf# {
598 fn defaultrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Default]default().() -> Selfrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Default] {
599 Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().()
600 }
601 }
602
603 #[cfg(test)]
604 mod testrust-analyzer cargo netbuf 0.4.1 buf/test/ {
605 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().;
606 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/::{selfrust-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#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#};
607 use superrust-analyzer cargo netbuf 0.4.1 buf/::Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#;
608 use superrust-analyzer cargo netbuf 0.4.1 buf/::ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.;
609 use mockstreamrust-analyzer cargo mockstream 0.0.2 crate/::SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#;
610
611 struct ReadErrrust-analyzer cargo netbuf 0.4.1 buf/test/ReadErr#;
612
613 impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for ReadErrrust-analyzer cargo netbuf 0.4.1 buf/test/ReadErr# {
614 fn readrust-analyzer cargo netbuf 0.4.1 buf/test/impl#[ReadErr][Read]read().(&mut self, _: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, 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#> {
615 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(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().(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#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock#, "fake would block"))
616 }
617 }
618
619 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
620 #[cfg(target_arch="x86_64")]
621 fn size32rust-analyzer cargo netbuf 0.4.1 buf/test/size32().() {
622 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#>(), 32);
623 }
624
625 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
626 #[cfg(target_arch="x86")]
627 fn size32() {
628 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(size_of::<Buf>(), 16);
629 }
630
631 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
632 fn emptyrust-analyzer cargo netbuf 0.4.1 buf/test/empty().() {
633 let buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
634 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
635 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", buf), "Buf { len=0; consumed=0; remaining=0 }")
636 }
637
638 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
639 fn read_from_emptyrust-analyzer cargo netbuf 0.4.1 buf/test/read_from_empty().() {
640 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
641 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
642 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
643 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.is_emptyrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]is_empty().());
644 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
645 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", buf), "Buf { len=0; consumed=0; remaining=0 }")
646 }
647
648 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
649 fn read_from_errrust-analyzer cargo netbuf 0.4.1 buf/test/read_from_err().() {
650 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
651 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut ReadErrrust-analyzer cargo netbuf 0.4.1 buf/test/ReadErr#).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
652 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.is_emptyrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]is_empty().());
653 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
654 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", buf), "Buf { len=0; consumed=0; remaining=0 }")
655 }
656
657 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
658 fn read_max_from_emptyrust-analyzer cargo netbuf 0.4.1 buf/test/read_max_from_empty().() {
659 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
660 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
661 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(1024, &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), false);
662 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.is_emptyrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]is_empty().());
663 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
664 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", buf), "Buf { len=0; consumed=0; remaining=0 }")
665 }
666
667 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
668 fn read_max_from_errrust-analyzer cargo netbuf 0.4.1 buf/test/read_max_from_err().() {
669 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
670 buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(1024, &mut ReadErrrust-analyzer cargo netbuf 0.4.1 buf/test/ReadErr#).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
671 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.is_emptyrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]is_empty().());
672 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
673 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", buf), "Buf { len=0; consumed=0; remaining=0 }")
674 }
675
676 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
677 fn read_fromrust-analyzer cargo netbuf 0.4.1 buf/test/read_from().() {
678 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
679 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b"hello");
680 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
681 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 5);
682 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello");
683 }
684
685 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
686 fn read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/test/read_max_from().() {
687 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
688 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b"hello");
689 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
690 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b"hello world");
691 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(1024*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024, &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
692 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hellohello world");
693 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
694 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b" from me!Oh, crap!");
695 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(25, &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
696 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hellohello world from me!");
697 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
698 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(25, &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
699 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hellohello world from me!");
700 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
701 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(5);
702 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.read_max_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_max_from().(22, &mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
703 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world from me!Oh");
704 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
705 }
706
707 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
708 fn two_readsrust-analyzer cargo netbuf 0.4.1 buf/test/two_reads().() {
709 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
710 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b"hello");
711 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
712 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
713 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b" world");
714 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
715 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world");
716 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.);
717 }
718
719 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
720 fn reallocrust-analyzer cargo netbuf 0.4.1 buf/test/realloc().() {
721 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
722 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(b"hello");
723 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
724 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
725 s.push_bytes_to_readrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]push_bytes_to_read().(&b"abcdefg".iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().cyclerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cycle().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1024*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024)
726 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().);
727 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
728 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...9]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"helloabcd");
729 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.);
730 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.);
731 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
732 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
733 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() >= 32768);
734 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
735 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
736 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
737 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
738 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
739 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
740 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
741 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
742 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
743 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
744 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
745 buf.read_fromrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]read_from().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
746 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Capacity {}", buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().());
747 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 1048576 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 5);
748 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() >= buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().());
749 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().() <= 2100000);
750 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().()-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().10..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"bcdefgabcd");
751 }
752
753 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
754 fn two_writesrust-analyzer cargo netbuf 0.4.1 buf/test/two_writes().() {
755 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
756 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 5);
757 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b" world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 6);
758 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world");
759 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.);
760 }
761
762 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
763 fn two_extendsrust-analyzer cargo netbuf 0.4.1 buf/test/two_extends().() {
764 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
765 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
766 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b" world");
767 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world");
768 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 11);
769 }
770
771 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
772 fn write_extendrust-analyzer cargo netbuf 0.4.1 buf/test/write_extend().() {
773 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
774 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
775 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b" world");
776 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world");
777 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), ALLOC_MINrust-analyzer cargo netbuf 0.4.1 buf/ALLOC_MIN.);
778 }
779
780 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
781 fn extend_writerust-analyzer cargo netbuf 0.4.1 buf/test/extend_write().() {
782 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
783 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
784 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b" world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
785 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world");
786 let cap = buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().();
787 // We don't know exact allocation policy for vec
788 // So this check is fuzzy
789 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cap >= 11);
790 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cap <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). 256);
791 }
792
793 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
794 fn extend_emptyrust-analyzer cargo netbuf 0.4.1 buf/test/extend_empty().() {
795 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
796 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"");
797 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
798 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 0);
799 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 0);
800 }
801
802 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
803 fn intorust-analyzer cargo netbuf 0.4.1 buf/test/into().() {
804 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
805 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
806 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b" world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
807 let vec: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = buf.intorust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Into<Vec<u8>>`]into().();
808 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., b"hello world");
809 let cap = vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
810 // We don't know exact allocation policy for vec
811 // So this check is fuzzy
812 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cap >= 11);
813 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cap <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). 256);
814 }
815
816 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
817 fn consumed_intorust-analyzer cargo netbuf 0.4.1 buf/test/consumed_into().() {
818 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
819 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
820 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b" world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
821 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(6);
822 let vec: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = buf.intorust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Into<Vec<u8>>`]into().();
823 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., b"world");
824 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().(), 5);
825 }
826 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
827 fn write_torust-analyzer cargo netbuf 0.4.1 buf/test/write_to().() {
828 let mut s = SharedMockStreamrust-analyzer cargo mockstream 0.0.2 SharedMockStream#::newrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]new().();
829 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
830 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello world");
831 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.write_torust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]write_to().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 11);
832 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&s.pop_bytes_writtenrust-analyzer cargo mockstream 0.0.2 impl#[SharedMockStream]pop_bytes_written().()[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., b"hello world");
833 }
834
835 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
836 fn empty_write_to_emptyrust-analyzer cargo netbuf 0.4.1 buf/test/empty_write_to_empty().() {
837 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
838 let mut empty = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
839 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(empty.write_torust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]write_to().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
840 }
841
842 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
843 fn extend_consume_extendrust-analyzer cargo netbuf 0.4.1 buf/test/extend_consume_extend().() {
844 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
845 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
846 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(3);
847 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b" world");
848 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"lo world");
849 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 8);
850 }
851
852 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
853 fn extend_consume_writerust-analyzer cargo netbuf 0.4.1 buf/test/extend_consume_write().() {
854 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
855 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
856 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(3);
857 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b"Some larger string for you").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
858 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"loSome larger string for you");
859 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 28);
860 }
861
862 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
863 fn consume_allrust-analyzer cargo netbuf 0.4.1 buf/test/consume_all().() {
864 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
865 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"hello");
866 buf.writerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][Write]write().(b" world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
867 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(11);
868 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 0);
869 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
870 let vec: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = buf.intorust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Into<Vec<u8>>`]into().();
871 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., b"");
872 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vec.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().(), 0);
873 }
874
875 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
876 fn indexrust-analyzer cargo netbuf 0.4.1 buf/test/index().() {
877 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
878 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World!");
879 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'H');
880 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().6]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'W');
881 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(2);
882 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().2]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'o');
883 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().8]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'd');
884 }
885
886 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
887 fn index_mutrust-analyzer cargo netbuf 0.4.1 buf/test/index_mut().() {
888 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
889 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World!");
890 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'H');
891 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut(). = b'h';
892 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index().6]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<usize>`]index()., b'W');
893 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().6]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut(). = b'M';
894 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello Morld!");
895 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(2);
896 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().1]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut(). = b'e';
897 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut(). = b'e';
898 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut().8]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<usize>`]index_mut(). = b'e';
899 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"leo Merle!");
900 }
901
902 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
903 fn getrust-analyzer cargo netbuf 0.4.1 buf/test/get().() {
904 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
905 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(0), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
906 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World!");
907 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(0), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'H'));
908 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(6), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'W'));
909 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(11), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'!'));
910 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(12), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
911 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(2);
912 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(2), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'o'));
913 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(8), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'd'));
914 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(9), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'!'));
915 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.getrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get().(10), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
916 }
917
918 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
919 fn get_mutrust-analyzer cargo netbuf 0.4.1 buf/test/get_mut().() {
920 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
921 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(0), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
922 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World!");
923 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(0), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut b'H'));
924 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(0) { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = b'h'; }
925 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(6), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut b'W'));
926 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(6) { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = b'M'; }
927 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello Morld!");
928 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(11), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut b'!'));
929 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(12), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
930 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(2);
931 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(1) { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = b'e'; }
932 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(5) { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = b'e'; }
933 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(8) { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = b'e'; }
934 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"leo Merle!");
935 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(9), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut b'!'));
936 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.get_mutrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]get_mut().(10), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
937 }
938
939 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
940 fn rangesrust-analyzer cargo netbuf 0.4.1 buf/test/ranges().() {
941 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
942 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello world!");
943 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"Hello world!");
944 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"");
945 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello");
946 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello world!");
947 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...7]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello w");
948 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().0..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"Hello world!");
949 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().3..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"lo world!");
950 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().6..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"world!");
951 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().12..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"");
952 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().0..0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"");
953 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().2..8]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"llo wo");
954 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().0..12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"Hello world!");
955 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().0..5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"Hello");
956 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().7..12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"orld!");
957 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().3..3]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"");
958 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().3..9]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"lo wor");
959 }
960
961 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
962 fn consume_rangesrust-analyzer cargo netbuf 0.4.1 buf/test/consume_ranges().() {
963 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
964 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Crappy stuff");
965 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello world!");
966 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(12);
967 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"Hello world!");
968 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...0]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"");
969 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello");
970 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello world!");
971 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()...7]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeTo<usize>>`]index()., b"Hello w");
972 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().0..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"Hello world!");
973 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().3..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"lo world!");
974 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().6..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"world!");
975 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index().12..]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFrom<usize>>`]index()., b"");
976 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().2..8]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"llo wo");
977 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().0..12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"Hello world!");
978 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().0..5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"Hello");
979 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().7..12]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"orld!");
980 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().3..3]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"");
981 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index().3..9]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<Range<usize>>`]index()., b"lo wor");
982 }
983
984 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
985 fn remove_rangesrust-analyzer cargo netbuf 0.4.1 buf/test/remove_ranges().() {
986 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
987 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Crappy stuff");
988 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello world!");
989 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"Crappy stuffHello world!");
990 buf.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#4);
991 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"py stuffHello world!");
992 buf.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8);
993 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"py Hello world!");
994 buf.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(7..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#14);
995 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"py Hell!");
996 buf.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(7..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#);
997 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"py Hell");
998 let end = buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().();
999 buf.remove_rangerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]remove_range().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end);
1000 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"py");
1001 }
1002
1003 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1004 fn mut_rangesrust-analyzer cargo netbuf 0.4.1 buf/test/mut_ranges().() {
1005 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
1006 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Crappy stuff");
1007 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello world!");
1008 buf.consumerust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consume().(12);
1009 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFull>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFull>`]index_mut()..clone_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]clone_from_slice().(b"HELLO WORLD.");
1010 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"HELLO WORLD.");
1011 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeTo<usize>>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#5]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeTo<usize>>`]index_mut()..clone_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]clone_from_slice().(b"hell!");
1012 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hell! WORLD.");
1013 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<Range<usize>>`]index_mut().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<Range<usize>>`]index_mut()..clone_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]clone_from_slice().(b"o worl");
1014 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello worlD.");
1015 buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFrom<usize>>`]index_mut().10..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`IndexMut<RangeFrom<usize>>`]index_mut()..clone_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]clone_from_slice().(b"d!");
1016 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"hello world!");
1017 }
1018
1019 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1020 fn split_off_realloc_selfrust-analyzer cargo netbuf 0.4.1 buf/test/split_off_realloc_self().() {
1021 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
1022 buf.reserve_exactrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve_exact().(20);
1023 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World");
1024 let tail = buf.split_offrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]split_off().(5);
1025 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"Hello");
1026 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(), 0);
1027 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 5);
1028
1029 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&tail[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b" World");
1030 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tail.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(), 5);
1031 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tail.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 6);
1032 }
1033
1034 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1035 fn split_off_alloc_tailrust-analyzer cargo netbuf 0.4.1 buf/test/split_off_alloc_tail().() {
1036 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
1037 buf.reserve_exactrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]reserve_exact().(20);
1038 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"Hello World!...");
1039 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 20);
1040
1041 let tail = buf.split_offrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]split_off().(11);
1042 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"Hello World");
1043 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 20);
1044 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(), 0);
1045 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 11);
1046
1047 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&tail[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"!...");
1048 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tail.capacityrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]capacity().(), 4);
1049 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tail.consumedrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]consumed().(), 0);
1050 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tail.lenrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]len().(), 4);
1051
1052 let mut buf = Bufrust-analyzer cargo netbuf 0.4.1 buf/Buf#::newrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]new().();
1053 buf.extendrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]extend().(b"abcdefg");
1054 let tail = buf.split_offrust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf]split_off().(0);
1055 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&tail[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"abcdefg");
1056 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()...]rust-analyzer cargo netbuf 0.4.1 buf/impl#[Buf][`Index<RangeFull>`]index()., b"");
1057 }
1058 }