Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 UUIDs #91

Closed
rrichardson opened this issue Jun 5, 2017 · 6 comments
Closed

v1 UUIDs #91

rrichardson opened this issue Jun 5, 2017 · 6 comments

Comments

@rrichardson
Copy link
Contributor

rrichardson commented Jun 5, 2017

Is there a desire to have such a thing in this crate?

They would mutually exclusive with the [nostd] directive, since time::get_time would be the preferred method for getting at least 60 bits of precision of time since 1582.

In addition, it would need to take a context in order to store a counter in case of clock collisions due to low resolution on a platform.

Also "Node ID" is a vague notion, usually the mac address, but I assume we'd just want to let someone pass in 16 bytes for that.

So an interface might be:

pub fn new_v1_context() -> UUidV1Context;  

pub fn new_v1(&UUidV1Context,  &[u8; 16]) -> Uuid; 

}

The context would be internally mutable, using, say, a local atomic uint counter.

Thoughts?

@alexcrichton
Copy link
Contributor

Adding support seems fine by me! I'd prefer to keep the crate relatively slim on dependencies (e.g. if we need time keeping or local mac support then this may be best done in a separate crate), but if we can add support here for construction that seems reasonable.

@rrichardson
Copy link
Contributor Author

If we wanted to avoid a dependency on time, that is do-able, we could just take a u64 and u32 that would correspond to the sec and nsec fraction from time::timespec.

However, I don't think that there is a way to avoid a dependency on sync::atomic

If that is acceptable, I can start working on this.

@alexcrichton
Copy link
Contributor

Sounds great to me! (using atomics is totally fine)

@kw217
Copy link

kw217 commented Jun 20, 2017

I'd love to have v1 UUIDs too.

@rushmorem
Copy link
Contributor

@alexcrichton Now that v1 has landed, can we get a release? I have been using master to generate v1 UUIDs successfully.

@alexcrichton
Copy link
Contributor

Certainly, published now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants