UUID library for Nim
Find a file
ee7 8cb8720b56 Fix error with styleCheck
Before this commit, running `nim c --styleCheck:error` on a file
that imports the `uuids` package would produce an error on Windows.

`WINBOOL` is defined here:
52cf728001/lib/windows/winlean.nim (L33)

Fixes: #5
2021-01-15 17:07:13 +07:00
.vscode First version 2016-09-15 20:35:01 +07:00
uuids Fix error with styleCheck 2021-01-15 17:07:13 +07:00
.gitignore fixed nimble check and compatibility with new nim compiler (strings can't be nil) 2018-09-05 15:00:33 +07:00
LICENSE First version 2016-09-15 20:35:01 +07:00
README.md Expose mostSigBits and leastSigBits 2017-06-18 22:37:13 +07:00
uuids.nim fixed nimble check and compatibility with new nim compiler (strings can't be nil) 2018-09-05 15:00:33 +07:00
uuids.nimble Fix error with styleCheck 2021-01-15 17:07:13 +07:00

uuids

UUID library for Nim.

API:

type UUID* = object
  ## 128-bit UUID compliant with RFC-4122

proc initUUID*(mostSigBits, leastSigBits: int64): UUID =
  ## Initializes UUID with the specified most and least significant bits

proc leastSigBits*(uuid: UUID): int64 {.inline.}
  ## Returns 64 least significant bits of the ``uuid``

proc mostSigBits*(uuid: UUID): int64 {.inline.}
  ## Returns 64 most significant bits of the ``uuid``

proc `$`*(uuid: UUID): string
  ## Returns a string representation of the ``uuid`` in canonical form.

proc hash*(uuid: UUID): Hash
  ## Computes hash of the specified ``uuid``.

proc `==`*(x, y: UUID): bool
  ## Returns true when the specified UUIDs are equal, false otherwise.

proc isZero*(uuid: UUID): bool
  ## Returns ``true`` when the ``uuid`` is zero (not set), ``false`` otherwise.

proc genUUID*(): UUID
  ## Returns a random (v4) UUID.
  ## Uses a thread-local cryptographically secure PRNG (ISAAC) seeded with
  ## true random values obtained from OS.

proc parseUUID*(s: string): UUID {.raises: [ValueError].}
  ## Converts string representation of an UUID to UUID object.
  ## Raises ValueError if invalid format is provided.

License

This library is licensed under the MIT license. Read LICENSE file for details.

Copyright (c) 2016 Xored Software, Inc.