Skip to main content

PdsClient

Struct PdsClient 

Source
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

Source

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.

Source

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.

Source

pub fn did(&self) -> &str

The repo DID this client targets.

Source

pub fn pds_base(&self) -> &str

The PDS base URL this client talks to.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

pub async fn create_subscription( &self, sub: &Subscription, ) -> Result<WriteResult>

Create a Subscription record (subscribe to a feed).

Source

pub async fn list_folders(&self) -> Result<Vec<(String, Folder)>>

List every Folder record in the user’s repo.

Source

pub async fn create_folder(&self, folder: &Folder) -> Result<WriteResult>

Create a Folder record.

Source

pub async fn list_saved(&self) -> Result<Vec<(String, Saved)>>

List every Saved (starred) record in the user’s repo.

Source

pub async fn create_saved(&self, saved: &Saved) -> Result<WriteResult>

Create a Saved record (star an article).

Source

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).

Source

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.

Source

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§

Source§

impl Clone for PdsClient

Source§

fn clone(&self) -> PdsClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more