37 lines
11 KiB
HTML
37 lines
11 KiB
HTML
<!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="Ini parser for Rust"><meta name="keywords" content="rust, rustlang, rust-lang, ini"><title>ini - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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">☰</button><a class="sidebar-logo" href="../ini/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../ini/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate ini</a></h2><div class="sidebar-elems"><div class="block"><ul><li class="version">Version 0.18.0</li><li><a id="all-types" href="all.html">All Items</a></li></ul></div><section><div class="block"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#types">Type Definitions</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../ini/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">ini</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/ini/lib.rs.html#22-2038">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Ini parser for Rust</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">ini::Ini</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">conf</span> <span class="op">=</span> <span class="ident">Ini::new</span>();
|
||
<span class="ident">conf</span>.<span class="ident">with_section</span>(<span class="prelude-val">Some</span>(<span class="string">"User"</span>))
|
||
.<span class="ident">set</span>(<span class="string">"name"</span>, <span class="string">"Raspberry树莓"</span>)
|
||
.<span class="ident">set</span>(<span class="string">"value"</span>, <span class="string">"Pi"</span>);
|
||
<span class="ident">conf</span>.<span class="ident">with_section</span>(<span class="prelude-val">Some</span>(<span class="string">"Library"</span>))
|
||
.<span class="ident">set</span>(<span class="string">"name"</span>, <span class="string">"Sun Yat-sen U"</span>)
|
||
.<span class="ident">set</span>(<span class="string">"location"</span>, <span class="string">"Guangzhou=world"</span>);
|
||
<span class="ident">conf</span>.<span class="ident">write_to_file</span>(<span class="string">"conf.ini"</span>).<span class="ident">unwrap</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">i</span> <span class="op">=</span> <span class="ident">Ini::load_from_file</span>(<span class="string">"conf.ini"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">for</span> (<span class="ident">sec</span>, <span class="ident">prop</span>) <span class="kw">in</span> <span class="ident">i</span>.<span class="ident">iter</span>() {
|
||
<span class="macro">println!</span>(<span class="string">"Section: {:?}"</span>, <span class="ident">sec</span>);
|
||
<span class="kw">for</span> (<span class="ident">k</span>, <span class="ident">v</span>) <span class="kw">in</span> <span class="ident">prop</span>.<span class="ident">iter</span>() {
|
||
<span class="macro">println!</span>(<span class="string">"{}:{}"</span>, <span class="ident">k</span>, <span class="ident">v</span>);
|
||
}
|
||
}</code></pre></div>
|
||
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Ini.html" title="ini::Ini struct">Ini</a></div><div class="item-right docblock-short"><p>Ini struct</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ParseError.html" title="ini::ParseError struct">ParseError</a></div><div class="item-right docblock-short"><p>Parse error</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ParseOption.html" title="ini::ParseOption struct">ParseOption</a></div><div class="item-right docblock-short"><p>Parsing configuration</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Properties.html" title="ini::Properties struct">Properties</a></div><div class="item-right docblock-short"><p>Properties type (key-value pairs)</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SectionIter.html" title="ini::SectionIter struct">SectionIter</a></div><div class="item-right docblock-short"><p>Iterator for traversing sections</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SectionIterMut.html" title="ini::SectionIterMut struct">SectionIterMut</a></div><div class="item-right docblock-short"><p>Iterator for traversing sections</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SectionOccupiedEntry.html" title="ini::SectionOccupiedEntry struct">SectionOccupiedEntry</a></div><div class="item-right docblock-short"><p>A view into a occupied entry in a <code>Ini</code></p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SectionSetter.html" title="ini::SectionSetter struct">SectionSetter</a></div><div class="item-right docblock-short"><p>A setter which could be used to set key-value pair in a specified section</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SectionVacantEntry.html" title="ini::SectionVacantEntry struct">SectionVacantEntry</a></div><div class="item-right docblock-short"><p>A view into a vacant entry in a <code>Ini</code></p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.WriteOption.html" title="ini::WriteOption struct">WriteOption</a></div><div class="item-right docblock-short"><p>Writing configuration</p>
|
||
</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Error.html" title="ini::Error enum">Error</a></div><div class="item-right docblock-short"><p>Error while parsing an INI document</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.EscapePolicy.html" title="ini::EscapePolicy enum">EscapePolicy</a></div><div class="item-right docblock-short"><p>Policies for escaping logic</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.LineSeparator.html" title="ini::LineSeparator enum">LineSeparator</a></div><div class="item-right docblock-short"><p>Newline style</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.SectionEntry.html" title="ini::SectionEntry enum">SectionEntry</a></div><div class="item-right docblock-short"><p>A view into an <code>Ini</code>, which may either be vacant or occupied.</p>
|
||
</div></div></div><h2 id="types" class="small-section-header"><a href="#types">Type Definitions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="type" href="type.PropertyKey.html" title="ini::PropertyKey type">PropertyKey</a></div><div class="item-right docblock-short"><p>Internal storage of property’s key</p>
|
||
</div></div><div class="item-row"><div class="item-left module-item"><a class="type" href="type.SectionKey.html" title="ini::SectionKey type">SectionKey</a></div><div class="item-right docblock-short"><p>Internal storage of section’s key</p>
|
||
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="ini" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html> |