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
|
# from the fact that the dynamic dispatch mechanisms used in
|
||||||
# faststreams may be reading from a file or a network device.
|
# faststreams may be reading from a file or a network device.
|
||||||
try:
|
try:
|
||||||
var stream = memoryInput(input)
|
var stream = unsafeMemoryInput(input)
|
||||||
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
||||||
reader.readValue(RecordType)
|
reader.readValue(RecordType)
|
||||||
except IOError:
|
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,
|
template decode*(Format: distinct type,
|
||||||
input: openarray[byte],
|
input: openarray[byte],
|
||||||
|
@ -77,11 +77,11 @@ template decode*(Format: distinct type,
|
||||||
# from the fact that the dynamic dispatch mechanisms used in
|
# from the fact that the dynamic dispatch mechanisms used in
|
||||||
# faststreams may be reading from a file or a network device.
|
# faststreams may be reading from a file or a network device.
|
||||||
try:
|
try:
|
||||||
var stream = memoryInput(input)
|
var stream = unsafeMemoryInput(input)
|
||||||
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
||||||
reader.readValue(RecordType)
|
reader.readValue(RecordType)
|
||||||
except IOError:
|
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,
|
template loadFile*(Format: distinct type,
|
||||||
filename: string,
|
filename: string,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import
|
import
|
||||||
unittest, times, typetraits, random, strutils, options, sets, tables,
|
unittest, times, typetraits, random, strutils, options, sets, tables,
|
||||||
faststreams/input_stream,
|
faststreams/inputs,
|
||||||
../../serialization, ../object_serialization
|
../../serialization, ../object_serialization
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -318,7 +318,7 @@ proc executeReaderWriterTests*(Format: type) =
|
||||||
check fieldReader != nil and idx == 1
|
check fieldReader != nil and idx == 1
|
||||||
|
|
||||||
var bytes = Format.encode("test")
|
var bytes = Format.encode("test")
|
||||||
var stream = memoryInput(bytes)
|
var stream = unsafeMemoryInput(bytes)
|
||||||
var reader = Reader.init(stream)
|
var reader = Reader.init(stream)
|
||||||
|
|
||||||
var bar: Bar
|
var bar: Bar
|
||||||
|
|
Loading…
Reference in New Issue