possum/handle
DIDs are the long-term persistent identifiers for accounts in atproto, but they can be opaque and unfriendly for human use. Handles are mutable and human-friendly account usernames, in the form of a DNS hostname. For example, “user.example.com”.
Documentation: Handle
Types
Handles have a limited role in atproto, and need to be resolved to a DID in almost all situations.
pub opaque type Handle
pub type ParseError {
InvalidRegexPattern(pattern: String)
InvalidSyntax(value: String)
DisallowedTopLevelDomain(domain: String)
}
Constructors
-
InvalidRegexPattern(pattern: String)Regex failed to compile
-
InvalidSyntax(value: String)String does not have a valid handle format
-
DisallowedTopLevelDomain(domain: String)“Reserved” top-level domains should not fail syntax validation, but they must immediately fail any attempt at registration.
The following TLD are not allowed:
- .alt
- .arpa
- .internal
- .invalid
- .local
- .localhost
- .onion
Documentation: Non-syntax Retrictions
Values
pub fn parse(content: String) -> Result(Handle, ParseError)
Parse a string into a valid Handle type
If the value is not a valid string then an error is returned.
Examples
import possum/handle
let string = "gleam.run"
let assert Ok(handle) = handle.parse(string)