Skip to main content

BYNK_ADAPTER_SRC

Constant BYNK_ADAPTER_SRC 

Source
pub const BYNK_ADAPTER_SRC: &str = "adapter bynk {\n\tuses bynk.locale.types\n\texports capability { Clock, Random, Logger, Fetch, Secrets, Locale, Idempotency, Events }\n\texports transparent { Uuid, Method, FetchError, Request, Response, EventEnvelope }\n\n\t---\n\tA UUID in canonical 8-4-4-4-12 lowercase-hex form.\n\t---\n\ttype Uuid = String where Matches(\"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\")\n\n\t---\n\tAn HTTP request method.\n\t---\n\ttype Method = enum { Get, Post, Put, Delete }\n\n\t---\n\tWhy an outbound `Fetch.send` failed: a network error or a timeout.\n\t---\n\ttype FetchError = enum { Network, Timeout }\n\n\t---\n\tAn outbound HTTP request, as passed to `Fetch.send`.\n\t---\n\ttype Request = {\n\t\tmethod: Method,\n\t\turl: String,\n\t\tcontentType: Option[String],\n\t\tauthorization: Option[String],\n\t\tbody: Option[String],\n\t}\n\n\t---\n\tAn HTTP response: a status code and a body.\n\t---\n\ttype Response = { status: Int, body: String }\n\n\t---\n\tRuntime metadata carried alongside an event payload (Events track, slice\n\t2; design/tracks/events.md, spine #936), available as an `on event`\n\thandler\'s optional second parameter. `eventId` is minted once per\n\temission \u{2014} every subscriber of that emission sees the same value, making\n\tit the dedup key for the `Idempotency` capability\'s `dedup`/`remember`\n\tidiom. `publisherId` is the emitting context\'s qualified name, not the\n\temitting agent\'s instance identity: `Events.emit` is legal from a plain,\n\tkeyless service handler with no agent to report, so a context-scoped\n\tidentifier is the only one available uniformly at every legal emission\n\tsite (an amendment to design/bynk-design-notes.md \u{a7}7\'s \"the publisher is\n\tthe emitting agent\" framing). `schemaVersion` is the version the\n\tcross-build schema registry (`bynk.schema.lock`, Events slice 3c) computes\n\tfor the emitting event: unchanged shape keeps its stored version, a purely\n\tadditive shape change (only new defaulted fields) auto-bumps it, and a\n\tnon-additive change fails the build. An explicit `@schema(N)` annotation\n\t(slice 3b) is checked against that computed value rather than trusted\n\toutright \u{2014} a mismatch is a build error, not a silent override.\n\t---\n\ttype EventEnvelope = {\n\t\teventId: String,\n\t\tpublisherId: String,\n\t\temittedAt: Instant,\n\t\tschemaVersion: Int,\n\t}\n\n\t---\n\tReads the current wall-clock time, as Unix milliseconds.\n\t---\n\tcapability Clock {\n\t\tfn now() -> Effect[Instant]\n\t}\n\n\t---\n\tA source of randomness \u{2014} fresh UUIDs and bounded integers.\n\t---\n\tcapability Random {\n\t\tfn uuid() -> Effect[Uuid]\n\t\tfn int(lo: Int, hi: Int) -> Effect[Int]\n\t}\n\n\t---\n\tStructured logging at info and error levels.\n\t---\n\tcapability Logger {\n\t\tfn info(msg: String) -> Effect[()]\n\t\tfn error(msg: String) -> Effect[()]\n\t}\n\n\t---\n\tPerforms outbound HTTP requests.\n\t---\n\tcapability Fetch {\n\t\tfn send(req: Request) -> Effect[Result[Response, FetchError]]\n\t}\n\n\t---\n\tReads named secrets from the platform\'s secret store.\n\t---\n\tcapability Secrets {\n\t\tfn get(name: String) -> Effect[Option[String]]\n\t}\n\n\t---\n\tReads the current locale for this request/session. Slice 1: always\n\treturns a fixed reference tag (`\"en\"`) on every platform.\n\t---\n\tcapability Locale {\n\t\tfn current() -> Effect[LocaleTag]\n\t}\n\n\t---\n\tMechanical dedup for at-least-once delivery (design notes \u{a7}12). `dedup`\n\tchecks for a cached outcome under `key`; on a cache miss the caller\n\tcomputes its outcome and writes it back with `remember` (`record` is a\n\treserved keyword), which the caller must call to actually cache anything\n\t\u{2014} a `dedup` miss with no matching `remember` call simply recomputes every\n\ttime. `expiresAfter` sets the retention window a call to `remember`\n\testablishes. Slice 0 (design/tracks/idempotency-capability.md): a single\n\tin-memory provider, lost on process restart \u{2014} no durability guarantee yet.\n\t---\n\tcapability Idempotency {\n\t\tfn dedup[T](key: String) -> Effect[Option[T]]\n\t\tfn remember[T](key: String, value: T, expiresAfter: Duration) -> Effect[()]\n\t}\n\n\t---\n\tEmits an event declared by the calling context (Events track, slice 0;\n\tdesign/tracks/events.md, spine #936). Owner-only: the compiler rejects\n\t`emit[E]` when `E` is not an event declared in the emitting context, even\n\twhen `E` is otherwise visible via `consumes`. Fire-and-forget: releases at\n\thandler commit, so an aborted handler emits nothing \u{2014} a `dedup`/`remember`-\n\tstyle write-then-flush the provider itself is responsible for, not a\n\tdistinct control-flow form here. The explicit `[E]` type argument follows\n\tthe `Idempotency.remember[T]` precedent: a generic capability operation\'s\n\ttype parameter is never inferred, even where an argument\'s type would\n\tdetermine it.\n\t---\n\tcapability Events {\n\t\tfn emit[E](event: E) -> Effect[()]\n\t}\n\n\tprovides Clock = ClockProvider\n\n\tprovides Random = RandomProvider\n\n\tprovides Logger = LoggerProvider\n\n\tprovides Fetch = FetchProvider\n\n\tprovides Secrets = SecretsProvider\n\n\tprovides Locale = LocaleProvider\n\n\tprovides Idempotency = IdempotencyProvider given Clock\n\n\tprovides Events = EventsProvider\n}\n";
Expand description

The reserved bynk conformance-surface adapter (env-free core). It has no binding clause — the toolchain supplies one per platform (see Platform::bynk_binding_source).