GenId

API Documentation for GenId.

GenId.bit_mask_intMethod
bit_mask_int(type, v, from, to)

Applies a 64 bit signed integer mask to a value v, with ones between bits in postitions between from and to and zeroes for other bits.

Counting of bits starts at 0.

v can't be a negative integer.

Examples

julia> bit_mask_int(Int64, typemax(Int64), 0,0)
1
julia> bit_mask_int(Int64, typemax(Int64), 0,1)
3
source
GenId.bit_mask_uintMethod
bit_mask_uint(type, v, from, to)

Masks a 64 bit unsigned integer v with ones between bits in postitions between from and to and zeroes for other bits.

Counting of bits starts at 0.

Examples

julia> bit_mask_uint(UInt64, typemax(UInt64), 0,0)
0x0000000000000001
julia> bit_mask_uint(UInt64, typemax(UInt64), 12, 21)
0x00000000003ff000
source
GenId.bit_mask_uintMethod
bit_mask_uint(from, to)

Creates a 64 bit unsigned integer mask, with ones between bits in postitions between from and to and zeroes for other bits.

Counting of bits starts at 0.

Examples

julia> bit_mask_uint(0,0)
0x0000000000000000000000000000000000000000000000000000000000000001
julia> bit_mask_uint(63,63)
0x1000000000000000000000000000000000000000000000000000000000000000
julia> bit_mask_uint(12,21)
0x0000000000000000000000000000000000000000001111111111000000000000
source
GenId.crockford32_decode_int64Method
crockford32_decode_int64(s_input::String; skip_fn=skip_dashes_13_1, with_checksum=false)

Decodes a Crockford Base 32 encoded text into an Int64.

If with_checksum is set to true, parses the last character from the text as a modulo 37 checksum.

Examples

julia> crockford32_decode_int64("Z")
31

julia> crockford32_decode_int64("ZZ"; with_checksum=true)
31

julia> crockford32_decode_int64("Z-Z"; with_checksum=true)
31
source
GenId.crockford32_decode_uint64Method
crockford32_decode_uint64(s_input::String; skip_fn=skip_dashes_13_1, with_checksum=false)

Decodes a Crockford Base 32 encoded text into an UInt64.

If with_checksum is set to true, parses the last character from the text as a modulo 37 checksum.

Examples

julia> crockford32_decode_uint64("Z")
0x000000000000001f

julia> crockford32_decode_uint64("ZZ"; with_checksum=true)
0x000000000000001f

julia> crockford32_decode_uint64("Z-Z"; with_checksum=true)
0x000000000000001f
source
GenId.crockford32_encode_int64Method
crockford32_encode_int64(n::UInt64; started_init::Bool=false, with_checksum::Bool=false)

Encodes an Int64 n using Crockford Base 32.

If with_checksum is set to true, adds a modulo 37 checksum character at the end.

If started_init is set to true, pads the string to the left to 13(14 when a checksum is generated) characters.

Examples

julia> crockford32_encode_int64(31)
"Z"

julia> crockford32_encode_int64(31; with_checksum=true)
"ZZ"

julia> crockford32_encode_int64(31; with_checksum=true, started_init=true)
"000000000000ZZ"
source
GenId.crockford32_encode_uint64Method
crockford32_encode_uint64(n::UInt64; started_init::Bool=false, with_checksum::Bool=false)

Encodes an UInt64 n using Crockford Base 32.

If with_checksum is set to true, adds a modulo 37 checksum character at the end.

If started_init is set to true, pads the string to the left to 13(14 when a checksum is generated) characters.

Examples

julia> crockford32_encode_uint64(0x000000000000001f)
"Z"

julia> crockford32_encode_uint64(0x000000000000001f; with_checksum=true)
"ZZ"

julia> crockford32_encode_uint64(0x000000000000001f; with_checksum=true, started_init=true)
"000000000000ZZ"
source
GenId.tsid_int_from_stringMethod
tsid_int_from_string(def::TsIdDefinition, s::AbstractString)

Creates a new UUID from a textual representation in s based on text_* flags in def`.

Examples

julia> tsid_from_string(iddef, "DJR0RGDG0401")
489485826766409729
source
GenId.tsid_to_stringMethod
tsid_to_string(def::TsIdDefinition, tsid::T) where T <: Integer

Creates a new UUID from a textual representation in s based on text_* flags in def`.

Examples

julia> tsid_to_string(iddef, 489485826766409729)
"DJR0RGDG0401"
source