logos-delivery/logos_delivery/api/reliable_channel_manager_api.nim
Ivan FB f332c130ed
feat(channels): add channelExists to reliable channels API
Callers need to know whether a channel is open before create/send, and
had no way to ask without inferring it from a "channel already exists"
error. Exposed at both layers so FFI consumers get the same answer.

"Exists" means currently held by the manager, i.e. between a successful
createReliableChannel and closeChannel. Persisted SDS state outlives a
close, so a closed channel reports false -- this is a liveness check,
not a "was this channel ever created" check.

Cherry-picked from chore/channel-exists, which forked before the nim-ffi
0.2.0 migration. The FFI proc is re-expressed in the typed model, which
also lets it carry a real bool instead of a "true"/"false" string; the
hand-written header hunk is dropped since that header is generated now.

Closes #4039

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 17:52:27 +02:00

17 lines
647 B
Nim

import chronos, results
import logos_delivery/api/types as api_types
import logos_delivery/channels/types as channel_types
export api_types, channel_types
# Structural API contract for the reliable-channel surface (ops in `channels/api/*`).
type ReliableChannelApi* = concept c
createReliableChannel(
c, channelId = ChannelId, contentTopic = ContentTopic, senderId = SdsParticipantID
) is Result[ChannelId, string]
channelExists(c, channelId = ChannelId) is bool
closeChannel(c, channelId = ChannelId) is Future[Result[void, string]]
send(c, channelId = ChannelId, appPayload = seq[byte]) is
Future[Result[RequestId, string]]