Cosmetic tweaks to the README
This commit is contained in:
parent
0d90e444c2
commit
97effdb2b3
1 changed files with 12 additions and 3 deletions
15
README.md
15
README.md
|
|
@ -173,6 +173,9 @@ handle the possible errors from the closing operation.
|
||||||
Here is an example usage:
|
Here is an example usage:
|
||||||
|
|
||||||
```nim
|
```nim
|
||||||
|
import
|
||||||
|
faststreams/inputs
|
||||||
|
|
||||||
var
|
var
|
||||||
jsonString = "[1, 2, 3]"
|
jsonString = "[1, 2, 3]"
|
||||||
jsonNodes = parseJson(unsafeMemoryInput(jsonString))
|
jsonNodes = parseJson(unsafeMemoryInput(jsonString))
|
||||||
|
|
@ -183,6 +186,9 @@ The example above assumes we might have a `parseJson` function accepting an
|
||||||
`InputStream`. Here how this function could be defined:
|
`InputStream`. Here how this function could be defined:
|
||||||
|
|
||||||
```nim
|
```nim
|
||||||
|
import
|
||||||
|
faststreams/inputs
|
||||||
|
|
||||||
proc scanString(stream: InputStream): JsonToken {.fsMultiSync.} =
|
proc scanString(stream: InputStream): JsonToken {.fsMultiSync.} =
|
||||||
result = newStringToken()
|
result = newStringToken()
|
||||||
|
|
||||||
|
|
@ -355,6 +361,9 @@ handle the possible errors from the closing operation.
|
||||||
Here is an example usage:
|
Here is an example usage:
|
||||||
|
|
||||||
```nim
|
```nim
|
||||||
|
import
|
||||||
|
faststreams/outputs
|
||||||
|
|
||||||
type
|
type
|
||||||
ABC = object
|
ABC = object
|
||||||
a: int
|
a: int
|
||||||
|
|
@ -371,7 +380,7 @@ let's see how it can be implemented:
|
||||||
|
|
||||||
```nim
|
```nim
|
||||||
import
|
import
|
||||||
typetraits, faststreams
|
typetraits, faststreams/outputs
|
||||||
|
|
||||||
proc writeNimRepr*(stream: OutputStream, str: string) =
|
proc writeNimRepr*(stream: OutputStream, str: string) =
|
||||||
stream.write '"'
|
stream.write '"'
|
||||||
|
|
@ -425,8 +434,6 @@ context or if a maximum memory usage policy is specified.
|
||||||
In a non-memory stream, any writes larger than a page or issued through the
|
In a non-memory stream, any writes larger than a page or issued through the
|
||||||
`writeNow` API will be sent to the output device immediately.
|
`writeNow` API will be sent to the output device immediately.
|
||||||
|
|
||||||
#### Delayed Writes
|
|
||||||
|
|
||||||
Please note that even in async context, `write` will complete immediately.
|
Please note that even in async context, `write` will complete immediately.
|
||||||
To handle back-pressure properly, use `stream.flush` or `stream.waitForConsumer`
|
To handle back-pressure properly, use `stream.flush` or `stream.waitForConsumer`
|
||||||
which will ensure that the buffered data is drained to a specified number of
|
which will ensure that the buffered data is drained to a specified number of
|
||||||
|
|
@ -434,6 +441,8 @@ bytes before continuing. The rationale here is that introducing an interruption
|
||||||
point at every `write` produces less optimal code, but if this is desired you
|
point at every `write` produces less optimal code, but if this is desired you
|
||||||
can use the `stream.writeAndWait` API.
|
can use the `stream.writeAndWait` API.
|
||||||
|
|
||||||
|
#### Delayed Writes
|
||||||
|
|
||||||
Many protocols and formats employ fixed-size and variable-size length prefixes
|
Many protocols and formats employ fixed-size and variable-size length prefixes
|
||||||
that have been tradionally difficult to handle because they require you to
|
that have been tradionally difficult to handle because they require you to
|
||||||
either measure the size of the content before writing it to the stream, or
|
either measure the size of the content before writing it to the stream, or
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue