atproto_lexicon/lib.rs
1//! AT Protocol lexicon resolution and validation library.
2//!
3//! This library provides functionality for resolving and validating AT Protocol lexicons,
4//! which define the schema and structure of AT Protocol data.
5//!
6//! ## Overview
7//!
8//! Lexicons in AT Protocol serve as schema definitions that describe the structure
9//! and types of data that can be stored and transmitted. This library implements
10//! the full lexicon resolution chain as specified by the AT Protocol:
11//!
12//! 1. Convert NSID to DNS name with `_lexicon` prefix
13//! 2. Perform DNS TXT lookup to get the authoritative DID
14//! 3. Resolve the DID to get the DID document
15//! 4. Extract PDS endpoint from the DID document
16//! 5. Make XRPC call to fetch the lexicon schema
17//!
18//! ## Modules
19//!
20//! - [`errors`]: Structured error types for all lexicon operations
21//! - [`resolve`]: Core lexicon resolution implementation
22//! - [`resolve_recursive`]: Recursive resolution with dependency tracking
23//! - [`transmogrify`]: Record transformation between lexicon schemas
24//! - [`compatibility`]: Schema compatibility analysis (requires `panproto` feature)
25//! - [`validation`]: NSID validation, parsing, and helper functions
26//!
27//! ## Example Usage
28//!
29//! ```no_run
30//! # use anyhow::Result;
31//! # #[tokio::main]
32//! # async fn main() -> Result<()> {
33//! use atproto_lexicon::resolve::{DefaultLexiconResolver, LexiconResolver};
34//! use atproto_identity::resolve::HickoryDnsResolver;
35//!
36//! let http_client = reqwest::Client::new();
37//! let dns_resolver = HickoryDnsResolver::create_resolver(&[]);
38//! let resolver = DefaultLexiconResolver::new(http_client, dns_resolver);
39//!
40//! // Resolve a lexicon
41//! let lexicon = resolver.resolve("app.bsky.feed.post").await?;
42//! # Ok(())
43//! # }
44//! ```
45
46#![forbid(unsafe_code)]
47#![warn(missing_docs)]
48
49pub mod errors;
50pub mod resolve;
51pub mod resolve_recursive;
52pub mod transmogrify;
53pub mod validation;
54
55#[cfg(feature = "panproto")]
56pub mod compatibility;