pub struct Swarm { /* private fields */ }Expand description
The transport and dht management.
Implementations§
Source§impl Swarm
impl Swarm
Sourcepub fn account_pubkey(&self) -> Result<PublicKey<33>, Error>
pub fn account_pubkey(&self) -> Result<PublicKey<33>, Error>
Get the local account public key used for E2E public-key negotiation.
Sourcepub fn account_verification_pubkey(
&self,
) -> Result<VerificationPublicKey, Error>
pub fn account_verification_pubkey( &self, ) -> Result<VerificationPublicKey, Error>
Get the typed account verification public key.
Sourcepub fn network_id(&self) -> u32
pub fn network_id(&self) -> u32
Get this swarm’s network id.
Sourcepub fn storage_redundancy(&self) -> u16
pub fn storage_redundancy(&self) -> u16
Get the storage redundancy for this swarm’s DHT protocol mode.
Sourcepub fn dht_virtual_nodes(&self) -> u16
pub fn dht_virtual_nodes(&self) -> u16
Get the storage virtual-node positions for this swarm’s DHT protocol mode.
Sourcepub fn dht_protocol_mode(&self) -> DhtProtocolMode
pub fn dht_protocol_mode(&self) -> DhtProtocolMode
Get this swarm’s full DHT protocol mode descriptor.
Sourcepub fn set_callback(
&self,
callback: Arc<dyn SwarmCallback + Sync + Send>,
) -> Result<(), Error>
pub fn set_callback( &self, callback: Arc<dyn SwarmCallback + Sync + Send>, ) -> Result<(), Error>
Set callback for swarm.
Sourcepub fn stabilizer(&self) -> Stabilizer
pub fn stabilizer(&self) -> Stabilizer
Create Stabilizer for swarm.
Sourcepub async fn disconnect(&self, peer: Did) -> Result<(), Error>
pub async fn disconnect(&self, peer: Did) -> Result<(), Error>
Disconnect a connection. There are three steps:
- remove from DHT;
- remove from Transport;
- close the connection;
Sourcepub async fn connect(&self, peer: Did) -> Result<(), Error>
pub async fn connect(&self, peer: Did) -> Result<(), Error>
Start a non-routable handshake with a peer.
The peer becomes visible through the connection inspection APIs only after its data channel opens and the swarm admits it to the DHT.
Sourcepub async fn send_message(
&self,
msg: Message,
destination: Did,
) -> Result<Uuid, Error>
pub async fn send_message( &self, msg: Message, destination: Did, ) -> Result<Uuid, Error>
Send Message to peer.
Sourcepub async fn send_direct_message(
&self,
msg: Message,
destination: Did,
) -> Result<Uuid, Error>
pub async fn send_direct_message( &self, msg: Message, destination: Did, ) -> Result<Uuid, Error>
Send a message directly to an already connected peer, without a Chord lookup.
This preserves an application protocol’s explicit next-hop selection. Callers must ensure the destination has an active direct transport connection.
Sourcepub fn peers(&self) -> Vec<ConnectionInspect>
pub fn peers(&self) -> Vec<ConnectionInspect>
List active, routable peers and their connection status.
Sourcepub fn connected_peer_dids(&self) -> Vec<Did>
pub fn connected_peer_dids(&self) -> Vec<Did>
List DIDs whose direct WebRTC transport connection is active.
Sourcepub async fn peer_measurement(&self, peer: Did) -> Option<PeerMeasurement>
pub async fn peer_measurement(&self, peer: Did) -> Option<PeerMeasurement>
Return local measurement counters for peer, if observed.
Sourcepub async fn peer_measurements(&self) -> Vec<PeerMeasurement>
pub async fn peer_measurements(&self) -> Vec<PeerMeasurement>
Return every retained local peer measurement.
Sourcepub async fn peer_measurements_page(
&self,
after: Option<Did>,
limit: NonZero<usize>,
) -> PeerMeasurementPage
pub async fn peer_measurements_page( &self, after: Option<Did>, limit: NonZero<usize>, ) -> PeerMeasurementPage
Return one bounded page of retained local peer measurements.
Sourcepub async fn inspect(&self) -> SwarmInspect
pub async fn inspect(&self) -> SwarmInspect
Check the status of swarm
Source§impl Swarm
impl Swarm
Sourcepub async fn create_offer(&self, peer: Did) -> Result<MessagePayload, Error>
pub async fn create_offer(&self, peer: Did) -> Result<MessagePayload, Error>
Create new connection and its answer. This function will wrap the offer inside a payload with verification.
Sourcepub async fn answer_offer(
&self,
offer_payload: MessagePayload,
) -> Result<MessagePayload, Error>
pub async fn answer_offer( &self, offer_payload: MessagePayload, ) -> Result<MessagePayload, Error>
Answer the offer of remote connection. This function will verify the answer payload and will wrap the answer inside a payload with verification.
Sourcepub async fn accept_answer(
&self,
answer_payload: MessagePayload,
) -> Result<(), Error>
pub async fn accept_answer( &self, answer_payload: MessagePayload, ) -> Result<(), Error>
Accept the answer of remote connection. This function will verify the answer payload and will return its did with the connection.
Trait Implementations§
Source§impl<const REDUNDANT: u16> ChordStorageInterface<REDUNDANT> for Swarm
impl<const REDUNDANT: u16> ChordStorageInterface<REDUNDANT> for Swarm
Source§fn storage_fetch<'life0, 'async_trait>(
&'life0 self,
entry_key: Did,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn storage_fetch<'life0, 'async_trait>(
&'life0 self,
entry_key: Did,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Swarm: 'async_trait,
Fetch an entry. If it exists in local storage, copy it to the cache; otherwise query the responsible remote node.
Source§fn storage_store<'life0, 'async_trait>(
&'life0 self,
entry: Entry,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn storage_store<'life0, 'async_trait>(
&'life0 self,
entry: Entry,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Swarm: 'async_trait,
Store Entry, TryInto<Entry> is implemented for alot of types
Source§fn storage_append_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
fn storage_append_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
Source§fn storage_touch_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
fn storage_touch_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
Source§fn storage_tombstone_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
fn storage_tombstone_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
data: Encoded,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
Source§fn storage_compact_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
removals: Vec<Encoded>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
fn storage_compact_data<'life0, 'life1, 'async_trait>(
&'life0 self,
topic: &'life1 str,
removals: Vec<Encoded>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
Auto Trait Implementations§
impl !Freeze for Swarm
impl !RefUnwindSafe for Swarm
impl !UnwindSafe for Swarm
impl Send for Swarm
impl Sync for Swarm
impl Unpin for Swarm
impl UnsafeUnpin for Swarm
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.