{"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.3.0","deps":[],"features":{},"cksum":"sha256:2348007c132ecfebbd40b63f7c4f736d95dc44b200a1fab8794e33e26fed2477","sig":"ed25519:d7024a7c14189104204310f30e89c133910d7be19c3621d1991a5194a3b54a5058f6dfa6a54fa0b55e8258376005ebf42c3daa726c7be8059a727a404f475904","key_fp":"SHA256:jLehs0udkm2NCjnfcFdvc8l8rkRR5tJ++54dk9PpbGk","yanked":false,"edition":"2026","hew":">=0.6.1, <0.7.0","registry_sig":"ed25519:83d9fa1395d2fd3eac9b6f0e61ba2633e681d2c194f8b1c82fe517643cbfb852f62ee8374422019f2bf933065882d8d8c2d195dd7d50bff35bae82d6c68d3a01","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-17T05:38:33.337Z","dl":"https://cdn.hewpkg.com/tarballs/hew/queue/nats/0.3.0.tar.zst"}}