pub struct BskyAgent<T = ReqwestClient, S = MemorySessionStore>where
T: XrpcClient + Send + Sync,
S: AtpSessionStore + Send + Sync,
S::Error: Error + Send + Sync + 'static,{ /* private fields */ }default-client only.Expand description
A Bluesky agent.
This agent is a wrapper around the Agent that provides additional functionality for working with Bluesky.
For creating an instance of this agent, use the BskyAtpAgentBuilder.
§Example
use bsky_sdk::BskyAgent;
#[tokio::main]
async fn main() {
let agent = BskyAgent::builder().build().await.expect("failed to build agent");
}Implementations§
Source§impl BskyAgent
impl BskyAgent
Sourcepub fn builder() -> BskyAtpAgentBuilder<ReqwestClient, MemorySessionStore>
pub fn builder() -> BskyAtpAgentBuilder<ReqwestClient, MemorySessionStore>
Create a new BskyAtpAgentBuilder with the default client and session store.
Source§impl<T, S> BskyAgent<T, S>where
T: XrpcClient + Send + Sync,
S: AtpSessionStore + Send + Sync,
S::Error: Error + Send + Sync + 'static,
impl<T, S> BskyAgent<T, S>where
T: XrpcClient + Send + Sync,
S: AtpSessionStore + Send + Sync,
S::Error: Error + Send + Sync + 'static,
Sourcepub async fn get_preferences(
&self,
enable_bsky_labeler: bool,
) -> Result<Preferences>
pub async fn get_preferences( &self, enable_bsky_labeler: bool, ) -> Result<Preferences>
Get the logged-in user’s Preferences.
This implementation does not perform migration of SavedFeedsPref to V2.
§Arguments
enable_bsky_labeler - If true, the Bluesky’s moderation labeler will be included in the moderation preferences.
Sourcepub fn configure_labelers_from_preferences(&self, preferences: &Preferences)
pub fn configure_labelers_from_preferences(&self, preferences: &Preferences)
Configure the labelers header.
Read labelers preferences from the provided Preferences and set the labelers header up to 10 labelers.
See details: https://docs.bsky.app/docs/advanced-guides/moderation#labeler-subscriptions
Sourcepub async fn moderator(&self, preferences: &Preferences) -> Result<Moderator>
pub async fn moderator(&self, preferences: &Preferences) -> Result<Moderator>
Make a Moderator instance with the provided Preferences.
Source§impl<T, S> BskyAgent<T, S>where
T: XrpcClient + Send + Sync,
S: AtpSessionStore + Send + Sync,
S::Error: Error + Send + Sync + 'static,
impl<T, S> BskyAgent<T, S>where
T: XrpcClient + Send + Sync,
S: AtpSessionStore + Send + Sync,
S::Error: Error + Send + Sync + 'static,
Sourcepub async fn create_record(
&self,
subject: impl Into<KnownRecord>,
) -> Result<Output>
pub async fn create_record( &self, subject: impl Into<KnownRecord>, ) -> Result<Output>
Create a record with various types of data.
For example, the Record families defined in KnownRecord are supported.
§Example
use bsky_sdk::{BskyAgent, Result};
#[tokio::main]
async fn main() -> Result<()> {
let agent = BskyAgent::builder().build().await?;
let output = agent.create_record(atrium_api::app::bsky::graph::block::RecordData {
created_at: atrium_api::types::string::Datetime::now(),
subject: "did:fake:handle.test".parse().expect("invalid did"),
}).await?;
Ok(())
}Sourcepub async fn delete_record(&self, at_uri: impl AsRef<str>) -> Result<Output>
pub async fn delete_record(&self, at_uri: impl AsRef<str>) -> Result<Output>
Delete a record with AT URI.
§Errors
Returns an Error::InvalidAtUri if the at_uri is invalid.
§Example
use bsky_sdk::{BskyAgent, Result};
#[tokio::main]
async fn main() -> Result<()> {
let agent = BskyAgent::builder().build().await?;
agent.delete_record("at://did:fake:handle.test/app.bsky.graph.block/3kxmfwtgfxl2w").await?;
Ok(())
}Methods from Deref<Target = AtpAgent<S, T>>§
Sourcepub async fn login(
&self,
identifier: impl AsRef<str>,
password: impl AsRef<str>,
) -> Result<Object<OutputData>, Error<Error>>
pub async fn login( &self, identifier: impl AsRef<str>, password: impl AsRef<str>, ) -> Result<Object<OutputData>, Error<Error>>
Start a new session with this agent.
pub async fn resume_session( &self, session: Object<OutputData>, ) -> Result<(), Error<Error>>
Sourcepub async fn get_session(&self) -> Option<Object<OutputData>>
pub async fn get_session(&self) -> Option<Object<OutputData>>
Get the current session.
Sourcepub async fn get_endpoint(&self) -> String
pub async fn get_endpoint(&self) -> String
Get the current endpoint.
Sourcepub async fn get_labelers_header(&self) -> Option<Vec<String>>
pub async fn get_labelers_header(&self) -> Option<Vec<String>>
Get the current labelers header.
Sourcepub async fn get_proxy_header(&self) -> Option<String>
pub async fn get_proxy_header(&self) -> Option<String>
Get the current proxy header.