ReadableStream
public protocol ReadableStream: class, TextOutputStreamable, CommandRunning
A stream of text. Does as much as possible lazily.
-
Undocumented
Declaration
Swift
var encoding: String.Encoding -
Undocumented
Declaration
Swift
var filehandle: FileHandle -
readSome()Default implementationAll the text the stream contains so far. If the source is a file this will read everything at once. If the stream is empty and still open this will wait for more content or end-of-file.
Default Implementation
Declaration
Swift
func readSome() -> String?Return Value
more text from the stream, or nil if we have reached the end.
-
read()Default implementationReads everything at once.
Default Implementation
Declaration
Swift
func read() -> String
-
lines()Extension methodSplits stream lazily into lines.
Declaration
Swift
public func lines() -> LazySequence<AnySequence<String>> -
write(to:)Extension methodWrites the text in this stream to the given TextOutputStream.
Declaration
Swift
public func write<Target: TextOutputStream>(to target: inout Target) -
write(to:)Extension methodWrites the text in this stream to the given WritableStream.
Declaration
Swift
public func write(to target: inout WritableStream) -
contextExtension methodUndocumented
Declaration
Swift
public var context: Context -
readSomeData()Extension methodAll the data the stream contains so far. If the source is a file this will read everything at once. If the stream is empty and still open this will wait for more content or end-of-file.
Declaration
Swift
public func readSomeData() -> Data?Return Value
more data from the stream, or nil if we have reached the end.
-
readData()Extension methodReads everything at once.
Declaration
Swift
public func readData() -> Data
-
onOutput(_:)Extension methodhandlerwill be called whenever there is new output available.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.Declaration
Swift
public func onOutput(_ handler: @escaping (ReadableStream) -> Void) -
onStringOutput(_:)Extension methodhandlerwill be called whenever there is new text output available.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.Declaration
Swift
public func onStringOutput(_ handler: @escaping (String) -> Void)
View on GitHub
ReadableStream Protocol Reference