mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-17 16:29:50 +00:00
628 lines
No EOL
125 KiB
HTML
628 lines
No EOL
125 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 bytes::buf - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.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-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="bytes" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../bytes/index.html">bytes</a><span class="version">1.9.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Buf</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.advance" title="advance">advance</a></li><li><a href="#tymethod.chunk" title="chunk">chunk</a></li><li><a href="#tymethod.remaining" title="remaining">remaining</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.chain" title="chain">chain</a></li><li><a href="#method.chunks_vectored" title="chunks_vectored">chunks_vectored</a></li><li><a href="#method.copy_to_bytes" title="copy_to_bytes">copy_to_bytes</a></li><li><a href="#method.copy_to_slice" title="copy_to_slice">copy_to_slice</a></li><li><a href="#method.get_f32" title="get_f32">get_f32</a></li><li><a href="#method.get_f32_le" title="get_f32_le">get_f32_le</a></li><li><a href="#method.get_f32_ne" title="get_f32_ne">get_f32_ne</a></li><li><a href="#method.get_f64" title="get_f64">get_f64</a></li><li><a href="#method.get_f64_le" title="get_f64_le">get_f64_le</a></li><li><a href="#method.get_f64_ne" title="get_f64_ne">get_f64_ne</a></li><li><a href="#method.get_i128" title="get_i128">get_i128</a></li><li><a href="#method.get_i128_le" title="get_i128_le">get_i128_le</a></li><li><a href="#method.get_i128_ne" title="get_i128_ne">get_i128_ne</a></li><li><a href="#method.get_i16" title="get_i16">get_i16</a></li><li><a href="#method.get_i16_le" title="get_i16_le">get_i16_le</a></li><li><a href="#method.get_i16_ne" title="get_i16_ne">get_i16_ne</a></li><li><a href="#method.get_i32" title="get_i32">get_i32</a></li><li><a href="#method.get_i32_le" title="get_i32_le">get_i32_le</a></li><li><a href="#method.get_i32_ne" title="get_i32_ne">get_i32_ne</a></li><li><a href="#method.get_i64" title="get_i64">get_i64</a></li><li><a href="#method.get_i64_le" title="get_i64_le">get_i64_le</a></li><li><a href="#method.get_i64_ne" title="get_i64_ne">get_i64_ne</a></li><li><a href="#method.get_i8" title="get_i8">get_i8</a></li><li><a href="#method.get_int" title="get_int">get_int</a></li><li><a href="#method.get_int_le" title="get_int_le">get_int_le</a></li><li><a href="#method.get_int_ne" title="get_int_ne">get_int_ne</a></li><li><a href="#method.get_u128" title="get_u128">get_u128</a></li><li><a href="#method.get_u128_le" title="get_u128_le">get_u128_le</a></li><li><a href="#method.get_u128_ne" title="get_u128_ne">get_u128_ne</a></li><li><a href="#method.get_u16" title="get_u16">get_u16</a></li><li><a href="#method.get_u16_le" title="get_u16_le">get_u16_le</a></li><li><a href="#method.get_u16_ne" title="get_u16_ne">get_u16_ne</a></li><li><a href="#method.get_u32" title="get_u32">get_u32</a></li><li><a href="#method.get_u32_le" title="get_u32_le">get_u32_le</a></li><li><a href="#method.get_u32_ne" title="get_u32_ne">get_u32_ne</a></li><li><a href="#method.get_u64" title="get_u64">get_u64</a></li><li><a href="#method.get_u64_le" title="get_u64_le">get_u64_le</a></li><li><a href="#method.get_u64_ne" title="get_u64_ne">get_u64_ne</a></li><li><a href="#method.get_u8" title="get_u8">get_u8</a></li><li><a href="#method.get_uint" title="get_uint">get_uint</a></li><li><a href="#method.get_uint_le" title="get_uint_le">get_uint_le</a></li><li><a href="#method.get_uint_ne" title="get_uint_ne">get_uint_ne</a></li><li><a href="#method.has_remaining" title="has_remaining">has_remaining</a></li><li><a href="#method.reader" title="reader">reader</a></li><li><a href="#method.take" title="take">take</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Buf-for-%26%5Bu8%5D" title="&[u8]">&[u8]</a></li><li><a href="#impl-Buf-for-%26mut+T" title="&mut T">&mut T</a></li><li><a href="#impl-Buf-for-Box%3CT%3E" title="Box<T>">Box<T></a></li><li><a href="#impl-Buf-for-Cursor%3CT%3E" title="Cursor<T>">Cursor<T></a></li><li><a href="#impl-Buf-for-VecDeque%3Cu8%3E" title="VecDeque<u8>">VecDeque<u8></a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bytes::<wbr>buf</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">bytes</a>::<wbr><a href="index.html">buf</a></span><h1>Trait <span class="trait">Buf</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/bytes/buf/buf_impl.rs.html#99-1228">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Buf {
|
||
<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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'a>]) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../struct.Bytes.html" title="struct bytes::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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Take.html" title="struct bytes::buf::Take">Take</a><Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/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: <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a>>(self, next: U) -> <a class="struct" href="struct.Chain.html" title="struct bytes::buf::Chain">Chain</a><Self, U>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/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) -> <a class="struct" href="struct.Reader.html" title="struct bytes::buf::Reader">Reader</a><Self> <a href="#" class="tooltip" data-notable-ty="Reader<Self>">ⓘ</a>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#125">Source</a><h4 class="code-header">fn <a href="#tymethod.remaining" class="fn">remaining</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#158">Source</a><h4 class="code-header">fn <a href="#tymethod.chunk" class="fn">chunk</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/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 a 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. <code>chunk()</code> should return an empty
|
||
slice <strong>if and only if</strong> <code>remaining()</code> returns 0. In other words,
|
||
<code>chunk()</code> returning an empty slice implies that <code>remaining()</code> will
|
||
return 0 and <code>remaining()</code> returning 0 implies that <code>chunk()</code> will
|
||
return an empty slice.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.advance" class="method"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#232">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#189-200">Source</a><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/1.84.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'a>]) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a></h4></section></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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#251-253">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#276-290">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#308-315">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#333-340">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#358-360">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#378-380">Source</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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#401-403">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#421-423">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#441-443">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#464-466">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#484-486">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#504-506">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#527-529">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#547-549">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#567-569">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#590-592">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#610-612">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#630-632">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#653-655">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#673-675">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#693-695">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#716-718">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#736-738">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#756-758">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#779-781">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#799-801">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#819-821">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#842-844">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#862-864">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#882-884">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#906-912">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#931-933">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#952-954">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#976-982">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1001-1003">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1022-1024">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1046-1048">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1067-1069">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1088-1090">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1112-1114">Source</a><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/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1135-1145">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../struct.Bytes.html" title="struct bytes::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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1168-1173">Source</a><h4 class="code-header">fn <a href="#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="struct.Take.html" title="struct bytes::buf::Take">Take</a><Self><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1190-1195">Source</a><h4 class="code-header">fn <a href="#method.chain" class="fn">chain</a><U: <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a>>(self, next: U) -> <a class="struct" href="struct.Chain.html" title="struct bytes::buf::Chain">Chain</a><Self, U><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/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"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1222-1227">Source</a><h4 class="code-header">fn <a href="#method.reader" class="fn">reader</a>(self) -> <a class="struct" href="struct.Reader.html" title="struct bytes::buf::Reader">Reader</a><Self> <a href="#" class="tooltip" data-notable-ty="Reader<Self>">ⓘ</a><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></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 class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1408-1437">Source</a><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 bytes::buf::Buf">Buf</a> for &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]</h3></section></summary><div class="impl-items"><section id="method.remaining" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1410-1412">Source</a><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/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1415-1417">Source</a><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/1.84.1/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 class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1420-1426">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>)</h4></section><section id="method.copy_to_slice-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1429-1436">Source</a><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/1.84.1/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 class="src rightside" href="../../src/bytes/buf/vec_deque.rs.html#5-22">Source</a><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 bytes::buf::Buf">Buf</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/std/primitive.u8.html">u8</a>></h3></section></summary><div class="impl-items"><section id="method.remaining-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/vec_deque.rs.html#6-8">Source</a><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/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/vec_deque.rs.html#10-17">Source</a><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/1.84.1/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 class="src rightside" href="../../src/bytes/buf/vec_deque.rs.html#19-21">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>)</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Buf-for-Cursor%3CT%3E" class="impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1440-1468">Source</a><a href="#impl-Buf-for-Cursor%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>> <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/cursor/struct.Cursor.html" title="struct std::io::cursor::Cursor">Cursor</a><T></h3></section></summary><div class="impl-items"><section id="method.remaining-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1442-1444">Source</a><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/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1447-1451">Source</a><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/1.84.1/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.advance-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1454-1467">Source</a><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/1.84.1/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 class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1400-1402">Source</a><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 bytes::buf::Buf">Buf</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h3></section></summary><div class="impl-items"><section id="method.remaining-3" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-3" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.chunks_vectored-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'b>]) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.advance-3" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>)</h4></section><section id="method.has_remaining-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.bool.html">bool</a></h4></section><section id="method.copy_to_slice-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.u8.html">u8</a>])</h4></section><section id="method.get_u8-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.u8.html">u8</a></h4></section><section id="method.get_i8-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.i8.html">i8</a></h4></section><section id="method.get_u16-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u16_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_i16-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i16-1" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_i16_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i16_le-1" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_i16_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i16_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_u32-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u32-1" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_u32_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u32_le-1" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_u32_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u32_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_i32-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i32-1" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_i32_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i32_le-1" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_i32_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i32_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_u64-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u64-1" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_u64_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u64_le-1" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_u64_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_u64_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_i64-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i64-1" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_i64_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i64_le-1" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_i64_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_i64_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_uint-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_uint-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_uint_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_uint_le-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_uint_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_uint_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_int-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_int-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_int_le-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_int_le-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_int_ne-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.get_int_ne-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.copy_to_bytes-1" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1401">Source</a><a href="#method.copy_to_bytes-1" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Buf-for-Box%3CT%3E" class="impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1404-1406">Source</a><a href="#impl-Buf-for-Box%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><T></h3></section></summary><div class="impl-items"><section id="method.remaining-4" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.chunk-4" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.u8.html">u8</a>] <a href="#" class="tooltip" data-notable-ty="&[u8]">ⓘ</a></h4></section><section id="method.chunks_vectored-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'b>]) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a></h4></section><section id="method.advance-4" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.usize.html">usize</a>)</h4></section><section id="method.has_remaining-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.bool.html">bool</a></h4></section><section id="method.copy_to_slice-3" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.u8.html">u8</a>])</h4></section><section id="method.get_u8-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.u8.html">u8</a></h4></section><section id="method.get_i8-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.i8.html">i8</a></h4></section><section id="method.get_u16-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_u16_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u16_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.u16.html">u16</a></h4></section><section id="method.get_i16-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i16-2" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_i16_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i16_le-2" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_i16_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i16_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.i16.html">i16</a></h4></section><section id="method.get_u32-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u32-2" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_u32_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u32_le-2" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_u32_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u32_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.u32.html">u32</a></h4></section><section id="method.get_i32-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i32-2" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_i32_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i32_le-2" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_i32_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i32_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.i32.html">i32</a></h4></section><section id="method.get_u64-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u64-2" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_u64_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u64_le-2" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_u64_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_u64_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_i64-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i64-2" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_i64_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i64_le-2" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_i64_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_i64_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_uint-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_uint-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_uint_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_uint_le-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_uint_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_uint_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></h4></section><section id="method.get_int-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_int-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_int_le-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_int_le-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.get_int_ne-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.get_int_ne-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.i64.html">i64</a></h4></section><section id="method.copy_to_bytes-2" class="method trait-impl"><a class="src rightside" href="../../src/bytes/buf/buf_impl.rs.html#1405">Source</a><a href="#method.copy_to_bytes-2" class="anchor">§</a><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/1.84.1/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../struct.Bytes.html" title="struct bytes::Bytes">Bytes</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 class="src rightside" href="../../src/bytes/bytes.rs.html#698-726">Source</a><a href="#impl-Buf-for-Bytes" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="../struct.Bytes.html" title="struct bytes::Bytes">Bytes</a></h3></section><section id="impl-Buf-for-BytesMut" class="impl"><a class="src rightside" href="../../src/bytes/bytes_mut.rs.html#1140-1169">Source</a><a href="#impl-Buf-for-BytesMut" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="../struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a></h3></section><section id="impl-Buf-for-Chain%3CT,+U%3E" class="impl"><a class="src rightside" href="../../src/bytes/buf/chain.rs.html#130-189">Source</a><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 bytes::buf::Buf">Buf</a> for <a class="struct" href="struct.Chain.html" title="struct bytes::buf::Chain">Chain</a><T, U><div class="where">where
|
||
T: <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a>,
|
||
U: <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a>,</div></h3></section><section id="impl-Buf-for-Take%3CT%3E" class="impl"><a class="src rightside" href="../../src/bytes/buf/take.rs.html#132-155">Source</a><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 bytes::buf::Buf">Buf</a>> <a class="trait" href="trait.Buf.html" title="trait bytes::buf::Buf">Buf</a> for <a class="struct" href="struct.Take.html" title="struct bytes::buf::Take">Take</a><T></h3></section></div><script src="../../trait.impl/bytes/buf/buf_impl/trait.Buf.js" data-ignore-extern-crates="alloc,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/1.84.1/std/primitive.u8.html\">u8</a>]</code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &[<a class=\"primitive\" href=\"https://doc.rust-lang.org/1.84.1/std/primitive.u8.html\">u8</a>]</div>","Reader<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Reader.html\" title=\"struct bytes::buf::Reader\">Reader</a><B></code></h3><pre><code><div class=\"where\">impl<B: <a class=\"trait\" href=\"trait.Buf.html\" title=\"trait bytes::buf::Buf\">Buf</a> + <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html\" title=\"trait core::marker::Sized\">Sized</a>> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"struct.Reader.html\" title=\"struct bytes::buf::Reader\">Reader</a><B></div>"}</script></section></div></main></body></html> |