gabi 0.2.6

This crate provides a simple `Bytes` struct that stores a number and displays it in human readable format
Documentation
<!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="This crate provides a mechanism to store numbers and display them as a multiple of the chosen power of 1000 bytes or 1024 bytes, e.g. in Megabytes or Mebibytes for human readability."><meta name="keywords" content="rust, rustlang, rust-lang, lib"><title>lib - Rust</title><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="../light.css"  id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings" ></script><script src="../storage.js"></script><script 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"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></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="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a href='../lib/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><h2 class="location">Crate lib</h2><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all lib's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#traits">Traits</a></li></ul></div><div id="sidebar-vars" data-name="lib" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../wheel.svg"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">lib</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><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../src/lib/lib.rs.html#1-156" title="goto source code">[src]</a></span></h1><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This crate provides a mechanism to store numbers and display them
as a multiple of the chosen power of 1000 bytes or 1024 bytes,
e.g. in Megabytes or Mebibytes for human readability.</p>
<p>Example:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bb</span> <span class="op">=</span> <span class="ident">BytesConfig::default</span>();
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> <span class="ident">bb</span>.<span class="ident">bytes</span>(<span class="number">5247</span> <span class="kw">as</span> <span class="ident">u16</span>);
<span class="macro">println!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">b</span>);  <span class="comment">//  Prints &quot;5.25 KB&quot;</span></code></pre></div>
<p>The number is stored internally in the same type as was provided to initialize
the struct: <code>u16</code> in this example.</p>
<p>The <code>Bytes</code> structs are displayed using the preferences held in the <code>BytesConfig</code> struct
that created them:</p>

<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="ident">bb</span>.<span class="ident">set_precision</span>(<span class="number">1</span>);
<span class="macro">println!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">b</span>);  <span class="comment">//  Prints &quot;5.3 KB&quot;</span></code></pre></div>
<p>See example for more details.</p>
</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.Bytes.html" title="lib::Bytes struct">Bytes</a></div><div class="item-right docblock-short"><p>The struct used to store the number of bytes.
Trait bounds specify what traits are required from the type used to store the number of bytes.
<code>Into&lt;u64&gt;</code> in particular is required as the number of bytes is temporarily converted to <code>u64</code>
(the only type that we are sure can store any number stored in another type without overflowing)
to compare it.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BytesConfig.html" title="lib::BytesConfig struct">BytesConfig</a></div><div class="item-right docblock-short"><p>This struct captures the preferences for display of bytes and
creates instances of <code>Bytes</code> struct that contain a reference
to the preferences that they must use for display.
If the preferences are changed, all <code>Bytes</code> that the <code>BytesConfig</code>
instanciated adopt immediately the change. Config wrapped in Mutex
makes the implementation threadsafe.</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.BytesBase.html" title="lib::BytesBase enum">BytesBase</a></div><div class="item-right docblock-short"><p>Specify the possible choices for the base used
for the display of bytes, i.e.
<strong>Gabyte</strong>: Powers of 1000 bytes (Kilobyte, Megabyte, …)
<strong>Bibyte</strong>: Powers of 1024 bytes (Kibibyte, Mebibyte, …)
giving its name to the crate Ga/Bi(byte).</p>
</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.BIBYTES.html" title="lib::BIBYTES constant">BIBYTES</a></div><div class="item-right docblock-short"><p>Array with the list of unit names to use in the power of 1024 system</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.GABYTES.html" title="lib::GABYTES constant">GABYTES</a></div><div class="item-right docblock-short"><p>Array with the list of unit names to use in the power of 1000 system</p>
</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Unsigned.html" title="lib::Unsigned trait">Unsigned</a></div><div class="item-right docblock-short"><p>Marker trait used to indicate to the compiler what types are allowed to initialize the struct.</p>
</div></div></div></section><section id="search" class="content hidden"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="lib" data-search-index-js="../search-index.js" data-search-js="../search.js"></div>
</body></html>