Up-to-date README

This commit is contained in:
Zahary Karadjov 2018-09-17 13:12:40 +03:00 committed by zah
parent 6556821572
commit d248146313
1 changed files with 12 additions and 4 deletions

View File

@ -22,11 +22,13 @@ $ nimble install rlp
The `Rlp` type provided by this library represents a cursor over a RLP-encoded The `Rlp` type provided by this library represents a cursor over a RLP-encoded
byte stream. Before instantiating such a cursor, you must convert your byte stream. Before instantiating such a cursor, you must convert your
input data to a `BytesRange` object, which represents an immutable and input data a `BytesRange` value provided by the [nim-ranges][RNG] library,
thus cheap-to-copy sub-range view over an underlying `seq[byte]` instance: which represents an immutable and thus cheap-to-copy sub-range view over an
underlying `seq[byte]` instance:
[RNG]: https://github.com/status-im/nim-ranges
``` nim ``` nim
proc initBytesRange*(s: var seq[byte], ibegin = 0, iend = -1): BytesRange
proc rlpFromBytes*(data: BytesRange): Rlp proc rlpFromBytes*(data: BytesRange): Rlp
``` ```
@ -54,7 +56,7 @@ such as `string`, `int`, `seq[T]`, etc, including composite user-defined
types (see [Object Serialization](#object-serialization)). The cursor types (see [Object Serialization](#object-serialization)). The cursor
will be advanced just past the end of the consumed object. will be advanced just past the end of the consumed object.
The `toXX` and `read` family of procs may raise a `BadCastError` in case The `toXX` and `read` family of procs may raise a `RlpTypeMismatch` in case
of type mismatch with the stream contents under the cursor. A corrupted of type mismatch with the stream contents under the cursor. A corrupted
RLP stream or an attemp to read past the stream end will be signaled RLP stream or an attemp to read past the stream end will be signaled
with the `MalformedRlpError` exception. If the RLP stream includes data with the `MalformedRlpError` exception. If the RLP stream includes data
@ -137,6 +139,12 @@ var bytes = encode(t1)
var t2 = bytes.decode(Transaction) var t2 = bytes.decode(Transaction)
``` ```
By default, sub-fields within objects are wrapped in RLP lists. You can avoid this
behavior by adding the custom pragma `rlpInline` on a particular field. In rare
circumstances, you may need to serialize the same field type differently depending
on the enclosing object type. You can use the `rlpCustomSerialization` pragma to
achieve this.
## Contributing / Testing ## Contributing / Testing
To test the correctness of any modifications to the library, please execute To test the correctness of any modifications to the library, please execute