nwaku/waku/common/paging.nim
Álex Cabeza Romero fae20bff20
refactor(store): HistoryQuery.direction (#2263)
* Fix issue with default history query ascending value in serde operations: Should use the same value.
* Update direction types to PagingDirection.
2023-12-19 15:10:27 +01:00

36 lines
649 B
Nim

import std/options
type
PagingDirection* {.pure.} = enum
## PagingDirection determines the direction of pagination
BACKWARD = uint32(0)
FORWARD = uint32(1)
proc default*(): PagingDirection {.inline.} =
PagingDirection.FORWARD
proc into*(b: bool): PagingDirection =
PagingDirection(b)
proc into*(b: Option[bool]): PagingDirection =
if b.isNone():
return default()
b.get().into()
proc into*(d: PagingDirection): bool =
d == PagingDirection.FORWARD
proc into*(d: Option[PagingDirection]): bool =
if d.isNone():
return false
d.get().into()
proc into*(s: string): PagingDirection =
(s == "true").into()