Initial docs commit
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
<!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_rs::Encoding - 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="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[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='../encoding_rs/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct Encoding</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.ascii_valid_up_to">ascii_valid_up_to</a><a href="#method.can_encode_everything">can_encode_everything</a><a href="#method.decode">decode</a><a href="#method.decode_with_bom_removal">decode_with_bom_removal</a><a href="#method.decode_without_bom_handling">decode_without_bom_handling</a><a href="#method.decode_without_bom_handling_and_without_replacement">decode_without_bom_handling_and_without_replacement</a><a href="#method.encode">encode</a><a href="#method.for_bom">for_bom</a><a href="#method.for_label">for_label</a><a href="#method.for_label_no_replacement">for_label_no_replacement</a><a href="#method.is_ascii_compatible">is_ascii_compatible</a><a href="#method.is_single_byte">is_single_byte</a><a href="#method.iso_2022_jp_ascii_valid_up_to">iso_2022_jp_ascii_valid_up_to</a><a href="#method.name">name</a><a href="#method.new_decoder">new_decoder</a><a href="#method.new_decoder_with_bom_removal">new_decoder_with_bom_removal</a><a href="#method.new_decoder_without_bom_handling">new_decoder_without_bom_handling</a><a href="#method.new_encoder">new_encoder</a><a href="#method.output_encoding">output_encoding</a><a href="#method.utf8_valid_up_to">utf8_valid_up_to</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Eq">Eq</a><a href="#impl-Hash">Hash</a><a href="#impl-PartialEq%3CEncoding%3E">PartialEq<Encoding></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="index.html">encoding_rs</a></p><div id="sidebar-vars" data-name="Encoding" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></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><button type="button" class="help-button">?</button>
|
||||
<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="in-band">Struct <a href="index.html">encoding_rs</a>::<wbr><a class="struct" href="">Encoding</a></span><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/encoding_rs/lib.rs.html#2648-2651" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Encoding { /* fields omitted */ }</pre></div><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>
|
||||
<h1 id="streaming-vs-non-streaming" class="section-header"><a href="#streaming-vs-non-streaming">Streaming vs. Non-Streaming</a></h1>
|
||||
<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>
|
||||
<h1 id="instances" class="section-header"><a href="#instances">Instances</a></h1>
|
||||
<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><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/encoding_rs/lib.rs.html#2653-3355" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.for_label" class="method"><code>pub fn <a href="#method.for_label" class="fnname">for_label</a>(label: &[u8]) -> <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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2675-2780" title="goto source code">[src]</a></h4><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>
|
||||
</div><h4 id="method.for_label_no_replacement" class="method"><code>pub fn <a href="#method.for_label_no_replacement" class="fnname">for_label_no_replacement</a>(label: &[u8]) -> <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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2797-2808" title="goto source code">[src]</a></h4><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><h4 id="method.for_bom" class="method"><code>pub fn <a href="#method.for_bom" class="fnname">for_bom</a>(buffer: &[u8]) -> <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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, usize)></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2822-2832" title="goto source code">[src]</a></h4><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><h4 id="method.name" class="method"><code>pub fn <a href="#method.name" class="fnname">name</a>(&'static self) -> &'static str</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2841-2843" title="goto source code">[src]</a></h4><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><h4 id="method.can_encode_everything" class="method"><code>pub fn <a href="#method.can_encode_everything" class="fnname">can_encode_everything</a>(&'static self) -> bool</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2850-2852" title="goto source code">[src]</a></h4><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><h4 id="method.is_ascii_compatible" class="method"><code>pub fn <a href="#method.is_ascii_compatible" class="fnname">is_ascii_compatible</a>(&'static self) -> bool</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2859-2861" title="goto source code">[src]</a></h4><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><h4 id="method.is_single_byte" class="method"><code>pub fn <a href="#method.is_single_byte" class="fnname">is_single_byte</a>(&'static self) -> bool</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2873-2875" title="goto source code">[src]</a></h4><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><h4 id="method.output_encoding" class="method"><code>pub fn <a href="#method.output_encoding" class="fnname">output_encoding</a>(&'static self) -> &'static <a class="struct" href="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2889-2895" title="goto source code">[src]</a></h4><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>Available via the C wrapper.</p>
|
||||
</div><h4 id="method.decode" class="method"><code>pub fn <a href="#method.decode" class="fnname">decode</a><'a>(<br> &'static self, <br> bytes: &'a [u8]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, str>, &'static <a class="struct" href="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, bool)</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2932-2939" title="goto source code">[src]</a></h4><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>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>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>If the size calculation for a heap-allocated backing buffer overflows
|
||||
<code>usize</code>.</p>
|
||||
<p>Available to Rust only.</p>
|
||||
</div><h4 id="method.decode_with_bom_removal" class="method"><code>pub fn <a href="#method.decode_with_bom_removal" class="fnname">decode_with_bom_removal</a><'a>(<br> &'static self, <br> bytes: &'a [u8]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, str>, bool)</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#2975-2986" title="goto source code">[src]</a></h4><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>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>
|
||||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||||
<p>If the size calculation for a heap-allocated backing buffer overflows
|
||||
<code>usize</code>.</p>
|
||||
<p>Available to Rust only.</p>
|
||||
</div><h4 id="method.decode_without_bom_handling" class="method"><code>pub fn <a href="#method.decode_without_bom_handling" class="fnname">decode_without_bom_handling</a><'a>(<br> &'static self, <br> bytes: &'a [u8]<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, str>, bool)</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3021-3084" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
|
||||
<p>If the size calculation for a heap-allocated backing buffer overflows
|
||||
<code>usize</code>.</p>
|
||||
<p>Available to Rust only.</p>
|
||||
</div><h4 id="method.decode_without_bom_handling_and_without_replacement" class="method"><code>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 [u8]<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, str>></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3116-3170" title="goto source code">[src]</a></h4><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>
|
||||
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
|
||||
<p>If the size calculation for a heap-allocated backing buffer overflows
|
||||
<code>usize</code>.</p>
|
||||
<p>Available to Rust only.</p>
|
||||
</div><h4 id="method.encode" class="method"><code>pub fn <a href="#method.encode" class="fnname">encode</a><'a>(<br> &'static self, <br> string: &'a str<br>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, [u8]>, &'static <a class="struct" href="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>, bool)</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3211-3264" title="goto source code">[src]</a></h4><div class="docblock"><p>Encode complete input to <code>Cow<'a, [u8]></code> 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 (which may differ from this encoding thanks to some encodings
|
||||
having UTF-8 as their output encoding).</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>
|
||||
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
|
||||
<p>If the size calculation for a heap-allocated backing buffer overflows
|
||||
<code>usize</code>.</p>
|
||||
<p>Available to Rust only.</p>
|
||||
</div><h4 id="method.new_decoder" class="method"><code>pub fn <a href="#method.new_decoder" class="fnname">new_decoder</a>(&'static self) -> <a class="struct" href="../encoding_rs/struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3277-3279" title="goto source code">[src]</a></h4><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.</p>
|
||||
<p>Available via the C wrapper.</p>
|
||||
</div><h4 id="method.new_decoder_with_bom_removal" class="method"><code>pub fn <a href="#method.new_decoder_with_bom_removal" class="fnname">new_decoder_with_bom_removal</a>(&'static self) -> <a class="struct" href="../encoding_rs/struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3291-3293" title="goto source code">[src]</a></h4><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><h4 id="method.new_decoder_without_bom_handling" class="method"><code>pub fn <a href="#method.new_decoder_without_bom_handling" class="fnname">new_decoder_without_bom_handling</a>(&'static self) -> <a class="struct" href="../encoding_rs/struct.Decoder.html" title="struct encoding_rs::Decoder">Decoder</a></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3307-3309" title="goto source code">[src]</a></h4><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><h4 id="method.new_encoder" class="method"><code>pub fn <a href="#method.new_encoder" class="fnname">new_encoder</a>(&'static self) -> <a class="struct" href="../encoding_rs/struct.Encoder.html" title="struct encoding_rs::Encoder">Encoder</a></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3315-3318" title="goto source code">[src]</a></h4><div class="docblock"><p>Instantiates a new encoder for the output encoding of this encoding.</p>
|
||||
<p>Available via the C wrapper.</p>
|
||||
</div><h4 id="method.utf8_valid_up_to" class="method"><code>pub fn <a href="#method.utf8_valid_up_to" class="fnname">utf8_valid_up_to</a>(bytes: &[u8]) -> usize</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3330-3332" title="goto source code">[src]</a></h4><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><h4 id="method.ascii_valid_up_to" class="method"><code>pub fn <a href="#method.ascii_valid_up_to" class="fnname">ascii_valid_up_to</a>(bytes: &[u8]) -> usize</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3340-3342" title="goto source code">[src]</a></h4><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><h4 id="method.iso_2022_jp_ascii_valid_up_to" class="method"><code>pub fn <a href="#method.iso_2022_jp_ascii_valid_up_to" class="fnname">iso_2022_jp_ascii_valid_up_to</a>(bytes: &[u8]) -> usize</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3352-3354" title="goto source code">[src]</a></h4><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></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/encoding_rs/lib.rs.html#3387-3392" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>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></code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3389-3391" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../src/encoding_rs/lib.rs.html#3364" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Hash" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Hash" class="anchor"></a><a class="srclink" href="../src/encoding_rs/lib.rs.html#3380-3385" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.hash" class="method hidden"><code>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: &mut H)</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3382-3384" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div><h4 id="method.hash_slice" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a><H>(data: &[Self], state: &mut 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></code><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#184-186" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div></div><h3 id="impl-PartialEq%3CEncoding%3E" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>> for <a class="struct" href="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-PartialEq%3CEncoding%3E" class="anchor"></a><a class="srclink" href="../src/encoding_rs/lib.rs.html#3357-3362" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a>) -> bool</code><a class="srclink" href="../src/encoding_rs/lib.rs.html#3359-3361" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div><h4 id="method.ne" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: &Rhs) -> bool</code><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#213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
|
||||
</div></div></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"><h3 id="impl-Send" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Send" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">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="../encoding_rs/struct.Encoding.html" title="struct encoding_rs::Encoding">Encoding</a></code><a href="#impl-Unpin" class="anchor"></a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">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></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub 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></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">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></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#207-211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> &T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">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></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-218" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> &mut T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#215" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">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</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-549" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">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></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#534-541" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#538" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">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></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#582-591" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_from" class="method hidden"><code>pub 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="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#588" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">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></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#568-577" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">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="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||||
</div><h4 id="method.try_into" class="method hidden"><code>pub 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="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#574" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="encoding_rs"></div>
|
||||
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|
||||
Reference in New Issue
Block a user