Skip to main content

ClientRef

Struct ClientRef 

Source
pub struct ClientRef<'r> { /* private fields */ }
Expand description

A strong reference to Client

It contains a phantom reference, to avoid attempts of storing it anywhere.

Implementations§

Source§

impl ClientRef<'_>

Source

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

Connect to a peer using the shared connection cache

Returns a cached connection if available, otherwise creates a new one. This is more efficient than connect_uncached when making repeated connections to the same peer.

Methods from Deref<Target = 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 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 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>

Trait Implementations§

Source§

impl<'r> Clone for ClientRef<'r>

Source§

fn clone(&self) -> Self

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

impl Deref for ClientRef<'_>

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for ClientRef<'r>

§

impl<'r> !UnwindSafe for ClientRef<'r>

§

impl<'r> Freeze for ClientRef<'r>

§

impl<'r> Send for ClientRef<'r>

§

impl<'r> Sync for ClientRef<'r>

§

impl<'r> Unpin for ClientRef<'r>

§

impl<'r> UnsafeUnpin for ClientRef<'r>

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> 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> 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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = !

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