pub struct PdsClient { /* private fields */ }Expand description
A lightweight client for one user’s PDS repo.
Holds the user’s DID (the repo to read/write), the PDS base URL (resolved
from the DID doc), the shared reqwest::Client, and the Auth token.
All the com.atproto.repo.* methods below act on self.did’s repo.
Cheap to clone (Arc internals); one is held per logged-in session.
Implementations§
Source§impl PdsClient
impl PdsClient
Sourcepub fn new(
http: Client,
pds_base: impl Into<String>,
did: impl Into<String>,
auth: Auth,
) -> Self
pub fn new( http: Client, pds_base: impl Into<String>, did: impl Into<String>, auth: Auth, ) -> Self
Construct a client against an already-resolved PDS base + DID + auth.
Sourcepub async fn login(
http: Client,
handle: &str,
app_password: &str,
resolver_base: Option<&str>,
plc_directory: Option<&str>,
) -> Result<Self>
pub async fn login( http: Client, handle: &str, app_password: &str, resolver_base: Option<&str>, plc_directory: Option<&str>, ) -> Result<Self>
Resolve handle → DID → PDS, obtain an app-password session, and build a
ready-to-use client. A convenience constructor for the direct-PDS path
that exercises the whole stack end-to-end.
resolver_base / plc_directory default to DEFAULT_RESOLVER_HOST /
DEFAULT_PLC_DIRECTORY when passed None.
Sourcepub async fn list_records(
&self,
collection: &str,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<ListRecordsResponse>
pub async fn list_records( &self, collection: &str, limit: Option<u32>, cursor: Option<&str>, ) -> Result<ListRecordsResponse>
com.atproto.repo.listRecords — one page of a collection’s records.
cursor continues a previous page; limit caps the page (atproto’s max
is 100). Use list_all_records to page fully.
Sourcepub async fn list_all_records(
&self,
collection: &str,
) -> Result<Vec<RecordEntry>>
pub async fn list_all_records( &self, collection: &str, ) -> Result<Vec<RecordEntry>>
Page through all records in a collection, following the cursor until
exhausted. Convenience over list_records for the
login-time “load the whole follow-list” read.
Sourcepub async fn create_record<T: Serialize>(
&self,
collection: &str,
record: &T,
) -> Result<WriteResult>
pub async fn create_record<T: Serialize>( &self, collection: &str, record: &T, ) -> Result<WriteResult>
com.atproto.repo.createRecord — create a new record (server assigns the
rkey, key: tid). Returns the written record’s strong ref.
Sourcepub async fn put_record<T: Serialize>(
&self,
collection: &str,
rkey: &str,
record: &T,
) -> Result<WriteResult>
pub async fn put_record<T: Serialize>( &self, collection: &str, rkey: &str, record: &T, ) -> Result<WriteResult>
com.atproto.repo.putRecord — upsert a record at a known rkey
(key: any). This is the readState upsert primitive: a feed-derived
rkey makes the write idempotent (one record per feed).
Sourcepub async fn delete_record(&self, collection: &str, rkey: &str) -> Result<()>
pub async fn delete_record(&self, collection: &str, rkey: &str) -> Result<()>
com.atproto.repo.deleteRecord — delete a record by collection + rkey
(e.g. unsubscribe → delete the subscription record).
Sourcepub async fn apply_writes(&self, writes: &[WriteOp]) -> Result<()>
pub async fn apply_writes(&self, writes: &[WriteOp]) -> Result<()>
com.atproto.repo.applyWrites — a batch of create/update/delete
operations in one atomic-per-repo round-trip.
This is the read-state flusher’s workhorse: dozens of dirty per-feed
ReadState cursors coalesce into one call rather than one putRecord
each. See flush_read_states.
Sourcepub async fn list_subscriptions(&self) -> Result<Vec<(String, Subscription)>>
pub async fn list_subscriptions(&self) -> Result<Vec<(String, Subscription)>>
List every Subscription record in the user’s repo (paged fully). The
login-time “what does this user follow?” read.
Sourcepub async fn create_subscription(
&self,
sub: &Subscription,
) -> Result<WriteResult>
pub async fn create_subscription( &self, sub: &Subscription, ) -> Result<WriteResult>
Create a Subscription record (subscribe to a feed).
Sourcepub async fn list_folders(&self) -> Result<Vec<(String, Folder)>>
pub async fn list_folders(&self) -> Result<Vec<(String, Folder)>>
List every Folder record in the user’s repo.
Sourcepub async fn create_folder(&self, folder: &Folder) -> Result<WriteResult>
pub async fn create_folder(&self, folder: &Folder) -> Result<WriteResult>
Create a Folder record.
Sourcepub async fn list_saved(&self) -> Result<Vec<(String, Saved)>>
pub async fn list_saved(&self) -> Result<Vec<(String, Saved)>>
List every Saved (starred) record in the user’s repo.
Sourcepub async fn create_saved(&self, saved: &Saved) -> Result<WriteResult>
pub async fn create_saved(&self, saved: &Saved) -> Result<WriteResult>
Create a Saved record (star an article).
Sourcepub async fn list_read_states(&self) -> Result<Vec<(String, ReadState)>>
pub async fn list_read_states(&self) -> Result<Vec<(String, ReadState)>>
List every ReadState cursor in the user’s repo (the read side a
login-time read-state merge would consume).
Sourcepub async fn put_read_state(
&self,
rkey: &str,
state: &ReadState,
) -> Result<WriteResult>
pub async fn put_read_state( &self, rkey: &str, state: &ReadState, ) -> Result<WriteResult>
Upsert a single ReadState cursor at its feed-derived rkey. For a
batch of dirty cursors prefer flush_read_states.
Sourcepub async fn flush_read_states(
&self,
cursors: &[(String, ReadState, bool)],
) -> Result<()>
pub async fn flush_read_states( &self, cursors: &[(String, ReadState, bool)], ) -> Result<()>
Batch-flush many dirty ReadState cursors in one applyWrites call —
the debounced read-state flusher’s coalesced write.
Each (rkey, state, pds_created) becomes a create op at the feed-derived
rkey when the record does not yet exist, and an update when it does — so a
feed’s FIRST flush succeeds (an #update on a missing record errors, and
applyWrites is atomic per-repo). Both kinds ride the same batch.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PdsClient
impl !UnwindSafe for PdsClient
impl Freeze for PdsClient
impl Send for PdsClient
impl Sync for PdsClient
impl Unpin for PdsClient
impl UnsafeUnpin for PdsClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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