Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion async_postgres/pg_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,18 @@ proc `$`*(v: PgInterval): string =
proc `==`*(a, b: PgInterval): bool =
a.months == b.months and a.days == b.days and a.microseconds == b.microseconds

proc toBytes(s: string): seq[byte] =
proc toBytes*(s: string): seq[byte] =
## Converts a string to a sequence of bytes.
result = newSeq[byte](s.len)
if s.len > 0:
copyMem(addr result[0], unsafeAddr s[0], s.len)

proc toString*(s: seq[byte]): string =
## Converts a sequence of bytes to a string.
result = newString(s.len)
if s.len > 0:
copyMem(addr result[0], unsafeAddr s[0], s.len)

proc toBE16(v: int16): array[2, byte] =
[byte((v shr 8) and 0xFF), byte(v and 0xFF)]

Expand Down
Loading