| <!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="An encoding as defined in the Encoding Standard."><meta name="keywords" content="rust, rustlang, rust-lang, Encoding"><title>Encoding in encoding_rs - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[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">☰</button><a class="sidebar-logo" href="../encoding_rs/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../encoding_rs/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Encoding</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.ascii_valid_up_to">ascii_valid_up_to</a></li><li><a href="#method.can_encode_everything">can_encode_everything</a></li><li><a href="#method.decode">decode</a></li><li><a href="#method.decode_with_bom_removal">decode_with_bom_removal</a></li><li><a href="#method.decode_without_bom_handling">decode_without_bom_handling</a></li><li><a href="#method.decode_without_bom_handling_and_without_replacement">decode_without_bom_handling_and_without_replacement</a></li><li><a href="#method.encode">encode</a></li><li><a href="#method.for_bom">for_bom</a></li><li><a href="#method.for_label">for_label</a></li><li><a href="#method.for_label_no_replacement">for_label_no_replacement</a></li><li><a href="#method.is_ascii_compatible">is_ascii_compatible</a></li><li><a href="#method.is_single_byte">is_single_byte</a></li><li><a href="#method.iso_2022_jp_ascii_valid_up_to">iso_2022_jp_ascii_valid_up_to</a></li><li><a href="#method.name">name</a></li><li><a href="#method.new_decoder">new_decoder</a></li><li><a href="#method.new_decoder_with_bom_removal">new_decoder_with_bom_removal</a></li><li><a href="#method.new_decoder_without_bom_handling">new_decoder_without_bom_handling</a></li><li><a href="#method.new_encoder">new_encoder</a></li><li><a href="#method.output_encoding">output_encoding</a></li><li><a href="#method.utf8_valid_up_to">utf8_valid_up_to</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-Encoding">Debug</a></li><li><a href="#impl-Eq-for-Encoding">Eq</a></li><li><a href="#impl-Hash-for-Encoding">Hash</a></li><li><a href="#impl-PartialEq%3CEncoding%3E-for-Encoding">PartialEq<Encoding></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Encoding">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Encoding">Send</a></li><li><a href="#impl-Sync-for-Encoding">Sync</a></li><li><a href="#impl-Unpin-for-Encoding">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Encoding">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Encoding">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Encoding">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Encoding">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Encoding">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Encoding">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-Encoding">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Encoding">TryInto<U></a></li></ul></section><h2><a href="index.html">In encoding_rs</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">encoding_rs</a>::<wbr><a class="struct" href="#">Encoding</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/encoding_rs/lib.rs.html#2680-2683">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Encoding { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An encoding as defined in the <a href="https://encoding.spec.whatwg.org/">Encoding Standard</a>.</p> |
| <p>An <em>encoding</em> defines a mapping from a <code>u8</code> sequence to a <code>char</code> sequence |
| and, in most cases, vice versa. Each encoding has a name, an output |
| encoding, and one or more labels.</p> |
| <p><em>Labels</em> are ASCII-case-insensitive strings that are used to identify an |
| encoding in formats and protocols. The <em>name</em> of the encoding is the |
| preferred label in the case appropriate for returning from the |
| <a href="https://dom.spec.whatwg.org/#dom-document-characterset"><code>characterSet</code></a> property of the <code>Document</code> DOM interface.</p> |
| <p>The <em>output encoding</em> is the encoding used for form submission and URL |
| parsing on Web pages in the encoding. This is UTF-8 for the replacement, |
| UTF-16LE and UTF-16BE encodings and the encoding itself for other |
| encodings.</p> |
| <h2 id="streaming-vs-non-streaming"><a href="#streaming-vs-non-streaming">Streaming vs. Non-Streaming</a></h2> |
| <p>When you have the entire input in a single buffer, you can use the |
| methods <a href="#method.decode"><code>decode()</code></a>, <a href="#method.decode"><code>decode_with_bom_removal()</code></a>, |
| <a href="#method.decode_without_bom_handling"><code>decode_without_bom_handling()</code></a>, |
| <a href="#method.decode_without_bom_handling_and_without_replacement"><code>decode_without_bom_handling_and_without_replacement()</code></a> and |
| <a href="#method.encode"><code>encode()</code></a>. (These methods are available to Rust callers only and are |
| not available in the C API.) Unlike the rest of the API available to Rust, |
| these methods perform heap allocations. You should the <code>Decoder</code> and |
| <code>Encoder</code> objects when your input is split into multiple buffers or when |
| you want to control the allocation of the output buffers.</p> |
| <h2 id="instances"><a href="#instances">Instances</a></h2> |
| <p>All instances of <code>Encoding</code> are statically allocated and have the <code>'static</code> |
| lifetime. There is precisely one unique <code>Encoding</code> instance for each |
| encoding defined in the Encoding Standard.</p> |
| <p>To obtain a reference to a particular encoding whose identity you know at |
| compile time, use a <code>static</code> that refers to encoding. There is a <code>static</code> |
| for each encoding. The <code>static</code>s are named in all caps with hyphens |
| replaced with underscores (and in C/C++ have <code>_ENCODING</code> appended to the |
| name). For example, if you know at compile time that you will want to |
| decode using the UTF-8 encoding, use the <code>UTF_8</code> <code>static</code> (<code>UTF_8_ENCODING</code> |
| in C/C++).</p> |
| <p>Additionally, there are non-reference-typed forms ending with <code>_INIT</code> to |
| work around the problem that <code>static</code>s of the type <code>&'static Encoding</code> |
| cannot be used to initialize items of an array whose type is |
| <code>[&'static Encoding; N]</code>.</p> |
| <p>If you don’t know what encoding you need at compile time and need to |
| dynamically get an encoding by label, use |
| <code>Encoding::<a href="#method.for_label">for_label</a>(<var>label</var>)</code>.</p> |
| <p>Instances of <code>Encoding</code> can be compared with <code>==</code> (in both Rust and in |
| C/C++).</p> |
| </div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Encoding" class="impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2685-3425">source</a><a href="#impl-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_label" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2721-2826">source</a><h4 class="code-header">pub fn <a href="#method.for_label" class="fnname">for_label</a>(label: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>></h4></section></summary><div class="docblock"><p>Implements the |
| <a href="https://encoding.spec.whatwg.org/#concept-encoding-get"><em>get an encoding</em></a> |
| algorithm.</p> |
| <p>If, after ASCII-lowercasing and removing leading and trailing |
| whitespace, the argument matches a label defined in the Encoding |
| Standard, <code>Some(&'static Encoding)</code> representing the corresponding |
| encoding is returned. If there is no match, <code>None</code> is returned.</p> |
| <p>This is the right method to use if the action upon the method returning |
| <code>None</code> is to use a fallback encoding (e.g. <code>WINDOWS_1252</code>) instead. |
| When the action upon the method returning <code>None</code> is not to proceed with |
| a fallback but to refuse processing, <code>for_label_no_replacement()</code> is more |
| appropriate.</p> |
| <p>The argument is of type <code>&[u8]</code> instead of <code>&str</code> to save callers |
| that are extracting the label from a non-UTF-8 protocol the trouble |
| of conversion to UTF-8. (If you have a <code>&str</code>, just call <code>.as_bytes()</code> |
| on it.)</p> |
| <p>Available via the C wrapper.</p> |
| <h5 id="example"><a href="#example">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>encoding_rs::Encoding; |
| |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(encoding_rs::UTF_8), Encoding::for_label(<span class="string">b"utf-8"</span>)); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(encoding_rs::UTF_8), Encoding::for_label(<span class="string">b"unicode11utf8"</span>)); |
| |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(encoding_rs::ISO_8859_2), Encoding::for_label(<span class="string">b"latin2"</span>)); |
| |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(encoding_rs::UTF_16BE), Encoding::for_label(<span class="string">b"utf-16be"</span>)); |
| |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, Encoding::for_label(<span class="string">b"unrecognized label"</span>));</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_label_no_replacement" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2843-2854">source</a><h4 class="code-header">pub fn <a href="#method.for_label_no_replacement" class="fnname">for_label_no_replacement</a>(label: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>></h4></section></summary><div class="docblock"><p>This method behaves the same as <code>for_label()</code>, except when <code>for_label()</code> |
| would return <code>Some(REPLACEMENT)</code>, this method returns <code>None</code> instead.</p> |
| <p>This method is useful in scenarios where a fatal error is required |
| upon invalid label, because in those cases the caller typically wishes |
| to treat the labels that map to the replacement encoding as fatal |
| errors, too.</p> |
| <p>It is not OK to use this method when the action upon the method returning |
| <code>None</code> is to use a fallback encoding (e.g. <code>WINDOWS_1252</code>). In such a |
| case, the <code>for_label()</code> method should be used instead in order to avoid |
| unsafe fallback for labels that <code>for_label()</code> maps to <code>Some(REPLACEMENT)</code>.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.for_bom" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2868-2878">source</a><h4 class="code-header">pub fn <a href="#method.for_bom" class="fnname">for_bom</a>(buffer: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.usize.html">usize</a>)></h4></section></summary><div class="docblock"><p>Performs non-incremental BOM sniffing.</p> |
| <p>The argument must either be a buffer representing the entire input |
| stream (non-streaming case) or a buffer representing at least the first |
| three bytes of the input stream (streaming case).</p> |
| <p>Returns <code>Some((UTF_8, 3))</code>, <code>Some((UTF_16LE, 2))</code> or |
| <code>Some((UTF_16BE, 2))</code> if the argument starts with the UTF-8, UTF-16LE |
| or UTF-16BE BOM or <code>None</code> otherwise.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.name" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2887-2889">source</a><h4 class="code-header">pub fn <a href="#method.name" class="fnname">name</a>(&'static self) -> &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Returns the name of this encoding.</p> |
| <p>This name is appropriate to return as-is from the DOM |
| <code>document.characterSet</code> property.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.can_encode_everything" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2896-2898">source</a><h4 class="code-header">pub fn <a href="#method.can_encode_everything" class="fnname">can_encode_everything</a>(&'static self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Checks whether the <em>output encoding</em> of this encoding can encode every |
| <code>char</code>. (Only true if the output encoding is UTF-8.)</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_ascii_compatible" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2905-2907">source</a><h4 class="code-header">pub fn <a href="#method.is_ascii_compatible" class="fnname">is_ascii_compatible</a>(&'static self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Checks whether the bytes 0x00…0x7F map exclusively to the characters |
| U+0000…U+007F and vice versa.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_single_byte" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2919-2921">source</a><h4 class="code-header">pub fn <a href="#method.is_single_byte" class="fnname">is_single_byte</a>(&'static self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Checks whether this encoding maps one byte to one Basic Multilingual |
| Plane code point (i.e. byte length equals decoded UTF-16 length) and |
| vice versa (for mappable characters).</p> |
| <p><code>true</code> iff this encoding is on the list of <a href="https://encoding.spec.whatwg.org/#legacy-single-byte-encodings">Legacy single-byte |
| encodings</a> |
| in the spec or x-user-defined.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.output_encoding" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2939-2945">source</a><h4 class="code-header">pub fn <a href="#method.output_encoding" class="fnname">output_encoding</a>(&'static self) -> &'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h4></section></summary><div class="docblock"><p>Returns the <em>output encoding</em> of this encoding. This is UTF-8 for |
| UTF-16BE, UTF-16LE, and replacement and the encoding itself otherwise.</p> |
| <p><em>Note:</em> The <em>output encoding</em> concept is needed for form submission and |
| error handling in the query strings of URLs in the Web Platform.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.decode" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#2986-2993">source</a><h4 class="code-header">pub fn <a href="#method.decode" class="fnname">decode</a><'a>(<br> &'static self,<br> bytes: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a>>, &'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Decode complete input to <code>Cow<'a, str></code> <em>with BOM sniffing</em> and with |
| malformed sequences replaced with the REPLACEMENT CHARACTER when the |
| entire input is available as a single buffer (i.e. the end of the |
| buffer marks the end of the stream).</p> |
| <p>The BOM, if any, does not appear in the output.</p> |
| <p>This method implements the (non-streaming version of) the |
| <a href="https://encoding.spec.whatwg.org/#decode"><em>decode</em></a> spec concept.</p> |
| <p>The second item in the returned tuple is the encoding that was actually |
| used (which may differ from this encoding thanks to BOM sniffing).</p> |
| <p>The third item in the returned tuple indicates whether there were |
| malformed sequences (that were replaced with the REPLACEMENT CHARACTER).</p> |
| <p><em>Note:</em> It is wrong to use this when the input buffer represents only |
| a segment of the input instead of the whole input. Use <code>new_decoder()</code> |
| when decoding segmented input.</p> |
| <p>This method performs a one or two heap allocations for the backing |
| buffer of the <code>String</code> when unable to borrow. (One allocation if not |
| errors and potentially another one in the presence of errors.) The |
| first allocation assumes jemalloc and may not be optimal with |
| allocators that do not use power-of-two buckets. A borrow is performed |
| if decoding UTF-8 and the input is valid UTF-8, if decoding an |
| ASCII-compatible encoding and the input is ASCII-only, or when decoding |
| ISO-2022-JP and the input is entirely in the ASCII state without state |
| transitions.</p> |
| <h5 id="panics"><a href="#panics">Panics</a></h5> |
| <p>If the size calculation for a heap-allocated backing buffer overflows |
| <code>usize</code>.</p> |
| <p>Available to Rust only and only with the <code>alloc</code> feature enabled (enabled |
| by default).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.decode_with_bom_removal" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3033-3044">source</a><h4 class="code-header">pub fn <a href="#method.decode_with_bom_removal" class="fnname">decode_with_bom_removal</a><'a>(<br> &'static self,<br> bytes: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a>>, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Decode complete input to <code>Cow<'a, str></code> <em>with BOM removal</em> and with |
| malformed sequences replaced with the REPLACEMENT CHARACTER when the |
| entire input is available as a single buffer (i.e. the end of the |
| buffer marks the end of the stream).</p> |
| <p>Only an initial byte sequence that is a BOM for this encoding is removed.</p> |
| <p>When invoked on <code>UTF_8</code>, this method implements the (non-streaming |
| version of) the |
| <a href="https://encoding.spec.whatwg.org/#utf-8-decode"><em>UTF-8 decode</em></a> spec |
| concept.</p> |
| <p>The second item in the returned pair indicates whether there were |
| malformed sequences (that were replaced with the REPLACEMENT CHARACTER).</p> |
| <p><em>Note:</em> It is wrong to use this when the input buffer represents only |
| a segment of the input instead of the whole input. Use |
| <code>new_decoder_with_bom_removal()</code> when decoding segmented input.</p> |
| <p>This method performs a one or two heap allocations for the backing |
| buffer of the <code>String</code> when unable to borrow. (One allocation if not |
| errors and potentially another one in the presence of errors.) The |
| first allocation assumes jemalloc and may not be optimal with |
| allocators that do not use power-of-two buckets. A borrow is performed |
| if decoding UTF-8 and the input is valid UTF-8, if decoding an |
| ASCII-compatible encoding and the input is ASCII-only, or when decoding |
| ISO-2022-JP and the input is entirely in the ASCII state without state |
| transitions.</p> |
| <h5 id="panics-1"><a href="#panics-1">Panics</a></h5> |
| <p>If the size calculation for a heap-allocated backing buffer overflows |
| <code>usize</code>.</p> |
| <p>Available to Rust only and only with the <code>alloc</code> feature enabled (enabled |
| by default).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.decode_without_bom_handling" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3081-3144">source</a><h4 class="code-header">pub fn <a href="#method.decode_without_bom_handling" class="fnname">decode_without_bom_handling</a><'a>(<br> &'static self,<br> bytes: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a>>, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Decode complete input to <code>Cow<'a, str></code> <em>without BOM handling</em> and |
| with malformed sequences replaced with the REPLACEMENT CHARACTER when |
| the entire input is available as a single buffer (i.e. the end of the |
| buffer marks the end of the stream).</p> |
| <p>When invoked on <code>UTF_8</code>, this method implements the (non-streaming |
| version of) the |
| <a href="https://encoding.spec.whatwg.org/#utf-8-decode-without-bom"><em>UTF-8 decode without BOM</em></a> |
| spec concept.</p> |
| <p>The second item in the returned pair indicates whether there were |
| malformed sequences (that were replaced with the REPLACEMENT CHARACTER).</p> |
| <p><em>Note:</em> It is wrong to use this when the input buffer represents only |
| a segment of the input instead of the whole input. Use |
| <code>new_decoder_without_bom_handling()</code> when decoding segmented input.</p> |
| <p>This method performs a one or two heap allocations for the backing |
| buffer of the <code>String</code> when unable to borrow. (One allocation if not |
| errors and potentially another one in the presence of errors.) The |
| first allocation assumes jemalloc and may not be optimal with |
| allocators that do not use power-of-two buckets. A borrow is performed |
| if decoding UTF-8 and the input is valid UTF-8, if decoding an |
| ASCII-compatible encoding and the input is ASCII-only, or when decoding |
| ISO-2022-JP and the input is entirely in the ASCII state without state |
| transitions.</p> |
| <h5 id="panics-2"><a href="#panics-2">Panics</a></h5> |
| <p>If the size calculation for a heap-allocated backing buffer overflows |
| <code>usize</code>.</p> |
| <p>Available to Rust only and only with the <code>alloc</code> feature enabled (enabled |
| by default).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.decode_without_bom_handling_and_without_replacement" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3178-3232">source</a><h4 class="code-header">pub fn <a href="#method.decode_without_bom_handling_and_without_replacement" class="fnname">decode_without_bom_handling_and_without_replacement</a><'a>(<br> &'static self,<br> bytes: &'a [<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a>>></h4></section></summary><div class="docblock"><p>Decode complete input to <code>Cow<'a, str></code> <em>without BOM handling</em> and |
| <em>with malformed sequences treated as fatal</em> when the entire input is |
| available as a single buffer (i.e. the end of the buffer marks the end |
| of the stream).</p> |
| <p>When invoked on <code>UTF_8</code>, this method implements the (non-streaming |
| version of) the |
| <a href="https://encoding.spec.whatwg.org/#utf-8-decode-without-bom-or-fail"><em>UTF-8 decode without BOM or fail</em></a> |
| spec concept.</p> |
| <p>Returns <code>None</code> if a malformed sequence was encountered and the result |
| of the decode as <code>Some(String)</code> otherwise.</p> |
| <p><em>Note:</em> It is wrong to use this when the input buffer represents only |
| a segment of the input instead of the whole input. Use |
| <code>new_decoder_without_bom_handling()</code> when decoding segmented input.</p> |
| <p>This method performs a single heap allocation for the backing |
| buffer of the <code>String</code> when unable to borrow. A borrow is performed if |
| decoding UTF-8 and the input is valid UTF-8, if decoding an |
| ASCII-compatible encoding and the input is ASCII-only, or when decoding |
| ISO-2022-JP and the input is entirely in the ASCII state without state |
| transitions.</p> |
| <h5 id="panics-3"><a href="#panics-3">Panics</a></h5> |
| <p>If the size calculation for a heap-allocated backing buffer overflows |
| <code>usize</code>.</p> |
| <p>Available to Rust only and only with the <code>alloc</code> feature enabled (enabled |
| by default).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.encode" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3276-3329">source</a><h4 class="code-header">pub fn <a href="#method.encode" class="fnname">encode</a><'a>(<br> &'static self,<br> string: &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.str.html">str</a><br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, [<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]>, &'static <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Encode complete input to <code>Cow<'a, [u8]></code> using the |
| <a href="struct.Encoding.html#method.output_encoding"><em>output encoding</em></a> of this encoding with |
| unmappable characters replaced with decimal numeric character references |
| when the entire input is available as a single buffer (i.e. the end of |
| the buffer marks the end of the stream).</p> |
| <p>This method implements the (non-streaming version of) the |
| <a href="https://encoding.spec.whatwg.org/#encode"><em>encode</em></a> spec concept. For |
| the <a href="https://encoding.spec.whatwg.org/#utf-8-encode"><em>UTF-8 encode</em></a> |
| spec concept, it is slightly more efficient to use |
| <code><var>string</var>.as_bytes()</code> instead of invoking this |
| method on <code>UTF_8</code>.</p> |
| <p>The second item in the returned tuple is the encoding that was actually |
| used (<em>which may differ from this encoding thanks to some encodings |
| having UTF-8 as their output encoding</em>).</p> |
| <p>The third item in the returned tuple indicates whether there were |
| unmappable characters (that were replaced with HTML numeric character |
| references).</p> |
| <p><em>Note:</em> It is wrong to use this when the input buffer represents only |
| a segment of the input instead of the whole input. Use <code>new_encoder()</code> |
| when encoding segmented output.</p> |
| <p>When encoding to UTF-8 or when encoding an ASCII-only input to a |
| ASCII-compatible encoding, this method returns a borrow of the input |
| without a heap allocation. Otherwise, this method performs a single |
| heap allocation for the backing buffer of the <code>Vec<u8></code> if there are no |
| unmappable characters and potentially multiple heap allocations if |
| there are. These allocations are tuned for jemalloc and may not be |
| optimal when using a different allocator that doesn’t use power-of-two |
| buckets.</p> |
| <h5 id="panics-4"><a href="#panics-4">Panics</a></h5> |
| <p>If the size calculation for a heap-allocated backing buffer overflows |
| <code>usize</code>.</p> |
| <p>Available to Rust only and only with the <code>alloc</code> feature enabled (enabled |
| by default).</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_decoder" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3343-3345">source</a><h4 class="code-header">pub fn <a href="#method.new_decoder" class="fnname">new_decoder</a>(&'static self) -> <a class="struct" href="struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></h4></section></summary><div class="docblock"><p>Instantiates a new decoder for this encoding with BOM sniffing enabled.</p> |
| <p>BOM sniffing may cause the returned decoder to morph into a decoder |
| for UTF-8, UTF-16LE or UTF-16BE instead of this encoding. The BOM |
| does not appear in the output.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_decoder_with_bom_removal" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3357-3359">source</a><h4 class="code-header">pub fn <a href="#method.new_decoder_with_bom_removal" class="fnname">new_decoder_with_bom_removal</a>(&'static self) -> <a class="struct" href="struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></h4></section></summary><div class="docblock"><p>Instantiates a new decoder for this encoding with BOM removal.</p> |
| <p>If the input starts with bytes that are the BOM for this encoding, |
| those bytes are removed. However, the decoder never morphs into a |
| decoder for another encoding: A BOM for another encoding is treated as |
| (potentially malformed) input to the decoding algorithm for this |
| encoding.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_decoder_without_bom_handling" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3373-3375">source</a><h4 class="code-header">pub fn <a href="#method.new_decoder_without_bom_handling" class="fnname">new_decoder_without_bom_handling</a>(&'static self) -> <a class="struct" href="struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></h4></section></summary><div class="docblock"><p>Instantiates a new decoder for this encoding with BOM handling disabled.</p> |
| <p>If the input starts with bytes that look like a BOM, those bytes are |
| not treated as a BOM. (Hence, the decoder never morphs into a decoder |
| for another encoding.)</p> |
| <p><em>Note:</em> If the caller has performed BOM sniffing on its own but has not |
| removed the BOM, the caller should use <code>new_decoder_with_bom_removal()</code> |
| instead of this method to cause the BOM to be removed.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_encoder" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3385-3388">source</a><h4 class="code-header">pub fn <a href="#method.new_encoder" class="fnname">new_encoder</a>(&'static self) -> <a class="struct" href="struct.Encoder.html" title="struct encoding_rs::Encoder">Encoder</a></h4></section></summary><div class="docblock"><p>Instantiates a new encoder for the <a href="struct.Encoding.html#method.output_encoding"><em>output encoding</em></a> |
| of this encoding.</p> |
| <p><em>Note:</em> The output encoding of UTF-16BE, UTF-16LE, and replacement is UTF-8. There |
| is no encoder for UTF-16BE, UTF-16LE, and replacement themselves.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.utf8_valid_up_to" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3400-3402">source</a><h4 class="code-header">pub fn <a href="#method.utf8_valid_up_to" class="fnname">utf8_valid_up_to</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Validates UTF-8.</p> |
| <p>Returns the index of the first byte that makes the input malformed as |
| UTF-8 or the length of the slice if the slice is entirely valid.</p> |
| <p>This is currently faster than the corresponding standard library |
| functionality. If this implementation gets upstreamed to the standard |
| library, this method may be removed in the future.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ascii_valid_up_to" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3410-3412">source</a><h4 class="code-header">pub fn <a href="#method.ascii_valid_up_to" class="fnname">ascii_valid_up_to</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Validates ASCII.</p> |
| <p>Returns the index of the first byte that makes the input malformed as |
| ASCII or the length of the slice if the slice is entirely valid.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iso_2022_jp_ascii_valid_up_to" class="method has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3422-3424">source</a><h4 class="code-header">pub fn <a href="#method.iso_2022_jp_ascii_valid_up_to" class="fnname">iso_2022_jp_ascii_valid_up_to</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a>]) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Validates ISO-2022-JP ASCII-state data.</p> |
| <p>Returns the index of the first byte that makes the input not |
| representable in the ASCII state of ISO-2022-JP or the length of the |
| slice if the slice is entirely representable in the ASCII state of |
| ISO-2022-JP.</p> |
| <p>Available via the C wrapper.</p> |
| </div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3457-3462">source</a><a href="#impl-Debug-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3459-3461">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3450-3455">source</a><a href="#impl-Hash-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3452-3454">source</a><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a><H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&mut </a>H)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#237-239">source</a></span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a><H>(data: &<a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&mut </a>H)<span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CEncoding%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3427-3432">source</a><a href="#impl-PartialEq%3CEncoding%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3429-3431">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: &<a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used |
| by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#227">source</a></span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always |
| sufficient, and should not be overridden without very good reason. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne">Read more</a></div></details></div></details><section id="impl-Eq-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="../src/encoding_rs/lib.rs.html#3434">source</a><a href="#impl-Eq-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Encoding" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section><section id="impl-Send-for-Encoding" class="impl has-srclink"><a href="#impl-Send-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section><section id="impl-Sync-for-Encoding" class="impl has-srclink"><a href="#impl-Sync-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section><section id="impl-Unpin-for-Encoding" class="impl has-srclink"><a href="#impl-Unpin-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section><section id="impl-UnwindSafe-for-Encoding" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Encoding" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> |
| <p>That is, this conversion is whatever the implementation of |
| <code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Encoding" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-Encoding" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="encoding_rs" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |