{"metadata":{"name":"hew/queue/nats","vers":"0.7.3","description":"Typed, actor-owned NATS pub/sub and request/reply client","license":"MIT OR Apache-2.0","authors":["Hew Contributors"],"deps":[],"features":{},"keywords":["messaging","nats","pubsub","queue"],"repository":"https://github.com/hew-lang/ecosystem","edition":"2026","hew":">=0.10.0, <0.12.0","readme":"# hew.queue.nats\n\nA typed, actor-owned NATS client for publish/subscribe and request/reply.\nSubscriptions are owned by their connection actor, receive timeouts are\n`Receive.Missing`, and messages are immutable `#[wire]` snapshots.\n\nRun a server and the example from the repository root:\n\n```sh\ndocker run --rm -d --name hew-nats -p 14222:4222 nats:2.11.8-alpine3.22\nhew run --pkg-path . queue/nats/examples/pubsub.hew\n```\n\nEach `Conn` method is a `receive fn` that returns `T fails NatsError`, so a\ncall replies with `Result<T, ActorError<NatsError>>`: `.Ok(value)` on success,\n`.Err(.Failed(error))` when the NATS operation fails, and another `.Err` when\nthe actor could not answer.\n\n```hew\nimport hew.queue.nats;\n\nfn main() {\n    let client = spawn nats.Conn { options: nats.Options { url: \"nats://127.0.0.1:14222\" } };\n    match client.subscribe(\"hew.readme\") {\n        .Ok(subscription) => {\n            let _ = client.publish(\"hew.readme\", \"hello\");\n            match client.next_message(subscription.clone(), 1000) {\n                .Ok(.Message(message)) => println(message.data),\n                .Ok(.Missing) => println(\"no message arrived\"),\n                .Err(.Failed(error)) => println(nats.error_message(error)),\n                .Err(_) => println(\"NATS actor stopped before replying\"),\n            }\n            let _ = client.unsubscribe(subscription);\n        }\n        .Err(.Failed(error)) => println(nats.error_message(error)),\n        .Err(_) => println(\"NATS actor stopped before replying\"),\n    }\n    stop(client);\n    stopped(client);\n}\n```\n\n## API surface\n\n- `actor Conn` — owns one NATS connection and every subscription it creates.\n  - `init(options: Options)`\n  - `receive fn publish(subject: string, data: string) fails NatsError`\n  - `receive fn subscribe(subject: string) -> Subscription fails NatsError`\n  - `receive fn next_message(subscription: Subscription, timeout_ms: i64) -> Receive fails NatsError`\n  - `receive fn request(subject: string, data: string, timeout_ms: i64) -> Receive fails NatsError`\n  - `receive fn reply(message: Delivery, data: string) fails NatsError`\n  - `receive fn unsubscribe(subscription: Subscription)`\n- `stop(client); stopped(client);` — gracefully stop the actor and wait for connection cleanup.\n- `type Options { url: string; }`\n- `type Subscription { handle: i64; }`\n- `type Delivery { subject: string; data: string; reply_to: ReplyTo; }`\n- `enum ReplyTo { Missing; Subject(string); }`\n- `enum Receive { Missing; Message(Delivery); }`\n- `enum NatsError { Connection; InvalidInput; Operation; Closed; Internal; }` — each variant carries a diagnostic `string`.\n- `fn error_message(error: NatsError) -> string` — extracts the diagnostic from any `NatsError` variant.\n"},"version":{"name":"hew/queue/nats","vers":"0.5.0","deps":[],"features":{},"cksum":"sha256:6cf40171da793f740e1e20a2c838ad4e6229bd93ab1d2cda555765b11c52ce04","sig":"ed25519:e6f562b1d04b8e7c35652d5125f55cd8b95ca293ca79297ae79a977e775ae5141f37387145859907c4433d06d652ce2106f061280dacc8f4fa73e076c977560c","key_fp":"SHA256:EGxvQ8Gktjf0VMLt5eW4gxeKAR30l3wnVMa2c/DuSHQ","yanked":false,"edition":"2026","hew":">=0.8.0, <0.9.0","registry_sig":"ed25519:2c00f1422f0dcb5ff91d7765d1e34e6c75454f95101698fa2bf11ee2d5754730b5492901b5646d86761e1a7e20683bb6ae368f427a24680605b8e2882f0d500e","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-24T00:00:07.829Z","dl":"https://cdn.hewpkg.com/tarballs/hew/queue/nats/0.5.0.tar.zst"}}