forked from pola-rs/polars
/
trait.QueueableCommand.html
58 lines (51 loc) · 9.71 KB
/
trait.QueueableCommand.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!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="An interface for types that can queue commands for further execution."><meta name="keywords" content="rust, rustlang, rust-lang, QueueableCommand"><title>crossterm::QueueableCommand - 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><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><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">☰</div><a href='../crossterm/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait QueueableCommand</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.queue">queue</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">crossterm</a></p><div id="sidebar-vars" data-name="QueueableCommand" data-ty="trait" 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"><img src="../brush.svg" width="18" height="18" alt="Pick another theme!"></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" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="index.html">crossterm</a>::<wbr><a class="trait" href="">QueueableCommand</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/crossterm/command.rs.html#58-61" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait QueueableCommand {
fn <a href="#tymethod.queue" class="fnname">queue</a>(&mut self, command: impl <a class="trait" href="../crossterm/trait.Command.html" title="trait crossterm::Command">Command</a>) -> <a class="type" href="../crossterm/type.Result.html" title="type crossterm::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>;
}</pre></div><div class="docblock"><p>An interface for types that can queue commands for further execution.</p>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.queue" class="method"><code>fn <a href="#tymethod.queue" class="fnname">queue</a>(&mut self, command: impl <a class="trait" href="../crossterm/trait.Command.html" title="trait crossterm::Command">Command</a>) -> <a class="type" href="../crossterm/type.Result.html" title="type crossterm::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self></code><a class="srclink" href="../src/crossterm/command.rs.html#60" title="goto source code">[src]</a></h3><div class="docblock"><p>Queues the given command for further execution.</p>
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-QueueableCommand" class="impl"><code class="in-band">impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="../crossterm/trait.QueueableCommand.html" title="trait crossterm::QueueableCommand">QueueableCommand</a> for T</code><a href="#impl-QueueableCommand" class="anchor"></a><a class="srclink" href="../src/crossterm/command.rs.html#69-137" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.queue" class="method"><code>fn <a href="#method.queue" class="fnname">queue</a>(&mut self, command: impl <a class="trait" href="../crossterm/trait.Command.html" title="trait crossterm::Command">Command</a>) -> <a class="type" href="../crossterm/type.Result.html" title="type crossterm::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self></code><a class="srclink" href="../src/crossterm/command.rs.html#122-136" title="goto source code">[src]</a></h4><div class="docblock"><p>Queues the given command for further execution.</p>
<p>Queued commands will be executed in the following cases:</p>
<ul>
<li>When <code>flush</code> is called manually on the given type implementing <code>io::Write</code>.</li>
<li>The terminal will <code>flush</code> automatically if the buffer is full.</li>
<li>Each line is flushed in case of <code>stdout</code>, because it is line buffered.</li>
</ul>
<h1 id="arguments" class="section-header"><a href="#arguments">Arguments</a></h1>
<ul>
<li>
<p><a href="./trait.Command.html">Command</a></p>
<p>The command that you want to queue for later execution.</p>
</li>
</ul>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::{<span class="ident">Write</span>, <span class="ident">stdout</span>};
<span class="kw">use</span> <span class="ident">crossterm</span>::{<span class="prelude-ty">Result</span>, <span class="ident">QueueableCommand</span>, <span class="ident">style</span>::<span class="ident">Print</span>};
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">stdout</span> <span class="op">=</span> <span class="ident">stdout</span>();
<span class="comment">// `Print` will executed executed when `flush` is called.</span>
<span class="ident">stdout</span>
.<span class="ident">queue</span>(<span class="ident">Print</span>(<span class="string">"foo 1\n"</span>.<span class="ident">to_string</span>()))<span class="question-mark">?</span>
.<span class="ident">queue</span>(<span class="ident">Print</span>(<span class="string">"foo 2"</span>.<span class="ident">to_string</span>()))<span class="question-mark">?</span>;
<span class="comment">// some other code (no execution happening here) ...</span>
<span class="comment">// when calling `flush` on `stdout`, all commands will be written to the stdout and therefore executed.</span>
<span class="ident">stdout</span>.<span class="ident">flush</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
<span class="comment">// ==== Output ====</span>
<span class="comment">// foo 1</span>
<span class="comment">// foo 2</span>
}</pre></div>
<p>Have a look over at the <a href="./#command-api">Command API</a> for more details.</p>
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
<ul>
<li>In the case of UNIX and Windows 10, ANSI codes are written to the given ‘writer’.</li>
<li>In case of Windows versions lower than 10, a direct WinAPI call will be made.
The reason for this is that Windows versions lower than 10 do not support ANSI codes,
and can therefore not be written to the given <code>writer</code>.
Therefore, there is no difference between <a href="./trait.ExecutableCommand.html">execute</a>
and <a href="./trait.QueueableCommand.html">queue</a> for those old Windows versions.</li>
</ul>
</div></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../implementors/crossterm/trait.QueueableCommand.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="crossterm" data-search-js="../search-index.js"></div>
<script src="../main.js"></script></body></html>