Skip to main content

Farcaster

Struct Farcaster 

Source
pub struct Farcaster {
    pub account: Account,
    pub registry: Registry,
}
Expand description

The Farcaster type that holds the keys to the castle - so to speak :)

Fields§

§account: Account§registry: Registry

Implementations§

Source§

impl Farcaster

Source

pub async fn generate_bearer( wallet: &Wallet<SigningKey>, duration_secs: Option<i64>, ) -> Result<Bearer, Box<dyn Error>>

§Best not to use this function directly

Instead, use the Account struct methods, such as from_mnemonic, and from_private_key, as that generates these automatically.

However, if you’d really like to use these, go ahead.

Source§

impl Farcaster

Source

pub async fn get_session_token( bearer: &Bearer, ) -> Result<SecretToken, Box<dyn Error>>

§Best not to use this function directly

Instead, use the Account struct methods, such as from_mnemonic, and from_private_key, as that generates these automatically.

However, if you’d really like to use these, go ahead.

Source§

impl Farcaster

Source

pub async fn revoke_session_token( token: &SecretToken, ) -> Result<RevokedKeyRoot, Box<dyn Error>>

Best not to use this function on its own, as the Account struct has a method that does this in a clean way i.e. farcaster.account.revoke_auth_token().await?;

Source§

impl Farcaster

Source

pub async fn get_collection_owners( &self, collection_id: &str, limit: Option<i64>, cursor: Option<String>, ) -> Result<CollectionOwnersRoot, Box<dyn Error>>

Source§

impl Farcaster

Source

pub async fn get_collections_by_fid( &self, fid: i64, limit: Option<i64>, cursor: Option<String>, ) -> Result<UserCollectionsRoot, Box<dyn Error>>

Get all collections an FID owns

use farcaster_rs::{Account, Farcaster};

let account: Account = Account::from_mnemonic("mnemonic phrase", None).await?;
let farcaster: Farcaster = Farcaster::new("eth provider", account).await?;

// Returns all Farcaster collection owners of the ID specified
let collections = farcaster.get_collections_by_fid(5, None, None).await?;
Source

pub async fn get_collections_by_username( &self, username: &str, limit: Option<i64>, cursor: Option<String>, ) -> Result<UserCollectionsRoot, Box<dyn Error>>

Get all collections a username owns

use farcaster_rs::{Account, Farcaster};

let account: Account = Account::from_mnemonic("mnemonic phrase", None).await?;
let farcaster: Farcaster = Farcaster::new("eth provider", account).await?;

// Returns all Farcaster collection owners of the ID specified
let collections = farcaster.get_collections_by_username("ace", None, None).await?;
Source

pub async fn get_collections_by_address( &self, address: &str, limit: Option<i64>, cursor: Option<String>, ) -> Result<UserCollectionsRoot, Box<dyn Error>>

Get all collections an address owns

use farcaster_rs::{Account, Farcaster};

let account: Account = Account::from_mnemonic("mnemonic phrase", None).await?;
let farcaster: Farcaster = Farcaster::new("eth provider", account).await?;

// Returns all Farcaster collection owners of the ID specified
let collections = farcaster.get_collections_by_address("0x000.....", None, None).await?;
Source§

impl Farcaster

Source

pub async fn delete_cast_by_cast_hash( &self, cast_hash: &str, ) -> Result<DeletedCastRoot, Box<dyn Error>>

Delete a cast via its hash

§Params

cast_hash: &str

§Example
let casts = farcaster.delete_cast_by_cast_hash("cast_hash").await?;
Source§

impl Farcaster

Source

pub async fn get_casts_by_fid( &self, fid: i64, limit: Option<i32>, cursor: Option<&str>, ) -> Result<CastRoot, Box<dyn Error>>

Get a users casts by their FID

§Params

fid: i64 limit: Option cursor: Option<&str>

§Example
let casts = farcaster.get_casts_by_fid(0, None, None).await?;
Source

pub async fn get_casts_by_username( &self, username: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<CastRoot, Box<dyn Error>>

Get a users casts by their Username

§Params

username: &str limit: Option cursor: Option<&str>

§Example
let casts = farcaster.get_casts_by_username("cassie", None, None).await?;
Source

pub async fn get_casts_by_address( &self, address: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<CastRoot, Box<dyn Error>>

Get a users casts by their Address

§Params

address: &str limit: Option cursor: Option<&str>

§Example
let casts = farcaster.get_casts_by_address("0x0000....", None, None).await?;
Source§

impl Farcaster

Source

pub async fn publish_cast( &self, content: &str, reply_to_hash: Option<&str>, reply_to_fid: Option<i64>, ) -> Result<PublishedCast, Box<dyn Error>>

Publish a cast to the protocol

use farcaster_rs::{Account, Farcaster};

let account: Account = Account::from_mnemonic("mnemonic phrase", None).await?;
let farcaster: Farcaster = Farcaster::new("eth provider", account).await?;

// Publish a cast.
// 1st Param: Content
// 2nd & 3rd Param: Parent Cast Hash & Parent User FID
    // Used for replying to a cast
let cast = farcaster.publish_cast("cast content", Some("optional parent hash to reply to"), Some(0)).await?;
Source§

impl Farcaster

Source

pub async fn follow_user_by_fid( &self, fid: i64, ) -> Result<FollowUserRoot, Box<dyn Error>>

Get a users followers via their FID

§Params

fid: i64

§Example
let follow = farcaster.follow_user_by_fid(0).await?;
Source

pub async fn follow_user_by_username( &self, username: &str, ) -> Result<FollowUserRoot, Box<dyn Error>>

Get a users followers via their username

§Params

username: &str

§Example
let follow = farcaster.follow_user_by_username("abc").await?;
Source

pub async fn follow_user_by_address( &self, address: &str, ) -> Result<FollowUserRoot, Box<dyn Error>>

Get a users followers via their address

§Params

address: &str

§Example
let follow = farcaster.follow_user_by_address("0x000....").await?;
Source§

impl Farcaster

Source

pub async fn get_following_by_fid( &self, fid: i64, limit: Option<i64>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source

pub async fn get_following_by_username( &self, username: &str, limit: Option<i64>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source

pub async fn get_following_by_address( &self, address: &str, limit: Option<i64>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source§

impl Farcaster

Source

pub async fn get_followers_by_fid( &self, fid: i64, limit: Option<i32>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source

pub async fn get_followers_by_username( &self, username: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source

pub async fn get_followers_by_address( &self, address: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<FollowersRoot, Box<dyn Error>>

Source§

impl Farcaster

Source

pub async fn unfollow_user_by_fid( &self, fid: i64, ) -> Result<UnfollowUserRoot, Box<dyn Error>>

Source

pub async fn unfollow_user_by_username( &self, username: &str, ) -> Result<UnfollowUserRoot, Box<dyn Error>>

Source

pub async fn unfollow_user_by_address( &self, address: &str, ) -> Result<UnfollowUserRoot, Box<dyn Error>>

Source§

impl Farcaster

Source

pub async fn get_api_health() -> Result<String, Box<dyn Error>>

Source§

impl Farcaster

Source

pub async fn get_notifications( &self, limit: Option<i64>, cursor: Option<&str>, ) -> Result<NotificationsRoot, Box<dyn Error>>

Fetch your notifications

§Params

limit: Option - How many casts to get (max 100) cursor: Option<&str) - For pagination

§Example
let notifications = farcaster.get_notifications(None, None).await?;
Source§

impl Farcaster

Source

pub async fn delete_like_by_cast_hash( &self, cast_hash: &str, ) -> Result<DeletedLikeRoot, Box<dyn Error>>

Unlike a cast

§Params

cast_hash: &str

§Example
farcaster.delete_like_by_cast_hash("cast hash").await?;
Source§

impl Farcaster

Source

pub async fn delete_recast_by_cast_hash( &self, cast_hash: &str, ) -> Result<DeletedRecastRoot, Box<dyn Error>>

Delete a recast by the parent cast’s hash

§Params

cast_hash: &str

§Example
let delete = farcaster.delete_recast_by_cast_hash("cast hash").await?;
Source§

impl Farcaster

Source

pub async fn get_likes_by_cast_hash( &self, cast_hash: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ManyLikedCastsRoot, Box<dyn Error>>

Get likes by the cast hash

§Params

cast_hash: &str limit: Option - Optional # of likes to get (max 100) cursor: Option<&str> - Optional cursor for pagination

§Example
farcaster.get_likes_by_cast_hash("cast hash", None, None).await?;
Source§

impl Farcaster

Source

pub async fn get_recasters_by_cast_hash( &self, cast_hash: &str, limit: Option<i32>, cursor: Option<&str>, ) -> Result<RecastersRoot, Box<dyn Error>>

Get recasters by cast hash

§Params

cast_hash: &str, limit: Option - Optional # of recasters to get (max 100) cursor: Option<&str) - Optional cursor for pagination

§Example
let recasters = farcaster.get_recasters.by_cast_hash("cast hash", None, None).await?;
Source§

impl Farcaster

Source

pub async fn like_cast_by_cast_hash( &self, cast_hash: &str, ) -> Result<LikedCastRoot, Box<dyn Error>>

Like cast by the cast hash

§Params

cast_hash: &str

§Example
farcaster.like_cast_by_cast_hash("cast hash").await?;
Source§

impl Farcaster

Source

pub async fn recast_by_cast_hash( &self, cast_hash: &str, ) -> Result<RecastedRoot, Box<dyn Error>>

Recast a cast by its hash

§Params

cast_hash: &str

§Example
let recast = farcaster.recast_by_cast_hash("cast hash").await?;
Source§

impl Farcaster

Source

pub async fn get_custody_address_by_fid( &self, fid: i64, ) -> Result<CustodyAddressRoot, Box<dyn Error>>

Get a custody address by FID

Source

pub async fn get_custody_address_by_username( &self, username: &str, ) -> Result<CustodyAddressRoot, Box<dyn Error>>

Get a custody address by FID

Source

pub async fn get_custody_address_by_address( &self, address: &str, ) -> Result<CustodyAddressRoot, Box<dyn Error>>

Get a custody address by FID

Source§

impl Farcaster

Source

pub async fn get_user_by_fid( &self, fid: u64, ) -> Result<UserInfo, Box<dyn Error>>

Get information about a user via their Farcaster ID (more commonly shortened to FID throughout this codebase

Source

pub async fn get_user_by_username( &self, username: &str, ) -> Result<UserInfo, Box<dyn Error>>

Get information about a user via their Farcaster Username

Source

pub async fn get_user_by_address( &self, address: &str, ) -> Result<UserInfo, Box<dyn Error>>

Get information about a user via their Ethereum address

Source§

impl Farcaster

Source

pub async fn get_me(&self) -> Result<UserRoot, Box<dyn Error>>

Get information about the authenticated user

Source§

impl Farcaster

Source

pub async fn get_verifications_by_fid( &self, fid: i64, ) -> Result<VerificationsRoot, Box<dyn Error>>

Get verifications of a user by their FID

Source

pub async fn get_verifications_by_username( &self, username: &str, ) -> Result<VerificationsRoot, Box<dyn Error>>

Get verifications of a user by their username

Source

pub async fn get_verifications_by_address( &self, address: &str, ) -> Result<VerificationsRoot, Box<dyn Error>>

Get verifications of a user by their address

Source§

impl Farcaster

Source

pub async fn new( ethereum_provider: &str, account: Account, ) -> Result<Self, Box<dyn Error>>

Trait Implementations§

Source§

impl Debug for Farcaster

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> JsonSchemaMaybe for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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