Files
SwiftShell/docsets/SwiftShell.docset/Contents/Resources/Documents/Protocols/ReadableStream.html
T
2017-04-05 22:34:43 +02:00

503 lines
25 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<title>ReadableStream Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset='utf-8'>
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/ReadableStream" class="dashAnchor"></a>
<a title="ReadableStream Protocol Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">SwiftShell Docs</a> (67% documented)</p>
<p class="header-right"><a href="https://github.com/kareman/SwiftShell"><img src="../img/gh.png"/>View on GitHub</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="../index.html">SwiftShell Reference</a>
<img id="carat" src="../img/carat.png" />
ReadableStream Protocol Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="../Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Classes/AsyncCommand.html">AsyncCommand</a>
</li>
<li class="nav-group-task">
<a href="../Classes/FileHandleStream.html">FileHandleStream</a>
</li>
<li class="nav-group-task">
<a href="../Classes/MainContext.html">MainContext</a>
</li>
<li class="nav-group-task">
<a href="../Classes/RunOutput.html">RunOutput</a>
</li>
<li class="nav-group-task">
<a href="../Classes/StdoutStream.html">StdoutStream</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Global Variables.html">Global Variables</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Global Variables.html#/s:v10SwiftShell5FilesCSo11FileManager">Files</a>
</li>
<li class="nav-group-task">
<a href="../Global Variables.html#/s:v10SwiftShell4mainCS_11MainContext">main</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Enums.html">Enums</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Enums/CommandError.html">CommandError</a>
</li>
<li class="nav-group-task">
<a href="../Enums/FileError.html">FileError</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/FileHandle.html">FileHandle</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/FileHandle.html">FileHandle</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/LazyCollectionProtocol.html">LazyCollectionProtocol</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/Process.html">Process</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/String.html">String</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Functions.html">Functions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShelloi1pFTV10Foundation3URLSS_S1_">+(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShelloi2eeFTOS_12CommandErrorS0__Sb">==(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4exitFTPs5Error_4fileSS4lineSi_Os5Never">exit(_:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4exiturFT12errormessagex9errorcodeSi4fileSS4lineSi_Os5Never">exit(errormessage:errorcode:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4openFzTSS8encodingVE10FoundationSS8Encoding_PS_14ReadableStream_">open(_:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4openFzTV10Foundation3URL8encodingVES0_SS8Encoding_PS_14ReadableStream_">open(_:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4openFzT10forWritingSS9overwriteSb8encodingVE10FoundationSS8Encoding_PS_14WritableStream_">open(forWriting:overwrite:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell4openFzT10forWritingV10Foundation3URL9overwriteSb8encodingVES0_SS8Encoding_PS_14WritableStream_">open(forWriting:overwrite:encoding:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell3runFTSSGSaP__13combineOutputSb_CS_9RunOutput">run(_:_:combineOutput:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell3runFT4bashSS13combineOutputSb_CS_9RunOutput">run(bash:combineOutput:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell11runAndPrintFztSSGSaP___T_">runAndPrint(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell11runAndPrintFzT4bashSS_T_">runAndPrint(bash:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell8runAsyncFTSSGSaP__4fileSS4lineSi_CS_12AsyncCommand">runAsync(_:_:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell8runAsyncFT4bashSS4fileSS4lineSi_CS_12AsyncCommand">runAsync(bash:file:line:)</a>
</li>
<li class="nav-group-task">
<a href="../Functions.html#/s:F10SwiftShell7streamsFT_TPS_14WritableStream_PS_14ReadableStream__">streams()</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Protocols.html#/CommandRunning">CommandRunning</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/CommandRunning.html">CommandRunning</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/Context.html">Context</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/ReadableStream.html">ReadableStream</a>
</li>
<li class="nav-group-task">
<a href="../Protocols/WritableStream.html">WritableStream</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Structs.html">Structs</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Structs/CustomContext.html">CustomContext</a>
</li>
<li class="nav-group-task">
<a href="../Structs/LazySplitSequence.html">LazySplitSequence</a>
</li>
<li class="nav-group-task">
<a href="../Structs/PartialSourceLazySplitSequence.html">PartialSourceLazySplitSequence</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>ReadableStream</h1>
<div class="declaration">
<div class="language">
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">ReadableStream</span><span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">TextOutputStreamable</span><span class="p">,</span> <span class="kt"><a href="../Protocols/CommandRunning.html">CommandRunning</a></span></code></pre>
</div>
</div>
<p>A stream of text. Does as much as possible lazily.</p>
</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:vP10SwiftShell14ReadableStream8encodingVE10FoundationSS8Encoding"></a>
<a name="//apple_ref/swift/Property/encoding" class="dashAnchor"></a>
<a class="token" href="#/s:vP10SwiftShell14ReadableStream8encodingVE10FoundationSS8Encoding">encoding</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">ReadableStream</span><span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">TextOutputStreamable</span><span class="p">,</span> <span class="kt"><a href="../Protocols/CommandRunning.html">CommandRunning</a></span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:vP10SwiftShell14ReadableStream10filehandleCSo10FileHandle"></a>
<a name="//apple_ref/swift/Property/filehandle" class="dashAnchor"></a>
<a class="token" href="#/s:vP10SwiftShell14ReadableStream10filehandleCSo10FileHandle">filehandle</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">ReadableStream</span><span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">TextOutputStreamable</span><span class="p">,</span> <span class="kt"><a href="../Protocols/CommandRunning.html">CommandRunning</a></span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:FP10SwiftShell14ReadableStream8readSomeFT_GSqSS_"></a>
<a name="//apple_ref/swift/Method/readSome()" class="dashAnchor"></a>
<a class="token" href="#/s:FP10SwiftShell14ReadableStream8readSomeFT_GSqSS_">readSome()</a>
</code>
<span class="declaration-note">
Default implementation
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>All the text the stream contains so far.
If the source is a file this will read everything at once.
- Returns: more text from the stream, or nil if we have reached the end.</p>
</div>
<h4>Default Implementation</h4>
<div class="default_impl abstract">
<p>Reads everything at once.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">readSome</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">String</span><span class="p">?</span></code></pre>
</div>
</div>
<div>
<h4>Return Value</h4>
<p>more text from the stream, or nil if we have reached the end.</p>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:FP10SwiftShell14ReadableStream4readFT_SS"></a>
<a name="//apple_ref/swift/Method/read()" class="dashAnchor"></a>
<a class="token" href="#/s:FP10SwiftShell14ReadableStream4readFT_SS">read()</a>
</code>
<span class="declaration-note">
Default implementation
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Reads everything at once.</p>
</div>
<h4>Default Implementation</h4>
<div class="default_impl abstract">
<p>Reads everything at once.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">read</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">String</span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:FE10SwiftShellPS_14ReadableStream5linesFT_GVs12LazySequenceGVs11AnySequenceSS__"></a>
<a name="//apple_ref/swift/Method/lines()" class="dashAnchor"></a>
<a class="token" href="#/s:FE10SwiftShellPS_14ReadableStream5linesFT_GVs12LazySequenceGVs11AnySequenceSS__">lines()</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Splits stream lazily into lines.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">lines</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">LazySequence</span><span class="o">&lt;</span><span class="kt">AnySequence</span><span class="o">&lt;</span><span class="kt">String</span><span class="o">&gt;&gt;</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:FE10SwiftShellPS_14ReadableStream5writeuRd__s16TextOutputStreamrFT2toRqd___T_"></a>
<a name="//apple_ref/swift/Method/write(to:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE10SwiftShellPS_14ReadableStream5writeuRd__s16TextOutputStreamrFT2toRqd___T_">write(to:)</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Writes the text in this file to the given TextOutputStream.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">write</span><span class="o">&lt;</span><span class="kt">Target</span><span class="p">:</span> <span class="kt">TextOutputStream</span><span class="o">&gt;</span><span class="p">(</span><span class="n">to</span> <span class="nv">target</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Target</span><span class="p">)</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:vE10SwiftShellPS_14ReadableStream7contextPS_7Context_"></a>
<a name="//apple_ref/swift/Property/context" class="dashAnchor"></a>
<a class="token" href="#/s:vE10SwiftShellPS_14ReadableStream7contextPS_7Context_">context</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">ReadableStream</span><span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">TextOutputStreamable</span><span class="p">,</span> <span class="kt"><a href="../Protocols/CommandRunning.html">CommandRunning</a></span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:FE10SwiftShellPS_14ReadableStream8onOutputFT7handlerGSqFPS0__T___T_"></a>
<a name="//apple_ref/swift/Method/onOutput(handler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE10SwiftShellPS_14ReadableStream8onOutputFT7handlerGSqFPS0__T___T_">onOutput(handler:)</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>handler</code> will be called whenever there is new output available.
Pass <code>nil</code> to remove any preexisting handlers.
- Note: if the stream is read from outside of the handler, or more than once inside
the handler, it may be called once when stream is closed and empty.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">onOutput</span> <span class="p">(</span> <span class="nv">handler</span><span class="p">:</span> <span class="p">((</span><span class="kt">ReadableStream</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">())?</span> <span class="p">)</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:FE10SwiftShellPS_14ReadableStream14onStringOutputFT7handlerGSqFSST___T_"></a>
<a name="//apple_ref/swift/Method/onStringOutput(handler:)" class="dashAnchor"></a>
<a class="token" href="#/s:FE10SwiftShellPS_14ReadableStream14onStringOutputFT7handlerGSqFSST___T_">onStringOutput(handler:)</a>
</code>
<span class="declaration-note">
Extension method
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>handler</code> will be called whenever there is new text output available.
Pass <code>nil</code> to remove any preexisting handlers.
- Note: if the stream is read from outside of the handler, or more than once inside
the handler, it may be called once when stream is closed and empty.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">onStringOutput</span> <span class="p">(</span> <span class="nv">handler</span><span class="p">:</span> <span class="p">((</span><span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">())?</span> <span class="p">)</span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2017 <a class="link" href="" target="_blank" rel="external">kareman</a>. All rights reserved. (Last updated: 2017-04-05)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>