46 lines
885 B
Plaintext
46 lines
885 B
Plaintext
parseUuid(value: Text) (out: Uuid?) {
|
|
out = uuid.parse(value)
|
|
}
|
|
|
|
writeUuid(value: Uuid) (out: Text) {
|
|
out = uuid.toText(value)
|
|
}
|
|
|
|
rule requiredUuid(value: Uuid?) (out: Uuid)
|
|
| value | out |
|
|
| null | fail(Invalid) |
|
|
| other | value |
|
|
|
|
readUuid(value: Text) (out: Uuid) {
|
|
out = requiredUuid(uuid.parse(value))
|
|
}
|
|
|
|
sameUuid(left: Uuid, right: Uuid) (out: Bool) {
|
|
out = left == right
|
|
}
|
|
|
|
lookupUuid(values: Map<Uuid, Int>, key: Uuid) (out: Int?) {
|
|
out = get(values, key)
|
|
}
|
|
|
|
mapUuid(first: Uuid, second: Uuid) (out: Map<Uuid, Int>) {
|
|
values: Map<Uuid, Int> = {}
|
|
out = put(put(values, first, 1), second, 2)
|
|
}
|
|
|
|
type Identifier {
|
|
value: Uuid
|
|
previous: Uuid?
|
|
}
|
|
|
|
uuidEcho(value: Identifier) (out: Identifier) {
|
|
out = value
|
|
}
|
|
|
|
uuidJson(value: Identifier) (out: Identifier) {
|
|
out = dever.json.decode(dever.json.encode(value))
|
|
}
|
|
|
|
cmd echo = app.uuidEcho
|
|
cmd json = app.uuidJson
|