Auto Generated Documentation

This commit is contained in:
github-actions[bot]
2025-04-02 13:41:38 +00:00
parent e9a232e07d
commit 21efed14f2
18523 changed files with 340249 additions and 282417 deletions
@@ -0,0 +1,32 @@
<!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="Implementation of functionality for `PyString`."><title>PyStringMethods in pyo3::prelude - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="pyo3" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.1 (4eb161250 2025-03-15)" data-channel="1.85.1" data-search-js="search-75f5ac3e.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../pyo3/index.html">pyo3</a><span class="version">0.24.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">PyString<wbr>Methods</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.data" title="data">data</a></li><li><a href="#tymethod.encode_utf8" title="encode_utf8">encode_utf8</a></li><li><a href="#tymethod.to_cow" title="to_cow">to_cow</a></li><li><a href="#tymethod.to_str" title="to_str">to_str</a></li><li><a href="#tymethod.to_string_lossy" title="to_string_lossy">to_string_lossy</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In pyo3::<wbr>prelude</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">pyo3</a>::<wbr><a href="index.html">prelude</a></span><h1>Trait <span class="trait">PyStringMethods</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/pyo3/types/string.rs.html#251-290">Source</a> </span></div><pre class="rust item-decl"><code>pub trait PyStringMethods&lt;'py&gt;: Sealed {
// Required methods
fn <a href="#tymethod.to_str" class="fn">to_str</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.to_cow" class="fn">to_cow</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.85.1/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.to_string_lossy" class="fn">to_string_lossy</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.encode_utf8" class="fn">encode_utf8</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyBytes.html" title="struct pyo3::types::PyBytes">PyBytes</a>&gt;&gt;;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.data" class="fn">data</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="enum" href="../types/enum.PyStringData.html" title="enum pyo3::types::PyStringData">PyStringData</a>&lt;'_&gt;&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementation of functionality for <a href="../types/struct.PyString.html" title="struct pyo3::types::PyString"><code>PyString</code></a>.</p>
<p>These methods are defined for the <code>Bound&lt;'py, PyString&gt;</code> smart pointer, so to use method call
syntax these methods are separated into a trait, because stable Rust does not yet support
<code>arbitrary_self_types</code>.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.to_str" class="method"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#257">Source</a><h4 class="code-header">fn <a href="#tymethod.to_str" class="fn">to_str</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;</h4></section></summary><div class="docblock"><p>Gets the Python string as a Rust UTF-8 string slice.</p>
<p>Returns a <code>UnicodeEncodeError</code> if the input is not valid unicode
(containing unpaired surrogates).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.to_cow" class="method"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#263">Source</a><h4 class="code-header">fn <a href="#tymethod.to_cow" class="fn">to_cow</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.85.1/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Converts the <code>PyString</code> into a Rust string, avoiding copying when possible.</p>
<p>Returns a <code>UnicodeEncodeError</code> if the input is not valid unicode
(containing unpaired surrogates).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.to_string_lossy" class="method"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#269">Source</a><h4 class="code-header">fn <a href="#tymethod.to_string_lossy" class="fn">to_string_lossy</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>&gt;</h4></section></summary><div class="docblock"><p>Converts the <code>PyString</code> into a Rust string.</p>
<p>Unpaired surrogates invalid UTF-8 sequences are
replaced with <code>U+FFFD REPLACEMENT CHARACTER</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.encode_utf8" class="method"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#272">Source</a><h4 class="code-header">fn <a href="#tymethod.encode_utf8" class="fn">encode_utf8</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyBytes.html" title="struct pyo3::types::PyBytes">PyBytes</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Encodes this string as a Python <code>bytes</code> object, using UTF-8 encoding.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.data" class="method"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#289">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.data" class="fn">data</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="enum" href="../types/enum.PyStringData.html" title="enum pyo3::types::PyStringData">PyStringData</a>&lt;'_&gt;&gt;</h4></section></summary><div class="docblock"><p>Obtains the raw data backing the Python string.</p>
<p>If the Python string object was created through legacy APIs, its internal storage format
will be canonicalized before data is returned.</p>
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
<p>This function implementation relies on manually decoding a C bitfield. In practice, this
works well on common little-endian architectures such as x86_64, where the bitfield has a
common representation (even if it is not part of the C spec). The PyO3 CI tests this API on
x86_64 platforms.</p>
<p>By using this API, you accept responsibility for testing that PyStringData behaves as
expected on the targets where you plan to distribute your software.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-PyStringMethods%3C'py%3E-for-Bound%3C'py,+PyString%3E" class="impl"><a class="src rightside" href="../../src/pyo3/types/string.rs.html#292-318">Source</a><a href="#impl-PyStringMethods%3C'py%3E-for-Bound%3C'py,+PyString%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'py&gt; <a class="trait" href="../types/trait.PyStringMethods.html" title="trait pyo3::types::PyStringMethods">PyStringMethods</a>&lt;'py&gt; for <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyString.html" title="struct pyo3::types::PyString">PyString</a>&gt;</h3></section></div><script src="../../trait.impl/pyo3/types/string/trait.PyStringMethods.js" async></script></section></div></main></body></html>