<!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="API documentation for the Rust `sysctl` crate.">
<meta name="keywords" content="rust, rustlang, rust-lang, sysctl">
<title>sysctl - Rust</title>
<link rel="stylesheet" type="text/css" href="../normalize.css">
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
</head>
<body class="rustdoc">
<nav class="sidebar">
<p class='location'></p><script>window.sidebarCurrent = {name: 'sysctl', ty: 'mod', relpath: '../'};</script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Crate <a class='mod' href=''>sysctl</a></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'>−</span>]
</a>
</span><a class='srclink' href='../src/sysctl/lib.rs.html#1-702' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>A simplified Rust interface to the <code>sysctl</code> system call.</p>
<p>Currently built for and only tested on FreeBSD.</p>
<h1 id='example-get-description-and-value' class='section-header'><a href='#example-get-description-and-value'>Example: Get description and value</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>sysctl</span>;
<span class='kw'>fn</span> <span class='ident'>main</span>() {
<span class='kw'>let</span> <span class='ident'>ctl</span> <span class='op'>=</span> <span class='string'>"kern.osrevision"</span>;
<span class='kw'>let</span> <span class='ident'>d</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>sysctl</span>::<span class='ident'>description</span>(<span class='ident'>ctl</span>).<span class='ident'>unwrap</span>();
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Description: {:?}"</span>, <span class='ident'>d</span>);
<span class='kw'>let</span> <span class='ident'>val_enum</span> <span class='op'>=</span> <span class='ident'>sysctl</span>::<span class='ident'>value</span>(<span class='ident'>ctl</span>).<span class='ident'>unwrap</span>();
<span class='kw'>if</span> <span class='kw'>let</span> <span class='ident'>sysctl</span>::<span class='ident'>CtlValue</span>::<span class='ident'>Int</span>(<span class='ident'>val</span>) <span class='op'>=</span> <span class='ident'>val_enum</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Value: {}"</span>, <span class='ident'>val</span>);
}
}</pre>
<h1 id='example-get-value-as-struct' class='section-header'><a href='#example-get-value-as-struct'>Example: Get value as struct</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>sysctl</span>;
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>libc</span>;
<span class='kw'>use</span> <span class='ident'>libc</span>::<span class='ident'>c_int</span>;
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>)]</span>
<span class='attribute'>#[<span class='ident'>repr</span>(<span class='ident'>C</span>)]</span>
<span class='kw'>struct</span> <span class='ident'>ClockInfo</span> {
<span class='ident'>hz</span>: <span class='ident'>c_int</span>, <span class='comment'>/* clock frequency */</span>
<span class='ident'>tick</span>: <span class='ident'>c_int</span>, <span class='comment'>/* micro-seconds per hz tick */</span>
<span class='ident'>spare</span>: <span class='ident'>c_int</span>,
<span class='ident'>stathz</span>: <span class='ident'>c_int</span>, <span class='comment'>/* statistics clock frequency */</span>
<span class='ident'>profhz</span>: <span class='ident'>c_int</span>, <span class='comment'>/* profiling clock frequency */</span>
}
<span class='kw'>fn</span> <span class='ident'>main</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{:?}"</span>, <span class='ident'>sysctl</span>::<span class='ident'>value_as</span>::<span class='op'><</span><span class='ident'>ClockInfo</span><span class='op'>></span>(<span class='string'>"kern.clockrate"</span>));
}</pre>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.Temperature.html'
title='sysctl::Temperature'>Temperature</a></td>
<td class='docblock-short'>
<p>A custom type for temperature sysctls.</p>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class='enum' href='enum.CtlValue.html'
title='sysctl::CtlValue'>CtlValue</a></td>
<td class='docblock-short'>
<p>An Enum that holds all values returned by sysctl calls.
Extract inner value with <code>if let</code> or <code>match</code>.</p>
</td>
</tr></table><h2 id='constants' class='section-header'><a href="#constants">Constants</a></h2>
<table>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_ANYBODY.html'
title='sysctl::CTLFLAG_ANYBODY'>CTLFLAG_ANYBODY</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_CAPRD.html'
title='sysctl::CTLFLAG_CAPRD'>CTLFLAG_CAPRD</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_CAPRW.html'
title='sysctl::CTLFLAG_CAPRW'>CTLFLAG_CAPRW</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_CAPWR.html'
title='sysctl::CTLFLAG_CAPWR'>CTLFLAG_CAPWR</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_DYING.html'
title='sysctl::CTLFLAG_DYING'>CTLFLAG_DYING</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_DYN.html'
title='sysctl::CTLFLAG_DYN'>CTLFLAG_DYN</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_MPSAFE.html'
title='sysctl::CTLFLAG_MPSAFE'>CTLFLAG_MPSAFE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_NOFETCH.html'
title='sysctl::CTLFLAG_NOFETCH'>CTLFLAG_NOFETCH</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_PRISON.html'
title='sysctl::CTLFLAG_PRISON'>CTLFLAG_PRISON</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_RD.html'
title='sysctl::CTLFLAG_RD'>CTLFLAG_RD</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_RDTUN.html'
title='sysctl::CTLFLAG_RDTUN'>CTLFLAG_RDTUN</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_RW.html'
title='sysctl::CTLFLAG_RW'>CTLFLAG_RW</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_RWTUN.html'
title='sysctl::CTLFLAG_RWTUN'>CTLFLAG_RWTUN</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_SECURE.html'
title='sysctl::CTLFLAG_SECURE'>CTLFLAG_SECURE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_SECURE1.html'
title='sysctl::CTLFLAG_SECURE1'>CTLFLAG_SECURE1</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_SECURE2.html'
title='sysctl::CTLFLAG_SECURE2'>CTLFLAG_SECURE2</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_SECURE3.html'
title='sysctl::CTLFLAG_SECURE3'>CTLFLAG_SECURE3</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_SKIP.html'
title='sysctl::CTLFLAG_SKIP'>CTLFLAG_SKIP</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_STATS.html'
title='sysctl::CTLFLAG_STATS'>CTLFLAG_STATS</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_TUN.html'
title='sysctl::CTLFLAG_TUN'>CTLFLAG_TUN</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_VNET.html'
title='sysctl::CTLFLAG_VNET'>CTLFLAG_VNET</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLFLAG_WR.html'
title='sysctl::CTLFLAG_WR'>CTLFLAG_WR</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLMASK_SECURE.html'
title='sysctl::CTLMASK_SECURE'>CTLMASK_SECURE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLSHIFT_SECURE.html'
title='sysctl::CTLSHIFT_SECURE'>CTLSHIFT_SECURE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE.html'
title='sysctl::CTLTYPE'>CTLTYPE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_INT.html'
title='sysctl::CTLTYPE_INT'>CTLTYPE_INT</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_LONG.html'
title='sysctl::CTLTYPE_LONG'>CTLTYPE_LONG</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_NODE.html'
title='sysctl::CTLTYPE_NODE'>CTLTYPE_NODE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_OPAQUE.html'
title='sysctl::CTLTYPE_OPAQUE'>CTLTYPE_OPAQUE</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_S16.html'
title='sysctl::CTLTYPE_S16'>CTLTYPE_S16</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_S32.html'
title='sysctl::CTLTYPE_S32'>CTLTYPE_S32</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_S64.html'
title='sysctl::CTLTYPE_S64'>CTLTYPE_S64</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_S8.html'
title='sysctl::CTLTYPE_S8'>CTLTYPE_S8</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_STRING.html'
title='sysctl::CTLTYPE_STRING'>CTLTYPE_STRING</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_STRUCT.html'
title='sysctl::CTLTYPE_STRUCT'>CTLTYPE_STRUCT</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_U16.html'
title='sysctl::CTLTYPE_U16'>CTLTYPE_U16</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_U32.html'
title='sysctl::CTLTYPE_U32'>CTLTYPE_U32</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_U64.html'
title='sysctl::CTLTYPE_U64'>CTLTYPE_U64</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_U8.html'
title='sysctl::CTLTYPE_U8'>CTLTYPE_U8</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_UINT.html'
title='sysctl::CTLTYPE_UINT'>CTLTYPE_UINT</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTLTYPE_ULONG.html'
title='sysctl::CTLTYPE_ULONG'>CTLTYPE_ULONG</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='constant' href='constant.CTL_MAXNAME.html'
title='sysctl::CTL_MAXNAME'>CTL_MAXNAME</a></td>
<td class='docblock-short'>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='fn' href='fn.description.html'
title='sysctl::description'>description</a></td>
<td class='docblock-short'>
<p>Returns a result containing the sysctl description if success,
the errno caused by sysctl() as string if failure.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.set_value.html'
title='sysctl::set_value'>set_value</a></td>
<td class='docblock-short'>
<p>Sets the value of a sysctl.
Fetches and returns the new value if successful, errno string if failure.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.value.html'
title='sysctl::value'>value</a></td>
<td class='docblock-short'>
<p>Returns a result containing the sysctl value if success,
the errno caused by sysctl() as string if failure.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.value_as.html'
title='sysctl::value_as'>value_as</a></td>
<td class='docblock-short'>
<p>Returns a result containing the sysctl value if success,
the errno caused by sysctl() as string if failure.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>⇤</dt>
<dd>Move up in search results</dd>
<dt>⇥</dt>
<dd>Move down in search results</dd>
<dt>⏎</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "sysctl";
</script>
<script src="../jquery.js"></script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>