Custom RNGs #153

Closed
opened 2018-02-20 09:35:34 -06:00 by dicej · 3 comments
dicej commented 2018-02-20 09:35:34 -06:00 (Migrated from github.com)

According to the docs, it should be possible to use the rand::Rand trait's rand() method to generate a v4 UUID using a custom RNG:

If you'd like to use a custom generator, don't use this method: use the rand::Rand trait's rand() method instead.

However, as of github.com/uuid-rs/uuid@addaecd0fc, Uuid no longer implements rand::Rand even if v4 support is enabled. Is there some other mechanism to specify a custom RNG?

According to the [docs](https://docs.rs/uuid/0.6.0/uuid/struct.Uuid.html), it should be possible to use the `rand::Rand` trait's `rand()` method to generate a v4 UUID using a custom RNG: > If you'd like to use a custom generator, don't use this method: use the rand::Rand trait's rand() method instead. However, as of https://github.com/uuid-rs/uuid/commit/addaecd0fc9a1dbb053420ff91ed61ec1fc31395, `Uuid` no longer implements `rand::Rand` even if v4 support is enabled. Is there some other mechanism to specify a custom RNG?
kinggoesgaming commented 2018-02-20 14:50:17 -06:00 (Migrated from github.com)

I think we will need to do a little research on this. Perhaps we will provide a temporary fix until rand is stabilized and we can make rand a public dependency.

as of addaecd, Uuid no longer implements rand::Rand even if v4 support is enabled.

Actually no. The implementation still exists, however its just not exposed to the library user.

I think we will need to do a little research on this. Perhaps we will provide a temporary fix until `rand` is stabilized and we can make `rand` a public dependency. > as of addaecd, Uuid no longer implements rand::Rand even if v4 support is enabled. Actually no. The implementation still exists, however its just not exposed to the library user.
adaszko commented 2018-03-04 05:55:10 -06:00 (Migrated from github.com)

I have the same problem as @dicej. My use case is to seed the RNG with a fixed value in order to keep my tests deterministic where the tested code generates a lot of UUIDv4 (#100).

I have the same problem as @dicej. My use case is to seed the RNG with a fixed value in order to keep my tests deterministic where the tested code generates a lot of UUIDv4 (#100).
asajeffrey commented 2018-03-15 09:49:55 -05:00 (Migrated from github.com)

This is impacting servo, which uses a custom RNG (https://github.com/servo/servo/blob/master/components/rand/lib.rs) which we use among other things to generate uuids. AFAICT there's now no way to do this.

This is impacting servo, which uses a custom RNG (https://github.com/servo/servo/blob/master/components/rand/lib.rs) which we use among other things to generate uuids. AFAICT there's now no way to do this.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#153
No description provided.