deploy: de38ae62916547ad097c066f94a32e9ba7790eeb

This commit is contained in:
NotAShelf 2025-02-05 00:10:33 +00:00
commit 9a86359447
28502 changed files with 1261284 additions and 0 deletions

1
foreign_types/all.html Normal file
View file

@ -0,0 +1 @@
<!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="List of all items in this crate"><title>List of all items in this crate</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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.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 mod sys"><!--[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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#macros">Crate Items</a></h3><ul class="block"><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Opaque.html">Opaque</a></li></ul><h3 id="traits">Traits</h3><ul class="all-items"><li><a href="trait.ForeignType.html">ForeignType</a></li><li><a href="trait.ForeignTypeRef.html">ForeignTypeRef</a></li></ul><h3 id="macros">Macros</h3><ul class="all-items"><li><a href="macro.foreign_type.html">foreign_type</a></li></ul></section></div></main></body></html>

158
foreign_types/index.html Normal file
View file

@ -0,0 +1,158 @@
<!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="A framework for Rust wrappers over C APIs."><title>foreign_types - 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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.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 mod crate"><!--[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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#macros">Crate Items</a></h3><ul class="block"><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>foreign_types</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/foreign_types/lib.rs.html#1-306">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A framework for Rust wrappers over C APIs.</p>
<p>Ownership is as important in C as it is in Rust, but the semantics are often implicit. In
particular, pointer-to-value is commonly used to pass C values both when transferring ownership
or a borrow.</p>
<p>This crate provides a framework to define a Rust wrapper over these kinds of raw C APIs in a way
that allows ownership semantics to be expressed in an ergonomic manner. The framework takes a
dual-type approach similar to APIs in the standard library such as <code>PathBuf</code>/<code>Path</code> or <code>String</code>/
<code>str</code>. One type represents an owned value and references to the other represent borrowed
values.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>foreign_types::{ForeignType, ForeignTypeRef, Opaque};
<span class="kw">use </span>std::ops::{Deref, DerefMut};
<span class="kw">mod </span>foo_sys {
<span class="kw">pub enum </span>FOO {}
<span class="kw">extern </span>{
<span class="kw">pub fn </span>FOO_free(foo: <span class="kw-2">*mut </span>FOO);
}
}
<span class="comment">// The borrowed type is a newtype wrapper around an `Opaque` value.
//
// `FooRef` values never exist; we instead create references to `FooRef`s
// from raw C pointers.
</span><span class="kw">pub struct </span>FooRef(Opaque);
<span class="kw">impl </span>ForeignTypeRef <span class="kw">for </span>FooRef {
<span class="kw">type </span>CType = foo_sys::FOO;
}
<span class="comment">// The owned type is simply a newtype wrapper around the raw C type.
//
// It dereferences to `FooRef`, so methods that do not require ownership
// should be defined there.
</span><span class="kw">pub struct </span>Foo(<span class="kw-2">*mut </span>foo_sys::FOO);
<span class="kw">impl </span>Drop <span class="kw">for </span>Foo {
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">unsafe </span>{ foo_sys::FOO_free(<span class="self">self</span>.<span class="number">0</span>) }
}
}
<span class="kw">impl </span>ForeignType <span class="kw">for </span>Foo {
<span class="kw">type </span>CType = foo_sys::FOO;
<span class="kw">type </span>Ref = FooRef;
<span class="kw">unsafe fn </span>from_ptr(ptr: <span class="kw-2">*mut </span>foo_sys::FOO) -&gt; Foo {
Foo(ptr)
}
<span class="kw">fn </span>as_ptr(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">*mut </span>foo_sys::FOO {
<span class="self">self</span>.<span class="number">0
</span>}
}
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = FooRef;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>FooRef {
<span class="kw">unsafe </span>{ FooRef::from_ptr(<span class="self">self</span>.<span class="number">0</span>) }
}
}
<span class="kw">impl </span>DerefMut <span class="kw">for </span>Foo {
<span class="kw">fn </span>deref_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>FooRef {
<span class="kw">unsafe </span>{ FooRef::from_ptr_mut(<span class="self">self</span>.<span class="number">0</span>) }
}
}</code></pre></div>
<p>The <code>foreign_type!</code> macro can generate this boilerplate for you:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[macro_use]
</span><span class="kw">extern crate </span>foreign_types;
<span class="kw">mod </span>foo_sys {
<span class="kw">pub enum </span>FOO {}
<span class="kw">extern </span>{
<span class="kw">pub fn </span>FOO_free(foo: <span class="kw-2">*mut </span>FOO);
<span class="kw">pub fn </span>FOO_duplicate(foo: <span class="kw-2">*mut </span>FOO) -&gt; <span class="kw-2">*mut </span>FOO; <span class="comment">// Optional
</span>}
}
<span class="macro">foreign_type!</span> {
<span class="kw">type </span>CType = foo_sys::FOO;
<span class="kw">fn </span>drop = foo_sys::FOO_free;
<span class="kw">fn </span>clone = foo_sys::FOO_duplicate; <span class="comment">// Optional
</span><span class="doccomment">/// A Foo.
</span><span class="kw">pub struct </span>Foo;
<span class="doccomment">/// A borrowed Foo.
</span><span class="kw">pub struct </span>FooRef;
}
</code></pre></div>
<p>If <code>fn clone</code> is specified, then it must take <code>CType</code> as an argument and return a copy of it as <code>CType</code>.
It will be used to implement <code>ToOwned</code> and <code>Clone</code>.</p>
<p><code>#[derive(…)] is permitted before the lines with </code>pub struct<code>. </code>#[doc(hidden)]<code>before the</code>type CType<code>line will hide the</code>foreign_type!` implementations from documentation.</p>
<p>Say we then have a separate type in our C API that contains a <code>FOO</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">mod </span>foo_sys {
<span class="kw">pub enum </span>FOO {}
<span class="kw">pub enum </span>BAR {}
<span class="kw">extern </span>{
<span class="kw">pub fn </span>FOO_free(foo: <span class="kw-2">*mut </span>FOO);
<span class="kw">pub fn </span>BAR_free(bar: <span class="kw-2">*mut </span>BAR);
<span class="kw">pub fn </span>BAR_get_foo(bar: <span class="kw-2">*mut </span>BAR) -&gt; <span class="kw-2">*mut </span>FOO;
}
}</code></pre></div>
<p>The documentation for the C library states that <code>BAR_get_foo</code> returns a reference into the <code>BAR</code>
passed to it, which translates into a reference in Rust. It also says that were allowed to
modify the <code>FOO</code>, so well define a pair of accessor methods, one immutable and one mutable:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[macro_use]
</span><span class="kw">extern crate </span>foreign_types;
<span class="kw">use </span>foreign_types::ForeignTypeRef;
<span class="kw">mod </span>foo_sys {
<span class="kw">pub enum </span>FOO {}
<span class="kw">pub enum </span>BAR {}
<span class="kw">extern </span>{
<span class="kw">pub fn </span>FOO_free(foo: <span class="kw-2">*mut </span>FOO);
<span class="kw">pub fn </span>BAR_free(bar: <span class="kw-2">*mut </span>BAR);
<span class="kw">pub fn </span>BAR_get_foo(bar: <span class="kw-2">*mut </span>BAR) -&gt; <span class="kw-2">*mut </span>FOO;
}
}
<span class="macro">foreign_type!</span> {
<span class="attr">#[doc(hidden)]
</span><span class="kw">type </span>CType = foo_sys::FOO;
<span class="kw">fn </span>drop = foo_sys::FOO_free;
<span class="doccomment">/// A Foo.
</span><span class="kw">pub struct </span>Foo;
<span class="doccomment">/// A borrowed Foo.
</span><span class="kw">pub struct </span>FooRef;
}
<span class="macro">foreign_type!</span> {
<span class="kw">type </span>CType = foo_sys::BAR;
<span class="kw">fn </span>drop = foo_sys::BAR_free;
<span class="doccomment">/// A Foo.
</span><span class="kw">pub struct </span>Bar;
<span class="doccomment">/// A borrowed Bar.
</span><span class="kw">pub struct </span>BarRef;
}
<span class="kw">impl </span>BarRef {
<span class="kw">fn </span>foo(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>FooRef {
<span class="kw">unsafe </span>{ FooRef::from_ptr(foo_sys::BAR_get_foo(<span class="self">self</span>.as_ptr())) }
}
<span class="kw">fn </span>foo_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>FooRef {
<span class="kw">unsafe </span>{ FooRef::from_ptr_mut(foo_sys::BAR_get_foo(<span class="self">self</span>.as_ptr())) }
}
}
</code></pre></div>
</div></details><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.foreign_type.html" title="macro foreign_types::foreign_type">foreign_<wbr>type</a></div><div class="desc docblock-short">A macro to easily define wrappers for foreign types.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></div><div class="desc docblock-short">An opaque type used to define <code>ForeignTypeRef</code> types.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.ForeignType.html" title="trait foreign_types::ForeignType">Foreign<wbr>Type</a></div><div class="desc docblock-short">A type implemented by wrappers over foreign types.</div></li><li><div class="item-name"><a class="trait" href="trait.ForeignTypeRef.html" title="trait foreign_types::ForeignTypeRef">Foreign<wbr>Type<wbr>Ref</a></div><div class="desc docblock-short">A trait implemented by types which reference borrowed foreign types.</div></li></ul></section></div></main></body></html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.foreign_type.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.foreign_type.html">macro.foreign_type.html</a>...</p>
<script>location.replace("macro.foreign_type.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,27 @@
<!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="A macro to easily define wrappers for foreign types."><title>foreign_type in foreign_types - 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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.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 macro"><!--[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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">foreign_<wbr>type</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate foreign_<wbr>types</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">foreign_types</a></span><h1>Macro <span class="macro">foreign_type</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/foreign_types/lib.rs.html#208-306">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! foreign_type {
(
$(#[$impl_attr:meta])*
type CType = $ctype:ty;
fn drop = $drop:expr;
$(fn clone = $clone:expr;)*
$(#[$owned_attr:meta])*
pub struct $owned:ident;
$(#[$borrowed_attr:meta])*
pub struct $borrowed:ident;
) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A macro to easily define wrappers for foreign types.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[macro_use]
</span><span class="kw">extern crate </span>foreign_types;
<span class="macro">foreign_type!</span> {
<span class="kw">type </span>CType = openssl_sys::SSL;
<span class="kw">fn </span>drop = openssl_sys::SSL_free;
<span class="kw">fn </span>clone = openssl_sys::SSL_dup;
<span class="doccomment">/// Documentation for the owned type.
</span><span class="kw">pub struct </span>Ssl;
<span class="doccomment">/// Documentation for the borrowed type.
</span><span class="kw">pub struct </span>SslRef;
}
</code></pre></div>
</div></details></section></div></main></body></html>

View file

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"macro":["foreign_type"],"struct":["Opaque"],"trait":["ForeignType","ForeignTypeRef"]};

View file

@ -0,0 +1,13 @@
<!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 opaque type used to define `ForeignTypeRef` types."><title>Opaque in foreign_types - 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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Opaque</a></h2><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Opaque" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Opaque" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-Sync-for-Opaque" title="!Sync">!Sync</a></li><li><a href="#impl-Send-for-Opaque" title="Send">Send</a></li><li><a href="#impl-Unpin-for-Opaque" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Opaque" 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-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></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate foreign_<wbr>types</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">foreign_types</a></span><h1>Struct <span class="struct">Opaque</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/foreign_types_shared/lib.rs.html#12">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Opaque(<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>An opaque type used to define <code>ForeignTypeRef</code> types.</p>
<p>A type implementing <code>ForeignTypeRef</code> should simply be a newtype wrapper around this type.</p>
</div></details><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-Opaque" class="impl"><a href="#impl-Freeze-for-Opaque" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></h3></section><section id="impl-RefUnwindSafe-for-Opaque" class="impl"><a href="#impl-RefUnwindSafe-for-Opaque" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></h3></section><section id="impl-Send-for-Opaque" class="impl"><a href="#impl-Send-for-Opaque" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></h3></section><section id="impl-Sync-for-Opaque" class="impl"><a href="#impl-Sync-for-Opaque" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></h3></section><section id="impl-Unpin-for-Opaque" class="impl"><a href="#impl-Unpin-for-Opaque" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></h3></section><section id="impl-UnwindSafe-for-Opaque" class="impl"><a href="#impl-UnwindSafe-for-Opaque" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Opaque.html" title="struct foreign_types::Opaque">Opaque</a></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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.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.84.1/core/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.84.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.84.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.84.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.84.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.84.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.84.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.84.1/core/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.84.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.84.1/src/core/convert/mod.rs.html#765">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.84.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.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.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-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">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.84.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.84.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.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.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.84.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.84.1/src/core/convert/mod.rs.html#805-807">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.84.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.84.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.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.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.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.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.84.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.84.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.84.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.84.1/src/core/convert/mod.rs.html#790-792">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.84.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.84.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.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.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.84.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.84.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.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.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.84.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.84.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.84.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></div></section></div></main></body></html>

View file

@ -0,0 +1,13 @@
<!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="A type implemented by wrappers over foreign types."><title>ForeignType in foreign_types - 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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Foreign<wbr>Type</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.CType" title="CType">CType</a></li><li><a href="#associatedtype.Ref" title="Ref">Ref</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_ptr" title="as_ptr">as_ptr</a></li><li><a href="#tymethod.from_ptr" title="from_ptr">from_ptr</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate foreign_<wbr>types</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">foreign_types</a></span><h1>Trait <span class="trait">ForeignType</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/foreign_types_shared/lib.rs.html#15">Source</a> </span></div><pre class="rust item-decl"><code>pub trait ForeignType: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href="#associatedtype.CType" class="associatedtype">CType</a>;
type <a href="#associatedtype.Ref" class="associatedtype">Ref</a>: <a class="trait" href="trait.ForeignTypeRef.html" title="trait foreign_types::ForeignTypeRef">ForeignTypeRef</a>&lt;CType = Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a>&gt;;
// Required methods
unsafe fn <a href="#tymethod.from_ptr" class="fn">from_ptr</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a>) -&gt; Self;
<span class="item-spacer"></span> fn <a href="#tymethod.as_ptr" class="fn">as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type implemented by wrappers over foreign types.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.CType" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#17">Source</a><h4 class="code-header">type <a href="#associatedtype.CType" class="associatedtype">CType</a></h4></section></summary><div class="docblock"><p>The raw C type.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Ref" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#20">Source</a><h4 class="code-header">type <a href="#associatedtype.Ref" class="associatedtype">Ref</a>: <a class="trait" href="trait.ForeignTypeRef.html" title="trait foreign_types::ForeignTypeRef">ForeignTypeRef</a>&lt;CType = Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a>&gt;</h4></section></summary><div class="docblock"><p>The type representing a reference to this type.</p>
</div></details></div><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.from_ptr" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#23">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.from_ptr" class="fn">from_ptr</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a>) -&gt; Self</h4></section></summary><div class="docblock"><p>Constructs an instance of this type from its raw type.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.as_ptr" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#26">Source</a><h4 class="code-header">fn <a href="#tymethod.as_ptr" class="fn">as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignType.html#associatedtype.CType" title="type foreign_types::ForeignType::CType">CType</a></h4></section></summary><div class="docblock"><p>Returns a raw pointer to the wrapped value.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/foreign_types_shared/trait.ForeignType.js" async></script></section></div></main></body></html>

View file

@ -0,0 +1,13 @@
<!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="A trait implemented by types which reference borrowed foreign types."><title>ForeignTypeRef in foreign_types - 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-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="foreign_types" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.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="../foreign_types/index.html">foreign_<wbr>types</a><span class="version">0.3.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Foreign<wbr>Type<wbr>Ref</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.CType" title="CType">CType</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.as_ptr" title="as_ptr">as_ptr</a></li><li><a href="#method.from_ptr" title="from_ptr">from_ptr</a></li><li><a href="#method.from_ptr_mut" title="from_ptr_mut">from_ptr_mut</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate foreign_<wbr>types</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">foreign_types</a></span><h1>Trait <span class="trait">ForeignTypeRef</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/foreign_types_shared/lib.rs.html#30">Source</a> </span></div><pre class="rust item-decl"><code>pub trait ForeignTypeRef: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href="#associatedtype.CType" class="associatedtype">CType</a>;
// Provided methods
unsafe fn <a href="#method.from_ptr" class="fn">from_ptr</a>&lt;'a&gt;(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a>) -&gt; &amp;'a Self { ... }
<span class="item-spacer"></span> unsafe fn <a href="#method.from_ptr_mut" class="fn">from_ptr_mut</a>&lt;'a&gt;(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a>) -&gt; &amp;'a mut Self { ... }
<span class="item-spacer"></span> fn <a href="#method.as_ptr" class="fn">as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A trait implemented by types which reference borrowed foreign types.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.CType" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#32">Source</a><h4 class="code-header">type <a href="#associatedtype.CType" class="associatedtype">CType</a></h4></section></summary><div class="docblock"><p>The raw C type.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.from_ptr" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#36">Source</a><h4 class="code-header">unsafe fn <a href="#method.from_ptr" class="fn">from_ptr</a>&lt;'a&gt;(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a>) -&gt; &amp;'a Self</h4></section></summary><div class="docblock"><p>Constructs a shared instance of this type from its raw type.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_ptr_mut" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#42">Source</a><h4 class="code-header">unsafe fn <a href="#method.from_ptr_mut" class="fn">from_ptr_mut</a>&lt;'a&gt;(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a>) -&gt; &amp;'a mut Self</h4></section></summary><div class="docblock"><p>Constructs a mutable reference of this type from its raw type.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_ptr" class="method"><a class="src rightside" href="../src/foreign_types_shared/lib.rs.html#48">Source</a><h4 class="code-header">fn <a href="#method.as_ptr" class="fn">as_ptr</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.pointer.html">*mut </a>Self::<a class="associatedtype" href="trait.ForeignTypeRef.html#associatedtype.CType" title="type foreign_types::ForeignTypeRef::CType">CType</a></h4></section></summary><div class="docblock"><p>Returns a raw pointer to the wrapped value.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/foreign_types_shared/trait.ForeignTypeRef.js" async></script></section></div></main></body></html>