Skip to content

Commit 1954950

Browse files
committed
Deploying to gh-pages from @ 9d16c20 🚀
0 parents  commit 1954950

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1279
-0
lines changed

.lock

Whitespace-only changes.

crate_interface/all.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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-84e720fa.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crate_interface" data-themes="" data-resource-suffix="" data-rustdoc-version="1.89.0-nightly (4d08223c0 2025-05-31)" data-channel="nightly" data-search-js="search-f7877310.js" data-settings-js="settings-5514c975.js" ><script src="../static.files/storage-4e99c027.js"></script><script defer src="../static.files/main-fd3af306.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-32bb7600.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="../crate_interface/index.html">crate_<wbr>interface</a><span class="version">0.1.4</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="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="macros">Macros</h3><ul class="all-items"><li><a href="macro.call_interface.html">call_interface</a></li></ul><h3 id="attributes">Attribute Macros</h3><ul class="all-items"><li><a href="attr.def_interface.html">def_interface</a></li><li><a href="attr.impl_interface.html">impl_interface</a></li></ul></section></div></main></body></html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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="Define an interface."><title>def_interface in crate_interface - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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-84e720fa.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crate_interface" data-themes="" data-resource-suffix="" data-rustdoc-version="1.89.0-nightly (4d08223c0 2025-05-31)" data-channel="nightly" data-search-js="search-f7877310.js" data-settings-js="settings-5514c975.js" ><script src="../static.files/storage-4e99c027.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-fd3af306.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-32bb7600.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 attr"><!--[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="../crate_interface/index.html">crate_<wbr>interface</a><span class="version">0.1.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">crate_interface</a></div><h1>Attribute Macro <span class="attr">def_interface</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/crate_interface/lib.rs.html#28-86">Source</a> </span></div><pre class="rust item-decl"><code>#[def_interface]</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Define an interface.</p>
2+
<p>This attribute should be added above the definition of a trait. All traits
3+
that use the attribute cannot have the same name.</p>
4+
<p>It is not necessary to define it in the same crate as the implementation,
5+
but it is required that these crates are linked together.</p>
6+
<p>See the <a href="index.html" title="mod crate_interface">crate-level documentation</a> for more details.</p>
7+
</div></details></section></div></main></body></html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="Implement the interface for a struct."><title>impl_interface in crate_interface - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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-84e720fa.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crate_interface" data-themes="" data-resource-suffix="" data-rustdoc-version="1.89.0-nightly (4d08223c0 2025-05-31)" data-channel="nightly" data-search-js="search-f7877310.js" data-settings-js="settings-5514c975.js" ><script src="../static.files/storage-4e99c027.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-fd3af306.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-32bb7600.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 attr"><!--[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="../crate_interface/index.html">crate_<wbr>interface</a><span class="version">0.1.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">impl_<wbr>interface</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#caveat" title="Caveat">Caveat</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate crate_<wbr>interface</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">crate_interface</a></div><h1>Attribute Macro <span class="attr">impl_interface</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/crate_interface/lib.rs.html#119-197">Source</a> </span></div><pre class="rust item-decl"><code>#[impl_interface]</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement the interface for a struct.</p>
2+
<p>This attribute should be added above the implementation of a trait for a
3+
struct, and the trait must be defined with
4+
<a href="attr.def_interface.html" title="attr crate_interface::def_interface"><code>#[def_interface]</code></a>.</p>
5+
<p>It is not necessary to implement it in the same crate as the definition, but
6+
it is required that these crates are linked together.</p>
7+
<p>See the <a href="index.html" title="mod crate_interface">crate-level documentation</a> for more details.</p>
8+
<h2 id="caveat"><a class="doc-anchor" href="#caveat">§</a>Caveat</h2>
9+
<p>The specified trait name must not be an alias to the originally defined
10+
name; otherwise, it will result in a compile error.</p>
11+
12+
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="attr">#[def_interface]
13+
</span><span class="kw">trait </span>MyIf {
14+
<span class="kw">fn </span>foo();
15+
}
16+
17+
<span class="kw">use </span>MyIf <span class="kw">as </span>MyIf2;
18+
<span class="kw">struct </span>MyImpl;
19+
<span class="attr">#[impl_interface]
20+
</span><span class="kw">impl </span>MyIf2 <span class="kw">for </span>MyImpl {
21+
<span class="kw">fn </span>foo() {}
22+
}</code></pre></div>
23+
</div></details></section></div></main></body></html>

crate_interface/index.html

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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="crate_interface"><title>crate_interface - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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-84e720fa.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crate_interface" data-themes="" data-resource-suffix="" data-rustdoc-version="1.89.0-nightly (4d08223c0 2025-05-31)" data-channel="nightly" data-search-js="search-f7877310.js" data-settings-js="settings-5514c975.js" ><script src="../static.files/storage-4e99c027.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-fd3af306.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-32bb7600.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="../crate_interface/index.html">crate_<wbr>interface</a><span class="version">0.1.4</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="#crate_interface" title="crate_interface">crate_interface</a><ul><li><a href="#example" title="Example">Example</a></li><li><a href="#implementation" title="Implementation">Implementation</a></li></ul></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="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>crate_interface</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/crate_interface/lib.rs.html#1-245">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="crate_interface"><a class="doc-anchor" href="#crate_interface">§</a>crate_interface</h2>
2+
<p><a href="https://crates.io/crates/crate_interface"><img src="https://img.shields.io/crates/v/crate_interface" alt="Crates.io" /></a>
3+
<a href="https://docs.rs/crate_interface"><img src="https://docs.rs/crate_interface/badge.svg" alt="Docs.rs" /></a>
4+
<a href="https://github.com/arceos-org/crate_interface/actions/workflows/ci.yml"><img src="https://github.com/arceos-org/crate_interface/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a></p>
5+
<p>Provides a way to <strong>define</strong> an interface (trait) in a crate, but can
6+
<strong>implement</strong> or <strong>use</strong> it in any crate. It ’s usually used to solve
7+
the problem of <em>circular dependencies</em> between crates.</p>
8+
<h3 id="example"><a class="doc-anchor" href="#example">§</a>Example</h3>
9+
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Define the interface
10+
</span><span class="attr">#[crate_interface::def_interface]
11+
</span><span class="kw">pub trait </span>HelloIf {
12+
<span class="kw">fn </span>hello(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String;
13+
}
14+
15+
<span class="comment">// Implement the interface in any crate
16+
</span><span class="kw">struct </span>HelloIfImpl;
17+
18+
<span class="attr">#[crate_interface::impl_interface]
19+
</span><span class="kw">impl </span>HelloIf <span class="kw">for </span>HelloIfImpl {
20+
<span class="kw">fn </span>hello(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String {
21+
<span class="macro">format!</span>(<span class="string">"Hello, {} {}!"</span>, name, id)
22+
}
23+
}
24+
25+
<span class="comment">// Call `HelloIfImpl::hello` in any crate
26+
</span><span class="kw">use </span>crate_interface::call_interface;
27+
<span class="macro">assert_eq!</span>(
28+
<span class="macro">call_interface!</span>(HelloIf::hello(<span class="string">"world"</span>, <span class="number">123</span>)),
29+
<span class="string">"Hello, world 123!"
30+
</span>);
31+
<span class="macro">assert_eq!</span>(
32+
<span class="macro">call_interface!</span>(HelloIf::hello, <span class="string">"rust"</span>, <span class="number">456</span>), <span class="comment">// another calling style
33+
</span><span class="string">"Hello, rust 456!"
34+
</span>);</code></pre></div>
35+
<h3 id="implementation"><a class="doc-anchor" href="#implementation">§</a>Implementation</h3>
36+
<p>The procedural macros in the above example will generate the following code:</p>
37+
38+
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// #[def_interface]
39+
</span><span class="kw">pub trait </span>HelloIf {
40+
<span class="kw">fn </span>hello(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String;
41+
}
42+
43+
<span class="attr">#[allow(non_snake_case)]
44+
</span><span class="kw">pub mod </span>__HelloIf_mod {
45+
<span class="kw">use super</span>::<span class="kw-2">*</span>;
46+
<span class="kw">extern </span><span class="string">"Rust" </span>{
47+
<span class="kw">pub fn </span>__HelloIf_hello(name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String;
48+
}
49+
}
50+
51+
<span class="kw">struct </span>HelloIfImpl;
52+
53+
<span class="comment">// #[impl_interface]
54+
</span><span class="kw">impl </span>HelloIf <span class="kw">for </span>HelloIfImpl {
55+
<span class="attr">#[inline]
56+
</span><span class="kw">fn </span>hello(<span class="kw-2">&amp;</span><span class="self">self</span>, name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String {
57+
{
58+
<span class="attr">#[inline]
59+
#[export_name = <span class="string">"__HelloIf_hello"</span>]
60+
</span><span class="kw">extern </span><span class="string">"Rust" </span><span class="kw">fn </span>__HelloIf_hello(name: <span class="kw-2">&amp;</span>str, id: usize) -&gt; String {
61+
<span class="kw">let </span>_impl: HelloIfImpl = HelloIfImpl;
62+
_impl.hello(name, id)
63+
}
64+
}
65+
{
66+
<span class="macro">format!</span>(<span class="string">"Hello, {} {}!"</span>, name, id)
67+
}
68+
}
69+
}
70+
71+
<span class="comment">// call_interface!
72+
</span><span class="macro">assert_eq!</span>(
73+
<span class="kw">unsafe </span>{ __HelloIf_mod::__HelloIf_hello(<span class="string">"world"</span>, <span class="number">123</span>) },
74+
<span class="string">"Hello, world 123!"
75+
</span>);</code></pre></div>
76+
</div></details><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.call_interface.html" title="macro crate_interface::call_interface">call_<wbr>interface</a></dt><dd>Call a function in the interface.</dd></dl><h2 id="attributes" class="section-header">Attribute Macros<a href="#attributes" class="anchor">§</a></h2><dl class="item-table"><dt><a class="attr" href="attr.def_interface.html" title="attr crate_interface::def_interface">def_<wbr>interface</a></dt><dd>Define an interface.</dd><dt><a class="attr" href="attr.impl_interface.html" title="attr crate_interface::impl_interface">impl_<wbr>interface</a></dt><dd>Implement the interface for a struct.</dd></dl></section></div></main></body></html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="refresh" content="0;URL=macro.call_interface.html">
5+
<title>Redirection</title>
6+
</head>
7+
<body>
8+
<p>Redirecting to <a href="macro.call_interface.html">macro.call_interface.html</a>...</p>
9+
<script>location.replace("macro.call_interface.html" + location.search + location.hash);</script>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)