diff --git a/rlp.nim b/rlp.nim index cdc44d5..90e28c2 100644 --- a/rlp.nim +++ b/rlp.nim @@ -278,7 +278,7 @@ proc read*(rlp: var Rlp, T: typedesc[enum]): T = proc read*[R, E](rlp: var Rlp, T: type array[R, E]): T = mixin read - when E is byte: + when E is (byte or char): if not rlp.isBlob: raise newException(BadCastError, "The source RLP is not a blob.") @@ -302,7 +302,7 @@ proc read*[R, E](rlp: var Rlp, T: type array[R, E]): T = proc read*[E](rlp: var Rlp, T: type seq[E]): T = mixin read - when E is byte: + when E is (byte or char): var bytes = rlp.toBytes result = newSeq[byte](bytes.len) copyMem(addr result[0], bytes.baseAddr, bytes.len) diff --git a/rlp/writer.nim b/rlp/writer.nim index 122f667..1bd78ca 100644 --- a/rlp/writer.nim +++ b/rlp/writer.nim @@ -148,6 +148,9 @@ proc append*(self; data: string) = proc appendBlob(self; data: openarray[byte]) = appendImpl(self, data, BLOB_START_MARKER) +proc appendBlob(self; data: openarray[char]) = + appendImpl(self, data, BLOB_START_MARKER) + proc appendBytesRange(self; data: BytesRange) = appendImpl(self, data, BLOB_START_MARKER) @@ -176,7 +179,7 @@ proc append*[T](self; listOrBlob: openarray[T]) = # TODO: This append proc should be overloaded by `openarray[byte]` after # nim bug #7416 is fixed. - when T is byte: + when T is (byte or char): self.appendBlob(listOrBlob) else: self.startList listOrBlob.len