NanoIdError variantv0.1.0

Source
Why an identifier could not be generated.
pub variant NanoIdError {
    AlphabetTooSmall,
    AlphabetTooLarge,
    DuplicateCharacter(uint),
    NonAsciiCharacter(uint),
    Entropy(EntropyError)
}

Failure-only: a filled destination is the success channel of ! NanoIdError. Copy, owning nothing. The alphabet cases are found before any random bytes are requested, so they never consume entropy.

Cases

NameDescription
AlphabetTooSmallThe alphabet has fewer than two characters, so an identifier from it carries no information.
AlphabetTooLargeThe alphabet has more than 256 characters, more than one random byte can choose between.
DuplicateCharacter(uint)A character appears twice, which would make it twice as likely as the rest. The offset is the second occurrence.
NonAsciiCharacter(uint)A byte outside ASCII. The offset is that byte. Each character of an identifier is one byte, which a character that takes several bytes in UTF-8 cannot be.
Entropy(EntropyError)The operating system could not supply random bytes, for the reason carried.