add RawString type in serial

This commit is contained in:
Ivan FB 2026-05-05 15:14:28 +02:00
parent ed099ba314
commit 233d6d726b
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270

View File

@ -2,6 +2,17 @@ import std/[json, macros, options]
import results
import ./codegen/meta
## RawString passes the C string through as-is, with no JSON encoding/decoding.
## Use this when the C caller provides a value that should not be treated as a
## JSON-encoded string (e.g. a raw config JSON blob, a multiaddress, an ENR).
type RawString* = distinct string
proc ffiSerialize*(x: RawString): string =
string(x)
proc ffiDeserialize*(s: cstring, _: typedesc[RawString]): Result[RawString, string] =
ok(RawString($s))
proc ffiSerialize*(x: string): string =
$(%*x)