FSharpx.Async


AsyncStreamReader

Namespace: FSharpx.Control

Implements a TextReader-like API that asynchronously reads characters from a byte stream in a particular encoding.

Constructors

ConstructorDescription
new(...)
Signature: (stream:Stream * encoding:Encoding * detectEncodingFromByteOrderMarks:bool) -> AsyncStreamReader

CompiledName: .ctor

new(stream, encoding)
Signature: (stream:Stream * encoding:Encoding) -> AsyncStreamReader

CompiledName: .ctor

new(...)
Signature: (stream:Stream * detectEncodingFromByteOrderMarks:bool) -> AsyncStreamReader

CompiledName: .ctor

new(stream)
Signature: stream:Stream -> AsyncStreamReader

CompiledName: .ctor

new(...)
Signature: (stream:Stream * encoding:Encoding * detectEncodingFromByteOrderMarks:bool * bufferSize:int) -> AsyncStreamReader

Creates a new AsyncStreamReader for the given stream. The character encoding is set by encoding and the buffer size, in number of 16-bit characters, is set by bufferSize.

Note that detectEncodingFromByteOrderMarks is a very loose attempt at detecting the encoding by looking at the first 3 bytes of the stream. It will recognize UTF-8, little endian unicode, and big endian unicode text, but that's it. If neither of those three match, it will use the Encoding you provided.

CompiledName: .ctor

Instance members

Instance memberDescription
BaseStream
Signature: Stream

CompiledName: get_BaseStream

Close()
Signature: unit -> unit
CurrentEncoding
Signature: Encoding

CompiledName: get_CurrentEncoding

DiscardBufferedData()
Signature: unit -> unit

. DiscardBufferedData tells StreamReader to throw away its internal . buffer contents. This is useful if the user needs to seek on the underlying stream to a known location then wants the StreamReader to start reading from this new point. This method should be called very sparingly, if ever, since it can lead to very poor performance. However, it may be the only way of handling some scenarios where users need to re-read the contents of a StreamReader a second time.

EndOfStream
Signature: Async<bool>

An async that produces true if the reader is at the end of stream and false otherwise

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

CompiledName: get_EndOfStream

Peek()
Signature: unit -> Async<int>

Creates an async that produces next character from the stream without advancing the stream

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

Read(buffer, index, count)
Signature: (buffer:char [] * index:int * count:int) -> Async<int>

Creates an async that reads all the charactes that are avilable in the stream up to countbuffer starting at index. The async returns the number of characters that are read.

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

Read()
Signature: unit -> Async<char>

Creates an async that reads next character from the stream

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

ReadExactly(buffer, index, count)
Signature: (buffer:char [] * index:int * count:int) -> Async<int>

Creates an async that reads exactly count characters from the stream unless end of stream is reached and puts them into buffer starting at index. The async returns the number of characters that are read (if end-of-stream is not reached that will be count

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

ReadLine()
Signature: unit -> Async<string>

Creates an async that reads next line from the stream

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

ReadToEnd()
Signature: unit -> Async<string>

Creates an async that read all characters in the stream up to the end.

Note that when the async is run it reflects the reader state at the time of running; multiple runs will yield different results.

Fork me on GitHub