Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The networked runtime for one Rostra identity.

Construct clients with Client::builder. The returned Arc<Self> owns all request handling and background work, which stops when the final strong reference is dropped.

Implementations§

Source§

impl Client

Source

pub fn builder(id: RostraId) -> ClientBuilder

Construct a client for id.

Without db, the client uses temporary in-memory storage and does not start full-client background synchronization tasks. Supplying a durable db enables the supported full-client mode. The request handler starts by default, background tasks start by default for full clients, and client-created networking is relay-only unless public_mode is explicitly enabled. A supplied iroh_endpoint retains its existing transport and privacy policy instead.

Source§

impl Client

Source

pub fn rostra_id(&self) -> RostraId

Return the identity served by this client.

Source

pub async fn unlock_active( &self, id_secret: RostraIdSecretKey, ) -> ActivateResult<()>

Unlock signing operations and start signing-dependent background tasks.

The secret must belong to Client::rostra_id. Calling this method more than once is harmless after the first successful activation.

Source

pub async fn publish_node_announcement( &self, id_secret: RostraIdSecretKey, ) -> PostResult<()>

Source

pub fn make_pkarr_client() -> InitResult<Arc<Client>>

Create a shared pkarr client.

The pkarr client is identity-agnostic, so a single instance can be reused across all Rostra clients via the pkarr_client parameter on Client::builder.

Source

pub fn self_head_subscribe(&self) -> CurrentState<Option<ShortEventId>>

Subscribe to owned snapshots of the minimum current self-head representative.

The retained value is a deterministic default and does not imply that the complete current head set is a singleton.

Source

pub fn new_content_subscribe(&self) -> Receiver<VerifiedEventContent>

Subscribe to newly accepted verified event content.

Source

pub fn new_posts_subscribe( &self, ) -> Receiver<(VerifiedEventContent, SocialPost)>

Subscribe to newly accepted social posts.

Source

pub fn new_shoutbox_subscribe( &self, ) -> Receiver<(VerifiedEventContent, Shoutbox)>

Subscribe to newly accepted shoutbox messages.

Source

pub fn new_heads_subscribe(&self) -> Receiver<(RostraId, ShortEventId)>

Subscribe to lossy incremental exact new-head signals.

Each signal names the accepted event that became a head. Consumers that lag must recover from the database’s complete durable head set.

Source

pub fn ids_with_missing_events_subscribe( &self, capacity: usize, ) -> Receiver<RostraId>

Subscribe to deduplicated identities whose event history is incomplete.

Source

pub fn db(&self) -> &Arc<Database> ⓘ

Access the identity’s database and materialized views.

Source

pub async fn events_head(&self) -> Option<ShortEventId>

Return the deterministic representative of the current self-head set.

Source

pub fn handle(&self) -> ClientHandle

Create a weak handle that does not keep this client running.

Source

pub fn p2p_state(&self) -> &P2PState

Access in-memory P2P connection state for debugging.

Source

pub fn local_iroh_id(&self) -> IrohNodeId

Returns our local Iroh node ID.

Source

pub async fn resolve_id_data( &self, id: RostraId, ) -> Result<IdResolvedData, IdResolveError>

Resolve an identity’s published transport and graph-head information.

Source

pub async fn resolve_id_ticket( &self, id: RostraId, ) -> Result<CompactTicket, IdResolveError>

Resolve an identity’s compact transport ticket.

Source

pub async fn connect_uncached(&self, id: RostraId) -> ConnectResult<Connection>

Open a fresh typed RPC connection to an identity.

Source

pub async fn connect_by_pkarr_resolution( &self, id: RostraId, ) -> ConnectResult<Connection>

Resolve an identity through Pkarr and open a fresh typed RPC connection.

Source

pub async fn connect_ticket( &self, ticket: CompactTicket, ) -> ConnectResult<Connection>

Open a typed RPC connection using a previously resolved compact ticket.

Source

pub async fn fetch_event_content( &self, author_id: RostraId, event_id: ShortEventId, followers_cache: &mut BTreeMap<RostraId, Vec<RostraId>>, ) -> Result<bool, DbError>

Fetch an event and its content from its author or known followers.

The caller-owned cache avoids repeating follower lookups while fetching a batch of related events. The method returns true when content was found and stored.

Source

pub async fn sync_event_from_peers( &self, author_id: RostraId, head: ShortEventId, peers: &[RostraId], ) -> Result<bool, DbError>

Synchronize an event and its ancestors from a set of candidate peers.

This explicit synchronization boundary is useful when an integration learns a remote head outside the client’s normal background discovery. It returns true when any new envelope or content was stored.

Source

pub async fn store_event_with_content( &self, event_id: impl Into<ShortEventId>, content: &VerifiedEventContent, ) -> StoreEventResult<()>

Store verified event content, retaining author and event context on error.

Source

pub async fn read_id_secret( path: &Path, ) -> IdSecretReadResult<RostraIdSecretKey>

Read and parse a secret identity key from a UTF-8 file.

Source

pub async fn check_published_id_state( &self, ) -> Result<IdResolvedData, IdResolveError>

Source

pub async fn post_shoutbox( &self, id_secret: RostraIdSecretKey, body: String, ) -> PostResult<VerifiedEvent>

Source

pub async fn social_post( &self, id_secret: RostraIdSecretKey, body: String, reply_to: Option<ExternalEventId>, persona_tags: BTreeSet<PersonaTag>, ) -> PostResult<VerifiedEvent>

Source

pub async fn social_news_post( &self, id_secret: RostraIdSecretKey, body: String, url: Option<Url>, title: Option<String>, ) -> PostResult<VerifiedEvent>

Source

pub async fn set_social_vote( &self, id_secret: RostraIdSecretKey, post_id: ExternalEventId, upvote: Option<bool>, ) -> PostResult<VerifiedEvent>

Source

pub async fn get_self_social_vote( &self, post_id: ExternalEventId, ) -> Option<Option<bool>>

Source

pub async fn post_social_profile_update( &self, id_secret: RostraIdSecretKey, display_name: String, bio: String, avatar: Option<(String, Vec<u8>)>, ) -> PostResult<VerifiedEvent>

Source

pub async fn follow( &self, id_secret: RostraIdSecretKey, followee_id: RostraId, tags_selector: PersonasTagsSelector, ) -> PostResult<VerifiedEvent>

Source

pub async fn unfollow( &self, id_secret: RostraIdSecretKey, followee: RostraId, ) -> PostResult<VerifiedEvent>

Source

pub async fn publish_omni_tbd( &self, id_secret: RostraIdSecretKey, body: String, ) -> PostResult<()>

Source

pub fn self_followees_subscribe( &self, ) -> CurrentState<Arc<HashMap<RostraId, IdsFolloweesRecord>>>

Subscribe to owned snapshots of the retained self-followee projection.

Source

pub fn self_followers_subscribe( &self, ) -> CurrentState<Arc<HashMap<RostraId, IdsFollowersRecord>>>

Subscribe to owned snapshots of the retained self-follower projection.

Source

pub fn self_wot_subscribe(&self) -> CurrentState<Arc<WotData>>

Subscribe to owned snapshots of the retained Web-of-Trust projection.

Source

pub fn publish_event<'f1, C>( &'f1 self, id_secret: RostraIdSecretKey, content: C, ) -> ClientPublishEventBuilder<'f1, C>

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

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<F, I> CastInto<I> for F
where I: CastFrom<F>,

Source§

fn cast_into(self) -> I

Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T> ⓘ
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T> ⓘ

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T> ⓘ

Applies the Compat adapter by mutable reference. Read more
Source§

impl<F, T> ExpectFrom<F> for T
where T: TryFrom<F>, <T as TryFrom<F>>::Error: Debug,

Source§

fn expect_from(other: F) -> T

Source§

impl<F, I> ExpectInto<I> for F
where I: ExpectFrom<F>,

Source§

fn expect_into(self) -> I

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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