NanoIdError variantv0.1.0
Why an identifier could not be generated.
pub variant NanoIdError {
AlphabetTooSmall,
AlphabetTooLarge,
DuplicateCharacter(uint),
NonAsciiCharacter(uint),
Entropy(EntropyError)
}
Failure-only: a call that succeeds fills its destination, and one that fails throws this. Copy, owning nothing. The alphabet cases are found before any random bytes are requested, so they never consume entropy.
Cases
| Name | Description |
|---|---|
AlphabetTooSmall | The alphabet has fewer than two characters, so an identifier from it carries no information. |
AlphabetTooLarge | The 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. |