mirror of
https://github.com/status-im/nim-serialization.git
synced 2025-01-28 20:55:45 +00:00
Use the latest FastStreams API
This commit is contained in:
parent
f310607d04
commit
5e8ec3485c
@ -58,11 +58,11 @@ template decode*(Format: distinct type,
|
||||
# from the fact that the dynamic dispatch mechanisms used in
|
||||
# faststreams may be reading from a file or a network device.
|
||||
try:
|
||||
var stream = memoryInput(input)
|
||||
var stream = unsafeMemoryInput(input)
|
||||
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
||||
reader.readValue(RecordType)
|
||||
except IOError:
|
||||
raise (ref Defect)() # A memoryInput cannot have an IOError
|
||||
raise (ref Defect)() # memory inputs cannot raise an IOError
|
||||
|
||||
template decode*(Format: distinct type,
|
||||
input: openarray[byte],
|
||||
@ -77,11 +77,11 @@ template decode*(Format: distinct type,
|
||||
# from the fact that the dynamic dispatch mechanisms used in
|
||||
# faststreams may be reading from a file or a network device.
|
||||
try:
|
||||
var stream = memoryInput(input)
|
||||
var stream = unsafeMemoryInput(input)
|
||||
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
||||
reader.readValue(RecordType)
|
||||
except IOError:
|
||||
raise (ref Defect)() # a memoryInput cannot have an IOError
|
||||
raise (ref Defect)() # memory inputs cannot raise an IOError
|
||||
|
||||
template loadFile*(Format: distinct type,
|
||||
filename: string,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import
|
||||
unittest, times, typetraits, random, strutils, options, sets, tables,
|
||||
faststreams/input_stream,
|
||||
faststreams/inputs,
|
||||
../../serialization, ../object_serialization
|
||||
|
||||
type
|
||||
@ -318,7 +318,7 @@ proc executeReaderWriterTests*(Format: type) =
|
||||
check fieldReader != nil and idx == 1
|
||||
|
||||
var bytes = Format.encode("test")
|
||||
var stream = memoryInput(bytes)
|
||||
var stream = unsafeMemoryInput(bytes)
|
||||
var reader = Reader.init(stream)
|
||||
|
||||
var bar: Bar
|
||||
|
Loading…
x
Reference in New Issue
Block a user