ReadableStream
public protocol ReadableStream : AnyObject, TextOutputStreamable, CommandRunning
A stream of text. Does as much as possible lazily.
-
Undocumented
Declaration
Swift
var encoding: String.Encoding { get set }
-
Undocumented
Declaration
Swift
var filehandle: FileHandle { get }
-
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>(to target: inout Target) where Target : TextOutputStream
-
write(to:)
Extension methodWrites the text in this stream to the given WritableStream.
Declaration
Swift
public func write(to target: inout WritableStream)
-
context
Extension methodUndocumented
Declaration
Swift
public var context: Context { get }
-
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. Marked with @discardableResult so that the stream can be read before calling .finish() without causing any compiler warnings or requiring developer work-arounds when the result will not be used (see #52 & #57)
Declaration
Swift
@discardableResult public func readData() -> Data
-
onOutput(_:)
Extension methodSets code to be executed whenever there is new output available.
Note
if the stream is read from outside ofhandler
, or more than once inside it, it may be called once when stream is closed and empty.Declaration
Swift
public func onOutput(_ handler: @escaping (ReadableStream) -> Void)
-
onStringOutput(_:)
Extension methodSets code to be executed whenever there is new text output available.
Note
if the stream is read from outside ofhandler
, or more than once inside it, it may be called once when stream is closed and empty.Declaration
Swift
public func onStringOutput(_ handler: @escaping (String) -> Void)