Struct rings_core::swarm::Swarm
source · pub struct Swarm { /* private fields */ }Expand description
The transport and dht management.
Implementations§
source§impl Swarm
impl Swarm
sourcepub fn set_callback(&self, callback: SharedSwarmCallback) -> Result<()>
pub fn set_callback(&self, callback: SharedSwarmCallback) -> Result<()>
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<()>
pub async fn disconnect(&self, peer: Did) -> Result<()>
Disconnect a connection. There are three steps:
- remove from DHT;
- remove from Transport;
- close the connection;
sourcepub async fn connect(&self, peer: Did) -> Result<()>
pub async fn connect(&self, peer: Did) -> Result<()>
Connect a given Did. If the did is already connected, return directly, else try prepare offer and establish connection by dht. This function may returns a pending connection or connected connection.
sourcepub async fn send_message(&self, msg: Message, destination: Did) -> Result<Uuid>
pub async fn send_message(&self, msg: Message, destination: Did) -> Result<Uuid>
Send Message to peer.
sourcepub fn peers(&self) -> Vec<ConnectionInspect>
pub fn peers(&self) -> Vec<ConnectionInspect>
List peers and their connection status.
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>
pub async fn create_offer(&self, peer: Did) -> Result<MessagePayload>
Creaet 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>
pub async fn answer_offer( &self, offer_payload: MessagePayload ) -> Result<MessagePayload>
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<()>
pub async fn accept_answer(&self, answer_payload: MessagePayload) -> Result<()>
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,
vid: Did
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn storage_fetch<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch virtual node, if exist in localstoreage, copy it to the cache, else Query Remote Node
source§fn storage_store<'life0, 'async_trait>(
&'life0 self,
vnode: VirtualNode
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn storage_store<'life0, 'async_trait>(
&'life0 self,
vnode: VirtualNode
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store VirtualNode, TryInto<VirtualNode> is implemented for alot of types
source§impl ChordStorageInterfaceCacheChecker for Swarm
impl ChordStorageInterfaceCacheChecker for Swarm
source§fn storage_check_cache<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Option<VirtualNode>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn storage_check_cache<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Option<VirtualNode>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check local cache
source§impl<const REDUNDANT: u16> SubringInterface<REDUNDANT> for Swarm
impl<const REDUNDANT: u16> SubringInterface<REDUNDANT> for Swarm
source§fn subring_join<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn subring_join<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
add did into current chord subring.
send direct message with JoinSubring type, which will handled by next node.
Auto Trait Implementations§
impl !Freeze for Swarm
impl !RefUnwindSafe for Swarm
impl Send for Swarm
impl Sync for Swarm
impl Unpin for Swarm
impl !UnwindSafe for Swarm
Blanket Implementations§
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
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 more