Expand description
TAP (Trusted Attestation Protocol) service consumer for AT Protocol.
This crate provides a client for consuming events from a TAP service, which delivers filtered, verified AT Protocol repository events.
§Overview
TAP is a single-tenant service that subscribes to an AT Protocol Relay and outputs filtered, verified events. Key features include:
- Verified Events: MST integrity checks and signature verification
- Automatic Backfill: Historical events delivered with
live: false - Repository Filtering: Track specific DIDs or collections
- Acknowledgment Protocol: At-least-once delivery semantics
§Quick Start
ⓘ
use atproto_tap::{connect_to, TapEvent};
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() {
let mut stream = connect_to("localhost:2480");
while let Some(result) = stream.next().await {
match result {
Ok(event) => match event.as_ref() {
TapEvent::Record { record, .. } => {
println!("{} {} {}", record.action, record.collection, record.did);
}
TapEvent::Identity { identity, .. } => {
println!("Identity: {} = {}", identity.did, identity.handle);
}
},
Err(e) => eprintln!("Error: {}", e),
}
}
}§Using with tokio::select!
The stream integrates naturally with Tokio’s select macro:
ⓘ
use atproto_tap::{connect, TapConfig};
use tokio_stream::StreamExt;
use tokio::signal;
#[tokio::main]
async fn main() {
let config = TapConfig::builder()
.hostname("localhost:2480")
.admin_password("secret")
.build();
let mut stream = connect(config);
loop {
tokio::select! {
Some(result) = stream.next() => {
// Process event
}
_ = signal::ctrl_c() => {
break;
}
}
}
}§Management API
Use TapClient to manage tracked repositories:
ⓘ
use atproto_tap::TapClient;
let client = TapClient::new("localhost:2480", Some("password".to_string()));
// Add repositories to track
client.add_repos(&["did:plc:xyz123"]).await?;
// Check service health
if client.health().await? {
println!("TAP service is healthy");
}§Memory Efficiency
This crate is optimized for high-throughput event processing:
- Arc-wrapped events: Events are shared via
Arcfor zero-cost sharing - CompactString: Small strings use inline storage (no heap allocation)
Box<str>: Immutable strings without capacity overhead- RawValue: Record payloads are lazily parsed on demand
- Pre-allocated buffers: Ack messages avoid per-message allocations
Structs§
- Document
- Complete DID document containing identity information. Contains services, verification methods, and aliases for a DID.
- Identity
Event - An identity change event from TAP.
- Record
Event - A repository record event from TAP.
- Repo
Info - Repository tracking information.
- Service
- AT Protocol service configuration from a DID document. Represents services like Personal Data Servers (PDS).
- TapClient
- HTTP client for TAP management API.
- TapConfig
- Configuration for a TAP stream connection.
- TapConfig
Builder - Builder for
TapConfig. - TapStream
- An async stream of TAP events with automatic reconnection.
Enums§
- Identity
Status - Account status in an identity event.
- Record
Action - The action performed on a record.
- Repo
State - Repository sync state.
- TapError
- Errors that can occur during TAP operations.
- TapEvent
- A TAP event received from the stream.
- Verification
Method - Cryptographic verification method from a DID document. Used to verify signatures and authenticate identity operations.
Functions§
- connect
- Create a new TAP stream with the given configuration.
- connect_
to - Create a new TAP stream connected to the given hostname.
- extract_
event_ id - Extract only the event ID from a JSON string without fully parsing it.
Type Aliases§
- Repo
Status Deprecated - Deprecated alias for RepoState.