Files
greptimedb/common_config/config/trait.Configurable.html
2026-01-08 13:00:41 +00:00

28 lines
10 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="Configuration trait defines the common interface for configuration that can be loaded from multiple sources and serialized to TOML."><title>Configurable in common_config::config - 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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="common_config" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0-nightly (fa3155a64 2025-09-30)" data-channel="nightly" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-828709d0.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.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]--><rustdoc-topbar><h2><a href="#">Configurable</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../common_config/index.html">common_<wbr>config</a><span class="version">1.0.0-beta.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Configurable</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.env_list_keys" title="env_list_keys">env_list_keys</a></li><li><a href="#method.load_layered_options" title="load_layered_options">load_layered_options</a></li><li><a href="#method.to_toml" title="to_toml">to_toml</a></li><li><a href="#method.validate_sanitize" title="validate_sanitize">validate_sanitize</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><a href="index.html">In common_<wbr>config::<wbr>config</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">common_config</a>::<wbr><a href="index.html">config</a></div><h1>Trait <span class="trait">Configurable</span>&nbsp;<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/common_config/config.rs.html#29-100">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Configurable:
<a class="trait" href="https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html" title="trait serde_core::ser::Serialize">Serialize</a>
+ <a class="trait" href="https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html" title="trait serde_core::de::DeserializeOwned">DeserializeOwned</a>
+ <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>
+ <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
// Provided methods
fn <a href="#method.load_layered_options" class="fn">load_layered_options</a>(
config_file: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
env_prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.validate_sanitize" class="fn">validate_sanitize</a>(&amp;mut self) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.env_list_keys" class="fn">env_list_keys</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'static [&amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.to_toml" class="fn">to_toml</a>(&amp;self) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt; { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Configuration trait defines the common interface for configuration that can be loaded from multiple sources and serialized to TOML.</p>
</div></details><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.load_layered_options" class="method"><a class="src rightside" href="../../src/common_config/config.rs.html#37-84">Source</a><h4 class="code-header">fn <a href="#method.load_layered_options" class="fn">load_layered_options</a>(
config_file: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
env_prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Load the configuration from multiple sources and merge them.
The precedence order is: config file &gt; environment variables &gt; default values.
<code>env_prefix</code> is the prefix of environment variables, e.g. “FRONTEND__xxx”.
The function will use dunder(double underscore) <code>__</code> as the separator for environment variables, for example:
<code>DATANODE__STORAGE__MANIFEST__CHECKPOINT_MARGIN</code> will be mapped to <code>DatanodeOptions.storage.manifest.checkpoint_margin</code> field in the configuration.
<code>list_keys</code> is the list of keys that should be parsed as a list, for example, you can pass <code>Some(&amp;["meta_client_options.metasrv_addrs"]</code> to parse <code>GREPTIMEDB_METASRV__META_CLIENT_OPTIONS__METASRV_ADDRS</code> as a list.
The function will use comma <code>,</code> as the separator for list values, for example: <code>127.0.0.1:3001,127.0.0.1:3002,127.0.0.1:3003</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.validate_sanitize" class="method"><a class="src rightside" href="../../src/common_config/config.rs.html#87-89">Source</a><h4 class="code-header">fn <a href="#method.validate_sanitize" class="fn">validate_sanitize</a>(&amp;mut self) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Validate(and possibly sanitize) the configuration.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.env_list_keys" class="method"><a class="src rightside" href="../../src/common_config/config.rs.html#92-94">Source</a><h4 class="code-header">fn <a href="#method.env_list_keys" class="fn">env_list_keys</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'static [&amp;'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>]&gt;</h4></section></summary><div class="docblock"><p>List of toml keys that should be parsed as a list.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_toml" class="method"><a class="src rightside" href="../../src/common_config/config.rs.html#97-99">Source</a><h4 class="code-header">fn <a href="#method.to_toml" class="fn">to_toml</a>(&amp;self) -&gt; <a class="type" href="../error/type.Result.html" title="type common_config::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></summary><div class="docblock"><p>Serialize the configuration to a TOML string.</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/nightly/reference/items/traits.html#dyn-compatibility">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/common_config/config/trait.Configurable.js" async></script></section></div></main></body></html>