CualerID
Documentation for CualerID.
CualerID.BASE30_ALPHABETCualerID.ResultCodeCualerID.ResultCodeOptionCualerID._hammingCualerID.base30encodeCualerID.cualer_idCualerID.has_duplicateCualerID.has_fixedCualerID.has_not_fixableCualerID.has_validCualerID.mint_ids!
CualerID.BASE30_ALPHABET — Constant
BASE30_ALPHABET::Vector{UInt8}An alphabet designed for unambiguous representation of values in either upper- or lower-case. The alphabet was formed by taking the numbers 0-9 and the Latin alphabet and removing characters that are considered easy to confuse. Excluded characters are
- $I$ => easily confused for lowercase $L$ or the digit $1$
- $L$ => easily confused for uppercase $I$ or the digit $1$
- $O$ => easily confused for the digit $0$
- $Q$ => easily confused with uppercase $O$ or lowercase $g$
- $V$ => easily confused with $U$
This array contains the ASCII index of the characters included in the base30 alphabet starting with 0 at position BASE30_ALPHABET[1]. Use String() to convert an array of these indices to a base30 string.
CualerID.ResultCode — Type
ResultCode::UInt8Encodes a result of attempting to correct a CualerID
The valid codes are
- D: duplicate
- F: fixed
- N: not fixable
- V: valid (no need for correction)
CualerID.ResultCodeOption — Type
ResultCodeOptionEncodes potential corrected id codes.
The valid codes are
- D: duplicate
- F: fixed
- N: not fixable
- V: valid (no need for correction)
The codes are implemented exactly as from cual-id and in that order
Constructors
ResultCodeOption(str::AbstractString)Create a ResultCodeOption based on a the character codes contained within str. str is case insensitive, may contain an arbitrary number of valid codes (as specified above), and may contain duplicates. A ResultCodeOption cannot be constructed from a combination of strings and bitmasks/integers.
Extended help
The struct stores values as a bitmask
| Bit (Int) | Bit (UInt) | Description |
|---|---|---|
| 1 | 0x01 | D - duplicate |
| 2 | 0x02 | F - fixed |
| 4 | 0x04 | N - not fixable |
| 8 | 0x08 | V - valid |
CualerID._hamming — Method
_hamming(str1::AbstractString, str2::AbstractString)Computes the Hamming distance between str1 and str2.
CualerID.base30encode — Method
base30encode(v::Integer; pad::Integer=1)
base30encode(v::UUID; pad::Integer=1)Creates a base30 representation of v padded out to pad digits. If v is a UUID, then the UInt128 value of the UUID is passed directly into the method.
Examples
julia> base30encode(30)
"10"julia> using UUIDs; base30encode(uuid1())
"7ZK00JECBDF2H7GNBXN59C6S9S"CualerID.cualer_id — Method
cualer_id(u::UUID; length::Integer = 29)Convert u to a base30 CualerID, truncating all but the last length digits as the human-readable representation of u
CualerID.has_duplicate — Method
has_duplicate(r::ResultCodeOption)Determines if r contains a duplicate result (ResultCode D)
CualerID.has_fixed — Method
has_fixed(r::ResultCodeOption)Determines if r contains a fixed result (ResultCode F)
CualerID.has_not_fixable — Method
has_not_fixable(r::ResultCodeOption)Determines if r contains a not fixable result (ResultCode N)
CualerID.has_valid — Method
has_valid(r::ResultCodeOption)Determines if r contains a valid (not corrected) result (ResultCode V)
CualerID.mint_ids! — Method
mint_ids!(
[existing_ids::Vector{UUID}],
desired_total::Integer,
desired_length::Integer,
failure_threshold::AbstractFloat,
)Creates desired_total number of UUIDs that are valid CualerIDs at a desired_length
Arguments
existing_ids::Vector{UUID}: A set of existing CualerIDs that have already been validated. The default is an empty array, i.e. construct an entirely new set of CualerIDs.desired_total::Integer: The length to growexisting_idstodesired_length::Integer: The length of the CualerID string that is compared to check for conflictsfailure_threshold::AbstractFloat: The fraction of non-conflicting values (between 0 and- that is required