Replacement for xdg-open that uses Syndicate for messaging (Embrace, Extend, Extinguish).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xdg_open_ng/src/protocol.nim

39 lines
1021 B

import
std/typetraits, preserves
type
XdgOpen* {.preservesRecord: "xdg-open".} = object
`uris`*: seq[string]
UriRunnerConfigKind* {.pure.} = enum
`ListenOn`, `ActionHandler`
`UriRunnerConfig`*[E] {.preservesOr.} = ref object
case orKind*: UriRunnerConfigKind
of UriRunnerConfigKind.`ListenOn`:
`listenon`*: ListenOn[E]
of UriRunnerConfigKind.`ActionHandler`:
`actionhandler`*: ActionHandler[E]
ListenOn*[E] {.preservesRecord: "listen-on".} = ref object
`dataspace`*: Preserve[E]
ActionHandler*[E] {.preservesRecord: "action-handler".} = ref object
`pat`*: string
`action`*: Preserve[E]
`entity`*: Preserve[E]
proc `$`*[E](x: UriRunnerConfig[E] | ListenOn[E] | ActionHandler[E]): string =
`$`(toPreserve(x, E))
proc encode*[E](x: UriRunnerConfig[E] | ListenOn[E] | ActionHandler[E]): seq[
byte] =
encode(toPreserve(x, E))
proc `$`*(x: XdgOpen): string =
`$`(toPreserve(x))
proc encode*(x: XdgOpen): seq[byte] =
encode(toPreserve(x))