{"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.4.0","deps":[],"features":{},"cksum":"sha256:8089df091d634f44ad3689e25ac2845752edad34dc7e71fda3e5e4e08579b670","sig":"ed25519:7d5776ca612598ee413af71428ad42169d42274d3b2ac6148bf7ac2fcb8ba61eca8be30e9b40054efb6beda98b426f674d42caf1aaf304823ee57bf4fbb97b04","key_fp":"SHA256:xl0hCTnhRoxLob4M6UdsT7Jtjn0a2wyYJf9ObIANTao","yanked":false,"edition":"2026","hew":">=0.6.2, <0.7.0","registry_sig":"ed25519:3e678f4f21911ba49e9bf25d0d6fe9def80b6d5fc0c8b7bfe2624585a3bc7e37db42aacc0fca5c5177c1bda11749ce3d68715c32782d709d5d618280a764420f","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-21T03:47:56.355Z","dl":"https://cdn.hewpkg.com/tarballs/hew/queue/nats/0.4.0.tar.zst"}}