{"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.7.1","deps":[],"features":{},"cksum":"sha256:00dba81a83fec1a09a8602c225e3b5065e911b9431e651fb3ae1c753e0c97e28","sig":"ed25519:5978b2d0812ef6d4eec718afa1fc6d94564c42d29b44ca63be2553e9bdb1c940313c83b48bb0c5850375e4330df9c7556e51ab06e88e1251c2781d10ce0faf00","key_fp":"SHA256:jiRoI3zNjRf/jbs3rkssGHT0JSZIte0YQJ/WV2hf5xE","yanked":false,"edition":"2026","hew":">=0.10.0, <0.12.0","registry_sig":"ed25519:c33009f6bedca231b09225da7ba5e2d936d4b81ed0785d00cc33b45f37e38a510ad1c6fff88e5d9e41c5608e3d5b34e85148bd019f5cf7dd30167e8fb672e306","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-11-19T02:50:52.494Z","dl":"https://cdn.hewpkg.com/tarballs/hew/queue/nats/0.7.1.tar.zst"}}