definitions.odin 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package uuid
  2. // A RFC 4122 Universally Unique Identifier
  3. Identifier :: distinct [16]u8
  4. EXPECTED_LENGTH :: 8 + 4 + 4 + 4 + 12 + 4
  5. VERSION_BYTE_INDEX :: 6
  6. VARIANT_BYTE_INDEX :: 8
  7. // The number of 100-nanosecond intervals between 1582-10-15 and 1970-01-01.
  8. HNS_INTERVALS_BETWEEN_GREG_AND_UNIX :: 141427 * 24 * 60 * 60 * 1000 * 1000 * 10
  9. VERSION_7_TIME_MASK :: 0xffffffff_ffff0000_00000000_00000000
  10. VERSION_7_TIME_SHIFT :: 80
  11. VERSION_7_COUNTER_MASK :: 0x00000000_00000fff_00000000_00000000
  12. VERSION_7_COUNTER_SHIFT :: 64
  13. @(private)
  14. NO_CSPRNG_ERROR :: "The context random generator is not cryptographic. See the documentation for an example of how to set one up."
  15. @(private)
  16. BIG_CLOCK_ERROR :: "The clock sequence can only hold 14 bits of data, therefore no number greater than 16,383 (0x3FFF)."
  17. @(private)
  18. VERSION_7_BIG_COUNTER_ERROR :: "This implementation of the version 7 UUID counter can only hold 12 bits of data, therefore no number greater than 4,095 (0xFFF)."
  19. Read_Error :: enum {
  20. None,
  21. Invalid_Length,
  22. Invalid_Hexadecimal,
  23. Invalid_Separator,
  24. }
  25. Variant_Type :: enum {
  26. Unknown,
  27. Reserved_Apollo_NCS, // 0b0xx
  28. RFC_4122, // 0b10x
  29. Reserved_Microsoft_COM, // 0b110
  30. Reserved_Future, // 0b111
  31. }
  32. // Name string is a fully-qualified domain name.
  33. @(rodata)
  34. Namespace_DNS := Identifier {
  35. 0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1,
  36. 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
  37. }
  38. // Name string is a URL.
  39. @(rodata)
  40. Namespace_URL := Identifier {
  41. 0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1,
  42. 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
  43. }
  44. // Name string is an ISO OID.
  45. @(rodata)
  46. Namespace_OID := Identifier {
  47. 0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1,
  48. 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
  49. }
  50. // Name string is an X.500 DN (in DER or a text output format).
  51. @(rodata)
  52. Namespace_X500 := Identifier {
  53. 0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1,
  54. 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
  55. }