Files
2025-04-02 13:41:38 +00:00

147 lines
52 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="Allows access to the underlying buffer used by a python object such as `bytes`, `bytearray` or `array.array`."><title>PyBuffer in pyo3::buffer - 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 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" 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="#">PyBuffer</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.as_fortran_mut_slice" title="as_fortran_mut_slice">as_fortran_mut_slice</a></li><li><a href="#method.as_fortran_slice" title="as_fortran_slice">as_fortran_slice</a></li><li><a href="#method.as_mut_slice" title="as_mut_slice">as_mut_slice</a></li><li><a href="#method.as_slice" title="as_slice">as_slice</a></li><li><a href="#method.buf_ptr" title="buf_ptr">buf_ptr</a></li><li><a href="#method.copy_from_fortran_slice" title="copy_from_fortran_slice">copy_from_fortran_slice</a></li><li><a href="#method.copy_from_slice" title="copy_from_slice">copy_from_slice</a></li><li><a href="#method.copy_to_fortran_slice" title="copy_to_fortran_slice">copy_to_fortran_slice</a></li><li><a href="#method.copy_to_slice" title="copy_to_slice">copy_to_slice</a></li><li><a href="#method.dimensions" title="dimensions">dimensions</a></li><li><a href="#method.format" title="format">format</a></li><li><a href="#method.get" title="get">get</a></li><li><a href="#method.get_bound" title="get_bound">get_bound</a></li><li><a href="#method.get_ptr" title="get_ptr">get_ptr</a></li><li><a href="#method.is_c_contiguous" title="is_c_contiguous">is_c_contiguous</a></li><li><a href="#method.is_fortran_contiguous" title="is_fortran_contiguous">is_fortran_contiguous</a></li><li><a href="#method.item_count" title="item_count">item_count</a></li><li><a href="#method.item_size" title="item_size">item_size</a></li><li><a href="#method.len_bytes" title="len_bytes">len_bytes</a></li><li><a href="#method.readonly" title="readonly">readonly</a></li><li><a href="#method.release" title="release">release</a></li><li><a href="#method.shape" title="shape">shape</a></li><li><a href="#method.strides" title="strides">strides</a></li><li><a href="#method.suboffsets" title="suboffsets">suboffsets</a></li><li><a href="#method.to_fortran_vec" title="to_fortran_vec">to_fortran_vec</a></li><li><a href="#method.to_vec" title="to_vec">to_vec</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-PyBuffer%3CT%3E" title="Debug">Debug</a></li><li><a href="#impl-Drop-for-PyBuffer%3CT%3E" title="Drop">Drop</a></li><li><a href="#impl-FromPyObject%3C'_%3E-for-PyBuffer%3CT%3E" title="FromPyObject&#60;&#39;_&#62;">FromPyObject&#60;&#39;_&#62;</a></li><li><a href="#impl-Send-for-PyBuffer%3CT%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-PyBuffer%3CT%3E" title="Sync">Sync</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-PyBuffer%3CT%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-PyBuffer%3CT%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Unpin-for-PyBuffer%3CT%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-PyBuffer%3CT%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-FromPyObjectBound%3C'_,+'py%3E-for-T" title="FromPyObjectBound&#60;&#39;_, &#39;py&#62;">FromPyObjectBound&#60;&#39;_, &#39;py&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li><li><a href="#impl-Ungil-for-T" title="Ungil">Ungil</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In pyo3::<wbr>buffer</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">buffer</a></span><h1>Struct <span class="struct">PyBuffer</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/buffer.rs.html#32">Source</a> </span></div><pre class="rust item-decl"><code>pub struct PyBuffer&lt;T&gt;(<span class="comment">/* private fields */</span>);</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Allows access to the underlying buffer used by a python object such as <code>bytes</code>, <code>bytearray</code> or <code>array.array</code>.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#191-628">Source</a><a href="#impl-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="trait.Element.html" title="trait pyo3::buffer::Element">Element</a>&gt; <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#193-225">Source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a>(obj: &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'_, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;&gt;</h4></section></summary><div class="docblock"><p>Gets the underlying buffer from the specified python object.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_bound" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#230-232">Source</a><h4 class="code-header">pub fn <a href="#method.get_bound" class="fn">get_bound</a>(obj: &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'_, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;&gt;</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.23.0: renamed to <code>PyBuffer::get</code></span></div></span></summary><div class="docblock"><p>Deprecated name for <a href="struct.PyBuffer.html#method.get" title="associated function pyo3::buffer::PyBuffer::get"><code>PyBuffer::get</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.buf_ptr" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#239-241">Source</a><h4 class="code-header">pub fn <a href="#method.buf_ptr" class="fn">buf_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.pointer.html">*mut </a><a class="type" href="https://doc.rust-lang.org/1.85.1/std/os/raw/type.c_void.html" title="type std::os::raw::c_void">c_void</a></h4></section></summary><div class="docblock"><p>Gets the pointer to the start of the buffer memory.</p>
<p>Warning: the buffer memory might be mutated by other Python functions,
and thus may only be accessed while the GIL is held.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_ptr" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#246-269">Source</a><h4 class="code-header">pub fn <a href="#method.get_ptr" class="fn">get_ptr</a>(&amp;self, indices: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>]) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.pointer.html">*mut </a><a class="type" href="https://doc.rust-lang.org/1.85.1/std/os/raw/type.c_void.html" title="type std::os::raw::c_void">c_void</a></h4></section></summary><div class="docblock"><p>Gets a pointer to the specified item.</p>
<p>If <code>indices.len() &lt; self.dimensions()</code>, returns the start address of the sub-array at the specified dimension.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.readonly" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#273-275">Source</a><h4 class="code-header">pub fn <a href="#method.readonly" class="fn">readonly</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Gets whether the underlying buffer is read-only.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.item_size" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#280-282">Source</a><h4 class="code-header">pub fn <a href="#method.item_size" class="fn">item_size</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Gets the size of a single element, in bytes.
Important exception: when requesting an unformatted buffer, item_size still has the value</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.item_count" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#286-288">Source</a><h4 class="code-header">pub fn <a href="#method.item_count" class="fn">item_count</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Gets the total number of items.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.len_bytes" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#294-296">Source</a><h4 class="code-header">pub fn <a href="#method.len_bytes" class="fn">len_bytes</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p><code>item_size() * item_count()</code>.
For contiguous arrays, this is the length of the underlying memory block.
For non-contiguous arrays, it is the length that the logical structure would have if it were copied to a contiguous representation.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.dimensions" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#302-304">Source</a><h4 class="code-header">pub fn <a href="#method.dimensions" class="fn">dimensions</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Gets the number of dimensions.</p>
<p>May be 0 to indicate a single scalar value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.shape" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#314-316">Source</a><h4 class="code-header">pub fn <a href="#method.shape" class="fn">shape</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>]</h4></section></summary><div class="docblock"><p>Returns an array of length <code>dimensions</code>. <code>shape()[i]</code> is the length of the array in dimension number <code>i</code>.</p>
<p>May return None for single-dimensional arrays or scalar values (<code>dimensions() &lt;= 1</code>);
You can call <code>item_count()</code> to get the length of the single dimension.</p>
<p>Despite Python using an array of signed integers, the values are guaranteed to be non-negative.
However, dimensions of length 0 are possible and might need special attention.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.strides" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#323-325">Source</a><h4 class="code-header">pub fn <a href="#method.strides" class="fn">strides</a>(&amp;self) -&gt; &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.isize.html">isize</a>]</h4></section></summary><div class="docblock"><p>Returns an array that holds, for each dimension, the number of bytes to skip to get to the next element in the dimension.</p>
<p>Stride values can be any integer. For regular arrays, strides are usually positive,
but a consumer MUST be able to handle the case <code>strides[n] &lt;= 0</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.suboffsets" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#333-344">Source</a><h4 class="code-header">pub fn <a href="#method.suboffsets" class="fn">suboffsets</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;[<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.isize.html">isize</a>]&gt;</h4></section></summary><div class="docblock"><p>An array of length ndim.
If <code>suboffsets[n] &gt;= 0</code>, the values stored along the nth dimension are pointers and the suboffset value dictates how many bytes to add to each pointer after de-referencing.
A suboffset value that is negative indicates that no de-referencing should occur (striding in a contiguous memory block).</p>
<p>If all suboffsets are negative (i.e. no de-referencing is needed), then this field must be NULL (the default value).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.format" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#348-354">Source</a><h4 class="code-header">pub fn <a href="#method.format" class="fn">format</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/1.85.1/core/ffi/c_str/struct.CStr.html" title="struct core::ffi::c_str::CStr">CStr</a></h4></section></summary><div class="docblock"><p>A NUL terminated string in struct module style syntax describing the contents of a single item.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_c_contiguous" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#358-360">Source</a><h4 class="code-header">pub fn <a href="#method.is_c_contiguous" class="fn">is_c_contiguous</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Gets whether the buffer is contiguous in C-style order (last index varies fastest when visiting items in order of memory address).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_fortran_contiguous" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#364-366">Source</a><h4 class="code-header">pub fn <a href="#method.is_fortran_contiguous" class="fn">is_fortran_contiguous</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Gets whether the buffer is contiguous in Fortran-style order (first index varies fastest when visiting items in order of memory address).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#377-388">Source</a><h4 class="code-header">pub fn <a href="#method.as_slice" class="fn">as_slice</a>&lt;'a&gt;(&amp;'a self, _py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'a&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a [<a class="struct" href="struct.ReadOnlyCell.html" title="struct pyo3::buffer::ReadOnlyCell">ReadOnlyCell</a>&lt;T&gt;]&gt;</h4></section></summary><div class="docblock"><p>Gets the buffer memory as a slice.</p>
<p>This function succeeds if:</p>
<ul>
<li>the buffer format is compatible with <code>T</code></li>
<li>alignment and size of buffer elements is matching the expectations for type <code>T</code></li>
<li>the buffer is C-style contiguous</li>
</ul>
<p>The returned slice uses type <code>Cell&lt;T&gt;</code> because its theoretically possible for any call into the Python runtime
to modify the values in the slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_mut_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#400-411">Source</a><h4 class="code-header">pub fn <a href="#method.as_mut_slice" class="fn">as_mut_slice</a>&lt;'a&gt;(&amp;'a self, _py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'a&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a [<a class="struct" href="https://doc.rust-lang.org/1.85.1/core/cell/struct.Cell.html" title="struct core::cell::Cell">Cell</a>&lt;T&gt;]&gt;</h4></section></summary><div class="docblock"><p>Gets the buffer memory as a slice.</p>
<p>This function succeeds if:</p>
<ul>
<li>the buffer is not read-only</li>
<li>the buffer format is compatible with <code>T</code></li>
<li>alignment and size of buffer elements is matching the expectations for type <code>T</code></li>
<li>the buffer is C-style contiguous</li>
</ul>
<p>The returned slice uses type <code>Cell&lt;T&gt;</code> because its theoretically possible for any call into the Python runtime
to modify the values in the slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_fortran_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#422-433">Source</a><h4 class="code-header">pub fn <a href="#method.as_fortran_slice" class="fn">as_fortran_slice</a>&lt;'a&gt;(
&amp;'a self,
_py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'a&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a [<a class="struct" href="struct.ReadOnlyCell.html" title="struct pyo3::buffer::ReadOnlyCell">ReadOnlyCell</a>&lt;T&gt;]&gt;</h4></section></summary><div class="docblock"><p>Gets the buffer memory as a slice.</p>
<p>This function succeeds if:</p>
<ul>
<li>the buffer format is compatible with <code>T</code></li>
<li>alignment and size of buffer elements is matching the expectations for type <code>T</code></li>
<li>the buffer is Fortran-style contiguous</li>
</ul>
<p>The returned slice uses type <code>Cell&lt;T&gt;</code> because its theoretically possible for any call into the Python runtime
to modify the values in the slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_fortran_mut_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#445-456">Source</a><h4 class="code-header">pub fn <a href="#method.as_fortran_mut_slice" class="fn">as_fortran_mut_slice</a>&lt;'a&gt;(
&amp;'a self,
_py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'a&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a [<a class="struct" href="https://doc.rust-lang.org/1.85.1/core/cell/struct.Cell.html" title="struct core::cell::Cell">Cell</a>&lt;T&gt;]&gt;</h4></section></summary><div class="docblock"><p>Gets the buffer memory as a slice.</p>
<p>This function succeeds if:</p>
<ul>
<li>the buffer is not read-only</li>
<li>the buffer format is compatible with <code>T</code></li>
<li>alignment and size of buffer elements is matching the expectations for type <code>T</code></li>
<li>the buffer is Fortran-style contiguous</li>
</ul>
<p>The returned slice uses type <code>Cell&lt;T&gt;</code> because its theoretically possible for any call into the Python runtime
to modify the values in the slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_to_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#467-469">Source</a><h4 class="code-header">pub fn <a href="#method.copy_to_slice" class="fn">copy_to_slice</a>(&amp;self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;, target: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.slice.html">[T]</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Copies the buffer elements to the specified slice.
If the buffer is multi-dimensional, the elements are written in C-style order.</p>
<ul>
<li>Fails if the slice does not have the correct length (<code>buf.item_count()</code>).</li>
<li>Fails if the buffer format is not compatible with type <code>T</code>.</li>
</ul>
<p>To check whether the buffer format is compatible before calling this method,
you can use <code>&lt;T as buffer::Element&gt;::is_compatible_format(buf.format())</code>.
Alternatively, <code>match buffer::ElementType::from_format(buf.format())</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_to_fortran_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#480-482">Source</a><h4 class="code-header">pub fn <a href="#method.copy_to_fortran_slice" class="fn">copy_to_fortran_slice</a>(
&amp;self,
py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;,
target: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.slice.html">[T]</a>,
) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Copies the buffer elements to the specified slice.
If the buffer is multi-dimensional, the elements are written in Fortran-style order.</p>
<ul>
<li>Fails if the slice does not have the correct length (<code>buf.item_count()</code>).</li>
<li>Fails if the buffer format is not compatible with type <code>T</code>.</li>
</ul>
<p>To check whether the buffer format is compatible before calling this method,
you can use <code>&lt;T as buffer::Element&gt;::is_compatible_format(buf.format())</code>.
Alternatively, <code>match buffer::ElementType::from_format(buf.format())</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_vec" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#512-514">Source</a><h4 class="code-header">pub fn <a href="#method.to_vec" class="fn">to_vec</a>(&amp;self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.85.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;T&gt;&gt;</h4></section></summary><div class="docblock"><p>Copies the buffer elements to a newly allocated vector.
If the buffer is multi-dimensional, the elements are written in C-style order.</p>
<p>Fails if the buffer format is not compatible with type <code>T</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_fortran_vec" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#520-522">Source</a><h4 class="code-header">pub fn <a href="#method.to_fortran_vec" class="fn">to_fortran_vec</a>(&amp;self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.85.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;T&gt;&gt;</h4></section></summary><div class="docblock"><p>Copies the buffer elements to a newly allocated vector.
If the buffer is multi-dimensional, the elements are written in Fortran-style order.</p>
<p>Fails if the buffer format is not compatible with type <code>T</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_from_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#558-560">Source</a><h4 class="code-header">pub fn <a href="#method.copy_from_slice" class="fn">copy_from_slice</a>(&amp;self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;, source: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.slice.html">[T]</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Copies the specified slice into the buffer.
If the buffer is multi-dimensional, the elements in the slice are expected to be in C-style order.</p>
<ul>
<li>Fails if the buffer is read-only.</li>
<li>Fails if the slice does not have the correct length (<code>buf.item_count()</code>).</li>
<li>Fails if the buffer format is not compatible with type <code>T</code>.</li>
</ul>
<p>To check whether the buffer format is compatible before calling this method,
use <code>&lt;T as buffer::Element&gt;::is_compatible_format(buf.format())</code>.
Alternatively, <code>match buffer::ElementType::from_format(buf.format())</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_from_fortran_slice" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#572-574">Source</a><h4 class="code-header">pub fn <a href="#method.copy_from_fortran_slice" class="fn">copy_from_fortran_slice</a>(
&amp;self,
py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;,
source: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.slice.html">[T]</a>,
) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Copies the specified slice into the buffer.
If the buffer is multi-dimensional, the elements in the slice are expected to be in Fortran-style order.</p>
<ul>
<li>Fails if the buffer is read-only.</li>
<li>Fails if the slice does not have the correct length (<code>buf.item_count()</code>).</li>
<li>Fails if the buffer format is not compatible with type <code>T</code>.</li>
</ul>
<p>To check whether the buffer format is compatible before calling this method,
use <code>&lt;T as buffer::Element&gt;::is_compatible_format(buf.format())</code>.
Alternatively, <code>match buffer::ElementType::from_format(buf.format())</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.release" class="method"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#613-627">Source</a><h4 class="code-header">pub fn <a href="#method.release" class="fn">release</a>(self, _py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a>&lt;'_&gt;)</h4></section></summary><div class="docblock"><p>Releases the buffer object, freeing the reference to the Python object
which owns the buffer.</p>
<p>This will automatically be called on drop.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#39-55">Source</a><a href="#impl-Debug-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#40-54">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.85.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.85.1/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/1.85.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#630-634">Source</a><a href="#impl-Drop-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#631-633">Source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&amp;mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.85.1/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromPyObject%3C'_%3E-for-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#185-189">Source</a><a href="#impl-FromPyObject%3C'_%3E-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="trait.Element.html" title="trait pyo3::buffer::Element">Element</a>&gt; <a class="trait" href="../conversion/trait.FromPyObject.html" title="trait pyo3::conversion::FromPyObject">FromPyObject</a>&lt;'_&gt; for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.extract_bound" class="method trait-impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#186-188">Source</a><a href="#method.extract_bound" class="anchor">§</a><h4 class="code-header">fn <a href="../conversion/trait.FromPyObject.html#tymethod.extract_bound" class="fn">extract_bound</a>(obj: &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'_, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;&gt;</h4></section></summary><div class='docblock'>Extracts <code>Self</code> from the bound smart pointer <code>obj</code>. <a href="../conversion/trait.FromPyObject.html#tymethod.extract_bound">Read more</a></div></details></div></details><section id="impl-Send-for-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#36">Source</a><a href="#impl-Send-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section><section id="impl-Sync-for-PyBuffer%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/buffer.rs.html#37">Source</a><a href="#impl-Sync-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-PyBuffer%3CT%3E" class="impl"><a href="#impl-Freeze-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;</h3></section><section id="impl-RefUnwindSafe-for-PyBuffer%3CT%3E" class="impl"><a href="#impl-RefUnwindSafe-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,</div></h3></section><section id="impl-Unpin-for-PyBuffer%3CT%3E" class="impl"><a href="#impl-Unpin-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-PyBuffer%3CT%3E" class="impl"><a href="#impl-UnwindSafe-for-PyBuffer%3CT%3E" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.PyBuffer.html" title="struct pyo3::buffer::PyBuffer">PyBuffer</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.85.1/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/1.85.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#767">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#770">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-FromPyObjectBound%3C'_,+'py%3E-for-T" class="impl"><a class="src rightside" href="../../src/pyo3/conversion.rs.html#530-542">Source</a><a href="#impl-FromPyObjectBound%3C'_,+'py%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;'py, T&gt; <a class="trait" href="../conversion/trait.FromPyObjectBound.html" title="trait pyo3::conversion::FromPyObjectBound">FromPyObjectBound</a>&lt;'_, 'py&gt; for T<div class="where">where
T: <a class="trait" href="../conversion/trait.FromPyObject.html" title="trait pyo3::conversion::FromPyObject">FromPyObject</a>&lt;'py&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_py_object_bound" class="method trait-impl"><a class="src rightside" href="../../src/pyo3/conversion.rs.html#534-536">Source</a><a href="#method.from_py_object_bound" class="anchor">§</a><h4 class="code-header">fn <a href="../conversion/trait.FromPyObjectBound.html#tymethod.from_py_object_bound" class="fn">from_py_object_bound</a>(ob: <a class="struct" href="../struct.Borrowed.html" title="struct pyo3::Borrowed">Borrowed</a>&lt;'_, 'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, <a class="struct" href="../struct.PyErr.html" title="struct pyo3::PyErr">PyErr</a>&gt;</h4></section></summary><div class='docblock'>Extracts <code>Self</code> from the bound smart pointer <code>obj</code>. <a href="../conversion/trait.FromPyObjectBound.html#tymethod.from_py_object_bound">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#750-752">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#760">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; 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/1.85.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#807-809">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#811">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.85.1/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="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#814">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#792-794">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#796">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.1/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="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#799">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><section id="impl-Ungil-for-T" class="impl"><a class="src rightside" href="../../src/pyo3/marker.rs.html#194">Source</a><a href="#impl-Ungil-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="../marker/trait.Ungil.html" title="trait pyo3::marker::Ungil">Ungil</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</div></h3></section></div></section></div></main></body></html>