I am working on my timezone library (
[https://github.com/treeform/chrono](https://github.com/treeform/chrono) ) and
I would like to pack timezone definitions into the binary. I can do that with
staticRead, but then I have to read the binary out of the string. My binary
uses the exact same flat (no nested structures) as the seq memory. Is there a
way for me to just say seq should point to the bytes from staticRead without
doing any copies or reads?
Here is the code I have now which feels super complex (and stupid):
const zoneData = staticRead("../tzdata/timeZones.bin")
var timeZones* = newSeq[TimeZone](zoneData.len div sizeof(TimeZone)) ##
List of all timezones
var zoneStream = newStringStream(zoneData)
for i in 0..<timeZones.len:
var dummyZone = TimeZone()
discard zoneStream.readData(cast[pointer](addr dummyZone),
sizeof(TimeZone))
timeZones[i] = dummyZone
I want to have code look more like this:
var timeZones = newSeq[TimeZone](0)
var timeZonesBin = staticRead("../tzdata/timeZones.bin")
timeZone.internalPointer = addr timeZonesBin[0]
timeZone.len = timeZonesBin.len div sizeof(TimeZone)
Thanks!