possum/at_uri
The AT URI scheme (at://) makes it easy to reference individual records in a specific repository, identified by either DID or handle.
AT URIs are not content-addressed, so the contents of the record they refer to may also change over time.
Documentation: AT URI Scheme
Types
A URI scheme for addressing atproto repository data.
See also: parse
pub opaque type AtUri
pub type Authority {
Handle(value: handle.Handle)
Did(value: did.Did)
}
Constructors
-
Handle(value: handle.Handle)User handle, like: “tangled.org”
AT URIs referencing handles are not durable. If a user changes their handle, any AT URIs using that handle will become invalid and could potentially point to a record in another repo if the handle is reused.
-
Did(value: did.Did)User DID, like: “did:plc:wshs7t2adsemcrrd4snkeqli”
When referencing records, especially from other repositories, best practice is to use a DID in the authority part, not a handle.
pub type ParseError {
InvalidScheme(value: String)
MissingScheme
InvalidHandleAuthority(reason: handle.ParseError)
InvalidDidAuthority(reason: did.ParseError)
MissingAuthority
}
Constructors
-
InvalidScheme(value: String)Only “at://” is supported
-
MissingSchemeScheme is missing from the URI
-
InvalidHandleAuthority(reason: handle.ParseError)Authority not a valid Handle
-
InvalidDidAuthority(reason: did.ParseError)Authority not a valid DID
-
MissingAuthorityAuthority is an empty string
Values
pub fn authority(self: AtUri) -> Authority
Return the authority part of the Uri
Examples
import possum/at_uri
let string = "at://did:plc:vwzwgnygau7ed7b7wt5ux7y2/app.bsky.feed.post/3k5nobkf2w72g"
let assert Ok(at_uri) = at_uri.parse(string)
assert at_uri.authority(at_uri) == "did:plc:vwzwgnygau7ed7b7wt5ux7y2"
See also: Aturi
pub fn collection(self: AtUri) -> String
Return the collecion part of the Uri
Examples
import possum/at_uri
let string = "at://did:plc:vwzwgnygau7ed7b7wt5ux7y2/app.bsky.feed.post/3k5nobkf2w72g"
let assert Ok(at_uri) = at_uri.parse(string)
assert at_uri.collection(at_uri) == "app.bsky.feed.post"
See also: Aturi
pub fn parse(content: String) -> Result(AtUri, ParseError)
Parse a String into a valid At-Uri type If the value is not a valid string then an error is returned.
Handles are not supported, use a DID instead.
Examples
import possum/at_uri
let string = "at://did:plc:vwzwgnygau7ed7b7wt5ux7y2/app.bsky.feed.post/3k5nobkf2w72g"
let assert Ok(at_uri) = at_uri.parse(string)
See also: Aturi
pub fn rkey(self: AtUri) -> String
Return the rkey part of the Uri
Examples
import possum/at_uri
let string = "at://did:plc:vwzwgnygau7ed7b7wt5ux7y2/app.bsky.feed.post/3k5nobkf2w72g"
let assert Ok(at_uri) = at_uri.parse(string)
assert at_uri.rkey(at_uri) == "3k5nobkf2w72g"
See also: Aturi