nanoid icon indicating copy to clipboard operation
nanoid copied to clipboard

API 2.0

Open ai opened this issue 5 years ago • 7 comments

Let’s update the library to be compatible with the latest Nano ID 2.0:

  • [x] Replace ~ to - in default alphabet
  • [ ] Add non-secure fast generator
  • [ ] Async API?

ai avatar Nov 06 '18 16:11 ai

How do you see async in Rust? We have event-loop, and any operation is performed synchronously

nikolay-govorov avatar Nov 06 '18 18:11 nikolay-govorov

It is questionable part depends on a programming language. Maybe it should not be implemented in Rust.

But what about event-loop based framework which we talk about in Logux issue?

ai avatar Nov 06 '18 18:11 ai

It seems to me that to bring a big Tokio for small nanoid is inadmissible. It seems to me that in the reality of Rust, it is better for the user to decide how he organizes the asynchrony

nikolay-govorov avatar Nov 06 '18 18:11 nikolay-govorov

it is better for the user to decide how he organizes the asynchrony

👍

ai avatar Nov 06 '18 18:11 ai

I like your plan to let users decide asynchrony. That makes sense to me too.

The non-secure generator would be a nice feature, so I'll keep an eye out for that. Maybe changing this issue to just track that would fit since it's the only remaining task.

Thank you

naturallymitchell avatar Feb 22 '19 17:02 naturallymitchell

I like that the Uuid crate has a Uuid type that just stores the random bytes. If you're planning to change the API, something like this would be nice to have. It improves performance when using the NanoID as the key in object stores that don't use String keys.

sorcix avatar May 29 '22 16:05 sorcix

Maybe also change the API of the random generator to be FnMut(&mut [u8]) so that a new vec doesn't have to be allocated each time more random data is needed.

tmccombs avatar Jan 10 '23 05:01 tmccombs