pub struct PdsClient { /* private fields */ }Expand description
Thin wrapper over reqwest::Client pinned to one PDS base URL.
Construct once per cairn process; one instance serves the
whole command’s lifetime.
Implementations§
Source§impl PdsClient
impl PdsClient
Sourcepub fn new(base_url: &str) -> Result<Self, PdsError>
pub fn new(base_url: &str) -> Result<Self, PdsError>
Construct a client for the given PDS base URL
(e.g., https://bsky.social). Trailing slashes are
normalized away.
Sourcepub fn with_http_client(
base_url: &str,
client: Client,
) -> Result<Self, PdsError>
pub fn with_http_client( base_url: &str, client: Client, ) -> Result<Self, PdsError>
Inject a preconfigured reqwest::Client. Used by tests that
need to disable TLS verification (mock PDS at plain HTTP)
without plumbing feature flags through the public API.
Sourcepub async fn create_session(
&self,
identifier: &str,
password: &str,
) -> Result<CreateSessionResponse, PdsError>
pub async fn create_session( &self, identifier: &str, password: &str, ) -> Result<CreateSessionResponse, PdsError>
Exchange handle+app-password for a PDS session.
Sourcepub async fn refresh_session(
&self,
refresh_jwt: &str,
) -> Result<RefreshSessionResponse, PdsError>
pub async fn refresh_session( &self, refresh_jwt: &str, ) -> Result<RefreshSessionResponse, PdsError>
Rotate access+refresh tokens using a valid refresh token.
Sourcepub async fn delete_session(&self, refresh_jwt: &str) -> Result<(), PdsError>
pub async fn delete_session(&self, refresh_jwt: &str) -> Result<(), PdsError>
Invalidate the refresh token server-side. Success on 2xx; callers typically treat any error here as non-fatal (local cleanup proceeds regardless, per Q3 in the criteria confirmation).
Sourcepub async fn put_record(
&self,
access_jwt: &str,
repo: &str,
collection: &str,
rkey: &str,
record: &Value,
swap_record: Option<&str>,
) -> Result<PutRecordResponse, PdsError>
pub async fn put_record( &self, access_jwt: &str, repo: &str, collection: &str, rkey: &str, record: &Value, swap_record: Option<&str>, ) -> Result<PutRecordResponse, PdsError>
Put a record at (repo, collection, rkey). When swap_record
is Some, the request is conditional on the PDS’s current
record having that CID — §F1 swap-race detection rides on
this. Used by cairn publish-service-record to emit the
app.bsky.labeler.service record at rkey=self.
Distinct context discriminators for auth failures:
"putRecord" generally, mapped upward to a specific
swap-race error via PdsError::SwapRace when the PDS’s
response body carries the InvalidSwap shape.
Sourcepub async fn get_record(
&self,
repo: &str,
collection: &str,
rkey: &str,
) -> Result<Option<GetRecordResponse>, PdsError>
pub async fn get_record( &self, repo: &str, collection: &str, rkey: &str, ) -> Result<Option<GetRecordResponse>, PdsError>
Fetch a record via com.atproto.repo.getRecord. Unauthenticated
public endpoint — used by cairn serve’s startup verify check
to read the published app.bsky.labeler.service record
without requiring an operator session on the serve host.
Returns:
Ok(Some(_))— record exists, body deserializedOk(None)— record does not exist (HTTP 404 OR XRPCRecordNotFounderror body). Distinct from a transport failure: callers that need to differentiate “absent” from “unreachable” branch on this distinction.Err(PdsError::Network { .. })— transport-level failure (DNS, TLS, timeout, refused).Err(PdsError::UnexpectedStatus { .. })— any other non-2xx (auth-required-on-private-PDS, server error, rate-limit response).
Sourcepub async fn delete_record(
&self,
access_jwt: &str,
repo: &str,
collection: &str,
rkey: &str,
swap_record: Option<&str>,
) -> Result<(), PdsError>
pub async fn delete_record( &self, access_jwt: &str, repo: &str, collection: &str, rkey: &str, swap_record: Option<&str>, ) -> Result<(), PdsError>
Delete a record at (repo, collection, rkey) via
com.atproto.repo.deleteRecord. When swap_record is Some,
the request is conditional on the PDS’s current record having
that CID — same swap-race semantics as put_record. Used by
cairn unpublish-service-record (#34) to remove the published
app.bsky.labeler.service record.
Idempotency on the wire: real PDSes return 200 even when
the target record is already absent, matching the ATProto
spec. Callers that want a “did we actually delete something”
distinction should consult their own state (e.g.,
labeler_config) before calling — that’s the path the
unpublish flow takes.
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);