Skip to content

Use async-nats in tools and extractors and don't use the nats crate anymore #192

Closed

Description

@0xB10C

The sync NATS crate currently in use is deprecated and doesn't receive updates anymore. While it works, it causes problems when cargo updateing as the nuid package is incompatible with a newer rand version. Automated update PRs such as #189 fail with:

error[E0432]: unresolved import `rand::distributions`
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nuid-0.3.2/src/lib.rs:19:11
   |
19 | use rand::distributions::Alphanumeric;
   |           ^^^^^^^^^^^^^ could not find `distributions` in `rand`

error[E0599]: the method `sample_iter` exists for struct `OsRng`, but its trait bounds were not satisfied
  --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nuid-0.3.2/src/lib.rs:82:27
   |
82 |         for (i, n) in rng.sample_iter(&Alphanumeric).take(PRE_LEN).enumerate() {
   |                           ^^^^^^^^^^^ method cannot be called on `OsRng` due to unsatisfied trait bounds
   |
  ::: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/os.rs:47:1
   |
47 | pub struct OsRng;
   | ---------------- doesn't satisfy `OsRng: RngCore` or `OsRng: Rng`
   |
   = note: the following trait bounds were not satisfied:
           `OsRng: RngCore`
           which is required by `OsRng: Rng`
           `&OsRng: RngCore`
           which is required by `&OsRng: Rng`
           `&mut OsRng: RngCore`
           which is required by `&mut OsRng: Rng`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `nuid` (lib) due to 2 previous errors

A work around is running cargo update [email protected] once, but ideally we'd switch to the maintained async-nats crate.

See also nats-io/nats.rs#1378 and nats-io/nats.rs#1375

PR #191 uses async-nats and tokio. Other tools and extractor can be switchted, once this is merged.

Progress:

Activity

  1. added 2 commits that reference this issue on Aug 11, 2025
    0ffeedb
    f28067b
  2. 0xB10C commented on Aug 11, 2025

    @0xB10C
    CollaboratorAuthor

    This shouldn't have been closed - #202 should have been closed instead.

  3. reopened this on Aug 11, 2025
  4. added a commit that references this issue on Aug 18, 2025
    9651291
  5. added a commit that references this issue on Aug 26, 2025
    caa53f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions