Regenerate protocol modules
This commit is contained in:
parent
17c7328be8
commit
c4dace1eb7
|
@ -28,7 +28,7 @@ proc genId(T: type): T =
|
||||||
type
|
type
|
||||||
Attenuation = sturdy.Attenuation[Ref]
|
Attenuation = sturdy.Attenuation[Ref]
|
||||||
Oid = sturdy.Oid
|
Oid = sturdy.Oid
|
||||||
Assertion* = protocol.Assertion[Ref]
|
Assertion* = Preserve[Ref]
|
||||||
Caveat = sturdy.Caveat[Ref]
|
Caveat = sturdy.Caveat[Ref]
|
||||||
Rewrite = sturdy.Rewrite[Ref]
|
Rewrite = sturdy.Rewrite[Ref]
|
||||||
|
|
||||||
|
|
|
@ -4,44 +4,22 @@
|
||||||
import preserves
|
import preserves
|
||||||
import ./protocols/sturdy, ./private/hmacs
|
import ./protocols/sturdy, ./private/hmacs
|
||||||
|
|
||||||
from ./actors import Ref
|
proc mint*[T](key: openarray[byte]; oid: Preserve[T]): SturdyRef[T] =
|
||||||
|
SturdyRef[T](oid: oid, sig: hmacSha256(key, encode(oid), key.len))
|
||||||
|
|
||||||
type SturdyRef* = sturdy.SturdyRef[Ref]
|
proc mint*[T](key: openarray[byte]; oid: T; E = void): SturdyRef[E] =
|
||||||
|
var oidPr = toPreserve(oid, E)
|
||||||
|
SturdyRef[E](oid: oidPr, sig: hmacSha256(key, encode(oidPr), key.len))
|
||||||
|
|
||||||
proc mint*(key: openarray[byte]; oid: Preserve[Ref]): SturdyRef =
|
proc attenuate*[T](r: SturdyRef[T]; caveats: Attenuation): SturdyRef[T] =
|
||||||
SturdyRef(oid: oid, sig: hmacSha256(key, encode(oid), key.len))
|
result = SturdyRef[T](
|
||||||
|
|
||||||
proc mint*[T](key: openarray[byte]; oid: T): SturdyRef =
|
|
||||||
let oidPr = toPreserve(oid, Ref)
|
|
||||||
SturdyRef(oid: oidPr, sig: hmacSha256(key, encode(oidPr), key.len))
|
|
||||||
|
|
||||||
proc mint*(): SturdyRef {.deprecated.} =
|
|
||||||
## Mint a test capability for the use with the Syndicate server.
|
|
||||||
var key: array[16, byte]
|
|
||||||
mint(key, "syndicate")
|
|
||||||
|
|
||||||
proc attenuate*(r: SturdyRef; caveats: Attenuation): SturdyRef =
|
|
||||||
result = SturdyRef(
|
|
||||||
oid: r.oid,
|
oid: r.oid,
|
||||||
caveatChain: r.caveatChain,
|
caveatChain: r.caveatChain,
|
||||||
sig: hmacSha256(r.sig, caveats.encode))
|
sig: hmacSha256(r.sig, caveats.encode))
|
||||||
result.caveatChain.add caveats
|
result.caveatChain.add caveats
|
||||||
|
|
||||||
proc validate*(key: openarray[byte]; r: SturdyRef): bool =
|
proc validate*[T](key: openarray[byte]; r: SturdyRef[T]): bool =
|
||||||
var sig = hmacSha256(key, r.oid.encode, key.len)
|
var sig = hmacSha256(key, r.oid.encode, key.len)
|
||||||
for a in r.caveatChain:
|
for a in r.caveatChain:
|
||||||
sig = hmacSha256(sig, a.encode)
|
sig = hmacSha256(sig, a.encode)
|
||||||
r.sig == sig
|
r.sig == sig
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
import unittest
|
|
||||||
import preserves/parse
|
|
||||||
test "sturdy":
|
|
||||||
var
|
|
||||||
key: array[16, byte]
|
|
||||||
oid = "syndicate".toPreserve
|
|
||||||
sRef = mint(key, oid)
|
|
||||||
control = parsePreserves"""<ref "syndicate" [] #[pkgN9TBmEd3Q04grVG4Zdw]>"""
|
|
||||||
check(sRef.toPreserve == control)
|
|
||||||
let aRef = attenuate(sRef, newSeq[Caveat]())
|
|
||||||
check validate(key, aRef)
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import ./actors, ./protocols/dataspace, ./skeletons
|
||||||
from ./protocols/protocol import Handle
|
from ./protocols/protocol import Handle
|
||||||
|
|
||||||
type
|
type
|
||||||
|
Assertion = Preserve[Ref]
|
||||||
Observe = dataspace.Observe[Ref]
|
Observe = dataspace.Observe[Ref]
|
||||||
Turn = actors.Turn
|
Turn = actors.Turn
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ method publish(ds: Dataspace; turn: var Turn; v: Assertion; h: Handle) =
|
||||||
if add(ds.index, turn, v):
|
if add(ds.index, turn, v):
|
||||||
var obs: Observe
|
var obs: Observe
|
||||||
if obs.fromPreserve v:
|
if obs.fromPreserve v:
|
||||||
ds.index.add(turn, obs.pattern, unembed obs.observer)
|
ds.index.add(turn, obs.pattern, obs.observer)
|
||||||
ds.handleMap[h] = v
|
ds.handleMap[h] = v
|
||||||
|
|
||||||
method retract(ds: Dataspace; turn: var Turn; h: Handle) =
|
method retract(ds: Dataspace; turn: var Turn; h: Handle) =
|
||||||
|
@ -29,7 +30,7 @@ method retract(ds: Dataspace; turn: var Turn; h: Handle) =
|
||||||
ds.handleMap.del h
|
ds.handleMap.del h
|
||||||
var obs: Observe
|
var obs: Observe
|
||||||
if obs.fromPreserve v:
|
if obs.fromPreserve v:
|
||||||
ds.index.remove(turn, obs.pattern, unembed obs.observer)
|
ds.index.remove(turn, obs.pattern, obs.observer)
|
||||||
except KeyError: discard
|
except KeyError: discard
|
||||||
|
|
||||||
method message(ds: Dataspace; turn: var Turn; v: Assertion) =
|
method message(ds: Dataspace; turn: var Turn; v: Assertion) =
|
||||||
|
|
|
@ -51,4 +51,4 @@ method retract(de: DuringEntity; turn: var Turn; h: Handle) =
|
||||||
proc during*(cb: DuringProc): DuringEntity = DuringEntity(cb: cb)
|
proc during*(cb: DuringProc): DuringEntity = DuringEntity(cb: cb)
|
||||||
|
|
||||||
proc observe*(turn: var Turn; ds: Ref; pat: Pattern; e: Entity): Handle =
|
proc observe*(turn: var Turn; ds: Ref; pat: Pattern; e: Entity): Handle =
|
||||||
publish(turn, ds, Observe(pattern: pat, observer: embed newRef(turn, e)))
|
publish(turn, ds, Observe(pattern: pat, observer: newRef(turn, e)))
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
include_rules
|
include_rules
|
||||||
outputs = \
|
modules += dataspace.nim
|
||||||
dataspace.nim \
|
modules += dataspacePatterns.nim
|
||||||
dataspacePatterns.nim \
|
modules += gatekeeper.nim
|
||||||
gatekeeper.nim \
|
modules += protocol.nim
|
||||||
protocol.nim \
|
modules += racketEvent.nim
|
||||||
racketEvent.nim \
|
modules += secureChatProtocol.nim
|
||||||
secureChatProtocol.nim \
|
modules += service.nim
|
||||||
service.nim \
|
modules += simpleChatProtocol.nim
|
||||||
simpleChatProtocol.nim \
|
modules += stream.nim
|
||||||
stream.nim \
|
modules += sturdy.nim
|
||||||
sturdy.nim \
|
modules += tcp.nim
|
||||||
tcp.nim \
|
modules += timer.nim
|
||||||
timer.nim \
|
modules += trace.nim
|
||||||
trace.nim \
|
modules += transportAddress.nim
|
||||||
transportAddress.nim \
|
modules += worker.nim
|
||||||
worker.nim \
|
|
||||||
|
|
||||||
: foreach ../../../../syndicate-protocols/schema-bundle.bin |> !preserves_schema_nim |> $(outputs)
|
: ../../../../syndicate-protocols/schema-bundle.bin \
|
||||||
|
|> !preserves_schema_nim \
|
||||||
|
|> $(modules) | ../../../<protocols> {generated}
|
||||||
|
|
||||||
|
: foreach {generated} | {generated} |> !nim_run |>
|
||||||
|
|
Binary file not shown.
|
@ -3,12 +3,12 @@ import
|
||||||
std/typetraits, preserves, dataspacePatterns
|
std/typetraits, preserves, dataspacePatterns
|
||||||
|
|
||||||
type
|
type
|
||||||
Observe*[E] {.preservesRecord: "Observe".} = ref object
|
Observe*[Cap] {.preservesRecord: "Observe".} = ref object
|
||||||
`pattern`*: dataspacePatterns.Pattern[E]
|
`pattern`*: dataspacePatterns.Pattern[Cap]
|
||||||
`observer`*: Preserve[E]
|
`observer`*: Cap
|
||||||
|
|
||||||
proc `$`*[E](x: Observe[E]): string =
|
proc `$`*[Cap](x: Observe[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: Observe[E]): seq[byte] =
|
proc encode*[Cap](x: Observe[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
|
@ -12,8 +12,8 @@ type
|
||||||
AnyAtomString* = string
|
AnyAtomString* = string
|
||||||
AnyAtomBytes* = seq[byte]
|
AnyAtomBytes* = seq[byte]
|
||||||
AnyAtomSymbol* = Symbol
|
AnyAtomSymbol* = Symbol
|
||||||
AnyAtomEmbedded*[E] = Preserve[E]
|
AnyAtomEmbedded*[Cap] = Cap
|
||||||
`AnyAtom`*[E] {.preservesOr.} = ref object
|
`AnyAtom`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: AnyAtomKind
|
case orKind*: AnyAtomKind
|
||||||
of AnyAtomKind.`bool`:
|
of AnyAtomKind.`bool`:
|
||||||
`bool`*: AnyAtomBool
|
`bool`*: AnyAtomBool
|
||||||
|
@ -37,64 +37,65 @@ type
|
||||||
`symbol`*: AnyAtomSymbol
|
`symbol`*: AnyAtomSymbol
|
||||||
|
|
||||||
of AnyAtomKind.`embedded`:
|
of AnyAtomKind.`embedded`:
|
||||||
`embedded`*: AnyAtomEmbedded[E]
|
`embedded`*: AnyAtomEmbedded[Cap]
|
||||||
|
|
||||||
|
|
||||||
DLit*[E] {.preservesRecord: "lit".} = ref object
|
DLit*[Cap] {.preservesRecord: "lit".} = object
|
||||||
`value`*: AnyAtom[E]
|
`value`*: AnyAtom[Cap]
|
||||||
|
|
||||||
DBind*[E] {.preservesRecord: "bind".} = ref object
|
DBind*[Cap] {.preservesRecord: "bind".} = ref object
|
||||||
`pattern`*: Pattern[E]
|
`pattern`*: Pattern[Cap]
|
||||||
|
|
||||||
DDiscard* {.preservesRecord: "_".} = object
|
DDiscard* {.preservesRecord: "_".} = object
|
||||||
|
|
||||||
DCompoundKind* {.pure.} = enum
|
DCompoundKind* {.pure.} = enum
|
||||||
`rec`, `arr`, `dict`
|
`rec`, `arr`, `dict`
|
||||||
DCompoundRec*[E] {.preservesRecord: "rec".} = ref object
|
DCompoundRec*[Cap] {.preservesRecord: "rec".} = ref object
|
||||||
`label`*: Preserve[E]
|
`label`*: Preserve[Cap]
|
||||||
`fields`*: seq[Pattern[E]]
|
`fields`*: seq[Pattern[Cap]]
|
||||||
|
|
||||||
DCompoundArr*[E] {.preservesRecord: "arr".} = ref object
|
DCompoundArr*[Cap] {.preservesRecord: "arr".} = ref object
|
||||||
`items`*: seq[Pattern[E]]
|
`items`*: seq[Pattern[Cap]]
|
||||||
|
|
||||||
DCompoundDict*[E] {.preservesRecord: "dict".} = ref object
|
DCompoundDict*[Cap] {.preservesRecord: "dict".} = ref object
|
||||||
`entries`*: Table[Preserve[E], Pattern[E]]
|
`entries`*: Table[Preserve[Cap], Pattern[Cap]]
|
||||||
|
|
||||||
`DCompound`*[E] {.preservesOr.} = ref object
|
`DCompound`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: DCompoundKind
|
case orKind*: DCompoundKind
|
||||||
of DCompoundKind.`rec`:
|
of DCompoundKind.`rec`:
|
||||||
`rec`*: DCompoundRec[E]
|
`rec`*: DCompoundRec[Cap]
|
||||||
|
|
||||||
of DCompoundKind.`arr`:
|
of DCompoundKind.`arr`:
|
||||||
`arr`*: DCompoundArr[E]
|
`arr`*: DCompoundArr[Cap]
|
||||||
|
|
||||||
of DCompoundKind.`dict`:
|
of DCompoundKind.`dict`:
|
||||||
`dict`*: DCompoundDict[E]
|
`dict`*: DCompoundDict[Cap]
|
||||||
|
|
||||||
|
|
||||||
PatternKind* {.pure.} = enum
|
PatternKind* {.pure.} = enum
|
||||||
`DDiscard`, `DBind`, `DLit`, `DCompound`
|
`DDiscard`, `DBind`, `DLit`, `DCompound`
|
||||||
`Pattern`*[E] {.preservesOr.} = ref object
|
`Pattern`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: PatternKind
|
case orKind*: PatternKind
|
||||||
of PatternKind.`DDiscard`:
|
of PatternKind.`DDiscard`:
|
||||||
`ddiscard`*: DDiscard
|
`ddiscard`*: DDiscard
|
||||||
|
|
||||||
of PatternKind.`DBind`:
|
of PatternKind.`DBind`:
|
||||||
`dbind`*: DBind[E]
|
`dbind`*: DBind[Cap]
|
||||||
|
|
||||||
of PatternKind.`DLit`:
|
of PatternKind.`DLit`:
|
||||||
`dlit`*: DLit[E]
|
`dlit`*: DLit[Cap]
|
||||||
|
|
||||||
of PatternKind.`DCompound`:
|
of PatternKind.`DCompound`:
|
||||||
`dcompound`*: DCompound[E]
|
`dcompound`*: DCompound[Cap]
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[E](x: AnyAtom[E] | DLit[E] | DBind[E] | DCompound[E] | Pattern[E]): string =
|
proc `$`*[Cap](x: AnyAtom[Cap] | DLit[Cap] | DBind[Cap] | DCompound[Cap] |
|
||||||
`$`(toPreserve(x, E))
|
Pattern[Cap]): string =
|
||||||
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: AnyAtom[E] | DLit[E] | DBind[E] | DCompound[E] | Pattern[E]): seq[
|
proc encode*[Cap](x: AnyAtom[Cap] | DLit[Cap] | DBind[Cap] | DCompound[Cap] |
|
||||||
byte] =
|
Pattern[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc `$`*(x: DDiscard): string =
|
proc `$`*(x: DDiscard): string =
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
|
@ -3,17 +3,17 @@ import
|
||||||
std/typetraits, preserves, sturdy
|
std/typetraits, preserves, sturdy
|
||||||
|
|
||||||
type
|
type
|
||||||
Bind*[E] {.preservesRecord: "bind".} = ref object
|
Bind*[Cap] {.preservesRecord: "bind".} = object
|
||||||
`oid`*: Preserve[E]
|
`oid`*: Preserve[Cap]
|
||||||
`key`*: seq[byte]
|
`key`*: seq[byte]
|
||||||
`target`*: Preserve[E]
|
`target`*: Cap
|
||||||
|
|
||||||
Resolve*[E] {.preservesRecord: "resolve".} = ref object
|
Resolve*[Cap] {.preservesRecord: "resolve".} = ref object
|
||||||
`sturdyref`*: sturdy.SturdyRef[E]
|
`sturdyref`*: sturdy.SturdyRef[Cap]
|
||||||
`observer`*: Preserve[E]
|
`observer`*: Cap
|
||||||
|
|
||||||
proc `$`*[E](x: Bind[E] | Resolve[E]): string =
|
proc `$`*[Cap](x: Bind[Cap] | Resolve[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: Bind[E] | Resolve[E]): seq[byte] =
|
proc encode*[Cap](x: Bind[Cap] | Resolve[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -3,81 +3,77 @@ import
|
||||||
std/typetraits, preserves
|
std/typetraits, preserves
|
||||||
|
|
||||||
type
|
type
|
||||||
Error*[E] {.preservesRecord: "error".} = ref object
|
Error* {.preservesRecord: "error".} = object
|
||||||
`message`*: string
|
`message`*: string
|
||||||
`detail`*: Preserve[E]
|
`detail`*: Preserve[void]
|
||||||
|
|
||||||
Turn*[E] = seq[TurnEvent[E]]
|
Turn* = seq[TurnEvent]
|
||||||
Message*[E] {.preservesRecord: "message".} = ref object
|
Message* {.preservesRecord: "message".} = object
|
||||||
`body`*: Assertion[E]
|
`body`*: Assertion
|
||||||
|
|
||||||
Retract* {.preservesRecord: "retract".} = object
|
Retract* {.preservesRecord: "retract".} = object
|
||||||
`handle`*: Handle
|
`handle`*: Handle
|
||||||
|
|
||||||
Assert*[E] {.preservesRecord: "assert".} = ref object
|
Assert* {.preservesRecord: "assert".} = object
|
||||||
`assertion`*: Assertion[E]
|
`assertion`*: Assertion
|
||||||
`handle`*: Handle
|
`handle`*: Handle
|
||||||
|
|
||||||
Extension*[E] {.preservesRecord: "label".} = ref object
|
Extension* {.preservesRecord: "label".} = object
|
||||||
`data`*: seq[Preserve[E]]
|
`data`*: seq[Preserve[void]]
|
||||||
|
|
||||||
Sync*[E] {.preservesRecord: "sync".} = ref object
|
Sync* {.preservesRecord: "sync".} = object
|
||||||
`peer`*: Preserve[E]
|
`peer`* {.preservesLiteral: "#!<lit #t>".}: bool
|
||||||
|
|
||||||
TurnEvent*[E] {.preservesTuple.} = ref object
|
TurnEvent* {.preservesTuple.} = object
|
||||||
`oid`*: Oid
|
`oid`*: Oid
|
||||||
`event`*: Event[E]
|
`event`*: Event
|
||||||
|
|
||||||
Oid* = BiggestInt
|
Oid* = BiggestInt
|
||||||
Assertion*[E] = Preserve[E]
|
Assertion* = Preserve[void]
|
||||||
Handle* = BiggestInt
|
Handle* = BiggestInt
|
||||||
PacketKind* {.pure.} = enum
|
PacketKind* {.pure.} = enum
|
||||||
`Turn`, `Error`, `Extension`
|
`Turn`, `Error`, `Extension`
|
||||||
`Packet`*[E] {.preservesOr.} = ref object
|
`Packet`* {.preservesOr.} = object
|
||||||
case orKind*: PacketKind
|
case orKind*: PacketKind
|
||||||
of PacketKind.`Turn`:
|
of PacketKind.`Turn`:
|
||||||
`turn`*: Turn[E]
|
`turn`*: Turn
|
||||||
|
|
||||||
of PacketKind.`Error`:
|
of PacketKind.`Error`:
|
||||||
`error`*: Error[E]
|
`error`*: Error
|
||||||
|
|
||||||
of PacketKind.`Extension`:
|
of PacketKind.`Extension`:
|
||||||
`extension`*: Extension[E]
|
`extension`*: Extension
|
||||||
|
|
||||||
|
|
||||||
EventKind* {.pure.} = enum
|
EventKind* {.pure.} = enum
|
||||||
`Assert`, `Retract`, `Message`, `Sync`
|
`Assert`, `Retract`, `Message`, `Sync`
|
||||||
`Event`*[E] {.preservesOr.} = ref object
|
`Event`* {.preservesOr.} = object
|
||||||
case orKind*: EventKind
|
case orKind*: EventKind
|
||||||
of EventKind.`Assert`:
|
of EventKind.`Assert`:
|
||||||
`assert`*: Assert[E]
|
`assert`*: Assert
|
||||||
|
|
||||||
of EventKind.`Retract`:
|
of EventKind.`Retract`:
|
||||||
`retract`*: Retract
|
`retract`*: Retract
|
||||||
|
|
||||||
of EventKind.`Message`:
|
of EventKind.`Message`:
|
||||||
`message`*: Message[E]
|
`message`*: Message
|
||||||
|
|
||||||
of EventKind.`Sync`:
|
of EventKind.`Sync`:
|
||||||
`sync`*: Sync[E]
|
`sync`*: Sync
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[E](x: Error[E] | Turn[E] | Message[E] | Assert[E] | Extension[E] |
|
proc `$`*(x: Error | Turn | Message | Retract | Assert | Extension | Sync |
|
||||||
Sync[E] |
|
TurnEvent |
|
||||||
TurnEvent[E] |
|
Oid |
|
||||||
Packet[E] |
|
Handle |
|
||||||
Event[E]): string =
|
Packet |
|
||||||
`$`(toPreserve(x, E))
|
Event): string =
|
||||||
|
|
||||||
proc encode*[E](x: Error[E] | Turn[E] | Message[E] | Assert[E] | Extension[E] |
|
|
||||||
Sync[E] |
|
|
||||||
TurnEvent[E] |
|
|
||||||
Packet[E] |
|
|
||||||
Event[E]): seq[byte] =
|
|
||||||
encode(toPreserve(x, E))
|
|
||||||
|
|
||||||
proc `$`*(x: Retract | Oid | Handle): string =
|
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
||||||
proc encode*(x: Retract | Oid | Handle): seq[byte] =
|
proc encode*(x: Error | Turn | Message | Retract | Assert | Extension | Sync |
|
||||||
|
TurnEvent |
|
||||||
|
Oid |
|
||||||
|
Handle |
|
||||||
|
Packet |
|
||||||
|
Event): seq[byte] =
|
||||||
encode(toPreserve(x))
|
encode(toPreserve(x))
|
||||||
|
|
|
@ -3,12 +3,12 @@ import
|
||||||
std/typetraits, preserves
|
std/typetraits, preserves
|
||||||
|
|
||||||
type
|
type
|
||||||
RacketEvent*[E] {.preservesRecord: "racket-event".} = ref object
|
RacketEvent* {.preservesRecord: "racket-event".} = object
|
||||||
`source`*: Preserve[E]
|
`source`* {.preservesEmbedded.}: Preserve[void]
|
||||||
`event`*: Preserve[E]
|
`event`* {.preservesEmbedded.}: Preserve[void]
|
||||||
|
|
||||||
proc `$`*[E](x: RacketEvent[E]): string =
|
proc `$`*(x: RacketEvent): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x))
|
||||||
|
|
||||||
proc encode*[E](x: RacketEvent[E]): seq[byte] =
|
proc encode*(x: RacketEvent): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x))
|
||||||
|
|
|
@ -17,30 +17,30 @@ type
|
||||||
`nickconflict`*: NickConflict
|
`nickconflict`*: NickConflict
|
||||||
|
|
||||||
|
|
||||||
Join*[E] {.preservesRecord: "joinedUser".} = ref object
|
Join*[Cap] {.preservesRecord: "joinedUser".} = object
|
||||||
`uid`*: UserId
|
`uid`*: UserId
|
||||||
`handle`*: Preserve[E]
|
`handle`*: Cap
|
||||||
|
|
||||||
SessionKind* {.pure.} = enum
|
SessionKind* {.pure.} = enum
|
||||||
`observeUsers`, `observeSpeech`, `NickClaim`, `Says`
|
`observeUsers`, `observeSpeech`, `NickClaim`, `Says`
|
||||||
SessionObserveUsers*[E] {.preservesRecord: "Observe".} = ref object
|
SessionObserveUsers*[Cap] {.preservesRecord: "Observe".} = object
|
||||||
`data`* {.preservesLiteral: "user".}: bool
|
`data`* {.preservesLiteral: "user".}: bool
|
||||||
`observer`*: Preserve[E]
|
`observer`*: Cap
|
||||||
|
|
||||||
SessionObserveSpeech*[E] {.preservesRecord: "Observe".} = ref object
|
SessionObserveSpeech*[Cap] {.preservesRecord: "Observe".} = object
|
||||||
`data`* {.preservesLiteral: "says".}: bool
|
`data`* {.preservesLiteral: "says".}: bool
|
||||||
`observer`*: Preserve[E]
|
`observer`*: Cap
|
||||||
|
|
||||||
`Session`*[E] {.preservesOr.} = ref object
|
`Session`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: SessionKind
|
case orKind*: SessionKind
|
||||||
of SessionKind.`observeUsers`:
|
of SessionKind.`observeUsers`:
|
||||||
`observeusers`*: SessionObserveUsers[E]
|
`observeusers`*: SessionObserveUsers[Cap]
|
||||||
|
|
||||||
of SessionKind.`observeSpeech`:
|
of SessionKind.`observeSpeech`:
|
||||||
`observespeech`*: SessionObserveSpeech[E]
|
`observespeech`*: SessionObserveSpeech[Cap]
|
||||||
|
|
||||||
of SessionKind.`NickClaim`:
|
of SessionKind.`NickClaim`:
|
||||||
`nickclaim`*: NickClaim[E]
|
`nickclaim`*: NickClaim[Cap]
|
||||||
|
|
||||||
of SessionKind.`Says`:
|
of SessionKind.`Says`:
|
||||||
`says`*: Says
|
`says`*: Says
|
||||||
|
@ -50,20 +50,20 @@ type
|
||||||
`uid`*: UserId
|
`uid`*: UserId
|
||||||
`name`*: string
|
`name`*: string
|
||||||
|
|
||||||
NickClaim*[E] {.preservesRecord: "claimNick".} = ref object
|
NickClaim*[Cap] {.preservesRecord: "claimNick".} = object
|
||||||
`uid`*: UserId
|
`uid`*: UserId
|
||||||
`name`*: string
|
`name`*: string
|
||||||
`k`*: Preserve[E]
|
`k`*: Cap
|
||||||
|
|
||||||
Says* {.preservesRecord: "says".} = object
|
Says* {.preservesRecord: "says".} = object
|
||||||
`who`*: UserId
|
`who`*: UserId
|
||||||
`what`*: string
|
`what`*: string
|
||||||
|
|
||||||
proc `$`*[E](x: Join[E] | Session[E] | NickClaim[E]): string =
|
proc `$`*[Cap](x: Join[Cap] | Session[Cap] | NickClaim[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: Join[E] | Session[E] | NickClaim[E]): seq[byte] =
|
proc encode*[Cap](x: Join[Cap] | Session[Cap] | NickClaim[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc `$`*(x: UserId | NickConflict | NickClaimResponse | UserInfo | Says): string =
|
proc `$`*(x: UserId | NickConflict | NickClaimResponse | UserInfo | Says): string =
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
|
@ -5,8 +5,8 @@ import
|
||||||
type
|
type
|
||||||
StateKind* {.pure.} = enum
|
StateKind* {.pure.} = enum
|
||||||
`started`, `ready`, `failed`, `complete`, `userDefined`
|
`started`, `ready`, `failed`, `complete`, `userDefined`
|
||||||
StateUserDefined*[E] = Preserve[E]
|
StateUserDefined*[Cap] = Preserve[Cap]
|
||||||
`State`*[E] {.preservesOr.} = ref object
|
`State`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: StateKind
|
case orKind*: StateKind
|
||||||
of StateKind.`started`:
|
of StateKind.`started`:
|
||||||
`started`* {.preservesLiteral: "started".}: bool
|
`started`* {.preservesLiteral: "started".}: bool
|
||||||
|
@ -21,40 +21,40 @@ type
|
||||||
`complete`* {.preservesLiteral: "complete".}: bool
|
`complete`* {.preservesLiteral: "complete".}: bool
|
||||||
|
|
||||||
of StateKind.`userDefined`:
|
of StateKind.`userDefined`:
|
||||||
`userdefined`*: StateUserDefined[E]
|
`userdefined`*: StateUserDefined[Cap]
|
||||||
|
|
||||||
|
|
||||||
ServiceObject*[E] {.preservesRecord: "service-object".} = ref object
|
ServiceObject*[Cap] {.preservesRecord: "service-object".} = object
|
||||||
`serviceName`*: Preserve[E]
|
`serviceName`*: Preserve[Cap]
|
||||||
`object`*: Preserve[E]
|
`object`*: Preserve[Cap]
|
||||||
|
|
||||||
RequireService*[E] {.preservesRecord: "require-service".} = ref object
|
RequireService*[Cap] {.preservesRecord: "require-service".} = object
|
||||||
`serviceName`*: Preserve[E]
|
`serviceName`*: Preserve[Cap]
|
||||||
|
|
||||||
RestartService*[E] {.preservesRecord: "restart-service".} = ref object
|
RestartService*[Cap] {.preservesRecord: "restart-service".} = object
|
||||||
`serviceName`*: Preserve[E]
|
`serviceName`*: Preserve[Cap]
|
||||||
|
|
||||||
RunService*[E] {.preservesRecord: "run-service".} = ref object
|
RunService*[Cap] {.preservesRecord: "run-service".} = object
|
||||||
`serviceName`*: Preserve[E]
|
`serviceName`*: Preserve[Cap]
|
||||||
|
|
||||||
ServiceState*[E] {.preservesRecord: "service-state".} = ref object
|
ServiceState*[Cap] {.preservesRecord: "service-state".} = object
|
||||||
`serviceName`*: Preserve[E]
|
`serviceName`*: Preserve[Cap]
|
||||||
`state`*: State[E]
|
`state`*: State[Cap]
|
||||||
|
|
||||||
ServiceDependency*[E] {.preservesRecord: "depends-on".} = ref object
|
ServiceDependency*[Cap] {.preservesRecord: "depends-on".} = object
|
||||||
`depender`*: Preserve[E]
|
`depender`*: Preserve[Cap]
|
||||||
`dependee`*: ServiceState[E]
|
`dependee`*: ServiceState[Cap]
|
||||||
|
|
||||||
proc `$`*[E](x: State[E] | ServiceObject[E] | RequireService[E] |
|
proc `$`*[Cap](x: State[Cap] | ServiceObject[Cap] | RequireService[Cap] |
|
||||||
RestartService[E] |
|
RestartService[Cap] |
|
||||||
RunService[E] |
|
RunService[Cap] |
|
||||||
ServiceState[E] |
|
ServiceState[Cap] |
|
||||||
ServiceDependency[E]): string =
|
ServiceDependency[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: State[E] | ServiceObject[E] | RequireService[E] |
|
proc encode*[Cap](x: State[Cap] | ServiceObject[Cap] | RequireService[Cap] |
|
||||||
RestartService[E] |
|
RestartService[Cap] |
|
||||||
RunService[E] |
|
RunService[Cap] |
|
||||||
ServiceState[E] |
|
ServiceState[Cap] |
|
||||||
ServiceDependency[E]): seq[byte] =
|
ServiceDependency[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
|
@ -18,76 +18,76 @@ type
|
||||||
StreamError* {.preservesRecord: "error".} = object
|
StreamError* {.preservesRecord: "error".} = object
|
||||||
`message`*: string
|
`message`*: string
|
||||||
|
|
||||||
StreamListenerError*[E] {.preservesRecord: "stream-listener-error".} = ref object
|
StreamListenerError*[Cap] {.preservesRecord: "stream-listener-error".} = object
|
||||||
`spec`*: Preserve[E]
|
`spec`*: Preserve[Cap]
|
||||||
`message`*: string
|
`message`*: string
|
||||||
|
|
||||||
StreamConnection*[E] {.preservesRecord: "stream-connection".} = ref object
|
StreamConnection*[Cap] {.preservesRecord: "stream-connection".} = object
|
||||||
`source`*: Preserve[E]
|
`source`*: Cap
|
||||||
`sink`*: Preserve[E]
|
`sink`*: Cap
|
||||||
`spec`*: Preserve[E]
|
`spec`*: Preserve[Cap]
|
||||||
|
|
||||||
`LineMode`* {.preservesOr, pure.} = enum
|
`LineMode`* {.preservesOr, pure.} = enum
|
||||||
`lf`, `crlf`
|
`lf`, `crlf`
|
||||||
SourceKind* {.pure.} = enum
|
SourceKind* {.pure.} = enum
|
||||||
`sink`, `StreamError`, `credit`
|
`sink`, `StreamError`, `credit`
|
||||||
SourceSink*[E] {.preservesRecord: "sink".} = ref object
|
SourceSink*[Cap] {.preservesRecord: "sink".} = object
|
||||||
`controller`*: Preserve[E]
|
`controller`*: Cap
|
||||||
|
|
||||||
SourceCredit*[E] {.preservesRecord: "credit".} = ref object
|
SourceCredit*[Cap] {.preservesRecord: "credit".} = object
|
||||||
`amount`*: CreditAmount
|
`amount`*: CreditAmount
|
||||||
`mode`*: Mode[E]
|
`mode`*: Mode[Cap]
|
||||||
|
|
||||||
`Source`*[E] {.preservesOr.} = ref object
|
`Source`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: SourceKind
|
case orKind*: SourceKind
|
||||||
of SourceKind.`sink`:
|
of SourceKind.`sink`:
|
||||||
`sink`*: SourceSink[E]
|
`sink`*: SourceSink[Cap]
|
||||||
|
|
||||||
of SourceKind.`StreamError`:
|
of SourceKind.`StreamError`:
|
||||||
`streamerror`*: StreamError
|
`streamerror`*: StreamError
|
||||||
|
|
||||||
of SourceKind.`credit`:
|
of SourceKind.`credit`:
|
||||||
`credit`*: SourceCredit[E]
|
`credit`*: SourceCredit[Cap]
|
||||||
|
|
||||||
|
|
||||||
SinkKind* {.pure.} = enum
|
SinkKind* {.pure.} = enum
|
||||||
`source`, `StreamError`, `data`, `eof`
|
`source`, `StreamError`, `data`, `eof`
|
||||||
SinkSource*[E] {.preservesRecord: "source".} = ref object
|
SinkSource*[Cap] {.preservesRecord: "source".} = object
|
||||||
`controller`*: Preserve[E]
|
`controller`*: Cap
|
||||||
|
|
||||||
SinkData*[E] {.preservesRecord: "data".} = ref object
|
SinkData*[Cap] {.preservesRecord: "data".} = object
|
||||||
`payload`*: Preserve[E]
|
`payload`*: Preserve[Cap]
|
||||||
`mode`*: Mode[E]
|
`mode`*: Mode[Cap]
|
||||||
|
|
||||||
SinkEof* {.preservesRecord: "eof".} = object
|
SinkEof* {.preservesRecord: "eof".} = object
|
||||||
|
|
||||||
`Sink`*[E] {.preservesOr.} = ref object
|
`Sink`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: SinkKind
|
case orKind*: SinkKind
|
||||||
of SinkKind.`source`:
|
of SinkKind.`source`:
|
||||||
`source`*: SinkSource[E]
|
`source`*: SinkSource[Cap]
|
||||||
|
|
||||||
of SinkKind.`StreamError`:
|
of SinkKind.`StreamError`:
|
||||||
`streamerror`*: StreamError
|
`streamerror`*: StreamError
|
||||||
|
|
||||||
of SinkKind.`data`:
|
of SinkKind.`data`:
|
||||||
`data`*: SinkData[E]
|
`data`*: SinkData[Cap]
|
||||||
|
|
||||||
of SinkKind.`eof`:
|
of SinkKind.`eof`:
|
||||||
`eof`*: SinkEof
|
`eof`*: SinkEof
|
||||||
|
|
||||||
|
|
||||||
StreamListenerReady*[E] {.preservesRecord: "stream-listener-ready".} = ref object
|
StreamListenerReady*[Cap] {.preservesRecord: "stream-listener-ready".} = object
|
||||||
`spec`*: Preserve[E]
|
`spec`*: Preserve[Cap]
|
||||||
|
|
||||||
ModeKind* {.pure.} = enum
|
ModeKind* {.pure.} = enum
|
||||||
`bytes`, `lines`, `packet`, `object`
|
`bytes`, `lines`, `packet`, `object`
|
||||||
ModePacket* {.preservesRecord: "packet".} = object
|
ModePacket* {.preservesRecord: "packet".} = object
|
||||||
`size`*: BiggestInt
|
`size`*: BiggestInt
|
||||||
|
|
||||||
ModeObject*[E] {.preservesRecord: "object".} = ref object
|
ModeObject*[Cap] {.preservesRecord: "object".} = object
|
||||||
`description`*: Preserve[E]
|
`description`*: Preserve[Cap]
|
||||||
|
|
||||||
`Mode`*[E] {.preservesOr.} = ref object
|
`Mode`*[Cap] {.preservesOr.} = object
|
||||||
case orKind*: ModeKind
|
case orKind*: ModeKind
|
||||||
of ModeKind.`bytes`:
|
of ModeKind.`bytes`:
|
||||||
`bytes`* {.preservesLiteral: "bytes".}: bool
|
`bytes`* {.preservesLiteral: "bytes".}: bool
|
||||||
|
@ -99,20 +99,21 @@ type
|
||||||
`packet`*: ModePacket
|
`packet`*: ModePacket
|
||||||
|
|
||||||
of ModeKind.`object`:
|
of ModeKind.`object`:
|
||||||
`object`*: ModeObject[E]
|
`object`*: ModeObject[Cap]
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[E](x: StreamListenerError[E] | StreamConnection[E] | Source[E] |
|
proc `$`*[Cap](x: StreamListenerError[Cap] | StreamConnection[Cap] | Source[Cap] |
|
||||||
Sink[E] |
|
Sink[Cap] |
|
||||||
StreamListenerReady[E] |
|
StreamListenerReady[Cap] |
|
||||||
Mode[E]): string =
|
Mode[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: StreamListenerError[E] | StreamConnection[E] | Source[E] |
|
proc encode*[Cap](x: StreamListenerError[Cap] | StreamConnection[Cap] |
|
||||||
Sink[E] |
|
Source[Cap] |
|
||||||
StreamListenerReady[E] |
|
Sink[Cap] |
|
||||||
Mode[E]): seq[byte] =
|
StreamListenerReady[Cap] |
|
||||||
encode(toPreserve(x, E))
|
Mode[Cap]): seq[byte] =
|
||||||
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc `$`*(x: CreditAmount | StreamError): string =
|
proc `$`*(x: CreditAmount | StreamError): string =
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
|
@ -1,112 +1,112 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
std/typetraits, preserves, std/tables
|
std/typetraits, preserves, std/tables, std/tables
|
||||||
|
|
||||||
type
|
type
|
||||||
PCompoundKind* {.pure.} = enum
|
PCompoundKind* {.pure.} = enum
|
||||||
`rec`, `arr`, `dict`
|
`rec`, `arr`, `dict`
|
||||||
PCompoundRec*[E] {.preservesRecord: "rec".} = ref object
|
PCompoundRec*[Cap] {.preservesRecord: "rec".} = ref object
|
||||||
`label`*: Preserve[E]
|
`label`*: Preserve[Cap]
|
||||||
`fields`*: seq[Pattern[E]]
|
`fields`*: seq[Pattern[Cap]]
|
||||||
|
|
||||||
PCompoundArr*[E] {.preservesRecord: "arr".} = ref object
|
PCompoundArr*[Cap] {.preservesRecord: "arr".} = ref object
|
||||||
`items`*: seq[Pattern[E]]
|
`items`*: seq[Pattern[Cap]]
|
||||||
|
|
||||||
PCompoundDict*[E] {.preservesRecord: "dict".} = ref object
|
PCompoundDict*[Cap] {.preservesRecord: "dict".} = ref object
|
||||||
`entries`*: Table[Preserve[E], Pattern[E]]
|
`entries`*: Table[Preserve[Cap], Pattern[Cap]]
|
||||||
|
|
||||||
`PCompound`*[E] {.preservesOr.} = ref object
|
`PCompound`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: PCompoundKind
|
case orKind*: PCompoundKind
|
||||||
of PCompoundKind.`rec`:
|
of PCompoundKind.`rec`:
|
||||||
`rec`*: PCompoundRec[E]
|
`rec`*: PCompoundRec[Cap]
|
||||||
|
|
||||||
of PCompoundKind.`arr`:
|
of PCompoundKind.`arr`:
|
||||||
`arr`*: PCompoundArr[E]
|
`arr`*: PCompoundArr[Cap]
|
||||||
|
|
||||||
of PCompoundKind.`dict`:
|
of PCompoundKind.`dict`:
|
||||||
`dict`*: PCompoundDict[E]
|
`dict`*: PCompoundDict[Cap]
|
||||||
|
|
||||||
|
|
||||||
PAnd*[E] {.preservesRecord: "and".} = ref object
|
PAnd*[Cap] {.preservesRecord: "and".} = ref object
|
||||||
`patterns`*: seq[Pattern[E]]
|
`patterns`*: seq[Pattern[Cap]]
|
||||||
|
|
||||||
Rewrite*[E] {.preservesRecord: "rewrite".} = ref object
|
Rewrite*[Cap] {.preservesRecord: "rewrite".} = ref object
|
||||||
`pattern`*: Pattern[E]
|
`pattern`*: Pattern[Cap]
|
||||||
`template`*: Template[E]
|
`template`*: Template[Cap]
|
||||||
|
|
||||||
TRef* {.preservesRecord: "ref".} = object
|
TRef* {.preservesRecord: "ref".} = object
|
||||||
`binding`*: BiggestInt
|
`binding`*: BiggestInt
|
||||||
|
|
||||||
PBind*[E] {.preservesRecord: "bind".} = ref object
|
PBind*[Cap] {.preservesRecord: "bind".} = ref object
|
||||||
`pattern`*: Pattern[E]
|
`pattern`*: Pattern[Cap]
|
||||||
|
|
||||||
Lit*[E] {.preservesRecord: "lit".} = ref object
|
Lit*[Cap] {.preservesRecord: "lit".} = object
|
||||||
`value`*: Preserve[E]
|
`value`*: Preserve[Cap]
|
||||||
|
|
||||||
TCompoundKind* {.pure.} = enum
|
TCompoundKind* {.pure.} = enum
|
||||||
`rec`, `arr`, `dict`
|
`rec`, `arr`, `dict`
|
||||||
TCompoundRec*[E] {.preservesRecord: "rec".} = ref object
|
TCompoundRec*[Cap] {.preservesRecord: "rec".} = ref object
|
||||||
`label`*: Preserve[E]
|
`label`*: Preserve[Cap]
|
||||||
`fields`*: seq[Template[E]]
|
`fields`*: seq[Template[Cap]]
|
||||||
|
|
||||||
TCompoundArr*[E] {.preservesRecord: "arr".} = ref object
|
TCompoundArr*[Cap] {.preservesRecord: "arr".} = ref object
|
||||||
`items`*: seq[Template[E]]
|
`items`*: seq[Template[Cap]]
|
||||||
|
|
||||||
TCompoundDict*[E] {.preservesRecord: "dict".} = ref object
|
TCompoundDict*[Cap] {.preservesRecord: "dict".} = ref object
|
||||||
`entries`*: Table[Preserve[E], Template[E]]
|
`entries`*: Table[Preserve[Cap], Template[Cap]]
|
||||||
|
|
||||||
`TCompound`*[E] {.preservesOr.} = ref object
|
`TCompound`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: TCompoundKind
|
case orKind*: TCompoundKind
|
||||||
of TCompoundKind.`rec`:
|
of TCompoundKind.`rec`:
|
||||||
`rec`*: TCompoundRec[E]
|
`rec`*: TCompoundRec[Cap]
|
||||||
|
|
||||||
of TCompoundKind.`arr`:
|
of TCompoundKind.`arr`:
|
||||||
`arr`*: TCompoundArr[E]
|
`arr`*: TCompoundArr[Cap]
|
||||||
|
|
||||||
of TCompoundKind.`dict`:
|
of TCompoundKind.`dict`:
|
||||||
`dict`*: TCompoundDict[E]
|
`dict`*: TCompoundDict[Cap]
|
||||||
|
|
||||||
|
|
||||||
`PAtom`* {.preservesOr, pure.} = enum
|
`PAtom`* {.preservesOr, pure.} = enum
|
||||||
`Boolean`, `Float`, `Double`, `SignedInteger`, `String`, `ByteString`,
|
`Boolean`, `Float`, `Double`, `SignedInteger`, `String`, `ByteString`,
|
||||||
`Symbol`
|
`Symbol`
|
||||||
Attenuation*[E] = seq[Caveat[E]]
|
Attenuation*[Cap] = seq[Caveat[Cap]]
|
||||||
PDiscard* {.preservesRecord: "_".} = object
|
PDiscard* {.preservesRecord: "_".} = object
|
||||||
|
|
||||||
TemplateKind* {.pure.} = enum
|
TemplateKind* {.pure.} = enum
|
||||||
`TAttenuate`, `TRef`, `Lit`, `TCompound`
|
`TAttenuate`, `TRef`, `Lit`, `TCompound`
|
||||||
`Template`*[E] {.preservesOr.} = ref object
|
`Template`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: TemplateKind
|
case orKind*: TemplateKind
|
||||||
of TemplateKind.`TAttenuate`:
|
of TemplateKind.`TAttenuate`:
|
||||||
`tattenuate`*: TAttenuate[E]
|
`tattenuate`*: TAttenuate[Cap]
|
||||||
|
|
||||||
of TemplateKind.`TRef`:
|
of TemplateKind.`TRef`:
|
||||||
`tref`*: TRef
|
`tref`*: TRef
|
||||||
|
|
||||||
of TemplateKind.`Lit`:
|
of TemplateKind.`Lit`:
|
||||||
`lit`*: Lit[E]
|
`lit`*: Lit[Cap]
|
||||||
|
|
||||||
of TemplateKind.`TCompound`:
|
of TemplateKind.`TCompound`:
|
||||||
`tcompound`*: TCompound[E]
|
`tcompound`*: TCompound[Cap]
|
||||||
|
|
||||||
|
|
||||||
CaveatKind* {.pure.} = enum
|
CaveatKind* {.pure.} = enum
|
||||||
`Rewrite`, `Alts`
|
`Rewrite`, `Alts`
|
||||||
`Caveat`*[E] {.preservesOr.} = ref object
|
`Caveat`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: CaveatKind
|
case orKind*: CaveatKind
|
||||||
of CaveatKind.`Rewrite`:
|
of CaveatKind.`Rewrite`:
|
||||||
`rewrite`*: Rewrite[E]
|
`rewrite`*: Rewrite[Cap]
|
||||||
|
|
||||||
of CaveatKind.`Alts`:
|
of CaveatKind.`Alts`:
|
||||||
`alts`*: Alts[E]
|
`alts`*: Alts[Cap]
|
||||||
|
|
||||||
|
|
||||||
PNot*[E] {.preservesRecord: "not".} = ref object
|
PNot*[Cap] {.preservesRecord: "not".} = ref object
|
||||||
`pattern`*: Pattern[E]
|
`pattern`*: Pattern[Cap]
|
||||||
|
|
||||||
SturdyRef*[E] {.preservesRecord: "ref".} = ref object
|
SturdyRef*[Cap] {.preservesRecord: "ref".} = ref object
|
||||||
`oid`*: Preserve[E]
|
`oid`*: Preserve[Cap]
|
||||||
`caveatChain`*: seq[Attenuation[E]]
|
`caveatChain`*: seq[Attenuation[Cap]]
|
||||||
`sig`*: seq[byte]
|
`sig`*: seq[byte]
|
||||||
|
|
||||||
WireRefKind* {.pure.} = enum
|
WireRefKind* {.pure.} = enum
|
||||||
|
@ -115,32 +115,32 @@ type
|
||||||
`data`* {.preservesLiteral: "0".}: bool
|
`data`* {.preservesLiteral: "0".}: bool
|
||||||
`oid`*: Oid
|
`oid`*: Oid
|
||||||
|
|
||||||
WireRefYours*[E] {.preservesTuple.} = ref object
|
WireRefYours*[Cap] {.preservesTuple.} = ref object
|
||||||
`data`* {.preservesLiteral: "1".}: bool
|
`data`* {.preservesLiteral: "1".}: bool
|
||||||
`oid`*: Oid
|
`oid`*: Oid
|
||||||
`attenuation`* {.preservesTupleTail.}: seq[Caveat[E]]
|
`attenuation`* {.preservesTupleTail.}: seq[Caveat[Cap]]
|
||||||
|
|
||||||
`WireRef`*[E] {.preservesOr.} = ref object
|
`WireRef`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: WireRefKind
|
case orKind*: WireRefKind
|
||||||
of WireRefKind.`mine`:
|
of WireRefKind.`mine`:
|
||||||
`mine`*: WireRefMine
|
`mine`*: WireRefMine
|
||||||
|
|
||||||
of WireRefKind.`yours`:
|
of WireRefKind.`yours`:
|
||||||
`yours`*: WireRefYours[E]
|
`yours`*: WireRefYours[Cap]
|
||||||
|
|
||||||
|
|
||||||
TAttenuate*[E] {.preservesRecord: "attenuate".} = ref object
|
TAttenuate*[Cap] {.preservesRecord: "attenuate".} = ref object
|
||||||
`template`*: Template[E]
|
`template`*: Template[Cap]
|
||||||
`attenuation`*: Attenuation[E]
|
`attenuation`*: Attenuation[Cap]
|
||||||
|
|
||||||
Oid* = BiggestInt
|
Oid* = BiggestInt
|
||||||
Alts*[E] {.preservesRecord: "or".} = ref object
|
Alts*[Cap] {.preservesRecord: "or".} = ref object
|
||||||
`alternatives`*: seq[Rewrite[E]]
|
`alternatives`*: seq[Rewrite[Cap]]
|
||||||
|
|
||||||
PatternKind* {.pure.} = enum
|
PatternKind* {.pure.} = enum
|
||||||
`PDiscard`, `PAtom`, `PEmbedded`, `PBind`, `PAnd`, `PNot`, `Lit`,
|
`PDiscard`, `PAtom`, `PEmbedded`, `PBind`, `PAnd`, `PNot`, `Lit`,
|
||||||
`PCompound`
|
`PCompound`
|
||||||
`Pattern`*[E] {.preservesOr.} = ref object
|
`Pattern`*[Cap] {.preservesOr.} = ref object
|
||||||
case orKind*: PatternKind
|
case orKind*: PatternKind
|
||||||
of PatternKind.`PDiscard`:
|
of PatternKind.`PDiscard`:
|
||||||
`pdiscard`*: PDiscard
|
`pdiscard`*: PDiscard
|
||||||
|
@ -152,46 +152,48 @@ type
|
||||||
`pembedded`* {.preservesLiteral: "Embedded".}: bool
|
`pembedded`* {.preservesLiteral: "Embedded".}: bool
|
||||||
|
|
||||||
of PatternKind.`PBind`:
|
of PatternKind.`PBind`:
|
||||||
`pbind`*: PBind[E]
|
`pbind`*: PBind[Cap]
|
||||||
|
|
||||||
of PatternKind.`PAnd`:
|
of PatternKind.`PAnd`:
|
||||||
`pand`*: PAnd[E]
|
`pand`*: PAnd[Cap]
|
||||||
|
|
||||||
of PatternKind.`PNot`:
|
of PatternKind.`PNot`:
|
||||||
`pnot`*: PNot[E]
|
`pnot`*: PNot[Cap]
|
||||||
|
|
||||||
of PatternKind.`Lit`:
|
of PatternKind.`Lit`:
|
||||||
`lit`*: Lit[E]
|
`lit`*: Lit[Cap]
|
||||||
|
|
||||||
of PatternKind.`PCompound`:
|
of PatternKind.`PCompound`:
|
||||||
`pcompound`*: PCompound[E]
|
`pcompound`*: PCompound[Cap]
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[E](x: PCompound[E] | PAnd[E] | Rewrite[E] | PBind[E] | Lit[E] |
|
proc `$`*[Cap](x: PCompound[Cap] | PAnd[Cap] | Rewrite[Cap] | PBind[Cap] |
|
||||||
TCompound[E] |
|
Lit[Cap] |
|
||||||
Attenuation[E] |
|
TCompound[Cap] |
|
||||||
Template[E] |
|
Attenuation[Cap] |
|
||||||
Caveat[E] |
|
Template[Cap] |
|
||||||
PNot[E] |
|
Caveat[Cap] |
|
||||||
SturdyRef[E] |
|
PNot[Cap] |
|
||||||
WireRef[E] |
|
SturdyRef[Cap] |
|
||||||
TAttenuate[E] |
|
WireRef[Cap] |
|
||||||
Alts[E] |
|
TAttenuate[Cap] |
|
||||||
Pattern[E]): string =
|
Alts[Cap] |
|
||||||
`$`(toPreserve(x, E))
|
Pattern[Cap]): string =
|
||||||
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: PCompound[E] | PAnd[E] | Rewrite[E] | PBind[E] | Lit[E] |
|
proc encode*[Cap](x: PCompound[Cap] | PAnd[Cap] | Rewrite[Cap] | PBind[Cap] |
|
||||||
TCompound[E] |
|
Lit[Cap] |
|
||||||
Attenuation[E] |
|
TCompound[Cap] |
|
||||||
Template[E] |
|
Attenuation[Cap] |
|
||||||
Caveat[E] |
|
Template[Cap] |
|
||||||
PNot[E] |
|
Caveat[Cap] |
|
||||||
SturdyRef[E] |
|
PNot[Cap] |
|
||||||
WireRef[E] |
|
SturdyRef[Cap] |
|
||||||
TAttenuate[E] |
|
WireRef[Cap] |
|
||||||
Alts[E] |
|
TAttenuate[Cap] |
|
||||||
Pattern[E]): seq[byte] =
|
Alts[Cap] |
|
||||||
encode(toPreserve(x, E))
|
Pattern[Cap]): seq[byte] =
|
||||||
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc `$`*(x: TRef | PDiscard | Oid): string =
|
proc `$`*(x: TRef | PDiscard | Oid): string =
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
|
@ -7,8 +7,8 @@ type
|
||||||
`host`*: string
|
`host`*: string
|
||||||
`port`*: BiggestInt
|
`port`*: BiggestInt
|
||||||
|
|
||||||
TcpPeerInfo*[E] {.preservesRecord: "tcp-peer".} = ref object
|
TcpPeerInfo*[Cap] {.preservesRecord: "tcp-peer".} = object
|
||||||
`handle`*: Preserve[E]
|
`handle`*: Cap
|
||||||
`local`*: TcpLocal
|
`local`*: TcpLocal
|
||||||
`remote`*: TcpRemote
|
`remote`*: TcpRemote
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@ type
|
||||||
`host`*: string
|
`host`*: string
|
||||||
`port`*: BiggestInt
|
`port`*: BiggestInt
|
||||||
|
|
||||||
proc `$`*[E](x: TcpPeerInfo[E]): string =
|
proc `$`*[Cap](x: TcpPeerInfo[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: TcpPeerInfo[E]): seq[byte] =
|
proc encode*[Cap](x: TcpPeerInfo[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc `$`*(x: TcpLocal | TcpRemote): string =
|
proc `$`*(x: TcpLocal | TcpRemote): string =
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
|
@ -3,12 +3,12 @@ import
|
||||||
std/typetraits, preserves
|
std/typetraits, preserves
|
||||||
|
|
||||||
type
|
type
|
||||||
TimerExpired*[E] {.preservesRecord: "timer-expired".} = ref object
|
TimerExpired* {.preservesRecord: "timer-expired".} = object
|
||||||
`label`*: Preserve[E]
|
`label`*: Preserve[void]
|
||||||
`msecs`*: float64
|
`msecs`*: float64
|
||||||
|
|
||||||
SetTimer*[E] {.preservesRecord: "set-timer".} = ref object
|
SetTimer* {.preservesRecord: "set-timer".} = object
|
||||||
`label`*: Preserve[E]
|
`label`*: Preserve[void]
|
||||||
`msecs`*: float64
|
`msecs`*: float64
|
||||||
`kind`*: TimerKind
|
`kind`*: TimerKind
|
||||||
|
|
||||||
|
@ -17,14 +17,8 @@ type
|
||||||
LaterThan* {.preservesRecord: "later-than".} = object
|
LaterThan* {.preservesRecord: "later-than".} = object
|
||||||
`msecs`*: float64
|
`msecs`*: float64
|
||||||
|
|
||||||
proc `$`*[E](x: TimerExpired[E] | SetTimer[E]): string =
|
proc `$`*(x: TimerExpired | SetTimer | LaterThan): string =
|
||||||
`$`(toPreserve(x, E))
|
|
||||||
|
|
||||||
proc encode*[E](x: TimerExpired[E] | SetTimer[E]): seq[byte] =
|
|
||||||
encode(toPreserve(x, E))
|
|
||||||
|
|
||||||
proc `$`*(x: LaterThan): string =
|
|
||||||
`$`(toPreserve(x))
|
`$`(toPreserve(x))
|
||||||
|
|
||||||
proc encode*(x: LaterThan): seq[byte] =
|
proc encode*(x: TimerExpired | SetTimer | LaterThan): seq[byte] =
|
||||||
encode(toPreserve(x))
|
encode(toPreserve(x))
|
||||||
|
|
|
@ -0,0 +1,270 @@
|
||||||
|
|
||||||
|
import
|
||||||
|
std/typetraits, preserves, protocol, protocol, protocol, protocol, protocol,
|
||||||
|
protocol
|
||||||
|
|
||||||
|
type
|
||||||
|
TargetedTurnEvent*[Cap] {.preservesRecord: "event".} = object
|
||||||
|
`target`*: Target[Cap]
|
||||||
|
`detail`*: TurnEvent[Cap]
|
||||||
|
|
||||||
|
`LinkedTaskReleaseReason`* {.preservesOr, pure.} = enum
|
||||||
|
`cancelled`, `normal`
|
||||||
|
TurnId*[Cap] = Preserve[Cap]
|
||||||
|
AssertionDescriptionKind* {.pure.} = enum
|
||||||
|
`value`, `opaque`
|
||||||
|
AssertionDescriptionValue*[Cap] {.preservesRecord: "value".} = object
|
||||||
|
`value`*: Preserve[Cap]
|
||||||
|
|
||||||
|
AssertionDescriptionOpaque*[Cap] {.preservesRecord: "opaque".} = object
|
||||||
|
`description`*: Preserve[Cap]
|
||||||
|
|
||||||
|
`AssertionDescription`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: AssertionDescriptionKind
|
||||||
|
of AssertionDescriptionKind.`value`:
|
||||||
|
`value`*: AssertionDescriptionValue[Cap]
|
||||||
|
|
||||||
|
of AssertionDescriptionKind.`opaque`:
|
||||||
|
`opaque`*: AssertionDescriptionOpaque[Cap]
|
||||||
|
|
||||||
|
|
||||||
|
NameKind* {.pure.} = enum
|
||||||
|
`anonymous`, `named`
|
||||||
|
NameAnonymous* {.preservesRecord: "anonymous".} = object
|
||||||
|
|
||||||
|
NameNamed*[Cap] {.preservesRecord: "named".} = object
|
||||||
|
`name`*: Preserve[Cap]
|
||||||
|
|
||||||
|
`Name`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: NameKind
|
||||||
|
of NameKind.`anonymous`:
|
||||||
|
`anonymous`*: NameAnonymous
|
||||||
|
|
||||||
|
of NameKind.`named`:
|
||||||
|
`named`*: NameNamed[Cap]
|
||||||
|
|
||||||
|
|
||||||
|
ActorId*[Cap] = Preserve[Cap]
|
||||||
|
FacetId*[Cap] = Preserve[Cap]
|
||||||
|
`FacetStopReason`* {.preservesOr, pure.} = enum
|
||||||
|
`explicitAction`, `inert`, `parentStopping`, `actorStopping`
|
||||||
|
TaskId*[Cap] = Preserve[Cap]
|
||||||
|
ActorActivationKind* {.pure.} = enum
|
||||||
|
`start`, `turn`, `stop`
|
||||||
|
ActorActivationStart*[Cap] {.preservesRecord: "start".} = object
|
||||||
|
`actorName`*: Name[Cap]
|
||||||
|
|
||||||
|
ActorActivationStop* {.preservesRecord: "stop".} = object
|
||||||
|
`status`*: ExitStatus
|
||||||
|
|
||||||
|
`ActorActivation`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: ActorActivationKind
|
||||||
|
of ActorActivationKind.`start`:
|
||||||
|
`start`*: ActorActivationStart[Cap]
|
||||||
|
|
||||||
|
of ActorActivationKind.`turn`:
|
||||||
|
`turn`*: TurnDescription[Cap]
|
||||||
|
|
||||||
|
of ActorActivationKind.`stop`:
|
||||||
|
`stop`*: ActorActivationStop
|
||||||
|
|
||||||
|
|
||||||
|
Target*[Cap] {.preservesRecord: "entity".} = object
|
||||||
|
`actor`*: ActorId[Cap]
|
||||||
|
`facet`*: FacetId[Cap]
|
||||||
|
`oid`*: Oid[Cap]
|
||||||
|
|
||||||
|
TurnCauseKind* {.pure.} = enum
|
||||||
|
`turn`, `cleanup`, `linkedTaskRelease`, `periodicActivation`, `delay`,
|
||||||
|
`external`
|
||||||
|
TurnCauseTurn*[Cap] {.preservesRecord: "caused-by".} = object
|
||||||
|
`id`*: TurnId[Cap]
|
||||||
|
|
||||||
|
TurnCauseCleanup* {.preservesRecord: "cleanup".} = object
|
||||||
|
|
||||||
|
TurnCauseLinkedTaskRelease*[Cap] {.preservesRecord: "linked-task-release".} = object
|
||||||
|
`id`*: TaskId[Cap]
|
||||||
|
`reason`*: LinkedTaskReleaseReason
|
||||||
|
|
||||||
|
TurnCausePeriodicActivation* {.preservesRecord: "periodic-activation".} = object
|
||||||
|
`period`*: float64
|
||||||
|
|
||||||
|
TurnCauseDelay*[Cap] {.preservesRecord: "delay".} = object
|
||||||
|
`causingTurn`*: TurnId[Cap]
|
||||||
|
`amount`*: float64
|
||||||
|
|
||||||
|
TurnCauseExternal*[Cap] {.preservesRecord: "external".} = object
|
||||||
|
`description`*: Preserve[Cap]
|
||||||
|
|
||||||
|
`TurnCause`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: TurnCauseKind
|
||||||
|
of TurnCauseKind.`turn`:
|
||||||
|
`turn`*: TurnCauseTurn[Cap]
|
||||||
|
|
||||||
|
of TurnCauseKind.`cleanup`:
|
||||||
|
`cleanup`*: TurnCauseCleanup
|
||||||
|
|
||||||
|
of TurnCauseKind.`linkedTaskRelease`:
|
||||||
|
`linkedtaskrelease`*: TurnCauseLinkedTaskRelease[Cap]
|
||||||
|
|
||||||
|
of TurnCauseKind.`periodicActivation`:
|
||||||
|
`periodicactivation`*: TurnCausePeriodicActivation
|
||||||
|
|
||||||
|
of TurnCauseKind.`delay`:
|
||||||
|
`delay`*: TurnCauseDelay[Cap]
|
||||||
|
|
||||||
|
of TurnCauseKind.`external`:
|
||||||
|
`external`*: TurnCauseExternal[Cap]
|
||||||
|
|
||||||
|
|
||||||
|
TurnEventKind* {.pure.} = enum
|
||||||
|
`assert`, `retract`, `message`, `sync`, `breakLink`
|
||||||
|
TurnEventAssert*[Cap] {.preservesRecord: "assert".} = object
|
||||||
|
`assertion`*: AssertionDescription[Cap]
|
||||||
|
`handle`*: protocol.Handle
|
||||||
|
|
||||||
|
TurnEventRetract* {.preservesRecord: "retract".} = object
|
||||||
|
`handle`*: protocol.Handle
|
||||||
|
|
||||||
|
TurnEventMessage*[Cap] {.preservesRecord: "message".} = object
|
||||||
|
`body`*: AssertionDescription[Cap]
|
||||||
|
|
||||||
|
TurnEventSync*[Cap] {.preservesRecord: "sync".} = object
|
||||||
|
`peer`*: Target[Cap]
|
||||||
|
|
||||||
|
TurnEventBreakLink*[Cap] {.preservesRecord: "break-link".} = object
|
||||||
|
`source`*: ActorId[Cap]
|
||||||
|
`handle`*: protocol.Handle
|
||||||
|
|
||||||
|
`TurnEvent`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: TurnEventKind
|
||||||
|
of TurnEventKind.`assert`:
|
||||||
|
`assert`*: TurnEventAssert[Cap]
|
||||||
|
|
||||||
|
of TurnEventKind.`retract`:
|
||||||
|
`retract`*: TurnEventRetract
|
||||||
|
|
||||||
|
of TurnEventKind.`message`:
|
||||||
|
`message`*: TurnEventMessage[Cap]
|
||||||
|
|
||||||
|
of TurnEventKind.`sync`:
|
||||||
|
`sync`*: TurnEventSync[Cap]
|
||||||
|
|
||||||
|
of TurnEventKind.`breakLink`:
|
||||||
|
`breaklink`*: TurnEventBreakLink[Cap]
|
||||||
|
|
||||||
|
|
||||||
|
TurnDescription*[Cap] {.preservesRecord: "turn".} = object
|
||||||
|
`id`*: TurnId[Cap]
|
||||||
|
`cause`*: TurnCause[Cap]
|
||||||
|
`actions`*: seq[ActionDescription[Cap]]
|
||||||
|
|
||||||
|
ExitStatusKind* {.pure.} = enum
|
||||||
|
`ok`, `Error`
|
||||||
|
`ExitStatus`* {.preservesOr.} = object
|
||||||
|
case orKind*: ExitStatusKind
|
||||||
|
of ExitStatusKind.`ok`:
|
||||||
|
`ok`* {.preservesLiteral: "ok".}: bool
|
||||||
|
|
||||||
|
of ExitStatusKind.`Error`:
|
||||||
|
`error`*: protocol.Error
|
||||||
|
|
||||||
|
|
||||||
|
TraceEntry*[Cap] {.preservesRecord: "trace".} = object
|
||||||
|
`timestamp`*: float64
|
||||||
|
`actor`*: ActorId[Cap]
|
||||||
|
`item`*: ActorActivation[Cap]
|
||||||
|
|
||||||
|
Oid*[Cap] = Preserve[Cap]
|
||||||
|
ActionDescriptionKind* {.pure.} = enum
|
||||||
|
`dequeue`, `enqueue`, `dequeueInternal`, `enqueueInternal`, `spawn`, `link`,
|
||||||
|
`facetStart`, `facetStop`, `linkedTaskStart`
|
||||||
|
ActionDescriptionDequeue*[Cap] {.preservesRecord: "dequeue".} = object
|
||||||
|
`event`*: TargetedTurnEvent[Cap]
|
||||||
|
|
||||||
|
ActionDescriptionEnqueue*[Cap] {.preservesRecord: "enqueue".} = object
|
||||||
|
`event`*: TargetedTurnEvent[Cap]
|
||||||
|
|
||||||
|
ActionDescriptionDequeueInternal*[Cap] {.preservesRecord: "dequeue-internal".} = object
|
||||||
|
`event`*: TargetedTurnEvent[Cap]
|
||||||
|
|
||||||
|
ActionDescriptionEnqueueInternal*[Cap] {.preservesRecord: "enqueue-internal".} = object
|
||||||
|
`event`*: TargetedTurnEvent[Cap]
|
||||||
|
|
||||||
|
ActionDescriptionSpawn*[Cap] {.preservesRecord: "spawn".} = object
|
||||||
|
`link`*: bool
|
||||||
|
`id`*: ActorId[Cap]
|
||||||
|
|
||||||
|
ActionDescriptionLink*[Cap] {.preservesRecord: "link".} = object
|
||||||
|
`parentActor`*: ActorId[Cap]
|
||||||
|
`childToParent`*: protocol.Handle
|
||||||
|
`childActor`*: ActorId[Cap]
|
||||||
|
`parentToChild`*: protocol.Handle
|
||||||
|
|
||||||
|
ActionDescriptionFacetStart*[Cap] {.preservesRecord: "facet-start".} = object
|
||||||
|
`path`*: seq[FacetId[Cap]]
|
||||||
|
|
||||||
|
ActionDescriptionFacetStop*[Cap] {.preservesRecord: "facet-stop".} = object
|
||||||
|
`path`*: seq[FacetId[Cap]]
|
||||||
|
`reason`*: FacetStopReason
|
||||||
|
|
||||||
|
ActionDescriptionLinkedTaskStart*[Cap] {.preservesRecord: "linked-task-start".} = object
|
||||||
|
`taskName`*: Name[Cap]
|
||||||
|
`id`*: TaskId[Cap]
|
||||||
|
|
||||||
|
`ActionDescription`*[Cap] {.preservesOr.} = object
|
||||||
|
case orKind*: ActionDescriptionKind
|
||||||
|
of ActionDescriptionKind.`dequeue`:
|
||||||
|
`dequeue`*: ActionDescriptionDequeue[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`enqueue`:
|
||||||
|
`enqueue`*: ActionDescriptionEnqueue[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`dequeueInternal`:
|
||||||
|
`dequeueinternal`*: ActionDescriptionDequeueInternal[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`enqueueInternal`:
|
||||||
|
`enqueueinternal`*: ActionDescriptionEnqueueInternal[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`spawn`:
|
||||||
|
`spawn`*: ActionDescriptionSpawn[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`link`:
|
||||||
|
`link`*: ActionDescriptionLink[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`facetStart`:
|
||||||
|
`facetstart`*: ActionDescriptionFacetStart[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`facetStop`:
|
||||||
|
`facetstop`*: ActionDescriptionFacetStop[Cap]
|
||||||
|
|
||||||
|
of ActionDescriptionKind.`linkedTaskStart`:
|
||||||
|
`linkedtaskstart`*: ActionDescriptionLinkedTaskStart[Cap]
|
||||||
|
|
||||||
|
|
||||||
|
proc `$`*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] | Name[Cap] |
|
||||||
|
ActorActivation[Cap] |
|
||||||
|
Target[Cap] |
|
||||||
|
TurnCause[Cap] |
|
||||||
|
TurnEvent[Cap] |
|
||||||
|
TurnDescription[Cap] |
|
||||||
|
TraceEntry[Cap] |
|
||||||
|
ActionDescription[Cap]): string =
|
||||||
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
|
proc encode*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] |
|
||||||
|
Name[Cap] |
|
||||||
|
ActorActivation[Cap] |
|
||||||
|
Target[Cap] |
|
||||||
|
TurnCause[Cap] |
|
||||||
|
TurnEvent[Cap] |
|
||||||
|
TurnDescription[Cap] |
|
||||||
|
TraceEntry[Cap] |
|
||||||
|
ActionDescription[Cap]): seq[byte] =
|
||||||
|
encode(toPreserve(x, Cap))
|
||||||
|
|
||||||
|
proc `$`*(x: ExitStatus): string =
|
||||||
|
`$`(toPreserve(x))
|
||||||
|
|
||||||
|
proc encode*(x: ExitStatus): seq[byte] =
|
||||||
|
encode(toPreserve(x))
|
|
@ -3,12 +3,12 @@ import
|
||||||
std/typetraits, preserves
|
std/typetraits, preserves
|
||||||
|
|
||||||
type
|
type
|
||||||
Instance*[E] {.preservesRecord: "Instance".} = ref object
|
Instance*[Cap] {.preservesRecord: "Instance".} = object
|
||||||
`name`*: string
|
`name`*: string
|
||||||
`argument`*: Preserve[E]
|
`argument`*: Preserve[Cap]
|
||||||
|
|
||||||
proc `$`*[E](x: Instance[E]): string =
|
proc `$`*[Cap](x: Instance[Cap]): string =
|
||||||
`$`(toPreserve(x, E))
|
`$`(toPreserve(x, Cap))
|
||||||
|
|
||||||
proc encode*[E](x: Instance[E]): seq[byte] =
|
proc encode*[Cap](x: Instance[Cap]): seq[byte] =
|
||||||
encode(toPreserve(x, E))
|
encode(toPreserve(x, Cap))
|
||||||
|
|
|
@ -13,12 +13,9 @@ else:
|
||||||
type Oid = sturdy.Oid
|
type Oid = sturdy.Oid
|
||||||
|
|
||||||
type
|
type
|
||||||
|
Value = Preserve[void]
|
||||||
Assertion = Preserve[Ref]
|
Assertion = Preserve[Ref]
|
||||||
WireRef = sturdy.WireRef[void]
|
WireRef = sturdy.WireRef[void]
|
||||||
WireAssertion = Preserve[WireRef]
|
|
||||||
Event = protocol.Event[WireRef]
|
|
||||||
TurnEvent = protocol.TurnEvent[WireRef]
|
|
||||||
Packet = protocol.Packet[WireRef]
|
|
||||||
|
|
||||||
Turn = actors.Turn
|
Turn = actors.Turn
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ type
|
||||||
exported: Membrane
|
exported: Membrane
|
||||||
imported: Membrane
|
imported: Membrane
|
||||||
nextLocalOid: Oid
|
nextLocalOid: Oid
|
||||||
pendingTurn: protocol.Turn[WireRef]
|
pendingTurn: protocol.Turn
|
||||||
packetWriter: PacketWriter
|
packetWriter: PacketWriter
|
||||||
untrusted: bool
|
untrusted: bool
|
||||||
|
|
||||||
|
@ -85,16 +82,16 @@ proc rewriteRefOut(relay: Relay; `ref`: Ref; transient: bool; exported: var seq[
|
||||||
mine: WireRefMine(oid: ws.oid))
|
mine: WireRefMine(oid: ws.oid))
|
||||||
|
|
||||||
proc rewriteOut(relay: Relay; v: Assertion; transient: bool):
|
proc rewriteOut(relay: Relay; v: Assertion; transient: bool):
|
||||||
tuple[rewritten: WireAssertion, exported: seq[WireSymbol]] =
|
tuple[rewritten: Value, exported: seq[WireSymbol]] =
|
||||||
var exported: seq[WireSymbol]
|
var exported: seq[WireSymbol]
|
||||||
result.rewritten = mapEmbeds[Ref, WireRef](v) do (r: Ref) -> WireRef:
|
result.rewritten = contract(v) do (r: Ref) -> Value:
|
||||||
rewriteRefOut(relay, r, transient, exported)
|
rewriteRefOut(relay, r, transient, exported).toPreserve
|
||||||
result.exported = exported
|
result.exported = exported
|
||||||
|
|
||||||
proc register(relay: Relay; v: Assertion): WireAssertion =
|
proc register(relay: Relay; v: Assertion): Value =
|
||||||
rewriteOut(relay, v, false).rewritten
|
rewriteOut(relay, v, false).rewritten
|
||||||
|
|
||||||
proc register(relay: Relay; v: Assertion; h: Handle): WireAssertion =
|
proc register(relay: Relay; v: Assertion; h: Handle): Value =
|
||||||
var (rewritten, exported) = rewriteOut(relay, v, false)
|
var (rewritten, exported) = rewriteOut(relay, v, false)
|
||||||
relay.outboundAssertions[h] = exported
|
relay.outboundAssertions[h] = exported
|
||||||
rewritten
|
rewritten
|
||||||
|
@ -125,7 +122,7 @@ proc send(re: RelayEntity; ev: Event) =
|
||||||
method publish(re: RelayEntity; t: var Turn; v: Assertion; h: Handle) =
|
method publish(re: RelayEntity; t: var Turn; v: Assertion; h: Handle) =
|
||||||
re.send Event(
|
re.send Event(
|
||||||
orKind: EventKind.Assert,
|
orKind: EventKind.Assert,
|
||||||
`assert`: protocol.Assert[WireRef](
|
`assert`: protocol.Assert(
|
||||||
assertion: re.relay.register(v, h),
|
assertion: re.relay.register(v, h),
|
||||||
handle: h))
|
handle: h))
|
||||||
|
|
||||||
|
@ -137,7 +134,7 @@ method retract(re: RelayEntity; t: var Turn; h: Handle) =
|
||||||
|
|
||||||
method message(re: RelayEntity; turn: var Turn; msg: Assertion) =
|
method message(re: RelayEntity; turn: var Turn; msg: Assertion) =
|
||||||
re.send Event(orKind: EventKind.Message,
|
re.send Event(orKind: EventKind.Message,
|
||||||
message: Message[WireRef](body: register(re.relay, msg)))
|
message: Message(body: register(re.relay, msg)))
|
||||||
|
|
||||||
method sync(re: RelayEntity; turn: var Turn; peer: Ref) =
|
method sync(re: RelayEntity; turn: var Turn; peer: Ref) =
|
||||||
var
|
var
|
||||||
|
@ -146,9 +143,7 @@ method sync(re: RelayEntity; turn: var Turn; peer: Ref) =
|
||||||
discard rewriteRefOut(re.relay, turn.newRef(peerEntity), false, exported)
|
discard rewriteRefOut(re.relay, turn.newRef(peerEntity), false, exported)
|
||||||
# TODO: discard?
|
# TODO: discard?
|
||||||
peerEntity.e = exported[0]
|
peerEntity.e = exported[0]
|
||||||
re.send Event(
|
re.send Event(orKind: EventKind.Sync)
|
||||||
orKind: EventKind.Sync,
|
|
||||||
sync: Sync[WireRef](peer: embed toPreserve(false, WireRef))) # TODO: send the WireRef?
|
|
||||||
|
|
||||||
proc newRelayEntity(label: string; r: Relay; o: Oid): RelayEntity =
|
proc newRelayEntity(label: string; r: Relay; o: Oid): RelayEntity =
|
||||||
RelayEntity(label: label, relay: r, oid: o)
|
RelayEntity(label: label, relay: r, oid: o)
|
||||||
|
@ -180,11 +175,14 @@ proc rewriteRefIn(relay; facet; n: WireRef, imported: var seq[WireSymbol]): Ref
|
||||||
if n.yours.attenuation.len == 0 or r.isInert: result = r
|
if n.yours.attenuation.len == 0 or r.isInert: result = r
|
||||||
else: raiseAssert "attenuation not implemented"
|
else: raiseAssert "attenuation not implemented"
|
||||||
|
|
||||||
proc rewriteIn(relay; facet; a: Preserve[WireRef]):
|
proc rewriteIn(relay; facet; v: Value):
|
||||||
tuple[rewritten: Assertion; imported: seq[WireSymbol]] =
|
tuple[rewritten: Assertion; imported: seq[WireSymbol]] =
|
||||||
var imported: seq[WireSymbol]
|
var imported: seq[WireSymbol]
|
||||||
result.rewritten = mapEmbeds(a) do (wr: WireRef) -> Ref:
|
result.rewritten = expand(v) do (pr: Value) -> Assertion:
|
||||||
rewriteRefIn(relay, facet, wr, imported)
|
var wr: WireRef
|
||||||
|
if not fromPreserve(wr, pr):
|
||||||
|
raiseAssert "expansion of embedded value failed"
|
||||||
|
rewriteRefIn(relay, facet, wr, imported).toPreserve(Ref)
|
||||||
result.imported = imported
|
result.imported = imported
|
||||||
|
|
||||||
proc close(r: Relay) = discard
|
proc close(r: Relay) = discard
|
||||||
|
@ -217,7 +215,7 @@ proc dispatch(relay: Relay; turn: var Turn; `ref`: Ref; event: Event) =
|
||||||
for e in imported: relay.imported.del e
|
for e in imported: relay.imported.del e
|
||||||
]#
|
]#
|
||||||
|
|
||||||
proc dispatch(relay: Relay; v: Preserve[WireRef]) =
|
proc dispatch(relay: Relay; v: Value) =
|
||||||
trace "S: ", v
|
trace "S: ", v
|
||||||
run(relay.facet) do (t: var Turn):
|
run(relay.facet) do (t: var Turn):
|
||||||
var pkt: Packet
|
var pkt: Packet
|
||||||
|
@ -227,12 +225,14 @@ proc dispatch(relay: Relay; v: Preserve[WireRef]) =
|
||||||
for te in pkt.turn:
|
for te in pkt.turn:
|
||||||
dispatch(relay, t, lookupLocal(relay, te.oid.Oid), te.event)
|
dispatch(relay, t, lookupLocal(relay, te.oid.Oid), te.event)
|
||||||
of PacketKind.Error:
|
of PacketKind.Error:
|
||||||
|
when defined(posix):
|
||||||
stderr.writeLine("Error from server: ", pkt.error.message, " (detail: ", pkt.error.detail, ")")
|
stderr.writeLine("Error from server: ", pkt.error.message, " (detail: ", pkt.error.detail, ")")
|
||||||
close relay
|
close relay
|
||||||
of PacketKind.Extension:
|
of PacketKind.Extension:
|
||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
stderr.writeLine "discarding undecoded packet ", v
|
when defined(posix):
|
||||||
|
stderr.writeLine("discarding undecoded packet ", v)
|
||||||
|
|
||||||
type
|
type
|
||||||
RelayOptions = object of RootObj
|
RelayOptions = object of RootObj
|
||||||
|
@ -318,7 +318,7 @@ proc connectUnix*(turn: var Turn; path: string; cap: SturdyRef; bootProc: Connec
|
||||||
run(facet) do (turn: var Turn): stopActor(turn)
|
run(facet) do (turn: var Turn): stopActor(turn)
|
||||||
else:
|
else:
|
||||||
feed(wireBuf, buf)
|
feed(wireBuf, buf)
|
||||||
var (success, pr) = decode(wireBuf, WireRef)
|
var (success, pr) = decode(wireBuf)
|
||||||
if success:
|
if success:
|
||||||
dispatch(relay, pr)
|
dispatch(relay, pr)
|
||||||
callSoon:
|
callSoon:
|
||||||
|
@ -340,7 +340,7 @@ proc connectUnix*(turn: var Turn; path: string; cap: SturdyRef; bootProc: Connec
|
||||||
result = action
|
result = action
|
||||||
var res = Resolve(
|
var res = Resolve(
|
||||||
sturdyref: cap,
|
sturdyref: cap,
|
||||||
observer: embed newRef(turn, during(duringCallback)))
|
observer: newRef(turn, during(duringCallback)))
|
||||||
discard publish(turn, gatekeeper, res)
|
discard publish(turn, gatekeeper, res)
|
||||||
fut.complete()
|
fut.complete()
|
||||||
asyncCheck(turn, fut)
|
asyncCheck(turn, fut)
|
||||||
|
@ -373,7 +373,7 @@ proc connectStdio*(ds: Ref; turn: var Turn) =
|
||||||
run(facet) do (turn: var Turn): stopActor(turn)
|
run(facet) do (turn: var Turn): stopActor(turn)
|
||||||
else:
|
else:
|
||||||
feed(wireBuf, buf)
|
feed(wireBuf, buf)
|
||||||
var (success, pr) = decode(wireBuf, WireRef)
|
var (success, pr) = decode(wireBuf)
|
||||||
if success:
|
if success:
|
||||||
dispatch(relay, pr)
|
dispatch(relay, pr)
|
||||||
callSoon: asyncStdin.read(stdinReadSize).addCallback(recvCb)
|
callSoon: asyncStdin.read(stdinReadSize).addCallback(recvCb)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "20221102"
|
version = "20221208"
|
||||||
author = "Emery Hemingway"
|
author = "Emery Hemingway"
|
||||||
description = "Syndicated actors for conversational concurrency"
|
description = "Syndicated actors for conversational concurrency"
|
||||||
license = "Unlicense"
|
license = "Unlicense"
|
||||||
|
@ -10,4 +10,4 @@ bin = @["syndicate/unix/swaybar_status_actor"]
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires "nim >= 1.4.8", "nimSHA2 >= 0.1.1", "preserves >= 202210230"
|
requires "nim >= 1.4.8", "nimSHA2 >= 0.1.1", "preserves >= 20221208", "taps >= 20221119"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
include_rules
|
||||||
|
: test_simpleChatProtocol.nim | ../<protocols> |> !nim_run |>
|
Loading…
Reference in New Issue