pub struct Repo { /* private fields */ }Expand description
High-level client for AT Protocol record repository operations.
Wraps com.atproto.repo.* XRPC calls with typed helpers.
Automatically uses the provided PDS endpoint for all operations.
§Example
let repo = Repo::new(http, "https://pds.example.com", "token", "did:plc:abc123");
let record = serde_json::json!({ "text": "Hello world" });
let strong_ref = repo.create_record("app.bsky.feed.post", &record).await?;Implementations§
Source§impl Repo
impl Repo
Sourcepub fn new(
http: &Client,
pds_endpoint: &str,
access_token: &str,
did: &str,
) -> Self
pub fn new( http: &Client, pds_endpoint: &str, access_token: &str, did: &str, ) -> Self
Create a new Repo client with explicit parameters.
Sourcepub fn from_session(
http: &Client,
session: &AtrgSession,
pds_endpoint: &str,
) -> Self
pub fn from_session( http: &Client, session: &AtrgSession, pds_endpoint: &str, ) -> Self
Create a Repo client from an authenticated session.
Sourcepub fn pds_endpoint(&self) -> &str
pub fn pds_endpoint(&self) -> &str
Return a reference to the PDS endpoint.
Sourcepub async fn get_record<T: DeserializeOwned>(
&self,
uri: &AtUri,
) -> Result<Record<T>, RepoError>
pub async fn get_record<T: DeserializeOwned>( &self, uri: &AtUri, ) -> Result<Record<T>, RepoError>
Get a record by AT-URI.
Calls com.atproto.repo.getRecord.
Sourcepub async fn list_records<T: DeserializeOwned>(
&self,
collection: &str,
cursor: Option<&str>,
limit: Option<usize>,
) -> Result<Page<Record<T>>, RepoError>
pub async fn list_records<T: DeserializeOwned>( &self, collection: &str, cursor: Option<&str>, limit: Option<usize>, ) -> Result<Page<Record<T>>, RepoError>
List records in a collection.
Calls com.atproto.repo.listRecords.
Sourcepub async fn create_record(
&self,
collection: &str,
record: &Value,
) -> Result<StrongRef, RepoError>
pub async fn create_record( &self, collection: &str, record: &Value, ) -> Result<StrongRef, RepoError>
Create a new record with an auto-generated TID as the rkey.
Calls com.atproto.repo.createRecord.
Sourcepub async fn put_record(
&self,
collection: &str,
rkey: &str,
record: &Value,
) -> Result<StrongRef, RepoError>
pub async fn put_record( &self, collection: &str, rkey: &str, record: &Value, ) -> Result<StrongRef, RepoError>
Create or update a record at a specific rkey.
Calls com.atproto.repo.putRecord.
Sourcepub async fn delete_record(&self, uri: &AtUri) -> Result<(), RepoError>
pub async fn delete_record(&self, uri: &AtUri) -> Result<(), RepoError>
Delete a record.
Calls com.atproto.repo.deleteRecord.
Sourcepub async fn upload_blob(
&self,
data: Vec<u8>,
mime_type: &str,
) -> Result<BlobRef, RepoError>
pub async fn upload_blob( &self, data: Vec<u8>, mime_type: &str, ) -> Result<BlobRef, RepoError>
Upload a blob to the authenticated user’s PDS.
Delegates to blob::upload_blob.
Auto Trait Implementations§
impl Freeze for Repo
impl !RefUnwindSafe for Repo
impl Send for Repo
impl Sync for Repo
impl Unpin for Repo
impl UnsafeUnpin for Repo
impl !UnwindSafe for Repo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more