query fixes

This commit is contained in:
Jaremy Creechley 2023-09-25 18:18:29 -07:00
parent f9e5992555
commit 3b30cc8b8a
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300

View File

@ -46,23 +46,11 @@ template toVal*(tp: typedesc[DataBuffer], id: openArray[byte]): DataBuffer = Dat
template toVal*(tp: typedesc[seq[byte]], id: openArray[byte]): seq[byte] = @(id)
proc new*(tp: typedesc[KeyId], id: cstring): KeyId =
## copy cstring including null terminator
KeyId(data: DataBuffer.new(id.toOpenArray(0, id.len()-1)))
proc new*(tp: typedesc[KeyId], id: string): KeyId =
## copy cstring including null terminator
KeyId(data: DataBuffer.new(id))
# proc toCString*(key: KeyId): cstring =
# ## copy cstring including null terminator
# cast[cstring](baseAddr key.data)
# proc toDb*(key: Key): DbKey {.inline, raises: [].} =
# let id: string = key.id()
# let db = DataBuffer.new(id.len()+1) # include room for null for cstring compat
# db.setData(id)
# DbKey(data: db)
proc toKey*(key: KeyId): Key {.inline, raises: [].} =
Key.init(key.data).expect("expected valid key here for but got `" & $key.data & "`")