520 lines
79 KiB
HTML
520 lines
79 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="API documentation for the Rust `BufMut` trait in crate `bytes`."><meta name="keywords" content="rust, rustlang, rust-lang, BufMut"><title>bytes::BufMut - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../bytes/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Trait BufMut</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.advance_mut">advance_mut</a><a href="#tymethod.bytes_mut">bytes_mut</a><a href="#tymethod.remaining_mut">remaining_mut</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.by_ref">by_ref</a><a href="#method.bytes_vec_mut">bytes_vec_mut</a><a href="#method.has_remaining_mut">has_remaining_mut</a><a href="#method.put">put</a><a href="#method.put_f32_be">put_f32_be</a><a href="#method.put_f32_le">put_f32_le</a><a href="#method.put_f64_be">put_f64_be</a><a href="#method.put_f64_le">put_f64_le</a><a href="#method.put_i16_be">put_i16_be</a><a href="#method.put_i16_le">put_i16_le</a><a href="#method.put_i32_be">put_i32_be</a><a href="#method.put_i32_le">put_i32_le</a><a href="#method.put_i64_be">put_i64_be</a><a href="#method.put_i64_le">put_i64_le</a><a href="#method.put_i8">put_i8</a><a href="#method.put_int_be">put_int_be</a><a href="#method.put_int_le">put_int_le</a><a href="#method.put_slice">put_slice</a><a href="#method.put_u16_be">put_u16_be</a><a href="#method.put_u16_le">put_u16_le</a><a href="#method.put_u32_be">put_u32_be</a><a href="#method.put_u32_le">put_u32_le</a><a href="#method.put_u64_be">put_u64_be</a><a href="#method.put_u64_le">put_u64_le</a><a href="#method.put_u8">put_u8</a><a href="#method.put_uint_be">put_uint_be</a><a href="#method.put_uint_le">put_uint_le</a><a href="#method.writer">writer</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-BufMut-for-%26%27a%20mut%20T">&'a mut T</a><a href="#impl-BufMut-for-Box%3CT%3E">Box<T></a><a href="#impl-BufMut-for-Cursor%3CT%3E">Cursor<T></a><a href="#impl-BufMut-for-Vec%3Cu8%3E">Vec<u8></a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>bytes</a></p><script>window.sidebarCurrent = {name: 'BufMut', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#27-1064' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='index.html'>bytes</a>::<wbr><a class="trait" href=''>BufMut</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait BufMut {
|
||
fn <a href='#tymethod.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
<div class='item-spacer'></div> unsafe fn <a href='#tymethod.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>);
|
||
<div class='item-spacer'></div> unsafe fn <a href='#tymethod.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>;
|
||
|
||
fn <a href='#method.has_remaining_mut' class='fnname'>has_remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> { ... }
|
||
<div class='item-spacer'></div> unsafe fn <a href='#method.bytes_vec_mut' class='fnname'>bytes_vec_mut</a><'a>(<br> &'a mut self, <br> dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a>&'a mut <a class="struct" href="../iovec/struct.IoVec.html" title="struct iovec::IoVec">IoVec</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br> ) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put' class='fnname'>put</a><T: <a class="trait" href="../bytes/buf/trait.IntoBuf.html" title="trait bytes::buf::IntoBuf">IntoBuf</a>>(&mut self, src: T)<br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_slice' class='fnname'>put_slice</a>(&mut self, src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u8' class='fnname'>put_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i8' class='fnname'>put_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u16_be' class='fnname'>put_u16_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u16_le' class='fnname'>put_u16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i16_be' class='fnname'>put_i16_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i16_le' class='fnname'>put_i16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u32_be' class='fnname'>put_u32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u32_le' class='fnname'>put_u32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i32_be' class='fnname'>put_i32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i32_le' class='fnname'>put_i32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u64_be' class='fnname'>put_u64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_u64_le' class='fnname'>put_u64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i64_be' class='fnname'>put_i64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_i64_le' class='fnname'>put_i64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_uint_be' class='fnname'>put_uint_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_uint_le' class='fnname'>put_uint_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_int_be' class='fnname'>put_int_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_int_le' class='fnname'>put_int_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_f32_be' class='fnname'>put_f32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_f32_le' class='fnname'>put_f32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_f64_be' class='fnname'>put_f64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.put_f64_le' class='fnname'>put_f64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self<br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
|
||
{ ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.writer' class='fnname'>writer</a>(self) -> <a class="struct" href="../bytes/buf/struct.Writer.html" title="struct bytes::buf::Writer">Writer</a><Self><br> <span class="where">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
|
||
{ ... }
|
||
}</pre></div><div class='docblock'><p>A trait for values that provide sequential write access to bytes.</p>
|
||
<p>Write bytes to a buffer</p>
|
||
<p>A buffer stores bytes in memory such that write operations are infallible.
|
||
The underlying storage may or may not be in contiguous memory. A <code>BufMut</code>
|
||
value is a cursor into the buffer. Writing to <code>BufMut</code> advances the cursor
|
||
position.</p>
|
||
<p>The simplest <code>BufMut</code> is a <code>Vec<u8></code>.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="string">"hello world"</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"hello world"</span>);</pre></div>
|
||
</div>
|
||
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.remaining_mut' class='method'><code id='remaining_mut.v'>fn <a href='#tymethod.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></h3><div class='docblock'><p>Returns the number of bytes that can be written from the current
|
||
position until the end of the buffer is reached.</p>
|
||
<p>This value is greater than or equal to the length of the slice returned
|
||
by <code>bytes_mut</code>.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">10</span>];
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>[..]);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">10</span>, <span class="ident">buf</span>.<span class="ident">remaining_mut</span>());
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="string">"hello"</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">5</span>, <span class="ident">buf</span>.<span class="ident">remaining_mut</span>());</pre></div>
|
||
<h1 id="implementer-notes" class="section-header"><a href="#implementer-notes">Implementer notes</a></h1>
|
||
<p>Implementations of <code>remaining_mut</code> should ensure that the return value
|
||
does not change unless a call is made to <code>advance_mut</code> or any other
|
||
function that is documented to change the <code>BufMut</code>'s current position.</p>
|
||
</div><h3 id='tymethod.advance_mut' class='method'><code id='advance_mut.v'>unsafe fn <a href='#tymethod.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></h3><div class='docblock'><p>Advance the internal cursor of the BufMut</p>
|
||
<p>The next call to <code>bytes_mut</code> will return a slice starting <code>cnt</code> bytes
|
||
further into the underlying buffer.</p>
|
||
<p>This function is unsafe because there is no guarantee that the bytes
|
||
being advanced past have been initialized.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">16</span>);
|
||
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">0</span>] <span class="op">=</span> <span class="string">b'h'</span>;
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">1</span>] <span class="op">=</span> <span class="string">b'e'</span>;
|
||
|
||
<span class="ident">buf</span>.<span class="ident">advance_mut</span>(<span class="number">2</span>);
|
||
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">0</span>] <span class="op">=</span> <span class="string">b'l'</span>;
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">1</span>..<span class="number">3</span>].<span class="ident">copy_from_slice</span>(<span class="string">b"lo"</span>);
|
||
|
||
<span class="ident">buf</span>.<span class="ident">advance_mut</span>(<span class="number">3</span>);
|
||
}
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">5</span>, <span class="ident">buf</span>.<span class="ident">len</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"hello"</span>);</pre></div>
|
||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||
<p>This function <strong>may</strong> panic if <code>cnt > self.remaining_mut()</code>.</p>
|
||
<h1 id="implementer-notes-1" class="section-header"><a href="#implementer-notes-1">Implementer notes</a></h1>
|
||
<p>It is recommended for implementations of <code>advance_mut</code> to panic if
|
||
<code>cnt > self.remaining_mut()</code>. If the implementation does not panic,
|
||
the call must behave as if <code>cnt == self.remaining_mut()</code>.</p>
|
||
<p>A call with <code>cnt == 0</code> should never panic and be a no-op.</p>
|
||
</div><h3 id='tymethod.bytes_mut' class='method'><code id='bytes_mut.v'>unsafe fn <a href='#tymethod.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code></h3><div class='docblock'><p>Returns a mutable slice starting at the current BufMut position and of
|
||
length between 0 and <code>BufMut::remaining_mut()</code>. Note that this <em>can</em> be shorter than the
|
||
whole remainder of the buffer (this allows non-continuous implementation).</p>
|
||
<p>This is a lower level function. Most operations are done with other
|
||
functions.</p>
|
||
<p>The returned byte slice may represent uninitialized memory.</p>
|
||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">16</span>);
|
||
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">0</span>] <span class="op">=</span> <span class="string">b'h'</span>;
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">1</span>] <span class="op">=</span> <span class="string">b'e'</span>;
|
||
|
||
<span class="ident">buf</span>.<span class="ident">advance_mut</span>(<span class="number">2</span>);
|
||
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">0</span>] <span class="op">=</span> <span class="string">b'l'</span>;
|
||
<span class="ident">buf</span>.<span class="ident">bytes_mut</span>()[<span class="number">1</span>..<span class="number">3</span>].<span class="ident">copy_from_slice</span>(<span class="string">b"lo"</span>);
|
||
|
||
<span class="ident">buf</span>.<span class="ident">advance_mut</span>(<span class="number">3</span>);
|
||
}
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">5</span>, <span class="ident">buf</span>.<span class="ident">len</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"hello"</span>);</pre></div>
|
||
<h1 id="implementer-notes-2" class="section-header"><a href="#implementer-notes-2">Implementer notes</a></h1>
|
||
<p>This function should never panic. <code>bytes_mut</code> should return an empty
|
||
slice <strong>if and only if</strong> <code>remaining_mut</code> returns 0. In other words,
|
||
<code>bytes_mut</code> returning an empty slice implies that <code>remaining_mut</code> will
|
||
return 0 and <code>remaining_mut</code> returning 0 implies that <code>bytes_mut</code> will
|
||
return an empty slice.</p>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='provided-methods' class='small-section-header'>Provided methods<a href='#provided-methods' class='anchor'></a></h2><div class='methods'><h3 id='method.has_remaining_mut' class='method'><code id='has_remaining_mut.v'>fn <a href='#method.has_remaining_mut' class='fnname'>has_remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></h3><div class='docblock'><p>Returns true if there is space in <code>self</code> for more bytes.</p>
|
||
<p>This is equivalent to <code>self.remaining_mut() != 0</code>.</p>
|
||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">5</span>];
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>);
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">buf</span>.<span class="ident">has_remaining_mut</span>());
|
||
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="string">"hello"</span>);
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">buf</span>.<span class="ident">has_remaining_mut</span>());</pre></div>
|
||
</div><h3 id='method.bytes_vec_mut' class='method'><code id='bytes_vec_mut.v'>unsafe fn <a href='#method.bytes_vec_mut' class='fnname'>bytes_vec_mut</a><'a>(&'a mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a>&'a mut <a class="struct" href="../iovec/struct.IoVec.html" title="struct iovec::IoVec">IoVec</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></h3><div class='docblock'><p>Fills <code>dst</code> with potentially multiple mutable slices starting at <code>self</code>'s
|
||
current position.</p>
|
||
<p>If the <code>BufMut</code> is backed by disjoint slices of bytes, <code>bytes_vec_mut</code>
|
||
enables fetching more than one slice at once. <code>dst</code> is a slice of
|
||
mutable <code>IoVec</code> references, enabling the slice to be directly used with
|
||
<a href="http://man7.org/linux/man-pages/man2/readv.2.html"><code>readv</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_mut()</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>bytes_vec_mut</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>
|
||
<h1 id="implementer-notes-3" class="section-header"><a href="#implementer-notes-3">Implementer notes</a></h1>
|
||
<p>This function should never panic. Once the end of the buffer is reached,
|
||
i.e., <code>BufMut::remaining_mut</code> returns 0, calls to <code>bytes_vec_mut</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><h3 id='method.put' class='method'><code id='put.v'>fn <a href='#method.put' class='fnname'>put</a><T: <a class="trait" href="../bytes/buf/trait.IntoBuf.html" title="trait bytes::buf::IntoBuf">IntoBuf</a>>(&mut self, src: T) <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code></h3><div class='docblock'><p>Transfer bytes into <code>self</code> from <code>src</code> and advance the cursor by the
|
||
number of bytes written.</p>
|
||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="string">b'h'</span>);
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="kw-2">&</span><span class="string">b"ello"</span>[..]);
|
||
<span class="ident">buf</span>.<span class="ident">put</span>(<span class="string">" world"</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"hello world"</span>);</pre></div>
|
||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||
<p>Panics if <code>self</code> does not have enough capacity to contain <code>src</code>.</p>
|
||
</div><h3 id='method.put_slice' class='method'><code id='put_slice.v'>fn <a href='#method.put_slice' class='fnname'>put_slice</a>(&mut self, src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></h3><div class='docblock'><p>Transfer bytes into <code>self</code> from <code>src</code> and advance the cursor by the
|
||
number of bytes written.</p>
|
||
<p><code>self</code> must have enough remaining capacity to contain all of <code>src</code>.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">6</span>];
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>);
|
||
<span class="ident">buf</span>.<span class="ident">put_slice</span>(<span class="string">b"hello"</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1</span>, <span class="ident">buf</span>.<span class="ident">remaining_mut</span>());
|
||
}
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">b"hello\0"</span>, <span class="kw-2">&</span><span class="ident">dst</span>);</pre></div>
|
||
</div><h3 id='method.put_u8' class='method'><code id='put_u8.v'>fn <a href='#method.put_u8' class='fnname'>put_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>)</code></h3><div class='docblock'><p>Writes an unsigned 8 bit integer to <code>self</code>.</p>
|
||
<p>The current position is advanced by 1.</p>
|
||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u8</span>(<span class="number">0x01</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01"</span>);</pre></div>
|
||
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i8' class='method'><code id='put_i8.v'>fn <a href='#method.put_i8' class='fnname'>put_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>)</code></h3><div class='docblock'><p>Writes a signed 8 bit integer to <code>self</code>.</p>
|
||
<p>The current position is advanced by 1.</p>
|
||
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i8</span>(<span class="number">0x01</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01"</span>);</pre></div>
|
||
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u16_be' class='method'><code id='put_u16_be.v'>fn <a href='#method.put_u16_be' class='fnname'>put_u16_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>)</code></h3><div class='docblock'><p>Writes an unsigned 16 bit integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 2.</p>
|
||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u16_be</span>(<span class="number">0x0809</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x09"</span>);</pre></div>
|
||
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u16_le' class='method'><code id='put_u16_le.v'>fn <a href='#method.put_u16_le' class='fnname'>put_u16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>)</code></h3><div class='docblock'><p>Writes an unsigned 16 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 2.</p>
|
||
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u16_le</span>(<span class="number">0x0809</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x09\x08"</span>);</pre></div>
|
||
<h1 id="panics-5" class="section-header"><a href="#panics-5">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i16_be' class='method'><code id='put_i16_be.v'>fn <a href='#method.put_i16_be' class='fnname'>put_i16_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>)</code></h3><div class='docblock'><p>Writes a signed 16 bit integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 2.</p>
|
||
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i16_be</span>(<span class="number">0x0809</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x09"</span>);</pre></div>
|
||
<h1 id="panics-6" class="section-header"><a href="#panics-6">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i16_le' class='method'><code id='put_i16_le.v'>fn <a href='#method.put_i16_le' class='fnname'>put_i16_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>)</code></h3><div class='docblock'><p>Writes a signed 16 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 2.</p>
|
||
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i16_le</span>(<span class="number">0x0809</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x09\x08"</span>);</pre></div>
|
||
<h1 id="panics-7" class="section-header"><a href="#panics-7">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u32_be' class='method'><code id='put_u32_be.v'>fn <a href='#method.put_u32_be' class='fnname'>put_u32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></h3><div class='docblock'><p>Writes an unsigned 32 bit integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u32_be</span>(<span class="number">0x0809A0A1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x09\xA0\xA1"</span>);</pre></div>
|
||
<h1 id="panics-8" class="section-header"><a href="#panics-8">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u32_le' class='method'><code id='put_u32_le.v'>fn <a href='#method.put_u32_le' class='fnname'>put_u32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></h3><div class='docblock'><p>Writes an unsigned 32 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u32_le</span>(<span class="number">0x0809A0A1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\xA1\xA0\x09\x08"</span>);</pre></div>
|
||
<h1 id="panics-9" class="section-header"><a href="#panics-9">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i32_be' class='method'><code id='put_i32_be.v'>fn <a href='#method.put_i32_be' class='fnname'>put_i32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></h3><div class='docblock'><p>Writes a signed 32 bit integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i32_be</span>(<span class="number">0x0809A0A1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x09\xA0\xA1"</span>);</pre></div>
|
||
<h1 id="panics-10" class="section-header"><a href="#panics-10">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i32_le' class='method'><code id='put_i32_le.v'>fn <a href='#method.put_i32_le' class='fnname'>put_i32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></h3><div class='docblock'><p>Writes a signed 32 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i32_le</span>(<span class="number">0x0809A0A1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\xA1\xA0\x09\x08"</span>);</pre></div>
|
||
<h1 id="panics-11" class="section-header"><a href="#panics-11">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u64_be' class='method'><code id='put_u64_be.v'>fn <a href='#method.put_u64_be' class='fnname'>put_u64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>)</code></h3><div class='docblock'><p>Writes an unsigned 64 bit integer to <code>self</code> in the big-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u64_be</span>(<span class="number">0x0102030405060708</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08"</span>);</pre></div>
|
||
<h1 id="panics-12" class="section-header"><a href="#panics-12">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_u64_le' class='method'><code id='put_u64_le.v'>fn <a href='#method.put_u64_le' class='fnname'>put_u64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>)</code></h3><div class='docblock'><p>Writes an unsigned 64 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_u64_le</span>(<span class="number">0x0102030405060708</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01"</span>);</pre></div>
|
||
<h1 id="panics-13" class="section-header"><a href="#panics-13">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i64_be' class='method'><code id='put_i64_be.v'>fn <a href='#method.put_i64_be' class='fnname'>put_i64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>)</code></h3><div class='docblock'><p>Writes a signed 64 bit integer to <code>self</code> in the big-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i64_be</span>(<span class="number">0x0102030405060708</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01\x02\x03\x04\x05\x06\x07\x08"</span>);</pre></div>
|
||
<h1 id="panics-14" class="section-header"><a href="#panics-14">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_i64_le' class='method'><code id='put_i64_le.v'>fn <a href='#method.put_i64_le' class='fnname'>put_i64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>)</code></h3><div class='docblock'><p>Writes a signed 64 bit integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_i64_le</span>(<span class="number">0x0102030405060708</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x08\x07\x06\x05\x04\x03\x02\x01"</span>);</pre></div>
|
||
<h1 id="panics-15" class="section-header"><a href="#panics-15">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_uint_be' class='method'><code id='put_uint_be.v'>fn <a href='#method.put_uint_be' class='fnname'>put_uint_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></h3><div class='docblock'><p>Writes an unsigned n-byte integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by <code>nbytes</code>.</p>
|
||
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_uint_be</span>(<span class="number">0x010203</span>, <span class="number">3</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01\x02\x03"</span>);</pre></div>
|
||
<h1 id="panics-16" class="section-header"><a href="#panics-16">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_uint_le' class='method'><code id='put_uint_le.v'>fn <a href='#method.put_uint_le' class='fnname'>put_uint_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></h3><div class='docblock'><p>Writes an unsigned n-byte integer to <code>self</code> in the little-endian byte order.</p>
|
||
<p>The current position is advanced by <code>nbytes</code>.</p>
|
||
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_uint_le</span>(<span class="number">0x010203</span>, <span class="number">3</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x03\x02\x01"</span>);</pre></div>
|
||
<h1 id="panics-17" class="section-header"><a href="#panics-17">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_int_be' class='method'><code id='put_int_be.v'>fn <a href='#method.put_int_be' class='fnname'>put_int_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></h3><div class='docblock'><p>Writes a signed n-byte integer to <code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by <code>nbytes</code>.</p>
|
||
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_int_be</span>(<span class="number">0x010203</span>, <span class="number">3</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x01\x02\x03"</span>);</pre></div>
|
||
<h1 id="panics-18" class="section-header"><a href="#panics-18">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_int_le' class='method'><code id='put_int_le.v'>fn <a href='#method.put_int_le' class='fnname'>put_int_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></h3><div class='docblock'><p>Writes a signed n-byte integer to <code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by <code>nbytes</code>.</p>
|
||
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_int_le</span>(<span class="number">0x010203</span>, <span class="number">3</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x03\x02\x01"</span>);</pre></div>
|
||
<h1 id="panics-19" class="section-header"><a href="#panics-19">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_f32_be' class='method'><code id='put_f32_be.v'>fn <a href='#method.put_f32_be' class='fnname'>put_f32_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>)</code></h3><div class='docblock'><p>Writes an IEEE754 single-precision (4 bytes) floating point number to
|
||
<code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_f32_be</span>(<span class="number">1.2f32</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x3F\x99\x99\x9A"</span>);</pre></div>
|
||
<h1 id="panics-20" class="section-header"><a href="#panics-20">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_f32_le' class='method'><code id='put_f32_le.v'>fn <a href='#method.put_f32_le' class='fnname'>put_f32_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>)</code></h3><div class='docblock'><p>Writes an IEEE754 single-precision (4 bytes) floating point number to
|
||
<code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 4.</p>
|
||
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_f32_le</span>(<span class="number">1.2f32</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x9A\x99\x99\x3F"</span>);</pre></div>
|
||
<h1 id="panics-21" class="section-header"><a href="#panics-21">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_f64_be' class='method'><code id='put_f64_be.v'>fn <a href='#method.put_f64_be' class='fnname'>put_f64_be</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>)</code></h3><div class='docblock'><p>Writes an IEEE754 double-precision (8 bytes) floating point number to
|
||
<code>self</code> in big-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_f64_be</span>(<span class="number">1.2f64</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x3F\xF3\x33\x33\x33\x33\x33\x33"</span>);</pre></div>
|
||
<h1 id="panics-22" class="section-header"><a href="#panics-22">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.put_f64_le' class='method'><code id='put_f64_le.v'>fn <a href='#method.put_f64_le' class='fnname'>put_f64_le</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>)</code></h3><div class='docblock'><p>Writes an IEEE754 double-precision (8 bytes) floating point number to
|
||
<code>self</code> in little-endian byte order.</p>
|
||
<p>The current position is advanced by 8.</p>
|
||
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
<span class="ident">buf</span>.<span class="ident">put_f64_le</span>(<span class="number">1.2f64</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">b"\x33\x33\x33\x33\x33\x33\xF3\x3F"</span>);</pre></div>
|
||
<h1 id="panics-23" class="section-header"><a href="#panics-23">Panics</a></h1>
|
||
<p>This function panics if there is not enough remaining capacity in
|
||
<code>self</code>.</p>
|
||
</div><h3 id='method.by_ref' class='method'><code id='by_ref.v'>fn <a href='#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code></h3><div class='docblock'><p>Creates a "by reference" adaptor for this instance of <code>BufMut</code>.</p>
|
||
<p>The returned adapter also implements <code>BufMut</code> and will simply borrow
|
||
<code>self</code>.</p>
|
||
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">reference</span> <span class="op">=</span> <span class="ident">buf</span>.<span class="ident">by_ref</span>();
|
||
|
||
<span class="comment">// Adapt reference to `std::io::Write`.</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">writer</span> <span class="op">=</span> <span class="ident">reference</span>.<span class="ident">writer</span>();
|
||
|
||
<span class="comment">// Use the buffer as a writter</span>
|
||
<span class="ident">io</span>::<span class="ident">Write</span>::<span class="ident">write</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">writer</span>, <span class="kw-2">&</span><span class="string">b"hello world"</span>[..]).<span class="ident">unwrap</span>();
|
||
} <span class="comment">// drop our &mut reference so that we can use `buf` again</span>
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="kw-2">&</span><span class="string">b"hello world"</span>[..]);</pre></div>
|
||
</div><h3 id='method.writer' class='method'><code id='writer.v'>fn <a href='#method.writer' class='fnname'>writer</a>(self) -> <a class="struct" href="../bytes/buf/struct.Writer.html" title="struct bytes::buf::Writer">Writer</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code></h3><div class='docblock'><p>Creates an adaptor which implements the <code>Write</code> trait for <code>self</code>.</p>
|
||
<p>This function returns a new value which implements <code>Write</code> by adapting
|
||
the <code>Write</code> trait functions to the <code>BufMut</code> trait functions. Given that
|
||
<code>BufMut</code> operations are infallible, none of the <code>Write</code> functions will
|
||
return with <code>Err</code>.</p>
|
||
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">bytes</span>::<span class="ident">BufMut</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Write</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[].<span class="ident">writer</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">num</span> <span class="op">=</span> <span class="ident">buf</span>.<span class="ident">write</span>(<span class="kw-2">&</span><span class="string">b"hello world"</span>[..]).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">11</span>, <span class="ident">num</span>);
|
||
|
||
<span class="kw">let</span> <span class="ident">buf</span> <span class="op">=</span> <span class="ident">buf</span>.<span class="ident">into_inner</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">*</span><span class="ident">buf</span>, <span class="string">b"hello world"</span>[..]);</pre></div>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='foreign-impls' class='small-section-header'>Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a></h2><h3 id='impl-BufMut-for-%26%27a%20mut%20T' class='impl'><code class='in-band'>impl<'a, T: <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>T</code><a href='#impl-BufMut-for-%26%27a%20mut%20T' class='anchor'></a><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1066-1082' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut' class="method hidden"><code id='remaining_mut.v-1'>fn <a href='#method.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1067-1069' title='goto source code'>[src]</a></h4><h4 id='method.bytes_mut' class="method hidden"><code id='bytes_mut.v-1'>unsafe fn <a href='#method.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1071-1073' title='goto source code'>[src]</a></h4><h4 id='method.bytes_vec_mut-1' class="method hidden"><code id='bytes_vec_mut.v-1'>unsafe fn <a href='#method.bytes_vec_mut' class='fnname'>bytes_vec_mut</a><'b>(&'b mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a>&'b mut <a class="struct" href="../iovec/struct.IoVec.html" title="struct iovec::IoVec">IoVec</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1075-1077' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut' class="method hidden"><code id='advance_mut.v-1'>unsafe fn <a href='#method.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1079-1081' title='goto source code'>[src]</a></h4></div><h3 id='impl-BufMut-for-Box%3CT%3E' class='impl'><code class='in-band'>impl<T: <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><T></code><a href='#impl-BufMut-for-Box%3CT%3E' class='anchor'></a><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1084-1100' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut-1' class="method hidden"><code id='remaining_mut.v-2'>fn <a href='#method.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1085-1087' title='goto source code'>[src]</a></h4><h4 id='method.bytes_mut-1' class="method hidden"><code id='bytes_mut.v-2'>unsafe fn <a href='#method.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1089-1091' title='goto source code'>[src]</a></h4><h4 id='method.bytes_vec_mut-2' class="method hidden"><code id='bytes_vec_mut.v-2'>unsafe fn <a href='#method.bytes_vec_mut' class='fnname'>bytes_vec_mut</a><'b>(&'b mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a>&'b mut <a class="struct" href="../iovec/struct.IoVec.html" title="struct iovec::IoVec">IoVec</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1093-1095' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut-1' class="method hidden"><code id='advance_mut.v-2'>unsafe fn <a href='#method.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1097-1099' title='goto source code'>[src]</a></h4></div><h3 id='impl-BufMut-for-Cursor%3CT%3E' class='impl'><code class='in-band'>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>> <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/cursor/struct.Cursor.html" title="struct std::io::cursor::Cursor">Cursor</a><T></code><a href='#impl-BufMut-for-Cursor%3CT%3E' class='anchor'></a><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1102-1128' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut-2' class="method hidden"><code id='remaining_mut.v-3'>fn <a href='#method.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1103-1106' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut-2' class="method"><code id='advance_mut.v-3'>unsafe fn <a href='#method.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1109-1112' title='goto source code'>[src]</a></h4><div class='docblock'><p>Advance the internal cursor of the BufMut</p>
|
||
</div><h4 id='method.bytes_mut-2' class="method"><code id='bytes_mut.v-3'>unsafe fn <a href='#method.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1118-1127' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a mutable slice starting at the current BufMut position and of
|
||
length between 0 and <code>BufMut::remaining()</code>.</p>
|
||
<p>The returned byte slice may represent uninitialized memory.</p>
|
||
</div></div><h3 id='impl-BufMut-for-Vec%3Cu8%3E' class='impl'><code class='in-band'>impl <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></code><a href='#impl-BufMut-for-Vec%3Cu8%3E' class='anchor'></a><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1130-1163' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut-3' class="method hidden"><code id='remaining_mut.v-4'>fn <a href='#method.remaining_mut' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1132-1134' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut-3' class="method hidden"><code id='advance_mut.v-4'>unsafe fn <a href='#method.advance_mut' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1137-1147' title='goto source code'>[src]</a></h4><h4 id='method.bytes_mut-3' class="method hidden"><code id='bytes_mut.v-4'>unsafe fn <a href='#method.bytes_mut' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/buf/buf_mut.rs.html#1150-1162' title='goto source code'>[src]</a></h4></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'><h3 id='impl-BufMut' class='impl'><code class='in-band'>impl BufMut for <a class="struct" href="../bytes/struct.BytesMut.html" title="struct bytes::BytesMut">BytesMut</a></code><a href='#impl-BufMut' class='anchor'></a><a class='srclink' href='../src/bytes/bytes.rs.html#1518-1561' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut-4' class="method hidden"><code id='remaining_mut.v-5'>fn <a href='#method.remaining_mut-4' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/bytes.rs.html#1520-1522' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut-4' class="method hidden"><code id='advance_mut.v-5'>unsafe fn <a href='#method.advance_mut-4' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/bytes.rs.html#1525-1530' title='goto source code'>[src]</a></h4><h4 id='method.bytes_mut-4' class="method hidden"><code id='bytes_mut.v-5'>unsafe fn <a href='#method.bytes_mut-4' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/bytes.rs.html#1533-1538' title='goto source code'>[src]</a></h4><h4 id='method.put_slice-1' class="method hidden"><code id='put_slice.v-1'>fn <a href='#method.put_slice-1' class='fnname'>put_slice</a>(&mut self, src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code><a class='srclink' href='../src/bytes/bytes.rs.html#1541-1550' title='goto source code'>[src]</a></h4><h4 id='method.put_u8-1' class="method hidden"><code id='put_u8.v-1'>fn <a href='#method.put_u8-1' class='fnname'>put_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>)</code><a class='srclink' href='../src/bytes/bytes.rs.html#1553-1555' title='goto source code'>[src]</a></h4><h4 id='method.put_i8-1' class="method hidden"><code id='put_i8.v-1'>fn <a href='#method.put_i8-1' class='fnname'>put_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>)</code><a class='srclink' href='../src/bytes/bytes.rs.html#1558-1560' title='goto source code'>[src]</a></h4></div><h3 id='impl-BufMut-1' class='impl'><code class='in-band'>impl<T, U> BufMut for <a class="struct" href="../bytes/buf/struct.Chain.html" title="struct bytes::buf::Chain">Chain</a><T, U> <span class="where fmt-newline">where<br> T: <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a>,<br> U: <a class="trait" href="../bytes/buf/trait.BufMut.html" title="trait bytes::buf::BufMut">BufMut</a>, </span></code><a href='#impl-BufMut-1' class='anchor'></a><a class='srclink' href='../src/bytes/buf/chain.rs.html#187-226' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.remaining_mut-5' class="method hidden"><code id='remaining_mut.v-6'>fn <a href='#method.remaining_mut-5' class='fnname'>remaining_mut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/chain.rs.html#191-193' title='goto source code'>[src]</a></h4><h4 id='method.bytes_mut-5' class="method hidden"><code id='bytes_mut.v-6'>unsafe fn <a href='#method.bytes_mut-5' class='fnname'>bytes_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../src/bytes/buf/chain.rs.html#195-201' title='goto source code'>[src]</a></h4><h4 id='method.advance_mut-5' class="method hidden"><code id='advance_mut.v-6'>unsafe fn <a href='#method.advance_mut-5' class='fnname'>advance_mut</a>(&mut self, cnt: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='../src/bytes/buf/chain.rs.html#203-219' title='goto source code'>[src]</a></h4><h4 id='method.bytes_vec_mut-3' class="method hidden"><code id='bytes_vec_mut.v-3'>unsafe fn <a href='#method.bytes_vec_mut-3' class='fnname'>bytes_vec_mut</a><'a>(&'a mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a>&'a mut <a class="struct" href="../iovec/struct.IoVec.html" title="struct iovec::IoVec">IoVec</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../src/bytes/buf/chain.rs.html#221-225' title='goto source code'>[src]</a></h4></div></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../implementors/bytes/trait.BufMut.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "bytes";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |