mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
632 lines
113 KiB
HTML
632 lines
113 KiB
HTML
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Read bytes from a buffer."><title>Buf in actix_web::web - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">Buf</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.advance">advance</a></li><li><a href="#tymethod.chunk">chunk</a></li><li><a href="#tymethod.remaining">remaining</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.chain">chain</a></li><li><a href="#method.chunks_vectored">chunks_vectored</a></li><li><a href="#method.copy_to_bytes">copy_to_bytes</a></li><li><a href="#method.copy_to_slice">copy_to_slice</a></li><li><a href="#method.get_f32">get_f32</a></li><li><a href="#method.get_f32_le">get_f32_le</a></li><li><a href="#method.get_f32_ne">get_f32_ne</a></li><li><a href="#method.get_f64">get_f64</a></li><li><a href="#method.get_f64_le">get_f64_le</a></li><li><a href="#method.get_f64_ne">get_f64_ne</a></li><li><a href="#method.get_i128">get_i128</a></li><li><a href="#method.get_i128_le">get_i128_le</a></li><li><a href="#method.get_i128_ne">get_i128_ne</a></li><li><a href="#method.get_i16">get_i16</a></li><li><a href="#method.get_i16_le">get_i16_le</a></li><li><a href="#method.get_i16_ne">get_i16_ne</a></li><li><a href="#method.get_i32">get_i32</a></li><li><a href="#method.get_i32_le">get_i32_le</a></li><li><a href="#method.get_i32_ne">get_i32_ne</a></li><li><a href="#method.get_i64">get_i64</a></li><li><a href="#method.get_i64_le">get_i64_le</a></li><li><a href="#method.get_i64_ne">get_i64_ne</a></li><li><a href="#method.get_i8">get_i8</a></li><li><a href="#method.get_int">get_int</a></li><li><a href="#method.get_int_le">get_int_le</a></li><li><a href="#method.get_int_ne">get_int_ne</a></li><li><a href="#method.get_u128">get_u128</a></li><li><a href="#method.get_u128_le">get_u128_le</a></li><li><a href="#method.get_u128_ne">get_u128_ne</a></li><li><a href="#method.get_u16">get
|
|||
|
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 48 methods</span></summary> // Required methods
|
|||
|
fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
|||
|
<span class="item-spacer"></span> fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a>;
|
|||
|
<span class="item-spacer"></span> fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>);
|
|||
|
|
|||
|
// Provided methods
|
|||
|
fn <a href="#method.chunks_vectored" class="fn">chunks_vectored</a><'a>(&'a self, dst: &mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'a>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.has_remaining" class="fn">has_remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&mut self, dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u8" class="fn">get_u8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i8" class="fn">get_i8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u16" class="fn">get_u16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u16_le" class="fn">get_u16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u16_ne" class="fn">get_u16_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i16" class="fn">get_i16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i16_le" class="fn">get_i16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i16_ne" class="fn">get_i16_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u32" class="fn">get_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u32_le" class="fn">get_u32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u32_ne" class="fn">get_u32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i32" class="fn">get_i32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i32_le" class="fn">get_i32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i32_ne" class="fn">get_i32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u64" class="fn">get_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u64_le" class="fn">get_u64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u64_ne" class="fn">get_u64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i64" class="fn">get_i64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i64_le" class="fn">get_i64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i64_ne" class="fn">get_i64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u128" class="fn">get_u128</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u128_le" class="fn">get_u128_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_u128_ne" class="fn">get_u128_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i128" class="fn">get_i128</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i128_le" class="fn">get_i128_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_i128_ne" class="fn">get_i128_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_uint" class="fn">get_uint</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_uint_le" class="fn">get_uint_le</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_uint_ne" class="fn">get_uint_ne</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_int" class="fn">get_int</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_int_le" class="fn">get_int_le</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_int_ne" class="fn">get_int_ne</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f32" class="fn">get_f32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f32_le" class="fn">get_f32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f32_ne" class="fn">get_f32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f64" class="fn">get_f64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f64_le" class="fn">get_f64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.get_f64_ne" class="fn">get_f64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.copy_to_bytes" class="fn">copy_to_bytes</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Bytes.html" title="struct actix_web::web::Bytes">Bytes</a> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Take<Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.chain" class="fn">chain</a><U>(self, next: U) -> Chain<Self, U>
|
|||
|
<span class="where">where U: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
<span class="item-spacer"></span> fn <a href="#method.reader" class="fn">reader</a>(self) -> Reader<Self>
|
|||
|
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
|||
|
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Read bytes from a buffer.</p>
|
|||
|
<p>A buffer stores bytes in memory such that read operations are infallible.
|
|||
|
The underlying storage may or may not be in contiguous memory. A <code>Buf</code> value
|
|||
|
is a cursor into the buffer. Reading from <code>Buf</code> advances the cursor
|
|||
|
position. It can be thought of as an efficient <code>Iterator</code> for collections of
|
|||
|
bytes.</p>
|
|||
|
<p>The simplest <code>Buf</code> is a <code>&[u8]</code>.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"hello world"</span>[..];
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="string">b'h'</span>, buf.get_u8());
|
|||
|
<span class="macro">assert_eq!</span>(<span class="string">b'e'</span>, buf.get_u8());
|
|||
|
<span class="macro">assert_eq!</span>(<span class="string">b'l'</span>, buf.get_u8());
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>rest = [<span class="number">0</span>; <span class="number">8</span>];
|
|||
|
buf.copy_to_slice(<span class="kw-2">&mut </span>rest);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>rest[..], <span class="kw-2">&</span><span class="string">b"lo world"</span>[..]);</code></pre></div>
|
|||
|
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.remaining" class="method"><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the number of bytes between the current position and the end of
|
|||
|
the buffer.</p>
|
|||
|
<p>This value is greater than or equal to the length of the slice returned
|
|||
|
by <code>chunk()</code>.</p>
|
|||
|
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"hello world"</span>[..];
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.remaining(), <span class="number">11</span>);
|
|||
|
|
|||
|
buf.get_u8();
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.remaining(), <span class="number">10</span>);</code></pre></div>
|
|||
|
<h5 id="implementer-notes"><a class="doc-anchor" href="#implementer-notes">§</a>Implementer notes</h5>
|
|||
|
<p>Implementations of <code>remaining</code> should ensure that the return value does
|
|||
|
not change unless a call is made to <code>advance</code> or any other function that
|
|||
|
is documented to change the <code>Buf</code>’s current position.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.chunk" class="method"><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section></summary><div class="docblock"><p>Returns a slice starting at the current position and of length between 0
|
|||
|
and <code>Buf::remaining()</code>. Note that this <em>can</em> return shorter slice (this allows
|
|||
|
non-continuous internal representation).</p>
|
|||
|
<p>This is a lower level function. Most operations are done with other
|
|||
|
functions.</p>
|
|||
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"hello world"</span>[..];
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.chunk(), <span class="kw-2">&</span><span class="string">b"hello world"</span>[..]);
|
|||
|
|
|||
|
buf.advance(<span class="number">6</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.chunk(), <span class="kw-2">&</span><span class="string">b"world"</span>[..]);</code></pre></div>
|
|||
|
<h5 id="implementer-notes-1"><a class="doc-anchor" href="#implementer-notes-1">§</a>Implementer notes</h5>
|
|||
|
<p>This function should never panic. Once the end of the buffer is reached,
|
|||
|
i.e., <code>Buf::remaining</code> returns 0, calls to <code>chunk()</code> should return an
|
|||
|
empty slice.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.advance" class="method"><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section></summary><div class="docblock"><p>Advance the internal cursor of the Buf</p>
|
|||
|
<p>The next call to <code>chunk()</code> will return a slice starting <code>cnt</code> bytes
|
|||
|
further into the underlying buffer.</p>
|
|||
|
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"hello world"</span>[..];
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.chunk(), <span class="kw-2">&</span><span class="string">b"hello world"</span>[..]);
|
|||
|
|
|||
|
buf.advance(<span class="number">6</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(buf.chunk(), <span class="kw-2">&</span><span class="string">b"world"</span>[..]);</code></pre></div>
|
|||
|
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
|||
|
<p>This function <strong>may</strong> panic if <code>cnt > self.remaining()</code>.</p>
|
|||
|
<h5 id="implementer-notes-2"><a class="doc-anchor" href="#implementer-notes-2">§</a>Implementer notes</h5>
|
|||
|
<p>It is recommended for implementations of <code>advance</code> to panic if <code>cnt > self.remaining()</code>. If the implementation does not panic, the call must
|
|||
|
behave as if <code>cnt == self.remaining()</code>.</p>
|
|||
|
<p>A call with <code>cnt == 0</code> should never panic and be a no-op.</p>
|
|||
|
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.chunks_vectored" class="method"><h4 class="code-header">fn <a href="#method.chunks_vectored" class="fn">chunks_vectored</a><'a>(&'a self, dst: &mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'a>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>std</code></strong> only.</div></span></summary><div class="docblock"><p>Fills <code>dst</code> with potentially multiple slices starting at <code>self</code>’s
|
|||
|
current position.</p>
|
|||
|
<p>If the <code>Buf</code> is backed by disjoint slices of bytes, <code>chunk_vectored</code> enables
|
|||
|
fetching more than one slice at once. <code>dst</code> is a slice of <code>IoSlice</code>
|
|||
|
references, enabling the slice to be directly used with <a href="http://man7.org/linux/man-pages/man2/readv.2.html"><code>writev</code></a>
|
|||
|
without any further conversion. The sum of the lengths of all the
|
|||
|
buffers in <code>dst</code> will be less than or equal to <code>Buf::remaining()</code>.</p>
|
|||
|
<p>The entries in <code>dst</code> will be overwritten, but the data <strong>contained</strong> by
|
|||
|
the slices <strong>will not</strong> be modified. If <code>chunk_vectored</code> does not fill every
|
|||
|
entry in <code>dst</code>, then <code>dst</code> is guaranteed to contain all remaining slices
|
|||
|
in `self.</p>
|
|||
|
<p>This is a lower level function. Most operations are done with other
|
|||
|
functions.</p>
|
|||
|
<h5 id="implementer-notes-3"><a class="doc-anchor" href="#implementer-notes-3">§</a>Implementer notes</h5>
|
|||
|
<p>This function should never panic. Once the end of the buffer is reached,
|
|||
|
i.e., <code>Buf::remaining</code> returns 0, calls to <code>chunk_vectored</code> must return 0
|
|||
|
without mutating <code>dst</code>.</p>
|
|||
|
<p>Implementations should also take care to properly handle being called
|
|||
|
with <code>dst</code> being a zero length slice.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.has_remaining" class="method"><h4 class="code-header">fn <a href="#method.has_remaining" class="fn">has_remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if there are any more bytes to consume</p>
|
|||
|
<p>This is equivalent to <code>self.remaining() != 0</code>.</p>
|
|||
|
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"a"</span>[..];
|
|||
|
|
|||
|
<span class="macro">assert!</span>(buf.has_remaining());
|
|||
|
|
|||
|
buf.get_u8();
|
|||
|
|
|||
|
<span class="macro">assert!</span>(!buf.has_remaining());</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_to_slice" class="method"><h4 class="code-header">fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&mut self, dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>])</h4></section></summary><div class="docblock"><p>Copies bytes from <code>self</code> into <code>dst</code>.</p>
|
|||
|
<p>The cursor is advanced by the number of bytes copied. <code>self</code> must have
|
|||
|
enough remaining bytes to fill <code>dst</code>.</p>
|
|||
|
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"hello world"</span>[..];
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>dst = [<span class="number">0</span>; <span class="number">5</span>];
|
|||
|
|
|||
|
buf.copy_to_slice(<span class="kw-2">&mut </span>dst);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"hello"</span>[..], <span class="kw-2">&</span>dst);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">6</span>, buf.remaining());</code></pre></div>
|
|||
|
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
|||
|
<p>This function panics if <code>self.remaining() < dst.len()</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u8" class="method"><h4 class="code-header">fn <a href="#method.get_u8" class="fn">get_u8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 8 bit integer from <code>self</code>.</p>
|
|||
|
<p>The current position is advanced by 1.</p>
|
|||
|
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">8</span>, buf.get_u8());</code></pre></div>
|
|||
|
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is no more remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i8" class="method"><h4 class="code-header">fn <a href="#method.get_i8" class="fn">get_i8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></h4></section></summary><div class="docblock"><p>Gets a signed 8 bit integer from <code>self</code>.</p>
|
|||
|
<p>The current position is advanced by 1.</p>
|
|||
|
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">8</span>, buf.get_i8());</code></pre></div>
|
|||
|
<h5 id="panics-3"><a class="doc-anchor" href="#panics-3">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is no more remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u16" class="method"><h4 class="code-header">fn <a href="#method.get_u16" class="fn">get_u16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 16 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x09 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_u16());</code></pre></div>
|
|||
|
<h5 id="panics-4"><a class="doc-anchor" href="#panics-4">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u16_le" class="method"><h4 class="code-header">fn <a href="#method.get_u16_le" class="fn">get_u16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 16 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x09\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_u16_le());</code></pre></div>
|
|||
|
<h5 id="panics-5"><a class="doc-anchor" href="#panics-5">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u16_ne" class="method"><h4 class="code-header">fn <a href="#method.get_u16_ne" class="fn">get_u16_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 16 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x08\x09 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x09\x08 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_u16_ne());</code></pre></div>
|
|||
|
<h5 id="panics-6"><a class="doc-anchor" href="#panics-6">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i16" class="method"><h4 class="code-header">fn <a href="#method.get_i16" class="fn">get_i16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></h4></section></summary><div class="docblock"><p>Gets a signed 16 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x09 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_i16());</code></pre></div>
|
|||
|
<h5 id="panics-7"><a class="doc-anchor" href="#panics-7">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i16_le" class="method"><h4 class="code-header">fn <a href="#method.get_i16_le" class="fn">get_i16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></h4></section></summary><div class="docblock"><p>Gets a signed 16 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x09\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_i16_le());</code></pre></div>
|
|||
|
<h5 id="panics-8"><a class="doc-anchor" href="#panics-8">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i16_ne" class="method"><h4 class="code-header">fn <a href="#method.get_i16_ne" class="fn">get_i16_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></h4></section></summary><div class="docblock"><p>Gets a signed 16 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 2.</p>
|
|||
|
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x08\x09 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x09\x08 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809</span>, buf.get_i16_ne());</code></pre></div>
|
|||
|
<h5 id="panics-9"><a class="doc-anchor" href="#panics-9">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u32" class="method"><h4 class="code-header">fn <a href="#method.get_u32" class="fn">get_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 32 bit integer from <code>self</code> in the big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x09\xA0\xA1 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_u32());</code></pre></div>
|
|||
|
<h5 id="panics-10"><a class="doc-anchor" href="#panics-10">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u32_le" class="method"><h4 class="code-header">fn <a href="#method.get_u32_le" class="fn">get_u32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 32 bit integer from <code>self</code> in the little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\xA1\xA0\x09\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_u32_le());</code></pre></div>
|
|||
|
<h5 id="panics-11"><a class="doc-anchor" href="#panics-11">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u32_ne" class="method"><h4 class="code-header">fn <a href="#method.get_u32_ne" class="fn">get_u32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 32 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x08\x09\xA0\xA1 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\xA1\xA0\x09\x08 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_u32_ne());</code></pre></div>
|
|||
|
<h5 id="panics-12"><a class="doc-anchor" href="#panics-12">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i32" class="method"><h4 class="code-header">fn <a href="#method.get_i32" class="fn">get_i32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></h4></section></summary><div class="docblock"><p>Gets a signed 32 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x09\xA0\xA1 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_i32());</code></pre></div>
|
|||
|
<h5 id="panics-13"><a class="doc-anchor" href="#panics-13">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i32_le" class="method"><h4 class="code-header">fn <a href="#method.get_i32_le" class="fn">get_i32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></h4></section></summary><div class="docblock"><p>Gets a signed 32 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\xA1\xA0\x09\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_i32_le());</code></pre></div>
|
|||
|
<h5 id="panics-14"><a class="doc-anchor" href="#panics-14">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i32_ne" class="method"><h4 class="code-header">fn <a href="#method.get_i32_ne" class="fn">get_i32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></h4></section></summary><div class="docblock"><p>Gets a signed 32 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x08\x09\xA0\xA1 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\xA1\xA0\x09\x08 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0809A0A1</span>, buf.get_i32_ne());</code></pre></div>
|
|||
|
<h5 id="panics-15"><a class="doc-anchor" href="#panics-15">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u64" class="method"><h4 class="code-header">fn <a href="#method.get_u64" class="fn">get_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 64 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_u64());</code></pre></div>
|
|||
|
<h5 id="panics-16"><a class="doc-anchor" href="#panics-16">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u64_le" class="method"><h4 class="code-header">fn <a href="#method.get_u64_le" class="fn">get_u64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 64 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_u64_le());</code></pre></div>
|
|||
|
<h5 id="panics-17"><a class="doc-anchor" href="#panics-17">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u64_ne" class="method"><h4 class="code-header">fn <a href="#method.get_u64_ne" class="fn">get_u64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 64 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_u64_ne());</code></pre></div>
|
|||
|
<h5 id="panics-18"><a class="doc-anchor" href="#panics-18">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i64" class="method"><h4 class="code-header">fn <a href="#method.get_i64" class="fn">get_i64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed 64 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-22"><a class="doc-anchor" href="#examples-22">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_i64());</code></pre></div>
|
|||
|
<h5 id="panics-19"><a class="doc-anchor" href="#panics-19">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i64_le" class="method"><h4 class="code-header">fn <a href="#method.get_i64_le" class="fn">get_i64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed 64 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-23"><a class="doc-anchor" href="#examples-23">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_i64_le());</code></pre></div>
|
|||
|
<h5 id="panics-20"><a class="doc-anchor" href="#panics-20">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i64_ne" class="method"><h4 class="code-header">fn <a href="#method.get_i64_ne" class="fn">get_i64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed 64 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-24"><a class="doc-anchor" href="#examples-24">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x0102030405060708</span>, buf.get_i64_ne());</code></pre></div>
|
|||
|
<h5 id="panics-21"><a class="doc-anchor" href="#panics-21">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u128" class="method"><h4 class="code-header">fn <a href="#method.get_u128" class="fn">get_u128</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 128 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-25"><a class="doc-anchor" href="#examples-25">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_u128());</code></pre></div>
|
|||
|
<h5 id="panics-22"><a class="doc-anchor" href="#panics-22">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u128_le" class="method"><h4 class="code-header">fn <a href="#method.get_u128_le" class="fn">get_u128_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 128 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-26"><a class="doc-anchor" href="#examples-26">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_u128_le());</code></pre></div>
|
|||
|
<h5 id="panics-23"><a class="doc-anchor" href="#panics-23">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_u128_ne" class="method"><h4 class="code-header">fn <a href="#method.get_u128_ne" class="fn">get_u128_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></h4></section></summary><div class="docblock"><p>Gets an unsigned 128 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-27"><a class="doc-anchor" href="#examples-27">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_u128_ne());</code></pre></div>
|
|||
|
<h5 id="panics-24"><a class="doc-anchor" href="#panics-24">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i128" class="method"><h4 class="code-header">fn <a href="#method.get_i128" class="fn">get_i128</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></h4></section></summary><div class="docblock"><p>Gets a signed 128 bit integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-28"><a class="doc-anchor" href="#examples-28">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_i128());</code></pre></div>
|
|||
|
<h5 id="panics-25"><a class="doc-anchor" href="#panics-25">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i128_le" class="method"><h4 class="code-header">fn <a href="#method.get_i128_le" class="fn">get_i128_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></h4></section></summary><div class="docblock"><p>Gets a signed 128 bit integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-29"><a class="doc-anchor" href="#examples-29">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_i128_le());</code></pre></div>
|
|||
|
<h5 id="panics-26"><a class="doc-anchor" href="#panics-26">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_i128_ne" class="method"><h4 class="code-header">fn <a href="#method.get_i128_ne" class="fn">get_i128_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></h4></section></summary><div class="docblock"><p>Gets a signed 128 bit integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 16.</p>
|
|||
|
<h5 id="examples-30"><a class="doc-anchor" href="#examples-30">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x01020304050607080910111213141516</span>, buf.get_i128_ne());</code></pre></div>
|
|||
|
<h5 id="panics-27"><a class="doc-anchor" href="#panics-27">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_uint" class="method"><h4 class="code-header">fn <a href="#method.get_uint" class="fn">get_uint</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned n-byte integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-31"><a class="doc-anchor" href="#examples-31">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_uint(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-28"><a class="doc-anchor" href="#panics-28">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_uint_le" class="method"><h4 class="code-header">fn <a href="#method.get_uint_le" class="fn">get_uint_le</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned n-byte integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-32"><a class="doc-anchor" href="#examples-32">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_uint_le(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-29"><a class="doc-anchor" href="#panics-29">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_uint_ne" class="method"><h4 class="code-header">fn <a href="#method.get_uint_ne" class="fn">get_uint_ne</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></summary><div class="docblock"><p>Gets an unsigned n-byte integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-33"><a class="doc-anchor" href="#examples-33">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_uint_ne(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-30"><a class="doc-anchor" href="#panics-30">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>, or
|
|||
|
if <code>nbytes</code> is greater than 8.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_int" class="method"><h4 class="code-header">fn <a href="#method.get_int" class="fn">get_int</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed n-byte integer from <code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-34"><a class="doc-anchor" href="#examples-34">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x01\x02\x03 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_int(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-31"><a class="doc-anchor" href="#panics-31">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>, or
|
|||
|
if <code>nbytes</code> is greater than 8.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_int_le" class="method"><h4 class="code-header">fn <a href="#method.get_int_le" class="fn">get_int_le</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed n-byte integer from <code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-35"><a class="doc-anchor" href="#examples-35">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x03\x02\x01 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_int_le(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-32"><a class="doc-anchor" href="#panics-32">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>, or
|
|||
|
if <code>nbytes</code> is greater than 8.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_int_ne" class="method"><h4 class="code-header">fn <a href="#method.get_int_ne" class="fn">get_int_ne</a>(&mut self, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></h4></section></summary><div class="docblock"><p>Gets a signed n-byte integer from <code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by <code>nbytes</code>.</p>
|
|||
|
<h5 id="examples-36"><a class="doc-anchor" href="#examples-36">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x01\x02\x03 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x03\x02\x01 hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">0x010203</span>, buf.get_int_ne(<span class="number">3</span>));</code></pre></div>
|
|||
|
<h5 id="panics-33"><a class="doc-anchor" href="#panics-33">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>, or
|
|||
|
if <code>nbytes</code> is greater than 8.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f32" class="method"><h4 class="code-header">fn <a href="#method.get_f32" class="fn">get_f32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 single-precision (4 bytes) floating point number from
|
|||
|
<code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-37"><a class="doc-anchor" href="#examples-37">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x3F\x99\x99\x9A hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f32</span>, buf.get_f32());</code></pre></div>
|
|||
|
<h5 id="panics-34"><a class="doc-anchor" href="#panics-34">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f32_le" class="method"><h4 class="code-header">fn <a href="#method.get_f32_le" class="fn">get_f32_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 single-precision (4 bytes) floating point number from
|
|||
|
<code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-38"><a class="doc-anchor" href="#examples-38">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x9A\x99\x99\x3F hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f32</span>, buf.get_f32_le());</code></pre></div>
|
|||
|
<h5 id="panics-35"><a class="doc-anchor" href="#panics-35">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f32_ne" class="method"><h4 class="code-header">fn <a href="#method.get_f32_ne" class="fn">get_f32_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 single-precision (4 bytes) floating point number from
|
|||
|
<code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 4.</p>
|
|||
|
<h5 id="examples-39"><a class="doc-anchor" href="#examples-39">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x3F\x99\x99\x9A hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x9A\x99\x99\x3F hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f32</span>, buf.get_f32_ne());</code></pre></div>
|
|||
|
<h5 id="panics-36"><a class="doc-anchor" href="#panics-36">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f64" class="method"><h4 class="code-header">fn <a href="#method.get_f64" class="fn">get_f64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 double-precision (8 bytes) floating point number from
|
|||
|
<code>self</code> in big-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-40"><a class="doc-anchor" href="#examples-40">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f64</span>, buf.get_f64());</code></pre></div>
|
|||
|
<h5 id="panics-37"><a class="doc-anchor" href="#panics-37">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f64_le" class="method"><h4 class="code-header">fn <a href="#method.get_f64_le" class="fn">get_f64_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 double-precision (8 bytes) floating point number from
|
|||
|
<code>self</code> in little-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-41"><a class="doc-anchor" href="#examples-41">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="kw-2">&</span><span class="string">b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello"</span>[..];
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f64</span>, buf.get_f64_le());</code></pre></div>
|
|||
|
<h5 id="panics-38"><a class="doc-anchor" href="#panics-38">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_f64_ne" class="method"><h4 class="code-header">fn <a href="#method.get_f64_ne" class="fn">get_f64_ne</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></h4></section></summary><div class="docblock"><p>Gets an IEEE754 double-precision (8 bytes) floating point number from
|
|||
|
<code>self</code> in native-endian byte order.</p>
|
|||
|
<p>The current position is advanced by 8.</p>
|
|||
|
<h5 id="examples-42"><a class="doc-anchor" href="#examples-42">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf: <span class="kw-2">&</span>[u8] = <span class="kw">match </span><span class="macro">cfg!</span>(target_endian = <span class="string">"big"</span>) {
|
|||
|
<span class="bool-val">true </span>=> <span class="string">b"\x3F\xF3\x33\x33\x33\x33\x33\x33 hello"</span>,
|
|||
|
<span class="bool-val">false </span>=> <span class="string">b"\x33\x33\x33\x33\x33\x33\xF3\x3F hello"</span>,
|
|||
|
};
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">1.2f64</span>, buf.get_f64_ne());</code></pre></div>
|
|||
|
<h5 id="panics-39"><a class="doc-anchor" href="#panics-39">§</a>Panics</h5>
|
|||
|
<p>This function panics if there is not enough remaining data in <code>self</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_to_bytes" class="method"><h4 class="code-header">fn <a href="#method.copy_to_bytes" class="fn">copy_to_bytes</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Bytes.html" title="struct actix_web::web::Bytes">Bytes</a></h4></section></summary><div class="docblock"><p>Consumes <code>len</code> bytes inside self and returns new instance of <code>Bytes</code>
|
|||
|
with this data.</p>
|
|||
|
<p>This function may be optimized by the underlying type to avoid actual
|
|||
|
copies. For example, <code>Bytes</code> implementation will do a shallow copy
|
|||
|
(ref-count increment).</p>
|
|||
|
<h5 id="examples-43"><a class="doc-anchor" href="#examples-43">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span>bytes = (<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]).copy_to_bytes(<span class="number">5</span>);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>bytes[..], <span class="kw-2">&</span><span class="string">b"hello"</span>[..]);</code></pre></div>
|
|||
|
<h5 id="panics-40"><a class="doc-anchor" href="#panics-40">§</a>Panics</h5>
|
|||
|
<p>This function panics if <code>len > self.remaining()</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method"><h4 class="code-header">fn <a href="#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Take<Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates an adaptor which will read at most <code>limit</code> bytes from <code>self</code>.</p>
|
|||
|
<p>This function returns a new instance of <code>Buf</code> which will read at most
|
|||
|
<code>limit</code> bytes.</p>
|
|||
|
<h5 id="examples-44"><a class="doc-anchor" href="#examples-44">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::{Buf, BufMut};
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = <span class="string">b"hello world"</span>[..].take(<span class="number">5</span>);
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>dst = <span class="macro">vec!</span>[];
|
|||
|
|
|||
|
dst.put(<span class="kw-2">&mut </span>buf);
|
|||
|
<span class="macro">assert_eq!</span>(dst, <span class="string">b"hello"</span>);
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>buf = buf.into_inner();
|
|||
|
dst.clear();
|
|||
|
dst.put(<span class="kw-2">&mut </span>buf);
|
|||
|
<span class="macro">assert_eq!</span>(dst, <span class="string">b" world"</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.chain" class="method"><h4 class="code-header">fn <a href="#method.chain" class="fn">chain</a><U>(self, next: U) -> Chain<Self, U><div class="where">where
|
|||
|
U: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Creates an adaptor which will chain this buffer with another.</p>
|
|||
|
<p>The returned <code>Buf</code> instance will first consume all bytes from <code>self</code>.
|
|||
|
Afterwards the output is equivalent to the output of next.</p>
|
|||
|
<h5 id="examples-45"><a class="doc-anchor" href="#examples-45">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::Buf;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>chain = <span class="string">b"hello "</span>[..].chain(<span class="kw-2">&</span><span class="string">b"world"</span>[..]);
|
|||
|
|
|||
|
<span class="kw">let </span>full = chain.copy_to_bytes(<span class="number">11</span>);
|
|||
|
<span class="macro">assert_eq!</span>(full.chunk(), <span class="string">b"hello world"</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.reader" class="method"><h4 class="code-header">fn <a href="#method.reader" class="fn">reader</a>(self) -> Reader<Self><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>std</code></strong> only.</div></span></summary><div class="docblock"><p>Creates an adaptor which implements the <code>Read</code> trait for <code>self</code>.</p>
|
|||
|
<p>This function returns a new value which implements <code>Read</code> by adapting
|
|||
|
the <code>Read</code> trait functions to the <code>Buf</code> trait functions. Given that
|
|||
|
<code>Buf</code> operations are infallible, none of the <code>Read</code> functions will
|
|||
|
return with <code>Err</code>.</p>
|
|||
|
<h5 id="examples-46"><a class="doc-anchor" href="#examples-46">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bytes::{Bytes, Buf};
|
|||
|
<span class="kw">use </span>std::io::Read;
|
|||
|
|
|||
|
<span class="kw">let </span>buf = Bytes::from(<span class="string">"hello world"</span>);
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>reader = buf.reader();
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>dst = [<span class="number">0</span>; <span class="number">1024</span>];
|
|||
|
|
|||
|
<span class="kw">let </span>num = reader.read(<span class="kw-2">&mut </span>dst).unwrap();
|
|||
|
|
|||
|
<span class="macro">assert_eq!</span>(<span class="number">11</span>, num);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>dst[..<span class="number">11</span>], <span class="kw-2">&</span><span class="string">b"hello world"</span>[..]);</code></pre></div>
|
|||
|
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Buf-for-%26%5Bu8%5D" class="impl"><a href="#impl-Buf-for-%26%5Bu8%5D" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]</h3></section></summary><div class="impl-items"><section id="method.remaining" class="method trait-impl"><a href="#method.remaining" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk" class="method trait-impl"><a href="#method.chunk" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.advance" class="method trait-impl"><a href="#method.advance" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section><section id="method.copy_to_slice-1" class="method trait-impl"><a href="#method.copy_to_slice-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&mut self, dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>])</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Buf-for-VecDeque%3Cu8%3E" class="impl"><a href="#impl-Buf-for-VecDeque%3Cu8%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/vec_deque/struct.VecDeque.html" title="struct alloc::collections::vec_deque::VecDeque">VecDeque</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></h3></section></summary><div class="impl-items"><section id="method.remaining-1" class="method trait-impl"><a href="#method.remaining-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-1" class="method trait-impl"><a href="#method.chunk-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.advance-1" class="method trait-impl"><a href="#method.advance-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Buf-for-%26mut+T" class="impl"><a href="#impl-Buf-for-%26mut+T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a><div class="where">where
|
|||
|
T: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><section id="method.remaining-2" class="method trait-impl"><a href="#method.remaining-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-2" class="method trait-impl"><a href="#method.chunk-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><details class="toggle method-toggle" open><summary><section id="method.chunks_vectored-1" class="method trait-impl"><a href="#method.chunks_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.chunks_vectored" class="fn">chunks_vectored</a><'b>(&'b self, dst: &mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'b>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>std</code></strong> only.</div></span></details><section id="method.advance-2" class="method trait-impl"><a href="#method.advance-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section><section id="method.has_remaining-1" class="method trait-impl"><a href="#method.has_remaining-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.has_remaining" class="fn">has_remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section><section id="method.copy_to_slice-2" class="method trait-impl"><a href="#method.copy_to_slice-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&mut self, dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>])</h4></section><section id="method.get_u8-1" class="method trait-impl"><a href="#method.get_u8-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u8" class="fn">get_u8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></h4></section><section id="method.get_i8-1" class="method trait-impl"><a href="#method.get_i8-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_i8" class="fn">get_i8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></h4></section><section id="method.get_u16-1" class="method trait-impl"><a href="#method.get_u16-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16" class="fn">get_u16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_le-1" class="method trait-impl"><a href="#method.get_u16_le-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16_le" class="fn">get_u16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_ne-1" class="method trait-impl"><a href="#method.get_u16_ne-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16_ne" class="fn">ge
|
|||
|
T: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><section id="method.remaining-3" class="method trait-impl"><a href="#method.remaining-3" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-3" class="method trait-impl"><a href="#method.chunk-3" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><details class="toggle method-toggle" open><summary><section id="method.chunks_vectored-2" class="method trait-impl"><a href="#method.chunks_vectored-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.chunks_vectored" class="fn">chunks_vectored</a><'b>(&'b self, dst: &mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'b>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>std</code></strong> only.</div></span></details><section id="method.advance-3" class="method trait-impl"><a href="#method.advance-3" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section><section id="method.has_remaining-2" class="method trait-impl"><a href="#method.has_remaining-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.has_remaining" class="fn">has_remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section><section id="method.copy_to_slice-3" class="method trait-impl"><a href="#method.copy_to_slice-3" class="anchor">§</a><h4 class="code-header">fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&mut self, dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>])</h4></section><section id="method.get_u8-2" class="method trait-impl"><a href="#method.get_u8-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u8" class="fn">get_u8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></h4></section><section id="method.get_i8-2" class="method trait-impl"><a href="#method.get_i8-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_i8" class="fn">get_i8</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></h4></section><section id="method.get_u16-2" class="method trait-impl"><a href="#method.get_u16-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16" class="fn">get_u16</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_le-2" class="method trait-impl"><a href="#method.get_u16_le-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16_le" class="fn">get_u16_le</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_ne-2" class="method trait-impl"><a href="#method.get_u16_ne-2" class="anchor">§</a><h4 class="code-header">fn <a href="#method.get_u16_ne" class="fn">ge
|
|||
|
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]>,</div></h3><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>std</code></strong> only.</div></span></section></summary><div class="impl-items"><section id="method.remaining-4" class="method trait-impl"><a href="#method.remaining-4" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-4" class="method trait-impl"><a href="#method.chunk-4" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.advance-4" class="method trait-impl"><a href="#method.advance-4" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.advance" class="fn">advance</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Buf-for-Bytes" class="impl"><a href="#impl-Buf-for-Bytes" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for <a class="struct" href="struct.Bytes.html" title="struct actix_web::web::Bytes">Bytes</a></h3></section><section id="impl-Buf-for-BytesMut" class="impl"><a href="#impl-Buf-for-BytesMut" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for <a class="struct" href="struct.BytesMut.html" title="struct actix_web::web::BytesMut">BytesMut</a></h3></section><section id="impl-Buf-for-Take%3CT%3E" class="impl"><a href="#impl-Buf-for-Take%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for Take<T><div class="where">where
|
|||
|
T: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,</div></h3></section><section id="impl-Buf-for-Chain%3CT,+U%3E" class="impl"><a href="#impl-Buf-for-Chain%3CT,+U%3E" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a> for Chain<T, U><div class="where">where
|
|||
|
T: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,
|
|||
|
U: <a class="trait" href="trait.Buf.html" title="trait actix_web::web::Buf">Buf</a>,</div></h3></section></div><script src="../../trait.impl/bytes/buf/buf_impl/trait.Buf.js" data-ignore-extern-crates="alloc,bytes,std" async></script><script type="text/json" id="notable-traits-data">{"&[u8]":"<h3>Notable traits for <code>&[<a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.u8.html\">u8</a>]</code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &[<a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.u8.html\">u8</a>]</div>"}</script></section></div></main></body></html>
|