UUID4.jl

CI status codecov.io


Usage

pkg> registry add https://github.com/0h7z/0hjl.git
pkg> add UUID4

julia> using UUID4
help?> UUID4
help?> uuid

API reference

UUID4.UUID4Module
UUID4

This module provides universally unique identifier (UUID) version 4, along with related functions.

source

Types

Functions

UUID4.uuidFunction
uuid(rng::Random.AbstractRNG = Random.RandomDevice()) -> UUID

Generate a version 4 (random or pseudo-random) universally unique identifier (UUID), as specified by RFC 4122.

Examples

julia> rng = Random.MersenneTwister(42);

julia> uuid(rng)
UUID("bc8f8f98-a497-45c4-817b-b034d1a24a0e")
source
UUID4.uuid_formatsMethod
uuid_formats() -> Vector{Int}

Return all 7 supported UUID string formats.

# case-sensitive
22 # (base62) 22
24 # (base62) 7-7-8
# case-insensitive
25 # (base36) 25
29 # (base36) 5-5-5-5-5
32 # (base16) 32
36 # (base16) 8-4-4-4-12
39 # (base16) 4-4-4-4-4-4-4-4
source
UUID4.uuid_parseFunction
uuid_parse(str::AbstractString; fmt::Int = ncodeunits(str)) -> Tuple{Int, UUID}
source
UUID4.uuid_stringFunction
uuid_string(id::UUID = uuid()) -> Dict{Int, String}
uuid_string(id::UUID = uuid(), T) -> T{Int, String} where T <: AbstractDict
uuid_string(id::UUID = uuid(), fmt::Int) -> String

Examples

julia> uuid_string(OrderedDict, "123e4567-e89b-12d3-a456-426614174000")
OrderedDict{Int64, String} with 7 entries:
  22 => "0YQJpYwUwvbaLOwTUr4thA"
  24 => "0YQJpYw-UwvbaLO-wTUr4thA"
  25 => "12vqjrnxk8whv3i8qi6qgrlz4"
  29 => "12vqj-rnxk8-whv3i-8qi6q-grlz4"
  32 => "123e4567e89b12d3a456426614174000"
  36 => "123e4567-e89b-12d3-a456-426614174000"
  39 => "123e-4567-e89b-12d3-a456-4266-1417-4000"
source
UUID4.uuid_versionFunction
uuid_version(id::AbstractString) -> Int
uuid_version(id::UUID)           -> Int

Inspect the given UUID or UUID string and return its version (see RFC 4122).

Examples

julia> uuid_version(uuid())
4
source