diff --git a/src/Tupfile b/src/Tupfile new file mode 100644 index 0000000..1ec15e2 --- /dev/null +++ b/src/Tupfile @@ -0,0 +1,5 @@ +include_rules +modules += json_socket_translator.nim +modules += json_translator.nim +modules += msg.nim +: foreach $(modules) | $(SYNDICATE_PROTOCOL) ./ |> !nim_bin |> diff --git a/src/http_translator.nim b/src/http_translator.nim index 9574033..e8f244b 100644 --- a/src/http_translator.nim +++ b/src/http_translator.nim @@ -37,7 +37,7 @@ bootDataspace("main") do (ds: Ref; turn: var Turn): pathPrefixMaxLen = 0 requestIdSource = 0 - during(turn, ds, ?Handler[Ref]) do (methods: Methods; path: seq[string]; entity: Ref): + during(turn, ds, ?Handler) do (methods: Methods; path: seq[string]; entity: Ref): handlers[path] = (entity, methods.toHttpCore) pathPrefixMaxLen = max(pathPrefixMaxLen, path.len) do: diff --git a/src/msg.nim b/src/msg.nim index afb163d..565f3df 100644 --- a/src/msg.nim +++ b/src/msg.nim @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Unlicense import std/[asyncdispatch, os] -from std/sequtils import map import preserves, syndicate, syndicate/capabilities proc unixSocketPath: string = @@ -12,7 +11,7 @@ proc unixSocketPath: string = proc mintCap: SturdyRef = var key: array[16, byte] - mint(key, "syndicate") + mint(key, toPreserve("syndicate", Ref)) bootDataspace("main") do (root: Ref; turn: var Turn): let label = getAppFilename().extractFilename diff --git a/src/schema/Tupfile b/src/schema/Tupfile index b2813f2..f405409 100644 --- a/src/schema/Tupfile +++ b/src/schema/Tupfile @@ -1,2 +1,2 @@ include_rules -: foreach ../../*.prs |> !preserves_schema_nim |> %B.nim +: foreach ../../*.prs |> !preserves_schema_nim |> %B.nim | ../ diff --git a/src/schema/http_protocol.nim b/src/schema/http_protocol.nim index 9c5f7ac..0ea6e17 100644 --- a/src/schema/http_protocol.nim +++ b/src/schema/http_protocol.nim @@ -1,44 +1,38 @@ import - std/typetraits, preserves, std/tables, std/sets + std/typetraits, preserves, std/tables type Path* = seq[string] - Headers* = TableRef[string, seq[string]] + Headers* = Table[string, seq[string]] Response* {.preservesRecord: "http".} = object - `handle`*: int - `code`*: int + `handle`*: BiggestInt + `code`*: BiggestInt `headers`*: Headers `body`*: string Listener* {.preservesRecord: "listen".} = object - `port`*: int + `port`*: BiggestInt - Handler*[E] {.preservesRecord: "handler".} = ref object + Handler* {.preservesRecord: "handler".} = object `methods`*: Methods `path`*: Path - `entity`*: Preserve[E] + `entity`* {.preservesEmbedded.}: Preserve[void] `Method`* {.preservesOr, pure.} = enum `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH` Request* {.preservesRecord: "http".} = object - `handle`*: int + `handle`*: BiggestInt `method`*: Method `headers`*: Headers `path`*: Path `body`*: string - Methods* = HashSet[Method] -proc `$`*[E](x: Handler[E]): string = - `$`(toPreserve(x, E)) - -proc encode*[E](x: Handler[E]): seq[byte] = - encode(toPreserve(x, E)) - -proc `$`*(x: Path | Headers | Response | Listener | Request | Methods): string = + Methods* = set[Method] +proc `$`*(x: Path | Headers | Response | Listener | Handler | Request | Methods): string = `$`(toPreserve(x)) -proc encode*(x: Path | Headers | Response | Listener | Request | Methods): seq[ - byte] = +proc encode*(x: Path | Headers | Response | Listener | Handler | Request | + Methods): seq[byte] = encode(toPreserve(x)) diff --git a/src/schema/notifications.nim b/src/schema/notifications.nim index cb0194c..8a45733 100644 --- a/src/schema/notifications.nim +++ b/src/schema/notifications.nim @@ -3,16 +3,16 @@ import std/typetraits, preserves type - Notify*[E] {.preservesRecord: "notify".} = ref object + Notify* {.preservesRecord: "notify".} = object `summary`*: string - `body`*: Preserve[E] - `timeout`*: int + `body`*: Preserve[void] + `timeout`*: BiggestInt `urgency`*: Urgency `Urgency`* {.preservesOr, pure.} = enum `Low`, `Normal`, `Critical` -proc `$`*[E](x: Notify[E]): string = - `$`(toPreserve(x, E)) +proc `$`*(x: Notify): string = + `$`(toPreserve(x)) -proc encode*[E](x: Notify[E]): seq[byte] = - encode(toPreserve(x, E)) +proc encode*(x: Notify): seq[byte] = + encode(toPreserve(x)) diff --git a/syndicate_utils.nimble b/syndicate_utils.nimble index 0b0bb97..619b44a 100644 --- a/syndicate_utils.nimble +++ b/syndicate_utils.nimble @@ -1,6 +1,6 @@ # Package -version = "99999999" +version = "20230301" author = "Emery Hemingway" description = "Utilites for Syndicated Actors and Synit" license = "unlicense"