mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-27 20:10:02 +00:00
Rewrite the C FFI over the new per-layer APIs using nim-ffi v0.2.0 typed
{.ffiCtor.}/{.ffiDtor.}/{.ffi.}/{.ffiEvent.} + CBOR, replacing the
hand-written cstring/JSON bridge and the declare/lifecycle scaffolding.
Final API shape from the start (no intermediate request wrappers):
- every {.ffi.} proc takes its parameters directly; the macro bundles them
into the per-proc CBOR request, so no `*Request` objects are needed
- WakuMessage rides the wire directly (its fields are CBOR-serializable)
- multi-parameter {.ffiEvent.} via the rc.3 envelope synthesis
- events are fed by internal nim-broker listeners (no AppCallbacks)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
902 B
Nim
33 lines
902 B
Nim
## The waku api getters are synchronous and can't fail, so the bodies just wrap
|
|
## the value; the `{.ffi.}` macro wraps it into the `Future` it must expose.
|
|
|
|
proc version*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok(self.waku.version())
|
|
|
|
proc listen_addresses*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok(self.waku.listenAddresses().join(","))
|
|
|
|
proc get_my_enr*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok(self.waku.myEnr())
|
|
|
|
proc get_my_peerid*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok(self.waku.myPeerId())
|
|
|
|
proc get_metrics*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok(self.waku.metrics())
|
|
|
|
proc is_online*(
|
|
self: LogosDelivery
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
return ok($self.waku.isOnline())
|