pub struct Client { /* private fields */ }Expand description
Wrap json_client send request between nodes or browsers.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(endpoint_url: &str) -> Result<Self>
pub fn new(endpoint_url: &str) -> Result<Self>
Creates a new Client instance with the specified endpoint URL and signature.
Sourcepub async fn connect_peer_via_http(
&mut self,
url: &str,
) -> Result<ClientOutput<String>>
pub async fn connect_peer_via_http( &mut self, url: &str, ) -> Result<ClientOutput<String>>
Establishes a WebRTC connection with a remote peer using HTTP as the signaling channel.
This function allows two peers to establish a WebRTC connection using HTTP, which can be useful in scenarios where a direct peer-to-peer connection is not possible due to firewall restrictions or other network issues. The function sends ICE candidates and Session Description Protocol (SDP) messages over HTTP as a form of signaling to establish the connection.
Takes a URL for an HTTP server that will be used as the signaling channel to exchange ICE candidates and SDP with the remote peer. Returns a Did that can be used to refer to this connection in subsequent WebRTC operations.
Sourcepub async fn connect_with_seed(
&mut self,
source: &str,
) -> Result<ClientOutput<()>>
pub async fn connect_with_seed( &mut self, source: &str, ) -> Result<ClientOutput<()>>
Attempts to connect to a peer using a seed file located at the specified source path.
Sourcepub async fn connect_with_did(&mut self, did: &str) -> Result<ClientOutput<()>>
pub async fn connect_with_did(&mut self, did: &str) -> Result<ClientOutput<()>>
Attempts to connect to a peer using a DID stored in a Distributed Hash Table (DHT).
Sourcepub async fn list_peers(&mut self) -> Result<ClientOutput<()>>
pub async fn list_peers(&mut self) -> Result<ClientOutput<()>>
Lists all connected peers and their status.
Returns an Output containing a formatted string representation of the list of peers if successful, or an anyhow::Error if an error occurred.
Sourcepub async fn disconnect(&mut self, did: &str) -> Result<ClientOutput<()>>
pub async fn disconnect(&mut self, did: &str) -> Result<ClientOutput<()>>
Disconnects from the peer with the specified DID.
Sourcepub async fn send_message(
&self,
did: &str,
namespace: &str,
data: &str,
) -> Result<ClientOutput<()>>
pub async fn send_message( &self, did: &str, namespace: &str, data: &str, ) -> Result<ClientOutput<()>>
Sends a namespaced message to the specified peer, routed to the peer’s protocol
registered under namespace (the extension Envelope model).
Sourcepub async fn register_service(&self, name: &str) -> Result<ClientOutput<()>>
pub async fn register_service(&self, name: &str) -> Result<ClientOutput<()>>
Registers a new service with the given name.
Sourcepub async fn lookup_service(&self, name: &str) -> Result<ClientOutput<()>>
pub async fn lookup_service(&self, name: &str) -> Result<ClientOutput<()>>
Looks up the DIDs of services registered with the given name.
Sourcepub async fn publish_message_to_topic(
&self,
topic: &str,
data: &str,
) -> Result<ClientOutput<()>>
pub async fn publish_message_to_topic( &self, topic: &str, data: &str, ) -> Result<ClientOutput<()>>
Publishes a message to the specified topic.
Sourcepub async fn subscribe_topic<'a, 'b>(
&'a self,
topic: String,
) -> impl Stream<Item = String> + 'bwhere
'a: 'b,
pub async fn subscribe_topic<'a, 'b>(
&'a self,
topic: String,
) -> impl Stream<Item = String> + 'bwhere
'a: 'b,
Subscribes to the specified topic and returns a stream of messages published to the topic.
Sourcepub async fn inspect(&self) -> Result<ClientOutput<SwarmInfo>>
pub async fn inspect(&self) -> Result<ClientOutput<SwarmInfo>>
Query for swarm inspect info.
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for T
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.