<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="API documentation for the Rust `termios` mod in crate `nix`."><metaname="keywords"content="rust, rustlang, rust-lang, termios"><title>nix::sys::termios - Rust</title><linkrel="stylesheet"type="text/css"href="../../../normalize.css"><linkrel="stylesheet"type="text/css"href="../../../rustdoc.css"id="mainThemeStyle"><linkrel="stylesheet"type="text/css"href="../../../dark.css"><linkrel="stylesheet"type="text/css"href="../../../light.css"id="themeStyle"><scriptsrc="../../../storage.js"></script><noscript><linkrel="stylesheet"href="../../../noscript.css"></noscript><linkrel="shortcut icon"href="../../../favicon.ico"><styletype="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><bodyclass="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="sidebar"><divclass="sidebar-menu">☰</div><ahref='../../../nix/index.html'><divclass='logo-container'><imgsrc='../../../rust-logo.png'alt='logo'></div></a><pclass='location'>Module termios</p><divclass="sidebar-elems"><divclass="block items"><ul><li><ahref="#structs">Structs</a></li><li><ahref="#enums">Enums</a></li><li><ahref="#constants">Constants</a></li><li><ahref="#functions">Functions</a></li></ul></div><pclass='location'><ahref='../../index.html'>nix</a>::<wbr><ahref='../index.html'>sys</a></p><script>window.sidebarCurrent={name:'termios',ty:'mod',relpath:'../'};</script><scriptdefersrc="../sidebar-items.js"></script></div></nav><divclass="theme-picker"><buttonid="theme-picker"aria-label="Pick another theme!"><imgsrc="../../../brush.svg"width="18"alt="Pick another theme!"></button><divid="theme-choices"></div></div><scriptsrc="../../../theme.js"></script><navclass="sub"><formclass="search-form js-only"><divclass="search-container"><div><selectid="crate-search"><optionvalue="All crates">All crates</option></select><inputclass="search-input"name="search"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"></div><aid="settings-menu"href="../../../settings.html"><imgsrc="../../../wheel.svg"width="18"alt="Change settings"></a></div></form></nav><sectionid="main"class="content"><h1class='fqn'><spanclass='out-of-band'><spanid='render-detail'><aid="toggle-all-docs"href="javascript:void(0)"title="collapse all docs">[<spanclass='inner'>−</span>]</a></span><aclass='srclink'href='../../../src/nix/sys/termios.rs.html#1-1107'title='goto source code'>[src]</a></span><spanclass='in-band'>Module <ahref='../../index.html'>nix</a>::<wbr><ahref='../index.html'>sys</a>::<wbr><aclass="mod"href=''>termios</a></span></h1><divclass='docblock'><p>An interface for controlling asynchronous communication ports</p>
<p>This interface provides a safe wrapper around the termios subsystem defined by POSIX. The
underlying types are all implemented in libc for most platforms and either wrapped in safer
types here or exported directly.</p>
<p>If you are unfamiliar with the <code>termios</code> API, you should first read the
<ahref="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/termios.h.html">API documentation</a> and
then come back to understand how <code>nix</code> safely wraps it.</p>
<p>It should be noted that this API incurs some runtime overhead above the base <code>libc</code> definitions.
As this interface is not used with high-bandwidth information, this should be fine in most
cases. The primary cost when using this API is that the <code>Termios</code> datatype here duplicates the
standard fields of the underlying <code>termios</code> struct and uses safe type wrappers for those fields.
This means that when crossing the FFI interface to the underlying C library, data is first
copied into the underlying <code>termios</code> struct, then the operation is done, and the data is copied
back (with additional sanity checking) into the safe wrapper types. The <code>termios</code> struct is
relatively small across all platforms (on the order of 32-64 bytes).</p>
<p>The following examples highlight some of the API use cases such that users coming from using C
or reading the standard documentation will understand how to use the safe API exposed here.</p>
<p>Example disabling processing of the end-of-file control character:</p>
<divclass='information'><divclass='tooltip ignore'>ⓘ<spanclass='tooltiptext'>This example is not tested</span></div></div><divclass="example-wrap"><preclass="rust rust-example-rendered ignore">
<table><trclass='module-item'><td><aclass="struct"href="struct.ControlFlags.html"title='nix::sys::termios::ControlFlags struct'>ControlFlags</a></td><tdclass='docblock-short'><p>Flags for setting the control mode of a terminal</p>
</td></tr><trclass='module-item'><td><aclass="struct"href="struct.InputFlags.html"title='nix::sys::termios::InputFlags struct'>InputFlags</a></td><tdclass='docblock-short'><p>Flags for configuring the input mode of a terminal</p>
</td></tr><trclass='module-item'><td><aclass="struct"href="struct.LocalFlags.html"title='nix::sys::termios::LocalFlags struct'>LocalFlags</a></td><tdclass='docblock-short'><p>Flags for setting any local modes</p>
</td></tr><trclass='module-item'><td><aclass="struct"href="struct.OutputFlags.html"title='nix::sys::termios::OutputFlags struct'>OutputFlags</a></td><tdclass='docblock-short'><p>Flags for configuring the output mode of a terminal</p>
</td></tr><trclass='module-item'><td><aclass="struct"href="struct.Termios.html"title='nix::sys::termios::Termios struct'>Termios</a></td><tdclass='docblock-short'><p>Stores settings for the termios API</p>
<table><trclass='module-item'><td><aclass="enum"href="enum.BaudRate.html"title='nix::sys::termios::BaudRate enum'>BaudRate</a></td><tdclass='docblock-short'><p>Baud rates supported by the system.</p>
</td></tr><trclass='module-item'><td><aclass="enum"href="enum.FlowArg.html"title='nix::sys::termios::FlowArg enum'>FlowArg</a></td><tdclass='docblock-short'><p>Specify how transmission flow should be altered</p>
</td></tr><trclass='module-item'><td><aclass="enum"href="enum.FlushArg.html"title='nix::sys::termios::FlushArg enum'>FlushArg</a></td><tdclass='docblock-short'><p>Specify a combination of the input and output buffers to flush</p>
</td></tr><trclass='module-item'><td><aclass="enum"href="enum.SetArg.html"title='nix::sys::termios::SetArg enum'>SetArg</a></td><tdclass='docblock-short'><p>Specify when a port configuration change should occur.</p>
</td></tr><trclass='module-item'><td><aclass="enum"href="enum.SpecialCharacterIndices.html"title='nix::sys::termios::SpecialCharacterIndices enum'>SpecialCharacterIndices</a></td><tdclass='docblock-short'><p>Indices into the <code>termios.c_cc</code> array for special characters.</p>
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.cfmakeraw.html"title='nix::sys::termios::cfmakeraw fn'>cfmakeraw</a></td><tdclass='docblock-short'><p>Configures the port to something like the "raw" mode of the old Version 7 terminal driver (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.cfsetspeed.html"title='nix::sys::termios::cfsetspeed fn'>cfsetspeed</a></td><tdclass='docblock-short'><p>Set both the input and output baud rates (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcdrain.html"title='nix::sys::termios::tcdrain fn'>tcdrain</a></td><tdclass='docblock-short'><p>Block until all output data is written (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcflow.html"title='nix::sys::termios::tcflow fn'>tcflow</a></td><tdclass='docblock-short'><p>Suspend or resume the transmission or reception of data (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcflush.html"title='nix::sys::termios::tcflush fn'>tcflush</a></td><tdclass='docblock-short'><p>Discard data in the output or input queue (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcgetattr.html"title='nix::sys::termios::tcgetattr fn'>tcgetattr</a></td><tdclass='docblock-short'><p>Return the configuration of a port
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcgetsid.html"title='nix::sys::termios::tcgetsid fn'>tcgetsid</a></td><tdclass='docblock-short'><p>Get the session controlled by the given terminal (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcsendbreak.html"title='nix::sys::termios::tcsendbreak fn'>tcsendbreak</a></td><tdclass='docblock-short'><p>Send a break for a specific duration (see
</td></tr><trclass='module-item'><td><aclass="fn"href="fn.tcsetattr.html"title='nix::sys::termios::tcsetattr fn'>tcsetattr</a></td><tdclass='docblock-short'><p>Set the configuration for a terminal (see
</td></tr></table></section><sectionid="search"class="content hidden"></section><sectionclass="footer"></section><asideid="help"class="hidden"><div><h1class="hidden">Help</h1><divclass="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><divclass="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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath="../../../";window.currentCrate="nix";</script><scriptsrc="../../../aliases.js"></script><scriptsrc="../../../main.js"></script><scriptdefersrc="../../../search-index.js"></script></body></html>