possum/nsid

Namespaced Identifiers (NSIDs) are used to reference Lexicon schemas for records, XRPC endpoints, and more. For example, com.atproto.sync.getRecord.

The basic structure and semantics of an NSID are a fully-qualified hostname in reverse domain-name order, followed by an additional name segment. The hostname part is the domain authority, and the final segment is the name.

Documentation: Namespaced Identifiers

Types

A specification for global semantic IDs.

pub opaque type Nsid
pub type ParseError {
  InvalidRegexPattern(pattern: String)
  InvalidSyntax(value: String)
}

Constructors

  • InvalidRegexPattern(pattern: String)

    Regex failed to compile

  • InvalidSyntax(value: String)

    String does not have a valid NSID format

Values

pub fn parse(content: String) -> Result(Nsid, ParseError)

Parse a string into a valid Nsid type If the value is not a valid string then an error is returned.

Examples

import possum/nsid

let string = "com.atproto.sync.getRecord."
let assert Ok(nsid) = nsid.parse(string)
pub fn to_string(nsid: Nsid) -> String

Convert a NSID into a String

Examples

import possum/nsid

let string = "com.atproto.sync.getRecord"

let assert Ok(nsid) = nsid.parse(string)
assert nsid.to_string(nsid) == string
Search Document