Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

make_uuid.rs 665 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  1. use structopt::StructOpt;
  2. use uuid::Uuid;
  3. use anyhow::Result;
  4. use super::Command;
  5. #[derive(StructOpt, Debug)]
  6. #[structopt(name="make-uuid")]
  7. pub struct MakeUuid {
  8. #[structopt(short="n", long="namespace")]
  9. namespace: Option<String>,
  10. #[structopt(name = "STRING")]
  11. string: Vec<String>
  12. }
  13. impl Command for MakeUuid {
  14. fn exec(self) -> Result<()> {
  15. let ns = match self.namespace {
  16. None => Uuid::nil(),
  17. Some(ref s) if s == "url" => uuid::NAMESPACE_URL,
  18. Some(ref s) => uuid::Uuid::new_v5(&uuid::Uuid::nil(), s)
  19. };
  20. for s in self.string {
  21. let u = Uuid::new_v5(&ns, &s);
  22. println!("{}\t{}", u, s);
  23. }
  24. Ok(())
  25. }
  26. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...