Skip to main content

SOURCE_WIT

Constant SOURCE_WIT 

Source
pub const SOURCE_WIT: &str = "package camel:plugin;\n\n// TODO(WIT-001): This file is a canonical source; camel-all.wit duplicates its content.\n// TODO(WIT-006): WIT interface versioning strategy is not yet defined. When the\n// WIT tooling supports it, add `@since(version = X.Y.Z)` annotations to each\n// interface and world definition to enable compatibility checks.\n\n/// Host-provided capabilities for guest-driven sources.\ninterface source-host {\n    use types.{wasm-exchange, wasm-error, stream-body-handle};\n\n    /// Host-owned HTTP listener handle. Created by the host when\n    /// the guest requests an http-listener capability in configure().\n    resource http-listener;\n\n    /// Incoming HTTP request delivered to the guest.\n    record http-request {\n        method: string,\n        path: string,\n        headers: list<tuple<string, string>>,\n        body: stream-body-handle,\n    }\n\n    /// Specification for an HTTP listener capability request.\n    record http-listener-spec {\n        bind: string,\n        path: option<string>,\n    }\n\n    /// What the guest requests from the host during configure().\n    variant capability-request {\n        http-listener(http-listener-spec),\n    }\n\n    /// The guest\'s concurrency model declaration.\n    variant concurrency-model {\n        sequential,\n        concurrent(u16),\n    }\n\n    /// Result of configure() \u{2014} declares what the guest needs.\n    /// Host rejects if capabilities.len() > 1 or unsupported capability.\n    record source-plan {\n        capabilities: list<capability-request>,\n        concurrency: concurrency-model,\n    }\n\n    /// Outcome of submit-exchange.\n    variant submit-outcome {\n        accepted,\n        stopped,\n    }\n\n    /// Accept the next HTTP request, or none if cancelled. Async: the guest\n    /// `await`s, yielding back to the host until a request arrives (or the run\n    /// is cancelled). The body is a `stream-body-handle` \u{2014} the guest reads\n    /// incrementally via `stream<u8>.read`, removing the materialization cap.\n    accept-http: async func(listener: borrow<http-listener>)\n        -> result<option<http-request>, wasm-error>;\n\n    /// Push an exchange into the pipeline. Returns once the pipeline accepts\n    /// the envelope (before full body drain). The guest MUST keep `run` alive\n    /// while a submitted body stream is still draining; the stream\'s terminal\n    /// future resolves when the body finished.\n    submit-exchange: async func(exchange: wasm-exchange)\n        -> result<submit-outcome, wasm-error>;\n\n    /// Check if the host has cancelled the run loop. Stays sync \u{2014} a quick\n    /// peek that must not yield (called in tight guest loops).\n    is-cancelled: func() -> bool;\n}\n\n/// The guest source world.\nworld source {\n    import source-host;\n    use types.{wasm-exchange, wasm-error};\n    use source-host.{source-plan, http-listener};\n\n    export configure: func(config: list<tuple<string, string>>)\n        -> result<source-plan, wasm-error>;\n\n    export run: async func(listener: borrow<http-listener>) -> result<_, wasm-error>;\n}\n";
Expand description

WIT source for the source world (standalone file, same package as PLUGIN_WIT).